fix: 统一商务表格展示并修正筛选和全量排序

This commit is contained in:
Yvan
2026-11-05 01:48:09 +08:00
parent dc97690eb1
commit 10600d1bc9
38 changed files with 356 additions and 145 deletions
+2 -1
View File
@@ -254,6 +254,7 @@ func sortAnalytics(rows []*AnalyticsRow, kind AnalyticsKind, field string, ascen
}
allowed := map[string]bool{"newRegisterCount": true, "activeCount": true, "payUserCount": true, "newPayUserCount": true, "totalPay": true, "payRate": true}
if kind == GameAnalytics {
allowed["gameId"] = true
allowed["arpu"] = true
allowed["arppu"] = true
} else {
@@ -277,7 +278,7 @@ func sortAnalytics(rows []*AnalyticsRow, kind AnalyticsKind, field string, ascen
n = big.NewRat(row.Counts.Pay, 1)
case "newPayUserCount":
n = big.NewRat(row.Counts.NewPay, 1)
case "promoteId":
case "promoteId", "gameId":
n = big.NewRat(row.ID, 1)
case "promoteType":
value := int64(0)
+10
View File
@@ -6,6 +6,16 @@ import (
"time"
)
func TestGameIDSortDoesNotFallBackToRechargeAmount(t *testing.T) {
rows := []*AnalyticsRow{{AnalyticsKey: AnalyticsKey{ID: 20, SourceDB: "lx"}, Pay: "1.00"}, {AnalyticsKey: AnalyticsKey{ID: 3, SourceDB: "lx"}, Pay: "900.00"}}
if err := sortAnalytics(rows, GameAnalytics, "gameId", true); err != nil || rows[0].ID != 3 {
t.Fatal("game ID ascending sort failed")
}
if err := sortAnalytics(rows, GameAnalytics, "gameId", false); err != nil || rows[0].ID != 20 {
t.Fatal("game ID descending sort fell back to recharge amount")
}
}
type analyticsRepoFake struct {
data *AnalyticsData
scope AnalyticsScope
+2
View File
@@ -142,6 +142,8 @@ func registrationSort(field string) string {
}
func spendSort(field string) string {
switch field {
case "id":
return "id"
case "payAmount", "pay_amount", "amount":
return "payAmount"
}