Commit 3672d0f245a29cb64724752a53478ab828878266
1 parent
6723cae7
商品模块移除对营销模块的依赖
Showing
5 changed files
with
5 additions
and
69 deletions
yudao-module-mall/yudao-module-product-biz/pom.xml
| ... | ... | @@ -28,11 +28,6 @@ |
| 28 | 28 | <artifactId>yudao-module-member-api</artifactId> |
| 29 | 29 | <version>${revision}</version> |
| 30 | 30 | </dependency> |
| 31 | - <dependency> | |
| 32 | - <groupId>cn.iocoder.boot</groupId> | |
| 33 | - <artifactId>yudao-module-promotion-api</artifactId> | |
| 34 | - <version>${revision}</version> | |
| 35 | - </dependency> | |
| 36 | 31 | |
| 37 | 32 | <!-- 业务组件 --> |
| 38 | 33 | <dependency> | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java
| ... | ... | @@ -11,8 +11,6 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 11 | 11 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| 12 | 12 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 13 | 13 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; |
| 14 | -import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi; | |
| 15 | -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; | |
| 16 | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -45,9 +43,6 @@ public class ProductSpuController { |
| 45 | 43 | @Resource |
| 46 | 44 | private ProductSkuService productSkuService; |
| 47 | 45 | |
| 48 | - @Resource | |
| 49 | - private CouponTemplateApi couponTemplateApi; | |
| 50 | - | |
| 51 | 46 | @PostMapping("/create") |
| 52 | 47 | @Operation(summary = "创建商品 SPU") |
| 53 | 48 | @PreAuthorize("@ss.hasPermission('product:spu:create')") |
| ... | ... | @@ -92,11 +87,7 @@ public class ProductSpuController { |
| 92 | 87 | } |
| 93 | 88 | // 查询商品 SKU |
| 94 | 89 | List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); |
| 95 | - // 查询优惠卷 | |
| 96 | - // TODO @puhui999:优惠劵的信息,要不交给前端读取?主要是为了避免商品依赖 promotion 模块哈; | |
| 97 | - List<CouponTemplateRespDTO> couponTemplateList = couponTemplateApi.getCouponTemplateListByIds( | |
| 98 | - spu.getGiveCouponTemplateIds()); | |
| 99 | - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, couponTemplateList)); | |
| 90 | + return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); | |
| 100 | 91 | } |
| 101 | 92 | |
| 102 | 93 | @GetMapping("/list-all-simple") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
| ... | ... | @@ -96,9 +96,6 @@ public class ProductSpuBaseVO { |
| 96 | 96 | @NotNull(message = "商品赠送积分不能为空") |
| 97 | 97 | private Integer giveIntegral; |
| 98 | 98 | |
| 99 | - @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称") | |
| 100 | - private List<GiveCouponTemplate> giveCouponTemplates; | |
| 101 | - | |
| 102 | 99 | @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") |
| 103 | 100 | @NotNull(message = "商品分销类型不能为空") |
| 104 | 101 | private Boolean subCommissionType; |
| ... | ... | @@ -111,16 +108,4 @@ public class ProductSpuBaseVO { |
| 111 | 108 | @Schema(description = "虚拟销量", example = "66") |
| 112 | 109 | private Integer virtualSalesCount; |
| 113 | 110 | |
| 114 | - @Schema(description = "管理后台 - 商品 SPU 赠送的优惠卷") | |
| 115 | - @Data | |
| 116 | - public static class GiveCouponTemplate { | |
| 117 | - | |
| 118 | - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 119 | - private Long id; | |
| 120 | - | |
| 121 | - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") | |
| 122 | - private String name; | |
| 123 | - | |
| 124 | - } | |
| 125 | - | |
| 126 | 111 | } | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
| ... | ... | @@ -12,7 +12,6 @@ import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; |
| 12 | 12 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 13 | 13 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 14 | 14 | import cn.iocoder.yudao.module.product.enums.DictTypeConstants; |
| 15 | -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; | |
| 16 | 15 | import org.mapstruct.Mapper; |
| 17 | 16 | import org.mapstruct.Mapping; |
| 18 | 17 | import org.mapstruct.Named; |
| ... | ... | @@ -101,14 +100,8 @@ public interface ProductSpuConvert { |
| 101 | 100 | |
| 102 | 101 | List<AppProductSpuDetailRespVO.Sku> convertListForGetSpuDetail(List<ProductSkuDO> skus); |
| 103 | 102 | |
| 104 | - List<ProductSpuDetailRespVO.GiveCouponTemplate> convertList04(List<CouponTemplateRespDTO> couponTemplateList); | |
| 105 | - | |
| 106 | - default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus, | |
| 107 | - List<CouponTemplateRespDTO> couponTemplateList) { | |
| 108 | - ProductSpuDetailRespVO respVO = convert03(spu); | |
| 109 | - respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); | |
| 110 | - respVO.setGiveCouponTemplates(convertList04(couponTemplateList)); | |
| 111 | - return respVO; | |
| 103 | + default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List<ProductSkuDO> skus) { | |
| 104 | + return convert03(spu).setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); | |
| 112 | 105 | } |
| 113 | 106 | |
| 114 | 107 | default List<ProductSpuDetailRespVO> convertForSpuDetailRespListVO(List<ProductSpuDO> spus, List<ProductSkuDO> skus) { | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| ... | ... | @@ -17,9 +17,6 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| 17 | 17 | import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; |
| 18 | 18 | import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; |
| 19 | 19 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 20 | -import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi; | |
| 21 | -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; | |
| 22 | -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; | |
| 23 | 20 | import com.google.common.collect.Maps; |
| 24 | 21 | import org.springframework.context.annotation.Lazy; |
| 25 | 22 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -28,10 +25,10 @@ import org.springframework.validation.annotation.Validated; |
| 28 | 25 | |
| 29 | 26 | import javax.annotation.Resource; |
| 30 | 27 | import java.util.*; |
| 31 | -import java.util.stream.Collectors; | |
| 32 | 28 | |
| 33 | 29 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 34 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 30 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; | |
| 31 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; | |
| 35 | 32 | import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; |
| 36 | 33 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; |
| 37 | 34 | |
| ... | ... | @@ -55,19 +52,12 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 55 | 52 | @Resource |
| 56 | 53 | private ProductCategoryService categoryService; |
| 57 | 54 | |
| 58 | - @Resource | |
| 59 | - @Lazy | |
| 60 | - private CouponTemplateApi couponTemplateApi; | |
| 61 | - | |
| 62 | 55 | @Override |
| 63 | 56 | @Transactional(rollbackFor = Exception.class) |
| 64 | 57 | public Long createSpu(ProductSpuCreateReqVO createReqVO) { |
| 65 | 58 | // 校验分类、品牌 |
| 66 | 59 | validateCategory(createReqVO.getCategoryId()); |
| 67 | 60 | brandService.validateProductBrand(createReqVO.getBrandId()); |
| 68 | - // 校验优惠券 | |
| 69 | - Set<Long> giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplates(), ProductSpuCreateReqVO.GiveCouponTemplate::getId); | |
| 70 | - validateCouponTemplate(giveCouponTemplateIds); | |
| 71 | 61 | // 校验 SKU |
| 72 | 62 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); |
| 73 | 63 | productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); |
| ... | ... | @@ -75,8 +65,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 75 | 65 | ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); |
| 76 | 66 | // 初始化 SPU 中 SKU 相关属性 |
| 77 | 67 | initSpuFromSkus(spu, skuSaveReqList); |
| 78 | - // 设置优惠券 | |
| 79 | - spu.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); | |
| 80 | 68 | // 插入 SPU |
| 81 | 69 | productSpuMapper.insert(spu); |
| 82 | 70 | // 插入 SKU |
| ... | ... | @@ -93,9 +81,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 93 | 81 | // 校验分类、品牌 |
| 94 | 82 | validateCategory(updateReqVO.getCategoryId()); |
| 95 | 83 | brandService.validateProductBrand(updateReqVO.getBrandId()); |
| 96 | - // 校验优惠券 | |
| 97 | - Set<Long> giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplates(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId); | |
| 98 | - validateCouponTemplate(giveCouponTemplateIds); | |
| 99 | 84 | // 校验SKU |
| 100 | 85 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus(); |
| 101 | 86 | productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); |
| ... | ... | @@ -103,8 +88,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 103 | 88 | // 更新 SPU |
| 104 | 89 | ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); |
| 105 | 90 | initSpuFromSkus(updateObj, skuSaveReqList); |
| 106 | - // 设置优惠券 | |
| 107 | - updateObj.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); | |
| 108 | 91 | productSpuMapper.updateById(updateObj); |
| 109 | 92 | // 批量更新 SKU |
| 110 | 93 | productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); |
| ... | ... | @@ -138,10 +121,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 138 | 121 | // 默认商品浏览量 |
| 139 | 122 | spu.setBrowseCount(0); |
| 140 | 123 | } |
| 141 | - // 如果活动顺序为空则默认初始化 | |
| 142 | - if (CollUtil.isEmpty(spu.getActivityOrders())) { | |
| 143 | - spu.setActivityOrders(Arrays.stream(PromotionTypeEnum.ARRAYS).boxed().collect(Collectors.toList())); | |
| 144 | - } | |
| 145 | 124 | } |
| 146 | 125 | |
| 147 | 126 | /** |
| ... | ... | @@ -157,13 +136,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 157 | 136 | } |
| 158 | 137 | } |
| 159 | 138 | |
| 160 | - private void validateCouponTemplate(Collection<Long> ids) { | |
| 161 | - List<CouponTemplateRespDTO> couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(ids); | |
| 162 | - if (couponTemplateList.size() != ids.size()) { | |
| 163 | - throw exception(SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS); | |
| 164 | - } | |
| 165 | - } | |
| 166 | - | |
| 167 | 139 | @Override |
| 168 | 140 | public List<ProductSpuDO> validateSpuList(Collection<Long> ids) { |
| 169 | 141 | if (CollUtil.isEmpty(ids)) { | ... | ... |