|
@@ -12,6 +12,7 @@ import (
|
|
|
"hongze/hz_crm_api/models/company_user"
|
|
|
"hongze/hz_crm_api/models/company_user/request"
|
|
|
"hongze/hz_crm_api/models/company_user/response"
|
|
|
+ "hongze/hz_crm_api/models/cygx"
|
|
|
"hongze/hz_crm_api/models/system"
|
|
|
"hongze/hz_crm_api/models/yb"
|
|
|
"hongze/hz_crm_api/services"
|
|
@@ -966,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)
|
|
@@ -1089,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
|
|
@@ -1120,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 {
|
|
@@ -2910,10 +2927,13 @@ Loop:
|
|
|
br.Data = resp
|
|
|
}
|
|
|
|
|
|
+// ViewReportList
|
|
|
// @Title 联系人阅读报告记录
|
|
|
// @Description 联系人阅读报告记录
|
|
|
// @Param UserId query int true "用户id"
|
|
|
// @Param TxtType query int true "类型0全部,1权益,2ficc"
|
|
|
+// @Param PageSize query int true "每页数据条数"
|
|
|
+// @Param LastViewTime query string true "最近一次的阅读时间,没有的话,那就是获取最新数据"
|
|
|
// @Success 200 {object} company.ViewReportListResp
|
|
|
// @router /view/report/list [get]
|
|
|
func (this *CompanyUserController) ViewReportList() {
|
|
@@ -2931,10 +2951,16 @@ func (this *CompanyUserController) ViewReportList() {
|
|
|
}
|
|
|
userId, _ := this.GetInt("UserId")
|
|
|
txtType, _ := this.GetInt("TxtType")
|
|
|
+ pageSize, _ := this.GetInt("PageSize")
|
|
|
+ lastViewTime := this.GetString("LastViewTime")
|
|
|
if userId <= 0 {
|
|
|
br.Msg = "参数错误"
|
|
|
return
|
|
|
}
|
|
|
+ // 默认20条数据
|
|
|
+ if pageSize <= 0 {
|
|
|
+ pageSize = utils.PageSize20
|
|
|
+ }
|
|
|
|
|
|
item, err := models.GetWxUserByUserId(userId)
|
|
|
if err != nil {
|
|
@@ -2943,28 +2969,235 @@ func (this *CompanyUserController) ViewReportList() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- list := make([]*company.ViewReportList, 0)
|
|
|
-
|
|
|
- if item.Mobile != "" {
|
|
|
- items, err := company.GetViewReportListByMobile(item.Mobile, txtType)
|
|
|
+ var lastViewTimeT time.Time
|
|
|
+ if lastViewTime != `` {
|
|
|
+ lastViewTimeT, err = time.ParseInLocation(utils.FormatDateTime, lastViewTime, time.Local)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
- br.Msg = "获取失败,Err:" + err.Error()
|
|
|
+ br.Msg = "最近一次阅读时间转换异常,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- list = append(list, items...)
|
|
|
}
|
|
|
|
|
|
- if item.Email != "" && item.Mobile == "" {
|
|
|
- items, err := company.GetViewReportListByEmail2(item.Email, txtType)
|
|
|
+ list := make([]*company.ViewReportList, 0)
|
|
|
+ recordList := make([]*models.UserReportViewRecord, 0)
|
|
|
+
|
|
|
+ obj := models.UserReportViewRecord{}
|
|
|
+
|
|
|
+ var baseCondition string // 基础条件
|
|
|
+ var basePars []interface{}
|
|
|
+ if item.Mobile != "" {
|
|
|
+ baseCondition = ` AND mobile = ? `
|
|
|
+ basePars = append(basePars, item.Mobile)
|
|
|
+ } else if item.Email == "" {
|
|
|
+ baseCondition = ` AND email = ? `
|
|
|
+ basePars = append(basePars, item.Email)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 阅读记录汇总数
|
|
|
+ total := item.FiccViewTotal + item.RaiViewTotal
|
|
|
+
|
|
|
+ switch txtType {
|
|
|
+ case 1:
|
|
|
+ baseCondition += ` AND source = ? `
|
|
|
+ basePars = append(basePars, 4)
|
|
|
+
|
|
|
+ total = item.RaiViewTotal
|
|
|
+ if lastViewTimeT.IsZero() {
|
|
|
+ if item.RaiLastViewTime != `` && item.RaiLastViewTime != `0000-00-00 00:00:00` {
|
|
|
+ lastViewTimeT, _ = time.ParseInLocation(utils.FormatDateTime, item.RaiLastViewTime, time.Local)
|
|
|
+ } else {
|
|
|
+ lastViewTimeT = time.Now()
|
|
|
+ }
|
|
|
+ lastViewTime = lastViewTimeT.Format(utils.FormatDateTime)
|
|
|
+ }
|
|
|
+ // 权益
|
|
|
+ case 2: // ficc
|
|
|
+ baseCondition += ` AND source in (?,?,?) `
|
|
|
+ basePars = append(basePars, 1, 2, 3)
|
|
|
+ total = item.FiccViewTotal
|
|
|
+
|
|
|
+ if lastViewTimeT.IsZero() {
|
|
|
+ if item.FiccLastViewTime != `` && item.FiccLastViewTime != `0000-00-00 00:00:00` {
|
|
|
+ lastViewTimeT, _ = time.ParseInLocation(utils.FormatDateTime, item.FiccLastViewTime, time.Local)
|
|
|
+ } else {
|
|
|
+ lastViewTimeT = time.Now()
|
|
|
+ }
|
|
|
+ lastViewTime = lastViewTimeT.Format(utils.FormatDateTime)
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ if lastViewTimeT.IsZero() {
|
|
|
+ var ficcViewTime, raiViewTime time.Time
|
|
|
+ if item.FiccLastViewTime != `` && item.FiccLastViewTime != `0000-00-00 00:00:00` {
|
|
|
+ ficcViewTime, _ = time.ParseInLocation(utils.FormatDateTime, item.FiccLastViewTime, time.Local)
|
|
|
+ }
|
|
|
+ if item.RaiLastViewTime != `` && item.RaiLastViewTime != `0000-00-00 00:00:00` {
|
|
|
+ raiViewTime, _ = time.ParseInLocation(utils.FormatDateTime, item.RaiLastViewTime, time.Local)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果两个都没有值的话,那么就是当前时间
|
|
|
+ if ficcViewTime.IsZero() && raiViewTime.IsZero() {
|
|
|
+ lastViewTimeT = time.Now()
|
|
|
+ } else if !ficcViewTime.IsZero() && !raiViewTime.IsZero() {
|
|
|
+ if ficcViewTime.After(raiViewTime) {
|
|
|
+ lastViewTimeT = ficcViewTime
|
|
|
+ } else {
|
|
|
+ lastViewTimeT = raiViewTime
|
|
|
+ }
|
|
|
+ } else if !ficcViewTime.IsZero() {
|
|
|
+ lastViewTimeT = ficcViewTime
|
|
|
+ } else {
|
|
|
+ lastViewTimeT = raiViewTime
|
|
|
+ }
|
|
|
+ // 默认要把最新的记录列出来,所以往后加1s
|
|
|
+ lastViewTime = lastViewTimeT.Add(1 * time.Second).Format(utils.FormatDateTime)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 开始实际的查询
|
|
|
+ {
|
|
|
+ condition := baseCondition
|
|
|
+ pars := basePars
|
|
|
+
|
|
|
+ condition += `AND create_time < ?`
|
|
|
+ pars = append(pars, lastViewTime)
|
|
|
+
|
|
|
+ total, items, err := obj.GetViewReportList(lastViewTimeT.Year(), condition, pars, pageSize)
|
|
|
if err != nil {
|
|
|
br.Msg = "获取失败"
|
|
|
br.Msg = "获取失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- list = append(list, items...)
|
|
|
+
|
|
|
+ recordList = append(recordList, items...)
|
|
|
+
|
|
|
+ // 查询去年的表
|
|
|
+ if total < int64(pageSize) {
|
|
|
+ secondCondition := baseCondition
|
|
|
+ secondPars := basePars
|
|
|
+
|
|
|
+ secondCondition += `AND create_time < ?`
|
|
|
+ secondPars = append(secondPars, lastViewTime)
|
|
|
+
|
|
|
+ _, items, err = obj.GetViewReportList(lastViewTimeT.Year(), secondCondition, secondPars, int(total)-pageSize)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.Msg = "获取失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ recordList = append(recordList, items...)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ viewReportMap := make(map[string]company.ViewReportList) // 阅读记录map
|
|
|
+ sourceReportIdListMap := make(map[int8][]int)
|
|
|
+
|
|
|
+ for _, v := range recordList {
|
|
|
+ tmpList, ok := sourceReportIdListMap[v.Source]
|
|
|
+ if !ok {
|
|
|
+ tmpList = make([]int, 0)
|
|
|
+ }
|
|
|
+ tmpList = append(tmpList, v.ReportId)
|
|
|
+ sourceReportIdListMap[v.Source] = tmpList
|
|
|
+
|
|
|
+ tmpTxtType := `ficc`
|
|
|
+ if v.Source == 4 {
|
|
|
+ tmpTxtType = `rights`
|
|
|
+ }
|
|
|
+ stopTime := `--`
|
|
|
+ if v.StopTime > 0 {
|
|
|
+ stopTime = fmt.Sprint(stopTime)
|
|
|
+ }
|
|
|
+ viewReportMap[fmt.Sprint(v.Source, "_", v.ReportId)] = company.ViewReportList{
|
|
|
+ ResearchReportName: "",
|
|
|
+ ReportType: "",
|
|
|
+ CreatedTime: v.CreateTime,
|
|
|
+ TxtType: tmpTxtType,
|
|
|
+ MatchTypeName: "--",
|
|
|
+ StopTime: stopTime,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取报告详情
|
|
|
+ for source, reportIdList := range sourceReportIdListMap {
|
|
|
+ switch source {
|
|
|
+ case 1: // rddp报告
|
|
|
+ tmpReportList, err := models.GetReportByIdList(reportIdList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.Msg = "获取weekly报告详情失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpReportList {
|
|
|
+ tmpKey := fmt.Sprint(source, "_", v.Id)
|
|
|
+ if tmpInfo, ok := viewReportMap[tmpKey]; ok {
|
|
|
+ tmpInfo.ResearchReportName = v.Title
|
|
|
+ tmpInfo.ReportType = `rddp`
|
|
|
+ tmpInfo.MatchTypeName = v.ClassifyNameFirst
|
|
|
+ viewReportMap[tmpKey] = tmpInfo
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case 2: // weekly报告
|
|
|
+ tmpReportList, err := models.GetResearchReportListByIdList(reportIdList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.Msg = "获取weekly报告详情失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpReportList {
|
|
|
+ tmpKey := fmt.Sprint(source, "_", v.ResearchReportId)
|
|
|
+ if tmpInfo, ok := viewReportMap[tmpKey]; ok {
|
|
|
+ tmpInfo.ResearchReportName = v.ResearchReportName
|
|
|
+ tmpInfo.ReportType = v.Type
|
|
|
+ viewReportMap[tmpKey] = tmpInfo
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case 3: // weekly_report商品的报告(应该是作废了);
|
|
|
+ tmpReportList, err := models.GetChartPermissionByIdList(reportIdList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.Msg = "获取weekly报告详情失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpReportList {
|
|
|
+ tmpKey := fmt.Sprint(source, "_", v.ChartPermissionId)
|
|
|
+ if tmpInfo, ok := viewReportMap[tmpKey]; ok {
|
|
|
+ tmpInfo.ResearchReportName = v.ChartPermissionName
|
|
|
+ tmpInfo.ReportType = `advisory`
|
|
|
+ tmpInfo.MatchTypeName = v.ClassifyName
|
|
|
+ viewReportMap[tmpKey] = tmpInfo
|
|
|
+ }
|
|
|
+ }
|
|
|
+ case 4: // 察研观向的报告
|
|
|
+ tmpReportList, err := cygx.GetArticleListByIdList(reportIdList)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "获取失败"
|
|
|
+ br.Msg = "获取weekly报告详情失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range tmpReportList {
|
|
|
+ tmpKey := fmt.Sprint(source, "_", v.ArticleId)
|
|
|
+ if tmpInfo, ok := viewReportMap[tmpKey]; ok {
|
|
|
+ tmpInfo.ResearchReportName = v.Title
|
|
|
+ tmpInfo.ReportType = `cygx`
|
|
|
+ tmpInfo.MatchTypeName = v.MatchTypeName
|
|
|
+ viewReportMap[tmpKey] = tmpInfo
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 报告标题处理
|
|
|
+ for _, v := range recordList {
|
|
|
+ tmpKey := fmt.Sprint(v.Source, "_", v.ReportId)
|
|
|
+ if tmpInfo, ok := viewReportMap[tmpKey]; ok {
|
|
|
+ list = append(list, &tmpInfo)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ // 类型处理
|
|
|
for k, v := range list {
|
|
|
if v.ReportType == "day" {
|
|
|
list[k].MatchTypeName = "晨报"
|
|
@@ -2990,7 +3223,7 @@ func (this *CompanyUserController) ViewReportList() {
|
|
|
}
|
|
|
resp := new(company.ViewReportListResp)
|
|
|
resp.List = list
|
|
|
- resp.Total = len(list)
|
|
|
+ resp.Total = total
|
|
|
br.Ret = 200
|
|
|
br.Success = true
|
|
|
br.Msg = "获取成功"
|