up
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
"""USDT (TRC20) 渠道:唯一金额生成。
|
||||
|
||||
USDT 无支付平台回调,到账依赖服务端轮询 TronGrid(每 15s):
|
||||
匹配条件 = 收款地址一致 + 金额(含尾差)精确相等 + 转账时间在订单有效期内 + 确认数 >= 19;
|
||||
匹配成功即入账(tx_hash 写入 third_trade_no,唯一索引保证幂等)。
|
||||
当前以 Celery worker 部署后实现轮询任务;开发期可用后台"人工补单"入账。
|
||||
"""
|
||||
import random
|
||||
from decimal import ROUND_HALF_UP, Decimal
|
||||
|
||||
|
||||
def gen_usdt_amount(amount_yuan: int, rate: Decimal) -> Decimal:
|
||||
"""base(元/汇率) + 随机尾差(0.001~0.999),保留 3 位小数;有效期内金额唯一用于订单匹配"""
|
||||
base = (Decimal(amount_yuan) / rate).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
|
||||
tail = Decimal(random.randint(1, 999)) / Decimal(1000)
|
||||
return base + tail
|
||||
Reference in New Issue
Block a user