fix: 补齐渠道全量合计筛选导出及有效端目标遗漏
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package business
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"kra/internal/biz/business"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
func (s *AnalyticsService) Export(ctx context.Context, req *dto.AnalyticsQuery) ([]byte, error) {
|
||||
f, err := analyticsRequest(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
page, err := s.uc.ListAll(ctx, business.ChannelAnalytics, f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !page.Available {
|
||||
return nil, business.ErrChannelReportsUnavailable
|
||||
}
|
||||
headers := []string{"所属平台", "渠道名称", "归属商务", "渠道类型", "新增注册", "活跃玩家", "充值额", "付费玩家", "新增付费", "付费率"}
|
||||
rows := make([][]ledgerCell, 0, len(page.Rows)+1)
|
||||
appendRow := func(row *business.AnalyticsRow, summary bool) {
|
||||
platform, name, owner, kind := business.PlatformName(row.SourceDB), row.Name, row.BusinessName(), "—"
|
||||
if row.PromoteType != nil {
|
||||
if *row.PromoteType == 1 {
|
||||
kind = "公会"
|
||||
} else if *row.PromoteType == 0 {
|
||||
kind = "个人"
|
||||
}
|
||||
}
|
||||
if summary {
|
||||
platform, name, owner, kind = "全部", "合计(有效端 "+strconv.FormatInt(page.EffectiveCount, 10)+")", "—", "—"
|
||||
}
|
||||
rows = append(rows, []ledgerCell{textCell(platform), textCell(name), textCell(owner), textCell(kind), numericCell(strconv.FormatInt(row.Counts.Register, 10)), numericCell(strconv.FormatInt(row.Counts.Active, 10)), numericCell(row.Pay), numericCell(strconv.FormatInt(row.Counts.Pay, 10)), numericCell(strconv.FormatInt(row.Counts.NewPay, 10)), textCell(row.PayRate + "%")})
|
||||
}
|
||||
for _, row := range page.Rows {
|
||||
appendRow(row, false)
|
||||
}
|
||||
if page.Summary != nil {
|
||||
appendRow(page.Summary, true)
|
||||
}
|
||||
return ledgerWorkbook("渠道数据统计", headers, rows)
|
||||
}
|
||||
Reference in New Issue
Block a user