消息推送
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user