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