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; 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()