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' => '此商品库存不足',