From 62e1912301297d25b0f0b2147cd9dc6ff62f64e0 Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Tue, 14 Apr 2026 11:47:38 +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 | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/plugin/webman/gateway/Events.php b/plugin/webman/gateway/Events.php index 1de80d0..a8d3d61 100644 --- a/plugin/webman/gateway/Events.php +++ b/plugin/webman/gateway/Events.php @@ -256,19 +256,23 @@ class Events ->fieldRaw('r.cons_info_id AS consId, SUM(r.surplus_stock * ' . $message['number'] . ') AS quantity, cons.stock_number AS current_quantity') ->group('r.cons_info_id') ->select()->toArray(); - if(!empty($tb_prod_cons[0]) && $tb_prod_cons[0]['quantity'] > $tb_prod_cons[0]['current_quantity']) { - $snd_data = [ - 'msg' => '此商品库存不足', - 'operate_type' => $message['operate_type'], - 'msg_id' => 'out_of_stock' . Random::build(), - 'type' => 'out_of_stock', - 'id' => !empty($message['id'])?$message['id']:'', - 'data_type' => 'cart', - 'status' => 0, - 'data' => [] - ]; - $gate_way::sendToClient($client_id, json_encode($snd_data)); - return; + if(!empty($tb_prod_cons)) { + foreach ($tb_prod_cons as $tb_prod_cons_k => $tb_prod_cons_v) { + if ($tb_prod_cons_v['quantity'] > $tb_prod_cons_v['current_quantity']) { + $snd_data = [ + 'msg' => '此商品库存不足', + 'operate_type' => $message['operate_type'], + 'msg_id' => 'out_of_stock' . Random::build(), + 'type' => 'out_of_stock', + 'id' => !empty($message['id'])?$message['id']:'', + 'data_type' => 'cart', + 'status' => 0, + 'data' => [] + ]; + $gate_way::sendToClient($client_id, json_encode($snd_data)); + return; + } + } } // $number = $message['number']; // try {