Commit 674b5d46 by chongfu.liang

fix

parent a05eb89c
...@@ -143,17 +143,15 @@ public class GiftSharingService { ...@@ -143,17 +143,15 @@ public class GiftSharingService {
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods oldSendGoods = goodsList.stream().filter(p -> p.getGoodsId().equals(discount.getGoodsId()) && ObjectUtils.equals(p.getCartGoodType(), 1)).findFirst().orElse(null); CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods oldSendGoods = goodsList.stream().filter(p -> p.getGoodsId().equals(discount.getGoodsId()) && ObjectUtils.equals(p.getCartGoodType(), 1)).findFirst().orElse(null);
if (oldSendGoods != null){ // 表明赠品原来有 if (oldSendGoods != null){ // 表明赠品原来有
Integer goodsQuantity = oldSendGoods.getGoodsQuantity(); Integer goodsQuantity = oldSendGoods.getGoodsQuantity();
sendQty = goodsQuantity + discount.getActualGoodsNumber(); Integer send = goodsQuantity + discount.getActualGoodsNumber();
oldSendGoods.setGoodsQuantity(sendQty); oldSendGoods.setGoodsQuantity(send);
Long discountAmount = oldSendGoods.getDiscountAmount(); Long discountAmount = oldSendGoods.getDiscountAmount();
discountAmount = discountAmount + discount.getDiscount(); discountAmount = discountAmount + discount.getDiscount();
oldSendGoods.setDiscountAmount(discountAmount); oldSendGoods.setDiscountAmount(discountAmount);
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount oldDiscount = oldSendGoods.getDiscounts().stream().filter(p -> p.getActivityCode().equals(discount.getActivityCode()) && ObjectUtils.equals(p.getType(), ActivityTypeEnum.TYPE_1040.getCode())).findFirst().orElse(null); CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount oldDiscount = oldSendGoods.getDiscounts().stream().filter(p -> p.getActivityCode().equals(discount.getActivityCode()) && ObjectUtils.equals(p.getType(), ActivityTypeEnum.TYPE_1040.getCode())).findFirst().orElse(null);
if (oldDiscount != null){ if (oldDiscount != null){
oldDiscount.setActualGoodsNumber(sendQty); oldDiscount.setActualGoodsNumber(send);
oldDiscount.setDiscount(discountAmount); oldDiscount.setDiscount(discountAmount);
} }
...@@ -181,14 +179,18 @@ public class GiftSharingService { ...@@ -181,14 +179,18 @@ public class GiftSharingService {
goodsDiscounts.add(goodsDiscount); goodsDiscounts.add(goodsDiscount);
sendGoods.setDiscounts(goodsDiscounts); sendGoods.setDiscounts(goodsDiscounts);
goodsList.add(sendGoods); goodsList.add(sendGoods);
sendQty += discount.getActualGoodsNumber();
} }
sendQty += discount.getActualGoodsNumber();
if (goods.getDiscountAmount() != null && discount.getDiscount() != null){ if (goods.getDiscountAmount() != null && discount.getDiscount() != null){
goods.setDiscountAmount(goods.getDiscountAmount() - discount.getDiscount()); goods.setDiscountAmount(goods.getDiscountAmount() - discount.getDiscount());
} }
} }
qtyMap.put(goods.getCartGoodsUid(), goods.getGoodsQuantity() - sendQty); if (qtyMap.get(goods.getCartGoodsUid()) != null){
qtyMap.put(goods.getCartGoodsUid(), qtyMap.get(goods.getCartGoodsUid()) - sendQty);
} else {
qtyMap.put(goods.getCartGoodsUid(), goods.getGoodsQuantity() - sendQty);
}
} }
result.setGoods(goodsList); result.setGoods(goodsList);
return qtyMap; return qtyMap;
......
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