From 5215424c07484838ea313907d8a93caa9926b10e Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Tue, 21 Apr 2026 17:10:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B6=E4=BB=96=E8=AE=A2=E5=8D=95=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/rabborderprint.php | 107 ++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/scripts/rabborderprint.php b/scripts/rabborderprint.php index d237ad0..b3dbeae 100644 --- a/scripts/rabborderprint.php +++ b/scripts/rabborderprint.php @@ -42,61 +42,60 @@ try { $data = $msg->body; Log::info('MQ收到消息[订单打印]--->' . $data . '--->' . $date_time . "\n"); $order = json_decode($data, true); - if(!is_array($order)) { - return; - } - // 如果是数字。则打印订单 - $is_log = false; - $curl_error = ''; -// $order_id_t = strpos($data, '_'); -// if($order_id_t !== false) { -// $order_id = substr($data, 0, $order_id_t); -// }else { -// $order_id = $data; -// } -// $order = Db::table('tb_order_info')->where(['id' => $order_id])->find(); -// if($order) { - $rand = 'cashier_order' . Random::build(); - $send_id = 'cashier_'. $order['shopId']; - // 收银机打印订单 - $snd_data = [ - 'msg' => '收银机订单打印', - 'type' => 'cashier', - 'operate_type' => 'order_print', - 'data_type' => 'order', - 'status' => 1, - 'method' => 'sendToUid', - 'send_num' => 0, - 'send_id' => $send_id, - 'msg_id' => $rand, - 'data' => $data - ]; - $snd_data_json = json_encode($snd_data); - Gateway::$registerAddress = '127.0.0.1:1238'; - $res = Gateway::sendToUid($send_id, $snd_data_json); - Log::info('订单打印推送结果-->' . $res); - $result = Redis::get($snd_data['send_id']); - if($result) { - $msg_id_arr = json_decode($result, true); - $msg_id_arr_c = count($msg_id_arr); - $msg_id_arr[$msg_id_arr_c] = $snd_data; - $result_n = json_encode($msg_id_arr); - Base::setredis_new($result_n, $snd_data['send_id']); - }else { - $params_arr_n[] = $snd_data; -// print_r('数组-------->' . json_encode($params_arr_n)) . "\r\n"; - Base::setredis_new(json_encode($params_arr_n), $snd_data['send_id']); + if(is_array($order)) { + // 如果是数字。则打印订单 + $is_log = false; + $curl_error = ''; + // $order_id_t = strpos($data, '_'); + // if($order_id_t !== false) { + // $order_id = substr($data, 0, $order_id_t); + // }else { + // $order_id = $data; + // } + // $order = Db::table('tb_order_info')->where(['id' => $order_id])->find(); + // if($order) { + $rand = 'cashier_order' . Random::build(); + $send_id = 'cashier_'. $order['shopId']; + // 收银机打印订单 + $snd_data = [ + 'msg' => '收银机订单打印', + 'type' => 'cashier', + 'operate_type' => 'order_print', + 'data_type' => 'order', + 'status' => 1, + 'method' => 'sendToUid', + 'send_num' => 0, + 'send_id' => $send_id, + 'msg_id' => $rand, + 'data' => $data + ]; + $snd_data_json = json_encode($snd_data); + Gateway::$registerAddress = '127.0.0.1:1238'; + $res = Gateway::sendToUid($send_id, $snd_data_json); + Log::info('订单打印推送结果-->' . $res); + $result = Redis::get($snd_data['send_id']); + if($result) { + $msg_id_arr = json_decode($result, true); + $msg_id_arr_c = count($msg_id_arr); + $msg_id_arr[$msg_id_arr_c] = $snd_data; + $result_n = json_encode($msg_id_arr); + Base::setredis_new($result_n, $snd_data['send_id']); + }else { + $params_arr_n[] = $snd_data; + // print_r('数组-------->' . json_encode($params_arr_n)) . "\r\n"; + Base::setredis_new(json_encode($params_arr_n), $snd_data['send_id']); + } + if($is_log) { + Db::table('tb_mq_log')->insert([ + 'queue' => $queue, + 'msg' => $data, + 'type' => 'orderPrint', + 'plat' => 'Cashier', + 'create_time' => date('Y-m-d H:i:s'), + 'fail_time' => date('Y-m-d H:i:s'), + 'err_info' => $curl_error, + ]); } - if($is_log) { - Db::table('tb_mq_log')->insert([ - 'queue' => $queue, - 'msg' => $data, - 'type' => 'orderPrint', - 'plat' => 'Cashier', - 'create_time' => date('Y-m-d H:i:s'), - 'fail_time' => date('Y-m-d H:i:s'), - 'err_info' => $curl_error, - ]); } $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']); };