From bc33820d47a97bec7207fbf686ba8967797d5004 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Fri, 18 Sep 2020 14:55:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/ShopCartUpdateService.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Service/v3/Implementations/ShopCartUpdateService.php b/app/Service/v3/Implementations/ShopCartUpdateService.php index 8ec7769..3a40bde 100644 --- a/app/Service/v3/Implementations/ShopCartUpdateService.php +++ b/app/Service/v3/Implementations/ShopCartUpdateService.php @@ -11,6 +11,7 @@ use App\Model\v3\ShoppingCart; use App\Model\v3\Goods; use App\Model\v3\GoodsActivity; use App\Constants\v3\Goods as GoodsConstants; +use App\Service\v3\Interfaces\StoreServiceInterface; use Hyperf\Di\Annotation\Inject; class ShopCartUpdateService implements ShopCartUpdateServiceInterface { @@ -26,6 +27,12 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface */ protected $goodsActivityService; + /** + * @Inject + * @var StoreServiceInterface + */ + protected $storeService; + public function do($userId,$goodsId,$num,$activityType) { $goodsType = ''; @@ -56,7 +63,7 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface throw new ErrorCodeException($goodsCheck); } - return ShoppingCart::query()->lockForUpdate()->updateOrCreate( + $shoppingCart = ShoppingCart::query()->lockForUpdate()->updateOrCreate( [ 'user_id' => $userId, 'goods_id' => $goodsId, @@ -69,6 +76,9 @@ class ShopCartUpdateService implements ShopCartUpdateServiceInterface 'goods_type' => $goodsType ] ); + $storeCheck = $this->storeService->check($goods->store_id); + $shoppingCart->check = $storeCheck; + return $shoppingCart; } public function check() From 8815e419b2aa306840e7ee71f503df1ac9c9539b Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Fri, 18 Sep 2020 15:08:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=95=86=E5=93=81=E5=94=AE=E5=85=89=20?= =?UTF-8?q?=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Constants/v3/ErrorCode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Constants/v3/ErrorCode.php b/app/Constants/v3/ErrorCode.php index b3aa83c..2a6f7c6 100644 --- a/app/Constants/v3/ErrorCode.php +++ b/app/Constants/v3/ErrorCode.php @@ -233,8 +233,8 @@ class ErrorCode extends AbstractConstants /* 商品相关 1101-1150 */ /************************************/ /** - * 已卖光 - * @Message("有商品已卖光") + * 库存不足 + * @Message("库存不足") */ const GOODS_INVENTORY_ERROR = 1101;