From 3672d0f245a29cb64724752a53478ab828878266 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Mon, 23 Oct 2023 17:29:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E6=A8=A1=E5=9D=97=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=AF=B9=E8=90=A5=E9=94=80=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yudao-module-product-biz/pom.xml | 5 --- .../admin/spu/ProductSpuController.java | 11 +------ .../admin/spu/vo/ProductSpuBaseVO.java | 15 --------- .../convert/spu/ProductSpuConvert.java | 11 ++----- .../service/spu/ProductSpuServiceImpl.java | 32 ++----------------- 5 files changed, 5 insertions(+), 69 deletions(-) diff --git a/yudao-module-mall/yudao-module-product-biz/pom.xml b/yudao-module-mall/yudao-module-product-biz/pom.xml index 385b6690e..f6190ceda 100644 --- a/yudao-module-mall/yudao-module-product-biz/pom.xml +++ b/yudao-module-mall/yudao-module-product-biz/pom.xml @@ -28,11 +28,6 @@ yudao-module-member-api ${revision} - - cn.iocoder.boot - yudao-module-promotion-api - ${revision} - diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java index f9c60a62b..7f88dd8c6 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/ProductSpuController.java +++ b/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; import cn.iocoder.yudao.module.product.enums.spu.ProductSpuStatusEnum; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; import cn.iocoder.yudao.module.product.service.spu.ProductSpuService; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -45,9 +43,6 @@ public class ProductSpuController { @Resource private ProductSkuService productSkuService; - @Resource - private CouponTemplateApi couponTemplateApi; - @PostMapping("/create") @Operation(summary = "创建商品 SPU") @PreAuthorize("@ss.hasPermission('product:spu:create')") @@ -92,11 +87,7 @@ public class ProductSpuController { } // 查询商品 SKU List skus = productSkuService.getSkuListBySpuId(spu.getId()); - // 查询优惠卷 - // TODO @puhui999:优惠劵的信息,要不交给前端读取?主要是为了避免商品依赖 promotion 模块哈; - List couponTemplateList = couponTemplateApi.getCouponTemplateListByIds( - spu.getGiveCouponTemplateIds()); - return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus, couponTemplateList)); + return success(ProductSpuConvert.INSTANCE.convertForSpuDetailRespVO(spu, skus)); } @GetMapping("/list-all-simple") diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java index 7f2c22c95..ff6253839 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java +++ b/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 { @NotNull(message = "商品赠送积分不能为空") private Integer giveIntegral; - @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称") - private List giveCouponTemplates; - @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") @NotNull(message = "商品分销类型不能为空") private Boolean subCommissionType; @@ -111,16 +108,4 @@ public class ProductSpuBaseVO { @Schema(description = "虚拟销量", example = "66") private Integer virtualSalesCount; - @Schema(description = "管理后台 - 商品 SPU 赠送的优惠卷") - @Data - public static class GiveCouponTemplate { - - @Schema(description = "模板编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "优惠劵名", requiredMode = Schema.RequiredMode.REQUIRED, example = "春节送送送") - private String name; - - } - } diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java index 0b83abe42..30dd2d8b9 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java +++ b/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; 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.enums.DictTypeConstants; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Named; @@ -101,14 +100,8 @@ public interface ProductSpuConvert { List convertListForGetSpuDetail(List skus); - List convertList04(List couponTemplateList); - - default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List skus, - List couponTemplateList) { - ProductSpuDetailRespVO respVO = convert03(spu); - respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); - respVO.setGiveCouponTemplates(convertList04(couponTemplateList)); - return respVO; + default ProductSpuDetailRespVO convertForSpuDetailRespVO(ProductSpuDO spu, List skus) { + return convert03(spu).setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); } default List convertForSpuDetailRespListVO(List spus, List skus) { diff --git a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java b/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java index 5f2fcbb04..72182d23c 100755 --- a/yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java +++ b/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; import cn.iocoder.yudao.module.product.service.brand.ProductBrandService; import cn.iocoder.yudao.module.product.service.category.ProductCategoryService; import cn.iocoder.yudao.module.product.service.sku.ProductSkuService; -import cn.iocoder.yudao.module.promotion.api.coupon.CouponTemplateApi; -import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; -import cn.iocoder.yudao.module.promotion.enums.common.PromotionTypeEnum; import com.google.common.collect.Maps; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -28,10 +25,10 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.util.*; -import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL; import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*; @@ -55,19 +52,12 @@ public class ProductSpuServiceImpl implements ProductSpuService { @Resource private ProductCategoryService categoryService; - @Resource - @Lazy - private CouponTemplateApi couponTemplateApi; - @Override @Transactional(rollbackFor = Exception.class) public Long createSpu(ProductSpuCreateReqVO createReqVO) { // 校验分类、品牌 validateCategory(createReqVO.getCategoryId()); brandService.validateProductBrand(createReqVO.getBrandId()); - // 校验优惠券 - Set giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplates(), ProductSpuCreateReqVO.GiveCouponTemplate::getId); - validateCouponTemplate(giveCouponTemplateIds); // 校验 SKU List skuSaveReqList = createReqVO.getSkus(); productSkuService.validateSkuList(skuSaveReqList, createReqVO.getSpecType()); @@ -75,8 +65,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { ProductSpuDO spu = ProductSpuConvert.INSTANCE.convert(createReqVO); // 初始化 SPU 中 SKU 相关属性 initSpuFromSkus(spu, skuSaveReqList); - // 设置优惠券 - spu.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); // 插入 SPU productSpuMapper.insert(spu); // 插入 SKU @@ -93,9 +81,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 校验分类、品牌 validateCategory(updateReqVO.getCategoryId()); brandService.validateProductBrand(updateReqVO.getBrandId()); - // 校验优惠券 - Set giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplates(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId); - validateCouponTemplate(giveCouponTemplateIds); // 校验SKU List skuSaveReqList = updateReqVO.getSkus(); productSkuService.validateSkuList(skuSaveReqList, updateReqVO.getSpecType()); @@ -103,8 +88,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 更新 SPU ProductSpuDO updateObj = ProductSpuConvert.INSTANCE.convert(updateReqVO); initSpuFromSkus(updateObj, skuSaveReqList); - // 设置优惠券 - updateObj.setGiveCouponTemplateIds(CollUtil.newArrayList(giveCouponTemplateIds)); productSpuMapper.updateById(updateObj); // 批量更新 SKU productSkuService.updateSkuList(updateObj.getId(), updateReqVO.getSkus()); @@ -138,10 +121,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { // 默认商品浏览量 spu.setBrowseCount(0); } - // 如果活动顺序为空则默认初始化 - if (CollUtil.isEmpty(spu.getActivityOrders())) { - spu.setActivityOrders(Arrays.stream(PromotionTypeEnum.ARRAYS).boxed().collect(Collectors.toList())); - } } /** @@ -157,13 +136,6 @@ public class ProductSpuServiceImpl implements ProductSpuService { } } - private void validateCouponTemplate(Collection ids) { - List couponTemplateList = couponTemplateApi.getCouponTemplateListByIds(ids); - if (couponTemplateList.size() != ids.size()) { - throw exception(SPU_SAVE_FAIL_COUPON_TEMPLATE_NOT_EXISTS); - } - } - @Override public List validateSpuList(Collection ids) { if (CollUtil.isEmpty(ids)) {