Эх сурвалжийг харах

fix:合并代码后修改差异完善商品评论相关

puhui999 2 жил өмнө
parent
commit
60172274ec
13 өөрчлөгдсөн 212 нэмэгдсэн , 105 устгасан
  1. 1 1
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java
  2. 1 2
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java
  3. 68 10
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java
  4. 5 0
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java
  5. 0 54
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentBaseVO.java
  6. 40 4
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentCreateReqVO.java
  7. 47 4
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java
  8. 4 0
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java
  9. 0 21
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java
  10. 2 4
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java
  11. 37 3
      yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java
  12. 5 2
      yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java
  13. 2 0
      yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java

+ 1 - 1
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java

@@ -46,7 +46,7 @@ public class ProductCommentController {
     @PutMapping("/reply")
     @Operation(summary = "商家回复")
     @PreAuthorize("@ss.hasPermission('product:comment:update')")
-    public CommonResult<Boolean> commentReply(@Valid @RequestBody ProductCommentReplyVO replyVO) {
+    public CommonResult<Boolean> commentReply(@Valid @RequestBody ProductCommentReplyReqVO replyVO) {
         productCommentService.replyComment(replyVO, getLoginUserId());
         return success(true);
     }

+ 1 - 2
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyVO.java → yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentReplyReqVO.java

@@ -7,11 +7,10 @@ import lombok.ToString;
 import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 
-// TODO @puhui999:ReqVO
 @Schema(description = "管理后台 - 商品评价可见修改 Request VO")
 @Data
 @ToString(callSuper = true)
-public class ProductCommentReplyVO {
+public class ProductCommentReplyReqVO {
 
     @Schema(description = "评价编号", required = true, example = "15721")
     @NotNull(message = "评价编号不能为空")

+ 68 - 10
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/AppProductCommentController.java

@@ -1,14 +1,15 @@
 package cn.iocoder.yudao.module.product.controller.app.comment;
 
-import cn.hutool.core.util.ObjectUtil;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO;
-import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
+import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
 import cn.iocoder.yudao.module.product.service.comment.ProductCommentService;
 import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -18,6 +19,11 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
 
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 
@@ -30,17 +36,69 @@ public class AppProductCommentController {
     @Resource
     private ProductCommentService productCommentService;
 
+    @GetMapping("/list")
+    @Operation(summary = "获得最近的 n 条商品评价")
+    @Parameters({
+            @Parameter(name = "spuId", description = "商品 SPU 编号", required = true, example = "1024"),
+            @Parameter(name = "count", description = "数量", required = true, example = "10")
+    })
+    public CommonResult<List<AppProductCommentRespVO>> getCommentList(@RequestParam("spuId") Long spuId,
+                                                                      @RequestParam(value = "count", defaultValue = "10") Integer count) {
+
+        List<AppProductPropertyValueDetailRespVO> list = new ArrayList<>();
+
+        AppProductPropertyValueDetailRespVO item1 = new AppProductPropertyValueDetailRespVO();
+        item1.setPropertyId(1L);
+        item1.setPropertyName("颜色");
+        item1.setValueId(1024L);
+        item1.setValueName("红色");
+        list.add(item1);
+
+        AppProductPropertyValueDetailRespVO item2 = new AppProductPropertyValueDetailRespVO();
+        item2.setPropertyId(2L);
+        item2.setPropertyName("尺寸");
+        item2.setValueId(2048L);
+        item2.setValueName("大号");
+        list.add(item2);
+
+        AppProductPropertyValueDetailRespVO item3 = new AppProductPropertyValueDetailRespVO();
+        item3.setPropertyId(3L);
+        item3.setPropertyName("重量");
+        item3.setValueId(3072L);
+        item3.setValueName("500克");
+        list.add(item3);
+
+        // TODO 生成 mock 的数据
+        AppProductCommentRespVO appCommentRespVO = new AppProductCommentRespVO();
+        appCommentRespVO.setUserId((long) (new Random().nextInt(100000) + 10000));
+        appCommentRespVO.setUserNickname("用户" + new Random().nextInt(100));
+        appCommentRespVO.setUserAvatar("https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg");
+        appCommentRespVO.setId((long) (new Random().nextInt(100000) + 10000));
+        appCommentRespVO.setAnonymous(new Random().nextBoolean());
+        appCommentRespVO.setOrderId((long) (new Random().nextInt(100000) + 10000));
+        appCommentRespVO.setOrderItemId((long) (new Random().nextInt(100000) + 10000));
+        appCommentRespVO.setReplyStatus(new Random().nextBoolean());
+        appCommentRespVO.setReplyUserId((long) (new Random().nextInt(100000) + 10000));
+        appCommentRespVO.setReplyContent("回复内容" + new Random().nextInt(100));
+        appCommentRespVO.setReplyTime(LocalDateTime.now().minusDays(new Random().nextInt(30)));
+        appCommentRespVO.setCreateTime(LocalDateTime.now().minusDays(new Random().nextInt(30)));
+        appCommentRespVO.setSpuId((long) (new Random().nextInt(100000) + 10000));
+        appCommentRespVO.setSpuName("商品" + new Random().nextInt(100));
+        appCommentRespVO.setSkuId((long) (new Random().nextInt(100000) + 10000));
+        appCommentRespVO.setSkuProperties(list);
+        appCommentRespVO.setScores(new Random().nextInt(5) + 1);
+        appCommentRespVO.setDescriptionScores(new Random().nextInt(5) + 1);
+        appCommentRespVO.setBenefitScores(new Random().nextInt(5) + 1);
+        appCommentRespVO.setContent("评论内容" + new Random().nextInt(100));
+        appCommentRespVO.setPicUrls(Arrays.asList("https://demo26.crmeb.net/uploads/attach/2021/11/15/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg"));
+
+        return success(Arrays.asList(appCommentRespVO));
+    }
+
     @GetMapping("/page")
     @Operation(summary = "获得商品评价分页")
     public CommonResult<PageResult<AppProductCommentRespVO>> getCommentPage(@Valid AppCommentPageReqVO pageVO) {
-        PageResult<AppProductCommentRespVO> result = productCommentService.getCommentPage(pageVO, Boolean.TRUE);
-        result.getList().forEach(item -> {
-            // 判断用户是否选择匿名
-            if (ObjectUtil.equal(item.getAnonymous(), true)) {
-                item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS);
-            }
-        });
-        return success(result);
+        return success(productCommentService.getCommentPage(pageVO, Boolean.TRUE));
     }
 
     @GetMapping("/getCommentStatistics")

+ 5 - 0
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppCommentPageReqVO.java

@@ -8,6 +8,11 @@ import lombok.ToString;
 
 import javax.validation.constraints.NotNull;
 
+/**
+ * 用户 APP - 商品评价分页 Request VO
+ *
+ * @author HUIHUI
+ */
 @Schema(description = "用户APP - 商品评价分页 Request VO")
 @Data
 @EqualsAndHashCode(callSuper = true)

+ 0 - 54
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentBaseVO.java

@@ -1,54 +0,0 @@
-package cn.iocoder.yudao.module.product.controller.app.comment.vo;
-
-import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import java.util.List;
-
-/**
- * 商品评论 Base VO
- *
- * @author HUIHUI
- */
-@Data
-public class AppProductCommentBaseVO {
-
-    @Schema(description = "商品SPU编号", required = true, example = "91192")
-    @NotNull(message = "商品SPU编号不能为空")
-    private Long spuId;
-
-    @Schema(description = "商品SPU名称", required = true, example = "清凉丝滑小短袖")
-    @NotNull(message = "商品SPU名称不能为空")
-    private String spuName;
-
-    @Schema(description = "商品SKU编号", required = true, example = "81192")
-    @NotNull(message = "商品SKU编号不能为空")
-    private Long skuId;
-
-    @Schema(description = "商品 SKU 属性", required = true)
-    private List<AppProductPropertyValueDetailRespVO> skuProperties; // TODO puhui999:这个需要从数据库查询哈
-
-    @Schema(description = "评分星级 1-5分", required = true, example = "5")
-    @NotNull(message = "评分星级 1-5分不能为空")
-    private Integer scores;
-
-    @Schema(description = "描述星级 1-5分", required = true, example = "5")
-    @NotNull(message = "描述星级 1-5分不能为空")
-    private Integer descriptionScores;
-
-    @Schema(description = "服务星级 1-5分", required = true, example = "5")
-    @NotNull(message = "服务星级 1-5分不能为空")
-    private Integer benefitScores;
-
-    @Schema(description = "评论内容", required = true, example = "哇,真的很丝滑凉快诶,好评")
-    @NotNull(message = "评论内容不能为空")
-    private String content;
-
-    @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]")
-    @Size(max = 9, message = "评论图片地址数组长度不能超过9张")
-    private List<String> picUrls;
-
-}

+ 40 - 4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentCreateReqVO.java

@@ -2,17 +2,21 @@ package cn.iocoder.yudao.module.product.controller.app.comment.vo;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
 import lombok.ToString;
 
 import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.List;
 
-// TODO @puhui999:不应该继承 AppProductCommentCreateReqVO
+/**
+ * 用户APP - 商品评价创建 Request VO
+ *
+ * @author HUIHUI
+ */
 @Schema(description = "用户APP - 商品评价创建 Request VO")
 @Data
-@EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
-public class AppProductCommentCreateReqVO extends AppProductCommentBaseVO {
+public class AppProductCommentCreateReqVO {
 
     @Schema(description = "是否匿名", required = true, example = "true")
     @NotNull(message = "是否匿名不能为空")
@@ -22,4 +26,36 @@ public class AppProductCommentCreateReqVO extends AppProductCommentBaseVO {
     @NotNull(message = "交易订单项编号不能为空")
     private Long orderItemId;
 
+    @Schema(description = "商品SPU编号", required = true, example = "91192")
+    @NotNull(message = "商品SPU编号不能为空")
+    private Long spuId;
+
+    @Schema(description = "商品SPU名称", required = true, example = "清凉丝滑小短袖")
+    @NotNull(message = "商品SPU名称不能为空")
+    private String spuName;
+
+    @Schema(description = "商品SKU编号", required = true, example = "81192")
+    @NotNull(message = "商品SKU编号不能为空")
+    private Long skuId;
+
+    @Schema(description = "评分星级 1-5分", required = true, example = "5")
+    @NotNull(message = "评分星级 1-5分不能为空")
+    private Integer scores;
+
+    @Schema(description = "描述星级 1-5分", required = true, example = "5")
+    @NotNull(message = "描述星级 1-5分不能为空")
+    private Integer descriptionScores;
+
+    @Schema(description = "服务星级 1-5分", required = true, example = "5")
+    @NotNull(message = "服务星级 1-5分不能为空")
+    private Integer benefitScores;
+
+    @Schema(description = "评论内容", required = true, example = "哇,真的很丝滑凉快诶,好评")
+    @NotNull(message = "评论内容不能为空")
+    private String content;
+
+    @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]")
+    @Size(max = 9, message = "评论图片地址数组长度不能超过9张")
+    private List<String> picUrls;
+
 }

+ 47 - 4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/comment/vo/AppProductCommentRespVO.java

@@ -1,19 +1,27 @@
 package cn.iocoder.yudao.module.product.controller.app.comment.vo;
 
+import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
 import java.time.LocalDateTime;
 import java.util.List;
 
-@Schema(description = "用户APP - 商品评价 Response VO")
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+/**
+ * 用户APP - 商品评价详情 Response VO
+ *
+ * @author HUIHUI
+ */
+@Schema(description = "用户APP - 商品评价详情 Response VO")
 @Data
-@EqualsAndHashCode(callSuper = true)
 @ToString(callSuper = true)
-public class AppProductCommentRespVO extends AppProductCommentBaseVO {
+public class AppProductCommentRespVO {
 
     @Schema(description = "评价人的用户编号", required = true, example = "15721")
     private Long userId;
@@ -63,4 +71,39 @@ public class AppProductCommentRespVO extends AppProductCommentBaseVO {
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
     private LocalDateTime createTime;
 
+    @Schema(description = "商品SPU编号", required = true, example = "91192")
+    @NotNull(message = "商品SPU编号不能为空")
+    private Long spuId;
+
+    @Schema(description = "商品SPU名称", required = true, example = "清凉丝滑小短袖")
+    @NotNull(message = "商品SPU名称不能为空")
+    private String spuName;
+
+    @Schema(description = "商品SKU编号", required = true, example = "81192")
+    @NotNull(message = "商品SKU编号不能为空")
+    private Long skuId;
+
+    @Schema(description = "商品 SKU 属性", required = true)
+    private List<AppProductPropertyValueDetailRespVO> skuProperties;
+
+    @Schema(description = "评分星级 1-5分", required = true, example = "5")
+    @NotNull(message = "评分星级 1-5分不能为空")
+    private Integer scores;
+
+    @Schema(description = "描述星级 1-5分", required = true, example = "5")
+    @NotNull(message = "描述星级 1-5分不能为空")
+    private Integer descriptionScores;
+
+    @Schema(description = "服务星级 1-5分", required = true, example = "5")
+    @NotNull(message = "服务星级 1-5分不能为空")
+    private Integer benefitScores;
+
+    @Schema(description = "评论内容", required = true, example = "哇,真的很丝滑凉快诶,好评")
+    @NotNull(message = "评论内容不能为空")
+    private String content;
+
+    @Schema(description = "评论图片地址数组,以逗号分隔最多上传9张", required = true, example = "[https://www.iocoder.cn/xx.png, https://www.iocoder.cn/xxx.png]")
+    @Size(max = 9, message = "评论图片地址数组长度不能超过9张")
+    private List<String> picUrls;
+
 }

+ 4 - 0
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java

@@ -6,7 +6,9 @@ import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommen
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO;
+import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
+import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
 import org.mapstruct.Mapper;
 import org.mapstruct.Mapping;
 import org.mapstruct.Named;
@@ -36,6 +38,8 @@ public interface ProductCommentConvert {
 
     List<ProductCommentRespVO> convertList(List<ProductCommentDO> list);
 
+    List<AppProductPropertyValueDetailRespVO> convertList01(List<ProductSkuDO.Property> properties);
+
     PageResult<ProductCommentRespVO> convertPage(PageResult<ProductCommentDO> page);
 
     PageResult<AppProductCommentRespVO> convertPage02(PageResult<ProductCommentDO> pageResult);

+ 0 - 21
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java

@@ -6,14 +6,10 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
-import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import org.apache.ibatis.annotations.Mapper;
 
-import java.time.LocalDateTime;
-
 @Mapper
 public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> {
 
@@ -55,23 +51,6 @@ public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> {
         return selectPage(reqVO, queryWrapper);
     }
 
-    default void updateCommentVisible(Long id, Boolean visible) {
-        LambdaUpdateWrapper<ProductCommentDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<ProductCommentDO>()
-                .set(ProductCommentDO::getVisible, visible)
-                .eq(ProductCommentDO::getId, id);
-        update(null, lambdaUpdateWrapper);
-    }
-
-    default void commentReply(ProductCommentReplyVO replyVO, Long loginUserId) {
-        LambdaUpdateWrapper<ProductCommentDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<ProductCommentDO>()
-                .set(ProductCommentDO::getReplyStatus, Boolean.TRUE)
-                .set(ProductCommentDO::getReplyTime, LocalDateTime.now())
-                .set(ProductCommentDO::getReplyUserId, loginUserId)
-                .set(ProductCommentDO::getReplyContent, replyVO.getReplyContent())
-                .eq(ProductCommentDO::getId, replyVO.getId());
-        update(null, lambdaUpdateWrapper);
-    }
-
     default ProductCommentDO selectByUserIdAndOrderIdAndSpuId(Long userId, Long orderId, Long spuId) {
         return selectOne(new LambdaQueryWrapperX<ProductCommentDO>()
                 .eq(ProductCommentDO::getUserId, userId)

+ 2 - 4
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentService.java

@@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.product.service.comment;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
-import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO;
+import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO;
@@ -36,15 +36,13 @@ public interface ProductCommentService {
      */
     void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO);
 
-    // TODO @puhui999:replyComment
-
     /**
      * 商家回复
      *
      * @param replyVO     商家回复
      * @param loginUserId 管理后台商家登陆人 ID
      */
-    void replyComment(ProductCommentReplyVO replyVO, Long loginUserId);
+    void replyComment(ProductCommentReplyReqVO replyVO, Long loginUserId);
 
     /**
      * 获得商品评价分页

+ 37 - 3
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java

@@ -1,25 +1,36 @@
 package cn.iocoder.yudao.module.product.service.comment;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentCreateReqVO;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
-import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO;
+import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppProductCommentRespVO;
+import cn.iocoder.yudao.module.product.controller.app.property.vo.value.AppProductPropertyValueDetailRespVO;
 import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
+import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
 import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
 import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper;
+import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
 import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
 import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
@@ -42,6 +53,10 @@ public class ProductCommentServiceImpl implements ProductCommentService {
     @Resource
     private ProductSpuService productSpuService;
 
+    @Resource
+    @Lazy
+    private ProductSkuService productSkuService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public void updateCommentVisible(ProductCommentUpdateVisibleReqVO updateReqVO) {
@@ -55,7 +70,7 @@ public class ProductCommentServiceImpl implements ProductCommentService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void replyComment(ProductCommentReplyVO replyVO, Long loginUserId) {
+    public void replyComment(ProductCommentReplyReqVO replyVO, Long loginUserId) {
         // 校验评论是否存在
         ProductCommentDO productCommentDO = validateCommentExists(replyVO.getId());
         productCommentDO.setReplyTime(LocalDateTime.now());
@@ -127,7 +142,26 @@ public class ProductCommentServiceImpl implements ProductCommentService {
 
     @Override
     public PageResult<AppProductCommentRespVO> getCommentPage(AppCommentPageReqVO pageVO, Boolean visible) {
-        return ProductCommentConvert.INSTANCE.convertPage02(productCommentMapper.selectPage(pageVO, visible));
+        PageResult<AppProductCommentRespVO> result = ProductCommentConvert.INSTANCE.convertPage02(
+                productCommentMapper.selectPage(pageVO, visible));
+        Set<Long> skuIds = result.getList().stream().map(AppProductCommentRespVO::getSkuId).collect(Collectors.toSet());
+        List<ProductSkuDO> skuList = productSkuService.getSkuList(skuIds);
+        Map<Long, ProductSkuDO> skuDOMap = new HashMap<>(skuIds.size());
+        if (CollUtil.isNotEmpty(skuList)) {
+            skuDOMap.putAll(skuList.stream().collect(Collectors.toMap(ProductSkuDO::getId, c -> c)));
+        }
+        result.getList().forEach(item -> {
+            // 判断用户是否选择匿名
+            if (ObjectUtil.equal(item.getAnonymous(), true)) {
+                item.setUserNickname(ProductCommentDO.NICKNAME_ANONYMOUS);
+            }
+            ProductSkuDO productSkuDO = skuDOMap.get(item.getSkuId());
+            if (productSkuDO != null) {
+                List<AppProductPropertyValueDetailRespVO> skuProperties = ProductCommentConvert.INSTANCE.convertList01(productSkuDO.getProperties());
+                item.setSkuProperties(skuProperties);
+            }
+        });
+        return result;
     }
 
     @Override

+ 5 - 2
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java

@@ -5,7 +5,7 @@ import cn.hutool.core.util.RandomUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
-import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyVO;
+import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO;
 import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
 import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
@@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
 import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
 import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper;
 import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum;
+import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
 import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
 import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
 import org.junit.jupiter.api.Test;
@@ -52,6 +53,8 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest {
     private TradeOrderApi tradeOrderApi;
     @MockBean
     private ProductSpuService productSpuService;
+    @MockBean
+    private ProductSkuService productSkuService;
 
     public String generateNo() {
         return DateUtil.format(new Date(), "yyyyMMddHHmmss") + RandomUtil.randomInt(100000, 999999);
@@ -183,7 +186,7 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest {
 
         Long productCommentId = productComment.getId();
 
-        ProductCommentReplyVO replyVO = new ProductCommentReplyVO();
+        ProductCommentReplyReqVO replyVO = new ProductCommentReplyReqVO();
         replyVO.setId(productCommentId);
         replyVO.setReplyContent("测试");
         productCommentService.replyComment(replyVO, 1L);

+ 2 - 0
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java

@@ -148,4 +148,6 @@ public class AppTradeOrderController {
         return success(productCommentApi.createComment(TradeOrderConvert.INSTANCE.convert04(createReqVO), item.getOrderId()));
     }
 
+    // TODO 合并代码后发现只有商家回复功能 用户追评不要了吗?
+
 }