Commit 71cbb5c8 by 胡敬轩

券码可用券列表查询->购物车->促销新算价 小料活动优惠

parent 68471529
......@@ -276,7 +276,7 @@ public class ActivityAdapter {
cartProduct.setRealAmount(discountGood.getRealAmount() + triple.getLeft());
cartProduct.setDiscountAmount(discountGood.getDiscountAmount()+triple.getMiddle() - mealDiscountAmount);
if(newCalculation){
buildGoodDiscount(cartProduct,discountGood.getDiscounts(),discountResult.getCouponSharedExclusive());
buildGoodDiscount(cartProduct,discountGood,discountResult.getCouponSharedExclusive());
}
goods.add(cartProduct);
}
......@@ -386,8 +386,8 @@ public class ActivityAdapter {
return Pair.of(realAmount,discountAmount);
}
private void buildGoodDiscount(CartProduct cartProduct, List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> discounts, Set<ActivityTypeSharedExclusive> couponSharedExclusive){
if(CollectionUtils.isEmpty(discounts)){
private void buildGoodDiscount(CartProduct cartProduct, ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods discountGood, Set<ActivityTypeSharedExclusive> couponSharedExclusive){
if(CollectionUtils.isEmpty(discountGood.getDiscounts())){
return;
}
HashMap<Integer,Integer> cashExclusiveMap = new HashMap<>();
......@@ -406,7 +406,7 @@ public class ActivityAdapter {
}
List<CartProduct.Discount> cartProductDiscountList = new ArrayList<>();
for(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount : discounts){
for(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount discount : discountGood.getDiscounts()){
if(Objects.equals(discount.getType(),ActivityTypeEnum.TYPE_310.getCode())){
continue;
}
......@@ -414,6 +414,10 @@ public class ActivityAdapter {
BeanUtils.copyProperties(discount,cartProductDiscount);
cartProductDiscount.setActualGoodsNumber(discount.getAddOnQuantity());
//小料或者可选搭配的优惠金额合并至主商品
long smallDiscountAmount = getSmallActivityDiscountAmount(discountGood.getSmallMaterial(),discount.getType());
cartProductDiscount.setDiscount(cartProductDiscount.getDiscount() + smallDiscountAmount);
//是否与代金券互斥
boolean cashExclusive = Objects.equals(cashExclusiveMap.get(discount.getType()),YesOrNoEnum.NO.getCode());
cartProductDiscount.setCashExclusive(cashExclusive);
......@@ -482,4 +486,20 @@ public class ActivityAdapter {
}
couponAvailableCartInfo.setDiscounts(cartDiscountList);
}
private Long getSmallActivityDiscountAmount(List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial> smallMaterial,Integer activityType){
long discountAmount = 0;
if(org.apache.commons.collections.CollectionUtils.isNotEmpty(smallMaterial)){
for(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial small :smallMaterial){
if(CollectionUtils.isNotEmpty(small.getDiscounts())){
for(ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount smallDiscount :small.getDiscounts()){
if(Objects.equals(smallDiscount.getType(),activityType)){
discountAmount += smallDiscount.getDiscount();
}
}
}
}
}
return discountAmount;
}
}
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