Просмотр исходного кода

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

xingzai 1 год назад
Родитель
Сommit
6a761bbd98

+ 166 - 148
controllers/company_user.go

@@ -967,64 +967,64 @@ func (this *CompanyUserController) List() {
 		//}
 
 		//报告统计删除晨报部分统计加入每日资讯 2021-4-9
-		//手机号
-		userViewMobileTotalMap := make(map[string]*models.UserViewMobileTotalSlice)
-		userReportViewMobileTotalMap := make(map[string]*models.ReportViewMobileRecord)
-		userAdvisoryViewMobileTotalMap := make(map[string]*advisory.UserViewMobileTotalSlice)
-		userCygxArticleHistoryRecordViewMobileTotalMap := make(map[string]*models.UserViewMobileTotalSlice)
-		if len(mobilesSlice) > 0 {
-			//用户浏览数据
-			userViewMobileTotalList, _ := models.GetCountUserViewHistoryByMobiles(mobileStr)
-			for _, userViewMobile := range userViewMobileTotalList {
-				userViewMobileTotalMap[userViewMobile.Mobile] = userViewMobile
-			}
-
-			//每日点评手机号数据
-			userReportViewMobileTotalList, _ := models.GetReportViewMaxTimeByMobiles(mobileStr)
-			for _, userReportViewMobile := range userReportViewMobileTotalList {
-				userReportViewMobileTotalMap[userReportViewMobile.Mobile] = userReportViewMobile
-			}
-
-			//每日资讯
-			userAdvisoryViewMobileTotalList, _ := advisory.GetCountUserViewHistoryByMobiles(mobileStr)
-			//fmt.Println(userAdvisoryViewMobileTotalList)
-			for _, userAdvisoryViewMobile := range userAdvisoryViewMobileTotalList {
-				userAdvisoryViewMobileTotalMap[userAdvisoryViewMobile.Mobile] = userAdvisoryViewMobile
-			}
-			//查研观向
-			userCygxArticleHistoryRecordViewMobileTotalList, _ := models.GetCountCygxArticleHistoryRecordByMobiles(mobileStr)
-			for _, userCygxArticleHistoryRecordViewMobile := range userCygxArticleHistoryRecordViewMobileTotalList {
-				userCygxArticleHistoryRecordViewMobileTotalMap[userCygxArticleHistoryRecordViewMobile.Mobile] = userCygxArticleHistoryRecordViewMobile
-			}
-		}
+		////手机号
+		//userViewMobileTotalMap := make(map[string]*models.UserViewMobileTotalSlice)
+		//userReportViewMobileTotalMap := make(map[string]*models.ReportViewMobileRecord)
+		//userAdvisoryViewMobileTotalMap := make(map[string]*advisory.UserViewMobileTotalSlice)
+		//userCygxArticleHistoryRecordViewMobileTotalMap := make(map[string]*models.UserViewMobileTotalSlice)
+		//if len(mobilesSlice) > 0 {
+		//	//用户浏览数据
+		//	userViewMobileTotalList, _ := models.GetCountUserViewHistoryByMobiles(mobileStr)
+		//	for _, userViewMobile := range userViewMobileTotalList {
+		//		userViewMobileTotalMap[userViewMobile.Mobile] = userViewMobile
+		//	}
+		//
+		//	//每日点评手机号数据
+		//	userReportViewMobileTotalList, _ := models.GetReportViewMaxTimeByMobiles(mobileStr)
+		//	for _, userReportViewMobile := range userReportViewMobileTotalList {
+		//		userReportViewMobileTotalMap[userReportViewMobile.Mobile] = userReportViewMobile
+		//	}
+		//
+		//	//每日资讯
+		//	userAdvisoryViewMobileTotalList, _ := advisory.GetCountUserViewHistoryByMobiles(mobileStr)
+		//	//fmt.Println(userAdvisoryViewMobileTotalList)
+		//	for _, userAdvisoryViewMobile := range userAdvisoryViewMobileTotalList {
+		//		userAdvisoryViewMobileTotalMap[userAdvisoryViewMobile.Mobile] = userAdvisoryViewMobile
+		//	}
+		//	//查研观向
+		//	userCygxArticleHistoryRecordViewMobileTotalList, _ := models.GetCountCygxArticleHistoryRecordByMobiles(mobileStr)
+		//	for _, userCygxArticleHistoryRecordViewMobile := range userCygxArticleHistoryRecordViewMobileTotalList {
+		//		userCygxArticleHistoryRecordViewMobileTotalMap[userCygxArticleHistoryRecordViewMobile.Mobile] = userCygxArticleHistoryRecordViewMobile
+		//	}
+		//}
 
-		//邮箱
-		userViewEmailTotalMap := make(map[string]*models.UserViewEmailTotalSlice)
-		userReportViewEmailTotalMap := make(map[string]*models.ReportViewEmailRecord)
-		userAdvisoryViewEmailTotalMap := make(map[string]*advisory.UserViewEmailTotalSlice)
-		userCygxViewEmailTotalMap := make(map[string]*models.UserViewEmailTotalSlice)
-		if len(emailsSlice) > 0 {
-			//用户浏览数据
-			userViewEmailTotalList, _ := models.GetCountUserViewHistoryByEmails(emailStr)
-			for _, userViewEmail := range userViewEmailTotalList {
-				userViewEmailTotalMap[userViewEmail.Email] = userViewEmail
-			}
-			//每日点评手机号数据
-			userReportViewEmailTotalList, _ := models.GetReportViewMaxTimeByEmails(emailStr)
-			for _, userReportViewEmail := range userReportViewEmailTotalList {
-				userReportViewEmailTotalMap[userReportViewEmail.Email] = userReportViewEmail
-			}
-			//每日资讯
-			userAdvisoryViewEmailTotalList, _ := advisory.GetCountUserViewHistoryByEmails(emailStr)
-			for _, userAdvisoryViewEmail := range userAdvisoryViewEmailTotalList {
-				userAdvisoryViewEmailTotalMap[userAdvisoryViewEmail.Email] = userAdvisoryViewEmail
-			}
-			//查研观向
-			userCygxViewEmailTotalList, _ := models.GetCountCygxArticleHistoryRecordByEmails(emailStr)
-			for _, userCygxReportViewEmail := range userCygxViewEmailTotalList {
-				userCygxViewEmailTotalMap[userCygxReportViewEmail.Email] = userCygxReportViewEmail
-			}
-		}
+		////邮箱
+		//userViewEmailTotalMap := make(map[string]*models.UserViewEmailTotalSlice)
+		//userReportViewEmailTotalMap := make(map[string]*models.ReportViewEmailRecord)
+		//userAdvisoryViewEmailTotalMap := make(map[string]*advisory.UserViewEmailTotalSlice)
+		//userCygxViewEmailTotalMap := make(map[string]*models.UserViewEmailTotalSlice)
+		//if len(emailsSlice) > 0 {
+		//	//用户浏览数据
+		//	userViewEmailTotalList, _ := models.GetCountUserViewHistoryByEmails(emailStr)
+		//	for _, userViewEmail := range userViewEmailTotalList {
+		//		userViewEmailTotalMap[userViewEmail.Email] = userViewEmail
+		//	}
+		//	//每日点评手机号数据
+		//	userReportViewEmailTotalList, _ := models.GetReportViewMaxTimeByEmails(emailStr)
+		//	for _, userReportViewEmail := range userReportViewEmailTotalList {
+		//		userReportViewEmailTotalMap[userReportViewEmail.Email] = userReportViewEmail
+		//	}
+		//	//每日资讯
+		//	userAdvisoryViewEmailTotalList, _ := advisory.GetCountUserViewHistoryByEmails(emailStr)
+		//	for _, userAdvisoryViewEmail := range userAdvisoryViewEmailTotalList {
+		//		userAdvisoryViewEmailTotalMap[userAdvisoryViewEmail.Email] = userAdvisoryViewEmail
+		//	}
+		//	//查研观向
+		//	userCygxViewEmailTotalList, _ := models.GetCountCygxArticleHistoryRecordByEmails(emailStr)
+		//	for _, userCygxReportViewEmail := range userCygxViewEmailTotalList {
+		//		userCygxViewEmailTotalMap[userCygxReportViewEmail.Email] = userCygxReportViewEmail
+		//	}
+		//}
 
 		//获取联系人关联产品的条数
 		userSellerRelationTotalSlice, err := models.GetUserSellerRelationCountByUserIds(userIdStr)
@@ -1090,23 +1090,6 @@ func (this *CompanyUserController) List() {
 			item := list[i]
 			//企业名称
 			list[i].CompanyName = companyInfo.CompanyName
-			//手机号用户累计浏览次数
-			if userView, ok := userViewMobileTotalMap[item.Mobile]; ok {
-				list[i].ViewTotal += userView.Total
-				if userView.CreatedTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = userView.CreatedTime
-					list[i].LastViewTimeStr = userView.CreatedTime.Format(utils.FormatDateTime)
-				}
-			}
-			//邮箱用户累计浏览次数
-			if userView, ok := userViewEmailTotalMap[item.Email]; ok {
-				//总共浏览的报表数据需要调整为(手机号用户浏览晨报数+邮箱号用户浏览晨报数)
-				list[i].ViewTotal += userView.Total
-				if userView.CreatedTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = userView.CreatedTime
-					list[i].LastViewTimeStr = userView.CreatedTime.Format(utils.FormatDateTime)
-				}
-			}
 
 			if item.OpenId != "" {
 				list[i].IsRegister = true
@@ -1121,78 +1104,111 @@ func (this *CompanyUserController) List() {
 					list[i].IsRegister = false
 				}
 			}
-			//如果存在手机号用户日评数据,那么需要做处理
-			if reportView, ok := userReportViewMobileTotalMap[item.Mobile]; ok {
-				//对日评数据做校验,日评时间晚于晨报时间,那么将最近一次浏览时间替换
-				if reportView.LastViewTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = reportView.LastViewTime
-					list[i].LastViewTimeStr = reportView.LastViewTime.Format(utils.FormatDateTime)
-				}
-				//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数)
-				list[i].ViewTotal += reportView.ViewTotal
-			}
-			//如果存在手机号用户日评数据,那么需要做处理
-			if reportView, ok := userReportViewEmailTotalMap[item.Email]; ok {
-				//对日评数据做校验,日评时间晚于晨报时间,那么将最近一次浏览时间替换
-				if reportView.LastViewTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = reportView.LastViewTime
-					list[i].LastViewTimeStr = reportView.LastViewTime.Format(utils.FormatDateTime)
-				}
-				//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数)
-				list[i].ViewTotal += reportView.ViewTotal
-			}
 
-			//如果存在手机号用户每日资讯,那么需要做处理
-			if advisoryView, ok := userAdvisoryViewMobileTotalMap[item.Mobile]; ok {
-				//fmt.Println("蝴蝶眨几次眼睛")
-				//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
-				if advisoryView.CreatedTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = advisoryView.CreatedTime
-					list[i].LastViewTimeStr = advisoryView.CreatedTime.Format(utils.FormatDateTime)
-				}
-				//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数)
-				list[i].ViewTotal += advisoryView.Total
-			}
-			//如果存在邮箱号用户每日资讯,那么需要做处理
-			if advisoryView, ok := userAdvisoryViewEmailTotalMap[item.Email]; ok {
-				//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
-				if advisoryView.CreatedTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = advisoryView.CreatedTime
-					list[i].LastViewTimeStr = advisoryView.CreatedTime.Format(utils.FormatDateTime)
-				}
-				//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数)
-				list[i].ViewTotal += advisoryView.Total
-			}
+			////手机号用户累计浏览次数
+			//if userView, ok := userViewMobileTotalMap[item.Mobile]; ok {
+			//	list[i].ViewTotal += userView.Total
+			//	if userView.CreatedTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = userView.CreatedTime
+			//		list[i].LastViewTimeStr = userView.CreatedTime.Format(utils.FormatDateTime)
+			//	}
+			//}
+			////邮箱用户累计浏览次数
+			//if userView, ok := userViewEmailTotalMap[item.Email]; ok {
+			//	//总共浏览的报表数据需要调整为(手机号用户浏览晨报数+邮箱号用户浏览晨报数)
+			//	list[i].ViewTotal += userView.Total
+			//	if userView.CreatedTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = userView.CreatedTime
+			//		list[i].LastViewTimeStr = userView.CreatedTime.Format(utils.FormatDateTime)
+			//	}
+			//}
+			////如果存在手机号用户日评数据,那么需要做处理
+			//if reportView, ok := userReportViewMobileTotalMap[item.Mobile]; ok {
+			//	//对日评数据做校验,日评时间晚于晨报时间,那么将最近一次浏览时间替换
+			//	if reportView.LastViewTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = reportView.LastViewTime
+			//		list[i].LastViewTimeStr = reportView.LastViewTime.Format(utils.FormatDateTime)
+			//	}
+			//	//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数)
+			//	list[i].ViewTotal += reportView.ViewTotal
+			//}
+			////如果存在手机号用户日评数据,那么需要做处理
+			//if reportView, ok := userReportViewEmailTotalMap[item.Email]; ok {
+			//	//对日评数据做校验,日评时间晚于晨报时间,那么将最近一次浏览时间替换
+			//	if reportView.LastViewTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = reportView.LastViewTime
+			//		list[i].LastViewTimeStr = reportView.LastViewTime.Format(utils.FormatDateTime)
+			//	}
+			//	//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数)
+			//	list[i].ViewTotal += reportView.ViewTotal
+			//}
+			//
+			////如果存在手机号用户每日资讯,那么需要做处理
+			//if advisoryView, ok := userAdvisoryViewMobileTotalMap[item.Mobile]; ok {
+			//	//fmt.Println("蝴蝶眨几次眼睛")
+			//	//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
+			//	if advisoryView.CreatedTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = advisoryView.CreatedTime
+			//		list[i].LastViewTimeStr = advisoryView.CreatedTime.Format(utils.FormatDateTime)
+			//	}
+			//	//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数)
+			//	list[i].ViewTotal += advisoryView.Total
+			//}
+			////如果存在邮箱号用户每日资讯,那么需要做处理
+			//if advisoryView, ok := userAdvisoryViewEmailTotalMap[item.Email]; ok {
+			//	//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
+			//	if advisoryView.CreatedTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = advisoryView.CreatedTime
+			//		list[i].LastViewTimeStr = advisoryView.CreatedTime.Format(utils.FormatDateTime)
+			//	}
+			//	//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数)
+			//	list[i].ViewTotal += advisoryView.Total
+			//}
+			//
+			////如果存在手机号用户查研观向,那么需要做处理
+			//if cygxView, ok := userCygxArticleHistoryRecordViewMobileTotalMap[item.Mobile]; ok {
+			//	//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
+			//	if cygxView.CreatedTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = cygxView.CreatedTime
+			//		list[i].LastViewTimeStr = cygxView.CreatedTime.Format(utils.FormatDateTime)
+			//	}
+			//	//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数+查研观向)
+			//	list[i].ViewTotal += cygxView.Total
+			//}
+			////如果存在邮箱号用户查研观向,那么需要做处理
+			//if cygxView, ok := userCygxViewEmailTotalMap[item.Email]; ok {
+			//	//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
+			//	if cygxView.CreatedTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = cygxView.CreatedTime
+			//		list[i].LastViewTimeStr = cygxView.CreatedTime.Format(utils.FormatDateTime)
+			//	}
+			//	//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数+查研观向)
+			//	list[i].ViewTotal += cygxView.Total
+			//}
+			///*if reportView, ok := userReportViewTotalMap[int(item.UserId)]; ok {
+			//	//对日评数据做校验,日评时间晚于晨报时间,那么将最近一次浏览时间替换
+			//	if reportView.LastViewTime.After(list[i].LastViewTime) {
+			//		list[i].LastViewTime = reportView.LastViewTime
+			//		list[i].LastViewTimeStr = reportView.LastViewTime.Format(utils.FormatDateTime)
+			//	}
+			//	//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数)
+			//	list[i].ViewTotal += reportView.ViewTotal
+			//}*/
 
-			//如果存在手机号用户查研观向,那么需要做处理
-			if cygxView, ok := userCygxArticleHistoryRecordViewMobileTotalMap[item.Mobile]; ok {
-				//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
-				if cygxView.CreatedTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = cygxView.CreatedTime
-					list[i].LastViewTimeStr = cygxView.CreatedTime.Format(utils.FormatDateTime)
+			list[i].ViewTotal = list[i].FiccViewTotal + list[i].RaiViewTotal
+			var tmpLastViewTime time.Time
+			tmpLastViewTime = list[i].FiccLastViewTime
+
+			if !list[i].RaiLastViewTime.IsZero() {
+				if tmpLastViewTime.IsZero() || list[i].RaiLastViewTime.After(tmpLastViewTime) {
+					tmpLastViewTime = list[i].RaiLastViewTime
 				}
-				//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数+查研观向)
-				list[i].ViewTotal += cygxView.Total
 			}
-			//如果存在邮箱号用户查研观向,那么需要做处理
-			if cygxView, ok := userCygxViewEmailTotalMap[item.Email]; ok {
-				//对每日资讯数据做校验,每日资讯时间晚日评报时间,那么将最近一次浏览时间替换
-				if cygxView.CreatedTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = cygxView.CreatedTime
-					list[i].LastViewTimeStr = cygxView.CreatedTime.Format(utils.FormatDateTime)
-				}
-				//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数+每日资讯数+查研观向)
-				list[i].ViewTotal += cygxView.Total
+
+			list[i].LastViewTime = tmpLastViewTime
+			if !tmpLastViewTime.IsZero() {
+				list[i].LastViewTimeStr = tmpLastViewTime.Format(utils.FormatDateTime)
 			}
-			/*if reportView, ok := userReportViewTotalMap[int(item.UserId)]; ok {
-				//对日评数据做校验,日评时间晚于晨报时间,那么将最近一次浏览时间替换
-				if reportView.LastViewTime.After(list[i].LastViewTime) {
-					list[i].LastViewTime = reportView.LastViewTime
-					list[i].LastViewTimeStr = reportView.LastViewTime.Format(utils.FormatDateTime)
-				}
-				//总共浏览的报表数据需要调整为(浏览晨报数+浏览日评数)
-				list[i].ViewTotal += reportView.ViewTotal
-			}*/
 
 			//如果有绑定数据,那么将数据返回对应的注册绑定数据
 			if _, ok := userRecordRegisterMap[int(item.UserId)]; ok {
@@ -2985,11 +3001,11 @@ func (this *CompanyUserController) ViewReportList() {
 	case 1:
 		baseCondition += ` AND source = ? `
 		basePars = append(basePars, 4)
-		total = item.FiccViewTotal
 
+		total = item.RaiViewTotal
 		if lastViewTimeT.IsZero() {
-			if item.FiccLastViewTime != `` && item.FiccLastViewTime != `0000-00-00 00:00:00` {
-				lastViewTimeT, _ = time.ParseInLocation(utils.FormatDateTime, item.FiccLastViewTime, time.Local)
+			if item.RaiLastViewTime != `` && item.RaiLastViewTime != `0000-00-00 00:00:00` {
+				lastViewTimeT, _ = time.ParseInLocation(utils.FormatDateTime, item.RaiLastViewTime, time.Local)
 			} else {
 				lastViewTimeT = time.Now()
 			}
@@ -2999,10 +3015,11 @@ func (this *CompanyUserController) ViewReportList() {
 	case 2: // ficc
 		baseCondition += ` AND source in (?,?,?) `
 		basePars = append(basePars, 1, 2, 3)
-		total = item.RaiViewTotal
+		total = item.FiccViewTotal
+
 		if lastViewTimeT.IsZero() {
-			if item.RaiLastViewTime != `` && item.RaiLastViewTime != `0000-00-00 00:00:00` {
-				lastViewTimeT, _ = time.ParseInLocation(utils.FormatDateTime, item.RaiLastViewTime, time.Local)
+			if item.FiccLastViewTime != `` && item.FiccLastViewTime != `0000-00-00 00:00:00` {
+				lastViewTimeT, _ = time.ParseInLocation(utils.FormatDateTime, item.FiccLastViewTime, time.Local)
 			} else {
 				lastViewTimeT = time.Now()
 			}
@@ -3032,7 +3049,8 @@ func (this *CompanyUserController) ViewReportList() {
 			} else {
 				lastViewTimeT = raiViewTime
 			}
-			lastViewTime = lastViewTimeT.Format(utils.FormatDateTime)
+			// 默认要把最新的记录列出来,所以往后加1s
+			lastViewTime = lastViewTimeT.Add(1 * time.Second).Format(utils.FormatDateTime)
 		}
 	}
 

+ 13 - 0
controllers/cygx/activity_meet.go

@@ -10,6 +10,7 @@ import (
 	"hongze/hz_crm_api/models/company"
 	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/models/system"
+	"hongze/hz_crm_api/services"
 	"hongze/hz_crm_api/services/alarm_msg"
 	cygxService "hongze/hz_crm_api/services/cygx"
 	"hongze/hz_crm_api/utils"
@@ -1407,6 +1408,7 @@ func (this *ActivityMeetCoAntroller) AttendanceDetail() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	var sellerCompanyIds []int
 	if len(listGroup) > 0 {
 		for _, v := range listGroup {
 			list1 = append(list1, v)
@@ -1420,6 +1422,7 @@ func (this *ActivityMeetCoAntroller) AttendanceDetail() {
 		if v.Mobile != "" {
 			mobileStr += v.Mobile + ","
 		}
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
 	}
 	mobileStr = strings.TrimRight(mobileStr, ",")
 	if mobileStr == "" {
@@ -1483,6 +1486,16 @@ func (this *ActivityMeetCoAntroller) AttendanceDetail() {
 			list2[k].FirstMeetingTime = ""
 			list2[k].LastMeetingTime = ""
 		}
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+
+	//获取公司ID所对应的销售名称
+	sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
+	for k, v := range list1 {
+		list1[k].SellerName = sellNameMap[v.CompanyId]
+	}
+	for k, v := range list2 {
+		list2[k].SellerName = sellNameMap[v.CompanyId]
 	}
 	mobileStr = ""
 	for k, v := range list3 {

+ 53 - 8
controllers/cygx/activity_signup.go

@@ -282,6 +282,12 @@ func (this *ActivitySignupCoAntroller) AppointmentList() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	//根据公司ID获取对应销售
+	var companyIds []int
+	for _, v := range list {
+		companyIds = append(companyIds, v.CompanyId)
+	}
+	sellNameMap := services.GetSellNameMapByCompanyIds(companyIds)
 	totalStr += " AND  s.company_id != 16  "
 	total, errtotal := cygx.GetCygxAppointmentCount(activityId, totalStr)
 	if errtotal != nil {
@@ -296,7 +302,7 @@ func (this *ActivitySignupCoAntroller) AppointmentList() {
 		return
 	}
 	for k, v := range list {
-		list[k].SellerName = v.PsellerName
+		list[k].SellerName = sellNameMap[v.CompanyId]
 	}
 	respList := new(cygx.GetAppointmentListRep)
 	//销售查看自己客户,销售组长查看组员
@@ -658,6 +664,12 @@ func (this *ActivitySignupCoAntroller) SalonFailSignupList() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	//根据公司ID获取对应销售
+	var sellerCompanyIds []int
+	for _, v := range list {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
 	sqlStrtotal := ` AND s.fail_type >0 `
 	total, errtotal := cygx.GetCygxAppointmentCount(activityId, sqlStrtotal)
 	if errtotal != nil {
@@ -706,6 +718,7 @@ func (this *ActivitySignupCoAntroller) SalonFailSignupList() {
 		}
 	}
 	for k, v := range list {
+		list[k].SellerName = sellNameMap[v.CompanyId]
 		if v.DoFailType == 0 {
 			list[k].SalonOperation = true
 			list[k].CallOperation = v.SignupType
@@ -1215,6 +1228,19 @@ func (this *ActivitySignupCoAntroller) CallExport() {
 		return
 	}
 
+	//根据公司ID获取对应销售
+	var sellerCompanyIds []int
+	for _, v := range list {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	for _, v := range listReminder {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	for _, v := range listSummary {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
+
 	//创建excel
 	dir, err := os.Executable()
 	exPath := filepath.Dir(dir)
@@ -1292,7 +1318,7 @@ func (this *ActivitySignupCoAntroller) CallExport() {
 					cellE := row.AddCell()
 					cellE.Value = item.CompanyName
 					cellF := row.AddCell()
-					cellF.Value = item.SellerName
+					cellF.Value = sellNameMap[item.CompanyId]
 				}
 			} else {
 				rowTitle := sheet.AddRow()
@@ -1321,7 +1347,7 @@ func (this *ActivitySignupCoAntroller) CallExport() {
 					cellD := row.AddCell()
 					cellD.Value = item.CompanyName
 					cellE := row.AddCell()
-					cellE.Value = item.SellerName
+					cellE.Value = sellNameMap[item.CompanyId]
 				}
 			}
 		} else {
@@ -1339,7 +1365,7 @@ func (this *ActivitySignupCoAntroller) CallExport() {
 				cellB := row.AddCell()
 				cellB.Value = item.CompanyName
 				cellC := row.AddCell()
-				cellC.Value = item.SellerName
+				cellC.Value = sellNameMap[item.CompanyId]
 			}
 		}
 	}
@@ -1448,6 +1474,19 @@ func (this *ActivitySignupCoAntroller) SignupFailExport() {
 		return
 	}
 
+	//根据公司ID获取对应销售
+	var sellerCompanyIds []int
+	for _, v := range listReminder {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	for _, v := range summaryList {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	for _, v := range list {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
+
 	//创建excel
 	dir, err := os.Executable()
 	exPath := filepath.Dir(dir)
@@ -1521,7 +1560,7 @@ func (this *ActivitySignupCoAntroller) SignupFailExport() {
 					cellE := row.AddCell()
 					cellE.Value = item.CompanyName
 					cellF := row.AddCell()
-					cellF.Value = item.SellerName
+					cellF.Value = sellNameMap[item.CompanyId]
 				}
 			} else {
 				rowTitle := sheet.AddRow()
@@ -1539,7 +1578,7 @@ func (this *ActivitySignupCoAntroller) SignupFailExport() {
 					cellB := row.AddCell()
 					cellB.Value = item.CompanyName
 					cellC := row.AddCell()
-					cellC.Value = item.SellerName
+					cellC.Value = sellNameMap[item.CompanyId]
 				}
 			}
 		} else {
@@ -1557,7 +1596,7 @@ func (this *ActivitySignupCoAntroller) SignupFailExport() {
 				cellB := row.AddCell()
 				cellB.Value = item.CompanyName
 				cellC := row.AddCell()
-				cellC.Value = item.SellerName
+				cellC.Value = sellNameMap[item.CompanyId]
 			}
 		}
 	}
@@ -2720,6 +2759,12 @@ func (this *ActivitySignupCoAntroller) ReminderList() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+	//根据公司ID获取对应销售
+	var sellerCompanyIds []int
+	for _, v := range list {
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyId)
+	}
+	sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
 	total, errtotal := cygx.GetCygxActivityMeetingReminderCount(activityId, totalStr)
 	if errtotal != nil {
 		br.Msg = "获取失败"
@@ -2734,7 +2779,7 @@ func (this *ActivitySignupCoAntroller) ReminderList() {
 	}
 	if len(list) > 0 {
 		for k, v := range list {
-			list[k].SellerName = v.PsellerName
+			list[k].SellerName = sellNameMap[v.CompanyId]
 		}
 	} else {
 		list = make([]*cygx.CygxAppointmentList, 0)

+ 5 - 1
controllers/cygx/apply_record.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hz_crm_api/controllers"
 	"hongze/hz_crm_api/models"
 	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/services"
 	cygxService "hongze/hz_crm_api/services/cygx"
 	"hongze/hz_crm_api/utils"
 	"strconv"
@@ -94,13 +95,15 @@ func (this *ApplyRecordController) ListSysRole() {
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-
+	var sellerCompanyIds []int
 	var microvideoIds []int
 	for _, v := range list {
 		if v.Source == "roadshow" {
 			microvideoIds = append(microvideoIds, v.SourceId)
 		}
+		sellerCompanyIds = append(sellerCompanyIds, v.CompanyIdPay)
 	}
+	sellNameMap := services.GetSellNameMapByCompanyIds(sellerCompanyIds)
 	lenmicrovideoIds := len(microvideoIds)
 	mapmicrovideoChartPermissionId := make(map[int]int) //产业视频ID所对应的行业ID
 	mapmicrovideoIndustryId := make(map[int]int)        //产业视频ID所对应的行业ID
@@ -134,6 +137,7 @@ func (this *ApplyRecordController) ListSysRole() {
 		if v.InviteeCompany != "" {
 			list[i].ApplySource = "免费送月卡"
 		}
+		list[i].SellerName = sellNameMap[v.CompanyIdPay]
 		//用户状态,1:潜在客户 、2:现有客户 、3:FICC客户 、4:现有客户(正式,无对应权限) 、5:现有客户(试用,无对应权限)  、6:现有客户(试用暂停) 、7:现有客户(冻结) 、8:现有客户(流失)
 		switch v.CompanyIdType {
 		case 1:

+ 12 - 0
models/company/company_product.go

@@ -376,6 +376,7 @@ func GetRemarkListByCompanyId(CompanyId string) (items []*CompanyProductRemark,
 	_, err = o.Raw(sql, CompanyId).QueryRows(&items)
 	return
 }
+
 // 冻结客户
 //func FreezeCompany(productId, companyId, adminId int, remark, realName string) (msg, errMsg string){
 //	time.Sleep(time.Second)
@@ -558,3 +559,14 @@ func DelCompanyRemark(remarkId int) (err error) {
 	_, err = o.Raw(sql, remarkId).Exec()
 	return
 }
+
+// 获取列表
+func GetCompanyProductList(condition string, pars []interface{}) (items []*CompanyProduct, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *  FROM company_product WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 4 - 0
models/company/company_user.go

@@ -63,6 +63,10 @@ type CompanyUser struct {
 	IsSubscribe              int       `description:"是否关注了微信公众号: 0-未关注; 1-已关注"`
 	IsSubscribeHzyj          int       `description:"是否关注了弘则研究微信公众号: 0-未关注; 1-已关注"`
 	IsSubscribeCygx          int       `description:"是否关注了查研观向微信公众号: 0-未关注; 1-已关注"`
+	FiccViewTotal            int       `description:"ficc报告的阅读次数" json:"-"`
+	FiccLastViewTime         time.Time `description:"ficc报告最近一次阅读时间" json:"-"`
+	RaiViewTotal             int       `description:"权益报告的阅读次数" json:"-"`
+	RaiLastViewTime          time.Time `description:"权益报告的最近一次阅读时间" json:"-"`
 }
 
 type CompanyUserListResp struct {

+ 1 - 0
models/cygx/activity_attendance_detail.go

@@ -36,6 +36,7 @@ type AttendanceDetail struct {
 	RealName              string `description:"姓名"`
 	Mobile                string `description:"手机号"`
 	CompanyName           string `description:"公司名称"`
+	CompanyId             int    `description:"公司ID"`
 	SellerName            string `orm:"column(pseller_name);"description:"销售姓名"`
 	IsMeeting             int    `description:"是否到会"`
 	FirstMeetingTime      string `description:"首次入会时间"`

+ 1 - 0
models/cygx/activity_help_ask.go

@@ -11,6 +11,7 @@ type ActivityHelpAsk struct {
 	CreateTime  string `description:"创建时间"`
 	Mobile      string `description:"手机号"`
 	CompanyName string `description:"公司名称"`
+	CompanyId   int    `description:"公司ID"`
 	RealName    string `description:"姓名"`
 	Content     string `description:"内容"`
 }

+ 4 - 4
models/cygx/cygx_user.go

@@ -180,8 +180,8 @@ func GetCygxCompanyUserListByNoLoss() (items []*CygxCompanyUserAndSellerResp, er
 
 // 对于上面的SQL的拆分优化查询速度
 func GetCygxCompanyUserListSplit(userIds string) (items []*CygxCompanyUser, err error) {
-	return
-	o := orm.NewOrm()
+
+	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT
 			u.user_id,
 			( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.mobile = u.mobile AND h.is_del = 0   AND h.mobile <>'' ) AS history_num,
@@ -215,7 +215,7 @@ func GetCygxCompanyUserListSplit(userIds string) (items []*CygxCompanyUser, err
 				man.activity_id IN ( SELECT activity_id FROM cygx_activity_signup AS f WHERE f.user_id = u.user_id  AND label != '') 
 			) AS activity_label
 		FROM
-			wx_user AS u WHERE  u.user_id IN( ` + userIds + `) `
+			cygx_user_interaction_num AS u WHERE  u.user_id IN (` + userIds + `) 	GROUP BY u.user_id  `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -605,7 +605,7 @@ func GetCygxActivitySpecialTripByUser(uid, startSize, pageSize int) (items []*Us
 		WHERE
 			1 = 1
 			 AND a.publish_status = 1 AND a.activity_time_end < NOW()
-			AND u.user_id = ?
+			AND h.user_id = ?
 			ORDER BY  a.activity_time DESC LIMIT ?,? `
 	_, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
 	return

+ 1 - 0
models/wx_user.go

@@ -557,6 +557,7 @@ func GetWxUserRaiSllerListByUserIds(userIds []int) (list []*WxUserSller, err err
 	}
 	o := orm.NewOrm()
 	sql := ` SELECT
+				w.user_id,
 				w.real_name,
 				w.mobile,
 				c.company_name,

+ 36 - 0
services/company_product.go

@@ -0,0 +1,36 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hz_crm_api/models/company"
+	"hongze/hz_crm_api/services/alarm_msg"
+)
+
+// 根据公司ID获取权益销售名称
+func GetSellNameMapByCompanyIds(companyIds []int) (respMap map[int]string) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg("根据公司ID获取权益销售名称,失败:"+err.Error()+fmt.Sprint(companyIds), 2)
+		}
+	}()
+	lenarr := len(companyIds)
+	if lenarr == 0 {
+		return
+	}
+	var pars []interface{}
+	var condition string
+	respMap = make(map[int]string, 0)
+	condition = "  AND product_id = 2 "
+	list, e := company.GetCompanyProductList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCompanyProductList, Err: " + e.Error())
+		return
+	}
+	for _, v := range list {
+		respMap[v.CompanyId] = v.SellerName
+	}
+	return
+}