Commit 0f13bc7c by 刘鹏飞

Merge remote-tracking branch 'remotes/origin/feature/coco-payGift-刘鹏飞' into qa

parents a25c77a1 cfce4c7e
...@@ -25,6 +25,7 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -25,6 +25,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service("cocoShoppingCartRelationService") @Service("cocoShoppingCartRelationService")
public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelationService { public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelationService {
...@@ -53,6 +54,16 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -53,6 +54,16 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
shoppingCartGoodsResponseVo.setDiscounts(discounts); shoppingCartGoodsResponseVo.setDiscounts(discounts);
shoppingCartGoodsResponseVo.setGoods(discountResult.getGoods()); shoppingCartGoodsResponseVo.setGoods(discountResult.getGoods());
List<CartGoods> products = shoppingCartGoodsResponseVo.getProducts();
List<String> gifeProductIds = new ArrayList<>();
if(products != null && !products.isEmpty()){
// 获取赠品的商品id
gifeProductIds = products.stream().filter(product -> Objects.equals(product.getActivityType(),ActivityTypeEnum.TYPE_63)).map(CartGoods::getGoodsId).collect(Collectors.toList());
}
// 第二件优惠活动,在点餐页需要给优惠商品单独显示一行 // 第二件优惠活动,在点餐页需要给优惠商品单独显示一行
// 第二件优惠活动Map // 第二件优惠活动Map
Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> goodsDiscountsMap = new HashMap<>(); Map<String,CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods.GoodsDiscount> goodsDiscountsMap = new HashMap<>();
...@@ -76,14 +87,16 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -76,14 +87,16 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
}); });
List<CartGoods> newProducts = new ArrayList<>(); List<CartGoods> newProducts = new ArrayList<>();
List<CartGoods> products = shoppingCartGoodsResponseVo.getProducts();
if(!Objects.equals(flag,1)){// 非结算页 if(!Objects.equals(flag,1)){// 非结算页
if(products == null || products.isEmpty()){ if(products == null || products.isEmpty()){
return; return;
} }
List<CartGoods> halfProduct = new ArrayList<>(); List<CartGoods> halfProduct = new ArrayList<>();
products.forEach(product -> {
for(int x = 0 ; x < products.size() ; x ++){
CartGoods product = products.get(x);
// 要添加的半价行数量,该字段从促销返回 // 要添加的半价行数量,该字段从促销返回
Integer num = 0; Integer num = 0;
// 商品优惠的金额 // 商品优惠的金额
...@@ -109,16 +122,15 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -109,16 +122,15 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
product.setAmount(product.getAmount() - discountAmount * num); product.setAmount(product.getAmount() - discountAmount * num);
product.setOriginalAmount(product.getOriginalAmount() - product.getOriginalPrice() * num); product.setOriginalAmount(product.getOriginalAmount() - product.getOriginalPrice() * num);
product.setQty(newQty); product.setQty(newQty);
// num不为0,全价行的活动类型就要设置成null
// 前端用这个字段控制能否加减 if(gifeProductIds.contains(product.getGoodsId())){
if(!Objects.equals(num,0)){ product.setGoodsId(null);
product.setActivityType(null);
} }
newProducts.add(product); newProducts.add(product);
} }
newProducts.addAll(halfProduct); newProducts.addAll(halfProduct);
}
});
shoppingCartGoodsResponseVo.setProducts(newProducts); shoppingCartGoodsResponseVo.setProducts(newProducts);
} }
...@@ -134,6 +146,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -134,6 +146,7 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
// 这个地方不要放置商品id,因为半价行的商品不打活动标签 // 这个地方不要放置商品id,因为半价行的商品不打活动标签
// 前端会根据这个活动检索 // 前端会根据这个活动检索
newCartGoods.setGoodsType(cgs.getGoodsType()); newCartGoods.setGoodsType(cgs.getGoodsType());
newCartGoods.setGoodsId(cgs.getGoodsId());
newCartGoods.setSpuId(cgs.getSpuId()); newCartGoods.setSpuId(cgs.getSpuId());
newCartGoods.setSkuId(cgs.getSkuId()); newCartGoods.setSkuId(cgs.getSkuId());
newCartGoods.setSpecProductId(cgs.getSpecProductId()); newCartGoods.setSpecProductId(cgs.getSpecProductId());
...@@ -169,7 +182,9 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation ...@@ -169,7 +182,9 @@ public class CocoShoppingCartRelationServiceImpl implements ShoppingCartRelation
newCartGoods.setSkuName(cgs.getSkuName()); newCartGoods.setSkuName(cgs.getSkuName());
newCartGoods.setClassificationId(cgs.getClassificationId()); newCartGoods.setClassificationId(cgs.getClassificationId());
newCartGoods.setClassificationName(cgs.getClassificationName()); newCartGoods.setClassificationName(cgs.getClassificationName());
newCartGoods.setActivityType(activityType); // 所以这个字段设置为空
// 前端用这个字段控制能否加减
newCartGoods.setActivityType(null);
newCartGoods.setQty(qty); newCartGoods.setQty(qty);
return newCartGoods; return newCartGoods;
......
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