fix: validate explicit migrations and preserve large business ids
This commit is contained in:
@@ -117,5 +117,5 @@ func (s *BindingService) Unbind(ctx context.Context, req *dto.BusinessBindingReq
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return s.uc.Unbind(ctx, business.PlatformKey{SourceDB: source, BusierID: req.PlatformBusierID})
|
||||
return s.uc.Unbind(ctx, business.PlatformKey{SourceDB: source, BusierID: uint64(req.PlatformBusierID)})
|
||||
}
|
||||
|
||||
@@ -21,6 +21,12 @@ func optionalNumber[T ~int | ~int64](value *T) ledgerCell {
|
||||
}
|
||||
return numericCell(strconv.FormatInt(int64(*value), 10))
|
||||
}
|
||||
func optionalID(value *int64) ledgerCell {
|
||||
if value == nil {
|
||||
return textCell("")
|
||||
}
|
||||
return textCell(strconv.FormatInt(*value, 10))
|
||||
}
|
||||
func optionalMoney(value *string) ledgerCell {
|
||||
if value == nil {
|
||||
return textCell("")
|
||||
@@ -83,7 +89,7 @@ func (s *LedgerService) ExportRegistrations(ctx context.Context, req *dto.Ledger
|
||||
rows := make([][]ledgerCell, 0, len(items))
|
||||
for _, item := range items {
|
||||
r := registrationResponse(item)
|
||||
rows = append(rows, []ledgerCell{textCell(r.SourceDB), textCell(r.SourceDBLabel), numericCell(strconv.FormatUint(r.ID, 10)), numericCell(strconv.FormatUint(r.UserID, 10)), optionalNumber(r.RegisterTime), optionalNumber(r.FirstGameID), textCell(r.FirstGameName), optionalMoney(r.TotalPayAmount), textCell(r.RegisterIP), textCell(r.DeviceName), textCell(r.PromoteAccount), optionalNumber(r.PromoteID), textCell(r.BusierName)})
|
||||
rows = append(rows, []ledgerCell{textCell(r.SourceDB), textCell(r.SourceDBLabel), textCell(strconv.FormatUint(r.ID, 10)), textCell(strconv.FormatUint(r.UserID, 10)), optionalNumber(r.RegisterTime), optionalID(r.FirstGameID), textCell(r.FirstGameName), optionalMoney(r.TotalPayAmount), textCell(r.RegisterIP), textCell(r.DeviceName), textCell(r.PromoteAccount), optionalID(r.PromoteID), textCell(r.BusierName)})
|
||||
}
|
||||
return ledgerWorkbook("注册明细", []string{"sourceDb", "所属平台", "ID", "玩家ID", "注册时间", "fgameId", "游戏", "累计充值", "注册IP", "机型", "渠道", "promoteId", "所属商务"}, rows)
|
||||
}
|
||||
@@ -99,7 +105,7 @@ func (s *LedgerService) ExportSpends(ctx context.Context, req *dto.LedgerQuery)
|
||||
rows := make([][]ledgerCell, 0, len(items))
|
||||
for _, item := range items {
|
||||
r := spendResponse(item)
|
||||
rows = append(rows, []ledgerCell{textCell(r.SourceDB), textCell(r.SourceDBLabel), numericCell(strconv.FormatUint(r.ID, 10)), optionalNumber(r.UserID), textCell(r.OrderNumber), optionalNumber(r.GameID), textCell(r.GameName), textCell(r.ServerID), textCell(r.ServerName), textCell(r.PlayerName), optionalMoney(r.PayAmount), optionalNumber(r.PayTime), optionalNumber(r.PayWay), optionalNumber(r.PayStatus), textCell(r.IP), textCell(r.PromoteAccount), optionalNumber(r.PromoteID), textCell(r.BusierName)})
|
||||
rows = append(rows, []ledgerCell{textCell(r.SourceDB), textCell(r.SourceDBLabel), textCell(strconv.FormatUint(r.ID, 10)), optionalID(r.UserID), textCell(r.OrderNumber), optionalID(r.GameID), textCell(r.GameName), textCell(r.ServerID), textCell(r.ServerName), textCell(r.PlayerName), optionalMoney(r.PayAmount), optionalNumber(r.PayTime), optionalNumber(r.PayWay), optionalNumber(r.PayStatus), textCell(r.IP), textCell(r.PromoteAccount), optionalID(r.PromoteID), textCell(r.BusierName)})
|
||||
}
|
||||
return ledgerWorkbook("充值明细", []string{"sourceDb", "所属平台", "ID", "玩家ID", "订单号", "gameId", "游戏", "serverId", "区服", "角色", "实付金额", "完成时间", "方式", "状态", "IP", "渠道", "promoteId", "所属商务"}, rows)
|
||||
}
|
||||
|
||||
@@ -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("原导出字段与顺序丢失")
|
||||
|
||||
Reference in New Issue
Block a user