Commit 1e1a22c256ea736ece7135a96b4430aaaab80464

Authored by YunaiV
1 parent 84b365a7

mall + product:评论的 review

Showing 17 changed files with 70 additions and 175 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java
@@ -35,6 +35,7 @@ public class ProductCommentController { @@ -35,6 +35,7 @@ public class ProductCommentController {
35 return success(ProductCommentConvert.INSTANCE.convertPage(pageResult)); 35 return success(ProductCommentConvert.INSTANCE.convertPage(pageResult));
36 } 36 }
37 37
  38 + // TODO @puhui999:update-visible
38 @PutMapping("/update/visible") 39 @PutMapping("/update/visible")
39 @Operation(summary = "显示 / 隐藏评论") 40 @Operation(summary = "显示 / 隐藏评论")
40 @PreAuthorize("@ss.hasPermission('product:comment:update')") 41 @PreAuthorize("@ss.hasPermission('product:comment:update')")
@@ -55,6 +56,7 @@ public class ProductCommentController { @@ -55,6 +56,7 @@ public class ProductCommentController {
55 @Operation(summary = "添加自评") 56 @Operation(summary = "添加自评")
56 @PreAuthorize("@ss.hasPermission('product:comment:update')") 57 @PreAuthorize("@ss.hasPermission('product:comment:update')")
57 public CommonResult<Boolean> createComment(@Valid @RequestBody ProductCommentCreateReqVO createReqVO) { 58 public CommonResult<Boolean> createComment(@Valid @RequestBody ProductCommentCreateReqVO createReqVO) {
  59 + // TODO @puhui999:不用 ProductCommentConvert.INSTANCE.convert(createReqVO) 哈;多写一个 create 方法即可;
58 productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(createReqVO), Boolean.TRUE); 60 productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(createReqVO), Boolean.TRUE);
59 return success(true); 61 return success(true);
60 } 62 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentBaseVO.java
@@ -10,6 +10,8 @@ import java.util.List; @@ -10,6 +10,8 @@ import java.util.List;
10 @Data 10 @Data
11 public class ProductCommentBaseVO { 11 public class ProductCommentBaseVO {
12 12
  13 + // TODO @puhui999:把 example 补充下
  14 +
13 @Schema(description = "评价人名称", required = true, example = "张三") 15 @Schema(description = "评价人名称", required = true, example = "张三")
14 @NotNull(message = "评价人名称不能为空") 16 @NotNull(message = "评价人名称不能为空")
15 private String userNickname; 17 private String userNickname;
@@ -18,34 +20,30 @@ public class ProductCommentBaseVO { @@ -18,34 +20,30 @@ public class ProductCommentBaseVO {
18 @NotNull(message = "评价人头像不能为空") 20 @NotNull(message = "评价人头像不能为空")
19 private String userAvatar; 21 private String userAvatar;
20 22
21 - @Schema(description = "商品SPU编号", required = true, example = "29502")  
22 - @NotNull(message = "商品SPU编号不能为空") 23 + @Schema(description = "商品 SPU 编号", required = true, example = "29502")
  24 + @NotNull(message = "商品 SPU 编号不能为空")
23 private Long spuId; 25 private Long spuId;
24 26
25 - @Schema(description = "商品SPU名称", required = true, example = "赵六")  
26 - @NotNull(message = "商品SPU名称不能为空") 27 + @Schema(description = "商品 SPU 名称", required = true, example = "赵六")
  28 + @NotNull(message = "商品 SPU 名称不能为空")
27 private String spuName; 29 private String spuName;
28 30
29 - @Schema(description = "商品SKU编号", required = true, example = "3082")  
30 - @NotNull(message = "商品SKU编号不能为空") 31 + @Schema(description = "商品 SKU 编号", required = true, example = "3082")
  32 + @NotNull(message = "商品 SKU 编号不能为空")
31 private Long skuId; 33 private Long skuId;
32 34
33 @Schema(description = "评分星级 1-5分", required = true) 35 @Schema(description = "评分星级 1-5分", required = true)
34 - @NotNull(message = "评分星级 1-5分不能为空") 36 + @NotNull(message = "评分星级不能为空")
35 private Integer scores; 37 private Integer scores;
36 38
37 @Schema(description = "描述星级 1-5分", required = true) 39 @Schema(description = "描述星级 1-5分", required = true)
38 - @NotNull(message = "描述星级 1-5分不能为空") 40 + @NotNull(message = "描述星级不能为空")
39 private Integer descriptionScores; 41 private Integer descriptionScores;
40 42
41 @Schema(description = "服务星级 1-5分", required = true) 43 @Schema(description = "服务星级 1-5分", required = true)
42 - @NotNull(message = "服务星级 1-5分不能为空") 44 + @NotNull(message = "服务星级分不能为空")
43 private Integer benefitScores; 45 private Integer benefitScores;
44 46
45 - @Schema(description = "配送星级 1-5分", required = true)  
46 - @NotNull(message = "配送星级 1-5分不能为空")  
47 - private Integer deliveryScores;  
48 -  
49 @Schema(description = "评论内容", required = true) 47 @Schema(description = "评论内容", required = true)
50 @NotNull(message = "评论内容不能为空") 48 @NotNull(message = "评论内容不能为空")
51 private String content; 49 private String content;
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyVO.java
@@ -4,8 +4,10 @@ import io.swagger.v3.oas.annotations.media.Schema; @@ -4,8 +4,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
4 import lombok.Data; 4 import lombok.Data;
5 import lombok.ToString; 5 import lombok.ToString;
6 6
  7 +import javax.validation.constraints.NotEmpty;
7 import javax.validation.constraints.NotNull; 8 import javax.validation.constraints.NotNull;
8 9
  10 +// TODO @puhui999:ReqVO
9 @Schema(description = "管理后台 - 商品评价可见修改 Request VO") 11 @Schema(description = "管理后台 - 商品评价可见修改 Request VO")
10 @Data 12 @Data
11 @ToString(callSuper = true) 13 @ToString(callSuper = true)
@@ -16,7 +18,7 @@ public class ProductCommentReplyVO { @@ -16,7 +18,7 @@ public class ProductCommentReplyVO {
16 private Long id; 18 private Long id;
17 19
18 @Schema(description = "商家回复内容", required = true, example = "谢谢亲") 20 @Schema(description = "商家回复内容", required = true, example = "谢谢亲")
19 - @NotNull(message = "商家回复内容不能为空") 21 + @NotEmpty(message = "商家回复内容不能为空")
20 private String replyContent; 22 private String replyContent;
21 23
22 } 24 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java
@@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode; @@ -6,7 +6,6 @@ import lombok.EqualsAndHashCode;
6 import lombok.ToString; 6 import lombok.ToString;
7 7
8 import java.time.LocalDateTime; 8 import java.time.LocalDateTime;
9 -import java.util.List;  
10 9
11 @Schema(description = "管理后台 - 商品评价 Response VO") 10 @Schema(description = "管理后台 - 商品评价 Response VO")
12 @Data 11 @Data
@@ -33,7 +32,7 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { @@ -33,7 +32,7 @@ public class ProductCommentRespVO extends ProductCommentBaseVO {
33 private Boolean visible; 32 private Boolean visible;
34 33
35 @Schema(description = "商家是否回复:[1:回复 0:未回复]", required = true) 34 @Schema(description = "商家是否回复:[1:回复 0:未回复]", required = true)
36 - private Boolean replied; 35 + private Boolean replyStatus;
37 36
38 @Schema(description = "回复管理员编号", example = "22212") 37 @Schema(description = "回复管理员编号", example = "22212")
39 private Long replyUserId; 38 private Long replyUserId;
@@ -44,15 +43,6 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { @@ -44,15 +43,6 @@ public class ProductCommentRespVO extends ProductCommentBaseVO {
44 @Schema(description = "商家回复时间") 43 @Schema(description = "商家回复时间")
45 private LocalDateTime replyTime; 44 private LocalDateTime replyTime;
46 45
47 - @Schema(description = "追加评价内容")  
48 - private String additionalContent;  
49 -  
50 - @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传9张")  
51 - private List<String> additionalPicUrls;  
52 -  
53 - @Schema(description = "追加评价时间")  
54 - private LocalDateTime additionalTime;  
55 -  
56 @Schema(description = "创建时间", required = true) 46 @Schema(description = "创建时间", required = true)
57 private LocalDateTime createTime; 47 private LocalDateTime createTime;
58 48
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentUpdateVisibleReqVO.java
@@ -15,7 +15,7 @@ public class ProductCommentUpdateVisibleReqVO { @@ -15,7 +15,7 @@ public class ProductCommentUpdateVisibleReqVO {
15 @NotNull(message = "评价编号不能为空") 15 @NotNull(message = "评价编号不能为空")
16 private Long id; 16 private Long id;
17 17
18 - @Schema(description = "是否可见 true:显示 false:隐藏", required = true, example = "false") 18 + @Schema(description = "是否可见", required = true, example = "false")
19 @NotNull(message = "是否可见不能为空") 19 @NotNull(message = "是否可见不能为空")
20 private Boolean visible; 20 private Boolean visible;
21 21
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppCommentController.java
@@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 import cn.iocoder.yudao.module.member.api.user.MemberUserApi; 5 import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
6 import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; 6 import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
7 -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentAdditionalReqVO;  
8 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentCreateReqVO; 7 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentCreateReqVO;
9 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; 8 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
10 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO; 9 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO;
@@ -22,6 +21,7 @@ import java.util.Map; @@ -22,6 +21,7 @@ import java.util.Map;
22 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 21 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
23 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; 22 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
24 23
  24 +// TODO @puhui999:AppCommentController =》 AppProductCommentController
25 @Tag(name = "用户 APP - 商品评价") 25 @Tag(name = "用户 APP - 商品评价")
26 @RestController 26 @RestController
27 @RequestMapping("/product/comment") 27 @RequestMapping("/product/comment")
@@ -40,8 +40,9 @@ public class AppCommentController { @@ -40,8 +40,9 @@ public class AppCommentController {
40 return success(productCommentService.getCommentPage(pageVO, Boolean.TRUE)); 40 return success(productCommentService.getCommentPage(pageVO, Boolean.TRUE));
41 } 41 }
42 42
  43 + // TODO @puhui999:方法名改成 getCommentStatistics?然后搞个对应的 vo?想了下,这样更优雅
43 @GetMapping("/get-count") 44 @GetMapping("/get-count")
44 - @Operation(summary = "获得商品评价分页 tab count") 45 + @Operation(summary = "获得商品的评价统计") // TODO @puhui999:@RequestParam 哈,针对 spuId
45 public CommonResult<Map<String, Long>> getCommentPage(@Valid Long spuId) { 46 public CommonResult<Map<String, Long>> getCommentPage(@Valid Long spuId) {
46 return success(productCommentService.getCommentPageTabsCount(spuId, Boolean.TRUE)); 47 return success(productCommentService.getCommentPageTabsCount(spuId, Boolean.TRUE));
47 } 48 }
@@ -50,18 +51,10 @@ public class AppCommentController { @@ -50,18 +51,10 @@ public class AppCommentController {
50 @Operation(summary = "创建商品评价") 51 @Operation(summary = "创建商品评价")
51 public CommonResult<Boolean> createComment(@RequestBody AppCommentCreateReqVO createReqVO) { 52 public CommonResult<Boolean> createComment(@RequestBody AppCommentCreateReqVO createReqVO) {
52 // TODO: 2023/3/20 要不要判断订单、商品是否存在 53 // TODO: 2023/3/20 要不要判断订单、商品是否存在
  54 + // TODO @ouhui999:这个接口,搞到交易那比较合适;
53 MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId()); 55 MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());
54 productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(user, createReqVO), Boolean.FALSE); 56 productCommentService.createComment(ProductCommentConvert.INSTANCE.convert(user, createReqVO), Boolean.FALSE);
55 return success(true); 57 return success(true);
56 } 58 }
57 59
58 - @PostMapping(value = "/additional")  
59 - @Operation(summary = "追加评论")  
60 - public CommonResult<Boolean> additionalComment(@RequestBody AppCommentAdditionalReqVO createReqVO) {  
61 - // 查询会员  
62 - MemberUserRespDTO user = memberUserApi.getUser(getLoginUserId());  
63 - productCommentService.additionalComment(user, createReqVO);  
64 - return success(true);  
65 - }  
66 -  
67 } 60 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentAdditionalReqVO.java deleted
1 -package cn.iocoder.yudao.module.product.controller.app.comment.vo;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.ToString;  
6 -  
7 -import javax.validation.constraints.NotNull;  
8 -import javax.validation.constraints.Size;  
9 -import java.util.List;  
10 -  
11 -@Schema(description = "用户APP - 商品追加评价创建 Request VO")  
12 -@Data  
13 -@ToString(callSuper = true)  
14 -public class AppCommentAdditionalReqVO {  
15 -  
16 - @Schema(description = "评论编号", required = true)  
17 - @NotNull(message = "评论编号不能为空")  
18 - private Long id;  
19 -  
20 - @Schema(description = "追加评价内容", required = true)  
21 - @NotNull(message = "追加评价内容不能为空")  
22 - private String additionalContent;  
23 -  
24 - @Schema(description = "追评评价图片地址数组,以逗号分隔最多上传9张", required = true)  
25 - @Size(max = 9, message = "追评评价图片地址数组长度不能超过9张")  
26 - private List<String> additionalPicUrls;  
27 -  
28 -}  
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentBaseVO.java
@@ -7,6 +7,7 @@ import javax.validation.constraints.NotNull; @@ -7,6 +7,7 @@ import javax.validation.constraints.NotNull;
7 import javax.validation.constraints.Size; 7 import javax.validation.constraints.Size;
8 import java.util.List; 8 import java.util.List;
9 9
  10 +// TODO @puhui999:把 Product 前缀给补下哈
10 @Data 11 @Data
11 public class AppCommentBaseVO { 12 public class AppCommentBaseVO {
12 13
@@ -34,10 +35,6 @@ public class AppCommentBaseVO { @@ -34,10 +35,6 @@ public class AppCommentBaseVO {
34 @NotNull(message = "服务星级 1-5分不能为空") 35 @NotNull(message = "服务星级 1-5分不能为空")
35 private Integer benefitScores; 36 private Integer benefitScores;
36 37
37 - @Schema(description = "配送星级 1-5分", required = true)  
38 - @NotNull(message = "配送星级 1-5分不能为空")  
39 - private Integer deliveryScores;  
40 -  
41 @Schema(description = "评论内容", required = true) 38 @Schema(description = "评论内容", required = true)
42 @NotNull(message = "评论内容不能为空") 39 @NotNull(message = "评论内容不能为空")
43 private String content; 40 private String content;
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentCreateReqVO.java
@@ -7,16 +7,19 @@ import lombok.ToString; @@ -7,16 +7,19 @@ import lombok.ToString;
7 7
8 import javax.validation.constraints.NotNull; 8 import javax.validation.constraints.NotNull;
9 9
  10 +// TODO @puhui999:不应该继承 AppCommentCreateReqVO
10 @Schema(description = "用户APP - 商品评价创建 Request VO") 11 @Schema(description = "用户APP - 商品评价创建 Request VO")
11 @Data 12 @Data
12 @EqualsAndHashCode(callSuper = true) 13 @EqualsAndHashCode(callSuper = true)
13 @ToString(callSuper = true) 14 @ToString(callSuper = true)
14 public class AppCommentCreateReqVO extends AppCommentBaseVO { 15 public class AppCommentCreateReqVO extends AppCommentBaseVO {
15 16
16 - @Schema(description = "是否匿名 true:是 false:否", required = true, example = "true") 17 + @Schema(description = "是否匿名", required = true, example = "true")
17 @NotNull(message = "是否匿名不能为空") 18 @NotNull(message = "是否匿名不能为空")
18 private Boolean anonymous; 19 private Boolean anonymous;
19 20
  21 + // TODO @puhui999:不应该传递 orderId
  22 +
20 @Schema(description = "交易订单编号", required = true, example = "12312") 23 @Schema(description = "交易订单编号", required = true, example = "12312")
21 @NotNull(message = "交易订单编号不能为空") 24 @NotNull(message = "交易订单编号不能为空")
22 private Long orderId; 25 private Long orderId;
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java
@@ -14,6 +14,7 @@ import javax.validation.constraints.NotNull; @@ -14,6 +14,7 @@ import javax.validation.constraints.NotNull;
14 @ToString(callSuper = true) 14 @ToString(callSuper = true)
15 public class AppCommentPageReqVO extends PageParam { 15 public class AppCommentPageReqVO extends PageParam {
16 16
  17 + // TODO @puhui999:不传递就是 all;
17 /** 18 /**
18 * 所有 19 * 所有
19 */ 20 */
@@ -24,11 +25,13 @@ public class AppCommentPageReqVO extends PageParam { @@ -24,11 +25,13 @@ public class AppCommentPageReqVO extends PageParam {
24 */ 25 */
25 public static final String ALL_COUNT = "allCount"; 26 public static final String ALL_COUNT = "allCount";
26 27
  28 + // TODO @puhui999:good 好评;
27 /** 29 /**
28 * 好评 30 * 好评
29 */ 31 */
30 public static final Integer FAVOURABLE_COMMENT = 1; 32 public static final Integer FAVOURABLE_COMMENT = 1;
31 33
  34 + // TODO @puhui999:medium 中评;然后 mediumCount 就好啦;
32 /** 35 /**
33 * 好评数量 key 36 * 好评数量 key
34 */ 37 */
@@ -54,6 +57,7 @@ public class AppCommentPageReqVO extends PageParam { @@ -54,6 +57,7 @@ public class AppCommentPageReqVO extends PageParam {
54 */ 57 */
55 public static final String NEGATIVE_COMMENT_COUNT = "negativeCommentCount"; 58 public static final String NEGATIVE_COMMENT_COUNT = "negativeCommentCount";
56 59
  60 + // TODO @puhui999:这个挪到 DO 那没问题的哈;NICKNAME_ANONYMOUS
57 /** 61 /**
58 * 默认匿名昵称 62 * 默认匿名昵称
59 */ 63 */
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentRespVO.java
@@ -14,7 +14,9 @@ import java.util.List; @@ -14,7 +14,9 @@ import java.util.List;
14 @ToString(callSuper = true) 14 @ToString(callSuper = true)
15 public class AppCommentRespVO extends AppCommentBaseVO { 15 public class AppCommentRespVO extends AppCommentBaseVO {
16 16
17 - @Schema(description = "评价人 用户编号", required = true, example = "15721") 17 + // TODO puhui999:把 example 也补充下哈
  18 +
  19 + @Schema(description = "评价人的用户编号", required = true, example = "15721")
18 private Long userId; 20 private Long userId;
19 21
20 @Schema(description = "评价人名称", required = true, example = "张三") 22 @Schema(description = "评价人名称", required = true, example = "张三")
@@ -36,7 +38,7 @@ public class AppCommentRespVO extends AppCommentBaseVO { @@ -36,7 +38,7 @@ public class AppCommentRespVO extends AppCommentBaseVO {
36 private Long orderItemId; 38 private Long orderItemId;
37 39
38 @Schema(description = "商家是否回复", required = true) 40 @Schema(description = "商家是否回复", required = true)
39 - private Boolean replied; 41 + private Boolean replyStatus;
40 42
41 @Schema(description = "回复管理员编号", example = "22212") 43 @Schema(description = "回复管理员编号", example = "22212")
42 private Long replyUserId; 44 private Long replyUserId;
@@ -61,4 +63,5 @@ public class AppCommentRespVO extends AppCommentBaseVO { @@ -61,4 +63,5 @@ public class AppCommentRespVO extends AppCommentBaseVO {
61 63
62 @Schema(description = "最终评分", required = true) 64 @Schema(description = "最终评分", required = true)
63 private Integer finalScore; 65 private Integer finalScore;
  66 +
64 } 67 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java
@@ -30,6 +30,7 @@ public interface ProductCommentConvert { @@ -30,6 +30,7 @@ public interface ProductCommentConvert {
30 30
31 PageResult<AppCommentRespVO> convertPage02(PageResult<ProductCommentDO> pageResult); 31 PageResult<AppCommentRespVO> convertPage02(PageResult<ProductCommentDO> pageResult);
32 32
  33 + // TODO @puhui999:用 mapstruct 的映射
33 default ProductCommentDO convert(MemberUserRespDTO user, AppCommentCreateReqVO createReqVO) { 34 default ProductCommentDO convert(MemberUserRespDTO user, AppCommentCreateReqVO createReqVO) {
34 ProductCommentDO productComment = new ProductCommentDO(); 35 ProductCommentDO productComment = new ProductCommentDO();
35 productComment.setUserId(user.getId()); 36 productComment.setUserId(user.getId());
@@ -44,12 +45,12 @@ public interface ProductCommentConvert { @@ -44,12 +45,12 @@ public interface ProductCommentConvert {
44 productComment.setScores(createReqVO.getScores()); 45 productComment.setScores(createReqVO.getScores());
45 productComment.setDescriptionScores(createReqVO.getDescriptionScores()); 46 productComment.setDescriptionScores(createReqVO.getDescriptionScores());
46 productComment.setBenefitScores(createReqVO.getBenefitScores()); 47 productComment.setBenefitScores(createReqVO.getBenefitScores());
47 - productComment.setDeliveryScores(createReqVO.getDeliveryScores());  
48 productComment.setContent(createReqVO.getContent()); 48 productComment.setContent(createReqVO.getContent());
49 productComment.setPicUrls(createReqVO.getPicUrls()); 49 productComment.setPicUrls(createReqVO.getPicUrls());
50 return productComment; 50 return productComment;
51 } 51 }
52 52
  53 + // TODO @puhui999:用 mapstruct 的映射
53 default ProductCommentDO convert(ProductCommentCreateReqVO createReq) { 54 default ProductCommentDO convert(ProductCommentCreateReqVO createReq) {
54 ProductCommentDO productComment = new ProductCommentDO(); 55 ProductCommentDO productComment = new ProductCommentDO();
55 productComment.setUserId(0L); 56 productComment.setUserId(0L);
@@ -64,7 +65,6 @@ public interface ProductCommentConvert { @@ -64,7 +65,6 @@ public interface ProductCommentConvert {
64 productComment.setScores(createReq.getScores()); 65 productComment.setScores(createReq.getScores());
65 productComment.setDescriptionScores(createReq.getDescriptionScores()); 66 productComment.setDescriptionScores(createReq.getDescriptionScores());
66 productComment.setBenefitScores(createReq.getBenefitScores()); 67 productComment.setBenefitScores(createReq.getBenefitScores());
67 - productComment.setDeliveryScores(createReq.getDeliveryScores());  
68 productComment.setContent(createReq.getContent()); 68 productComment.setContent(createReq.getContent());
69 productComment.setPicUrls(createReq.getPicUrls()); 69 productComment.setPicUrls(createReq.getPicUrls());
70 return productComment; 70 return productComment;
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java
@@ -36,20 +36,18 @@ public class ProductCommentDO extends BaseDO { @@ -36,20 +36,18 @@ public class ProductCommentDO extends BaseDO {
36 36
37 /** 37 /**
38 * 评价人 用户编号 38 * 评价人 用户编号
  39 + *
39 * 关联 MemberUserDO 的 id 编号 40 * 关联 MemberUserDO 的 id 编号
40 */ 41 */
41 private Long userId; 42 private Long userId;
42 -  
43 /** 43 /**
44 * 评价人名称 44 * 评价人名称
45 */ 45 */
46 private String userNickname; 46 private String userNickname;
47 -  
48 /** 47 /**
49 * 评价人头像 48 * 评价人头像
50 */ 49 */
51 private String userAvatar; 50 private String userAvatar;
52 -  
53 /** 51 /**
54 * 是否匿名 52 * 是否匿名
55 */ 53 */
@@ -57,12 +55,13 @@ public class ProductCommentDO extends BaseDO { @@ -57,12 +55,13 @@ public class ProductCommentDO extends BaseDO {
57 55
58 /** 56 /**
59 * 交易订单编号 57 * 交易订单编号
  58 + *
60 * 关联 TradeOrderDO 的 id 编号 59 * 关联 TradeOrderDO 的 id 编号
61 */ 60 */
62 private Long orderId; 61 private Long orderId;
63 -  
64 /** 62 /**
65 * 交易订单项编号 63 * 交易订单项编号
  64 + *
66 * 关联 TradeOrderItemDO 的 id 编号 65 * 关联 TradeOrderItemDO 的 id 编号
67 */ 66 */
68 private Long orderItemId; 67 private Long orderItemId;
@@ -72,53 +71,46 @@ public class ProductCommentDO extends BaseDO { @@ -72,53 +71,46 @@ public class ProductCommentDO extends BaseDO {
72 * 关联 {@link ProductSpuDO#getId()} 71 * 关联 {@link ProductSpuDO#getId()}
73 */ 72 */
74 private Long spuId; 73 private Long spuId;
75 -  
76 /** 74 /**
77 * 商品 SPU 名称 75 * 商品 SPU 名称
78 */ 76 */
79 private String spuName; 77 private String spuName;
80 -  
81 /** 78 /**
82 * 商品 SKU 编号 79 * 商品 SKU 编号
  80 + *
83 * 关联 {@link ProductSkuDO#getId()} 81 * 关联 {@link ProductSkuDO#getId()}
84 */ 82 */
85 private Long skuId; 83 private Long skuId;
86 84
87 /** 85 /**
88 * 是否可见 86 * 是否可见
89 - * true:显示 false:隐藏 87 + *
  88 + * true:显示
  89 + * false:隐藏
90 */ 90 */
91 private Boolean visible; 91 private Boolean visible;
92 -  
93 /** 92 /**
94 * 评分星级 93 * 评分星级
  94 + *
95 * 1-5分 95 * 1-5分
96 */ 96 */
97 private Integer scores; 97 private Integer scores;
98 -  
99 /** 98 /**
100 * 描述星级 99 * 描述星级
  100 + *
101 * 1-5 星 101 * 1-5 星
102 */ 102 */
103 private Integer descriptionScores; 103 private Integer descriptionScores;
104 -  
105 /** 104 /**
106 * 服务星级 105 * 服务星级
  106 + *
107 * 1-5 星 107 * 1-5 星
108 */ 108 */
109 private Integer benefitScores; 109 private Integer benefitScores;
110 -  
111 - /**  
112 - * 配送星级  
113 - * 1-5 星  
114 - */  
115 - private Integer deliveryScores;  
116 -  
117 /** 110 /**
118 * 评论内容 111 * 评论内容
119 */ 112 */
120 private String content; 113 private String content;
121 -  
122 /** 114 /**
123 * 评论图片地址数组 115 * 评论图片地址数组
124 */ 116 */
@@ -128,38 +120,19 @@ public class ProductCommentDO extends BaseDO { @@ -128,38 +120,19 @@ public class ProductCommentDO extends BaseDO {
128 /** 120 /**
129 * 商家是否回复 121 * 商家是否回复
130 */ 122 */
131 - private Boolean replied;  
132 - 123 + private Boolean replyStatus;
133 /** 124 /**
134 * 回复管理员编号 125 * 回复管理员编号
135 * 关联 AdminUserDO 的 id 编号 126 * 关联 AdminUserDO 的 id 编号
136 */ 127 */
137 private Long replyUserId; 128 private Long replyUserId;
138 -  
139 /** 129 /**
140 * 商家回复内容 130 * 商家回复内容
141 */ 131 */
142 private String replyContent; 132 private String replyContent;
143 -  
144 /** 133 /**
145 * 商家回复时间 134 * 商家回复时间
146 */ 135 */
147 private LocalDateTime replyTime; 136 private LocalDateTime replyTime;
148 137
149 - /**  
150 - * 追加评价内容  
151 - */  
152 - private String additionalContent;  
153 -  
154 - /**  
155 - * 追评评价图片地址数组  
156 - */  
157 - @TableField(typeHandler = JacksonTypeHandler.class)  
158 - private List<String> additionalPicUrls;  
159 -  
160 - /**  
161 - * 追加评价时间  
162 - */  
163 - private LocalDateTime additionalTime;  
164 -  
165 } 138 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java
@@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; @@ -7,7 +7,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
7 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 7 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
8 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; 8 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
9 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO; 9 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO;
10 -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentAdditionalReqVO;  
11 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; 10 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
12 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; 11 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
13 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 12 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -15,12 +14,6 @@ import org.apache.ibatis.annotations.Mapper; @@ -15,12 +14,6 @@ import org.apache.ibatis.annotations.Mapper;
15 14
16 import java.time.LocalDateTime; 15 import java.time.LocalDateTime;
17 16
18 -  
19 -/**  
20 - * 商品评论 Mapper  
21 - *  
22 - * @author wangzhs  
23 - */  
24 @Mapper 17 @Mapper
25 public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> { 18 public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> {
26 19
@@ -37,19 +30,16 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; { @@ -37,19 +30,16 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; {
37 30
38 // TODO 芋艿:在看看这块 31 // TODO 芋艿:在看看这块
39 static void appendTabQuery(LambdaQueryWrapperX<ProductCommentDO> queryWrapper, Integer type) { 32 static void appendTabQuery(LambdaQueryWrapperX<ProductCommentDO> queryWrapper, Integer type) {
40 - // 构建好评查询语句 33 + // 构建好评查询语句:好评计算 (商品评分星级+服务评分星级) >= 8
41 if (ObjectUtil.equal(type, AppCommentPageReqVO.FAVOURABLE_COMMENT)) { 34 if (ObjectUtil.equal(type, AppCommentPageReqVO.FAVOURABLE_COMMENT)) {
42 - // 好评计算 (商品评分星级+服务评分星级) >= 8  
43 queryWrapper.apply("(scores + benefit_scores) >= 8"); 35 queryWrapper.apply("(scores + benefit_scores) >= 8");
44 } 36 }
45 - // 构建中评查询语句 37 + // 构建中评查询语句:中评计算 (商品评分星级+服务评分星级) > 4 且 (商品评分星级+服务评分星级) < 8
46 if (ObjectUtil.equal(type, AppCommentPageReqVO.MEDIOCRE_COMMENT)) { 38 if (ObjectUtil.equal(type, AppCommentPageReqVO.MEDIOCRE_COMMENT)) {
47 - // 中评计算 (商品评分星级+服务评分星级) > 4 且 (商品评分星级+服务评分星级) < 8  
48 queryWrapper.apply("(scores + benefit_scores) > 4 and (scores + benefit_scores) < 8"); 39 queryWrapper.apply("(scores + benefit_scores) > 4 and (scores + benefit_scores) < 8");
49 } 40 }
50 - // 构建差评查询语句 41 + // 构建差评查询语句:差评计算 (商品评分星级+服务评分星级) <= 4
51 if (ObjectUtil.equal(type, AppCommentPageReqVO.NEGATIVE_COMMENT)) { 42 if (ObjectUtil.equal(type, AppCommentPageReqVO.NEGATIVE_COMMENT)) {
52 - // 差评计算 (商品评分星级+服务评分星级) <= 4  
53 queryWrapper.apply("(scores + benefit_scores) <= 4"); 43 queryWrapper.apply("(scores + benefit_scores) <= 4");
54 } 44 }
55 } 45 }
@@ -74,7 +64,7 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; { @@ -74,7 +64,7 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; {
74 64
75 default void commentReply(ProductCommentReplyVO replyVO, Long loginUserId) { 65 default void commentReply(ProductCommentReplyVO replyVO, Long loginUserId) {
76 LambdaUpdateWrapper<ProductCommentDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<ProductCommentDO>() 66 LambdaUpdateWrapper<ProductCommentDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<ProductCommentDO>()
77 - .set(ProductCommentDO::getReplied, Boolean.TRUE) 67 + .set(ProductCommentDO::getReplyStatus, Boolean.TRUE)
78 .set(ProductCommentDO::getReplyTime, LocalDateTime.now()) 68 .set(ProductCommentDO::getReplyTime, LocalDateTime.now())
79 .set(ProductCommentDO::getReplyUserId, loginUserId) 69 .set(ProductCommentDO::getReplyUserId, loginUserId)
80 .set(ProductCommentDO::getReplyContent, replyVO.getReplyContent()) 70 .set(ProductCommentDO::getReplyContent, replyVO.getReplyContent())
@@ -82,6 +72,7 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; { @@ -82,6 +72,7 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; {
82 update(null, lambdaUpdateWrapper); 72 update(null, lambdaUpdateWrapper);
83 } 73 }
84 74
  75 + // TODO @puhui999:使用 select 替代 find
85 default ProductCommentDO findByUserIdAndOrderIdAndSpuId(Long userId, Long orderId, Long spuId) { 76 default ProductCommentDO findByUserIdAndOrderIdAndSpuId(Long userId, Long orderId, Long spuId) {
86 return selectOne(new LambdaQueryWrapperX<ProductCommentDO>() 77 return selectOne(new LambdaQueryWrapperX<ProductCommentDO>()
87 .eq(ProductCommentDO::getUserId, userId) 78 .eq(ProductCommentDO::getUserId, userId)
@@ -89,15 +80,7 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; { @@ -89,15 +80,7 @@ public interface ProductCommentMapper extends BaseMapperX&lt;ProductCommentDO&gt; {
89 .eq(ProductCommentDO::getSpuId, spuId)); 80 .eq(ProductCommentDO::getSpuId, spuId));
90 } 81 }
91 82
92 - default void additionalComment(AppCommentAdditionalReqVO createReqVO) {  
93 - LambdaUpdateWrapper<ProductCommentDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<ProductCommentDO>()  
94 - .set(ProductCommentDO::getAdditionalTime, LocalDateTime.now())  
95 - .set(ProductCommentDO::getAdditionalPicUrls, createReqVO.getAdditionalPicUrls(), "javaType=List,jdbcType=VARCHAR,typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler")  
96 - .set(ProductCommentDO::getAdditionalContent, createReqVO.getAdditionalContent())  
97 - .eq(ProductCommentDO::getId, createReqVO.getId());  
98 - update(null, lambdaUpdateWrapper);  
99 - }  
100 - 83 + // TODO @puhui999:selectCountBySpuId 即可
101 default Long selectTabCount(Long spuId, Boolean visible, Integer type) { 84 default Long selectTabCount(Long spuId, Boolean visible, Integer type) {
102 LambdaQueryWrapperX<ProductCommentDO> queryWrapper = new LambdaQueryWrapperX<ProductCommentDO>() 85 LambdaQueryWrapperX<ProductCommentDO> queryWrapper = new LambdaQueryWrapperX<ProductCommentDO>()
103 .eqIfPresent(ProductCommentDO::getSpuId, spuId) 86 .eqIfPresent(ProductCommentDO::getSpuId, spuId)
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java
1 package cn.iocoder.yudao.module.product.service.comment; 1 package cn.iocoder.yudao.module.product.service.comment;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;  
5 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; 4 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
6 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO; 5 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO;
7 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; 6 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
8 -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentAdditionalReqVO;  
9 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; 7 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
10 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO; 8 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO;
11 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO; 9 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
@@ -38,11 +36,12 @@ public interface ProductCommentService { @@ -38,11 +36,12 @@ public interface ProductCommentService {
38 */ 36 */
39 void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO); 37 void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO);
40 38
  39 + // TODO @puhui999:replyComment
41 /** 40 /**
42 * 商家回复 41 * 商家回复
43 * 42 *
44 * @param replyVO 商家回复 43 * @param replyVO 商家回复
45 - * @param loginUserId 管理后台商家登陆人ID 44 + * @param loginUserId 管理后台商家登陆人 ID
46 */ 45 */
47 void commentReply(ProductCommentReplyVO replyVO, Long loginUserId); 46 void commentReply(ProductCommentReplyVO replyVO, Long loginUserId);
48 47
@@ -64,19 +63,12 @@ public interface ProductCommentService { @@ -64,19 +63,12 @@ public interface ProductCommentService {
64 void createComment(ProductCommentDO productComment, Boolean system); 63 void createComment(ProductCommentDO productComment, Boolean system);
65 64
66 /** 65 /**
67 - * 追加商品评论  
68 - *  
69 - * @param user 用户相关信息  
70 - * @param createReqVO 创建实体  
71 - */  
72 - void additionalComment(MemberUserRespDTO user, AppCommentAdditionalReqVO createReqVO);  
73 -  
74 - /**  
75 - * 评论页面标签数 66 + * 获得商品的评价统计
76 * 67 *
77 * @param spuId spu id 68 * @param spuId spu id
78 * @param visible 是否可见 69 * @param visible 是否可见
79 - * @return 获得商品评价分页 tab count 70 + * @return 评价统计
80 */ 71 */
81 Map<String, Long> getCommentPageTabsCount(Long spuId, Boolean visible); 72 Map<String, Long> getCommentPageTabsCount(Long spuId, Boolean visible);
  73 +
82 } 74 }
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java
@@ -2,11 +2,9 @@ package cn.iocoder.yudao.module.product.service.comment; @@ -2,11 +2,9 @@ package cn.iocoder.yudao.module.product.service.comment;
2 2
3 import cn.hutool.core.util.ObjectUtil; 3 import cn.hutool.core.util.ObjectUtil;
4 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 -import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;  
6 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO; 5 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
7 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO; 6 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO;
8 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO; 7 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
9 -import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentAdditionalReqVO;  
10 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO; 8 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
11 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO; 9 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentRespVO;
12 import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert; 10 import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
@@ -17,7 +15,6 @@ import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; @@ -17,7 +15,6 @@ import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
17 import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; 15 import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
18 import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO; 16 import cn.iocoder.yudao.module.trade.api.order.dto.TradeOrderRespDTO;
19 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
20 -import org.springframework.util.StringUtils;  
21 import org.springframework.validation.annotation.Validated; 18 import org.springframework.validation.annotation.Validated;
22 19
23 import javax.annotation.Resource; 20 import javax.annotation.Resource;
@@ -25,13 +22,11 @@ import java.math.BigDecimal; @@ -25,13 +22,11 @@ import java.math.BigDecimal;
25 import java.math.RoundingMode; 22 import java.math.RoundingMode;
26 import java.util.HashMap; 23 import java.util.HashMap;
27 import java.util.Map; 24 import java.util.Map;
28 -import java.util.Objects;  
29 25
30 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 26 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
31 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; 27 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
32 import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; 28 import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
33 29
34 -// TODO @芋艿:详细 review 下  
35 /** 30 /**
36 * 商品评论 Service 实现类 31 * 商品评论 Service 实现类
37 * 32 *
@@ -43,6 +38,7 @@ public class ProductCommentServiceImpl implements ProductCommentService { @@ -43,6 +38,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
43 38
44 @Resource 39 @Resource
45 private ProductCommentMapper productCommentMapper; 40 private ProductCommentMapper productCommentMapper;
  41 +
46 @Resource 42 @Resource
47 private TradeOrderApi tradeOrderApi; 43 private TradeOrderApi tradeOrderApi;
48 44
@@ -59,6 +55,8 @@ public class ProductCommentServiceImpl implements ProductCommentService { @@ -59,6 +55,8 @@ public class ProductCommentServiceImpl implements ProductCommentService {
59 // 校验评论是否存在 55 // 校验评论是否存在
60 validateCommentExists(updateReqVO.getId()); 56 validateCommentExists(updateReqVO.getId());
61 57
  58 + // 更新可见状态
  59 + // TODO @puhui999:直接使用 update 操作
62 productCommentMapper.updateCommentVisible(updateReqVO.getId(), updateReqVO.getVisible()); 60 productCommentMapper.updateCommentVisible(updateReqVO.getId(), updateReqVO.getVisible());
63 } 61 }
64 62
@@ -67,6 +65,8 @@ public class ProductCommentServiceImpl implements ProductCommentService { @@ -67,6 +65,8 @@ public class ProductCommentServiceImpl implements ProductCommentService {
67 // 校验评论是否存在 65 // 校验评论是否存在
68 validateCommentExists(replyVO.getId()); 66 validateCommentExists(replyVO.getId());
69 67
  68 + // 回复评论
  69 + // TODO @puhui999:直接使用 update 操作
70 productCommentMapper.commentReply(replyVO, loginUserId); 70 productCommentMapper.commentReply(replyVO, loginUserId);
71 } 71 }
72 72
@@ -90,12 +90,14 @@ public class ProductCommentServiceImpl implements ProductCommentService { @@ -90,12 +90,14 @@ public class ProductCommentServiceImpl implements ProductCommentService {
90 90
91 @Override 91 @Override
92 public PageResult<AppCommentRespVO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) { 92 public PageResult<AppCommentRespVO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) {
  93 + // TODO @puhui999:逻辑可以在 controller 做哈。让 service 简介一点;因为是 view 需要不展示昵称
93 PageResult<AppCommentRespVO> result = ProductCommentConvert.INSTANCE.convertPage02(productCommentMapper.selectPage(pageVO, visible)); 94 PageResult<AppCommentRespVO> result = ProductCommentConvert.INSTANCE.convertPage02(productCommentMapper.selectPage(pageVO, visible));
94 result.getList().forEach(item -> { 95 result.getList().forEach(item -> {
95 // 判断用户是否选择匿名 96 // 判断用户是否选择匿名
96 if (ObjectUtil.equal(item.getAnonymous(), true)) { 97 if (ObjectUtil.equal(item.getAnonymous(), true)) {
97 item.setUserNickname(AppCommentPageReqVO.ANONYMOUS_NICKNAME); 98 item.setUserNickname(AppCommentPageReqVO.ANONYMOUS_NICKNAME);
98 } 99 }
  100 + // TODO @puhui999:直接插入的时候,计算到 scores 字段里;这样就去掉 finalScore 字段哈
99 // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2 101 // 计算评价最终综合评分 最终星数 = (商品评星 + 服务评星) / 2
100 BigDecimal sumScore = new BigDecimal(item.getScores() + item.getBenefitScores()); 102 BigDecimal sumScore = new BigDecimal(item.getScores() + item.getBenefitScores());
101 BigDecimal divide = sumScore.divide(BigDecimal.valueOf(2L), 0, RoundingMode.DOWN); 103 BigDecimal divide = sumScore.divide(BigDecimal.valueOf(2L), 0, RoundingMode.DOWN);
@@ -127,30 +129,11 @@ public class ProductCommentServiceImpl implements ProductCommentService { @@ -127,30 +129,11 @@ public class ProductCommentServiceImpl implements ProductCommentService {
127 productCommentMapper.insert(productComment); 129 productCommentMapper.insert(productComment);
128 } 130 }
129 131
130 - @Override  
131 - public void additionalComment(MemberUserRespDTO user, AppCommentAdditionalReqVO createReqVO) {  
132 - // 校验评论是否存在  
133 - ProductCommentDO productComment = validateCommentExists(createReqVO.getId());  
134 -  
135 - // 判断是否是同一用户追加评论  
136 - if (!Objects.equals(productComment.getUserId(), user.getId())) {  
137 - throw exception(COMMENT_ERROR_OPT);  
138 - }  
139 -  
140 - // 判断是否已经追加评论过了  
141 - if (StringUtils.hasText(productComment.getAdditionalContent())) {  
142 - throw exception(COMMENT_ADDITIONAL_EXISTS);  
143 - }  
144 -  
145 - productCommentMapper.additionalComment(createReqVO);  
146 - }  
147 -  
148 - private ProductCommentDO validateCommentExists(Long id) { 132 + private void validateCommentExists(Long id) {
149 ProductCommentDO productComment = productCommentMapper.selectById(id); 133 ProductCommentDO productComment = productCommentMapper.selectById(id);
150 if (productComment == null) { 134 if (productComment == null) {
151 throw exception(COMMENT_NOT_EXISTS); 135 throw exception(COMMENT_NOT_EXISTS);
152 } 136 }
153 - return productComment;  
154 } 137 }
155 138
156 } 139 }
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java
@@ -82,7 +82,7 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { @@ -82,7 +82,7 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest {
82 o.setUserNickname("王二狗"); 82 o.setUserNickname("王二狗");
83 o.setSpuName("感冒药"); 83 o.setSpuName("感冒药");
84 o.setScores(ProductCommentScoresEnum.FOUR.getScores()); 84 o.setScores(ProductCommentScoresEnum.FOUR.getScores());
85 - o.setReplied(Boolean.TRUE); 85 + o.setReplyStatus(Boolean.TRUE);
86 o.setVisible(Boolean.TRUE); 86 o.setVisible(Boolean.TRUE);
87 o.setId(generateId()); 87 o.setId(generateId());
88 o.setUserId(generateId()); 88 o.setUserId(generateId());
@@ -118,7 +118,7 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest { @@ -118,7 +118,7 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest {
118 // 测试 scores 不匹配 118 // 测试 scores 不匹配
119 productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setScores(ProductCommentScoresEnum.ONE.getScores()))); 119 productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setScores(ProductCommentScoresEnum.ONE.getScores())));
120 // 测试 replied 不匹配 120 // 测试 replied 不匹配
121 - productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setReplied(Boolean.FALSE))); 121 + productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setReplyStatus(Boolean.FALSE)));
122 // 测试 visible 不匹配 122 // 测试 visible 不匹配
123 productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setVisible(Boolean.FALSE))); 123 productCommentMapper.insert(cloneIgnoreId(productComment, o -> o.setVisible(Boolean.FALSE)));
124 124