feat: QiweMessage 队列追加入队时间 ts

用于排查 / 按时间清理积压。

- 统一入口 Wms::withQueueTs(),覆盖 toMsgCache 与 AutoCreatePostNum 的 lpush
- Chat::send_group_message() 内联补 ts
- wx 队列 Message 故意不加:其消费端会把整个数组 http_build_query 转发给外部发送接口,
  未验证对方是否忽略未知参数
This commit is contained in:
liufumingren 2026-09-16 22:10:27 +08:00
parent d289a0757d
commit ca30f3302b
2 changed files with 20 additions and 2 deletions

View File

@ -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"=>"消息发送成功"]);

View File

@ -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