From 1f407b777e65dda04fbbf1aff3dac27bc6fa0fc2 Mon Sep 17 00:00:00 2001 From: ASUS <515617283@qq.com> Date: Mon, 22 Dec 2025 16:49:36 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E6=97=B6=E6=8A=98=E6=89=A3=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/workermans/model/Base.php | 31 +++++++++++++++-------------- extend/workermans/model/Cashier.php | 2 +- extend/workermans/model/Manage.php | 2 +- extend/workermans/model/Onboc.php | 2 +- extend/workermans/model/Pad.php | 2 +- plugin/webman/gateway/Events.php | 2 +- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/extend/workermans/model/Base.php b/extend/workermans/model/Base.php index 3483035..e27139f 100644 --- a/extend/workermans/model/Base.php +++ b/extend/workermans/model/Base.php @@ -256,24 +256,17 @@ class Base // 添加redis 新 public static function setredis_new(string $data, string $client_id) { -// print_r('redis保存client_id---->' . $client_id . "\r\n"); -// print_r('redis保存值---->' . $data . "\r\n"); -// print_r('redis保存时间---->' . self::REDIS_TIME . "\r\n"); - $res = Redis::setex($client_id, self::REDIS_TIME, $data); -// print_r('redis保存结果---->' . $res . "\r\n"); + Redis::setex('client_id:' . $client_id, self::REDIS_TIME, $data); } // 消息回执 public static function delredis_new(string $client_id, string $msg_id) { // 处理普通消息 - Redis::del($client_id); -// print_r('回执---》' . $msg_id . date('Y-m-d H:i:s') . "\r\n"); + Redis::del('client_id:' . $client_id); // 如果是订单打印回执,直接删除 if(strstr($msg_id, 'cashier_order')) { -// print_r('打印回执---》' . $msg_id . date('Y-m-d H:i:s') . "\r\n"); $uid = Gateway::getUidByClientId($client_id); -// print_r('UID---》' . $uid . date('Y-m-d H:i:s') . "\r\n"); Redis::del($uid); } } @@ -282,7 +275,6 @@ class Base // 定时器处理消息回执/在线列表/折扣信息 public static function geteventredis_new() { -// print_r('定时器' . "\r\n"); $gateway = Gateway::class; // 处理折扣消息 // self::savetimediscount(); @@ -290,7 +282,7 @@ class Base $redis_name = Gateway::getAllClientSessions(); foreach ($redis_name as $client_id => $client_id_data) { if(Gateway::isOnline($client_id)) { - $result = Redis::get($client_id); + $result = Redis::get('client_id:' . $client_id); // 处理普通消息 if($result) { $msg_info_arr = json_decode($result, true); @@ -312,7 +304,7 @@ class Base // print_r('推送了-----' . "\r\n"); // 推送以后新增推送次数 $msg_info_arr['send_num'] += 1; - Redis::setex($client_id, self::REDIS_TIME, json_encode($msg_info_arr), ); + Redis::setex('client_id:' . $client_id, self::REDIS_TIME, json_encode($msg_info_arr), ); return true; } } @@ -548,6 +540,15 @@ class Base } } + + public static function get_shopping_time_str($shop_id, $table_code) + { + return 'cart_update:' . $shop_id . ':' . $table_code; + } + + + + // 购物车 多端同步 UID public static function get_shopping_save_uid($shop_id, $table_code) { @@ -925,7 +926,7 @@ class Base // 获取限时折扣 public function getTimeInfo($message) { - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; $time_dis_info = Redis::get($redis_str); if($time_dis_info) { $time_dis_info = json_decode($time_dis_info, true); @@ -942,7 +943,7 @@ class Base // 限时折扣修改 public function setTimeInfo($message) { - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; if(empty($message['data'])) { $res = Redis::del($redis_str); }else { @@ -966,7 +967,7 @@ class Base // 限时折扣删除 public function delTimeInfo($message) { - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; Redis::del($redis_str); $time_discount_info = Redis::get('time_discount:info'); if($time_discount_info) { diff --git a/extend/workermans/model/Cashier.php b/extend/workermans/model/Cashier.php index 6bdda0c..2fad833 100644 --- a/extend/workermans/model/Cashier.php +++ b/extend/workermans/model/Cashier.php @@ -55,7 +55,7 @@ class Cashier extends Base "); } // 限时折扣 - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; $time_dis_info = Redis::get($redis_str); if($time_dis_info) { $time_dis_info = json_decode($time_dis_info, true); diff --git a/extend/workermans/model/Manage.php b/extend/workermans/model/Manage.php index 945c92f..dd3b45e 100644 --- a/extend/workermans/model/Manage.php +++ b/extend/workermans/model/Manage.php @@ -44,7 +44,7 @@ class Manage extends Base "); } // 限时折扣 - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; $time_dis_info = Redis::get($redis_str); if($time_dis_info) { $time_dis_info = json_decode($time_dis_info, true); diff --git a/extend/workermans/model/Onboc.php b/extend/workermans/model/Onboc.php index 04f5ea5..f454eda 100644 --- a/extend/workermans/model/Onboc.php +++ b/extend/workermans/model/Onboc.php @@ -45,7 +45,7 @@ class Onboc extends Base "); } // 限时折扣 - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; $time_dis_info = Redis::get($redis_str); if($time_dis_info) { $time_dis_info = json_decode($time_dis_info, true); diff --git a/extend/workermans/model/Pad.php b/extend/workermans/model/Pad.php index d8c29db..739d1cc 100644 --- a/extend/workermans/model/Pad.php +++ b/extend/workermans/model/Pad.php @@ -49,7 +49,7 @@ class Pad extends Base "); } // 限时折扣 - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; $time_dis_info = Redis::get($redis_str); if($time_dis_info) { $time_dis_info = json_decode($time_dis_info, true); diff --git a/plugin/webman/gateway/Events.php b/plugin/webman/gateway/Events.php index f3514f5..03717be 100644 --- a/plugin/webman/gateway/Events.php +++ b/plugin/webman/gateway/Events.php @@ -170,7 +170,7 @@ class Events Gateway::sendToClient($client_id, json_encode(['msg' => '桌码或shop_id不能为空'])); return; } - $redis_str = Base::get_shopping_save_uid($message['shop_id'], $message['table_code']) . ':time_discount'; + $redis_str = Base::get_shopping_time_str($message['shop_id'], $message['table_code']) . ':time_discount'; // 限时折扣获取 $snd_data = [ 'msg' => '折扣获取',