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,7 +97,7 @@ public class ProductSpuBaseVO { | ||
| 97 | private Integer giveIntegral; | 97 | private Integer giveIntegral; |
| 98 | 98 | ||
| 99 | @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称") | 99 | @Schema(description = "赠送的优惠劵数组包含优惠券编号和名称") |
| 100 | - private List<GiveCouponTemplate> giveCouponTemplate; | 100 | + private List<GiveCouponTemplate> giveCouponTemplates; |
| 101 | 101 | ||
| 102 | @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | 102 | @Schema(description = "分销类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") |
| 103 | @NotNull(message = "商品分销类型不能为空") | 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,7 +107,7 @@ public interface ProductSpuConvert { | ||
| 107 | List<CouponTemplateRespDTO> couponTemplateList) { | 107 | List<CouponTemplateRespDTO> couponTemplateList) { |
| 108 | ProductSpuDetailRespVO respVO = convert03(spu); | 108 | ProductSpuDetailRespVO respVO = convert03(spu); |
| 109 | respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); | 109 | respVO.setSkus(ProductSkuConvert.INSTANCE.convertList(skus)); |
| 110 | - respVO.setGiveCouponTemplate(convertList04(couponTemplateList)); | 110 | + respVO.setGiveCouponTemplates(convertList04(couponTemplateList)); |
| 111 | return respVO; | 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,7 +194,7 @@ public class ProductSpuDO extends BaseDO { | ||
| 194 | * 对应 PromotionTypeEnum 枚举 | 194 | * 对应 PromotionTypeEnum 枚举 |
| 195 | */ | 195 | */ |
| 196 | @TableField(typeHandler = JacksonTypeHandler.class) | 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,6 +56,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 56 | private ProductCategoryService categoryService; | 56 | private ProductCategoryService categoryService; |
| 57 | 57 | ||
| 58 | @Resource | 58 | @Resource |
| 59 | + @Lazy | ||
| 59 | private CouponTemplateApi couponTemplateApi; | 60 | private CouponTemplateApi couponTemplateApi; |
| 60 | 61 | ||
| 61 | @Override | 62 | @Override |
| @@ -65,7 +66,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -65,7 +66,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 65 | validateCategory(createReqVO.getCategoryId()); | 66 | validateCategory(createReqVO.getCategoryId()); |
| 66 | brandService.validateProductBrand(createReqVO.getBrandId()); | 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 | validateCouponTemplate(giveCouponTemplateIds); | 70 | validateCouponTemplate(giveCouponTemplateIds); |
| 70 | // 校验 SKU | 71 | // 校验 SKU |
| 71 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); | 72 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = createReqVO.getSkus(); |
| @@ -93,7 +94,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | @@ -93,7 +94,7 @@ public class ProductSpuServiceImpl implements ProductSpuService { | ||
| 93 | validateCategory(updateReqVO.getCategoryId()); | 94 | validateCategory(updateReqVO.getCategoryId()); |
| 94 | brandService.validateProductBrand(updateReqVO.getBrandId()); | 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 | validateCouponTemplate(giveCouponTemplateIds); | 98 | validateCouponTemplate(giveCouponTemplateIds); |
| 98 | // 校验SKU | 99 | // 校验SKU |
| 99 | List<ProductSkuCreateOrUpdateReqVO> skuSaveReqList = updateReqVO.getSkus(); | 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 | package cn.iocoder.yudao.module.promotion.api.coupon; | 1 | package cn.iocoder.yudao.module.promotion.api.coupon; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 3 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; | 4 | import cn.iocoder.yudao.module.promotion.api.coupon.dto.CouponTemplateRespDTO; |
| 4 | import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; | 5 | import cn.iocoder.yudao.module.promotion.convert.coupon.CouponTemplateConvert; |
| 5 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; | 6 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponTemplateService; |
| @@ -7,6 +8,7 @@ import org.springframework.stereotype.Service; | @@ -7,6 +8,7 @@ import org.springframework.stereotype.Service; | ||
| 7 | 8 | ||
| 8 | import javax.annotation.Resource; | 9 | import javax.annotation.Resource; |
| 9 | import java.util.Collection; | 10 | import java.util.Collection; |
| 11 | +import java.util.Collections; | ||
| 10 | import java.util.List; | 12 | import java.util.List; |
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| @@ -22,6 +24,9 @@ public class CouponTemplateApiImpl implements CouponTemplateApi { | @@ -22,6 +24,9 @@ public class CouponTemplateApiImpl implements CouponTemplateApi { | ||
| 22 | 24 | ||
| 23 | @Override | 25 | @Override |
| 24 | public List<CouponTemplateRespDTO> getCouponTemplateListByIds(Collection<Long> ids) { | 26 | public List<CouponTemplateRespDTO> getCouponTemplateListByIds(Collection<Long> ids) { |
| 27 | + if (CollUtil.isEmpty(ids)) { // 防御一下 | ||
| 28 | + return Collections.emptyList(); | ||
| 29 | + } | ||
| 25 | return CouponTemplateConvert.INSTANCE.convertList(couponTemplateService.getCouponTemplateListByIds(ids)); | 30 | return CouponTemplateConvert.INSTANCE.convertList(couponTemplateService.getCouponTemplateListByIds(ids)); |
| 26 | } | 31 | } |
| 27 | 32 |