Kaynağa Gözat

修改汇总逻辑

xyxie 1 yıl önce
ebeveyn
işleme
8da77a2012
1 değiştirilmiş dosya ile 23 ekleme ve 5 silme
  1. 23 5
      controllers/statistic_report.go

+ 23 - 5
controllers/statistic_report.go

@@ -6301,7 +6301,8 @@ func (this *StatisticReportController) UnusualRenewCompanyStatistics() {
 		List:        list,
 		SummaryList: summaryList,
 	}
-
+	unusualRenewTotal := make(map[int]int)
+	adminDataUnusualRenewTotal := make(map[int]int)
 	// 每日期组数据的汇总客户id
 	companyIdIndexMap := make(map[int][]string)
 	for k, v := range subAdmins {
@@ -6315,22 +6316,26 @@ func (this *StatisticReportController) UnusualRenewCompanyStatistics() {
 				EndDate:         adminData.EndDate,
 			})
 
+			unusualRenewTotal[index] = unusualRenewTotal[index] + adminData.UnusualRenewMap[v.AdminId]
+
 			if adminData.UnusualRenewIdMap[v.AdminId] != `` {
 				tmpCompanyIdList, ok := companyIdIndexMap[index]
 				if !ok {
 					tmpCompanyIdList = make([]string, 0)
 				}
 				companyIdIndexMap[index] = append(tmpCompanyIdList, adminData.UnusualRenewIdMap[v.AdminId])
+				adminDataUnusualRenewTotal[index] = adminData.FormalCompanyTotal
 			}
 
 			if k == 0 {
-				unusualRate := ``
+				/*unusualRate := ``
 				if adminData.UnusualRenewTotal > 0 && adminData.FormalCompanyTotal > 0 {
 					unusualRate = decimal.NewFromInt(int64(adminData.UnusualRenewTotal)*100).Div(decimal.NewFromInt(int64(adminData.FormalCompanyTotal))).Round(2).String() + `%`
-				}
+				}*/
+
 				summaryList = append(summaryList, statistic_report.SummaryUnusualRenewRecordNum{
-					UnusualRenewNum: adminData.UnusualRenewTotal,
-					UnusualRate:     unusualRate,
+					UnusualRenewNum: 0,
+					UnusualRate:     "0",
 				})
 			}
 		}
@@ -6343,6 +6348,19 @@ func (this *StatisticReportController) UnusualRenewCompanyStatistics() {
 
 	// 汇总数据
 	for index, _ := range summaryList {
+		totalSum, ok1 := unusualRenewTotal[index]
+		if ok1 {
+			summaryList[index].UnusualRenewNum = totalSum
+			unusualRate := ``
+			formalCompanyTotal, ok2 := adminDataUnusualRenewTotal[index]
+			if ok2 {
+				if totalSum > 0 && formalCompanyTotal > 0 {
+					unusualRate = decimal.NewFromInt(int64(totalSum)*100).Div(decimal.NewFromInt(int64(formalCompanyTotal))).Round(2).String() + `%`
+					summaryList[index].UnusualRate = unusualRate
+				}
+			}
+
+		}
 		tmpCompanyIdList, ok := companyIdIndexMap[index]
 		if ok {
 			summaryList[index].UnusualRenewIds = strings.Join(tmpCompanyIdList, ",")