Browse Source

Merge branch 'crm/crm_16.7' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 2 weeks ago
parent
commit
76bb9ff96f
1 changed files with 12 additions and 4 deletions
  1. 12 4
      controllers/statistic/rai_data_summary.go

+ 12 - 4
controllers/statistic/rai_data_summary.go

@@ -166,6 +166,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	mapNewContractNum := make(map[string]int)                       // 新签合同(数量)
 	mapExpiredContractMoney := make(map[string]float64)             // 到期合同(金额)
 	mapExpiredContractNum := make(map[string]int)                   // 到期合同(数量)
+	mapExpiredContractCompanyNum := make(map[string]int)            // 到期公司(数量)
 	mapRenewedContractMoney := make(map[string]float64)             // 续约合同(金额)
 	mapRenewedContractNum := make(map[string]int)                   // 续约合同(数量)
 	confirmedNoRenewalContractMoney := make(map[string]float64)     // 确认不续约合同(金额)
@@ -316,7 +317,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	}
 
 	//确认不续约、到期合同部分的数据
-	//mapKeyMapCompanyEndData := make(map[string]bool)
+	mapKeyMapCompanyEndData := make(map[string]bool)
 	//mapKeyMapCompanyNoData := make(map[string]bool)
 	for _, v := range listEndData {
 		if !mapsellerId[v.SellerIdLast] {
@@ -363,6 +364,13 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		//mapKeyMapCompanyEndData[keyMapCompany] = true
 		//}
 
+		//一家公司同一个时间纬度,只统计一次
+		if !mapKeyMapCompanyEndData[keyMapCompany] {
+			mapExpiredContractCompanyNum[keyMap]++
+			mapExpiredContractCompanyNum[keyMapTtoal]++
+			mapKeyMapCompanyEndData[keyMapCompany] = true
+		}
+
 		if mapNoRenewedcompanyContractIds[v.CompanyContractId] { // 确认不续约合同
 			confirmedNoRenewalContractMoney[keyMap] += v.Money
 
@@ -503,10 +511,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 				} else {
 					renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoney[keyMap]/mapExpiredContractMoney[keyMap]*100, 2) + "%"
 				}
-				if mapRenewedContractNum[keyMap] == 0 || mapExpiredContractNum[keyMap] == 0 {
+				if mapRenewedContractNum[keyMap] == 0 || mapExpiredContractCompanyNum[keyMap] == 0 {
 					renewalRateNum = "0%"
 				} else {
-					renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractNum[keyMap])/float64(mapExpiredContractNum[keyMap])*100, 2) + "%"
+					renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractNum[keyMap])/float64(mapExpiredContractCompanyNum[keyMap])*100, 2) + "%"
 				}
 				sellerItem.RenewalRateData = fmt.Sprint(renewalRateMoey, " / ", renewalRateNum)                                                                                          //"续约率(金额/数量)-(数据)"
 				sellerItem.ConfirmedNoRenewalContractData = fmt.Sprint(utils.SubFloatToString(confirmedNoRenewalContractMoney[keyMap], 2), " / ", confirmedNoRenewalContractNum[keyMap]) //"确认不续约合同(金额/数量)-(数据)"
@@ -1011,7 +1019,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 			conditionEnd += ` AND a.seller_id_last  IN (` + sellerId + `) `
 		}
 
-		condition += ` AND  a.status = 1  AND a.inherit_end_date >= ?  AND a.inherit_end_date <= ?  AND  inherit_company_contract_id > 0  `
+		condition += ` AND  a.status = 1  AND a.inherit_end_date >= ?  AND a.inherit_end_date <= ?  AND  inherit_company_contract_id > 0    AND a.rai_contract_type = '续约合同' `
 		pars = append(pars, startDate, endDate)
 		listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
 		if err != nil {