Commit f2d803c111341d9ee2d82ddbb40b3e447d5cd0fd
1 parent
4126e37d
mall + product:review 评论接口
Showing
14 changed files
with
92 additions
and
119 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
| ... | ... | @@ -6,7 +6,9 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 6 | 6 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 7 | 7 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 8 | 8 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 9 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 9 | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 11 | +import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | |
| 10 | 12 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 11 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | 14 | import io.swagger.v3.oas.annotations.Parameter; |
| ... | ... | @@ -22,8 +24,10 @@ import java.io.IOException; |
| 22 | 24 | import java.util.List; |
| 23 | 25 | import java.util.Map; |
| 24 | 26 | |
| 27 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 25 | 28 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 26 | 29 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 30 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; | |
| 27 | 31 | |
| 28 | 32 | /** |
| 29 | 33 | * 商品 SPU 相关接口 |
| ... | ... | @@ -38,6 +42,8 @@ public class ProductSpuController { |
| 38 | 42 | |
| 39 | 43 | @Resource |
| 40 | 44 | private ProductSpuService productSpuService; |
| 45 | + @Resource | |
| 46 | + private ProductSkuService productSkuService; | |
| 41 | 47 | |
| 42 | 48 | @PostMapping("/create") |
| 43 | 49 | @Operation(summary = "创建商品 SPU") |
| ... | ... | @@ -58,7 +64,7 @@ public class ProductSpuController { |
| 58 | 64 | @Operation(summary = "更新商品 SPU Status") |
| 59 | 65 | @PreAuthorize("@ss.hasPermission('product:spu:update')") |
| 60 | 66 | public CommonResult<Boolean> updateStatus(@Valid @RequestBody ProductSpuUpdateStatusReqVO updateReqVO) { |
| 61 | - productSpuService.updateStatus(updateReqVO); | |
| 67 | + productSpuService.updateSpuStatus(updateReqVO); | |
| 62 | 68 | return success(true); |
| 63 | 69 | } |
| 64 | 70 | |
| ... | ... | @@ -76,7 +82,14 @@ public class ProductSpuController { |
| 76 | 82 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 77 | 83 | @PreAuthorize("@ss.hasPermission('product:spu:query')") |
| 78 | 84 | public CommonResult<ProductSpuDetailRespVO> getSpuDetail(@RequestParam("id") Long id) { |
| 79 | - return success(productSpuService.getSpuDetail(id)); | |
| 85 | + // 获得商品 SPU | |
| 86 | + ProductSpuDO spu = productSpuService.getSpu(id); | |
| 87 | + if (spu == null) { | |
| 88 | + throw exception(SPU_NOT_EXISTS); | |
| 89 | + } | |
| 90 | + // 查询商品 SKU | |
| 91 | + List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); | |
| 92 | + return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); | |
| 80 | 93 | } |
| 81 | 94 | |
| 82 | 95 | @GetMapping("/get-simple-list") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/spu/AppProductSpuController.java
| ... | ... | @@ -6,7 +6,11 @@ import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetail |
| 6 | 6 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageItemRespVO; |
| 7 | 7 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 9 | +import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 9 | 10 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 11 | +import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | |
| 12 | +import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; | |
| 13 | +import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | |
| 10 | 14 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 11 | 15 | import io.swagger.v3.oas.annotations.Operation; |
| 12 | 16 | import io.swagger.v3.oas.annotations.Parameter; |
| ... | ... | @@ -19,8 +23,12 @@ import org.springframework.web.bind.annotation.RestController; |
| 19 | 23 | |
| 20 | 24 | import javax.annotation.Resource; |
| 21 | 25 | import javax.validation.Valid; |
| 26 | +import java.util.List; | |
| 22 | 27 | |
| 28 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 23 | 29 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 30 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_ENABLE; | |
| 31 | +import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SPU_NOT_EXISTS; | |
| 24 | 32 | |
| 25 | 33 | @Tag(name = "用户 APP - 商品 SPU") |
| 26 | 34 | @RestController |
| ... | ... | @@ -30,6 +38,10 @@ public class AppProductSpuController { |
| 30 | 38 | |
| 31 | 39 | @Resource |
| 32 | 40 | private ProductSpuService productSpuService; |
| 41 | + @Resource | |
| 42 | + private ProductSkuService productSkuService; | |
| 43 | + @Resource | |
| 44 | + private ProductPropertyValueService productPropertyValueService; | |
| 33 | 45 | |
| 34 | 46 | @GetMapping("/page") |
| 35 | 47 | @Operation(summary = "获得商品 SPU 分页") |
| ... | ... | @@ -38,12 +50,23 @@ public class AppProductSpuController { |
| 38 | 50 | return success(ProductSpuConvert.INSTANCE.convertPageForGetSpuPage(pageResult)); |
| 39 | 51 | } |
| 40 | 52 | |
| 41 | - // TODO 芋艿:等会看看 | |
| 42 | 53 | @GetMapping("/get-detail") |
| 43 | 54 | @Operation(summary = "获得商品 SPU 明细") |
| 44 | 55 | @Parameter(name = "id", description = "编号", required = true) |
| 45 | 56 | public CommonResult<AppProductSpuDetailRespVO> getSpuDetail(@RequestParam("id") Long id) { |
| 46 | - return success(productSpuService.getAppProductSpuDetail(id)); | |
| 57 | + // 获得商品 SPU | |
| 58 | + ProductSpuDO spu = productSpuService.getSpu(id); | |
| 59 | + if (spu == null) { | |
| 60 | + throw exception(SPU_NOT_EXISTS); | |
| 61 | + } | |
| 62 | + if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { | |
| 63 | + throw exception(SPU_NOT_ENABLE); | |
| 64 | + } | |
| 65 | + | |
| 66 | + // 查询商品 SKU | |
| 67 | + List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); | |
| 68 | + // 拼接 | |
| 69 | + return success(ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus)); | |
| 47 | 70 | } |
| 48 | 71 | |
| 49 | 72 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyDO.java
| ... | ... | @@ -22,13 +22,13 @@ import lombok.*; |
| 22 | 22 | public class ProductPropertyDO extends BaseDO { |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * 默认属性id | |
| 25 | + * SPU 单规格时,默认属性 id | |
| 26 | 26 | */ |
| 27 | - public static final Long PROPERTY_ID = 0L; | |
| 27 | + public static final Long ID_DEFAULT = 0L; | |
| 28 | 28 | /** |
| 29 | - * 默认属性名字 | |
| 29 | + * SPU 单规格时,默认属性名字 | |
| 30 | 30 | */ |
| 31 | - public static final String PROPERTY_NAME = "默认"; | |
| 31 | + public static final String NAME_DEFAULT = "默认"; | |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * 主键 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/property/ProductPropertyValueDO.java
| ... | ... | @@ -23,13 +23,13 @@ import lombok.*; |
| 23 | 23 | public class ProductPropertyValueDO extends BaseDO { |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * 默认属性值id | |
| 26 | + * SPU 单规格时,默认属性值 id | |
| 27 | 27 | */ |
| 28 | - public static final Long VALUE_ID = 0L; | |
| 28 | + public static final Long ID_DEFAULT = 0L; | |
| 29 | 29 | /** |
| 30 | - * 默认属性值名字 | |
| 30 | + * SPU 单规格时,默认属性值名字 | |
| 31 | 31 | */ |
| 32 | - public static final String VALUE_NAME = "默认"; | |
| 32 | + public static final String NAME_DEFAULT = "默认"; | |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * 主键 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/mysql/comment/ProductCommentMapper.java
| ... | ... | @@ -35,6 +35,7 @@ public interface ProductCommentMapper extends BaseMapperX<ProductCommentDO> { |
| 35 | 35 | .orderByDesc(ProductCommentDO::getId)); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | + // TODO 芋艿:在看看这块 | |
| 38 | 39 | static void appendTabQuery(LambdaQueryWrapperX<ProductCommentDO> queryWrapper, Integer type) { |
| 39 | 40 | // 构建好评查询语句 |
| 40 | 41 | if (ObjectUtil.equal(type, AppCommentPageReqVO.FAVOURABLE_COMMENT)) { | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/category/ProductCategoryServiceImpl.java
| ... | ... | @@ -68,8 +68,8 @@ public class ProductCategoryServiceImpl implements ProductCategoryService { |
| 68 | 68 | throw exception(CATEGORY_EXISTS_CHILDREN); |
| 69 | 69 | } |
| 70 | 70 | // 校验分类是否绑定了 SPU |
| 71 | - Long count = productSpuService.getSpuCountByCategoryId(id); | |
| 72 | - if (0 != count) { | |
| 71 | + Long spuCount = productSpuService.getSpuCountByCategoryId(id); | |
| 72 | + if (spuCount > 0) { | |
| 73 | 73 | throw exception(CATEGORY_HAVE_BIND_SPU); |
| 74 | 74 | } |
| 75 | 75 | // 删除 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImpl.java
| ... | ... | @@ -31,6 +31,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU |
| 31 | 31 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; |
| 32 | 32 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; |
| 33 | 33 | |
| 34 | +// TODO @芋艿:详细 review 下 | |
| 34 | 35 | /** |
| 35 | 36 | * 商品评论 Service 实现类 |
| 36 | 37 | * |
| ... | ... | @@ -73,13 +74,17 @@ public class ProductCommentServiceImpl implements ProductCommentService { |
| 73 | 74 | public Map<String, Long> getCommentPageTabsCount(Long spuId, Boolean visible) { |
| 74 | 75 | Map<String, Long> countMap = new HashMap<>(4); |
| 75 | 76 | // 查询商品 id = spuId 的所有评论数量 |
| 76 | - countMap.put(AppCommentPageReqVO.ALL_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.ALL)); | |
| 77 | + countMap.put(AppCommentPageReqVO.ALL_COUNT, | |
| 78 | + productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.ALL)); | |
| 77 | 79 | // 查询商品 id = spuId 的所有好评数量 |
| 78 | - countMap.put(AppCommentPageReqVO.FAVOURABLE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.FAVOURABLE_COMMENT)); | |
| 80 | + countMap.put(AppCommentPageReqVO.FAVOURABLE_COMMENT_COUNT, | |
| 81 | + productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.FAVOURABLE_COMMENT)); | |
| 79 | 82 | // 查询商品 id = spuId 的所有中评数量 |
| 80 | - countMap.put(AppCommentPageReqVO.MEDIOCRE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT)); | |
| 83 | + countMap.put(AppCommentPageReqVO.MEDIOCRE_COMMENT_COUNT, | |
| 84 | + productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.MEDIOCRE_COMMENT)); | |
| 81 | 85 | // 查询商品 id = spuId 的所有差评数量 |
| 82 | - countMap.put(AppCommentPageReqVO.NEGATIVE_COMMENT_COUNT, productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT)); | |
| 86 | + countMap.put(AppCommentPageReqVO.NEGATIVE_COMMENT_COUNT, | |
| 87 | + productCommentMapper.selectTabCount(spuId, visible, AppCommentPageReqVO.NEGATIVE_COMMENT)); | |
| 83 | 88 | return countMap; |
| 84 | 89 | } |
| 85 | 90 | |
| ... | ... | @@ -101,13 +106,14 @@ public class ProductCommentServiceImpl implements ProductCommentService { |
| 101 | 106 | |
| 102 | 107 | @Override |
| 103 | 108 | public void createComment(ProductCommentDO productComment, Boolean system) { |
| 109 | + // TODO @puhui999:这里不区分是否为 system;直接都校验 | |
| 104 | 110 | if (!system) { |
| 105 | - // TODO 判断订单是否存在 fix | |
| 111 | + // TODO 判断订单是否存在 fix; | |
| 112 | + // TODO @puhui999:改成 order 那有个 comment 接口,哪里校验下;商品评论这里不校验订单是否存在哈 | |
| 106 | 113 | TradeOrderRespDTO order = tradeOrderApi.getOrder(productComment.getOrderId()); |
| 107 | 114 | if (null == order) { |
| 108 | 115 | throw exception(ORDER_NOT_FOUND); |
| 109 | 116 | } |
| 110 | - // TODO 判断 SPU 是否存在 fix | |
| 111 | 117 | ProductSpuDO spu = productSpuService.getSpu(productComment.getSpuId()); |
| 112 | 118 | if (null == spu) { |
| 113 | 119 | throw exception(SPU_NOT_EXISTS); |
| ... | ... | @@ -147,5 +153,4 @@ public class ProductCommentServiceImpl implements ProductCommentService { |
| 147 | 153 | return productComment; |
| 148 | 154 | } |
| 149 | 155 | |
| 150 | - | |
| 151 | 156 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/sku/ProductSkuServiceImpl.java
| ... | ... | @@ -83,21 +83,20 @@ public class ProductSkuServiceImpl implements ProductSkuService { |
| 83 | 83 | if (CollUtil.isEmpty(skus)) { |
| 84 | 84 | throw exception(SKU_NOT_EXISTS); |
| 85 | 85 | } |
| 86 | - // 单规格处理 | |
| 86 | + // 单规格,赋予单规格默认属性 | |
| 87 | 87 | if (ObjectUtil.equal(specType, false)) { |
| 88 | 88 | ProductSkuCreateOrUpdateReqVO skuVO = skus.get(0); |
| 89 | - // 赋予单规格默认属性 | |
| 90 | 89 | List<ProductSkuBaseVO.Property> properties = new ArrayList<>(); |
| 91 | 90 | ProductSkuBaseVO.Property property = new ProductSkuBaseVO.Property(); |
| 92 | - property.setPropertyId(ProductPropertyDO.PROPERTY_ID); | |
| 93 | - property.setPropertyName(ProductPropertyDO.PROPERTY_NAME); | |
| 94 | - property.setValueId(ProductPropertyValueDO.VALUE_ID); | |
| 95 | - property.setValueName(ProductPropertyValueDO.VALUE_NAME); | |
| 91 | + property.setPropertyId(ProductPropertyDO.ID_DEFAULT); | |
| 92 | + property.setPropertyName(ProductPropertyDO.NAME_DEFAULT); | |
| 93 | + property.setValueId(ProductPropertyValueDO.ID_DEFAULT); | |
| 94 | + property.setValueName(ProductPropertyValueDO.NAME_DEFAULT); | |
| 96 | 95 | properties.add(property); |
| 97 | 96 | skuVO.setProperties(properties); |
| 98 | - // 单规格不需要后续的校验 | |
| 99 | - return; | |
| 97 | + return; // 单规格不需要后续的校验 | |
| 100 | 98 | } |
| 99 | + | |
| 101 | 100 | // 1、校验属性项存在 |
| 102 | 101 | Set<Long> propertyIds = skus.stream().filter(p -> p.getProperties() != null) |
| 103 | 102 | // 遍历多个 Property 属性 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuService.java
| ... | ... | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.product.service.spu; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 5 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; | |
| 6 | 5 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 7 | 6 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 8 | 7 | |
| ... | ... | @@ -107,40 +106,25 @@ public interface ProductSpuService { |
| 107 | 106 | void updateSpuStock(Map<Long, Integer> stockIncrCounts); |
| 108 | 107 | |
| 109 | 108 | /** |
| 110 | - * 得到spu详细 | |
| 109 | + * 更新 SPU 状态 | |
| 111 | 110 | * |
| 112 | - * @param id id | |
| 113 | - * @return {@link ProductSpuDetailRespVO} | |
| 111 | + * @param updateReqVO 更新请求 | |
| 114 | 112 | */ |
| 115 | - ProductSpuDetailRespVO getSpuDetail(Long id); | |
| 113 | + void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO); | |
| 116 | 114 | |
| 117 | 115 | /** |
| 118 | - * 更新状态 | |
| 116 | + * 获取 SPU 列表标签对应的 Count 数量 | |
| 119 | 117 | * |
| 120 | - * @param updateReqVO 更新请求签证官 | |
| 121 | - */ | |
| 122 | - void updateStatus(ProductSpuUpdateStatusReqVO updateReqVO); | |
| 123 | - | |
| 124 | - /** | |
| 125 | - * 获取spu列表标签对应的Count数量 | |
| 126 | - * | |
| 127 | - * @return {@link Map}<{@link Integer}, {@link Integer}> | |
| 118 | + * @return Count 数量 | |
| 128 | 119 | */ |
| 129 | 120 | Map<Integer, Long> getTabsCount(); |
| 130 | 121 | |
| 131 | 122 | /** |
| 132 | - * 通过分类 id 查询 spu 个数 | |
| 123 | + * 通过分类 categoryId 查询 SPU 个数 | |
| 133 | 124 | * |
| 134 | - * @param id 分类 id | |
| 135 | - * @return spu | |
| 125 | + * @param categoryId 分类 categoryId | |
| 126 | + * @return SPU 数量 | |
| 136 | 127 | */ |
| 137 | - Long getSpuCountByCategoryId(Long id); | |
| 128 | + Long getSpuCountByCategoryId(Long categoryId); | |
| 138 | 129 | |
| 139 | - /** | |
| 140 | - * 通过 spu id 获取商品 SPU 明细 | |
| 141 | - * | |
| 142 | - * @param id id | |
| 143 | - * @return 用户 App - 商品 SPU 明细 | |
| 144 | - */ | |
| 145 | - AppProductSpuDetailRespVO getAppProductSpuDetail(Long id); | |
| 146 | 130 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| ... | ... | @@ -7,21 +7,15 @@ import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | 7 | import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.product.controller.admin.sku.vo.ProductSkuCreateOrUpdateReqVO; |
| 9 | 9 | import cn.iocoder.yudao.module.product.controller.admin.spu.vo.*; |
| 10 | -import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuDetailRespVO; | |
| 11 | 10 | import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageReqVO; |
| 12 | -import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | |
| 13 | 11 | import cn.iocoder.yudao.module.product.convert.spu.ProductSpuConvert; |
| 14 | 12 | import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO; |
| 15 | -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyDO; | |
| 16 | -import cn.iocoder.yudao.module.product.dal.dataobject.property.ProductPropertyValueDO; | |
| 17 | -import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | |
| 18 | 13 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 19 | 14 | import cn.iocoder.yudao.module.product.dal.mysql.spu.ProductSpuMapper; |
| 20 | 15 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| 21 | 16 | import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; |
| 22 | 17 | import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; |
| 23 | 18 | import cn.iocoder.yudao.module.product.service.property.ProductPropertyValueService; |
| 24 | -import cn.iocoder.yudao.module.product.service.property.bo.ProductPropertyValueDetailRespBO; | |
| 25 | 19 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 26 | 20 | import com.google.common.collect.Maps; |
| 27 | 21 | import org.springframework.context.annotation.Lazy; |
| ... | ... | @@ -114,9 +108,9 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 114 | 108 | spu.setPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getPrice)); |
| 115 | 109 | // sku 单价最低的商品的市场价格 |
| 116 | 110 | spu.setMarketPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getMarketPrice)); |
| 117 | - // sku单价最低的商品的成本价格 | |
| 111 | + // sku 单价最低的商品的成本价格 | |
| 118 | 112 | spu.setCostPrice(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getCostPrice)); |
| 119 | - // sku单价最低的商品的条形码 | |
| 113 | + // sku 单价最低的商品的条形码 | |
| 120 | 114 | spu.setBarCode(getMinValue(skus, ProductSkuCreateOrUpdateReqVO::getBarCode)); |
| 121 | 115 | // skus 库存总数 |
| 122 | 116 | spu.setStock(getSumValue(skus, ProductSkuCreateOrUpdateReqVO::getStock, Integer::sum)); |
| ... | ... | @@ -214,20 +208,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 214 | 208 | } |
| 215 | 209 | |
| 216 | 210 | @Override |
| 217 | - public ProductSpuDetailRespVO getSpuDetail(Long id) { | |
| 218 | - // 获得商品 SPU | |
| 219 | - ProductSpuDO spu = getSpu(id); | |
| 220 | - if (spu == null) { | |
| 221 | - throw exception(SPU_NOT_EXISTS); | |
| 222 | - } | |
| 223 | - // 查询商品 SKU | |
| 224 | - List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); | |
| 225 | - return ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus); | |
| 226 | - } | |
| 227 | - | |
| 228 | - @Override | |
| 229 | 211 | @Transactional(rollbackFor = Exception.class) |
| 230 | - public void updateStatus(ProductSpuUpdateStatusReqVO updateReqVO) { | |
| 212 | + public void updateSpuStatus(ProductSpuUpdateStatusReqVO updateReqVO) { | |
| 231 | 213 | // 校验存在 |
| 232 | 214 | validateSpuExists(updateReqVO.getId()); |
| 233 | 215 | |
| ... | ... | @@ -258,39 +240,8 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 258 | 240 | } |
| 259 | 241 | |
| 260 | 242 | @Override |
| 261 | - public Long getSpuCountByCategoryId(Long id) { | |
| 262 | - return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, id); | |
| 263 | - } | |
| 264 | - | |
| 265 | - @Override | |
| 266 | - public AppProductSpuDetailRespVO getAppProductSpuDetail(Long id) { | |
| 267 | - // 获得商品 SPU | |
| 268 | - ProductSpuDO spu = getSpu(id); | |
| 269 | - if (spu == null) { | |
| 270 | - throw exception(SPU_NOT_EXISTS); | |
| 271 | - } | |
| 272 | - if (!ProductSpuStatusEnum.isEnable(spu.getStatus())) { | |
| 273 | - throw exception(SPU_NOT_ENABLE); | |
| 274 | - } | |
| 275 | - | |
| 276 | - // 查询商品 SKU | |
| 277 | - List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); | |
| 278 | - List<ProductPropertyValueDetailRespBO> propertyValues = new ArrayList<>(); | |
| 279 | - // 单规格商品 赋予默认属性值 | |
| 280 | - if (ObjectUtil.equal(spu.getSpecType(), false)) { | |
| 281 | - ProductPropertyValueDetailRespBO respBO = new ProductPropertyValueDetailRespBO(); | |
| 282 | - respBO.setPropertyId(ProductPropertyDO.PROPERTY_ID); | |
| 283 | - respBO.setPropertyName(ProductPropertyDO.PROPERTY_NAME); | |
| 284 | - respBO.setValueId(ProductPropertyValueDO.VALUE_ID); | |
| 285 | - respBO.setValueName(ProductPropertyValueDO.VALUE_NAME); | |
| 286 | - propertyValues.add(respBO); | |
| 287 | - } else { | |
| 288 | - // 多规格商品则查询商品属性 | |
| 289 | - propertyValues = productPropertyValueService | |
| 290 | - .getPropertyValueDetailList(ProductSkuConvert.INSTANCE.convertPropertyValueIds(skus)); | |
| 291 | - } | |
| 292 | - // 拼接 | |
| 293 | - return ProductSpuConvert.INSTANCE.convertForGetSpuDetail(spu, skus, propertyValues); | |
| 243 | + public Long getSpuCountByCategoryId(Long categoryId) { | |
| 244 | + return productSpuMapper.selectCount(ProductSpuDO::getCategoryId, categoryId); | |
| 294 | 245 | } |
| 295 | 246 | |
| 296 | 247 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/test/java/cn/iocoder/yudao/module/product/service/comment/ProductCommentServiceImplTest.java
| ... | ... | @@ -34,6 +34,7 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; |
| 34 | 34 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 35 | 35 | import static org.junit.jupiter.api.Assertions.assertFalse; |
| 36 | 36 | |
| 37 | +// TODO 芋艿:单测详细 review 下 | |
| 37 | 38 | /** |
| 38 | 39 | * {@link ProductCommentServiceImpl} 的单元测试类 |
| 39 | 40 | * | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/order/dto/TradeOrderRespDTO.java
| ... | ... | @@ -23,26 +23,24 @@ public class TradeOrderRespDTO { |
| 23 | 23 | private Long id; |
| 24 | 24 | /** |
| 25 | 25 | * 订单流水号 |
| 26 | - * <p> | |
| 26 | + * | |
| 27 | 27 | * 例如说,1146347329394184195 |
| 28 | 28 | */ |
| 29 | 29 | private String no; |
| 30 | 30 | /** |
| 31 | 31 | * 订单类型 |
| 32 | - * <p> | |
| 32 | + * | |
| 33 | 33 | * 枚举 {@link TradeOrderTypeEnum} |
| 34 | 34 | */ |
| 35 | 35 | private Integer type; |
| 36 | 36 | /** |
| 37 | 37 | * 订单来源 |
| 38 | - * <p> | |
| 38 | + * | |
| 39 | 39 | * 枚举 {@link TerminalEnum} |
| 40 | 40 | */ |
| 41 | 41 | private Integer terminal; |
| 42 | 42 | /** |
| 43 | 43 | * 用户编号 |
| 44 | - * <p> | |
| 45 | - * 关联 MemberUserDO 的 id 编号 | |
| 46 | 44 | */ |
| 47 | 45 | private Long userId; |
| 48 | 46 | /** |
| ... | ... | @@ -55,7 +53,7 @@ public class TradeOrderRespDTO { |
| 55 | 53 | private String userRemark; |
| 56 | 54 | /** |
| 57 | 55 | * 订单状态 |
| 58 | - * <p> | |
| 56 | + * | |
| 59 | 57 | * 枚举 {@link TradeOrderStatusEnum} |
| 60 | 58 | */ |
| 61 | 59 | private Integer status; |
| ... | ... | @@ -73,7 +71,7 @@ public class TradeOrderRespDTO { |
| 73 | 71 | private LocalDateTime cancelTime; |
| 74 | 72 | /** |
| 75 | 73 | * 取消类型 |
| 76 | - * <p> | |
| 74 | + * | |
| 77 | 75 | * 枚举 {@link TradeOrderCancelTypeEnum} |
| 78 | 76 | */ |
| 79 | 77 | private Integer cancelType; |
| ... | ... | @@ -83,9 +81,6 @@ public class TradeOrderRespDTO { |
| 83 | 81 | private String remark; |
| 84 | 82 | /** |
| 85 | 83 | * 是否评价 |
| 86 | - * <p> | |
| 87 | - * true - 已评价 | |
| 88 | - * false - 未评价 | |
| 89 | 84 | */ |
| 90 | 85 | private Boolean commentStatus; |
| 91 | 86 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/delivery/DeliveryExpressTemplateController.java
| ... | ... | @@ -70,7 +70,6 @@ public class DeliveryExpressTemplateController { |
| 70 | 70 | return success(DeliveryExpressTemplateConvert.INSTANCE.convertList(list)); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - // TODO @puhui999:DeliveryExpressTemplateRespVO 搞个 simple 的哈 fix | |
| 74 | 73 | @GetMapping("/list-all-simple") |
| 75 | 74 | @Operation(summary = "获取快递模版精简信息列表", description = "主要用于前端的下拉选项") |
| 76 | 75 | public CommonResult<List<DeliveryExpressTemplateSimpleRespVO>> getSimpleTemplateList() { | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderServiceImpl.java
| ... | ... | @@ -100,6 +100,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 100 | 100 | private AdminUserApi adminUserApi; |
| 101 | 101 | @Resource |
| 102 | 102 | private NotifyMessageSendApi notifyMessageSendApi; |
| 103 | + | |
| 103 | 104 | @Resource |
| 104 | 105 | private TradeOrderProperties tradeOrderProperties; |
| 105 | 106 | |
| ... | ... | @@ -356,6 +357,7 @@ public class TradeOrderServiceImpl implements TradeOrderService { |
| 356 | 357 | // TODO 芋艿:发送订单变化的消息 |
| 357 | 358 | |
| 358 | 359 | // TODO 芋艿:发送站内信 fix |
| 360 | + // TODO @puhui999:使用 sendSingleMessageToMember 呀;走模版;不用判断模版是否存在哈 | |
| 359 | 361 | // 1、获取模版编码为 order_delivery 的模版,判断是否存在 存在放回 true |
| 360 | 362 | if (!notifyMessageSendApi.validateNotifyTemplate("order_delivery")) { |
| 361 | 363 | // 1、1 站内信模版不存在则创建模版 | ... | ... |