Commit 187fe81c by 周晓航

新增 库存校验

parent cf3b439d
...@@ -3204,13 +3204,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3204,13 +3204,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//校验库存 //校验库存
List<CartGoods> stockLimitGoods = allCartGoodsList.stream().filter(CartGoods::isStockLimit).collect(toList()); List<CartGoods> stockLimitGoods = allCartGoodsList.stream().filter(CartGoods::isStockLimit).collect(toList());
List<CartGoods> notCheckStock = allCartGoodsList.stream().filter(cartGoods -> !cartGoods.isStockLimit()).collect(toList());
if (!CollectionUtils.isEmpty(stockLimitGoods)) { if (!CollectionUtils.isEmpty(stockLimitGoods)) {
List<Long> spuIds = stockLimitGoods.stream().map(v -> Long.parseLong(v.getSpuId())).collect(toList()); List<Long> goodsId = stockLimitGoods.stream().map(v -> Long.parseLong(v.getGoodsId())).collect(toList());
GetProductStockRequestDto requestDto = new GetProductStockRequestDto(); GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(replaceGoodsRequestVo.getMenuType()).getCode()); requestDto.setChannel(BusinessTypeEnum.getByType(replaceGoodsRequestVo.getMenuType()).getCode());
requestDto.setPartnerId(replaceGoodsRequestVo.getPartnerId()); requestDto.setPartnerId(replaceGoodsRequestVo.getPartnerId());
requestDto.setStoreId(replaceGoodsRequestVo.getShopId()); requestDto.setStoreId(replaceGoodsRequestVo.getShopId());
requestDto.setProductIds(spuIds); requestDto.setProductIds(goodsId);
GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto); GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
if (availableStocks != null ) { if (availableStocks != null ) {
if (!ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())){ if (!ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())){
...@@ -3237,18 +3238,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3237,18 +3238,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}); });
}); });
// 获取到最新的 库存 stockLimitGoods 数据 放入 nowCartGoodsList 中 // 获取到最新的 库存 stockLimitGoods 数据 放入 nowCartGoodsList 中
List<CartGoods> notCheckStock = allCartGoodsList.stream().filter(cartGoods -> !cartGoods.isStockLimit()).collect(toList());
notCheckStock.addAll(stockLimitGoods); notCheckStock.addAll(stockLimitGoods);
allCartGoodsList = notCheckStock;
notCheckStock = null;
stockLimitGoods = null;
}else { }else {
LogUtil.info("request check stock limit fail",requestDto,null); LogUtil.info("request check stock limit fail",requestDto,null);
fullReplace = false; fullReplace = false;
return fullReplace;
} }
} }
allCartGoodsList = notCheckStock;
// fisherman 删除 新门店的缓存数据 重新添加 测试 之后需要放开 // fisherman 删除 新门店的缓存数据 重新添加 测试 之后需要放开
shoppingCartNewBaseService.clear(replaceGoodsRequestVo.getPartnerId(), replaceGoodsRequestVo.getShopId(), userId); shoppingCartNewBaseService.clear(replaceGoodsRequestVo.getPartnerId(), replaceGoodsRequestVo.getShopId(), userId);
......
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