From 974b9650de3280af325cabb4bf09ac5bdde29391 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Mon, 15 Apr 2019 23:33:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E7=AB=AF=EF=BC=9A=E4=BF=83=E9=94=80?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E5=A2=9E=E5=8A=A0=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile-web/src/page/product/detail.vue | 16 +- order/order-application/pom.xml | 2 +- order/order-service-api/pom.xml | 5 + .../iocoder/mall/order/api/CartService.java | 7 +- .../mall/order/api/bo/CalcOrderPriceBO.java | 18 +- .../mall/order/api/bo/CalcSkuPriceBO.java | 31 ++++ .../order/biz/service/CartServiceImpl.java | 10 +- .../api/PromotionActivityService.java | 17 ++ .../promotion/api/bo/PromotionActivityBO.java | 134 +++++++++++++++ ...ypeEnum.java => PreferentialTypeEnum.java} | 9 +- .../constant/PromotionActivityStatusEnum.java | 41 +++++ .../constant/PromotionActivityTypeEnum.java | 4 +- ...eRangeTypeEnum.java => RangeTypeEnum.java} | 6 +- .../api/dto/CouponCardTemplateAddDTO.java | 8 +- .../api/dto/CouponCardTemplateUpdateDTO.java | 4 +- .../biz/dataobject/PromotionActivityDO.java | 158 +++++++++++++++++- .../biz/service/CouponServiceImpl.java | 4 +- 17 files changed, 445 insertions(+), 29 deletions(-) create mode 100644 order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcSkuPriceBO.java create mode 100644 promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/PromotionActivityService.java create mode 100644 promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/PromotionActivityBO.java rename promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/{CouponTemplatePreferentialTypeEnum.java => PreferentialTypeEnum.java} (75%) create mode 100644 promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityStatusEnum.java rename promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/{CouponTemplateRangeTypeEnum.java => RangeTypeEnum.java} (82%) diff --git a/mobile-web/src/page/product/detail.vue b/mobile-web/src/page/product/detail.vue index 9f439ec5b..a69c48a60 100644 --- a/mobile-web/src/page/product/detail.vue +++ b/mobile-web/src/page/product/detail.vue @@ -6,8 +6,22 @@ + +
+
+ ¥2.8 +
+
¥14
+
限时抢购
+
+
+
+

距离结束仅剩

+
714202
+
+
- + {{ formatPrice(initialSku.price) }} diff --git a/order/order-application/pom.xml b/order/order-application/pom.xml index 2f5f25b5c..d6421ee3e 100644 --- a/order/order-application/pom.xml +++ b/order/order-application/pom.xml @@ -124,4 +124,4 @@ - \ No newline at end of file + diff --git a/order/order-service-api/pom.xml b/order/order-service-api/pom.xml index 3fad5fa39..c43078998 100644 --- a/order/order-service-api/pom.xml +++ b/order/order-service-api/pom.xml @@ -22,6 +22,11 @@ product-service-api 1.0-SNAPSHOT + + cn.iocoder.mall + promotion-service-api + 1.0-SNAPSHOT + javax.validation diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/CartService.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/CartService.java index 6b5fa741e..84a0649be 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/CartService.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/CartService.java @@ -1,10 +1,7 @@ package cn.iocoder.mall.order.api; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO; -import cn.iocoder.mall.order.api.bo.CartBO; -import cn.iocoder.mall.order.api.bo.CartItemBO; -import cn.iocoder.mall.order.api.bo.OrderCreateBO; +import cn.iocoder.mall.order.api.bo.*; import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO; import org.springframework.lang.Nullable; @@ -90,6 +87,8 @@ public interface CartService { */ CommonResult calcOrderPrice(CalcOrderPriceDTO calcOrderPriceDTO); + CommonResult calcSkuPrice(Integer skuId); + /** * 获得购物车明细 * diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcOrderPriceBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcOrderPriceBO.java index c73760189..1c80edd88 100644 --- a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcOrderPriceBO.java +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcOrderPriceBO.java @@ -1,6 +1,7 @@ package cn.iocoder.mall.order.api.bo; import cn.iocoder.mall.product.api.bo.ProductSkuDetailBO; +import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO; import lombok.Data; import lombok.experimental.Accessors; @@ -35,8 +36,11 @@ public class CalcOrderPriceBO { @Accessors(chain = true) public static class ItemGroup { - // TODO 优惠活动 - private Object activity; + /** + * 优惠活动 + */ + // TODO 芋艿,目前只会有【满减送】的情况,未来有新的促销方式,可能需要改成数组 + private PromotionActivityBO activity; /** * 商品数组 */ @@ -56,6 +60,16 @@ public class CalcOrderPriceBO { * 购买数量 */ private Integer buyQuantity; + /** + * 优惠活动 + */ + private PromotionActivityBO activity; + /** + * 费用 + * + * TODO 芋艿,这里先偷懒,postageTotal 字段用不到。 + */ + private Fee fee; } diff --git a/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcSkuPriceBO.java b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcSkuPriceBO.java new file mode 100644 index 000000000..4b554b925 --- /dev/null +++ b/order/order-service-api/src/main/java/cn/iocoder/mall/order/api/bo/CalcSkuPriceBO.java @@ -0,0 +1,31 @@ +package cn.iocoder.mall.order.api.bo; + +import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 计算商品 SKU 价格结果 BO + */ +@Data +@Accessors(chain = true) +public class CalcSkuPriceBO { + + /** + * 满减送促销活动 + */ + private PromotionActivityBO fullPrivilege; + /** + * 电视和折扣促销活动 + */ + private PromotionActivityBO timeLimitedDiscount; + /** + * 原价格,单位:分。 + */ + private Integer originalPrice; + /** + * 最终价格,单位:分。 + */ + private Integer presentPrice; + +} diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java index e945703a7..fe823da05 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/CartServiceImpl.java @@ -4,10 +4,7 @@ import cn.iocoder.common.framework.constant.CommonStatusEnum; import cn.iocoder.common.framework.util.ServiceExceptionUtil; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.order.api.CartService; -import cn.iocoder.mall.order.api.bo.CalcOrderPriceBO; -import cn.iocoder.mall.order.api.bo.CartBO; -import cn.iocoder.mall.order.api.bo.CartItemBO; -import cn.iocoder.mall.order.api.bo.OrderCreateBO; +import cn.iocoder.mall.order.api.bo.*; import cn.iocoder.mall.order.api.constant.CartItemStatusEnum; import cn.iocoder.mall.order.api.constant.OrderErrorCodeEnum; import cn.iocoder.mall.order.api.dto.CalcOrderPriceDTO; @@ -190,6 +187,11 @@ public class CartServiceImpl implements CartService { return CommonResult.success(calcOrderPriceBO); } + @Override + public CommonResult calcSkuPrice(Integer skuId) { + return null; + } + @Override public CommonResult details(Integer userId) { return null; diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/PromotionActivityService.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/PromotionActivityService.java new file mode 100644 index 000000000..63bc91b91 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/PromotionActivityService.java @@ -0,0 +1,17 @@ +package cn.iocoder.mall.promotion.api; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.promotion.api.bo.PromotionActivityBO; + +import java.util.Collection; +import java.util.List; + +public interface PromotionActivityService { + + CommonResult> getPromotionActivityListBySpuId(Integer spuId, + Collection activityStatuses); + + CommonResult> getPromotionActivityListBySpuIds(Collection spuIds, + Collection activityStatuses); + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/PromotionActivityBO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/PromotionActivityBO.java new file mode 100644 index 000000000..925034c1b --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/bo/PromotionActivityBO.java @@ -0,0 +1,134 @@ +package cn.iocoder.mall.promotion.api.bo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.List; +import java.util.Set; + +@Data +@Accessors(chain = true) +public class PromotionActivityBO { + + /** + * 活动编号 + */ + private Integer id; + /** + * 活动标题 + */ + private String title; + /** + * 活动类型 + * + * 参见 {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityTypeEnum} 枚举 + */ + private Integer type; + /** + * 活动状态 + * + * 参见 {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityStatusEnum} 枚举 + */ + private Integer status; + /** + * 匹配的商品 SPU 编号 + */ + private Set spuIds; + + /** + * 限制折扣 + */ + @Data + @Accessors(chain = true) + public static class TimeLimitedDiscount { + + /** + * 商品折扣 + */ + @Data + @Accessors(chain = true) + public static class Item { + + /** + * 商品 SPU 编号 + */ + private Integer spuId; + /** + * 优惠类型 + */ + private Integer preferentialType; + /** + * 优惠值 + */ + private Integer preferentialValue; + + } + + /** + * 每人每种限购多少 + * + * 当 quota = 0 时,表示不限购 + */ + private Integer quota; + /** + * 商品折扣数组 + */ + private List items; + + } + + /** + * 满减送 + */ + @Data + @Accessors(chain = true) + public static class FullPrivilege { + + /** + * 优惠 + */ + @Data + @Accessors(chain = true) + public static class Privilege { + + /** + * 满足类型 + * + * 1 - 金额 + * 2 - 件数 + */ + private Integer meetType; + /** + * 满足值 + */ + private Integer meetValue; + /** + * 优惠类型 + */ + private Integer preferentialType; + /** + * 优惠值 + */ + private Integer preferentialValue; + + } + + /** + * 可用范围的类型 + * + * 参见 {@link cn.iocoder.mall.promotion.api.constant.RangeTypeEnum} 枚举 + * 暂时只用 “所有可用” + “PRODUCT_INCLUDE_PRT” + */ + private Integer rangeType; + /** + * 指定可用商品列表 + */ + private List rangeValues; + /** + * 优惠数组 + */ + private List privileges; + + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplatePreferentialTypeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PreferentialTypeEnum.java similarity index 75% rename from promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplatePreferentialTypeEnum.java rename to promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PreferentialTypeEnum.java index d958a5da7..cc683ce2b 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplatePreferentialTypeEnum.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PreferentialTypeEnum.java @@ -4,13 +4,16 @@ import cn.iocoder.common.framework.core.IntArrayValuable; import java.util.Arrays; -public enum CouponTemplatePreferentialTypeEnum implements IntArrayValuable { +/** + * 优惠类型枚举 + */ +public enum PreferentialTypeEnum implements IntArrayValuable { PRICE(1, "代金卷"), DISCOUNT(2, "折扣卷"), ; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplatePreferentialTypeEnum::getValue).toArray(); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PreferentialTypeEnum::getValue).toArray(); /** * 值 @@ -21,7 +24,7 @@ public enum CouponTemplatePreferentialTypeEnum implements IntArrayValuable { */ private final String name; - CouponTemplatePreferentialTypeEnum(Integer value, String name) { + PreferentialTypeEnum(Integer value, String name) { this.value = value; this.name = name; } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityStatusEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityStatusEnum.java new file mode 100644 index 000000000..3471ebf72 --- /dev/null +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityStatusEnum.java @@ -0,0 +1,41 @@ +package cn.iocoder.mall.promotion.api.constant; + +/** + * 促销活动状态枚举 + */ +public enum PromotionActivityStatusEnum { + + WAIT(10, "未开始"), + RUN(20, "进行中"), + END(30, "已结束"), + /** + * 1. WAIT、RUN、END 可以转换成 INVALID 状态。 + * 2. INVALID 只可以转换成 DELETED 状态。 + */ + INVALID(40, "已撤销"), + DELETED(50, "已删除"), + ; + + /** + * 状态值 + */ + private final Integer value; + /** + * 状态名 + */ + private final String name; + + PromotionActivityStatusEnum(Integer value, String name) { + this.value = value; + this.name = name; + } + + public Integer getValue() { + return value; + } + + public String getName() { + return name; + } + +} diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityTypeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityTypeEnum.java index c199bf2f1..d6bae8e6a 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityTypeEnum.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/PromotionActivityTypeEnum.java @@ -5,8 +5,8 @@ package cn.iocoder.mall.promotion.api.constant; */ public enum PromotionActivityTypeEnum { - LIMIT_DISCOUNT(1, "限时折扣"), - MEET_REDUCE(2, "满减送"), + TIME_LIMITED_DISCOUNT(1, "限时折扣"), + FULL_PRIVILEGE(2, "满减送"), ; /** diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateRangeTypeEnum.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/RangeTypeEnum.java similarity index 82% rename from promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateRangeTypeEnum.java rename to promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/RangeTypeEnum.java index 331209c62..341f50629 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/CouponTemplateRangeTypeEnum.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/constant/RangeTypeEnum.java @@ -4,7 +4,7 @@ import cn.iocoder.common.framework.core.IntArrayValuable; import java.util.Arrays; -public enum CouponTemplateRangeTypeEnum implements IntArrayValuable { +public enum RangeTypeEnum implements IntArrayValuable { ALL(10, "所有可用"), PRODUCT_INCLUDE_PRT(20, "部分商品可用,或指定商品可用"), @@ -13,7 +13,7 @@ public enum CouponTemplateRangeTypeEnum implements IntArrayValuable { CATEGORY_EXCLUDE_PRT(31, "部分分类不可用,或指定分类可用"), ; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CouponTemplateRangeTypeEnum::getValue).toArray(); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(RangeTypeEnum::getValue).toArray(); /** * 值 @@ -24,7 +24,7 @@ public enum CouponTemplateRangeTypeEnum implements IntArrayValuable { */ private final String name; - CouponTemplateRangeTypeEnum(Integer value, String name) { + RangeTypeEnum(Integer value, String name) { this.value = value; this.name = name; } diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java index 8db1d56d6..5cad0db07 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateAddDTO.java @@ -2,8 +2,8 @@ package cn.iocoder.mall.promotion.api.dto; import cn.iocoder.common.framework.validator.InEnum; import cn.iocoder.mall.promotion.api.constant.CouponTemplateDateTypeEnum; -import cn.iocoder.mall.promotion.api.constant.CouponTemplatePreferentialTypeEnum; -import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum; +import cn.iocoder.mall.promotion.api.constant.PreferentialTypeEnum; +import cn.iocoder.mall.promotion.api.constant.RangeTypeEnum; import lombok.Data; import lombok.experimental.Accessors; import org.hibernate.validator.constraints.Length; @@ -70,7 +70,7 @@ public class CouponCardTemplateAddDTO { * 31-部分(PART):部分分类不可用,或指定分类可用 */ @NotNull(message = "可用范围的类型不能为空") - @InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}") + @InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}") private Integer rangeType; /** * 指定商品 / 分类列表,使用逗号分隔商品编号 @@ -115,7 +115,7 @@ public class CouponCardTemplateAddDTO { * 2-折扣卷 */ @NotNull(message = "优惠类型不能为空") - @InEnum(value = CouponTemplatePreferentialTypeEnum.class, message = "优惠类型必须在 {value}") + @InEnum(value = PreferentialTypeEnum.class, message = "优惠类型必须在 {value}") private Integer preferentialType; /** * 优惠金额,单位:分 diff --git a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java index 024100ae3..c37effabf 100644 --- a/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java +++ b/promotion/promotion-service-api/src/main/java/cn/iocoder/mall/promotion/api/dto/CouponCardTemplateUpdateDTO.java @@ -1,7 +1,7 @@ package cn.iocoder.mall.promotion.api.dto; import cn.iocoder.common.framework.validator.InEnum; -import cn.iocoder.mall.promotion.api.constant.CouponTemplateRangeTypeEnum; +import cn.iocoder.mall.promotion.api.constant.RangeTypeEnum; import lombok.Data; import lombok.experimental.Accessors; import org.hibernate.validator.constraints.Length; @@ -69,7 +69,7 @@ public class CouponCardTemplateUpdateDTO { * 31-部分(PART):部分分类不可用,或指定分类可用 */ @NotNull(message = "可用范围的类型不能为空") - @InEnum(value = CouponTemplateRangeTypeEnum.class, message = "可用范围的类型必须在 {value}") + @InEnum(value = RangeTypeEnum.class, message = "可用范围的类型必须在 {value}") private Integer rangeType; /** * 指定商品 / 分类列表,使用逗号分隔商品编号 diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/PromotionActivityDO.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/PromotionActivityDO.java index e56d4be13..84a153dbf 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/PromotionActivityDO.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/dataobject/PromotionActivityDO.java @@ -4,6 +4,9 @@ import cn.iocoder.common.framework.dataobject.BaseDO; import lombok.Data; import lombok.experimental.Accessors; +import java.util.Date; +import java.util.List; + /** * 促销活动 DO */ @@ -21,7 +24,160 @@ public class PromotionActivityDO extends BaseDO { private String title; /** * 活动类型 + * + * 参见 {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityTypeEnum} 枚举 */ - private Integer type; + private Integer activityType; +// /** +// * 促销类型 +// * // TODO 芋艿 https://jos.jd.com/api/complexTemplate.htm?webPamer=promotion_v_o&groupName=%E4%BF%83%E9%94%80API&id=54&restName=jingdong.seller.promotion.list&isMulti=false 促销类型,可选值:单品促销(1),赠品促销(4),套装促销(6),总价促销(10) +// */ +// private Integer promotionType; + /** + * 活动状态 + * + * 参见 {@link cn.iocoder.mall.promotion.api.constant.PromotionActivityStatusEnum} 枚举 + */ + private Integer status; + /** + * 开始时间 + */ + private Date startTime; + /** + * 结束时间 + */ + private Date endTime; + /** + * 失效时间 + */ + private Date invalidTime; + /** + * 删除时间 + */ + private Date deleteTime; + /** + * 限制折扣字符串,使用 JSON 序列化成字符串存储 + */ + private String timeLimitedDiscount; + /** + * 满减送字符串,使用 JSON 序列化成字符串存储 + */ + private String fullPrivilege; + + /** + * 限制折扣 + */ + @Data + @Accessors(chain = true) + public static class TimeLimitedDiscount { + + /** + * 商品折扣 + */ + @Data + @Accessors(chain = true) + public static class Item { + + /** + * 商品 SPU 编号 + */ + private Integer spuId; + /** + * 优惠类型 + */ + private Integer preferentialType; + /** + * 优惠值 + */ + private Integer preferentialValue; + + } + + /** + * 每人每种限购多少 + * + * 当 quota = 0 时,表示不限购 + */ + private Integer quota; + /** + * 商品折扣数组 + */ + private List items; + + } + + /** + * 满减送 + */ + @Data + @Accessors(chain = true) + public static class FullPrivilege { + + /** + * 优惠 + */ + @Data + @Accessors(chain = true) + public static class Privilege { + + /** + * 满足类型 + * + * 1 - 金额 + * 2 - 件数 + */ + private Integer meetType; + /** + * 满足值 + */ + private Integer meetValue; + /** + * 优惠类型 + */ + private Integer preferentialType; + /** + * 优惠值 + */ + private Integer preferentialValue; +// /** +// * 是否包邮 +// */ +// private Boolean isPostage; +// /** +// * 积分 +// */ +// private Integer score; +// /** +// * 优惠劵(码)分组编号 +// */ +// private Integer couponTemplateId; +// /** +// * 优惠劵(码)数量 +// */ +// private Integer couponNum; +// /** +// * 赠品编号 +// */ +// private Integer presentId; + + } + + /** + * 可用范围的类型 + * + * 参见 {@link cn.iocoder.mall.promotion.api.constant.RangeTypeEnum} 枚举 + * 暂时只用 “所有可用” + “PRODUCT_INCLUDE_PRT” + */ + private Integer rangeType; + /** + * 指定可用商品列表 + */ + private List rangeValues; + /** + * 优惠数组 + */ + private List privileges; + + } } diff --git a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java index 06de25ffe..9312e32e2 100644 --- a/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java +++ b/promotion/promotion-service-impl/src/main/java/cn/iocoder/mall/promotion/biz/service/CouponServiceImpl.java @@ -158,14 +158,14 @@ public class CouponServiceImpl implements CouponService { private CommonResult checkCouponTemplatePreferentialType(Integer preferentialType, Integer percentOff, Integer priceOff, Integer priceAvailable) { - if (CouponTemplatePreferentialTypeEnum.PRICE.getValue().equals(preferentialType)) { + if (PreferentialTypeEnum.PRICE.getValue().equals(preferentialType)) { if (priceOff == null) { return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "优惠金额不能为空"); } if (priceOff >= priceAvailable) { return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "优惠金额不能d大于等于使用金额门槛"); } - } else if (CouponTemplatePreferentialTypeEnum.DISCOUNT.getValue().equals(preferentialType)) { + } else if (PreferentialTypeEnum.DISCOUNT.getValue().equals(preferentialType)) { if (percentOff == null) { return CommonResult.error(SysErrorCodeEnum.VALIDATION_REQUEST_PARAM_ERROR.getCode(), "折扣百分比不能为空"); }