Commit 636cc794ddcc022e09b26518464a9587190279e6
1 parent
c87bc084
promotion:完善价格计算,重新接入限时折扣的多种优惠方式
Showing
6 changed files
with
75 additions
and
48 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/ErrorCodeConstants.java
| ... | ... | @@ -40,4 +40,7 @@ public interface ErrorCodeConstants { |
| 40 | 40 | ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_CLOSED = new ErrorCode(1003006004, "满减送活动已关闭,不能重复关闭"); |
| 41 | 41 | ErrorCode REWARD_ACTIVITY_CLOSE_FAIL_STATUS_END = new ErrorCode(1003006004, "满减送活动已结束,不能关闭"); |
| 42 | 42 | |
| 43 | + // ========== Price 相关 1003007000 ============ | |
| 44 | + ErrorCode PRICE_CALCULATE_PAY_PRICE_ILLEGAL = new ErrorCode(1003007000, "支付价格计算异常,原因:价格小于等于 0"); | |
| 45 | + | |
| 43 | 46 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityService.java
| ... | ... | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountAc |
| 6 | 6 | import cn.iocoder.yudao.module.promotion.controller.admin.discount.vo.DiscountActivityUpdateReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountActivityDO; |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; |
| 9 | +import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; | |
| 9 | 10 | |
| 10 | 11 | import javax.validation.Valid; |
| 11 | 12 | import java.util.Collection; |
| ... | ... | @@ -27,7 +28,7 @@ public interface DiscountActivityService { |
| 27 | 28 | * @param skuIds SKU 编号数组 |
| 28 | 29 | * @return 匹配的限时折扣商品 |
| 29 | 30 | */ |
| 30 | - Map<Long, DiscountProductDO> getMatchDiscountProducts(Collection<Long> skuIds); | |
| 31 | + Map<Long, DiscountProductDetailBO> getMatchDiscountProducts(Collection<Long> skuIds); | |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | 34 | * 创建限时折扣活动 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/DiscountActivityServiceImpl.java
| ... | ... | @@ -23,8 +23,7 @@ import javax.annotation.Resource; |
| 23 | 23 | import java.util.*; |
| 24 | 24 | |
| 25 | 25 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 26 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 27 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 26 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | |
| 28 | 27 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 29 | 28 | import static java.util.Arrays.asList; |
| 30 | 29 | |
| ... | ... | @@ -42,13 +41,10 @@ public class DiscountActivityServiceImpl implements DiscountActivityService { |
| 42 | 41 | @Resource |
| 43 | 42 | private DiscountProductMapper discountProductMapper; |
| 44 | 43 | |
| 45 | - // TODO 芋艿:待实现 | |
| 46 | 44 | @Override |
| 47 | - public Map<Long, DiscountProductDO> getMatchDiscountProducts(Collection<Long> skuIds) { | |
| 48 | - Map<Long, DiscountProductDO> products = new HashMap<>(); | |
| 49 | - products.put(1L, new DiscountProductDO().setDiscountPrice(100)); | |
| 50 | - products.put(2L, new DiscountProductDO().setDiscountPrice(50)); | |
| 51 | - return products; | |
| 45 | + public Map<Long, DiscountProductDetailBO> getMatchDiscountProducts(Collection<Long> skuIds) { | |
| 46 | + List<DiscountProductDetailBO> discountProducts = getRewardProductListBySkuIds(skuIds, singleton(PromotionActivityStatusEnum.RUN.getStatus())); | |
| 47 | + return convertMap(discountProducts, DiscountProductDetailBO::getSkuId); | |
| 52 | 48 | } |
| 53 | 49 | |
| 54 | 50 | @Override |
| ... | ... | @@ -116,7 +112,7 @@ public class DiscountActivityServiceImpl implements DiscountActivityService { |
| 116 | 112 | return; |
| 117 | 113 | } |
| 118 | 114 | // 查询商品参加的活动 |
| 119 | - List<DiscountProductDetailBO> discountActivityProductList = getRewardActivityListBySkuIds( | |
| 115 | + List<DiscountProductDetailBO> discountActivityProductList = getRewardProductListBySkuIds( | |
| 120 | 116 | convertSet(products, DiscountActivityBaseVO.Product::getSkuId), |
| 121 | 117 | asList(PromotionActivityStatusEnum.WAIT.getStatus(), PromotionActivityStatusEnum.RUN.getStatus())); |
| 122 | 118 | if (id != null) { // 排除自己这个活动 |
| ... | ... | @@ -128,8 +124,8 @@ public class DiscountActivityServiceImpl implements DiscountActivityService { |
| 128 | 124 | } |
| 129 | 125 | } |
| 130 | 126 | |
| 131 | - private List<DiscountProductDetailBO> getRewardActivityListBySkuIds(Collection<Long> skuIds, | |
| 132 | - Collection<Integer> statuses) { | |
| 127 | + private List<DiscountProductDetailBO> getRewardProductListBySkuIds(Collection<Long> skuIds, | |
| 128 | + Collection<Integer> statuses) { | |
| 133 | 129 | // 查询商品 |
| 134 | 130 | List<DiscountProductDO> products = discountProductMapper.selectListBySkuId(skuIds); |
| 135 | 131 | if (CollUtil.isEmpty(products)) { | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/discount/bo/DiscountProductDetailBO.java
| ... | ... | @@ -29,7 +29,15 @@ public class DiscountProductDetailBO { |
| 29 | 29 | */ |
| 30 | 30 | private Long skuId; |
| 31 | 31 | /** |
| 32 | - * 优惠价格,单位:分 | |
| 32 | + * 折扣类型 | |
| 33 | + */ | |
| 34 | + private Integer discountType; | |
| 35 | + /** | |
| 36 | + * 折扣百分比 | |
| 37 | + */ | |
| 38 | + private Integer discountPercent; | |
| 39 | + /** | |
| 40 | + * 优惠金额,单位:分 | |
| 33 | 41 | */ |
| 34 | 42 | private Integer discountPrice; |
| 35 | 43 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceImpl.java
| ... | ... | @@ -4,19 +4,20 @@ import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.lang.Assert; |
| 5 | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | +import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | |
| 8 | +import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | |
| 7 | 9 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; |
| 8 | 10 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; |
| 9 | 11 | import cn.iocoder.yudao.module.promotion.convert.price.PriceConvert; |
| 10 | 12 | import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; |
| 11 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | |
| 12 | 13 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; |
| 13 | 14 | import cn.iocoder.yudao.module.promotion.enums.common.*; |
| 14 | 15 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; |
| 15 | 16 | import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; |
| 16 | -import cn.iocoder.yudao.module.product.api.sku.ProductSkuApi; | |
| 17 | -import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; | |
| 17 | +import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; | |
| 18 | 18 | import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; |
| 19 | 19 | import com.google.common.base.Suppliers; |
| 20 | +import lombok.extern.slf4j.Slf4j; | |
| 20 | 21 | import org.springframework.stereotype.Service; |
| 21 | 22 | import org.springframework.validation.annotation.Validated; |
| 22 | 23 | |
| ... | ... | @@ -30,9 +31,8 @@ import java.util.function.Supplier; |
| 30 | 31 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 31 | 32 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 32 | 33 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue; |
| 33 | -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_MIN_PRICE; | |
| 34 | -import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_SPU; | |
| 35 | 34 | import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.SKU_NOT_EXISTS; |
| 35 | +import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; | |
| 36 | 36 | import static java.util.Collections.singletonList; |
| 37 | 37 | |
| 38 | 38 | /** |
| ... | ... | @@ -51,6 +51,7 @@ import static java.util.Collections.singletonList; |
| 51 | 51 | */ |
| 52 | 52 | @Service |
| 53 | 53 | @Validated |
| 54 | +@Slf4j | |
| 54 | 55 | public class PriceServiceImpl implements PriceService { |
| 55 | 56 | |
| 56 | 57 | @Resource |
| ... | ... | @@ -76,6 +77,13 @@ public class PriceServiceImpl implements PriceService { |
| 76 | 77 | calculatePriceForOrderLevel(calculateReqDTO.getUserId(), priceCalculate); |
| 77 | 78 | // 计算优惠劵级别的价格 |
| 78 | 79 | calculatePriceForCouponLevel(calculateReqDTO.getUserId(), calculateReqDTO.getCouponId(), priceCalculate); |
| 80 | + | |
| 81 | + // 如果最终支付金额小于等于 0,则抛出业务异常 | |
| 82 | + if (priceCalculate.getOrder().getPayPrice() <= 0) { | |
| 83 | + log.error("[calculatePrice][价格计算不正确,请求 calculateReqDTO({}),结果 priceCalculate({})]", | |
| 84 | + calculateReqDTO, priceCalculate); | |
| 85 | + throw exception(PRICE_CALCULATE_PAY_PRICE_ILLEGAL); | |
| 86 | + } | |
| 79 | 87 | return priceCalculate; |
| 80 | 88 | } |
| 81 | 89 | |
| ... | ... | @@ -111,24 +119,20 @@ public class PriceServiceImpl implements PriceService { |
| 111 | 119 | private void calculatePriceForSkuLevel(Long userId, PriceCalculateRespDTO priceCalculate) { |
| 112 | 120 | // 获取 SKU 级别的所有优惠信息 |
| 113 | 121 | Supplier<Double> memberDiscountPercentSupplier = getMemberDiscountPercentSupplier(userId); |
| 114 | - Map<Long, DiscountProductDO> discountProducts = discountService.getMatchDiscountProducts( | |
| 122 | + Map<Long, DiscountProductDetailBO> discountProducts = discountService.getMatchDiscountProducts( | |
| 115 | 123 | convertSet(priceCalculate.getOrder().getItems(), PriceCalculateRespDTO.OrderItem::getSkuId)); |
| 116 | 124 | |
| 117 | 125 | // 处理每个 SKU 的优惠 |
| 118 | 126 | priceCalculate.getOrder().getItems().forEach(orderItem -> { |
| 119 | 127 | // 获取该 SKU 的优惠信息 |
| 120 | 128 | Double memberDiscountPercent = memberDiscountPercentSupplier.get(); |
| 121 | - DiscountProductDO discountProduct = discountProducts.get(orderItem.getSkuId()); | |
| 122 | - if (discountProduct != null // 假设优惠价格更贵,则认为没优惠 | |
| 123 | - && discountProduct.getDiscountPrice() >= orderItem.getOriginalUnitPrice()) { | |
| 124 | - discountProduct = null; | |
| 125 | - } | |
| 129 | + DiscountProductDetailBO discountProduct = discountProducts.get(orderItem.getSkuId()); | |
| 126 | 130 | if (memberDiscountPercent == null && discountProduct == null) { |
| 127 | 131 | return; |
| 128 | 132 | } |
| 129 | 133 | // 计算价格,判断选择哪个折扣 |
| 130 | 134 | Integer memberPrice = memberDiscountPercent != null ? (int) (orderItem.getPayPrice() * memberDiscountPercent / 100) : null; |
| 131 | - Integer promotionPrice = discountProduct != null ? discountProduct.getDiscountPrice() * orderItem.getCount() : null; | |
| 135 | + Integer promotionPrice = discountProduct != null ? getDiscountProductPrice(discountProduct, orderItem) : null; | |
| 132 | 136 | if (memberPrice == null) { |
| 133 | 137 | calculatePriceByDiscountActivity(priceCalculate, orderItem, discountProduct, promotionPrice); |
| 134 | 138 | } else if (promotionPrice == null) { |
| ... | ... | @@ -141,6 +145,19 @@ public class PriceServiceImpl implements PriceService { |
| 141 | 145 | }); |
| 142 | 146 | } |
| 143 | 147 | |
| 148 | + private Integer getDiscountProductPrice(DiscountProductDetailBO discountProduct, | |
| 149 | + PriceCalculateRespDTO.OrderItem orderItem) { | |
| 150 | + Integer price = orderItem.getPayPrice(); | |
| 151 | + if (PromotionDiscountTypeEnum.PRICE.getType().equals(discountProduct.getDiscountType())) { // 减价 | |
| 152 | + price -= discountProduct.getDiscountPrice() * orderItem.getCount(); | |
| 153 | + } else if (PromotionDiscountTypeEnum.PERCENT.getType().equals(discountProduct.getDiscountType())) { // 打折 | |
| 154 | + price = price * discountProduct.getDiscountPercent() / 100; | |
| 155 | + } else { | |
| 156 | + throw new IllegalArgumentException(String.format("优惠活动的商品(%s) 的优惠类型不正确", discountProduct)); | |
| 157 | + } | |
| 158 | + return price; | |
| 159 | + } | |
| 160 | + | |
| 144 | 161 | private void calculatePriceByMemberDiscount(PriceCalculateRespDTO priceCalculate, PriceCalculateRespDTO.OrderItem orderItem, |
| 145 | 162 | Integer memberPrice) { |
| 146 | 163 | // 记录优惠明细 |
| ... | ... | @@ -152,10 +169,9 @@ public class PriceServiceImpl implements PriceService { |
| 152 | 169 | } |
| 153 | 170 | |
| 154 | 171 | private void calculatePriceByDiscountActivity(PriceCalculateRespDTO priceCalculate, PriceCalculateRespDTO.OrderItem orderItem, |
| 155 | - DiscountProductDO discountProduct, Integer promotionPrice) { | |
| 172 | + DiscountProductDetailBO discountProduct, Integer promotionPrice) { | |
| 156 | 173 | // 记录优惠明细 |
| 157 | - addPromotion(priceCalculate, orderItem, discountProduct.getActivityId(), null | |
| 158 | - /* TODO 芋艿:修复下 discountProduct.getActivityName()*/, | |
| 174 | + addPromotion(priceCalculate, orderItem, discountProduct.getActivityId(), discountProduct.getActivityName(), | |
| 159 | 175 | PromotionTypeEnum.DISCOUNT_ACTIVITY.getType(), PromotionLevelEnum.SKU.getLevel(), promotionPrice, |
| 160 | 176 | true, StrUtil.format("限时折扣:省 {} 元", formatPrice(orderItem.getPayPrice() - promotionPrice))); |
| 161 | 177 | // 修改 SKU 的优惠 |
| ... | ... | @@ -213,7 +229,6 @@ public class PriceServiceImpl implements PriceService { |
| 213 | 229 | } |
| 214 | 230 | |
| 215 | 231 | // 分摊金额 |
| 216 | - // TODO 芋艿:limit 不能超过最大价格 | |
| 217 | 232 | List<Integer> discountPartPrices = dividePrice(orderItems, rule.getDiscountPrice()); |
| 218 | 233 | // 记录优惠明细 |
| 219 | 234 | addPromotion(priceCalculate, orderItems, rewardActivity.getId(), rewardActivity.getName(), |
| ... | ... | @@ -288,7 +303,6 @@ public class PriceServiceImpl implements PriceService { |
| 288 | 303 | priceCalculate.getOrder().setCouponId(couponId); |
| 289 | 304 | Integer couponPrice = getCouponPrice(coupon, originPrice); |
| 290 | 305 | // 分摊金额 |
| 291 | - // TODO 芋艿:limit 不能超过最大价格 | |
| 292 | 306 | List<Integer> couponPartPrices = dividePrice(orderItems, couponPrice); |
| 293 | 307 | // 记录优惠明细 |
| 294 | 308 | addPromotion(priceCalculate, orderItems, coupon.getId(), coupon.getName(), | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/test/java/cn/iocoder/yudao/module/promotion/service/price/PriceServiceTest.java
| ... | ... | @@ -7,11 +7,11 @@ import cn.iocoder.yudao.module.product.api.sku.dto.ProductSkuRespDTO; |
| 7 | 7 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateReqDTO; |
| 8 | 8 | import cn.iocoder.yudao.module.promotion.api.price.dto.PriceCalculateRespDTO; |
| 9 | 9 | import cn.iocoder.yudao.module.promotion.dal.dataobject.coupon.CouponDO; |
| 10 | -import cn.iocoder.yudao.module.promotion.dal.dataobject.discount.DiscountProductDO; | |
| 11 | 10 | import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO; |
| 12 | 11 | import cn.iocoder.yudao.module.promotion.enums.common.*; |
| 13 | 12 | import cn.iocoder.yudao.module.promotion.service.coupon.CouponService; |
| 14 | 13 | import cn.iocoder.yudao.module.promotion.service.discount.DiscountActivityService; |
| 14 | +import cn.iocoder.yudao.module.promotion.service.discount.bo.DiscountProductDetailBO; | |
| 15 | 15 | import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService; |
| 16 | 16 | import org.junit.jupiter.api.Test; |
| 17 | 17 | import org.mockito.InjectMocks; |
| ... | ... | @@ -109,13 +109,18 @@ public class PriceServiceTest extends BaseMockitoUnitTest { |
| 109 | 109 | ProductSkuRespDTO productSku02 = randomPojo(ProductSkuRespDTO.class, o -> o.setId(20L).setPrice(50)); |
| 110 | 110 | when(productSkuApi.getSkuList(eq(asSet(10L, 20L)))).thenReturn(asList(productSku01, productSku02)); |
| 111 | 111 | // mock 方法(限时折扣 DiscountActivity 信息) |
| 112 | - DiscountProductDO discountProduct01 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(1000L)/*.setActsivityName("活动 1000 号") TODO 芋艿:待完善 */ | |
| 113 | - .setSkuId(10L).setDiscountPrice(80)); | |
| 114 | - DiscountProductDO discountProduct02 = randomPojo(DiscountProductDO.class, o -> o.setActivityId(2000L)/*.setActivityName("活动 2000 号") TODO 芋艿:待完善 */ | |
| 115 | - .setSkuId(20L).setDiscountPrice(80)); | |
| 112 | + DiscountProductDetailBO discountProduct01 = randomPojo(DiscountProductDetailBO.class, o -> o.setActivityId(1000L) | |
| 113 | + .setActivityName("活动 1000 号").setSkuId(10L) | |
| 114 | + .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(40)); | |
| 115 | + DiscountProductDetailBO discountProduct02 = randomPojo(DiscountProductDetailBO.class, o -> o.setActivityId(2000L) | |
| 116 | + .setActivityName("活动 2000 号").setSkuId(20L) | |
| 117 | + .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(60)); | |
| 116 | 118 | when(discountService.getMatchDiscountProducts(eq(asSet(10L, 20L)))).thenReturn( |
| 117 | 119 | MapUtil.builder(10L, discountProduct01).put(20L, discountProduct02).map()); |
| 118 | 120 | |
| 121 | + // 10L: 100 * 2 - 40 * 2 = 120 | |
| 122 | + // 20L:50 * 3 - 50 * 3 * 0.4 = 90 | |
| 123 | + | |
| 119 | 124 | // 调用 |
| 120 | 125 | PriceCalculateRespDTO priceCalculate = priceService.calculatePrice(calculateReqDTO); |
| 121 | 126 | // 断言 Order 部分 |
| ... | ... | @@ -124,7 +129,7 @@ public class PriceServiceTest extends BaseMockitoUnitTest { |
| 124 | 129 | assertEquals(order.getDiscountPrice(), 0); |
| 125 | 130 | assertEquals(order.getPointPrice(), 0); |
| 126 | 131 | assertEquals(order.getDeliveryPrice(), 0); |
| 127 | - assertEquals(order.getPayPrice(), 280); | |
| 132 | + assertEquals(order.getPayPrice(), 210); | |
| 128 | 133 | assertNull(order.getCouponId()); |
| 129 | 134 | // 断言 OrderItem 部分 |
| 130 | 135 | assertEquals(order.getItems().size(), 2); |
| ... | ... | @@ -133,19 +138,19 @@ public class PriceServiceTest extends BaseMockitoUnitTest { |
| 133 | 138 | assertEquals(orderItem01.getCount(), 2); |
| 134 | 139 | assertEquals(orderItem01.getOriginalPrice(), 200); |
| 135 | 140 | assertEquals(orderItem01.getOriginalUnitPrice(), 100); |
| 136 | - assertEquals(orderItem01.getDiscountPrice(), 40); | |
| 137 | - assertEquals(orderItem01.getPayPrice(), 160); | |
| 141 | + assertEquals(orderItem01.getDiscountPrice(), 80); | |
| 142 | + assertEquals(orderItem01.getPayPrice(), 120); | |
| 138 | 143 | assertEquals(orderItem01.getOrderPartPrice(), 0); |
| 139 | - assertEquals(orderItem01.getOrderDividePrice(), 160); | |
| 144 | + assertEquals(orderItem01.getOrderDividePrice(), 120); | |
| 140 | 145 | PriceCalculateRespDTO.OrderItem orderItem02 = order.getItems().get(1); |
| 141 | 146 | assertEquals(orderItem02.getSkuId(), 20L); |
| 142 | 147 | assertEquals(orderItem02.getCount(), 3); |
| 143 | 148 | assertEquals(orderItem02.getOriginalPrice(), 150); |
| 144 | 149 | assertEquals(orderItem02.getOriginalUnitPrice(), 50); |
| 145 | - assertEquals(orderItem02.getDiscountPrice(), 30); | |
| 146 | - assertEquals(orderItem02.getPayPrice(), 120); | |
| 150 | + assertEquals(orderItem02.getDiscountPrice(), 60); | |
| 151 | + assertEquals(orderItem02.getPayPrice(), 90); | |
| 147 | 152 | assertEquals(orderItem02.getOrderPartPrice(), 0); |
| 148 | - assertEquals(orderItem02.getOrderDividePrice(), 120); | |
| 153 | + assertEquals(orderItem02.getOrderDividePrice(), 90); | |
| 149 | 154 | // 断言 Promotion 部分 |
| 150 | 155 | assertEquals(priceCalculate.getPromotions().size(), 2); |
| 151 | 156 | PriceCalculateRespDTO.Promotion promotion01 = priceCalculate.getPromotions().get(0); |
| ... | ... | @@ -154,28 +159,28 @@ public class PriceServiceTest extends BaseMockitoUnitTest { |
| 154 | 159 | assertEquals(promotion01.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType()); |
| 155 | 160 | assertEquals(promotion01.getLevel(), PromotionLevelEnum.SKU.getLevel()); |
| 156 | 161 | assertEquals(promotion01.getOriginalPrice(), 200); |
| 157 | - assertEquals(promotion01.getDiscountPrice(), 40); | |
| 162 | + assertEquals(promotion01.getDiscountPrice(), 80); | |
| 158 | 163 | assertTrue(promotion01.getMeet()); |
| 159 | - assertEquals(promotion01.getMeetTip(), "限时折扣:省 0.40 元"); | |
| 164 | + assertEquals(promotion01.getMeetTip(), "限时折扣:省 0.80 元"); | |
| 160 | 165 | PriceCalculateRespDTO.PromotionItem promotionItem01 = promotion01.getItems().get(0); |
| 161 | 166 | assertEquals(promotion01.getItems().size(), 1); |
| 162 | 167 | assertEquals(promotionItem01.getSkuId(), 10L); |
| 163 | 168 | assertEquals(promotionItem01.getOriginalPrice(), 200); |
| 164 | - assertEquals(promotionItem01.getDiscountPrice(), 40); | |
| 169 | + assertEquals(promotionItem01.getDiscountPrice(), 80); | |
| 165 | 170 | PriceCalculateRespDTO.Promotion promotion02 = priceCalculate.getPromotions().get(1); |
| 166 | 171 | assertEquals(promotion02.getId(), 2000L); |
| 167 | 172 | assertEquals(promotion02.getName(), "活动 2000 号"); |
| 168 | 173 | assertEquals(promotion02.getType(), PromotionTypeEnum.DISCOUNT_ACTIVITY.getType()); |
| 169 | 174 | assertEquals(promotion02.getLevel(), PromotionLevelEnum.SKU.getLevel()); |
| 170 | 175 | assertEquals(promotion02.getOriginalPrice(), 150); |
| 171 | - assertEquals(promotion02.getDiscountPrice(), 30); | |
| 176 | + assertEquals(promotion02.getDiscountPrice(), 60); | |
| 172 | 177 | assertTrue(promotion02.getMeet()); |
| 173 | - assertEquals(promotion02.getMeetTip(), "限时折扣:省 0.30 元"); | |
| 178 | + assertEquals(promotion02.getMeetTip(), "限时折扣:省 0.60 元"); | |
| 174 | 179 | PriceCalculateRespDTO.PromotionItem promotionItem02 = promotion02.getItems().get(0); |
| 175 | 180 | assertEquals(promotion02.getItems().size(), 1); |
| 176 | 181 | assertEquals(promotionItem02.getSkuId(), 20L); |
| 177 | 182 | assertEquals(promotionItem02.getOriginalPrice(), 150); |
| 178 | - assertEquals(promotionItem02.getDiscountPrice(), 30); | |
| 183 | + assertEquals(promotionItem02.getDiscountPrice(), 60); | |
| 179 | 184 | } |
| 180 | 185 | |
| 181 | 186 | /** | ... | ... |