Commit 84454917 by chongfu.liang

Merge branch 'feature/2020218-购物车加料优惠券fix-lcf'

parents 70385e1a 8256e773
......@@ -332,6 +332,12 @@ public class CartGoods {
*/
private Long amount;
/**
* 当前选择的优惠券优惠
*
*/
private Integer currentCouponDiscount;
/**
* 购物车一行商品的数量
*/
private Integer qty;
......@@ -588,6 +594,13 @@ public class CartGoods {
private Long amount;
/**
* 当前选择的优惠券优惠
*
*/
private Integer currentCouponDiscount;
/**
* 麦咖啡入机键位
*/
private String customerCode;
......
......@@ -624,8 +624,16 @@ public class CouponServiceImpl implements CouponService {
// todo :小料价格累加到主商品上
if (CollectionUtils.isNotEmpty(cartGood.getProductMaterialList())) {
for (CartGoods.MaterialGoods materialGoods : cartGood.getProductMaterialList()) {
product.setAmount(product.getAmount() + materialGoods.getAmount().intValue());
totalAmount = totalAmount + materialGoods.getAmount();
Integer materialCurrentCouponDiscount = materialGoods.getCurrentCouponDiscount() != null ? materialGoods.getCurrentCouponDiscount() : 0;
product.setAmount(product.getAmount() + materialGoods.getAmount().intValue() + materialCurrentCouponDiscount);
totalAmount = totalAmount + materialGoods.getAmount() + materialCurrentCouponDiscount;
}
}
// 可选搭配优惠累加到主商品上
if (CollectionUtils.isNotEmpty(cartGood.getProductGroupList())) {
for (CartGoods.ComboxGoods comboxGoods : cartGood.getProductGroupList()) {
Integer comboxCurrentCouponDiscount = comboxGoods.getCurrentCouponDiscount() != null ? comboxGoods.getCurrentCouponDiscount() : 0;
totalAmount = totalAmount + comboxCurrentCouponDiscount;
}
}
// 数量
......
......@@ -140,6 +140,14 @@ public class CalculationCommonService {
}
else {
amount += mt.getRealAmount();
choice.setCurrentCouponDiscount(0);
if (CollectionUtils.isNotEmpty(mt.getDiscounts())){
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount goodsDiscount = mt.getDiscounts().stream()
.filter(p -> p.getActivityCode().equals(couponCode)).findFirst().orElse(null);
if (goodsDiscount != null){
choice.setCurrentCouponDiscount(goodsDiscount.getDiscount() == null ? 0 : goodsDiscount.getDiscount().intValue());
}
}
choice.setAmount(mt.getRealAmount().longValue());
}
originPrice += choice.getFinalPrice() * choice.getQty()*cartGoods.getQty();
......@@ -158,6 +166,14 @@ public class CalculationCommonService {
for (CartGoods.MaterialGoods mg : cartGoods.getProductMaterialList()) {
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial sm = sChoices.get(mg.getSpuId());
if (sm != null) {
mg.setCurrentCouponDiscount(0);
if (CollectionUtils.isNotEmpty(sm.getDiscounts())){
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount goodsDiscount = sm.getDiscounts().stream()
.filter(p -> p.getActivityCode().equals(couponCode)).findFirst().orElse(null);
if (goodsDiscount != null){
mg.setCurrentCouponDiscount(goodsDiscount.getDiscount() == null ? 0 : goodsDiscount.getDiscount().intValue());
}
}
mg.setAmount(sm.getRealAmount().longValue());
}
......
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