fix: validate explicit migrations and preserve large business ids

This commit is contained in:
Yvan
2026-11-06 07:00:05 +08:00
parent f6f2a4745e
commit 0f0ec2e6d7
53 changed files with 2653 additions and 1445 deletions
@@ -15,11 +15,11 @@ type ledgerExportFake struct{ LedgerUsecase }
func (ledgerExportFake) ExportRegistrations(context.Context, business.LedgerFilter) ([]*business.Registration, error) {
amount := "9007199254740993.10"
stamp := int64(1793577600)
return []*business.Registration{{ChannelKey: business.ChannelKey{SourceDB: "lx", ID: 7}, RegisterTime: &stamp, FirstGameName: "游戏", TotalPayAmount: &amount, LedgerNames: business.LedgerNames{PromoteAccount: "=1+1"}}}, nil
return []*business.Registration{{ChannelKey: business.ChannelKey{SourceDB: "lx", ID: 9007199254740993}, RegisterTime: &stamp, FirstGameName: "游戏", TotalPayAmount: &amount, LedgerNames: business.LedgerNames{PromoteAccount: "=1+1"}}}, nil
}
func (ledgerExportFake) ExportSpends(context.Context, business.LedgerFilter) ([]*business.Spend, error) {
amount := "123.45"
return []*business.Spend{{ChannelKey: business.ChannelKey{SourceDB: "lx", ID: 8}, OrderNumber: "000000000000000001", PayAmount: &amount}}, nil
return []*business.Spend{{ChannelKey: business.ChannelKey{SourceDB: "lx", ID: 9007199254740995}, OrderNumber: "000000000000000001", PayAmount: &amount}}, nil
}
func TestLedgerWorkbookPreservesNumbersAndText(t *testing.T) {
s := &LedgerService{uc: ledgerExportFake{}}
@@ -41,6 +41,13 @@ func TestLedgerWorkbookPreservesNumbersAndText(t *testing.T) {
if amount != "9007199254740993.10" || formula != "" || text != "=1+1" {
t.Fatalf("导出丢失金额精度或把账号当成公式: %s %s %s", amount, formula, text)
}
for _, cell := range []string{"C2", "D2"} {
value, _ := f.GetCellValue("注册明细", cell)
kind, _ := f.GetCellType("注册明细", cell)
if value != "9007199254740993" || kind != excelize.CellTypeSharedString {
t.Fatalf("ID must be exact text: %s %v", value, kind)
}
}
rows, err := f.GetRows("注册明细")
if err != nil || len(rows) != 2 || rows[0][0] != "sourceDb" || rows[0][12] != "所属商务" {
t.Fatal("原导出字段与顺序丢失")