Commit 27096d6f by 徐康

Merge branch 'feature/xukang_20210609_麦咖啡p7v2' into qa

parents 2cf1f57e acdefcb2
......@@ -244,7 +244,7 @@ public class ShoppingCartMCoffeeServiceImpl {
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, oldCartGoodsList, null, tableNumber, this.shoppingCartBaseService);
newCartGoods = oldCartGoodsList;
} else if(StringUtils.equals("9998",skuId)){
Optional<CartGoods> cartGoods = oldCartGoodsList.stream().filter(o -> "9998".equals(skuId) && o.getIsB3S1Coupon() == 1).findFirst();
Optional<CartGoods> cartGoods = oldCartGoodsList.stream().filter(o -> "9998".equals(o.getSkuId()) && o.getIsB3S1Coupon() == 1).findFirst();
if(cartGoods.isPresent()) {
cartGoods.get().getB3S1CouponGoodsInfo().getCardCodeSet().add(addCartGoods.getCouponCode());
} else {
......
......@@ -224,13 +224,13 @@ public class CouponDiscountCalculation {
cartGoods.setQty(b3S1DiscountOptional.get().getActualGoodsNumber());
cartGoods.setCouponCode(b3S1DiscountOptional.get().getActivityCode());
cartGoods.setCouponName(b3S1DiscountOptional.get().getActivityName());
cartGoods.setAmount(goodsMap.get(cartGoods.getCartGoodsUid()).getRealAmount());
cartGoods.setIsB3S1CouponGoods(1);
cartGoodsNew.setCartGoodsUid(UUID.randomUUID().toString());
cartGoodsNew.setQty(newNum);
cartGoodsNew.setCouponCode(null);
cartGoodsNew.setCouponName(null);
cartGoodsNew.setAmount(cartGoods.getOriginalPrice() * cartGoods.getQty());
cartGoods.setAmount(goodsMap.get(cartGoods.getCartGoodsUid()).getRealAmount());
newCartGoodsList.add(cartGoodsNew);
} else if(cartGoods.getQty() == b3S1DiscountOptional.get().getActualGoodsNumber()) {
cartGoods.setCouponCode(b3S1DiscountOptional.get().getActivityCode());
......@@ -252,25 +252,6 @@ public class CouponDiscountCalculation {
}
if(haveB3S1Fav) {
// List<CartGoods> nowCartGoodsList = new ArrayList<>();
// AtomicBoolean changed = new AtomicBoolean();
// changed.set(false);
// if(CollectionUtils.isNotEmpty(cartGoodsList)){
// ApiLog.debug("合并买3赠1商品券 【merge-before】 : {} ", JSONObject.toJSONString(cartGoodsList));
// cartGoodsList.forEach(newCartGood -> {
// int index;
// if ((index = nowCartGoodsList.indexOf(newCartGood)) >= 0) {
// changed.set(true);
// nowCartGoodsList.get(index).setQty(nowCartGoodsList.get(index).getQty() + newCartGood.getQty());
// } else {
// nowCartGoodsList.add(newCartGood);
// }
// });
// }
// if(changed.get()) {
// cartGoodsList.clear();
// cartGoodsList.addAll(nowCartGoodsList);
// }
int index = 0;
for (int i = 0; i < cartGoodsList.size(); i++) {
......@@ -288,6 +269,30 @@ public class CouponDiscountCalculation {
index++;
}
}
List<CartGoods> nowCartGoodsList = new ArrayList<>();
nowCartGoodsList.addAll(cartGoodsList);
AtomicBoolean changed = new AtomicBoolean();
changed.set(false);
if(CollectionUtils.isNotEmpty(cartGoodsList)){
ApiLog.debug("合并买3赠1商品券 【merge-before】 : {} ", JSONObject.toJSONString(nowCartGoodsList));
for (int i = cartGoodsList.size() - 1; i >= 1; i--) {
CartGoods cartGoods = cartGoodsList.get(i);
int index2 = nowCartGoodsList.indexOf(cartGoods);
if(index2 < i) {
changed.set(true);
nowCartGoodsList.get(index2).setQty(nowCartGoodsList.get(index2).getQty() + cartGoods.getQty());
nowCartGoodsList.remove(i);
}
ApiLog.debug("合并买3赠1商品券 【merge-ing】 : {} ", JSONObject.toJSONString(nowCartGoodsList));
}
ApiLog.debug("合并买3赠1商品券 【merge-after】 : {} ", JSONObject.toJSONString(nowCartGoodsList));
}
if(changed.get()) {
cartGoodsList.clear();
cartGoodsList.addAll(nowCartGoodsList);
}
}
// 当couponCode不为空时,需计算优惠价格
......
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