Commit 1bb6c28d by xiaoer.li@freemud.com

fix:库存校验空指针

parent cf1d3da2
......@@ -414,9 +414,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
requestDto.setProductIds(Collections.singletonList(Long.parseLong(cartGoods.getGoodsId())));
GetProductStockResponseDto availableStocks = stockClient.getAvailableStocks(requestDto);
if ((availableStocks != null) && (ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()))) {
if ((CollectionUtils.isEmpty(availableStocks.getResult())) || (qty > availableStocks.getResult().get(0).getQty())) {
if ((CollectionUtils.isEmpty(availableStocks.getResult())) || (availableStocks.getResult().get(0).getQty() != null &&
qty > availableStocks.getResult().get(0).getQty())) {
Integer stock = 0;
if ((stock = availableStocks.getResult().get(0).getQty()) > 0) {
if (availableStocks.getResult().get(0).getQty() != null && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
}
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
......@@ -1218,7 +1219,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
(CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null
|| availableStocks.getResult().get(0).getQty() < qty)) {
Integer stock = 0;
if ((stock = availableStocks.getResult().get(0).getQty()) > 0) {
if (availableStocks.getResult().get(0).getQty() != null && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
}
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
......
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