This commit is contained in:
2026-01-19 17:01:10 +08:00
parent fbaab6a45c
commit c9b83926a5
3 changed files with 35 additions and 4 deletions

View File

@@ -257,6 +257,7 @@ func (l *AdminGetDashboardStatisticsLogic) calculateProfitStatistics(todayStart,
// 今日API调用成本
todayApiCost := 0.0
if l.svcCtx.TianyuanapiCallLogService != nil {
logx.Infof("开始获取今日API调用成本时间范围: %v 到 %v", todayStart, todayEnd)
todayApiStats, err := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{
StartDate: todayStart,
EndDate: todayEnd,
@@ -265,7 +266,10 @@ func (l *AdminGetDashboardStatisticsLogic) calculateProfitStatistics(todayStart,
logx.Errorf("获取今日API调用成本失败: %v", err)
} else {
todayApiCost = todayApiStats.TotalCost
logx.Infof("今日API调用成本统计完成总成本: %f", todayApiCost)
}
} else {
logx.Errorf("TianyuanapiCallLogService 未初始化无法获取API调用成本")
}
// 今日利润 = 营收 - 佣金 - 返利 - 税务成本 - API调用成本 + 提现收税
stats.TodayProfit = todayRevenue - todayCommission - todayRebate - todayCompanyTax - todayApiCost + todayTaxIncome
@@ -313,6 +317,7 @@ func (l *AdminGetDashboardStatisticsLogic) calculateProfitStatistics(todayStart,
// 当月API调用成本
monthApiCost := 0.0
if l.svcCtx.TianyuanapiCallLogService != nil {
logx.Infof("开始获取当月API调用成本时间范围: %v 到 %v", monthStart, monthEnd)
monthApiStats, err := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{
StartDate: monthStart,
EndDate: monthEnd,
@@ -321,7 +326,10 @@ func (l *AdminGetDashboardStatisticsLogic) calculateProfitStatistics(todayStart,
logx.Errorf("获取当月API调用成本失败: %v", err)
} else {
monthApiCost = monthApiStats.TotalCost
logx.Infof("当月API调用成本统计完成总成本: %f", monthApiCost)
}
} else {
logx.Errorf("TianyuanapiCallLogService 未初始化无法获取API调用成本")
}
// 当月利润
stats.MonthProfit = monthRevenue - monthCommission - monthRebate - monthCompanyTax - monthApiCost + monthTaxIncome
@@ -369,12 +377,16 @@ func (l *AdminGetDashboardStatisticsLogic) calculateProfitStatistics(todayStart,
// 总API调用成本
totalApiCost := 0.0
if l.svcCtx.TianyuanapiCallLogService != nil {
logx.Infof("开始获取总API调用成本无时间限制")
totalApiStats, err := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{})
if err != nil {
logx.Errorf("获取总API调用成本失败: %v", err)
} else {
totalApiCost = totalApiStats.TotalCost
logx.Infof("总API调用成本统计完成总成本: %f", totalApiCost)
}
} else {
logx.Errorf("TianyuanapiCallLogService 未初始化无法获取API调用成本")
}
// 总利润
stats.TotalProfit = totalRevenue - totalCommission - totalRebate - totalCompanyTax - totalApiCost + totalTaxIncome