Commit a1360bfa by chongfu.liang

fix

parent 3ceb10e6
......@@ -79,6 +79,7 @@ public class CalculationSharingDiscountService {
HashMap<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16);
List<CalculationSharingDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
int cartSize = cartGoodsList.size() - 1;
HashMap<String, List<String>> spqIdToCartUuid = new HashMap<>(16);
for (int i = cartSize; i >= 0; i--) {
CartGoods cartGoods = cartGoodsList.get(i);
if (!cartGoods.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX)) {//非商品券
......@@ -100,6 +101,15 @@ public class CalculationSharingDiscountService {
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService);
//跑业务异常 商品券不存
} else {
if (spqIdToCartUuid.containsKey(spqId)){
List<String> uuidList = spqIdToCartUuid.get(spqId);
uuidList.add(cartGoods.getCartGoodsUid());
spqIdToCartUuid.put(spqId, uuidList);
} else {
List<String> uuidList = new ArrayList<>();
uuidList.add(cartGoods.getCartGoodsUid());
spqIdToCartUuid.put(spqId, uuidList);
}
validCouponMap.put(spqId, checkSpqInfo);
cartGoods.setName(checkSpqInfo.getCouponName());
cartGoods.setSpuName(checkSpqInfo.getCouponName());
......@@ -185,12 +195,16 @@ public class CalculationSharingDiscountService {
if (sharingDiscountResponseDto != null && StringUtils.equals(sharingDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) {
CalculationSharingDiscountResponseDto.CalculationDiscountResult result = sharingDiscountResponseDto.getResult();
if (validCouponMap != null){
List<String> activityCodeList = result.getDiscounts().stream().map(p -> p.getActivityCode()).collect(Collectors.toList());
for (String spqId : validCouponMap.keySet()) {
if (!activityCodeList.contains(spqId)){ // 表示商品券不够启用金额
List<String> uuidList = spqIdToCartUuid.get(spqId);
if (CollectionUtils.isNotEmpty(uuidList)){
List<CartGoods> newCartList = cartGoodsList.stream().filter(p -> !uuidList.contains(p.getCartGoodsUid())).collect(Collectors.toList());
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, newCartList, null, null, this.shoppingCartBaseService);
throw new BizServiceException(ResponseResult.COCO_COUPON_VALIDATOR_FAIL,sharingDiscountResponseDto.getMsg());
}
}
}
}
......
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