订单评论状态接口

This commit is contained in:
wangtongzhou 2019-06-13 08:32:22 +08:00
parent 9b08c5918c
commit e7c9464804
14 changed files with 242 additions and 28 deletions

View File

@ -7,8 +7,12 @@ import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO; import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO; import cn.iocoder.mall.order.api.bo.OrderCommentInfoAndMerchantReplyBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO; import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO; import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO; import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
import cn.iocoder.mall.user.sdk.annotation.RequiresLogin;
import cn.iocoder.mall.user.sdk.context.UserSecurityContextHolder;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference; import org.apache.dubbo.config.annotation.Reference;
@ -39,20 +43,20 @@ public class OrderCommentController {
@PostMapping("create_order_comment") @PostMapping("create_order_comment")
//@RequiresLogin //@RequiresLogin
@ApiOperation(value = "创建订单") @ApiOperation(value = "创建订单评论")
public CommonResult<OrderCommentCreateBO> createOrder(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) { public CommonResult<OrderCommentCreateBO> createOrderComment(@RequestBody @Validated OrderCommentCreateDTO orderCommentCreateDTO) {
Integer userId = UserSecurityContextHolder.getContext().getUserId();
orderCommentCreateDTO.setUserId(userId);
return success(orderCommentService.createOrderComment(orderCommentCreateDTO)); return success(orderCommentService.createOrderComment(orderCommentCreateDTO));
} }
@GetMapping("order_comment_page") @GetMapping("order_comment_page")
//@RequiresLogin
@ApiOperation(value = "获取评论分页") @ApiOperation(value = "获取评论分页")
public CommonResult<OrderCommentPageBO> getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){ public CommonResult<OrderCommentPageBO> getOrderCommentPage(@Validated OrderCommentPageDTO orderCommentPageDTO){
return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO)); return success(orderCommentService.getOrderCommentPage(orderCommentPageDTO));
} }
@GetMapping("order_comment_info_merchant_reply") @GetMapping("order_comment_info_merchant_reply")
//@RequiresLogin
@ApiOperation(value = "获取评论和商家回复") @ApiOperation(value = "获取评论和商家回复")
public CommonResult<OrderCommentInfoAndMerchantReplyBO> geOrderCommentInfoAndMerchantReply(@RequestParam("commentId") Integer commentId){ public CommonResult<OrderCommentInfoAndMerchantReplyBO> geOrderCommentInfoAndMerchantReply(@RequestParam("commentId") Integer commentId){
OrderCommentInfoAndMerchantReplyBO orderCommentInfoAndMerchantReplyBO=new OrderCommentInfoAndMerchantReplyBO(); OrderCommentInfoAndMerchantReplyBO orderCommentInfoAndMerchantReplyBO=new OrderCommentInfoAndMerchantReplyBO();
@ -61,4 +65,14 @@ public class OrderCommentController {
return success(orderCommentInfoAndMerchantReplyBO); return success(orderCommentInfoAndMerchantReplyBO);
} }
@GetMapping
//@RequiresLogin
@ApiOperation(value = "获取订单评论状态分页")
public CommonResult<OrderCommentStateInfoPageBO> getOrderCommentStateInfoPage(@Validated OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO){
//Integer userId = UserSecurityContextHolder.getContext().getUserId();
//orderCommentStateInfoPageDTO.setUserId(userId);
return success(orderCommentService.getOrderCommentStateInfoPage(orderCommentStateInfoPageDTO));
}
} }

View File

@ -3,8 +3,10 @@ package cn.iocoder.mall.order.api;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO; import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO; import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO; import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO; import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO; import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
/** /**
* 订单评论模块 * 订单评论模块
@ -39,6 +41,12 @@ public interface OrderCommentService {
OrderCommentInfoBO getOrderCommentInfo(Integer commentId); OrderCommentInfoBO getOrderCommentInfo(Integer commentId);
/**
* 获取订单评论状态详情
* @param orderCommentStateInfoPageDTO
* @return
*/
OrderCommentStateInfoPageBO getOrderCommentStateInfoPage(OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO);
/** /**
* 订单评价超时自动好评 * 订单评价超时自动好评

View File

@ -21,4 +21,5 @@ public class OrderCommentCreateBO implements Serializable {
* 订单评论 id * 订单评论 id
*/ */
private Integer id; private Integer id;
} }

View File

@ -4,6 +4,7 @@ package cn.iocoder.mall.order.api.bo;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
@ -16,7 +17,7 @@ import java.util.Date;
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class OrderCommentInfoBO { public class OrderCommentInfoBO implements Serializable {
/** /**
* 评论 id * 评论 id
@ -52,7 +53,7 @@ public class OrderCommentInfoBO {
/** /**
* 点赞数 * 点赞数
*/ */
private Integer collectCount; private Integer likeCount;
/** /**
* 创建时间 * 创建时间

View File

@ -4,6 +4,7 @@ package cn.iocoder.mall.order.api.bo;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -17,7 +18,7 @@ import java.util.List;
*/ */
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
public class OrderCommentReplyPageBO { public class OrderCommentReplyPageBO implements Serializable {
/** /**
* 评论回复总数 * 评论回复总数

View File

@ -0,0 +1,87 @@
package cn.iocoder.mall.order.api.bo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*
* 订单评论状态详情分页(这么设计因为这个接口需要登陆以后才能看到所以与订单分页接口分开)
*
* @author wtz
* @time 2019-06-07 10:39
*/
@Data
@Accessors(chain = true)
public class OrderCommentStateInfoPageBO implements Serializable {
/**
* (/)评论总数
*/
private Integer total;
/**
* 评论状态
*/
private List<OrderCommentStateInfoItem> orderCommentStateInfoItems;
@Data
@Accessors(chain = true)
public static class OrderCommentStateInfoItem{
/**
* 订单 id
*/
private Integer orderId;
/**
* 订单编号
*/
private String orderNo;
/**
* 商品 id
*/
private Integer productSpuId;
/**
* 商品名称
*/
private String productSpuName;
/**
* 商品 sku id
*/
private Integer productSkuId;
/**
* 商品 sku 属性
*/
private String productSkuAttrs;
/**
* 商品 sku 价格
*/
private Integer productSkuPrice;
/**
* 商品 sku url
*/
private String productSkuPicUrl;
/**
* 订单评论状态
*/
private Integer commentState;
/**
* 创建时间
*/
private Date createTime;
}
}

View File

@ -55,7 +55,6 @@ public class OrderCommentCreateDTO implements Serializable {
private String productSkuPicUrl; private String productSkuPicUrl;
@ApiModelProperty(value = "用户 id", required = true) @ApiModelProperty(value = "用户 id", required = true)
@NotNull(message = "用户 id 不能为空")
private Integer userId; private Integer userId;
@ApiModelProperty(value = "用户头像", required = true) @ApiModelProperty(value = "用户头像", required = true)

View File

@ -0,0 +1,38 @@
package cn.iocoder.mall.order.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
*
* 订单评论状态分页信息 query
*
* @author wtz
* @time 2019-06-07 10:45
*/
@Data
@Accessors(chain = true)
public class OrderCommentStateInfoPageDTO implements Serializable {
/**
* 用户 id
*/
private Integer userId;
/**
* 评论状态
*/
private Integer commentState;
/**
* 页码
*/
private Integer pageNo;
/**
* 每页条数
*/
private Integer pageSize;
}

View File

@ -2,7 +2,7 @@ package cn.iocoder.mall.order.biz.convert;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO; import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO; import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO; import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO; import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO; import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
@ -12,10 +12,11 @@ import org.mapstruct.factory.Mappers;
import java.util.List; import java.util.List;
/** /**
*
* 订单评论 convert * 订单评论 convert
* *
* @author wtz * @author wtz
* @time 2019-05-30 18:30 * @time 2019-05-31 18:30
*/ */
@Mapper @Mapper
public interface OrderCommentConvert { public interface OrderCommentConvert {
@ -23,12 +24,20 @@ public interface OrderCommentConvert {
OrderCommentConvert INSTANCE = Mappers.getMapper(OrderCommentConvert.class); OrderCommentConvert INSTANCE = Mappers.getMapper(OrderCommentConvert.class);
@Mappings({}) @Mappings({})
OrderCommentDO convert(OrderCommentCreateDTO orderCommentCreateDTO); OrderCommentStateInfoPageBO.OrderCommentStateInfoItem convertOrderCommentStateInfoItem(OrderCommentDO orderCommentDO);
@Mappings({}) @Mappings({})
OrderCommentCreateBO convert(OrderCommentDO orderCommentDO); List<OrderCommentStateInfoPageBO.OrderCommentStateInfoItem> convertOrderCommentStateInfoItems(List<OrderCommentDO> orderCommentDOList);
@Mappings({})
OrderCommentDO convertOrderCommentDO(OrderCommentCreateDTO orderCommentCreateDTO);
@Mappings({})
OrderCommentCreateBO convertOrderCommentCreateBO(OrderCommentDO orderCommentDO);
@Mappings({}) @Mappings({})
OrderCommentInfoBO convertOrderCommentInfoBO(OrderCommentDO orderCommentDO); OrderCommentInfoBO convertOrderCommentInfoBO(OrderCommentDO orderCommentDO);
} }

View File

@ -9,7 +9,6 @@ import org.mapstruct.Mapper;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import javax.validation.constraints.Max;
import java.util.List; import java.util.List;
/** /**

View File

@ -1,10 +1,8 @@
package cn.iocoder.mall.order.biz.dao; package cn.iocoder.mall.order.biz.dao;
import cn.iocoder.mall.order.api.bo.OrderCommentReplyCreateBO;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO; import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO; import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -53,5 +51,22 @@ public interface OrderCommentMapper{
OrderCommentDO selectCommentInfoByCommentId(@Param("id") Integer id); OrderCommentDO selectCommentInfoByCommentId(@Param("id") Integer id);
/**
* 订单评论状态信息详情
* @param orderCommentStateInfoPageDTO
* @return
*/
List<OrderCommentDO> selectOrderCommentStateInfoPage(OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO);
/**
* 订单评论状态总数
* @param userId,commentState
* @return
*/
int selectOrderCommentStateInfoTotal(@Param("userId") Integer userId,
@Param("commentState") Integer commentState);
} }

View File

@ -12,9 +12,9 @@ import lombok.experimental.Accessors;
* @time 2019-05-14 20:48 * @time 2019-05-14 20:48
* *
*/ */
@TableName(value = "order_comment")
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@TableName(value = "order_comment")
public class OrderCommentDO extends BaseDO { public class OrderCommentDO extends BaseDO {
/** /**
@ -117,4 +117,9 @@ public class OrderCommentDO extends BaseDO {
*/ */
private String commentPics; private String commentPics;
/**
* 订单评论状态
*/
private Integer commentState;
} }

View File

@ -4,9 +4,11 @@ import cn.iocoder.mall.order.api.OrderCommentService;
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO; import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO; import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO; import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum; import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO; import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO; import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
import cn.iocoder.mall.order.biz.convert.OrderCommentConvert; import cn.iocoder.mall.order.biz.convert.OrderCommentConvert;
import cn.iocoder.mall.order.biz.dao.OrderCommentMapper; import cn.iocoder.mall.order.biz.dao.OrderCommentMapper;
import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper; import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper;
@ -37,19 +39,13 @@ public class OrderCommentServiceImpl implements OrderCommentService {
private OrderCommentReplayMapper orderCommentReplayMapper; private OrderCommentReplayMapper orderCommentReplayMapper;
@Autowired
private OrderCommentService orderCommentService;
@Override @Override
public OrderCommentCreateBO createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO) { public OrderCommentCreateBO createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO) {
//首先判断订单状态是否处于待评价状态 OrderCommentDO orderCommentDO=OrderCommentConvert.INSTANCE.convertOrderCommentDO(orderCommentCreateDTO);
//接下来就是入库
OrderCommentDO orderCommentDO=OrderCommentConvert.INSTANCE.convert(orderCommentCreateDTO);
orderCommentDO.setCreateTime(new Date()); orderCommentDO.setCreateTime(new Date());
orderCommentDO.setUpdateTime(new Date()); orderCommentDO.setUpdateTime(new Date());
orderCommentMapper.insert(orderCommentDO); orderCommentMapper.insert(orderCommentDO);
return OrderCommentConvert.INSTANCE.convert(orderCommentDO); return OrderCommentConvert.INSTANCE.convertOrderCommentCreateBO(orderCommentDO);
} }
@Override @Override
@ -84,6 +80,22 @@ public class OrderCommentServiceImpl implements OrderCommentService {
return OrderCommentConvert.INSTANCE.convertOrderCommentInfoBO(orderCommentDO); return OrderCommentConvert.INSTANCE.convertOrderCommentInfoBO(orderCommentDO);
} }
@Override
public OrderCommentStateInfoPageBO getOrderCommentStateInfoPage(OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO) {
OrderCommentStateInfoPageBO orderCommentStateInfoPageBO=new OrderCommentStateInfoPageBO();
//总数
int total=orderCommentMapper.selectOrderCommentStateInfoTotal(orderCommentStateInfoPageDTO.getUserId(),
orderCommentStateInfoPageDTO.getCommentState());
//查询评论状态详情
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectOrderCommentStateInfoPage(orderCommentStateInfoPageDTO);
//转化评论状态详情
List<OrderCommentStateInfoPageBO.OrderCommentStateInfoItem> orderCommentStateInfoItemList=
OrderCommentConvert.INSTANCE.convertOrderCommentStateInfoItems(orderCommentDOList);
orderCommentStateInfoPageBO.setTotal(total);
orderCommentStateInfoPageBO.setOrderCommentStateInfoItems(orderCommentStateInfoItemList);
return orderCommentStateInfoPageBO;
}
@Override @Override
public Boolean OrderCommentTimeOutProductCommentTask() { public Boolean OrderCommentTimeOutProductCommentTask() {
return null; return null;

View File

@ -5,17 +5,17 @@
<sql id="FIELDS"> <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, 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, 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 comment_pics,comment_state,create_time,update_time
</sql> </sql>
<!--插入--> <!--插入-->
<insert id="insert" parameterType="OrderCommentDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> <insert id="insert" parameterType="OrderCommentDO" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO order_comment(order_id,order_no,product_spu_id,product_spu_name,product_sku_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_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) product_description_star,logistics_star,merchant_star,comment_content,comment_pics,comment_state,create_time,update_time)
VALUES (#{orderId},#{orderNo},#{productSpuId},#{productSpuName},#{productSkuId},#{productSkuAttrs}, VALUES (#{orderId},#{orderNo},#{productSpuId},#{productSpuName},#{productSkuId},#{productSkuAttrs},
#{productSkuPrice},#{productSkuPicUrl},#{userId},#{userAvatar},#{userNickName},#{star}, #{productSkuPrice},#{productSkuPicUrl},#{userId},#{userAvatar},#{userNickName},#{star},
#{productDescriptionStar},#{logisticsStar},#{merchantStar},#{commentContent},#{commentPics},#{createTime}, #{updateTime}); #{productDescriptionStar},#{logisticsStar},#{merchantStar},#{commentContent},#{commentPics},#{commentState},#{createTime}, #{updateTime});
</insert> </insert>
<!--根据 sku id 获取评论总数--> <!--根据 sku id 获取评论总数-->
@ -47,4 +47,29 @@
id = #{id} id = #{id}
</select> </select>
<!--分页获取订单评论状态信息详情-->
<select id="selectOrderCommentStateInfoPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
SELECT
<include refid="FIELDS" />
FROM order_comment
WHERE
user_id = #{userId}
AND
comment_state = #{commentState}
ORDER BY create_time DESC
LIMIT ${pageNo*pageSize},${pageSize}
</select>
<!--获取订单评论状态信息详情总数-->
<select id="selectOrderCommentStateInfoTotal" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM order_comment
WHERE
user_id = #{userId}
AND
comment_state = #{commentState}
</select>
</mapper> </mapper>