diff --git a/sql/mysql/product_comment.sql b/sql/mysql/product_comment.sql deleted file mode 100644 index f567e2923..000000000 --- a/sql/mysql/product_comment.sql +++ /dev/null @@ -1,14 +0,0 @@ --- 1.冗余 SKU 图片地址, 规格 -alter table product_comment - add column sku_pic_url varchar(256) not null comment '图片地址' after sku_id; - -alter table product_comment - add column sku_properties varchar(512) null - comment '属性数组,JSON 格式 [{propertId: , valueId: }, {propertId: , valueId: }]' after sku_pic_url; - --- 2.修复已有数据 -update product_comment pc - join product_sku ps on pc.spu_id = ps.spu_id -set pc.sku_pic_url = ps.pic_url, - pc.sku_properties = ps.properties -where pc.sku_id is not null; \ No newline at end of file diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java index f44acd4ab..70e95cd9a 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/ProductCommentController.java @@ -32,7 +32,7 @@ public class ProductCommentController { @PreAuthorize("@ss.hasPermission('product:comment:query')") public CommonResult> getCommentPage(@Valid ProductCommentPageReqVO pageVO) { PageResult pageResult = productCommentService.getCommentPage(pageVO); - return success(ProductCommentConvert.INSTANCE.convertPage2(pageResult)); + return success(ProductCommentConvert.INSTANCE.convertPage(pageResult)); } @PutMapping("/update-visible") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java index 8e3c732a5..d03359f7f 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/comment/vo/ProductCommentRespVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.product.controller.admin.comment.vo; +import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuBaseVO; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; @@ -7,6 +8,7 @@ import lombok.ToString; import javax.validation.constraints.NotNull; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 商品评价 Response VO") @Data @@ -23,10 +25,10 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { @Schema(description = "交易订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24428") private Long orderId; - @Schema(description = "是否可见:[true:显示 false:隐藏]", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED) private Boolean visible; - @Schema(description = "商家是否回复:[1:回复 0:未回复]", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(description = "商家是否回复", requiredMode = Schema.RequiredMode.REQUIRED) private Boolean replyStatus; @Schema(description = "回复管理员编号", example = "9527") @@ -54,4 +56,8 @@ public class ProductCommentRespVO extends ProductCommentBaseVO { @Schema(description = "商品 SKU 图片地址", example = "https://www.iocoder.cn/yudao.jpg") private String skuPicUrl; + + @Schema(description = "商品 SKU 规格值数组") + private List skuProperties; + } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java index 038642db1..9acbacd66 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/ProductSkuController.java @@ -1,57 +1,14 @@ package cn.iocoder.yudao.module.product.controller.admin.sku; -import cn.hutool.core.collection.CollUtil; -import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.util.collection.MapUtils; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO; -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; -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.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.annotation.Resource; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; - -@Tag(name = "管理后台 - 商品 sku") +@Tag(name = "管理后台 - 商品 SKU") @RestController @RequestMapping("/product/sku") @Validated public class ProductSkuController { - @Resource - private ProductSkuService productSkuService; - @Resource - private ProductSpuService productSpuService; - - @GetMapping("/get-option-list") - @Operation(summary = "获得商品 SKU 选项的列表") -// @PreAuthorize("@ss.hasPermission('product:sku:query')") - public CommonResult> getSkuOptionList() { - // 获得 SKU 列表 - List skus = productSkuService.getSkuList(); - if (CollUtil.isEmpty(skus)) { - return success(Collections.emptyList()); - } - - // 获得对应的 SPU 映射 - Map spuMap = productSpuService.getSpuMap(convertSet(skus, ProductSkuDO::getSpuId)); - // 转换为返回结果 - List skuVOs = ProductSkuConvert.INSTANCE.convertList05(skus); - skuVOs.forEach(sku -> MapUtils.findAndThen(spuMap, sku.getSpuId(), - spu -> sku.setSpuId(spu.getId()).setSpuName(spu.getName()))); - return success(skuVOs); - } - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java deleted file mode 100644 index f06ecc358..000000000 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/sku/vo/ProductSkuOptionRespVO.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.yudao.module.product.controller.admin.sku.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Data; - -@Schema(description = "管理后台 - 商品 SKU 选项 Response VO") // 用于前端 SELECT 选项 -@Data -public class ProductSkuOptionRespVO { - - @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "商品 SKU 名字", example = "红色") - private String name; - - @Schema(description = "销售价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private String price; - - @Schema(description = "库存", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") - private Integer stock; - - // ========== 商品 SPU 信息 ========== - - @Schema(description = "商品 SPU 编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - private Long spuId; - - @Schema(description = "商品 SPU 名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "iPhone 11") - private String spuName; - -} diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java index 6fac8823c..944eb2bc2 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/comment/ProductCommentConvert.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.product.convert.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.framework.common.util.collection.CollectionUtils; @@ -23,10 +22,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.List; import java.util.Map; -import java.util.Objects; -import java.util.stream.Collectors; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; /** @@ -122,35 +118,15 @@ public interface ProductCommentConvert { List convertList02(List list); - default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spuDO, ProductSkuDO skuDO) { + default ProductCommentDO convert(ProductCommentCreateReqVO createReq, ProductSpuDO spu, ProductSkuDO sku) { ProductCommentDO commentDO = convert(createReq); - if (spuDO != null) { - commentDO.setSpuId(spuDO.getId()); - commentDO.setSpuName(spuDO.getName()); + if (spu != null) { + commentDO.setSpuId(spu.getId()).setSpuName(spu.getName()); } - if (skuDO != null) { - commentDO.setSkuPicUrl(skuDO.getPicUrl()); - commentDO.setSkuProperties(skuDO.getProperties()); + if (sku != null) { + commentDO.setSkuPicUrl(sku.getPicUrl()).setSkuProperties(sku.getProperties()); } return commentDO; } - default PageResult convertPage2(PageResult pageResult) { - Map> propertiesMap = convertMap(pageResult.getList(), - ProductCommentDO::getId, - // 这里会有NULL异常, 需要处理一下 - comment -> CollUtil.emptyIfNull(comment.getSkuProperties())); - - PageResult result = convertPage(pageResult); - for (ProductCommentRespVO vo : result.getList()) { - findAndThen(propertiesMap, vo.getId(), properties -> { - String propertyNames = properties.stream() - .map(ProductSkuDO.Property::getValueName) - .filter(Objects::nonNull) - .collect(Collectors.joining(" ")); - vo.setSpuName(vo.getSpuName() + " " + propertyNames); - }); - } - return result; - } } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java index 2b78a00ef..5065a9c40 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/sku/ProductSkuConvert.java @@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuUpdateStockReqDTO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; -import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuOptionRespVO; import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuRespVO; import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; import org.mapstruct.Mapper; @@ -44,8 +43,6 @@ public interface ProductSkuConvert { List convertList04(List list); - List convertList05(List skus); - /** * 获得 SPU 的库存变化 Map * diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java index ff4e78468..40b04caf0 100644 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java +++ b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/comment/ProductCommentDO.java @@ -73,11 +73,14 @@ public class ProductCommentDO extends BaseDO { /** * 商品 SPU 编号 + * * 关联 {@link ProductSpuDO#getId()} */ private Long spuId; /** * 商品 SPU 名称 + * + * 关联 {@link ProductSpuDO#getName()} */ private String spuName; /** @@ -88,10 +91,14 @@ public class ProductCommentDO extends BaseDO { private Long skuId; /** * 商品 SKU 图片地址 + * + * 关联 {@link ProductSkuDO#getPicUrl()} */ private String skuPicUrl; /** * 属性数组,JSON 格式 + * + * 关联 {@link ProductSkuDO#getProperties()} */ @TableField(typeHandler = ProductSkuDO.PropertyTypeHandler.class) private List skuProperties; diff --git a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java index a107cabe3..8801ef33d 100644 --- a/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java +++ b/yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/point/MemberPointRecordServiceImpl.java @@ -81,17 +81,12 @@ public class MemberPointRecordServiceImpl implements MemberPointRecordService { // 2. 增加积分记录 MemberUserDO user = memberUserService.getUser(userId); Integer userPoint = ObjectUtil.defaultIfNull(user.getPoint(), 0); - // 用户变动后的积分 - Integer totalPoint = userPoint + point; - MemberPointRecordDO recordDO = new MemberPointRecordDO() - .setUserId(userId) - .setBizId(bizId) - .setBizType(bizType.getType()) - .setTitle(bizType.getName()) - .setDescription(StrUtil.format(bizType.getDescription(), point)) - .setPoint(point) - .setTotalPoint(totalPoint); - recordMapper.insert(recordDO); + Integer totalPoint = userPoint + point; // 用户变动后的积分 + MemberPointRecordDO record = new MemberPointRecordDO() + .setUserId(userId).setBizId(bizId).setBizType(bizType.getType()) + .setTitle(bizType.getName()).setDescription(StrUtil.format(bizType.getDescription(), point)) + .setPoint(point).setTotalPoint(totalPoint); + recordMapper.insert(record); // 3. 更新用户积分 memberUserService.updateUserPoint(userId, totalPoint);