feat(v2): crypto 孤儿到账发现——OrphanScanner 扫链核对 + orphan_payments 落表告警(对账兜底)

This commit is contained in:
wangjia
2026-07-10 17:52:10 +08:00
parent 04c3f4f31a
commit 727ed74899
12 changed files with 370 additions and 7 deletions
+16
View File
@@ -0,0 +1,16 @@
package model
import "time"
// OrphanPayment 到账但不匹配任何 attempt 的转账(对账发现,供人工核对/退款)。
// tx_id 唯一 → 重复扫描幂等 no-op。canonical pangolin-pay orphan_payments 的 v2 对应物。
type OrphanPayment struct {
Base
Channel string `gorm:"index;size:32;not null"`
AccountID string `gorm:"index;size:64"`
TxID string `gorm:"uniqueIndex;size:128;not null"`
AmountMinor int64 `gorm:"not null"`
Currency string `gorm:"size:16;not null"`
DetectedAt time.Time
Note string `gorm:"size:255"`
}
+1 -1
View File
@@ -32,7 +32,7 @@ func OpenTestDB(t *testing.T) *gorm.DB {
t.Fatalf("open test db: %v", err)
}
if err := db.AutoMigrate(&OrderV2{}, &Attempt{}, &Account{}, &Refund{}, &WebhookDelivery{},
&Product{}, &ProductPrice{}); err != nil {
&Product{}, &ProductPrice{}, &OrphanPayment{}); err != nil {
t.Fatalf("migrate: %v", err)
}
if err := UpgradeWebhookDeliveryIndex(db); err != nil {