diff --git a/application/api/controller/Buy.php b/application/api/controller/Buy.php index 77d3179..ee758b7 100644 --- a/application/api/controller/Buy.php +++ b/application/api/controller/Buy.php @@ -127,6 +127,8 @@ class Buy extends Api if (!is_numeric($id) || !is_numeric($number)) $this->error('参数不合法'); $model = new \app\api\model\UserBuylist(); + $order = $model->with('sku')->where('id',$id)->find(); + if ($number+$order['number'] > $order['stock_num']) $this->error('已达到最大库存,请勿重复提交'); $model->where('id',$id)->setInc('number',$number); $this->success('SUCCESS'); } diff --git a/application/api/controller/Cart.php b/application/api/controller/Cart.php index d3b5676..0850930 100644 --- a/application/api/controller/Cart.php +++ b/application/api/controller/Cart.php @@ -96,6 +96,8 @@ class Cart extends Api if (!is_numeric($id) || !is_numeric($number)) $this->error('参数不合法'); $model = new \app\api\model\Cart(); + $order = $model->with('sku')->where('id',$id)->find(); + if ($number+$order['number'] > $order['stock_num']) $this->error('已达到最大库存,请勿重复提交'); $model->where('id',$id)->setInc('number',$number); $this->success('SUCCESS'); }