Commit 283ca908b7ac87ecee9b0ac24bbcddbda35df167
1 parent
6e111540
SPU: 完善选择优惠卷
Showing
5 changed files
with
11 additions
and
5 deletions
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/admin/spu/vo/ProductSpuBaseVO.java
| ... | ... | @@ -97,7 +97,7 @@ public class ProductSpuBaseVO { |
| 97 | 97 | private Integer giveIntegral; |
| 98 | 98 | |
| 99 | 99 | @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称") |
| 100 | - private List<GiveCouponTemplate> giveCouponTemplate; | |
| 100 | + private List<GiveCouponTemplate> giveCouponTemplates; | |
| 101 | 101 | |
| 102 | 102 | @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") |
| 103 | 103 | @NotNull(message = "商品分销类型不能为空") | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/convert/spu/ProductSpuConvert.java
| ... | ... | @@ -107,7 +107,7 @@ public interface ProductSpuConvert { |
| 107 | 107 | List<CouponTemplateRespDTO> couponTemplateList) { |
| 108 | 108 | ProductSpuDetailRespVO respVO = convert03(spu); |
| 109 | 109 | respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); |
| 110 | - respVO.setGiveCouponTemplate(convertList04(couponTemplateList)); | |
| 110 | + respVO.setGiveCouponTemplates(convertList04(couponTemplateList)); | |
| 111 | 111 | return respVO; |
| 112 | 112 | } |
| 113 | 113 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/dal/dataobject/spu/ProductSpuDO.java
| ... | ... | @@ -194,7 +194,7 @@ public class ProductSpuDO extends BaseDO { |
| 194 | 194 | * 对应 PromotionTypeEnum 枚举 |
| 195 | 195 | */ |
| 196 | 196 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 197 | - private List<Integer> activityOrders; | |
| 197 | + private List<Integer> activityOrders; // TODO @芋艿: 活动顺序字段长度需要增加 | |
| 198 | 198 | |
| 199 | 199 | // ========== 统计相关字段 ========= |
| 200 | 200 | ... | ... |
yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/spu/ProductSpuServiceImpl.java
| ... | ... | @@ -56,6 +56,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 56 | 56 | private ProductCategoryService categoryService; |
| 57 | 57 | |
| 58 | 58 | @Resource |
| 59 | + @Lazy | |
| 59 | 60 | private CouponTemplateApi couponTemplateApi; |
| 60 | 61 | |
| 61 | 62 | @Override |
| ... | ... | @@ -65,7 +66,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 65 | 66 | validateCategory(createReqVO.getCategoryId()); |
| 66 | 67 | brandService.validateProductBrand(createReqVO.getBrandId()); |
| 67 | 68 | // 校验优惠券 |
| 68 | - Set<Long> giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplate(), ProductSpuCreateReqVO.GiveCouponTemplate::getId); | |
| 69 | + Set<Long> giveCouponTemplateIds = convertSet(createReqVO.getGiveCouponTemplates(), ProductSpuCreateReqVO.GiveCouponTemplate::getId); | |
| 69 | 70 | validateCouponTemplate(giveCouponTemplateIds); |
| 70 | 71 | // 校验 SKU |
| 71 | 72 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); |
| ... | ... | @@ -93,7 +94,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { |
| 93 | 94 | validateCategory(updateReqVO.getCategoryId()); |
| 94 | 95 | brandService.validateProductBrand(updateReqVO.getBrandId()); |
| 95 | 96 | // 校验优惠券 |
| 96 | - Set<Long> giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplate(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId); | |
| 97 | + Set<Long> giveCouponTemplateIds = convertSet(updateReqVO.getGiveCouponTemplates(), ProductSpuUpdateReqVO.GiveCouponTemplate::getId); | |
| 97 | 98 | validateCouponTemplate(giveCouponTemplateIds); |
| 98 | 99 | // 校验SKU |
| 99 | 100 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus(); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/CouponTemplateApiImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.promotion.api.coupon; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; |
| 4 | 5 | import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; |
| 5 | 6 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; |
| ... | ... | @@ -7,6 +8,7 @@ import org.springframework.stereotype.Service; |
| 7 | 8 | |
| 8 | 9 | import javax.annotation.Resource; |
| 9 | 10 | import java.util.Collection; |
| 11 | +import java.util.Collections; | |
| 10 | 12 | import java.util.List; |
| 11 | 13 | |
| 12 | 14 | /** |
| ... | ... | @@ -22,6 +24,9 @@ public class CouponTemplateApiImpl implements CouponTemplateApi { |
| 22 | 24 | |
| 23 | 25 | @Override |
| 24 | 26 | public List<CouponTemplateRespDTO> getCouponTemplateListByIds(Collection<Long> ids) { |
| 27 | + if (CollUtil.isEmpty(ids)) { // 防御一下 | |
| 28 | + return Collections.emptyList(); | |
| 29 | + } | |
| 25 | 30 | return CouponTemplateConvert.INSTANCE.convertList(couponTemplateService.getCouponTemplateListByIds(ids)); |
| 26 | 31 | } |
| 27 | 32 | ... | ... |