16 lines
536 B
Python
16 lines
536 B
Python
"""单号生成:前缀 + 日期 + 随机序列(唯一性由 DB 唯一键兜底)。"""
|
||
from __future__ import annotations
|
||
|
||
import secrets
|
||
from datetime import datetime
|
||
|
||
|
||
def gen_order_no(prefix: str = "PO") -> str:
|
||
"""生成全局唯一单号,如 PO20260912A1B2C3D4。
|
||
|
||
- PO:交易申请单(trade_order.order_no)
|
||
- TR:成交流水(fin_transaction.transaction_no)
|
||
- WO:业务工单(biz_work_order.work_order_no)
|
||
"""
|
||
return f"{prefix}{datetime.now():%Y%m%d}{secrets.token_hex(4).upper()}"
|