From ca30f3302b81d618585cea044d4b27d2b1adcf7a Mon Sep 17 00:00:00 2001 From: liufumingren Date: Wed, 16 Sep 2026 22:10:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20QiweMessage=20=E9=98=9F=E5=88=97?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E5=85=A5=E9=98=9F=E6=97=B6=E9=97=B4=20ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用于排查 / 按时间清理积压。 - 统一入口 Wms::withQueueTs(),覆盖 toMsgCache 与 AutoCreatePostNum 的 lpush - Chat::send_group_message() 内联补 ts - wx 队列 Message 故意不加:其消费端会把整个数组 http_build_query 转发给外部发送接口, 未验证对方是否忽略未知参数 --- application/index/controller/wms/Chat.php | 4 ++++ application/index/controller/wms/Wms.php | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/application/index/controller/wms/Chat.php b/application/index/controller/wms/Chat.php index 9435e8a..f460dce 100644 --- a/application/index/controller/wms/Chat.php +++ b/application/index/controller/wms/Chat.php @@ -3825,6 +3825,10 @@ _________________________________________________________ } $this->redis->select(2); $MessageKey = $this->SOURCE=="qiwe"?"QiweMessage":"Message"; + //企微队列追加入队时间,便于排查与按时间清理积压 + if($MessageKey === "QiweMessage" && isset($tomsg) && is_array($tomsg) && !isset($tomsg['ts'])){ + $tomsg['ts'] = date('Y-m-d H:i:s'); + } Log::error("发送群消息:{$MessageKey}".json_encode($tomsg)); $this->redis->lpush($MessageKey,json_encode($tomsg)); return json(["code"=>1,"msg"=>"消息发送成功"]); diff --git a/application/index/controller/wms/Wms.php b/application/index/controller/wms/Wms.php index 14dd434..88710b2 100644 --- a/application/index/controller/wms/Wms.php +++ b/application/index/controller/wms/Wms.php @@ -10621,7 +10621,7 @@ class Wms extends Frontend $order->status = 3; $tomsg = $this->toMsg($order["room_wxid"],"@{$order['creator_name']} \n================================\n{$order['msg']}\n================================\n已出运单号:{$data}\n",$order["creator_wxid"]); $this->redis->select(2); - $this->redis->lpush($MessageKey,json_encode($tomsg)); + $this->redis->lpush($MessageKey,json_encode($this->withQueueTs($tomsg,$MessageKey))); $order->postnum = $data; $order->save(); }else{ @@ -10629,7 +10629,7 @@ class Wms extends Frontend $order->error = $msg; $tomsg = $this->toMsg($order["room_wxid"],"@{$order['creator_name']} \n================================\n{$order['msg']}\n================================\n出单失败:{$msg}\n三分钟后重试出单",$order["creator_wxid"]); $this->redis->select(2); - $this->redis->lpush($MessageKey,json_encode($tomsg)); + $this->redis->lpush($MessageKey,json_encode($this->withQueueTs($tomsg,$MessageKey))); $order->save(); } array_push($datas,[$code,$msg,$data]); @@ -11588,10 +11588,24 @@ class Wms extends Frontend $cacheKey = "QiweMessage"; } } + //企微队列追加入队时间,便于排查与按时间清理积压(消费端 sendMessage 会忽略未知字段) + $msgData = $this->withQueueTs($msgData, $cacheKey); $this->redis->select(2); $this->redis->lpush($cacheKey, json_encode($msgData)); return $cacheKey; } + /** + * @description:企微队列消息追加 ts 入队时间 + * @param {array} $msgData 消息体 + * @param {string} $cacheKey 队列键名 + * @return {array} 补过 ts 的消息体 + */ + private function withQueueTs($msgData, $cacheKey){ + if($cacheKey === "QiweMessage" && is_array($msgData) && !isset($msgData['ts'])){ + $msgData['ts'] = date('Y-m-d H:i:s'); + } + return $msgData; + } /** * 获取货主对应的企微群聊房间,并返回房间信息及来源标识 * @param string $WAREHOUSEID 仓库ID