This commit is contained in:
@@ -67,3 +67,25 @@ export function generateShopCode(): string {
|
||||
|
||||
return `SHOP${year}${month}${day}${hours}${minutes}${seconds}${randomChars}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成运营商编码
|
||||
* 规则: CARRIER + 年月日时分秒 + 4位随机数
|
||||
* 示例: CARRIER20260328143025ABCD
|
||||
*/
|
||||
export function generateCarrierCode(): string {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear()
|
||||
const month = String(now.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(now.getDate()).padStart(2, '0')
|
||||
const hours = String(now.getHours()).padStart(2, '0')
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0')
|
||||
|
||||
// 生成4位随机大写字母
|
||||
const randomChars = Array.from({ length: 4 }, () =>
|
||||
String.fromCharCode(65 + Math.floor(Math.random() * 26))
|
||||
).join('')
|
||||
|
||||
return `CARRIER${year}${month}${day}${hours}${minutes}${seconds}${randomChars}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user