From f5dc2f73317222f0bd54ef9eb4db8cd1f114cede Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 11 Jun 2024 16:55:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/controller/cart/CartController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/store/controller/cart/CartController.php b/app/store/controller/cart/CartController.php index 2392beac7..6f3e640d8 100644 --- a/app/store/controller/cart/CartController.php +++ b/app/store/controller/cart/CartController.php @@ -4,6 +4,7 @@ namespace app\store\controller\cart; use app\api\logic\order\CartLogic; use app\api\validate\CartValidate; +use app\common\model\store_branch_product\StoreBranchProduct; use app\store\lists\cart\CartList; use app\common\model\order\Cart; use app\store\controller\BaseAdminController; @@ -32,6 +33,14 @@ class CartController extends BaseAdminController if ($count > 100) { return $this->fail('购物车商品不能大于100个,请先结算'); } + //数量下单判断 + $stock = StoreBranchProduct::where( + ['product_id'=>$params['product_id'], + 'store_id'=>$params['store_id'] + ])->value('stock')??0; + if ($params['cart_num'] >$stock) { + return $this->fail('库存数量不足'); + } if ($result) { $res = CartLogic::edit($params); } else {