Commit b3a5f6f0 by 张跃

购物车算价

parent 5e14d013
......@@ -46,7 +46,7 @@ public class TimeSalePromotionService implements IPromotionService {
Map<String, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods> goodsMap = goodsList.parallelStream()
.collect(Collectors.toMap(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods::getCartGoodsUid, Function.identity(), (k1, k2) -> k1));
// 存储当前享受限时特价折扣的商品数量,key:goodsId; value:可享受数量
Map<String, Integer> numberMap = new HashMap<>();
//Map<String, Integer> numberMap = new HashMap<>();
List<Integer> discounts = Arrays.asList(ActivityTypeEnum.TYPE_2.getCode(), ActivityTypeEnum.TYPE_21.getCode(), ActivityTypeEnum.TYPE_22.getCode());
String uid = "";
for (CartGoods cartGoods : cartGoodsList) {
......@@ -59,13 +59,13 @@ public class TimeSalePromotionService implements IPromotionService {
continue;
}
// 享受限时特价折扣的商品数量
Integer specialActualGoodsNumber = null;
Integer specialActualGoodsNumber = goodsDiscount.getActualGoodsNumber();
// 商品现价
Long goodsNowPrice = cartGoods.getOriginalPrice() - goodsDiscount.getDiscount() / goodsDiscount.getActualGoodsNumber();
Long goodsNowPrice = cartGoods.getOriginalPrice() - goodsDiscount.getDiscount()/goodsDiscount.getActualGoodsNumber();
// numberMap用于暂存当前商品行可享受限时特价折扣的商品数量
if ((specialActualGoodsNumber = numberMap.get(goods.getGoodsId())) == null) {
numberMap.put(goods.getGoodsId(), specialActualGoodsNumber=goodsDiscount.getActualGoodsNumber());
}
// if ((specialActualGoodsNumber = numberMap.get(goods.getGoodsId())) == null) {
// numberMap.put(goods.getGoodsId(), specialActualGoodsNumber=goodsDiscount.getActualGoodsNumber());
// }
//若可享受数量>=当前商品行的商品数量
if (specialActualGoodsNumber - cartGoods.getQty() >= 0) {
cartGoods.setAmount(goodsNowPrice * cartGoods.getQty());
......@@ -78,7 +78,7 @@ public class TimeSalePromotionService implements IPromotionService {
uid = goods.getCartGoodsUid();
}
}
numberMap.put(goods.getGoodsId(), specialActualGoodsNumber - cartGoods.getQty());
// numberMap.put(goods.getGoodsId(), specialActualGoodsNumber - cartGoods.getQty());
}
if (StringUtils.isNotBlank(toastMsg)) {
shoppingCartGoodsResponseVo.setToastMsg(toastMsg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment