Commit 5c4b61f5ff4fac3531f10aaf1f09d75fc417f6b6

Authored by YunaiV
1 parent e1d5cfe8

暂存调整 Price 接口

yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/api/price/dto/PriceCalculateRespDTO.java
@@ -35,34 +35,43 @@ public class PriceCalculateRespDTO { @@ -35,34 +35,43 @@ public class PriceCalculateRespDTO {
35 /** 35 /**
36 * 商品原价(总),单位:分 36 * 商品原价(总),单位:分
37 * 37 *
38 - * 基于 {@link OrderItem#getTotalOriginalPrice()} 求和 38 + * 基于 {@link OrderItem#getOriginalPrice()} 求和
39 */ 39 */
40 - private Integer skuOriginalPrice; 40 + private Integer originalPrice;
  41 + /**
  42 + * 活动减免优惠(总),单位:分
  43 + *
  44 + * 基于 {@link OrderItem#getActivityPrice()} 求和
  45 + */
  46 + private Integer activityPrice;
  47 + /**
  48 + * 优惠劵减免金额(总),单位:分
  49 + *
  50 + * 基于 {@link OrderItem#getCouponPrice()} 求和
  51 + */
  52 + private Integer couponPrice;
41 /** 53 /**
42 - * 商品优惠(总),单位:分 54 + * 积分减免金额(总),单位:分
43 * 55 *
44 - * 基于 {@link OrderItem#getTotalPromotionPrice()} 求和 56 + * 基于 {@link OrderItem#getPointPrice()} 求和
45 */ 57 */
46 - private Integer skuPromotionPrice; 58 + private Integer pointPrice;
47 /** 59 /**
48 - * 订单优惠(总),单位:分 60 + * 会员减免金额(总),单位:分
49 * 61 *
50 - * 例如说:满减折扣;不包括优惠劵、商品优惠 62 + * 基于 {@link OrderItem#getMemberPrice()} 求和
51 */ 63 */
52 - private Integer orderPromotionPrice; 64 + private Integer memberPrice;
53 /** 65 /**
54 * 运费金额,单位:分 66 * 运费金额,单位:分
55 */ 67 */
56 private Integer deliveryPrice; 68 private Integer deliveryPrice;
57 /** 69 /**
58 - * 应付金额(总),单位:分 70 + * 最终购买金额(总),单位:分
59 * 71 *
60 - * = {@link #skuOriginalPrice} 72 + * = {@link OrderItem#getPayPrice()} 求和
61 * + {@link #deliveryPrice} 73 * + {@link #deliveryPrice}
62 - * - {@link #skuPromotionPrice}  
63 - * - {@link #orderPromotionPrice}  
64 */ 74 */
65 - // * - {@link #couponPrice} // TODO 芋艿:靠营销表记录  
66 private Integer payPrice; 75 private Integer payPrice;
67 /** 76 /**
68 * 商品 SKU 数组 77 * 商品 SKU 数组
@@ -74,12 +83,6 @@ public class PriceCalculateRespDTO { @@ -74,12 +83,6 @@ public class PriceCalculateRespDTO {
74 * 优惠劵编号 83 * 优惠劵编号
75 */ 84 */
76 private Long couponId; 85 private Long couponId;
77 -// /**  
78 -// * 优惠劵减免金额,单位:分  
79 -// *  
80 -// * // TODO 芋艿:靠营销表记录  
81 -// */  
82 -// private Integer couponPrice;  
83 86
84 } 87 }
85 88
@@ -95,40 +98,53 @@ public class PriceCalculateRespDTO { @@ -95,40 +98,53 @@ public class PriceCalculateRespDTO {
95 private Integer count; 98 private Integer count;
96 99
97 /** 100 /**
  101 + * 商品原价(总),单位:分
  102 + *
  103 + * = {@link #originalUnitPrice} * {@link #getCount()}
  104 + */
  105 + private Integer originalPrice;
  106 + /**
98 * 商品原价(单),单位:分 107 * 商品原价(单),单位:分
99 * 108 *
100 * 对应 ProductSkuDO 的 price 字段 109 * 对应 ProductSkuDO 的 price 字段
101 */ 110 */
102 - private Integer originalPrice; 111 + private Integer originalUnitPrice;
103 /** 112 /**
104 - * 商品原价(总),单位:分 113 + * 活动减免优惠(总),单位:分
105 * 114 *
106 - * = {@link #originalPrice} * {@link #getCount()} 115 + * 例如说,限时折扣、满减送等营销活动
107 */ 116 */
108 - private Integer totalOriginalPrice; 117 + private Integer activityPrice;
109 /** 118 /**
110 - * 商品级优惠(总),单位:分 119 + * 优惠劵减免金额(总),单位:分
111 * 120 *
112 - * 例如说“限时折扣”:商品原价的 8 折;商品原价的减 50 元 121 + * 一个优惠劵会作用到的多个 SKU 商品,按照计算时的 {@link #payPrice} 的比例分摊
113 */ 122 */
114 - private Integer totalPromotionPrice; 123 + private Integer couponPrice;
  124 + /**
  125 + * 积分减免金额(总),单位:分
  126 + */
  127 + private Integer pointPrice;
  128 + /**
  129 + * 会员减免金额(总),单位:分
  130 + */
  131 + private Integer memberPrice;
115 /** 132 /**
116 * 最终购买金额(总),单位:分。 133 * 最终购买金额(总),单位:分。
117 * 134 *
118 - * = {@link #totalOriginalPrice}  
119 - * - {@link #totalPromotionPrice} 135 + * = {@link #originalPrice}
  136 + * - {@link #activityPrice}
  137 + * - {@link #couponPrice}
  138 + * - {@link #pointPrice}
  139 + * - {@link #memberPrice}
120 */ 140 */
121 - private Integer totalPresentPrice; 141 + private Integer payPrice;
122 /** 142 /**
123 * 最终购买金额(单),单位:分。 143 * 最终购买金额(单),单位:分。
124 * 144 *
125 - * = {@link #totalPresentPrice} / {@link #getCount()}  
126 - */  
127 - private Integer presentPrice;  
128 - /**  
129 - * 应付金额(总),单位:分 145 + * = {@link #payPrice} / {@link #getCount()}
130 */ 146 */
131 - private Integer totalPayPrice; 147 + private Integer payUnitPrice;
132 148
133 } 149 }
134 150
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionLevelEnum.java
@@ -15,8 +15,8 @@ import java.util.Arrays; @@ -15,8 +15,8 @@ import java.util.Arrays;
15 @AllArgsConstructor 15 @AllArgsConstructor
16 public enum PromotionLevelEnum implements IntArrayValuable { 16 public enum PromotionLevelEnum implements IntArrayValuable {
17 17
18 - ORDER(1, "订单级"),  
19 - SKU(2, "商品级"), 18 + ORDER(1, "订单级"), // 多个商品,进行组合后优惠
  19 + SKU(2, "商品级"), // 单个商品,直接优惠
20 ; 20 ;
21 21
22 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionLevelEnum::getLevel).toArray(); 22 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionLevelEnum::getLevel).toArray();
yudao-module-mall/yudao-module-market-api/src/main/java/cn/iocoder/yudao/module/market/enums/common/PromotionTypeEnum.java
@@ -15,8 +15,8 @@ import java.util.Arrays; @@ -15,8 +15,8 @@ import java.util.Arrays;
15 @AllArgsConstructor 15 @AllArgsConstructor
16 public enum PromotionTypeEnum implements IntArrayValuable { 16 public enum PromotionTypeEnum implements IntArrayValuable {
17 17
18 - DISCOUNT(1, "限时折扣"),  
19 - REWARD(2, "满减送"), 18 + DISCOUNT_ACTIVITY(1, "限时折扣"),
  19 + REWARD_ACTIVITY(2, "满减送"),
20 ; 20 ;
21 21
22 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray(); 22 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(PromotionTypeEnum::getType).toArray();
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/convert/price/PriceConvert.java
@@ -19,8 +19,8 @@ public interface PriceConvert { @@ -19,8 +19,8 @@ public interface PriceConvert {
19 default PriceCalculateRespDTO convert(PriceCalculateReqDTO calculateReqDTO, List<ProductSkuRespDTO> skuList) { 19 default PriceCalculateRespDTO convert(PriceCalculateReqDTO calculateReqDTO, List<ProductSkuRespDTO> skuList) {
20 // 创建 PriceCalculateRespDTO 对象 20 // 创建 PriceCalculateRespDTO 对象
21 PriceCalculateRespDTO priceCalculate = new PriceCalculateRespDTO(); 21 PriceCalculateRespDTO priceCalculate = new PriceCalculateRespDTO();
22 - priceCalculate.setOrder(new PriceCalculateRespDTO.Order().setSkuOriginalPrice(0).setSkuPromotionPrice(0)  
23 - .setOrderPromotionPrice(0).setDeliveryPrice(0).setPayPrice(0).setItems(new ArrayList<>()) 22 + priceCalculate.setOrder(new PriceCalculateRespDTO.Order().setOriginalPrice(0).setActivityPrice(0)
  23 + .setDeliveryPrice(0).setPayPrice(0).setItems(new ArrayList<>())
24 .setCouponId(calculateReqDTO.getCouponId())); 24 .setCouponId(calculateReqDTO.getCouponId()));
25 priceCalculate.setPromotions(new ArrayList<>()); 25 priceCalculate.setPromotions(new ArrayList<>());
26 // 创建它的 OrderItem 属性 26 // 创建它的 OrderItem 属性
@@ -29,9 +29,9 @@ public interface PriceConvert { @@ -29,9 +29,9 @@ public interface PriceConvert {
29 skuList.forEach(sku -> { 29 skuList.forEach(sku -> {
30 Integer count = skuIdCountMap.get(sku.getId()); 30 Integer count = skuIdCountMap.get(sku.getId());
31 PriceCalculateRespDTO.OrderItem orderItem = new PriceCalculateRespDTO.OrderItem().setCount(count) 31 PriceCalculateRespDTO.OrderItem orderItem = new PriceCalculateRespDTO.OrderItem().setCount(count)
32 - .setOriginalPrice(sku.getPrice()).setTotalOriginalPrice(sku.getPrice() * count).setTotalPromotionPrice(0);  
33 - orderItem.setTotalPresentPrice(orderItem.getTotalPresentPrice()).setPresentPrice(orderItem.getOriginalPrice())  
34 - .setTotalPayPrice(orderItem.getTotalPayPrice()); 32 + .setOriginalUnitPrice(sku.getPrice()).setOriginalPrice(sku.getPrice() * count).setActivityPrice(0);
  33 + orderItem.setPayPrice(orderItem.getPayPrice()).setPayUnitPrice(orderItem.getOriginalUnitPrice())
  34 + .setPayPrice(orderItem.getPayPrice());
35 priceCalculate.getOrder().getItems().add(orderItem); 35 priceCalculate.getOrder().getItems().add(orderItem);
36 }); 36 });
37 return priceCalculate; 37 return priceCalculate;
yudao-module-mall/yudao-module-market-biz/src/main/java/cn/iocoder/yudao/module/market/service/price/PriceServiceImpl.java
@@ -15,7 +15,6 @@ import java.util.Map; @@ -15,7 +15,6 @@ import java.util.Map;
15 15
16 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 16 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
17 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; 17 import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS;
18 -import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_STOCK_NOT_ENOUGH;  
19 18
20 /** 19 /**
21 * 价格计算 Service 实现类 20 * 价格计算 Service 实现类
@@ -54,9 +53,7 @@ public class PriceServiceImpl implements PriceService { @@ -54,9 +53,7 @@ public class PriceServiceImpl implements PriceService {
54 if (count == null) { 53 if (count == null) {
55 throw exception(SKU_NOT_EXISTS); 54 throw exception(SKU_NOT_EXISTS);
56 } 55 }
57 - if (count > sku.getStock()) {  
58 - throw exception(SKU_STOCK_NOT_ENOUGH);  
59 - } 56 + // 不校验库存不足,避免购物车场景,商品无货的情况
60 }); 57 });
61 return skus; 58 return skus;
62 } 59 }