Przeglądaj źródła

Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 2 dni temu
rodzic
commit
5feab5c48c

+ 9 - 50
controllers/cygx/user.go

@@ -2520,14 +2520,14 @@ func (this *UserController) CompanyTableDetail() {
 			endDate += " 23:59:59"
 			condition += ` AND r.create_time <= '` + endDate + `' `
 		}
-		condition += " AND r.source = 'article'  "
+		//condition += " AND r.source = 'article'  "
 		if classType == 1 {
 			condition += " AND art.article_type_id = 0  "
 		} else {
 			condition += " AND art.article_type_id > 0  "
 		}
 		condition += "  ORDER BY r.create_time DESC "
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			total, err = cygx.GetCygxArticleAndYanxuanRecordCount(condition, pars)
 			if err != nil {
@@ -2556,7 +2556,7 @@ func (this *UserController) CompanyTableDetail() {
 			}
 		}
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
@@ -3182,7 +3182,7 @@ func (this *UserController) CompanyExportInteraction() {
 		}
 		condition += ` ORDER BY r.create_time DESC  `
 		var pars []interface{}
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -3199,7 +3199,7 @@ func (this *UserController) CompanyExportInteraction() {
 			}
 		}
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
@@ -3832,10 +3832,9 @@ func (this *UserController) CompanyList() {
 			condition += " AND art.article_type_id > 0  "
 		}
 
-		condition += " AND r.source =  'article' "
 		var pars []interface{}
 		condition += "  ORDER BY r.create_time DESC "
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, startSize, pageSize)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -3865,7 +3864,7 @@ func (this *UserController) CompanyList() {
 		}
 
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
@@ -4776,7 +4775,7 @@ func (this *UserController) CompanyExportInteractionList() {
 		}
 		condition += ` ORDER BY r.create_time DESC  `
 		var pars []interface{}
-		var listRecord []*cygx.CygxArticleAndYanxuanRecordResp
+		var listRecord []*cygx.UserInteraction
 		if isAdminRole {
 			listRecord, err = cygx.GetCygxArticleAndYanxuanRecordRespList(condition, pars, 0, pageSize)
 			if err != nil && err.Error() != utils.ErrNoRow() {
@@ -4793,52 +4792,12 @@ func (this *UserController) CompanyExportInteractionList() {
 			}
 		}
 		//处理查询信息回显
-		list, err = cygxService.HandleArticleAndYanxuanRecordList(listRecord)
+		list, err = cygxService.HandleArticleAndYanxuanRecordList2(listRecord)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
 			return
 		}
-		if len(list) > 0 {
-			var articleIds string
-			mapAricleId := make(map[int]int)
-			mapAricleIndustrialSubjectName := make(map[int]*cygx.ArticleIndustrialSubjectNameResp)
-			for k, v := range list {
-				if v.ArticleId >= utils.SummaryArticleId {
-					list[k].ArticleType = 1
-				} else {
-					list[k].ArticleType = 2
-				}
-				if list[k].PermissionName == "" {
-					list[k].PermissionName = v.CategoryName
-				}
-				if mapAricleId[v.ArticleId] == 0 {
-					articleIds += strconv.Itoa(v.ArticleId) + ","
-					mapAricleId[v.ArticleId] = v.ArticleId
-				}
-			}
-			articleIds = strings.TrimRight(articleIds, ",")
-			if articleIds != "" {
-				listArticleIndustrialSubjectList, err := cygx.GetCygxArticleIndustrialSubjectName(articleIds)
-				if err != nil && err.Error() != utils.ErrNoRow() {
-					br.Msg = "获取信息失败"
-					br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
-					return
-				}
-				if len(listArticleIndustrialSubjectList) > 0 {
-					for _, v := range listArticleIndustrialSubjectList {
-						mapAricleIndustrialSubjectName[v.ArticleId] = v
-					}
-					for k, v := range list {
-						if mapAricleIndustrialSubjectName[v.ArticleId] != nil {
-							fmt.Println(mapAricleIndustrialSubjectName[v.ArticleId].IndustryName)
-							list[k].IndustryName = mapAricleIndustrialSubjectName[v.ArticleId].IndustryName
-							list[k].SubjectNameStr = mapAricleIndustrialSubjectName[v.ArticleId].SubjectNameStr
-						}
-					}
-				}
-			}
-		}
 	} else if source == 2 {
 		if classType == 1 {
 			condition += "  AND  a.chart_permission_id  != 31 "

+ 64 - 18
controllers/statistic/rai_data_summary.go

@@ -232,13 +232,15 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	for _, v := range companyConfirmList {
 		mapNoRenewedcompanyContractIds[v.CompanyContractId] = true
 	}
-
+	mapRenewedContractId := make(map[int]bool)                      // 出现在续约客户的合同
 	mapAddTrialNum := make(map[string]float64)                      // 新增试用-(数据)
 	mapNewContractMoney := make(map[string]float64)                 // 新签合同(金额)
 	mapNewContractNum := make(map[string]int)                       // 新签合同(数量)
 	mapExpiredContractMoney := make(map[string]float64)             // 到期合同(金额)
+	mapExpiredContractMoney2 := make(map[string]float64)            // 到期合同(金额)(处理永续合同使用)
 	mapExpiredContractNum := make(map[string]int)                   // 到期合同(数量)
 	mapExpiredContractCompanyNum := make(map[string]int)            // 到期公司(数量)
+	mapExpiredContractCompanyNum2 := make(map[string]int)           // 到期公司(数量)处理永续合同使用)
 	mapRenewedContractMoney := make(map[string]float64)             // 续约合同(金额)
 	mapRenewedContractNum := make(map[string]int)                   // 续约合同(数量)
 	mapRenewedContractCompanyNum := make(map[string]int)            // 续约公司(数量)
@@ -255,8 +257,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	mapNewContractMoneyServer := make(map[string]float64)              // 新签合同(金额)
 	mapNewContractNumServer := make(map[string]int)                    // 新签合同(数量)
 	mapExpiredContractMoneyServer := make(map[string]float64)          // 到期合同(金额)
+	mapExpiredContractMoneyServer2 := make(map[string]float64)         // 到期合同(金额)(处理永续合同使用)
 	mapExpiredContractNumServer := make(map[string]int)                // 到期合同(数量)_服务组
 	mapExpiredContractCompanyNumServer := make(map[string]int)         // 到期公司(数量)_服务组
+	mapExpiredContractCompanyNumServer2 := make(map[string]int)        // 到期公司(数量)_服务组
 	mapRenewedContractMoneyServer := make(map[string]float64)          // 续约合同(金额)_服务组
 	mapRenewedContractNumServer := make(map[string]int)                // 续约合同(数量)_服务组
 	mapRenewedContractCompanyNumServer := make(map[string]int)         // 续约公司(数量)_服务组
@@ -375,12 +379,16 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 
 	//续约部分的数据(服务组)
 	for _, v := range listInheritData {
+
 		if len(serviceAdminIdArr) > 0 && !utils.InArrayByStr(serviceAdminIdArr, strconv.Itoa(v.ShareSellerIdInit)) {
 			continue
 		}
 		if !mapsellerService[v.ShareSellerIdInit] {
 			continue
 		}
+		//if v.Status != "永续" || v.ContractType != "打分派点" {
+		//	mapRenewedContractId[v.CompanyContractId] = true
+		//}
 		yearStr := getYearStar(utils.StrDateToDate(v.InheritEndDate), dataType, isCustomizeDate)
 
 		keyMap = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdInit)
@@ -436,6 +444,12 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		mapExpiredContractMoney[keyMap] += v.Money
 		mapExpiredContractMoney[keyMapTtoal] += v.Money
 
+		//一份合同如果属于打分派点,并且当前状态是永续,同时还不属于续约合同,那就加在分子里面,如果是自定义的也可以进展示
+		if v.Status == "永续" && v.ContractType == "打分派点" && !mapRenewedContractId[v.CompanyContractId] && v.RaiCountShowType != -1 {
+			mapExpiredContractMoney2[keyMap] += v.Money
+			mapExpiredContractMoney2[keyMapTtoal] += v.Money
+		}
+
 		//一家公司同一个时间纬度,只统计一次
 		mapExpiredContractNum[keyMap]++
 		mapExpiredContractNum[keyMapTtoal]++
@@ -443,10 +457,16 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		//一家公司同一个时间纬度,只统计一次
 		if !mapKeyMapCompanyEndData[keyMapCompany] {
 			mapExpiredContractCompanyNum[keyMap]++
+			if v.Status == "永续" && v.ContractType == "打分派点" && !mapRenewedContractId[v.CompanyContractId] && v.RaiCountShowType != -1 {
+				mapExpiredContractCompanyNum2[keyMap]++
+			}
 			mapKeyMapCompanyEndData[keyMapCompany] = true
 		}
 		if !mapKeyMapCompanyEndDataTotal[keyMapCompanyTotal] { //同一家共公司,在某个时段的多分合同下有不同的销售进行兼容
 			mapExpiredContractCompanyNum[keyMapTtoal]++
+			if v.Status == "永续" && v.ContractType == "打分派点" && !mapRenewedContractId[v.CompanyContractId] && v.RaiCountShowType != -1 {
+				mapExpiredContractCompanyNum2[keyMapCompanyTotal]++
+			}
 			mapKeyMapCompanyEndDataTotal[keyMapCompanyTotal] = true
 		}
 
@@ -484,6 +504,13 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		//到期合同数据
 		mapExpiredContractMoneyServer[keyMap] += v.Money
 		mapExpiredContractMoneyServer[keyMapTtoal] += v.Money
+
+		//一份合同如果属于打分派点,并且当前状态是永续,同时还不属于续约合同,那就加在分子里面,如果是自定义的也可以进展示
+		if v.Status == "永续" && v.ContractType == "打分派点" && !mapRenewedContractId[v.CompanyContractId] && v.RaiCountShowType != -1 {
+			mapExpiredContractMoneyServer2[keyMap] += v.Money
+			mapExpiredContractMoneyServer2[keyMapTtoal] += v.Money
+		}
+
 		mapExpiredContractNumServer[keyMap]++
 		mapExpiredContractNumServer[keyMapTtoal]++
 
@@ -491,6 +518,11 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		if !mapKeyMapCompanyEndData[keyMapCompany] {
 			mapExpiredContractCompanyNumServer[keyMap]++
 			mapExpiredContractCompanyNumServer[keyMapTtoal]++
+
+			if v.Status == "永续" && v.ContractType == "打分派点" && !mapRenewedContractId[v.CompanyContractId] && v.RaiCountShowType != -1 {
+				mapExpiredContractCompanyNumServer2[keyMap]++
+				mapExpiredContractCompanyNumServer2[keyMapTtoal]++
+			}
 			mapKeyMapCompanyEndData[keyMapCompany] = true
 		}
 
@@ -645,6 +677,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	mapSortDateService := make(map[int]float64)
 	mapSortDateDevelop := make(map[int]float64)
 
+	fmt.Println("mapExpiredContractMoneyServer2", mapExpiredContractMoneyServer2)
+
 	for i := startYear; i <= endYear; i++ {
 		for _, Dv := range dataTypeArr {
 			item := new(statistic_report.RaiDataSummaryResp)
@@ -669,10 +703,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 				sellerItem.RenewedContractData = fmt.Sprint(utils.FormatNumberWithCommas(mapRenewedContractMoney[keyMap], 2), " / ", mapRenewedContractNum[keyMap]) // "续约合同(金额/数量)-(数据)"
 				var renewalRateMoey string
 				var renewalRateNum string
-				if mapRenewedContractMoney[keyMap] == 0 || mapExpiredContractMoney[keyMap] == 0 {
+				if mapRenewedContractMoney[keyMap]+mapExpiredContractMoney2[keyMap] == 0 || mapExpiredContractMoney[keyMap] == 0 {
 					renewalRateMoey = "0%"
 				} else {
-					renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoney[keyMap]/mapExpiredContractMoney[keyMap]*100, 2) + "%"
+					renewalRateMoey = utils.SubFloatToString((mapRenewedContractMoney[keyMap]+mapExpiredContractMoney2[keyMap])/mapExpiredContractMoney[keyMap]*100, 2) + "%"
 				}
 				if mapRenewedContractCompanyNum[keyMap] == 0 || mapExpiredContractCompanyNum[keyMap] == 0 {
 					renewalRateNum = "0%"
@@ -779,10 +813,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 				sellerItem.RenewedContractData = fmt.Sprint(utils.FormatNumberWithCommas(mapRenewedContractMoney[keyMapTtoal], 2), " / ", mapRenewedContractNum[keyMapTtoal]) // "续约合同(金额/数量)-(数据)"
 				var renewalRateMoey string
 				var renewalRateNum string
-				if mapRenewedContractMoney[keyMapTtoal] == 0 || mapExpiredContractMoney[keyMapTtoal] == 0 {
+				if mapRenewedContractMoney[keyMapTtoal]+mapExpiredContractMoney2[keyMapTtoal] == 0 || mapExpiredContractMoney[keyMapTtoal] == 0 {
 					renewalRateMoey = "0%"
 				} else {
-					renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoney[keyMapTtoal]/mapExpiredContractMoney[keyMapTtoal]*100, 2) + "%"
+					renewalRateMoey = utils.SubFloatToString((mapRenewedContractMoney[keyMapTtoal]+mapExpiredContractMoney2[keyMapTtoal])/mapExpiredContractMoney[keyMapTtoal]*100, 2) + "%"
 				}
 				if mapRenewedContractCompanyNum[keyMapTtoal] == 0 || mapExpiredContractCompanyNum[keyMapTtoal] == 0 {
 					renewalRateNum = "0%"
@@ -839,15 +873,15 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 				sellerItem.RenewedContractData = fmt.Sprint(utils.FormatNumberWithCommas(mapRenewedContractMoneyServer[keyMap], 2), " / ", mapRenewedContractNumServer[keyMap]) // "续约合同(金额/数量)-(数据)"
 				var renewalRateMoey string
 				var renewalRateNum string
-				if mapRenewedContractMoneyServer[keyMap] == 0 || mapExpiredContractMoneyServer[keyMap] == 0 {
+				if mapRenewedContractMoneyServer[keyMap]+mapExpiredContractMoneyServer2[keyMap] == 0 || mapExpiredContractMoneyServer[keyMap] == 0 {
 					renewalRateMoey = "0%"
 				} else {
-					renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoneyServer[keyMap]/mapExpiredContractMoneyServer[keyMap]*100, 2) + "%"
+					renewalRateMoey = utils.SubFloatToString((mapRenewedContractMoneyServer[keyMap]+mapExpiredContractMoneyServer2[keyMap])/mapExpiredContractMoneyServer[keyMap]*100, 2) + "%"
 				}
-				if mapRenewedContractCompanyNumServer[keyMap] == 0 || mapExpiredContractCompanyNumServer[keyMap] == 0 {
+				if mapRenewedContractCompanyNumServer[keyMap]+mapExpiredContractCompanyNumServer2[keyMap] == 0 || mapExpiredContractCompanyNumServer[keyMap] == 0 {
 					renewalRateNum = "0%"
 				} else {
-					renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractCompanyNumServer[keyMap])/float64(mapExpiredContractCompanyNumServer[keyMap])*100, 2) + "%"
+					renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractCompanyNumServer[keyMap]+mapExpiredContractCompanyNumServer2[keyMap])/float64(mapExpiredContractCompanyNumServer[keyMap])*100, 2) + "%"
 				}
 				sellerItem.RenewalRateData = fmt.Sprint(renewalRateMoey, " / ", renewalRateNum)                                                                                                            //"续约率(金额/数量)-(数据)"
 				sellerItem.ConfirmedNoRenewalContractData = fmt.Sprint(utils.FormatNumberWithCommas(confirmedNoRenewalContractMoneyServer[keyMap], 2), " / ", confirmedNoRenewalContractNumServer[keyMap]) //"确认不续约合同(金额/数量)-(数据)"
@@ -950,15 +984,15 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 				sellerItem.RenewedContractData = fmt.Sprint(utils.FormatNumberWithCommas(mapRenewedContractMoneyServer[keyMapTtoalServer], 2), " / ", mapRenewedContractNumServer[keyMapTtoalServer]) // "续约合同(金额/数量)-(数据)"
 				var renewalRateMoey string
 				var renewalRateNum string
-				if mapRenewedContractMoneyServer[keyMapTtoalServer] == 0 || mapExpiredContractMoneyServer[keyMapTtoalServer] == 0 {
+				if mapRenewedContractMoneyServer[keyMapTtoalServer]+mapExpiredContractMoneyServer2[keyMapTtoalServer] == 0 || mapExpiredContractMoneyServer[keyMapTtoalServer] == 0 {
 					renewalRateMoey = "0%"
 				} else {
-					renewalRateMoey = utils.SubFloatToString(mapRenewedContractMoneyServer[keyMapTtoalServer]/mapExpiredContractMoneyServer[keyMapTtoalServer]*100, 2) + "%"
+					renewalRateMoey = utils.SubFloatToString((mapRenewedContractMoneyServer[keyMapTtoalServer]+mapExpiredContractMoneyServer2[keyMapTtoalServer])/mapExpiredContractMoneyServer[keyMapTtoalServer]*100, 2) + "%"
 				}
-				if mapRenewedContractCompanyNumServer[keyMapTtoalServer] == 0 || mapExpiredContractCompanyNumServer[keyMapTtoalServer] == 0 {
+				if mapRenewedContractCompanyNumServer[keyMapTtoalServer]+mapExpiredContractCompanyNumServer2[keyMapTtoalServer] == 0 || mapExpiredContractCompanyNumServer[keyMapTtoalServer] == 0 {
 					renewalRateNum = "0%"
 				} else {
-					renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractCompanyNumServer[keyMapTtoalServer])/float64(mapExpiredContractCompanyNumServer[keyMapTtoalServer])*100, 2) + "%"
+					renewalRateNum = utils.SubFloatToString(float64(mapRenewedContractCompanyNumServer[keyMapTtoalServer]+mapExpiredContractCompanyNumServer2[keyMapTtoalServer])/float64(mapExpiredContractCompanyNumServer[keyMapTtoalServer])*100, 2) + "%"
 				}
 				sellerItem.RenewalRateData = fmt.Sprint(renewalRateMoey, " / ", renewalRateNum)                                                                                                                                  //"续约率(金额/数量)-(数据)"
 				sellerItem.ConfirmedNoRenewalContractData = fmt.Sprint(utils.FormatNumberWithCommas(confirmedNoRenewalContractMoneyServer[keyMapTtoalServer], 2), " / ", confirmedNoRenewalContractNumServer[keyMapTtoalServer]) //"确认不续约合同(金额/数量)-(数据)"
@@ -1299,6 +1333,9 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 				item := new(statistic_report.RaiDataSummaryDetailResp)
 				item.CompanyId = v.CompanyId
 				item.CompanyName = v.CompanyName
+				if v.ContractType == "打分派点" {
+					item.CompanyName = v.CompanyName + "(打分客户)"
+				}
 				if isServerSeller {
 					item.SellerName = v.ShareSellerLast
 				} else {
@@ -1415,16 +1452,19 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		var renewedContractCompany float64 // 续约客户数
 		maprenewedContractCompany := make(map[int]bool)
 
-		var expiredContractMoney float64   //到期金额
-		var expiredContractCompany float64 // 到期客户数
+		var expiredContractMoney float64    //到期金额
+		var expiredContractMoney2 float64   //到期金额
+		var expiredContractCompany float64  // 到期客户数
+		var expiredContractCompany2 float64 // 到期客户数
 		mapexpiredContractCompany := make(map[int]bool)
-
+		mapRenewedContractId := make(map[int]bool) // 出现在续约客户的合同
 		for _, v := range listRaiData {
 			renewedContractMoney += v.Money
 			if !maprenewedContractCompany[v.CompanyId] {
 				renewedContractCompany++
 				maprenewedContractCompany[v.CompanyId] = true
 			}
+			//mapRenewedContractId[v.CompanyContractId] = true
 			//startDateTime := utils.StrDateToDate(v.StartDate)
 			//if startDateTime.Before(time.Now().AddDate(0, 0, -1)) { //到期合同数据
 			//	expiredContractMoney += v.Money
@@ -1437,12 +1477,18 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 
 		for _, v := range listEndData {
 			expiredContractMoney += v.Money
+			if v.Status == "永续" && v.ContractType == "打分派点" && !mapRenewedContractId[v.CompanyContractId] && v.RaiCountShowType != -1 {
+				expiredContractMoney2 += v.Money
+			}
 			if !mapexpiredContractCompany[v.CompanyId] {
 				expiredContractCompany++
+				if v.Status == "永续" && v.ContractType == "打分派点" && !mapRenewedContractId[v.CompanyContractId] && v.RaiCountShowType != -1 {
+					expiredContractCompany2++
+				}
 				mapexpiredContractCompany[v.CompanyId] = true
 			}
 		}
-
+		renewedContractMoney += expiredContractMoney2
 		item := new(statistic_report.RaiDataSummaryDetailResp)
 		item.TbaleNameAText = "金额续约率"
 		item.RenewedContractMoney = fmt.Sprint(utils.SubFloatToString(renewedContractMoney, 2))
@@ -1454,7 +1500,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		}
 
 		listResp = append(listResp, item)
-
+		renewedContractCompany += expiredContractCompany2
 		item2 := new(statistic_report.RaiDataSummaryDetailResp)
 		item2.TbaleNameAText = "客户续约率"
 		item2.RenewedContractMoney = fmt.Sprint(renewedContractCompany)

+ 10 - 10
models/cygx/article_and_yanxuan_record.go

@@ -26,8 +26,8 @@ type CygxArticleAndYanxuanRecordResp struct {
 // 获取数量
 func GetCygxArticleAndYanxuanRecordCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_and_yanxuan_record as r
-                  INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id 
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_history_record_all as r
+                  INNER JOIN cygx_article  as art  ON  art.article_id = r.article_id 
                   WHERE 1= 1  `
 	if condition != "" {
 		sqlCount += condition
@@ -40,8 +40,8 @@ func GetCygxArticleAndYanxuanRecordCount(condition string, pars []interface{}) (
 func GetCygxArticleAndYanxuanRecordCountWeekly(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	databaseName := utils.GetWeeklyDatabase()
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_and_yanxuan_record as r 
-                             INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_history_record_all as r 
+                             INNER JOIN cygx_article  as art  ON  art.article_id = r.article_id
 				  INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
 		WHERE 1= 1  `
 	sqlCount = fmt.Sprintf(sqlCount, databaseName)
@@ -53,10 +53,10 @@ func GetCygxArticleAndYanxuanRecordCountWeekly(condition string, pars []interfac
 }
 
 // 列表
-func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleAndYanxuanRecordResp, err error) {
+func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT r.* ,art.title  FROM cygx_article_and_yanxuan_record as r 
-          INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id  WHERE 1= 1 `
+	sql := `SELECT r.* ,art.title  FROM cygx_article_history_record_all as r 
+          INNER JOIN cygx_article  as art  ON  art.article_id = r.article_id  WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
@@ -66,11 +66,11 @@ func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}
 }
 
 // 列表(关联用户跟销售的绑定关系跨库查询)
-func GetCygxArticleAndYanxuanRecordRespListWeekly(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleAndYanxuanRecordResp, err error) {
+func GetCygxArticleAndYanxuanRecordRespListWeekly(condition string, pars []interface{}, startSize, pageSize int) (items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	databaseName := utils.GetWeeklyDatabase()
-	sql := `SELECT r.* FROM cygx_article_and_yanxuan_record as r 
-     		INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id 
+	sql := `SELECT r.* FROM cygx_article_history_record_all as r 
+     		INNER JOIN cygx_article  as art  ON  art.article_id = r.article_id 
 			INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
 		WHERE 1= 1   `
 	sql = fmt.Sprintf(sql, databaseName)

+ 8 - 2
models/statistic_report/rai_data_summary.go

@@ -92,6 +92,7 @@ type IncrementalList struct {
 	RaiContractType   string `description:"权益合同类型:枚举值:'新签合同','续约合同','补充协议'"`
 	InheritEndDate    string `description:"所继承上一份合同的结束日期,权益自定义续约合同统计使用"`
 	DueEndDate        string `description:"所继承上一份合同的结束日期,权益自定义到期合同统计使用"`
+	RaiCountShowType  int    `description:"权益是否进行统计,0否,1是,默认0"`
 }
 
 // GetRaiDataSummaryList 获取增量客户报表列表数据(根据合同来展示)
@@ -104,6 +105,7 @@ func GetRaiDataSummaryList(condition string, pars []interface{}) (items []*Incre
 			   a.money,
 			   a.company_id,
 			   a.rai_contract_type,
+			   a.contract_type,
 			   a.seller_id_init,
 			   a.seller_name_init,
 			   a.share_seller_init,
@@ -111,7 +113,9 @@ func GetRaiDataSummaryList(condition string, pars []interface{}) (items []*Incre
 			   a.seller_id_last,
 			   a.seller_name_last, 
 			   a.share_seller_last,
-			   a.share_seller_id_last
+			   a.share_seller_id_last,
+			   a.rai_count_show_type,
+			   c.status
        FROM company_contract a
     	INNER JOIN  company_product c ON a.company_id = c.company_id and a.product_id=c.product_id and  c.product_id = 2 
 	   JOIN company b ON a.company_id = b.company_id
@@ -133,6 +137,7 @@ func GetRaiDataSummaryInheritList(condition string, pars []interface{}) (items [
 			   a.company_contract_id,
 			   a.money,
 		       a.company_id,
+			   a.contract_type,
 			   a.rai_contract_type,
 			   a.seller_id_init,
 			   a.seller_name_init,
@@ -141,7 +146,8 @@ func GetRaiDataSummaryInheritList(condition string, pars []interface{}) (items [
 			   a.seller_id_last,
 			   a.seller_name_last, 
 			   a.share_seller_last,
-			   a.share_seller_id_last
+			   a.rai_count_show_type,
+			   c.status
        FROM company_contract a
 	   JOIN company b ON a.company_id = b.company_id
 	   JOIN company_product c ON a.company_id = c.company_id and a.product_id=c.product_id WHERE 1 = 1 `

+ 112 - 0
services/cygx/article.go

@@ -340,6 +340,118 @@ func HandleArticleAndYanxuanRecordList(items []*cygx.CygxArticleAndYanxuanRecord
 	return
 }
 
+// 处理文章、研选专栏的查询信息回显
+func HandleArticleAndYanxuanRecordList2(items []*cygx.UserInteraction) (itemsResp []*cygx.UserInteraction, err error) {
+	itemsResp = make([]*cygx.UserInteraction, 0)
+	if len(items) > 0 {
+
+		var articleIds []int        // 文章ID
+		var yanxuanSpecialIds []int // 研选专栏ID
+		var sellerCompanyIds []int  // 公司ID
+		var mobiles []string        // 手机号
+		for _, v := range items {
+			articleIds = append(articleIds, v.ArticleId)
+			sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+			mobiles = append(mobiles, v.Mobile)
+		}
+
+		sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
+
+		mapIndustrialLabel := GetArticleIndustrialLabelByArticleId(articleIds) // 关联产业
+		mapSubjectLabel := GetArticleSubjectLabelByArticleId(articleIds)       // 关联标的
+
+		//根据手机号获取这些用户的信息
+		listUser, e := models.GetWxUserByOutboundMobiles(mobiles)
+		if e != nil {
+			err = errors.New("GetWxUserOutboundMobiles, Err: " + e.Error())
+			return
+		}
+		mapUserRealname := make(map[string]string)
+		for _, v := range listUser {
+			mapUserRealname[v.Mobile] = v.RealName
+		}
+
+		var condition string
+		var pars []interface{}
+
+		//获取文章map
+		mapArticle := make(map[int]*cygx.CygxReportArticle)
+		lenarticleIds := len(articleIds)
+		if lenarticleIds > 0 {
+			condition = " AND art.article_id IN  (" + utils.GetOrmInReplace(lenarticleIds) + ")  GROUP  BY art.article_id "
+			pars = append(pars, articleIds)
+			list, e := cygx.GetReportArticleList(condition, pars, 0, lenarticleIds, 1)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = e
+				return
+			}
+
+			if len(list) > 0 {
+				for _, v := range list {
+					mapArticle[v.ArticleId] = v
+				}
+			}
+		}
+
+		//获取研选专栏map
+		mapYanxuanSpecial := make(map[int]*cygx.CygxYanxuanSpeciaResplItem)
+		lenyanxuanSpecialIds := len(yanxuanSpecialIds)
+		if lenyanxuanSpecialIds > 0 {
+			pars = make([]interface{}, 0)
+			condition = " AND a.id IN  (" + utils.GetOrmInReplace(lenyanxuanSpecialIds) + ")"
+			pars = append(pars, yanxuanSpecialIds)
+			list, e := cygx.GetYanxuanSpecialListByCondition(condition, pars, 0, lenyanxuanSpecialIds)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = e
+				return
+			}
+			if len(list) > 0 {
+				for _, v := range list {
+					mapYanxuanSpecial[v.Id] = v
+				}
+			}
+		}
+
+		for _, v := range items {
+			item := new(cygx.UserInteraction)
+
+			item.IndustryName = strings.Join(mapIndustrialLabel[v.ArticleId], ",")
+			item.SubjectNameStr = strings.Join(mapSubjectLabel[v.ArticleId], ",")
+			if v.ArticleId >= utils.SummaryArticleId {
+				item.ArticleType = 1
+			} else {
+				item.ArticleType = 2
+			}
+			//如果对应的map不为空,就赋值
+			if mapArticle[v.ArticleId] != nil {
+				item.Title = mapArticle[v.ArticleId].Title
+				item.PublishDate = mapArticle[v.ArticleId].PublishDate
+				item.PermissionName = mapArticle[v.ArticleId].PermissionName
+				item.ArticleIdMd5 = mapArticle[v.ArticleId].ArticleIdMd5
+				item.ReportId = mapArticle[v.ArticleId].ReportId
+			}
+
+			item.ArticleId = v.ArticleId
+			item.CreateTime = v.CreateTime
+			item.UserId = v.UserId
+			item.RealName = v.RealName
+			if item.RealName == "" {
+				item.RealName = mapUserRealname[v.Mobile]
+			}
+			item.Mobile = v.Mobile
+			item.CompanyId = v.CompanyId
+			item.CompanyName = v.CompanyName
+			item.SellerName = sellNameMap[v.CompanyId]
+			item.RegisterPlatform = v.RegisterPlatform
+			item.RegisterPlatformText = GetArticleSourcePlatformText(v.RegisterPlatform)
+			item.StopTime = v.StopTime
+			itemsResp = append(itemsResp, item)
+		}
+
+	}
+	return
+}
+
 //
 //func init() {
 //	SendWxMsgWithroadshowEssence(1000546)

+ 1 - 0
services/cygx/yidong.go

@@ -734,6 +734,7 @@ func YiDongSignAppointmentsForThirdSpeaker(activityId int) {
 
 // 删除路演活动(新)
 func YiDongUpdateActivityStatus(activityId int) {
+	time.Sleep(3 * time.Second)
 	var err error
 	defer func() {
 		if err != nil {

+ 2 - 2
services/wechat_send_msg.go

@@ -1931,8 +1931,8 @@ func SendWxMsgWithRoadshowSellerActivity(keyword1, keyword2, keyword3, keyword4
 	var wxAppPath string
 	wxAppPath = utils.WX_MSG_PATH_SSBG_SELLER_ACTIVITY_DETAIL + strconv.Itoa(rsActivityId)
 	sendInfo := new(SendWxTemplate)
-	//sendInfo.WxAppId = utils.AdminWxAppId
-	sendInfo.WxAppId = "wx1392111da5426e9e"
+	sendInfo.WxAppId = utils.AdminWxAppId
+	//sendInfo.WxAppId = "wx1392111da5426e9e"
 	sendInfo.Keyword1 = keyword1
 	sendInfo.Keyword2 = keyword2
 	sendInfo.Keyword3 = keyword3