feat: 自动结算返回到期时间戳供前端秒级倒计时

详情/列表用 auto_expire_at_ts 做 HH:MM:SS 时钟;展示不依赖 Celery,真正自动结单才需要 beat。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
XingQue
2026-07-27 08:24:13 +08:00
parent 3fe24cbcce
commit 5e38a3d49a

View File

@@ -55,9 +55,15 @@ def order_auto_settle_payload(order) -> dict:
elif timezone.is_naive(expire_at) and timezone.is_aware(now):
expire_at = timezone.make_aware(expire_at, timezone.get_current_timezone())
remain = int((expire_at - now).total_seconds())
try:
expire_ts = int(expire_at.timestamp())
except Exception:
expire_ts = 0
return {
'auto_settle_eligible': True,
'auto_expire_at': fmt_datetime(expire_at),
# 前端用时间戳做秒级时钟倒计时,避免解析本地时区偏差
'auto_expire_at_ts': expire_ts,
'auto_settle_remain_seconds': max(0, remain),
}