fix
This commit is contained in:
@@ -39,6 +39,7 @@ type StatisticsApplicationServiceImpl struct {
|
|||||||
|
|
||||||
// 其他领域仓储
|
// 其他领域仓储
|
||||||
userRepo userRepos.UserRepository
|
userRepo userRepos.UserRepository
|
||||||
|
enterpriseInfoRepo userRepos.EnterpriseInfoRepository
|
||||||
apiCallRepo apiRepos.ApiCallRepository
|
apiCallRepo apiRepos.ApiCallRepository
|
||||||
walletTransactionRepo financeRepos.WalletTransactionRepository
|
walletTransactionRepo financeRepos.WalletTransactionRepository
|
||||||
rechargeRecordRepo financeRepos.RechargeRecordRepository
|
rechargeRecordRepo financeRepos.RechargeRecordRepository
|
||||||
@@ -58,6 +59,7 @@ func NewStatisticsApplicationService(
|
|||||||
reportRepo repositories.StatisticsReportRepository,
|
reportRepo repositories.StatisticsReportRepository,
|
||||||
dashboardRepo repositories.StatisticsDashboardRepository,
|
dashboardRepo repositories.StatisticsDashboardRepository,
|
||||||
userRepo userRepos.UserRepository,
|
userRepo userRepos.UserRepository,
|
||||||
|
enterpriseInfoRepo userRepos.EnterpriseInfoRepository,
|
||||||
apiCallRepo apiRepos.ApiCallRepository,
|
apiCallRepo apiRepos.ApiCallRepository,
|
||||||
walletTransactionRepo financeRepos.WalletTransactionRepository,
|
walletTransactionRepo financeRepos.WalletTransactionRepository,
|
||||||
rechargeRecordRepo financeRepos.RechargeRecordRepository,
|
rechargeRecordRepo financeRepos.RechargeRecordRepository,
|
||||||
@@ -73,6 +75,7 @@ func NewStatisticsApplicationService(
|
|||||||
reportRepo: reportRepo,
|
reportRepo: reportRepo,
|
||||||
dashboardRepo: dashboardRepo,
|
dashboardRepo: dashboardRepo,
|
||||||
userRepo: userRepo,
|
userRepo: userRepo,
|
||||||
|
enterpriseInfoRepo: enterpriseInfoRepo,
|
||||||
apiCallRepo: apiCallRepo,
|
apiCallRepo: apiCallRepo,
|
||||||
walletTransactionRepo: walletTransactionRepo,
|
walletTransactionRepo: walletTransactionRepo,
|
||||||
rechargeRecordRepo: rechargeRecordRepo,
|
rechargeRecordRepo: rechargeRecordRepo,
|
||||||
@@ -2333,9 +2336,19 @@ func (s *StatisticsApplicationServiceImpl) AdminGetConsumptionDomainStatistics(c
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
todayConsumption := float64(0)
|
// 获取今日消费金额
|
||||||
|
today := time.Now().Truncate(24 * time.Hour)
|
||||||
|
tomorrow := today.Add(24 * time.Hour)
|
||||||
|
todayConsumption, err := s.walletTransactionRepo.GetSystemAmountByDateRange(ctx, today, tomorrow)
|
||||||
|
if err != nil {
|
||||||
|
s.logger.Error("获取今日消费金额失败", zap.Error(err))
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取指定时间范围内的消费金额
|
||||||
|
rangeConsumption := float64(0)
|
||||||
if !startTime.IsZero() && !endTime.IsZero() {
|
if !startTime.IsZero() && !endTime.IsZero() {
|
||||||
todayConsumption, err = s.walletTransactionRepo.GetSystemAmountByDateRange(ctx, startTime, endTime)
|
rangeConsumption, err = s.walletTransactionRepo.GetSystemAmountByDateRange(ctx, startTime, endTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Error("获取指定时间范围消费金额失败", zap.Error(err))
|
s.logger.Error("获取指定时间范围消费金额失败", zap.Error(err))
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -2356,7 +2369,8 @@ func (s *StatisticsApplicationServiceImpl) AdminGetConsumptionDomainStatistics(c
|
|||||||
|
|
||||||
result := map[string]interface{}{
|
result := map[string]interface{}{
|
||||||
"total_consumption": totalConsumption,
|
"total_consumption": totalConsumption,
|
||||||
"range_consumption": todayConsumption,
|
"today_consumption": todayConsumption,
|
||||||
|
"range_consumption": rangeConsumption,
|
||||||
"consumption_trend": consumptionTrend,
|
"consumption_trend": consumptionTrend,
|
||||||
"period": period,
|
"period": period,
|
||||||
"start_date": startDate,
|
"start_date": startDate,
|
||||||
@@ -2399,9 +2413,19 @@ func (s *StatisticsApplicationServiceImpl) AdminGetRechargeDomainStatistics(ctx
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
todayRecharge := float64(0)
|
// 获取今日充值金额
|
||||||
|
today := time.Now().Truncate(24 * time.Hour)
|
||||||
|
tomorrow := today.Add(24 * time.Hour)
|
||||||
|
todayRecharge, err := s.rechargeRecordRepo.GetSystemAmountByDateRange(ctx, today, tomorrow)
|
||||||
|
if err != nil {
|
||||||
|
s.logger.Error("获取今日充值金额失败", zap.Error(err))
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取指定时间范围内的充值金额
|
||||||
|
rangeRecharge := float64(0)
|
||||||
if !startTime.IsZero() && !endTime.IsZero() {
|
if !startTime.IsZero() && !endTime.IsZero() {
|
||||||
todayRecharge, err = s.rechargeRecordRepo.GetSystemAmountByDateRange(ctx, startTime, endTime)
|
rangeRecharge, err = s.rechargeRecordRepo.GetSystemAmountByDateRange(ctx, startTime, endTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Error("获取指定时间范围充值金额失败", zap.Error(err))
|
s.logger.Error("获取指定时间范围充值金额失败", zap.Error(err))
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -2422,7 +2446,8 @@ func (s *StatisticsApplicationServiceImpl) AdminGetRechargeDomainStatistics(ctx
|
|||||||
|
|
||||||
result := map[string]interface{}{
|
result := map[string]interface{}{
|
||||||
"total_recharge": totalRecharge,
|
"total_recharge": totalRecharge,
|
||||||
"range_recharge": todayRecharge,
|
"today_recharge": todayRecharge,
|
||||||
|
"range_recharge": rangeRecharge,
|
||||||
"recharge_trend": rechargeTrend,
|
"recharge_trend": rechargeTrend,
|
||||||
"period": period,
|
"period": period,
|
||||||
"start_date": startDate,
|
"start_date": startDate,
|
||||||
@@ -2653,25 +2678,32 @@ func (s *StatisticsApplicationServiceImpl) AdminGetTodayCertifiedEnterprises(ctx
|
|||||||
completedCertifications = completedCertifications[:limit]
|
completedCertifications = completedCertifications[:limit]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户信息
|
// 直接从企业信息表获取数据
|
||||||
var enterprises []map[string]interface{}
|
var enterprises []map[string]interface{}
|
||||||
for _, cert := range completedCertifications {
|
for _, cert := range completedCertifications {
|
||||||
|
// 获取企业信息
|
||||||
|
enterpriseInfo, err := s.enterpriseInfoRepo.GetByUserID(ctx, cert.UserID)
|
||||||
|
if err != nil {
|
||||||
|
s.logger.Warn("获取企业信息失败", zap.String("user_id", cert.UserID), zap.Error(err))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户基本信息(仅需要用户名)
|
||||||
user, err := s.userRepo.GetByID(ctx, cert.UserID)
|
user, err := s.userRepo.GetByID(ctx, cert.UserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Warn("获取用户信息失败", zap.String("user_id", cert.UserID), zap.Error(err))
|
s.logger.Warn("获取用户信息失败", zap.String("user_id", cert.UserID), zap.Error(err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
enterpriseName := ""
|
|
||||||
if user.EnterpriseInfo != nil {
|
|
||||||
enterpriseName = user.EnterpriseInfo.CompanyName
|
|
||||||
}
|
|
||||||
|
|
||||||
enterprise := map[string]interface{}{
|
enterprise := map[string]interface{}{
|
||||||
"id": cert.ID,
|
"id": cert.ID,
|
||||||
"user_id": cert.UserID,
|
"user_id": cert.UserID,
|
||||||
"username": user.Username,
|
"username": user.Username,
|
||||||
"enterprise_name": enterpriseName,
|
"enterprise_name": enterpriseInfo.CompanyName,
|
||||||
|
"legal_person_name": enterpriseInfo.LegalPersonName,
|
||||||
|
"legal_person_phone": enterpriseInfo.LegalPersonPhone,
|
||||||
|
"unified_social_code": enterpriseInfo.UnifiedSocialCode,
|
||||||
|
"enterprise_address": enterpriseInfo.EnterpriseAddress,
|
||||||
"certified_at": cert.CompletedAt.Format(time.RFC3339),
|
"certified_at": cert.CompletedAt.Format(time.RFC3339),
|
||||||
}
|
}
|
||||||
enterprises = append(enterprises, enterprise)
|
enterprises = append(enterprises, enterprise)
|
||||||
|
|||||||
@@ -925,6 +925,7 @@ func NewContainer() *Container {
|
|||||||
reportRepo domain_statistics_repo.StatisticsReportRepository,
|
reportRepo domain_statistics_repo.StatisticsReportRepository,
|
||||||
dashboardRepo domain_statistics_repo.StatisticsDashboardRepository,
|
dashboardRepo domain_statistics_repo.StatisticsDashboardRepository,
|
||||||
userRepo domain_user_repo.UserRepository,
|
userRepo domain_user_repo.UserRepository,
|
||||||
|
enterpriseInfoRepo domain_user_repo.EnterpriseInfoRepository,
|
||||||
apiCallRepo domain_api_repo.ApiCallRepository,
|
apiCallRepo domain_api_repo.ApiCallRepository,
|
||||||
walletTransactionRepo domain_finance_repo.WalletTransactionRepository,
|
walletTransactionRepo domain_finance_repo.WalletTransactionRepository,
|
||||||
rechargeRecordRepo domain_finance_repo.RechargeRecordRepository,
|
rechargeRecordRepo domain_finance_repo.RechargeRecordRepository,
|
||||||
@@ -940,6 +941,7 @@ func NewContainer() *Container {
|
|||||||
reportRepo,
|
reportRepo,
|
||||||
dashboardRepo,
|
dashboardRepo,
|
||||||
userRepo,
|
userRepo,
|
||||||
|
enterpriseInfoRepo,
|
||||||
apiCallRepo,
|
apiCallRepo,
|
||||||
walletTransactionRepo,
|
walletTransactionRepo,
|
||||||
rechargeRecordRepo,
|
rechargeRecordRepo,
|
||||||
|
|||||||
Reference in New Issue
Block a user