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