浏览代码

no message

zhangchuanxing 2 周之前
父节点
当前提交
c6e0e3f2b7
共有 1 个文件被更改,包括 41 次插入18 次删除
  1. 41 18
      controllers/statistic/rai_data_summary.go

+ 41 - 18
controllers/statistic/rai_data_summary.go

@@ -136,8 +136,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	//确认不续约、到期合同部分的数据
 	var conditionEnd string
 	var parsEnd []interface{}
-	conditionEnd = " AND  a.product_id = 2  AND  a.status = 1  AND  a.end_date >= ?  AND  a.end_date <= ? "
-	parsEnd = append(parsEnd, startDate, endDate)
+	conditionEnd = " AND  a.product_id = 2  AND  a.status = 1  AND  a.end_date >= ?  AND  a.end_date <= ? AND  a.end_date <= ? "
+	parsEnd = append(parsEnd, startDate, endDate, time.Now().Format(utils.FormatDate))
 	listEndData, err := statistic_report.GetRaiDataSummaryList(conditionEnd, parsEnd)
 	if err != nil {
 		br.Msg = "获取数据信息失败"
@@ -328,6 +328,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 			confirmedNoRenewalContractNum[keyMapTtoal]++
 		}
 	}
+	fmt.Println(confirmedNoRenewalContractNum)
 
 	listFmsData, err := fms.GetContractRegisterListByStartDate(startDate, endDate)
 	if err != nil {
@@ -841,7 +842,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 			pars = append(pars, sellerId)
 		}
 
-		condition += ` AND  a.status = 1  AND a.start_date >= ?  AND a.start_date <= ?   AND a.end_date < ? `
+		condition += ` AND  a.status = 1  AND a.end_date >= ?  AND a.end_date <= ?   AND a.end_date < ? `
 		pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
 
 		total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
@@ -895,10 +896,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 			pars = append(pars, sellerId)
 		}
 
-		condition += ` AND  a.status = 1  AND a.start_date >= ?  AND a.start_date <= ?  `
+		condition += ` AND  a.status = 1  AND a.inherit_end_date >= ?  AND a.inherit_end_date <= ?  AND  inherit_company_contract_id > 0  `
 		pars = append(pars, startDate, endDate)
-		condition += `  AND a.rai_contract_type = ? `
-		pars = append(pars, "续约合同")
 
 		total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
 		if err != nil && err.Error() != utils.ErrNoRow() {
@@ -946,12 +945,17 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		}
 
 	case "续约率":
+		var conditionEnd string
+		var parsEnd []interface{}
 		if sellerId > 0 {
 			condition += ` AND a.seller_id_last = ? `
 			pars = append(pars, sellerId)
+
+			conditionEnd += ` AND a.seller_id_last = ? `
+			parsEnd = append(pars, sellerId)
 		}
 
-		condition += " AND  a.product_id = 2  AND  a.status = 1  AND  a.start_date >= ?  AND  a.start_date <= ? "
+		condition += ` AND  a.status = 1  AND a.inherit_end_date >= ?  AND a.inherit_end_date <= ?  AND  inherit_company_contract_id > 0  `
 		pars = append(pars, startDate, endDate)
 		listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
 		if err != nil {
@@ -959,6 +963,17 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 			br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
 			return
 		}
+
+		//到期合同数据
+		conditionEnd += ` AND  a.status = 1  AND a.end_date >= ?  AND a.end_date <= ?   AND a.end_date < ? `
+		parsEnd = append(parsEnd, startDate, endDate, time.Now().Format(utils.FormatDate))
+		listEndData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
+		if err != nil {
+			br.Msg = "获取数据信息失败"
+			br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
+			return
+		}
+
 		var renewedContractMoney float64   // 续约金额
 		var renewedContractCompany float64 // 续约客户数
 		maprenewedContractCompany := make(map[int]bool)
@@ -973,13 +988,21 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 				renewedContractCompany++
 				maprenewedContractCompany[v.CompanyId] = true
 			}
-			startDateTime := utils.StrDateToDate(v.StartDate)
-			if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
-				expiredContractMoney += v.Money
-				if !mapexpiredContractCompany[v.CompanyId] {
-					expiredContractCompany++
-					mapexpiredContractCompany[v.CompanyId] = true
-				}
+			//startDateTime := utils.StrDateToDate(v.StartDate)
+			//if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
+			//	expiredContractMoney += v.Money
+			//	if !mapexpiredContractCompany[v.CompanyId] {
+			//		expiredContractCompany++
+			//		mapexpiredContractCompany[v.CompanyId] = true
+			//	}
+			//}
+		}
+
+		for _, v := range listEndData {
+			expiredContractMoney += v.Money
+			if !mapexpiredContractCompany[v.CompanyId] {
+				expiredContractCompany++
+				mapexpiredContractCompany[v.CompanyId] = true
 			}
 		}
 
@@ -1015,8 +1038,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 			condition += ` AND a.seller_id_last = ? `
 			pars = append(pars, sellerId)
 		}
-		condition += ` AND  a.product_id = 2  AND  a.status = 1  AND a.start_date >= ?  AND a.start_date <= ?   `
-		pars = append(pars, startDate, endDate)
+		condition += ` AND  a.product_id = 2  AND  a.status = 1  AND a.end_date >= ?  AND a.end_date <= ?  AND a.end_date <= ?  `
+		pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
 
 		total, err := company.GetIncrementalNewCompanyProductMergeCount(condition, pars)
 		if err != nil && err.Error() != utils.ErrNoRow() {
@@ -1072,8 +1095,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 			pars = append(pars, sellerId)
 		}
 
-		condition += " AND  a.product_id = 2  AND  a.status = 1  AND  a.start_date >= ?  AND  a.start_date <= ? "
-		pars = append(pars, startDate, endDate)
+		condition += ` AND  a.product_id = 2  AND  a.status = 1  AND  a.start_date >= ?  AND  a.start_date <= ? AND a.end_date <= ?  `
+		pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
 		listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
 		if err != nil {
 			br.Msg = "获取数据信息失败"