From ca37b092c2cb68d2f36c0133648ba1daef1a19cf Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Tue, 14 Apr 2026 15:39:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=81=E5=BA=93=E5=AD=98=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/webman/gateway/Events.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugin/webman/gateway/Events.php b/plugin/webman/gateway/Events.php index 29b194f..3f43f2f 100644 --- a/plugin/webman/gateway/Events.php +++ b/plugin/webman/gateway/Events.php @@ -258,6 +258,23 @@ class Events ->order('cons.stock_number', 'asc') ->select()->toArray(); if(!empty($tb_prod_cons[0])) { + // 如果是编辑,拿到已有数量 + if($message['operate_type'] == 'edit' && !empty($message['id'])) { + $data = Db::query(" + SELECT * FROM `tb_cashier_cart` WHERE + `id`={$message['id']}"); + + if($data) { + // 如果编辑数量 小于已有数量并且大于库存数量 直接改成库存数量 + if($tb_prod_cons[0]['current_quantity'] < $data[0]['number']) { + $message['number'] = $tb_prod_cons[0]['current_quantity']; + } + if($tb_prod_cons[0]['current_quantity'] <= 0) { + $message['number'] = 0; + } + } + } + if ($tb_prod_cons[0]['quantity'] > $tb_prod_cons[0]['current_quantity']) { $snd_data = [ 'msg' => '此商品库存不足',