Browse Source

no message

xingzai 1 year ago
parent
commit
74a41bf3a7
2 changed files with 38 additions and 28 deletions
  1. 7 28
      controllers/statistic_company_merge.go
  2. 31 0
      services/company_ascribe.go

+ 7 - 28
controllers/statistic_company_merge.go

@@ -77,11 +77,7 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 	if dataType != "续约客户" {
 		packageDifference = "" // 只有续约客户才会有值,过滤前端传过来的脏数据
 	}
-	//if startDate == "" || endDate == "" {
-	//	br.Msg = "获取失败,开始日期或结束日期未传"
-	//	br.ErrMsg = "获取失败,开始日期或结束日期未传"
-	//	return
-	//}
+
 	if startDate == "" {
 		startDate = "2015-01-01"
 	}
@@ -166,7 +162,6 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 		}
 		parsAscribeRai = append(parsAscribeRai, noRenewedcompanyContractIds)
 	}
-	fmt.Println(noRenewedcompanyContractIds)
 	//归因ID CRM 13.9
 	if companyAscribeId > 0 {
 		var conditionAscribe string
@@ -189,8 +184,6 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 		}
 		conditionAscribRai += ` AND a.company_contract_id IN (` + utils.GetOrmInReplace(len(noRenewedcompanyContractIds)) + `)`
 		parsAscribeRai = append(parsAscribeRai, noRenewedcompanyContractIds)
-
-		fmt.Println(parsAscribeRai)
 	}
 
 	condition += ` AND c.product_id = ?   AND  a.status = 1 `
@@ -292,15 +285,6 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 		condition1 := condition
 		pars1 := pars
 
-		//endDateTime, err := time.Parse(utils.FormatDate, endDate)
-		//if err != nil {
-		//	br.Msg = "结束时间异常"
-		//	br.ErrMsg = "获取失败,Err:" + err.Error()
-		//	return
-		//}
-		////选择的日期加一天的原因是因为:筛选条件是截止到时分秒的,如果要把选择的这一天也统计进去,那么需要在选择的结束日期基础上加上一天
-		//tryOutEndDate := endDateTime.AddDate(0, 0, 1).Format(utils.FormatDate)
-
 		condition1 += ` AND a.end_date >= ? AND a.end_date  <= ? `
 		pars1 = append(pars1, startDate, endDate)
 		//condition1 += ` AND a.operation = ? `
@@ -370,13 +354,6 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 				total = notRenewalNotTryOut
 			}
 
-			//total, err := models.GetIncrementalCompanyProductCountByOperationRecord(condition1, pars1)
-			//if err != nil && err.Error() != utils.ErrNoRow() {
-			//	br.Msg = "获取失败"
-			//	br.ErrMsg = "获取失败,Err:" + err.Error()
-			//	return
-			//}
-
 			//分页total单独计算
 			total, err = company.GetIncrementalRenewalCompanyProductMergeCount(condition1, pars1)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -394,18 +371,20 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 			}
 
 			var ascribecompanyIds []int
+			var companyContractIds []int
 			for _, item := range tmpList {
 				//endDateTime, _ := time.Parse(utils.FormatDateTime, item.CreateTime)
 				//item.EndDate = endDateTime.Format(utils.FormatDate)
 				ascribecompanyIds = append(ascribecompanyIds, item.CompanyId)
+				companyContractIds = append(companyContractIds, item.CompanyContractId)
 			}
-			//归因标签
-			mapGetCompanyAscribeContent, mapContent := services.GetCompanyAscribeContentMap(ascribecompanyIds)
+			//合同归因标签
+			mapGetCompanyAscribeContent, mapContent := services.GetCompanyContractAscribeContentMap(companyContractIds)
 			mapNoRenewedNote := services.GetCompanyNoRenewedNoteMap(ascribecompanyIds)
 
 			for _, item := range tmpList {
-				item.AscribeContent = mapGetCompanyAscribeContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
-				item.Content = mapContent[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
+				item.AscribeContent = mapGetCompanyAscribeContent[item.CompanyContractId]
+				item.Content = mapContent[item.CompanyContractId]
 				item.IsShowNoRenewedNote = mapNoRenewedNote[fmt.Sprint("CID_", item.CompanyId, "PID_", item.ProductId)]
 			}
 

+ 31 - 0
services/company_ascribe.go

@@ -67,3 +67,34 @@ func GetCompanyNoRenewedNoteMap(companyIds []int) (mapResp map[string]bool) {
 	}
 	return
 }
+
+// 处理公司合同归因展示
+func GetCompanyContractAscribeContentMap(companyContractIds []int) (mapResp map[int]string, mapCountResp map[int]string) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err:", err)
+			go alarm_msg.SendAlarmMsg(" 处理公司归因展示失败 GetCompanyContractAscribeContentMap,Err:"+err.Error(), 3)
+		}
+	}()
+	lenArr := len(companyContractIds)
+	if lenArr == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND company_contract_id IN (` + utils.GetOrmInReplace(len(companyContractIds)) + `)`
+	pars = append(pars, companyContractIds)
+	list, e := company.GetCompanyContractNoRenewedAscribeList(condition, pars, 0, 0)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyNoRenewedAscribeList, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]string, 0)
+	mapCountResp = make(map[int]string, 0)
+	for _, v := range list {
+		mapResp[v.CompanyContractId] = v.AscribeContent
+		mapCountResp[v.CompanyContractId] = v.Content
+	}
+	return
+}