feat: automate business upgrades and sync reviewed frontend
This commit is contained in:
@@ -52,7 +52,7 @@ func TestBusinessHTTPListWithSystemOnlyAndCompleteDatabase(t *testing.T) {
|
||||
}
|
||||
for _, statement := range []string{
|
||||
"INSERT INTO sys_users(id,uuid,username,authority_id,level,id_path) VALUES (1,'admin','admin',888,0,'0'),(2,'child','child',901,1,'0'),(3,'empty','empty',903,3,'0,2')",
|
||||
"INSERT INTO sys_authorities(authority_id,authority_name) VALUES (901,'一级商务')",
|
||||
"INSERT INTO sys_authorities(authority_id,authority_name,business_level) VALUES (901,'一级商务',1)",
|
||||
"INSERT INTO sys_user_bind_platform(user_id,source_db,platform_busier_id,status) VALUES (2,'lx',9,'0')",
|
||||
} {
|
||||
if err := db.Exec(statement).Error; err != nil {
|
||||
|
||||
+14
-1
@@ -40,6 +40,7 @@ func TestLedgerHTTPQueriesAndExcelExports(t *testing.T) {
|
||||
}
|
||||
for _, sql := range []string{
|
||||
"INSERT INTO sys_users(id,uuid,username,level,parent_id,id_path,enable) VALUES(1,'root','root',0,0,'0',1),(7,'owner','owner',1,0,'0',1),(9,'leaf','leaf',3,7,'0,7',1),(99,'other','other',1,0,'0',1)",
|
||||
"UPDATE sys_users SET nick_name='商务昵称' WHERE id=9",
|
||||
"INSERT INTO sys_user_bind_platform(user_id,source_db,platform_busier_id,platform_busier_account,status) VALUES(9,'lx',14,'sdk','0'),(99,'hw',20,'other','0')",
|
||||
"CREATE TABLE tab_promote(id INTEGER,source_db TEXT,account TEXT,promote_level INTEGER,top_promote_id INTEGER,busier_id INTEGER)",
|
||||
"INSERT INTO tab_promote VALUES(100,'lx','root-channel',1,0,14),(101,'lx','child-channel',2,100,14),(100,'hw','outside',1,0,20)",
|
||||
@@ -110,7 +111,7 @@ func TestLedgerHTTPQueriesAndExcelExports(t *testing.T) {
|
||||
data := call(7, "GET", "/sw/register/list?sourceDb=lx&sortField=totalPayAmount", "", 0).(map[string]any)
|
||||
rows := data["rows"].([]any)
|
||||
first := rows[0].(map[string]any)
|
||||
if data["total"] != float64(2) || first["userId"] != "1" || first["totalPayAmount"] != "1012.34" || first["fgameName"] != "历史游戏" || first["busierName"] != "owner→leaf" {
|
||||
if data["total"] != float64(2) || first["userId"] != "1" || first["totalPayAmount"] != "1012.34" || first["fgameName"] != "历史游戏" || first["busierName"] != "sdk(leaf)" {
|
||||
t.Fatalf("注册明细口径或字段错误: %+v", data)
|
||||
}
|
||||
games := call(7, "GET", "/sw/serverAnalysis/games?sourceDb=lx&limit=50", "", 0).([]any)
|
||||
@@ -125,6 +126,9 @@ func TestLedgerHTTPQueriesAndExcelExports(t *testing.T) {
|
||||
if data["total"] != float64(1) || data["totalPayAmount"] != "0.00" {
|
||||
t.Fatal("合计不得包含筛选条件外的成功订单")
|
||||
}
|
||||
if data["rows"].([]any)[0].(map[string]any)["busierName"] != "sdk(leaf)" {
|
||||
t.Fatal("充值明细归属商务应显示平台账号和商务登录名")
|
||||
}
|
||||
data = call(1, "GET", "/sw/spend/list?sourceDb=lx", "", 0).(map[string]any)
|
||||
if data["total"] != float64(4) || data["totalPayAmount"] != "20.34" {
|
||||
t.Fatal("超管全平台遗漏官方订单")
|
||||
@@ -154,6 +158,11 @@ func TestLedgerHTTPQueriesAndExcelExports(t *testing.T) {
|
||||
if err != nil || len(xlsRows) != 3 || xlsRows[0][7] != "累计充值" {
|
||||
t.Fatal("注册 XLSX 字段或行数错误")
|
||||
}
|
||||
for _, row := range xlsRows[1:] {
|
||||
if len(row) != 13 || row[12] != "sdk(leaf)" {
|
||||
t.Fatalf("注册导出归属商务格式错误: %+v", row)
|
||||
}
|
||||
}
|
||||
raw, header = request(7, "POST", "/sw/spend/export", "sourceDb=lx&payStatus=1&sortField=payAmount")
|
||||
if header.Get("success") != "true" {
|
||||
t.Fatalf("充值导出失败: %s", raw)
|
||||
@@ -163,10 +172,14 @@ func TestLedgerHTTPQueriesAndExcelExports(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
order, _ := f.GetCellValue("充值明细", "E2")
|
||||
busierName, busierErr := f.GetCellValue("充值明细", "R2")
|
||||
f.Close()
|
||||
if order != "000000000001" {
|
||||
t.Fatal("订单号导出丢失前导零")
|
||||
}
|
||||
if busierErr != nil || busierName != "sdk(leaf)" {
|
||||
t.Fatalf("充值导出归属商务格式错误: %q %v", busierName, busierErr)
|
||||
}
|
||||
call(7, "GET", "/sw/register/list?beginRegisterTime=bad&endRegisterTime=2026-11-04", "", 7)
|
||||
if err := db.Exec("WITH RECURSIVE seq(n) AS (SELECT 1 UNION ALL SELECT n+1 FROM seq WHERE n<10001) INSERT INTO tab_user(id,source_db,register_time,fgame_id,fgame_name,promote_id,puid) SELECT 1000+n,'lx',?,1,'游戏',100,0 FROM seq", strconv.FormatInt(stamp, 10)).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
+5
-1
@@ -6,7 +6,9 @@ import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"kra/internal/config"
|
||||
"kra/internal/data"
|
||||
@@ -173,7 +175,9 @@ func main() {
|
||||
if bc.Data != nil {
|
||||
database = bc.Data.Database
|
||||
}
|
||||
if err := data.MigrateDatabase(context.Background(), database, modules.Catalog(), logger, flagCheckSchema); err != nil {
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
||||
defer cancel()
|
||||
if err := data.MigrateDatabase(ctx, database, modules.Catalog(), logger, flagCheckSchema, runtime.ConfigPath()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
logger.Info("database migration verification completed", "mod", "system", "check_only", flagCheckSchema)
|
||||
|
||||
Reference in New Issue
Block a user