From 3602e0a4b7d6d4149a3495e46878ca0e0a280ce4 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Mon, 9 Nov 2020 16:54:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=B8=8D=E8=B6=B3=E6=97=B6?= =?UTF-8?q?=20=E5=85=81=E8=AE=B8=E5=87=8F=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/ShopCartUpdateService.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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(