feat(server/pay): 订单展示层过期态(created 超 TTL 显 expired,零迁移)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-12 17:18:02 +08:00
parent a0367b37e5
commit b9e2f8c2da
2 changed files with 42 additions and 0 deletions
+6
View File
@@ -157,6 +157,9 @@ type orderView struct {
PaidAt *string `json:"paid_at,omitempty"`
}
// 未付订单展示层过期窗口(近似 pay 会话时效;仅影响列表/详情显示,不改台账)。
const orderPendingTTL = 30 * time.Minute
func orderViewFromRow(row *PurchaseRow) orderView {
v := orderView{
OrderNo: row.OutTradeNo, SKU: row.SKU, Method: row.Method, Status: row.Status,
@@ -178,6 +181,9 @@ func orderViewFromRow(row *PurchaseRow) orderView {
s := row.PaidAt.Time.UTC().Format(time.RFC3339)
v.PaidAt = &s
}
if row.Status == "created" && row.CreatedAt.Add(orderPendingTTL).Before(time.Now()) {
v.Status = "expired" // 展示层:台账仍 created,可继续支付/取消
}
return v
}