feat(v2): crypto 孤儿到账发现——OrphanScanner 扫链核对 + orphan_payments 落表告警(对账兜底)
This commit is contained in:
@@ -123,6 +123,36 @@ type RecurringProvider interface {
|
||||
CancelAgreement(ctx context.Context, agreementRef string) error
|
||||
}
|
||||
|
||||
// ---- 对账:孤儿到账扫描(P6,可选接口)----
|
||||
|
||||
// KnownAttempt 是 pay 合法签发过的一笔尝试的对账维度:期望金额 = base(AmountMinor)+ 渠道尾数
|
||||
// (尾数封在 provider_ref,由渠道自解,pay 不算)。渠道据此判断一笔到账是否"有主"。
|
||||
type KnownAttempt struct {
|
||||
AmountMinor int64
|
||||
ProviderRef string
|
||||
}
|
||||
|
||||
// OrphanScanRequest 扫描某账户 Since 以来、不匹配任何 Known 的到账。
|
||||
type OrphanScanRequest struct {
|
||||
AccountID string
|
||||
Since time.Time
|
||||
Known []KnownAttempt
|
||||
}
|
||||
|
||||
// OrphanTransfer 一笔"有钱到账但无主"的转账(付错金额/手动转/超窗迟到旧款)。
|
||||
type OrphanTransfer struct {
|
||||
TxID string
|
||||
AmountMinor int64
|
||||
Currency string
|
||||
At time.Time
|
||||
}
|
||||
|
||||
// OrphanScanner 自托管渠道(crypto)可选实现:发现到账但不匹配任何 attempt 的转账。
|
||||
// 网关侧渠道(alipay/stripe)以对账单核对,不实现此接口。
|
||||
type OrphanScanner interface {
|
||||
ScanOrphans(ctx context.Context, req OrphanScanRequest) ([]OrphanTransfer, error)
|
||||
}
|
||||
|
||||
// Registry — 方法名 → Provider(设计 §2 Provider adapter 注册表)。启动期注册,运行期只读。
|
||||
type Registry struct{ providers map[string]Provider }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user