Commit 8d9cac8b by 查志伟

购物车新算价赠品显示bug修复

parent 248b3b66
...@@ -28,7 +28,6 @@ import java.util.ArrayList; ...@@ -28,7 +28,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -93,15 +92,6 @@ public class GiftSharingService { ...@@ -93,15 +92,6 @@ public class GiftSharingService {
return gifts; return gifts;
} }
public Map<String, Goods> getDiscountForGift(CalculationDiscountResult discountResult) {
Map<String, Goods> gifts = discountResult.getGoods()
.stream()
.filter(d -> CalculationGoodsType.TYPE_1.getType().equals(d.getCartGoodType()))
.collect(Collectors.toMap(Goods::getGoodsId, Function.identity(), (k1, k2) -> k1));
return gifts;
}
/** /**
* 赠品detail * 赠品detail
* *
...@@ -179,12 +169,13 @@ public class GiftSharingService { ...@@ -179,12 +169,13 @@ public class GiftSharingService {
, UserLoginInfoDto userLoginInfoDto) { , UserLoginInfoDto userLoginInfoDto) {
if (CollectionUtils.isNotEmpty(products)) { if (CollectionUtils.isNotEmpty(products)) {
Map<String, ProductBean> productMap = products.stream().collect(Collectors.toMap(ProductBean::getPid, k -> k, (k1, k2) -> k1));
List<CartGoods> list = new ArrayList<>(); List<CartGoods> list = new ArrayList<>();
Map<String, Goods> discountForGift = this.getDiscountForGift(discountResult); for (Goods goods : discountResult.getGoods()) {
for (ProductBean product : products) { // 过滤掉非赠品的商品
Goods goods = discountForGift.get(product.getPid()); if (! CalculationGoodsType.TYPE_1.getType().equals(goods.getCartGoodType())) continue;
ProductBean product = productMap.get(goods.getGoodsId());
GoodsDiscount discount = this.discountInfo(goods); GoodsDiscount discount = this.discountInfo(goods);
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = new ShoppingCartGoodsDto.CartGoodsDetailDto();
CartGoods cartGood = new CartGoods(); CartGoods cartGood = new CartGoods();
cartGood.setGoodsId(goods.getGoodsId()); cartGood.setGoodsId(goods.getGoodsId());
cartGood.setGoodsType(1); cartGood.setGoodsType(1);
...@@ -210,16 +201,17 @@ public class GiftSharingService { ...@@ -210,16 +201,17 @@ public class GiftSharingService {
cartGood.setClassificationName(product.getCategoryName()); cartGood.setClassificationName(product.getCategoryName());
// nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额 // nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额
cartGood.setNodeId(discount.getActivityCode()); cartGood.setNodeId(discount.getActivityCode());
list.addAll(buyAndGiftsPromotionService.setGiftExtra(cartGood, product, null)); // 将有属性的赠品拆分为多行,每行一个,以支持每个赠品可以选择独立的属性
List<CartGoods> nl = buyAndGiftsPromotionService.setGiftExtra(cartGood, product, null);
nl.forEach(c -> {
// 构建优惠
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = calculationCommonService.convertCartGoods2DetailGoodsList(goods, c, activityQueryDto.getPartnerId());
cartGoodsDetailDtoList.add(cartGoodsDetailDto);
});
list.addAll(nl);
} }
// 因为有涉及到用户选择的属性,存入redis // 因为有涉及到用户选择的属性,存入redis
list = giftCacheManager.resetGiftCache(list, null, activityQueryDto.getPartnerId(), activityQueryDto.getStoreId(), userLoginInfoDto.getMemberId()); giftCacheManager.resetGiftCache(list, null, activityQueryDto.getPartnerId(), activityQueryDto.getStoreId(), userLoginInfoDto.getMemberId());
List<ShoppingCartGoodsDto.CartGoodsDetailDto> detail = new ArrayList<>();
list.forEach(c -> {
Goods goods = discountForGift.get(c.getGoodsId());
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = calculationCommonService.convertCartGoods2DetailGoodsList(goods, c, activityQueryDto.getPartnerId());
cartGoodsDetailDtoList.add(cartGoodsDetailDto);
});
} }
} }
......
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