修改订单号生成逻辑
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import time
|
||||
import random
|
||||
from datetime import datetime
|
||||
import uuid
|
||||
import secrets
|
||||
|
||||
|
||||
def generate_id() -> str:
|
||||
@@ -16,6 +16,6 @@ def generate_order_no() -> str:
|
||||
# 格式化为 yyyymmddhhmmss 格式的时间戳
|
||||
now = datetime.now()
|
||||
timestamp = now.strftime("%Y%m%d%H%M%S")
|
||||
# 使用 UUID 的部分值来生成更可靠的随机数,防止并发冲突
|
||||
random_part = uuid.uuid4().hex[:8].upper()
|
||||
# 使用密码学安全的随机数生成 8位纯数字,防止并发冲突
|
||||
random_part = ''.join(str(secrets.randbelow(10)) for _ in range(8))
|
||||
return f"MZZC{timestamp}{random_part}"
|
||||
|
||||
Reference in New Issue
Block a user