fix(v2): settle 定位尝试的瞬时读库错误归 SettleFailed(可重试),不再误标 not_found

AttemptByProviderRef 返回非哨兵错误(如 DB 抖动)时原先与"查无此单"终态
一并标 SettleNotFound;调用方按结果值决定 ack,会把已付订单永久丢弃。
非哨兵分支改判 SettleFailed(可重试,渠道会重投),errors.Is(ErrAttemptNotFound)
分支维持 SettleNotFound 不变。新增 TestSettleTransientReadErrorIsFailed 通过
关闭底层连接强制产出瞬时读库错误,验证结果与语义。
This commit is contained in:
wangjia
2026-07-10 11:20:53 +08:00
parent 68d162d6c4
commit 0877b01874
2 changed files with 41 additions and 1 deletions
+2 -1
View File
@@ -43,7 +43,8 @@ func (g *Gateway) Settle(ctx context.Context, ev *provider.PaidEvent) (SettleRes
if errors.Is(err, store.ErrAttemptNotFound) {
return SettleNotFound, nil
}
return SettleNotFound, err
// 读库瞬时失败是可重试态,不能与"查无此单"终态混淆。
return SettleFailed, err
}
// 金额/币种核对:币种须一致,实付须 ≥ 应收(允许 crypto 多付,拒少付)。
if ev.PaidCurrency != att.Currency || ev.PaidAmountMinor < att.AmountMinor {