前端+后端:完整接入订单确认的优惠劵计算

This commit is contained in:
YunaiV
2019-04-20 01:22:39 +08:00
parent cb07eb3f71
commit bc2bf52039
8 changed files with 42 additions and 16 deletions

View File

@@ -379,7 +379,8 @@ public class CartServiceImpl implements CartService {
Assert.isTrue(presentTotal > 0, "计算后,价格为负数:" + presentTotal);
} else if (PreferentialTypeEnum.DISCOUNT.getValue().equals(couponCard.getPreferentialType())) { // 打折
presentTotal = originalTotal * couponCard.getPercentOff() / 100;
if (originalTotal - presentTotal > couponCard.getDiscountPriceLimit()) {
if (couponCard.getDiscountPriceLimit() != null // 空,代表不限制优惠上限
&& originalTotal - presentTotal > couponCard.getDiscountPriceLimit()) {
presentTotal = originalTotal - couponCard.getDiscountPriceLimit();
}
} else {
@@ -432,7 +433,7 @@ public class CartServiceImpl implements CartService {
Assert.isTrue(PromotionActivityTypeEnum.FULL_PRIVILEGE.getValue().equals(activity.getActivityType()),
"传入的必须的满减送活动必须是满减送");
// 获得优惠信息
List<CalcOrderPriceBO.Item> items = itemGroup.getItems().stream().filter(item -> !item.getSelected())
List<CalcOrderPriceBO.Item> items = itemGroup.getItems().stream().filter(CalcOrderPriceBO.Item::getSelected)
.collect(Collectors.toList());
Integer itemCnt = items.stream().mapToInt(CalcOrderPriceBO.Item::getBuyQuantity).sum();
Integer originalTotal = items.stream().mapToInt(CalcOrderPriceBO.Item::getPresentTotal).sum();