diff --git a/app/Service/v3/Implementations/ShopCartUpdateService.php b/app/Service/v3/Implementations/ShopCartUpdateService.php index 72fd76f..8b22179 100644 --- a/app/Service/v3/Implementations/ShopCartUpdateService.php +++ b/app/Service/v3/Implementations/ShopCartUpdateService.php @@ -69,7 +69,20 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface if($goodsCheck !== true) { - throw new ErrorCodeException($goodsCheck); + if($goodsCheck === ErrorCode::GOODS_ACTIVITY_INVENTORY_ERROR){ + $shopcartNum = ShoppingCart::query() + ->where([ + 'user_id' => $userId, + 'goods_id' => $goodsId, + 'activity_type' => $activityType + ]) + ->value('num'); + if($num > $shopcartNum){ + throw new ErrorCodeException($goodsCheck); + } + }else{ + throw new ErrorCodeException($goodsCheck); + } } $shoppingCart = ShoppingCart::query()->lockForUpdate()->updateOrCreate(