消息推送

This commit is contained in:
mzl
2025-08-20 18:12:07 +08:00
parent 78e28a99dc
commit 9f96b8d625
13 changed files with 451 additions and 41 deletions
+24
View File
@@ -283,4 +283,28 @@ if (!function_exists('normalizeRichText')) {
// 替换所有空白实体为普通空格
return preg_replace('/\s+/u', ' ', $result);
}
}
/**
* 生成消息编号(唯一业务标识)
* 格式:年月日时分秒 + 微秒 + 随机数
* 例如:20250820175530987654321
*
* @return string
*/
if (!function_exists('generateMsgId')) {
function generateMsgId(): string
{
// 时间部分(精确到微秒)
$time = microtime(true);
$micro = sprintf("%06d", ($time - floor($time)) * 1e6);
$date = date('YmdHis', (int)$time);
// 随机部分(3位)
$rand = mt_rand(100, 999);
// 拼接:日期时间 + 微秒 + 随机数
return $date . $micro . $rand;
}
}