Commit 39c32f72 by 查志伟

bug fix 赠品下单属性不匹配问题

parent 12342346
......@@ -24,10 +24,7 @@ import org.apache.commons.lang.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -171,6 +168,7 @@ public class GiftSharingService {
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<>();
Map<String, Goods> map = new HashMap<>();
for (Goods goods : discountResult.getGoods()) {
// 过滤掉非赠品的商品
if (! CalculationGoodsType.TYPE_1.getType().equals(goods.getCartGoodType())) continue;
......@@ -203,16 +201,17 @@ public class GiftSharingService {
// nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额
cartGood.setNodeId(discount.getActivityCode());
// 将有属性的赠品拆分为多行,每行一个,以支持每个赠品可以选择独立的属性
List<CartGoods> nl = buyAndGiftsPromotionService.setGiftExtra(cartGood, product, null);
nl.forEach(c -> {
list.addAll(buyAndGiftsPromotionService.setGiftExtra(cartGood, product, null));
map.put(cartGood.getGoodsId(), goods);
}
// 因为有涉及到用户选择的属性,存入redis
list = giftCacheManager.resetGiftCache(list, null, activityQueryDto.getPartnerId(), activityQueryDto.getStoreId(), userLoginInfoDto.getMemberId());
list.forEach(c -> {
Goods goods = map.get(c.getGoodsId());
// 构建优惠
ShoppingCartGoodsDto.CartGoodsDetailDto cartGoodsDetailDto = calculationCommonService.convertCartGoods2DetailGoodsList(goods, c, activityQueryDto.getPartnerId());
cartGoodsDetailDtoList.add(cartGoodsDetailDto);
});
list.addAll(nl);
}
// 因为有涉及到用户选择的属性,存入redis
giftCacheManager.resetGiftCache(list, null, activityQueryDto.getPartnerId(), activityQueryDto.getStoreId(), userLoginInfoDto.getMemberId());
}
}
......
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