xyxie 1 year ago
parent
commit
b490f623ef

+ 7 - 2
controllers/statistic_report.go

@@ -6402,6 +6402,7 @@ func (this *StatisticReportController) UnusualRenewCompanyList() {
 
 	// 按月分组
 	monthMap := make(map[string]int)
+	monthCompanyMap := make(map[string]struct{})
 	monthList := make([]string, 0)
 	tmpDate, _ := time.ParseInLocation(utils.FormatYearMonthDate, startDate, time.Local)
 	tmpEndDate, _ := time.ParseInLocation(utils.FormatYearMonthDate, endDate, time.Local)
@@ -6449,8 +6450,12 @@ func (this *StatisticReportController) UnusualRenewCompanyList() {
 	if len(list) > 0 {
 		for _, v := range list {
 			t := v.ModifyTime.Format(utils.FormatYearMonthDate)
-			if num, ok := monthMap[t]; ok {
-				monthMap[t] = num + 1
+			name := fmt.Sprintf("%s_%d", t, v.CompanyId)
+			if _, ok := monthCompanyMap[name]; !ok {
+				if num, ok1 := monthMap[t]; ok1 {
+					monthMap[t] = num + 1
+				}
+				monthCompanyMap[name] = struct{}{}
 			}
 		}
 	}

+ 1 - 1
models/company/company_renewal_record.go

@@ -44,7 +44,7 @@ WHERE
     AND a.source = 1 
 	AND a.product_id = ?
 GROUP BY
-	a.seller_id;
+	a.share_seller_id;
 `
 	_, err = o.Raw(sql, startDate, endDate, productId).QueryRows(&list)
 

+ 3 - 2
services/statistic_report/unusual_renew_company.go

@@ -136,7 +136,8 @@ func getUnusualRenewSectionData(productId int, startDate, endDate time.Time, ch
 			if !ok {
 				tmp = 0
 			}
-			unusualRenewMap[v.ShareSellerId] = tmp + 1
+			companyIdSlice := strings.Split(v.CompanyIds, ",")
+			unusualRenewMap[v.ShareSellerId] = tmp + len(companyIdSlice)
 
 			// 客户id
 			tmpCompanyIdList2, ok := unusualRenewCompanyIdListMap[v.ShareSellerId]
@@ -145,7 +146,7 @@ func getUnusualRenewSectionData(productId int, startDate, endDate time.Time, ch
 			}
 			unusualRenewCompanyIdListMap[v.ShareSellerId] = append(tmpCompanyIdList2, fmt.Sprint(v.CompanyIds))
 
-			unusualRenewCompanyTotal++
+			unusualRenewCompanyTotal += len(companyIdSlice)
 		}
 
 		for sellerId, tmpCompanyIdList := range unusualRenewCompanyIdListMap {