mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
promotion: 优惠券模板 productSpuIds 改成 productScopeValues
This commit is contained in:
parent
6a7be19d3a
commit
8bbaaf1ce9
@ -71,9 +71,9 @@ public class CouponRespDTO {
|
|||||||
*/
|
*/
|
||||||
private Integer productScope;
|
private Integer productScope;
|
||||||
/**
|
/**
|
||||||
* 商品 SPU 编号的数组
|
* 商品范围编号的数组
|
||||||
*/
|
*/
|
||||||
private List<Long> productSpuIds;
|
private List<Long> productScopeValues;
|
||||||
// ========== 使用规则 END ==========
|
// ========== 使用规则 END ==========
|
||||||
|
|
||||||
// ========== 使用效果 BEGIN ==========
|
// ========== 使用效果 BEGIN ==========
|
||||||
|
@ -67,8 +67,8 @@ public class CouponBaseVO {
|
|||||||
@InEnum(PromotionProductScopeEnum.class)
|
@InEnum(PromotionProductScopeEnum.class)
|
||||||
private Integer productScope;
|
private Integer productScope;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号的数组", example = "1,3")
|
@Schema(description = "商品范围编号的数组", example = "1,3")
|
||||||
private List<Long> productSpuIds;
|
private List<Long> productScopeValues;
|
||||||
// ========== 使用规则 END ==========
|
// ========== 使用规则 END ==========
|
||||||
|
|
||||||
// ========== 使用效果 BEGIN ==========
|
// ========== 使用效果 BEGIN ==========
|
||||||
|
@ -54,8 +54,8 @@ public class CouponTemplateBaseVO {
|
|||||||
@InEnum(PromotionProductScopeEnum.class)
|
@InEnum(PromotionProductScopeEnum.class)
|
||||||
private Integer productScope;
|
private Integer productScope;
|
||||||
|
|
||||||
@Schema(description = "商品 SPU 编号的数组", example = "1,3")
|
@Schema(description = "商品范围编号的数组", example = "1,3")
|
||||||
private List<Long> productSpuIds;
|
private List<Long> productScopeValues;
|
||||||
|
|
||||||
@Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "生效日期类型不能为空")
|
@NotNull(message = "生效日期类型不能为空")
|
||||||
@ -95,11 +95,11 @@ public class CouponTemplateBaseVO {
|
|||||||
@Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
|
@Schema(description = "折扣上限", example = "100") // 单位:分,仅在 discountType 为 PERCENT 使用
|
||||||
private Integer discountLimitPrice;
|
private Integer discountLimitPrice;
|
||||||
|
|
||||||
@AssertTrue(message = "商品 SPU 编号的数组不能为空")
|
@AssertTrue(message = "商品范围编号的数组不能为空")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean isProductSpuIdsValid() {
|
public boolean isProductScopeValuesValid() {
|
||||||
return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
|
return Objects.equals(productScope, PromotionProductScopeEnum.ALL.getScope()) // 全部范围时,可以为空
|
||||||
|| CollUtil.isNotEmpty(productSpuIds);
|
|| CollUtil.isNotEmpty(productScopeValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AssertTrue(message = "生效开始时间不能为空")
|
@AssertTrue(message = "生效开始时间不能为空")
|
||||||
|
@ -28,8 +28,8 @@ public class AppCouponTemplateRespVO {
|
|||||||
// @InEnum(PromotionProductScopeEnum.class)
|
// @InEnum(PromotionProductScopeEnum.class)
|
||||||
// private Integer productScope;
|
// private Integer productScope;
|
||||||
//
|
//
|
||||||
// @Schema(description = "商品 SPU 编号的数组", example = "1,3")
|
// @Schema(description = "商品范围编号的数组", example = "1,3")
|
||||||
// private List<Long> productSpuIds;
|
// private List<Long> productScopeValues;
|
||||||
|
|
||||||
@Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "生效日期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Integer validityType;
|
private Integer validityType;
|
||||||
|
@ -33,7 +33,7 @@ public interface CouponConvert {
|
|||||||
.setTakeType(template.getTakeType())
|
.setTakeType(template.getTakeType())
|
||||||
.setUsePrice(template.getUsePrice())
|
.setUsePrice(template.getUsePrice())
|
||||||
.setProductScope(template.getProductScope())
|
.setProductScope(template.getProductScope())
|
||||||
.setProductSpuIds(template.getProductSpuIds())
|
.setProductScopeValues(template.getProductScopeValues())
|
||||||
.setDiscountType(template.getDiscountType())
|
.setDiscountType(template.getDiscountType())
|
||||||
.setDiscountPercent(template.getDiscountPercent())
|
.setDiscountPercent(template.getDiscountPercent())
|
||||||
.setDiscountPrice(template.getDiscountPrice())
|
.setDiscountPrice(template.getDiscountPrice())
|
||||||
|
@ -89,12 +89,12 @@ public class CouponDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer productScope;
|
private Integer productScope;
|
||||||
/**
|
/**
|
||||||
* 商品 SPU 编号的数组
|
* 商品范围编号的数组
|
||||||
*
|
*
|
||||||
* 冗余 {@link CouponTemplateDO#getProductSpuIds()}
|
* 冗余 {@link CouponTemplateDO#getProductScopeValues()}
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = LongListTypeHandler.class)
|
@TableField(typeHandler = LongListTypeHandler.class)
|
||||||
private List<Long> productSpuIds;
|
private List<Long> productScopeValues;
|
||||||
// ========== 使用规则 END ==========
|
// ========== 使用规则 END ==========
|
||||||
|
|
||||||
// ========== 使用效果 BEGIN ==========
|
// ========== 使用效果 BEGIN ==========
|
||||||
|
@ -85,10 +85,10 @@ public class CouponTemplateDO extends BaseDO {
|
|||||||
*/
|
*/
|
||||||
private Integer productScope;
|
private Integer productScope;
|
||||||
/**
|
/**
|
||||||
* 商品 SPU 编号的数组
|
* 商品范围编号的数组
|
||||||
*/
|
*/
|
||||||
@TableField(typeHandler = LongListTypeHandler.class)
|
@TableField(typeHandler = LongListTypeHandler.class)
|
||||||
private List<Long> productSpuIds;
|
private List<Long> productScopeValues;
|
||||||
/**
|
/**
|
||||||
* 生效日期类型
|
* 生效日期类型
|
||||||
*
|
*
|
||||||
|
@ -102,7 +102,7 @@ public class TradeCouponPriceCalculator implements TradePriceCalculator {
|
|||||||
Predicate<TradePriceCalculateRespBO.OrderItem> matchPredicate = TradePriceCalculateRespBO.OrderItem::getSelected;
|
Predicate<TradePriceCalculateRespBO.OrderItem> matchPredicate = TradePriceCalculateRespBO.OrderItem::getSelected;
|
||||||
if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) {
|
if (PromotionProductScopeEnum.SPU.getScope().equals(coupon.getProductScope())) {
|
||||||
matchPredicate = matchPredicate // 额外加如下条件
|
matchPredicate = matchPredicate // 额外加如下条件
|
||||||
.and(orderItem -> coupon.getProductSpuIds().contains(orderItem.getSpuId()));
|
.and(orderItem -> coupon.getProductScopeValues().contains(orderItem.getSpuId()));
|
||||||
}
|
}
|
||||||
return filterList(result.getItems(), matchPredicate);
|
return filterList(result.getItems(), matchPredicate);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class TradeCouponPriceCalculatorTest extends BaseMockitoUnitTest {
|
|||||||
|
|
||||||
// mock 方法(优惠劵 Coupon 信息)
|
// mock 方法(优惠劵 Coupon 信息)
|
||||||
CouponRespDTO coupon = randomPojo(CouponRespDTO.class, o -> o.setId(1024L).setName("程序员节")
|
CouponRespDTO coupon = randomPojo(CouponRespDTO.class, o -> o.setId(1024L).setName("程序员节")
|
||||||
.setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductSpuIds(asList(1L, 2L))
|
.setProductScope(PromotionProductScopeEnum.SPU.getScope()).setProductScopeValues(asList(1L, 2L))
|
||||||
.setUsePrice(350).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType())
|
.setUsePrice(350).setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType())
|
||||||
.setDiscountPercent(50).setDiscountLimitPrice(70));
|
.setDiscountPercent(50).setDiscountLimitPrice(70));
|
||||||
when(couponApi.validateCoupon(eq(new CouponValidReqDTO().setId(1024L).setUserId(233L)))).thenReturn(coupon);
|
when(couponApi.validateCoupon(eq(new CouponValidReqDTO().setId(1024L).setUserId(233L)))).thenReturn(coupon);
|
||||||
|
Loading…
Reference in New Issue
Block a user