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,11 +28,6 @@ | ||
| 28 | <artifactId>yudao-module-member-api</artifactId> | 28 | <artifactId>yudao-module-member-api</artifactId> |
| 29 | <version>${revision}</version> | 29 | <version>${revision}</version> |
| 30 | </dependency> | 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 | <dependency> | 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,8 +11,6 @@ import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | ||
| 11 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | 11 | import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; |
| 12 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | 12 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; |
| 13 | import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; | 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 | import io.swagger.v3.oas.annotations.Operation; | 14 | import io.swagger.v3.oas.annotations.Operation; |
| 17 | import io.swagger.v3.oas.annotations.Parameter; | 15 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | import io.swagger.v3.oas.annotations.tags.Tag; | 16 | import io.swagger.v3.oas.annotations.tags.Tag; |
| @@ -45,9 +43,6 @@ public class ProductSpuController { | @@ -45,9 +43,6 @@ public class ProductSpuController { | ||
| 45 | @Resource | 43 | @Resource |
| 46 | private ProductSkuService productSkuService; | 44 | private ProductSkuService productSkuService; |
| 47 | 45 | ||
| 48 | - @Resource | ||
| 49 | - private CouponTemplateApi couponTemplateApi; | ||
| 50 | - | ||
| 51 | @PostMapping("/create") | 46 | @PostMapping("/create") |
| 52 | @Operation(summary = "创建商品 SPU") | 47 | @Operation(summary = "创建商品 SPU") |
| 53 | @PreAuthorize("@ss.hasPermission('product:spu:create')") | 48 | @PreAuthorize("@ss.hasPermission('product:spu:create')") |
| @@ -92,11 +87,7 @@ public class ProductSpuController { | @@ -92,11 +87,7 @@ public class ProductSpuController { | ||
| 92 | } | 87 | } |
| 93 | // 查询商品 SKU | 88 | // 查询商品 SKU |
| 94 | List<ProductSkuDO> skus = productSkuService.getSkuListBySpuId(spu.getId()); | 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 | @GetMapping("/list-all-simple") | 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,9 +96,6 @@ public class ProductSpuBaseVO { | ||
| 96 | @NotNull(message = "商品赠送积分不能为空") | 96 | @NotNull(message = "商品赠送积分不能为空") |
| 97 | private Integer giveIntegral; | 97 | private Integer giveIntegral; |
| 98 | 98 | ||
| 99 | - @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称") | ||
| 100 | - private List<GiveCouponTemplate> giveCouponTemplates; | ||
| 101 | - | ||
| 102 | @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | 99 | @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") |
| 103 | @NotNull(message = "商品分销类型不能为空") | 100 | @NotNull(message = "商品分销类型不能为空") |
| 104 | private Boolean subCommissionType; | 101 | private Boolean subCommissionType; |
| @@ -111,16 +108,4 @@ public class ProductSpuBaseVO { | @@ -111,16 +108,4 @@ public class ProductSpuBaseVO { | ||
| 111 | @Schema(description = "虚拟销量", example = "66") | 108 | @Schema(description = "虚拟销量", example = "66") |
| 112 | private Integer virtualSalesCount; | 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,7 +12,6 @@ import cn.iocoder.yudao.module.product.convert.sku.ProductSkuConvert; | ||
| 12 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; | 12 | import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO; |
| 13 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; | 13 | import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO; |
| 14 | import cn.iocoder.yudao.module.product.enums.DictTypeConstants; | 14 | import cn.iocoder.yudao.module.product.enums.DictTypeConstants; |
| 15 | -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; | ||
| 16 | import org.mapstruct.Mapper; | 15 | import org.mapstruct.Mapper; |
| 17 | import org.mapstruct.Mapping; | 16 | import org.mapstruct.Mapping; |
| 18 | import org.mapstruct.Named; | 17 | import org.mapstruct.Named; |
| @@ -101,14 +100,8 @@ public interface ProductSpuConvert { | @@ -101,14 +100,8 @@ public interface ProductSpuConvert { | ||
| 101 | 100 | ||
| 102 | List<AppProductSpuDetailRespVO.Sku> convertListForGetSpuDetail(List<ProductSkuDO> skus); | 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 | default List<ProductSpuDetailRespVO> convertForSpuDetailRespListVO(List<ProductSpuDO> spus, List<ProductSkuDO> skus) { | 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,9 +17,6 @@ import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; | ||
| 17 | import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; | 17 | import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; |
| 18 | import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; | 18 | import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; |
| 19 | import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; | 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 | import com.google.common.collect.Maps; | 20 | import com.google.common.collect.Maps; |
| 24 | import org.springframework.context.annotation.Lazy; | 21 | import org.springframework.context.annotation.Lazy; |
| 25 | import org.springframework.stereotype.Service; | 22 | import org.springframework.stereotype.Service; |
| @@ -28,10 +25,10 @@ import org.springframework.validation.annotation.Validated; | @@ -28,10 +25,10 @@ import org.springframework.validation.annotation.Validated; | ||
| 28 | 25 | ||
| 29 | import javax.annotation.Resource; | 26 | import javax.annotation.Resource; |
| 30 | import java.util.*; | 27 | import java.util.*; |
| 31 | -import java.util.stream.Collectors; | ||
| 32 | 28 | ||
| 33 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 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 | import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; | 32 | import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; |
| 36 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; | 33 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; |
| 37 | 34 | ||
| @@ -55,19 +52,12 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -55,19 +52,12 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 55 | @Resource | 52 | @Resource |
| 56 | private ProductCategoryService categoryService; | 53 | private ProductCategoryService categoryService; |
| 57 | 54 | ||
| 58 | - @Resource | ||
| 59 | - @Lazy | ||
| 60 | - private CouponTemplateApi couponTemplateApi; | ||
| 61 | - | ||
| 62 | @Override | 55 | @Override |
| 63 | @Transactional(rollbackFor = Exception.class) | 56 | @Transactional(rollbackFor = Exception.class) |
| 64 | public Long createSpu(ProductSpuCreateReqVO createReqVO) { | 57 | public Long createSpu(ProductSpuCreateReqVO createReqVO) { |
| 65 | // 校验分类、品牌 | 58 | // 校验分类、品牌 |
| 66 | validateCategory(createReqVO.getCategoryId()); | 59 | validateCategory(createReqVO.getCategoryId()); |
| 67 | brandService.validateProductBrand(createReqVO.getBrandId()); | 60 | brandService.validateProductBrand(createReqVO.getBrandId()); |
| 68 | - // 校验优惠券 | ||
| 69 | - Set<Long> giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplates(), ProductSpuCreateReqVO.GiveCouponTemplate::getId); | ||
| 70 | - validateCouponTemplate(giveCouponTemplateIds); | ||
| 71 | // 校验 SKU | 61 | // 校验 SKU |
| 72 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); | 62 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); |
| 73 | productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); | 63 | productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); |
| @@ -75,8 +65,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -75,8 +65,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 75 | ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); | 65 | ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); |
| 76 | // 初始化 SPU 中 SKU 相关属性 | 66 | // 初始化 SPU 中 SKU 相关属性 |
| 77 | initSpuFromSkus(spu, skuSaveReqList); | 67 | initSpuFromSkus(spu, skuSaveReqList); |
| 78 | - // 设置优惠券 | ||
| 79 | - spu.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); | ||
| 80 | // 插入 SPU | 68 | // 插入 SPU |
| 81 | productSpuMapper.insert(spu); | 69 | productSpuMapper.insert(spu); |
| 82 | // 插入 SKU | 70 | // 插入 SKU |
| @@ -93,9 +81,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -93,9 +81,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 93 | // 校验分类、品牌 | 81 | // 校验分类、品牌 |
| 94 | validateCategory(updateReqVO.getCategoryId()); | 82 | validateCategory(updateReqVO.getCategoryId()); |
| 95 | brandService.validateProductBrand(updateReqVO.getBrandId()); | 83 | brandService.validateProductBrand(updateReqVO.getBrandId()); |
| 96 | - // 校验优惠券 | ||
| 97 | - Set<Long> giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplates(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId); | ||
| 98 | - validateCouponTemplate(giveCouponTemplateIds); | ||
| 99 | // 校验SKU | 84 | // 校验SKU |
| 100 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus(); | 85 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus(); |
| 101 | productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); | 86 | productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); |
| @@ -103,8 +88,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -103,8 +88,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 103 | // 更新 SPU | 88 | // 更新 SPU |
| 104 | ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); | 89 | ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); |
| 105 | initSpuFromSkus(updateObj, skuSaveReqList); | 90 | initSpuFromSkus(updateObj, skuSaveReqList); |
| 106 | - // 设置优惠券 | ||
| 107 | - updateObj.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); | ||
| 108 | productSpuMapper.updateById(updateObj); | 91 | productSpuMapper.updateById(updateObj); |
| 109 | // 批量更新 SKU | 92 | // 批量更新 SKU |
| 110 | productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); | 93 | productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); |
| @@ -138,10 +121,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -138,10 +121,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 138 | // 默认商品浏览量 | 121 | // 默认商品浏览量 |
| 139 | spu.setBrowseCount(0); | 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,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 | @Override | 139 | @Override |
| 168 | public List<ProductSpuDO> validateSpuList(Collection<Long> ids) { | 140 | public List<ProductSpuDO> validateSpuList(Collection<Long> ids) { |
| 169 | if (CollUtil.isEmpty(ids)) { | 141 | if (CollUtil.isEmpty(ids)) { |