fix: align business reports and record task migration progress

This commit is contained in:
Yvan
2026-11-06 00:47:06 +08:00
parent 1bc2082718
commit b1f14bd525
32 changed files with 501 additions and 53 deletions
+28 -3
View File
@@ -27,6 +27,7 @@ type AnalyticsKey struct {
ID int64
}
type AnalyticsFilter struct {
HasRegister, HasPay *bool
Sources, GameNames []string
PromoteName string
PromoteType *int
@@ -47,6 +48,22 @@ type AnalyticsRow struct {
Pay, PayRate, ARPU, ARPPU string
}
func (f AnalyticsFilter) MatchesMetrics(row *AnalyticsRow) (bool, error) {
if f.HasRegister != nil && (row.Counts.Register > 0) != *f.HasRegister {
return false, nil
}
if f.HasPay != nil {
amount, err := portraitNumber(row.Pay)
if err != nil {
return false, err
}
if (amount.Sign() > 0) != *f.HasPay {
return false, nil
}
}
return true, nil
}
func (r *AnalyticsRow) BusinessName() string {
if value := strings.TrimSpace(r.BindingAccount); value != "" {
return value
@@ -135,12 +152,20 @@ func (uc *AnalyticsUsecase) list(ctx context.Context, kind AnalyticsKind, filter
if kind == GameAnalytics {
filter.PromoteName = ""
filter.PromoteType = nil
filter.HasRegister, filter.HasPay = nil, nil
}
filter.StartDate, filter.EndDate = reportDateDefaults(filter.StartDate, filter.EndDate, 30, uc.now())
if filter.EndDate.Before(*filter.StartDate) {
if kind == GameAnalytics {
filter.StartDate, filter.EndDate = reportDateDefaults(filter.StartDate, filter.EndDate, 1, uc.now())
} else if filter.EndDate == nil {
_, filter.EndDate = reportDateDefaults(nil, nil, 1, uc.now())
}
if filter.StartDate != nil && filter.EndDate.Before(*filter.StartDate) {
return nil, ErrAnalyticsDateOrder
}
filter.Begin = filter.StartDate.Format("2006-01-02")
filter.Begin = ""
if filter.StartDate != nil {
filter.Begin = filter.StartDate.Format("2006-01-02")
}
filter.End = filter.EndDate.Format("2006-01-02")
out := &AnalyticsPage{Rows: []*AnalyticsRow{}, Begin: filter.Begin, End: filter.End, Available: true}
scope := AnalyticsScope{Viewer: viewer, IncludeSub: pref.IncludeSubPromote, IDCardDedup: pref.IDCardDedup}