订单评价和回复接口定义以及mapper实现

This commit is contained in:
wangtongzhou 2019-05-19 16:00:08 +08:00
parent 7905541501
commit 304c436e49
21 changed files with 581 additions and 242 deletions

View File

@ -0,0 +1,24 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
import java.util.List;
/**
*
* 订单评论回复模块
*
* @author wtz
* @time 2019-05-29 14:30
*
*/
public interface OrderCommentReplyService {
/**
* 分页获取评论回复
* @param orderCommentReplyPageDTO
* @return
*/
List<OrderCommentReplyPageBO> getOrderCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO);
}

View File

@ -1,11 +1,10 @@
package cn.iocoder.mall.order.api;
import cn.iocoder.common.framework.vo.CommonResult;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
/**
@ -21,7 +20,7 @@ public interface OrderCommentService {
* @param orderCommentCreateDTO
* @return
*/
CommonResult<OrderCommentCreateBO> createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO);
Boolean createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO);
/**
@ -29,22 +28,31 @@ public interface OrderCommentService {
* @param orderCommentReplyCreateDTO
* @return
*/
CommonResult<OrderCommentReplyCreateBO> createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO);
Boolean createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO);
/**
* 获取评论列表的分页
* @param productSpuId
* @param orderCommentPageDTO
* @return
*/
CommonResult<OrderCommentPageBO> getOrderCommentPage(Integer productSpuId);
OrderCommentPageBO getOrderCommentPage(OrderCommentPageDTO orderCommentPageDTO);
/**
* 获取评论详情
* 获取评论详情和商家回复
* @param commentId
* @return
*/
CommonResult<OrderCommentInfoBO> getOrderCommentInfo(Integer commentId);
OrderCommentInfoAndMerchantReplyBO getOrderCommentInfo(Integer commentId, Integer userType);
/**
* 订单评价超时自动好评
* 采用任务的形式执行
* @return
*/
Boolean OrderCommentTimeOutProductCommentTask();

View File

@ -16,7 +16,7 @@ import java.util.List;
*/
@Data
@Accessors(chain = true)
public class OrderCommentBo implements Serializable {
public class OrderCommentBO implements Serializable {
/**
* 总条数
@ -39,7 +39,7 @@ public class OrderCommentBo implements Serializable {
private Integer negativeTotal;
/**
* 评论id
* 评论 id
*/
private Integer id;

View File

@ -1,23 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
/**
*
* 订单评论创建
*
* @author wtz
* @time 2019-05-15 20:35
*
*/
@Data
@Accessors(chain = true)
public class OrderCommentCreateBO {
/**
* 评论id
*/
private Integer id;
}

View File

@ -0,0 +1,99 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
*
* 订单回复评价详情和商加回复
*
* @author wtz
* @time 2019-05-16 18:40
*
*/
public class OrderCommentInfoAndMerchantReplyBO {
/**
* 评论 id
*/
private Integer id;
/**
* 用户头像
*/
private String userAvatar;
/**
* 用户昵称
*/
private String userNickName;
/**
* 评价星
*/
private Integer star;
/**
* 评论的内容
*/
private String commentContent;
/**
* 评论的图片地址
*/
private String commentPics;
/**
* 点赞数
*/
private Integer collectCount;
/**
* 创建时间
*/
private Date createTime;
/**
* 商品 sku id
*/
private int productSkuId;
/**
* 商品 sku 属性
*/
private String productSkuAttrs;
/**
* 商品 sku 价格
*/
private String productSkuPrice;
/**
* 商品 sku 地址
*/
private String productSkuPicUrl;
/**
* 商家回复
*/
List<OrderCommentReplayMerchantItem> orderCommentReplayMerchantItems;
@Data
@Accessors(chain = true)
private static class OrderCommentReplayMerchantItem{
/**
* 回复的内容
*/
private String replyContent;
}
}

View File

@ -1,158 +0,0 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
*
* 订单回复评价详情
*
* @author wtz
* @time 2019-05-16 18:40
*
*/
public class OrderCommentInfoBO {
/**
* 评论id
*/
private Integer id;
/**
* 用户头像
*/
private String userAvatar;
/**
* 用户的真实姓名
*/
private String userNickName;
/**
* 评价星
*/
private Integer star;
/**
* 评论的内容
*/
private String commentContent;
/**
* 评论的图片地址
*/
private String commentPics;
/**
* 回复条数
*/
private Integer replayCount;
/**
* 点赞数
*/
private Integer collectCount;
/**
* 创建时间
*/
private Date createTime;
/**
* 商品SKUid
*/
private int productSkuId;
/**
* 商品SKU属性
*/
private String productSkuAttrs;
/**
* 商品SKU价格
*/
private String productSkuPrice;
/**
* 商品SKU地址
*/
private String productSkuPicUrl;
/**
* 商家回复
*/
List<OrderCommentReplayMerchantItem> orderCommentReplayMerchantItems;
/**
* 用户回复
*/
List<OrderCommentReplayUserItem> orderCommentReplayUserItems;
@Data
@Accessors(chain = true)
private static class OrderCommentReplayMerchantItem{
/**
* 回复的内容
*/
private String replyContent;
}
@Data
@Accessors(chain = true)
private static class OrderCommentReplayUserItem{
/**
* 回复id
*/
private Integer id;
/**
* 回复的类型
*/
private Integer replyType;
/**
* 回复的内容
*/
private String replyContent;
/**
* 回复的用户id
*/
private int replyUserId;
/**
* 回复用户的真实姓名
*/
private String replyUserNickName;
/**
* 回复用户的头像
*/
private String replyUserAvatar;
/**
* 回复的点赞数
*/
private int replyCollectCount;
/**
* 回复目标用户昵称
*/
private String parentUserNickName;
/**
* 创建时间
*/
private Date createTime;
}
}

View File

@ -49,7 +49,7 @@ public class OrderCommentPageBO implements Serializable {
@Accessors(chain = true)
private static class OrderCommentItem{
/**
* 评论id
* 评论 id
*/
private Integer id;

View File

@ -1,16 +0,0 @@
package cn.iocoder.mall.order.api.bo;
/**
*
* 评论回复创建
*
* @author wtz
* @time 2019-05-16 18:00:00
*/
public class OrderCommentReplyCreateBO {
/**
* 评论回复的id
*/
private Integer id;
}

View File

@ -0,0 +1,77 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.List;
/**
*
* 评论回复分页展示
*
* @author wtz
* @time 2019-05-19 14:19
*
*/
public class OrderCommentReplyPageBO {
private Integer total;
/**
* 用户回复
*/
List<OrderCommentReplayUserItem> orderCommentReplayUserItems;
@Data
@Accessors(chain = true)
private static class OrderCommentReplayUserItem{
/**
* 回复 id
*/
private Integer id;
/**
* 回复的类型
*/
private Integer replyType;
/**
* 回复的内容
*/
private String replyContent;
/**
* 回复的用户 id
*/
private int replyUserId;
/**
* 回复用户的真实姓名
*/
private String replyUserNickName;
/**
* 回复用户的头像
*/
private String replyUserAvatar;
/**
* 回复的点赞数
*/
private int replyCollectCount;
/**
* 回复目标用户昵称
*/
private String parentUserNickName;
/**
* 创建时间
*/
private Date createTime;
}
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.mall.order.api.constant;
/**
*
* 评论回复 - 回复的用户的类型
*
* @author wtz
* @time 2019-05-19 15:19
*/
public enum OrderReplyUserTypeEnum {
USER(1, "普通用户"),
MERCHANT(2, "商家");
/**
* 状态值
*/
private Integer value;
/**
* 状态名
*/
private String name;
OrderReplyUserTypeEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}

View File

@ -17,7 +17,7 @@ import java.io.Serializable;
public class OrderCommentCreateDTO implements Serializable {
/**
* 订单id
* 订单 id
*/
private int orderId;
@ -27,37 +27,37 @@ public class OrderCommentCreateDTO implements Serializable {
private String orderNo;
/**
* 商品SPU id
* 商品 spu id
*/
private int productSpuId;
/**
* 商品SPU 名字 SPU 这两个属性待考量我认为加入进去以后后期一些分析可能好做一些
* 商品 spu 名字 spu 这两个属性待考量我认为加入进去以后后期一些分析可能好做一些
*/
private String productSpuName;
/**
* 商品SKU id
* 商品 sku id
*/
private int productSkuId;
/**
* 商品SKU属性
* 商品 sku 属性
*/
private String productSkuAttrs;
/**
* 商品SKU价格
* 商品 sku 价格
*/
private int productSkuPrice;
/**
* 商品SKU地址
* 商品 sku 地址
*/
private String productSkuPicUrl;
/**
* 用户id
* 用户 id
*/
private Integer userId;
@ -95,4 +95,9 @@ public class OrderCommentCreateDTO implements Serializable {
* 评论内容
*/
private String commentContent;
/**
* 评论图片
*/
private String commentPics;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.mall.order.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
/**
*
* 订单评论 query
*
*/
@Data
@Accessors(chain = true)
public class OrderCommentPageDTO {
/**
* 商品 sku id
*/
private Integer productSkuId;
/**
* 页码
*/
private Integer pageNo;
/**
* 每页条数
*/
private Integer pageSize;
}

View File

@ -1,5 +1,8 @@
package cn.iocoder.mall.order.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
@ -10,20 +13,22 @@ import java.io.Serializable;
* @time 2019-05-16 19:07
*
*/
@Data
@Accessors(chain = true)
public class OrderCommentReplyCreateDTO implements Serializable {
/**
* 评论id
* 评论 id
*/
private Integer commentId;
/**
* 评论目标对象id
* 评论目标对象 id
*/
private Integer parentId;
/**
* 评论目标用户id
* 评论目标用户 id
*/
private Integer parentUserId;
@ -43,7 +48,7 @@ public class OrderCommentReplyCreateDTO implements Serializable {
private String replyContent;
/**
* 回复用户id
* 回复用户 id
*/
private Integer replyUserId;
@ -60,6 +65,6 @@ public class OrderCommentReplyCreateDTO implements Serializable {
/**
* 回复用户类型
*/
private Integer replyUserType;
private Integer userType;
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.mall.order.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Date;
/**
*
* 订单评论信息详情 query
*
* @author wtz
* @time 2019-05-19 10:16
*/
@Data
@Accessors(chain = true)
public class OrderCommentReplyPageDTO {
/**
* 评论 id
*/
private Integer commentId;
/**
* 用户类型
*/
private Integer userType;
/**
* 页码
*/
private Integer pageNo;
/**
* 每页条数
*/
private Integer pageSize;
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
*
* 订单评论 mapper
*
* @author wtz
* @time 2019-05-16 20:52
*/
@Repository
public interface OrderCommentMapper extends BaseMapper<OrderCommentDO> {
/**
* 插入订单评论
* @param orderCommentCreateDTO
* @return
*/
int insert(OrderCommentCreateDTO orderCommentCreateDTO);
/**
* 根据 sku id 查询评论总条数
* @param productSkuId
* @return
*/
int selectCommentTotalCountByProductSkuId(@Param("productSkuId") Integer productSkuId);
/**
* 根据 sku id 分页查询评论
* @param orderCommentPageDTO
* @return
*/
List<OrderCommentDO> selectCommentPage(OrderCommentPageDTO orderCommentPageDTO);
/**
* 根据评论 id 查询评论详情
* @param id
* @return
*/
OrderCommentDO selectCommentInfoByCommentId(@Param("id") Integer id);
}

View File

@ -0,0 +1,51 @@
package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.api.bo.OrderCommentBO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentReplyPageDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 订单评论回复 mapper
*
* @author wtz
* @time 2019-05-16 21:33
*/
public interface OrderCommentReplayMapper {
/**
* 插入订单评论回复
* @param orderCommentReplyCreateDTO
* @return
*/
int insert(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO);
/**
* 根据评论 id 和用户类型获取商家回复
* @param commentId,userType
* @return
*/
List<OrderCommentReplyDO> selectCommentMerchantReplyByCommentId(@Param("commentId") Integer commentId,
@Param("userType") Integer userType);
/**
* 评论回复分页
* @param orderCommentReplyPageDTO
* @return
*/
List<OrderCommentReplyDO> selectCommentReplyPage(OrderCommentReplyPageDTO orderCommentReplyPageDTO);
/**
* 根据评论 id 和用户类型获取评论回复总数
* @param commentId,userType
* @return
*/
int selectCommentReplyTotalCountByCommentId(@Param("commentId") Integer commentId,
@Param("userType") Integer userType);
}

View File

@ -8,7 +8,7 @@ import lombok.experimental.Accessors;
/**
* 订单评论表
*
* @author wtz
* @author wtz
* @time 2019-05-14 20:48
*
*/
@ -18,12 +18,12 @@ import lombok.experimental.Accessors;
public class OrderCommentDO extends BaseDO {
/**
* 评论id // TODO FROM 芋艿 TO wtz 中英文之间要有空格
* 评论 id // TODO FROM 芋艿 TO wtz 中英文之间要有空格
*/
private Integer id;
/**
* 订单id
* 订单 id
*/
private Integer orderId;
@ -33,7 +33,7 @@ public class OrderCommentDO extends BaseDO {
private String orderNo;
/**
* 商品id
* 商品 id
*/
private Integer productSpuId;
@ -43,22 +43,22 @@ public class OrderCommentDO extends BaseDO {
private String productSpuName;
/**
* 商品SKUid
* 商品 sku id
*/
private Integer productSkuId;
/**
* 商品SKU属性
* 商品 sku 属性
*/
private String productSkuAttrs;
/**
* 商品SKU价格
* 商品 sku 价格
*/
private Integer productSkuPrice;
/**
* 商品SKU URL
* 商品 sku url
*/
private String productSkuPicUrl;
@ -105,7 +105,7 @@ public class OrderCommentDO extends BaseDO {
/**
* 点赞数 // TODO FROM 芋艿 TO wtz collect 是收藏的意思最好换个单词噢
*/
private Integer collectCount;
private Integer likeCount;
/**
* 评论的内容

View File

@ -17,15 +17,15 @@ import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
@TableName(value = "order_comment_replay")
public class OrderCommentReplayDO extends BaseDO {
public class OrderCommentReplyDO extends BaseDO {
/**
* 回复id
* 回复 id
*/
private Integer id;
/**
* 评论id
* 评论 id
*/
private Integer commentId;
@ -35,12 +35,12 @@ public class OrderCommentReplayDO extends BaseDO {
private Integer replyType;
/**
* id
* id
*/
private Integer parentId;
/**
* 回复目标用户id
* 回复目标用户 id
*/
private Integer parentUserId;
@ -60,7 +60,7 @@ public class OrderCommentReplayDO extends BaseDO {
private String replyContent;
/**
* 回复用户id
* 回复用户 id
*/
private Integer replyUserId;
@ -77,11 +77,11 @@ public class OrderCommentReplayDO extends BaseDO {
/**
* 回复用户身份 // TODO FROM 芋艿 TO wtz 提示userType UserTypeEnum 记录保持一致
*/
private Integer replyUserType;
private Integer userType;
/**
* 回复点赞数
*/
private Integer replyCollectCount;
private Integer replyLikeCount;
}

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.OrderCommentMapper">
<sql id="FIELDS">
id,order_id,order_no,product_spu_id,product_spu_name,product_sku_id,product_sku_attrs,product_sku_price,product_sku_pic_url,
user_id,user_avatar,user_nick_name,star,product_description_star,logistics_star,merchant_star,replay_count,like_count,comment_content,
comment_pics,create_time,update_time
</sql>
<!--插入-->
<insert id="insert" parameterType="OrderCommentCreateDTO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO order_comment(order_id,order_no,product_spu_id,product_spu_name,product_sku_id,
product_sku_attrs,product_sku_price,product_sku_pic_url,user_id,user_avatar,user_nick_name,star,
product_description_star,logistics_star,merchant_star,comment_content,comment_pics,create_time,update_time)
VALUES (#{orderId},#{orderNo},#{productSpuId},#{productSpuName},#{productSkuId},#{productSkuAttrs},
#{productSkuPrice},#{productSkuPicUrl},#{userId},#{userAvatar},#{userNickName},#{star},
#{productDescriptionStar},#{logisticsStar},#{merchantStar},#{commentContent},#{commentPics},#{createTime}, #{updateTime});
</insert>
<!--根据 sku id 获取评论总数-->
<select id="selectCommentTotalCountByProductSkuId" parameterType="Integer" resultType="java.lang.Integer">
SELECT
COUNT (*)
FROM order_comment
WHERE
product_sku_id = #{productSkuId}
</select>
<!--分页获取评论分页-->
<select id="selectCommentPage" parameterType="OrderCommentQueryDTO" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
SELECT
<include refid="FIELDS" />
FROM order_comment
WHERE
product_sku_id = #{productSkuId}
ORDER BY create_time DESC
LIMIT ${pageNo * pageSize}, ${pageSize}
</select>
<!--根据评论 id 获取用户详情-->
<select id="selectCommentInfoByCommentId" parameterType="Integer" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
SELECT
<include refid="FIELDS" />
FROM order_comment
WHERE
id = #{id}
ORDER BY create_time DESC
LIMIT ${pageNo * pageSize}, ${pageSize}
</select>
</mapper>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper">
<sql id="FIELDS">
id,comment_id,reply_type,parent_id,parent_user_id,parent_user_nick_name,parent_user_avatar,reply_content,
reply_user_id,reply_user_nick_name,reply_user_avatar,user_type,reply_like_count,create_time,update_time
</sql>
<!--插入-->
<insert id="insert" parameterType="OrderCommentReplyCreateDTO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO `order_comment_replay`(comment_id,reply_type,parent_id,parent_user_id,parent_user_nick_name,parent_user_avatar,reply_content,reply_user_id
reply_user_nick_name,reply_user_avatar,user_type,create_time,update_time)
VALUES (#{commentId},#{replyType},#{parentId},#{parentUserId},#{parentUserNickName},#{parentUserAvatar},#{replyContent},#{replyUserId},
#{replyUserNickName},#{replyUserAvatar},#{userType},#{createTime},#{updateTime})
</insert>
<!--根据评论 id 和用户类型获取商家回复列表-->
<select id="selectCommentMerchantReplyByCommentId" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
SELECT
<include refid="FIELDS" />
FROM order_comment_replay
WHERE
comment_id = #{commentId}
AND
user_type = #{userType}
ORDER BY create_time DESC
</select>
<!--根据评论 id 和用户类型获取评论总数-->
<select id="selectCommentReplyTotalCountByCommentId" parameterType="Integer" resultType="java.lang.Integer">
SELECT
COUNT (*)
FROM order_comment_replay
WHERE
comment_id = #{commentId}
AND
user_type = #{userType}
</select>
<!--分页用户回复-->
<select id="selectCommentReplyPage" parameterType="OrderCommentReplyPageDTO" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO">
SELECT
<include refid="FIELDS" />
FROM order_comment_replay
WHERE
comment_id = #{commentId}
AND
user_type = #{userType}
ORDER BY create_time DESC
LIMIT ${pageNo * pageSize}, ${pageSize}
</select>
</mapper>

View File

@ -3,8 +3,7 @@
<mapper namespace="cn.iocoder.mall.order.biz.dao.OrderLogisticsDetailMapper">
<sql id="FIELDS">
id
,
id,
order_logistics_id,
logistics_time,
logistics_information,