Commit 32b33b9f by 刘鹏飞

coco结算页商品现单价添加小料的计算

parent 0270a33f
......@@ -99,7 +99,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
// 非结算页
orderingFoodPage(products,halfDiscountsMap,goodsDiscountsMap,gifeProductIds,shoppingCartGoodsResponseVo);
}else {// 结算页
settlementPage(products,halfDiscountsMap,goodsDiscountsMap,shoppingCartGoodsResponseVo);
settlementPage(products,halfDiscountsMap,goodsDiscountsMap,shoppingCartGoodsResponseVo,gifeProductIds);
}
}
......@@ -202,7 +202,8 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
public void settlementPage(List<CartGoods> products,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> halfDiscountsMap,
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods> goodsDiscountsMap,
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo,
List<String> gifeProductIds){
// 第二件优惠活动(单品优惠)要把一行商品分成多行,且每行商品数量是1,同时要有两行是打活动标的
List<CartGoods> newProducts = new ArrayList<>();
......@@ -212,6 +213,28 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
for(int x = 0 ; x < products.size() ; x ++){
CartGoods product = products.get(x);
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial> smallMaterial = goodsDiscountsMap.get(product.getCartGoodsUid()).getSmallMaterial();
Integer smallMaterialOriTotal = 0;
Long halfSmallMaterialOriTotal = 0L;
if(smallMaterial != null && !smallMaterial.isEmpty()){
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial sm : smallMaterial){
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> smDiscounts = sm.getDiscounts();
if(smDiscounts != null && !smDiscounts.isEmpty()){
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount smDiscount : smDiscounts){
if(ObjectUtils.equals(smDiscount.getType(),ActivityTypeEnum.TYPE_53.getCode())){
halfSmallMaterialOriTotal = halfSmallMaterialOriTotal + smDiscount.getSignleDiscount();
}
}
}
smallMaterialOriTotal = smallMaterialOriTotal + sm.getOriginalPrice();
}
}
// 商品的单价 = 商品单价+小料单价
Long originalPrice = (new Long(smallMaterialOriTotal) + product.getOriginalPrice());
// 这一行的商品参加了第二件优惠活动(单品优惠)
if( halfDiscountsMap.get(product.getCartGoodsUid() + "-" + product.getGoodsId()) != null){
// 行商品数量
......@@ -231,26 +254,21 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
continue;
}
// 限时特检的现单价获取促销的现单价
// 商品是否参加特价
// 限时立减的现单价获取促销的现单价
// 商品是否参加单品立减
boolean cutFlag = hashCutActive(goodsDiscountsMap,product);
if(cutFlag){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
}
// 小料信息
if(goodsDiscountsMap.get(product.getCartGoodsUid()) == null){
continue;
}
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial> smallMaterial = goodsDiscountsMap.get(product.getCartGoodsUid()).getSmallMaterial();
Integer smallMaterialOriTotal = 0;
for(CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.SmallMaterial sm : smallMaterial){
smallMaterialOriTotal = smallMaterialOriTotal + sm.getOriginalPrice();
}
// 如果是赠品行,这行的价格就不用算了
if(!gifeProductIds.contains(product.getGoodsId()) && product.getActivityType() == null){
// 商品的单价 = 商品单价+小料单价
product.setOriginalPrice(new Long(smallMaterialOriTotal) + product.getOriginalPrice());
product.setFinalPrice(new Long(smallMaterialOriTotal) + product.getFinalPrice());
product.setOriginalPrice(originalPrice);
// 商品现单价 = 商品现单价+小料现单价
smallMaterialOriTotal = smallMaterialOriTotal == null ? 0 : smallMaterialOriTotal;
product.setFinalPrice(new Long(smallMaterialOriTotal) + (product.getFinalPrice() == null ? 0L : product.getFinalPrice()));
}
newProducts.add(product);
}
......@@ -335,7 +353,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
product.setQty(newQty);
// 商品是否参加特价
// 商品是否参加立减
boolean cutFlag = hashCutActive(goodsDiscountsMap,product);
if(cutFlag){
product.setFinalPrice(goodsDiscountsMap.get(product.getCartGoodsUid()).getNowPrice());
......@@ -377,7 +395,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
}
/**
* 判断商品是否参加了限时特价
* 判断商品是否参加了立减
* @param goodsDiscountsMap
* @param product
* @return
......
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