Commit 9c1fb75a by 周晓航

商品库存服务查询失败, 或者 数量为null 不校验库存

Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent 532fe245
......@@ -2368,11 +2368,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
requestDto.setStoreId(addShoppingCartGoodsRequestVo.getShopId());
requestDto.setProductIds(productIds);
GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
if (availableStocks == null || !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
// 商品服务 返回null 或者 qty=null 表示不限制库存
if (Objects.isNull(availableStocks) || Objects.isNull(availableStocks.getResult().get(0).getQty())) {
return;
}
if (!ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
}
int stock = CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null ? 0 :
availableStocks.getResult().get(0).getQty();
int stock = availableStocks.getResult().get(0).getQty();
if (stock <= 0) {
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
} else if (stock < qty) {
......
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