From c44cc532c921a340d19179fc69259d59423c7552 Mon Sep 17 00:00:00 2001
From: 李忠强 <1354905998@qq.com>
Date: Sat, 22 Jan 2022 09:22:27 +0800
Subject: [PATCH] 更新

---
 application/api/controller/Buy.php  | 2 ++
 application/api/controller/Cart.php | 2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

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');
     }
--
libgit2 0.24.0