feat: Rock 兑换支持上游异步 pending 并记录发货全链路报文
问题:上游 0666.pro 兑换返回 HTTP 200 + status=pending(官方处理中), 旧逻辑仅凭「没有 error 字段」就判定成功并写 redeemed 终态,导致本地显示 已发货而上游仍是 bound,且 redeemed 为硬终态无法自愈。 后端: - RedeemSkin 改为三态判定(success / pending / failed),不再无 error 即成功 - 新增 redeeming「发货处理中」状态;pending 不写 redeemed_at/fulfill_id - 成功落库前二次 refresh 确认上游 redeemed 或 redeemed_at 才置终态 - 新增确认 worker:20s 轮询、30s→5m 指数退避、110001 全局冷却 60s、 15 分钟未确认仅告警不回退,确认后同步订单为 delivered 并触发回调 - pending 期间禁止重复兑换,订单保持 delivering,不下发发货成功回调 - 新增 rock_delivery_logs 表与记录器:入站参数、内部状态、上游请求/响应 原文全部留档,保留 180 天 - 分配/绑定校验/刷新/导入/删除/回收站/统计/客服查询全部适配 redeeming - 迁移 026:redeeming 跟踪字段、部分索引与报文日志表 前端: - Token 列表新增「发货处理中」筛选项、标签与超时提示 - 删除/回收站纳入 redeeming 危险状态 - 历史抽屉拆为「状态历史 / 发货报文」双页签,按 trace 展示报文详情 - 买家发货页在 pending 时提示官方处理中,无需重复提交 测试:新增 pending 不落终态、异常响应不误判、重复提交不重复兑换、 确认后同步订单、保持 pending 并退避 5 个用例;go build/vet/test 与 前端构建均通过。
This commit is contained in:
@@ -23,9 +23,10 @@ const (
|
||||
)
|
||||
|
||||
var rockTokenDangerousStatuses = map[string]bool{
|
||||
model.RockStatusUsing: true,
|
||||
model.RockStatusBound: true,
|
||||
model.RockStatusMismatch: true,
|
||||
model.RockStatusUsing: true,
|
||||
model.RockStatusBound: true,
|
||||
model.RockStatusRedeeming: true,
|
||||
model.RockStatusMismatch: true,
|
||||
}
|
||||
|
||||
// RockTokenDeleteStatusCount 是删除预览中的状态分布。
|
||||
@@ -67,7 +68,7 @@ type RockTokenForceRequiredError struct {
|
||||
}
|
||||
|
||||
func (e *RockTokenForceRequiredError) Error() string {
|
||||
return fmt.Sprintf("本次操作包含 %d 条使用中/已绑定/绑定错误的 Token,必须二次确认后强制删除", e.Dangerous)
|
||||
return fmt.Sprintf("本次操作包含 %d 条使用中/已绑定/发货处理中/绑定错误的 Token,必须二次确认后强制删除", e.Dangerous)
|
||||
}
|
||||
|
||||
// RockTokenDeleteConflictError 表示预览后数据已变化。
|
||||
@@ -84,7 +85,7 @@ func (e *RockTokenDeleteConflictError) Error() string {
|
||||
|
||||
func isKnownRockTokenStatus(status string) bool {
|
||||
switch status {
|
||||
case "", model.RockStatusAvailable, model.RockStatusUsing, model.RockStatusBound,
|
||||
case "", model.RockStatusAvailable, model.RockStatusUsing, model.RockStatusBound, model.RockStatusRedeeming,
|
||||
model.RockStatusRedeemed, model.RockStatusMismatch, model.RockStatusAbnormal,
|
||||
rockTokenStatusUsingOverdue, rockTokenStatusBoundOverdue:
|
||||
return true
|
||||
@@ -186,6 +187,7 @@ func rockTokenStatusCountsFromRows(rows []model.RockToken) []RockTokenDeleteStat
|
||||
model.RockStatusAvailable,
|
||||
model.RockStatusUsing,
|
||||
model.RockStatusBound,
|
||||
model.RockStatusRedeeming,
|
||||
model.RockStatusRedeemed,
|
||||
model.RockStatusMismatch,
|
||||
model.RockStatusAbnormal,
|
||||
|
||||
Reference in New Issue
Block a user