Commit 8bbaaf1ce9e3a2bf360cd7577e61c5ccb89a377f

Authored by owen
1 parent 6a7be19d

promotion: 优惠券模板 productSpuIds 改成 productScopeValues

yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/coupon/dto/CouponRespDTO.java
... ... @@ -71,9 +71,9 @@ public class CouponRespDTO {
71 71 */
72 72 private Integer productScope;
73 73 /**
74   - * 商品 SPU 编号的数组
  74 + * 商品范围编号的数组
75 75 */
76   - private List<Long> productSpuIds;
  76 + private List<Long> productScopeValues;
77 77 // ========== 使用规则 END ==========
78 78  
79 79 // ========== 使用效果 BEGIN ==========
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/coupon/CouponBaseVO.java
... ... @@ -67,8 +67,8 @@ public class CouponBaseVO {
67 67 @InEnum(PromotionProductScopeEnum.class)
68 68 private Integer productScope;
69 69  
70   - @Schema(description = "商品 SPU 编号的数组", example = "1,3")
71   - private List<Long> productSpuIds;
  70 + @Schema(description = "商品范围编号的数组", example = "1,3")
  71 + private List<Long> productScopeValues;
72 72 // ========== 使用规则 END ==========
73 73  
74 74 // ========== 使用效果 BEGIN ==========
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/coupon/vo/template/CouponTemplateBaseVO.java
... ... @@ -54,8 +54,8 @@ public class CouponTemplateBaseVO {
54 54 @InEnum(PromotionProductScopeEnum.class)
55 55 private Integer productScope;
56 56  
57   - @Schema(description = "商品 SPU 编号的数组", example = "1,3")
58   - private List<Long> productSpuIds;
  57 + @Schema(description = "商品范围编号的数组", example = "1,3")
  58 + private List<Long> productScopeValues;
59 59  
60 60 @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
61 61 @NotNull(message = "生效日期类型不能为空")
... ... @@ -95,11 +95,11 @@ public class CouponTemplateBaseVO {
95 95 @Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
96 96 private Integer discountLimitPrice;
97 97  
98   - @AssertTrue(message = "商品 SPU 编号的数组不能为空")
  98 + @AssertTrue(message = "商品范围编号的数组不能为空")
99 99 @JsonIgnore
100   - public boolean isProductSpuIdsValid() {
  100 + public boolean isProductScopeValuesValid() {
101 101 return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
102   - || CollUtil.isNotEmpty(productSpuIds);
  102 + || CollUtil.isNotEmpty(productScopeValues);
103 103 }
104 104  
105 105 @AssertTrue(message = "生效开始时间不能为空")
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/coupon/vo/template/AppCouponTemplateRespVO.java
... ... @@ -28,8 +28,8 @@ public class AppCouponTemplateRespVO {
28 28 // @InEnum(PromotionProductScopeEnum.class)
29 29 // private Integer productScope;
30 30 //
31   -// @Schema(description = "商品 SPU 编号的数组", example = "1,3")
32   -// private List<Long> productSpuIds;
  31 +// @Schema(description = "商品范围编号的数组", example = "1,3")
  32 +// private List<Long> productScopeValues;
33 33  
34 34 @Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
35 35 private Integer validityType;
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/coupon/CouponConvert.java
... ... @@ -33,7 +33,7 @@ public interface CouponConvert {
33 33 .setTakeType(template.getTakeType())
34 34 .setUsePrice(template.getUsePrice())
35 35 .setProductScope(template.getProductScope())
36   - .setProductSpuIds(template.getProductSpuIds())
  36 + .setProductScopeValues(template.getProductScopeValues())
37 37 .setDiscountType(template.getDiscountType())
38 38 .setDiscountPercent(template.getDiscountPercent())
39 39 .setDiscountPrice(template.getDiscountPrice())
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponDO.java
... ... @@ -89,12 +89,12 @@ public class CouponDO extends BaseDO {
89 89 */
90 90 private Integer productScope;
91 91 /**
92   - * 商品 SPU 编号的数组
  92 + * 商品范围编号的数组
93 93 *
94   - * 冗余 {@link CouponTemplateDO#getProductSpuIds()}
  94 + * 冗余 {@link CouponTemplateDO#getProductScopeValues()}
95 95 */
96 96 @TableField(typeHandler = LongListTypeHandler.class)
97   - private List<Long> productSpuIds;
  97 + private List<Long> productScopeValues;
98 98 // ========== 使用规则 END ==========
99 99  
100 100 // ========== 使用效果 BEGIN ==========
... ...
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/dataobject/coupon/CouponTemplateDO.java
... ... @@ -85,10 +85,10 @@ public class CouponTemplateDO extends BaseDO {
85 85 */
86 86 private Integer productScope;
87 87 /**
88   - * 商品 SPU 编号的数组
  88 + * 商品范围编号的数组
89 89 */
90 90 @TableField(typeHandler = LongListTypeHandler.class)
91   - private List<Long> productSpuIds;
  91 + private List<Long> productScopeValues;
92 92 /**
93 93 * 生效日期类型
94 94 *
... ...
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java
... ... @@ -102,7 +102,7 @@ public class TradeCouponPriceCalculator implements TradePriceCalculator {
102 102 Predicate<TradePriceCalculateRespBO.OrderItem> matchPredicate = TradePriceCalculateRespBO.OrderItem::getSelected;
103 103 if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) {
104 104 matchPredicate = matchPredicate // 额外加如下条件
105   - .and(orderItem -> coupon.getProductSpuIds().contains(orderItem.getSpuId()));
  105 + .and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getSpuId()));
106 106 }
107 107 return filterList(result.getItems(), matchPredicate);
108 108 }
... ...
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculatorTest.java
... ... @@ -65,7 +65,7 @@ public class TradeCouponPriceCalculatorTest extends BaseMockitoUnitTest {
65 65  
66 66 // mock 方法(优惠劵 Coupon 信息)
67 67 CouponRespDTO coupon = randomPojo(CouponRespDTO.class, o -> o.setId(1024L).setName("程序员节")
68   - .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))
  68 + .setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductScopeValues(asList(1L, 2L))
69 69 .setUsePrice(350).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType())
70 70 .setDiscountPercent(50).setDiscountLimitPrice(70));
71 71 when(couponApi.validateCoupon(eq(new CouponValidReqDTO().setId(1024L).setUserId(233L)))).thenReturn(coupon);
... ...