获取两次商品库存代码优化

This commit is contained in:
Chopper 2021-12-06 15:59:13 +08:00
parent f24019d306
commit d16cf44f4a

View File

@ -396,11 +396,8 @@ public class CartServiceImpl implements CartService {
private void checkSetGoodsQuantity(CartSkuVO cartSkuVO, String skuId, Integer num) {
Integer enableStock = goodsSkuService.getStock(skuId);
//读取sku的可用库存
Integer enableQuantity = goodsSkuService.getStock(skuId);
//如果sku的可用库存小于等于0或者小于用户购买的数量则不允许购买
if (enableQuantity <= 0 || enableQuantity < num) {
if (enableStock <= 0 || enableStock < num) {
throw new ServiceException(ResultCode.GOODS_SKU_QUANTITY_NOT_ENOUGH);
}