Răsfoiți Sursa

Merge branch 'cygx_9.2'

ziwen 2 ani în urmă
părinte
comite
07eb9e8840

+ 1 - 1
controllers/activity.go

@@ -981,7 +981,7 @@ func (this *ActivityCoAntroller) Detail() {
 				var condition string
 				condition = ` AND m.industrial_management_id IN (` + industrialManagementId + `)`
 				condition += ` AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId)
-				listIndustrialGrop, err := models.GetSearchResourceList(condition, 0, 0)
+				listIndustrialGrop, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
 				if err != nil && err.Error() != utils.ErrNoRow() {
 					br.Msg = "获取信息失败"
 					br.ErrMsg = "GetSearchResourceList,Err:" + err.Error() + "activityId:" + strconv.Itoa(activityId)

+ 3 - 3
controllers/base_auth.go

@@ -4,14 +4,13 @@ import (
 	"encoding/json"
 	"fmt"
 	beego "github.com/beego/beego/v2/adapter"
+	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
 	"net/http"
 	"net/url"
 	"strconv"
 
-	"hongze/hongze_cygx/models"
-	"hongze/hongze_cygx/utils"
-
 	"github.com/rdlucklib/rdluck_tools/log"
 )
 
@@ -83,6 +82,7 @@ func (this *BaseAuthController) Prepare() {
 				return
 			}
 			this.User = wxUser
+			go services.AddCygxPageHistoryRecord(this.User, this.Ctx)
 		} else {
 			this.JSON(models.BaseResponse{Ret: 408, Msg: "请求异常,请联系客服!", ErrMsg: "POST之外的请求,暂不支持"}, false, false)
 			this.StopRun()

+ 331 - 11
controllers/report.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"errors"
 	"fmt"
 	"github.com/medivhzhan/weapp/v2"
 	"github.com/rdlucklib/rdluck_tools/paging"
@@ -300,13 +301,15 @@ func (this *ReportController) ArticleCategoryList() {
 			return
 		}
 		Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
-		if err != nil {
+		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
-		if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
-			list[k].IsRed = true
+		if Newdetail != nil {
+			if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
+				list[k].IsRed = true
+			}
 		}
 	}
 
@@ -380,6 +383,17 @@ func (this *ReportController) ArticleCategoryList() {
 			CategoryId:    99999,
 			MatchTypeName: "时间线",
 		}
+		timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
+			return
+		}
+		for _, v := range timeLineList {
+			if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
+				timeLineItem.IsRed = true
+			}
+		}
 
 		list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
 	}
@@ -586,7 +600,7 @@ func (this *ReportController) List() {
 			return
 		}
 		page = paging.GetPaging(currentIndex, pageSize, total)
-		list, err := models.GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize)
+		list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
@@ -619,9 +633,9 @@ func (this *ReportController) List() {
 		//}
 
 		for k, v := range list {
-			//if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
-			//	list[k].IsRed = true
-			//}
+			if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
+				list[k].IsRed = true
+			}
 			if v.VideoUrl != "" {
 				list[k].IsHaveVideo = true
 			}
@@ -2551,7 +2565,7 @@ func (this *ReportController) SearchResource() {
 	conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
-	listHz, err := models.GetSearchResourceList(condition, 0, 0)
+	listHz, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -2561,7 +2575,7 @@ func (this *ReportController) SearchResource() {
 	conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
-	listYx, err := models.GetSearchResourceList(condition, 0, 0)
+	listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
@@ -2722,7 +2736,7 @@ func (this *ReportController) SearchReportAndResource() {
 	conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
-	listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
+	listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -2732,7 +2746,7 @@ func (this *ReportController) SearchReportAndResource() {
 	conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + `  AND publish_status = 1 ) `
 	condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
 
-	listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
+	listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
@@ -2746,15 +2760,99 @@ func (this *ReportController) SearchReportAndResource() {
 		return
 	}
 	industrialIdArr := make([]int, 0)
+	nowTime := time.Now().Local()
+	threeMonBefore := nowTime.AddDate(0, -3, 0)
+	mapHot := make(map[string]int)
+
+	hotCondition := ` ORDER BY sum_num DESC  `
+	listHot, err := models.GetThemeHeatList(user.UserId, hotCondition, 0, 3)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+	for _, v := range listHot {
+		mapHot[v.IndustryName] = v.IndustrialManagementId
+	}
+	orderSrt := "man.recommended_index DESC,update_time DESC"
 	for k, v := range listHzResource {
+		// 关联报告发布时间均在3个月内则标记New
+		if v.MinReportTime != "" {
+			t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
+			if e != nil {
+				err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
+				return
+			}
+			if t.After(threeMonBefore) {
+				listHzResource[k].IsNew = true
+			}
+		}
+		//弘则资源包不展示hot标签
+		//if mapHot[v.IndustryName] > 0 {
+		//	listHzResource[k].IsHot = true
+		//}
 		listHzResource[k].Source = 1
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			listHzResource[k].IsFollw = true
 		}
+		industrialIdSlice := make([]int, 0)
+		articleIdArr := make([]int, 0)
+		industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
+		listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return
+		}
+		for _, v := range listUpdateTime {
+			articleIdArr = append(articleIdArr, v.ArticleId)
+		}
+
+		if err != nil {
+			return
+		}
+		mapHistroyArticleId := make(map[int]int)
+
+		if user.UserId > 0 {
+			listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
+			if e != nil && e.Error() != utils.ErrNoRow() {
+				err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
+				return
+			}
+			for _, v := range listArticleHistory {
+				mapHistroyArticleId[v.ArticleId] = v.ArticleId
+			}
+		}
+		condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
+		list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+			return
+		}
+
+		for _, v2 := range list {
+			if mapHistroyArticleId[v2.ArticleId] == 0 && user.CreatedTime.Before(utils.StrDateToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrDateToTime(v.PublishDate)) {
+				listHzResource[k].IsRed = true
+			}
+		}
+
 		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
 	}
 
 	for k, v := range listYxResource {
+		// 关联报告发布时间均在3个月内则标记New
+		if v.MinReportTime != "" {
+			t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
+			if e != nil {
+				err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
+				return
+			}
+			if t.After(threeMonBefore) {
+				listYxResource[k].IsNew = true
+			}
+		}
+		if mapHot[v.IndustryName] > 0 {
+			listYxResource[k].IsHot = true
+		}
 		listYxResource[k].Source = 2
 		if fllowMap[v.IndustrialManagementId] > 0 {
 			listYxResource[k].IsFollw = true
@@ -3103,3 +3201,225 @@ func (this *ReportController) CommentAdd() {
 	br.Success = true
 	br.Msg = "提交成功"
 }
+
+// @Title 记录用户浏览音频回放接口
+// @Description 记录用户浏览音频回放接口
+// @Param	request	body models.ArticleIdReq true "type json string"
+// @Success Ret=200 操作成功
+// @router /voiceHistory/add [post]
+func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	var req models.ArticleIdReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+
+	articleId := req.ArticleId
+	playSeconds := req.PlaySeconds
+	pageRouter := req.PageRouter
+
+	if pageRouter == "本周研究汇总" {
+		articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
+		if articleInfo == nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
+			return
+		}
+		if errInfo != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+			return
+		}
+
+		var sellerName string
+		sellerName, err = models.GetCompanySellerName(user.CompanyId)
+		if err != nil {
+			br.Msg = "报名失败!"
+			br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+			return
+		}
+		item := models.CygxResearchSummaryVoiceHistory{
+			ArticleId:   articleId,
+			UserId:      uid,
+			CreateTime:  time.Now(),
+			Mobile:      user.Mobile,
+			Email:       user.Email,
+			CompanyId:   user.CompanyId,
+			CompanyName: user.CompanyName,
+			RealName:    user.RealName,
+			SellerName:  sellerName,
+			PlaySeconds: strconv.Itoa(req.PlaySeconds),
+			ModifyTime:  time.Now(),
+		}
+
+		if playSeconds != 0 {
+			lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
+				return
+			}
+			err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
+			if err != nil {
+				br.Msg = "更新失败"
+				br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
+				return
+			}
+		} else {
+			err = models.AddCygxResearchSummaryVoiceHistory(&item)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			err = models.UpdateResearchSummaryVoiceCounts(articleId)
+			if err != nil {
+				br.Msg = "更新失败"
+				br.ErrMsg = "更新失败,Err:" + err.Error()
+				return
+			}
+		}
+	} else if pageRouter == "上周纪要汇总" {
+		articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
+		if articleInfo == nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
+			return
+		}
+		if errInfo != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+			return
+		}
+
+		var sellerName string
+		sellerName, err = models.GetCompanySellerName(user.CompanyId)
+		if err != nil {
+			br.Msg = "报名失败!"
+			br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+			return
+		}
+		item := models.CygxMinutesSummaryVoiceHistory{
+			ArticleId:   articleId,
+			UserId:      uid,
+			CreateTime:  time.Now(),
+			Mobile:      user.Mobile,
+			Email:       user.Email,
+			CompanyId:   user.CompanyId,
+			CompanyName: user.CompanyName,
+			RealName:    user.RealName,
+			SellerName:  sellerName,
+			PlaySeconds: strconv.Itoa(req.PlaySeconds),
+			ModifyTime:  time.Now(),
+		}
+
+		if playSeconds != 0 {
+			lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
+				return
+			}
+			err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
+			if err != nil {
+				br.Msg = "更新失败"
+				br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
+				return
+			}
+		} else {
+			err = models.AddCygxMinutesSummaryVoiceHistory(&item)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			err = models.UpdateMinutesSummaryVoiceCounts(articleId)
+			if err != nil {
+				br.Msg = "更新失败"
+				br.ErrMsg = "更新失败,Err:" + err.Error()
+				return
+			}
+		}
+	} else if pageRouter == "报告精选" {
+		articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
+		if articleInfo == nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
+			return
+		}
+		if errInfo != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败,Err:" + errInfo.Error()
+			return
+		}
+
+		var sellerName string
+		sellerName, err = models.GetCompanySellerName(user.CompanyId)
+		if err != nil {
+			br.Msg = "报名失败!"
+			br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
+			return
+		}
+		item := models.CygxReportSelectionVoiceHistory{
+			ArticleId:   articleId,
+			UserId:      uid,
+			CreateTime:  time.Now(),
+			Mobile:      user.Mobile,
+			Email:       user.Email,
+			CompanyId:   user.CompanyId,
+			CompanyName: user.CompanyName,
+			RealName:    user.RealName,
+			SellerName:  sellerName,
+			PlaySeconds: strconv.Itoa(req.PlaySeconds),
+			ModifyTime:  time.Now(),
+		}
+
+		if playSeconds != 0 {
+			lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
+				return
+			}
+			err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
+			if err != nil {
+				br.Msg = "更新失败"
+				br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
+				return
+			}
+		} else {
+			err = models.AddCygxReportSelectionVoiceHistory(&item)
+			if err != nil {
+				br.Msg = "操作失败"
+				br.ErrMsg = "操作失败,Err:" + err.Error()
+				return
+			}
+			err = models.UpdateReportSelectionVoiceCounts(articleId)
+			if err != nil {
+				br.Msg = "更新失败"
+				br.ErrMsg = "更新失败,Err:" + err.Error()
+				return
+			}
+		}
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+	return
+}

+ 27 - 12
controllers/research.go

@@ -1,10 +1,12 @@
 package controllers
 
 import (
+	"errors"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"time"
 )
 
 //研选
@@ -163,16 +165,16 @@ func (this *ResearchController) HotList() {
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
 		return
 	}
-	newMap := make(map[int]string)
-	listNew, err := models.GetIndustrialManagementNewList("")
-	if err != nil {
-		br.Msg = "获取信息失败"
-		br.ErrMsg = "获取产业最新信息失败,Err:" + err.Error()
-		return
-	}
-	for _, v := range listNew {
-		newMap[v.IndustrialManagementId] = v.IndustryName
-	}
+	//newMap := make(map[int]string)
+	//listNew, err := models.GetIndustrialManagementNewList("")
+	//if err != nil {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取产业最新信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//for _, v := range listNew {
+	//	newMap[v.IndustrialManagementId] = v.IndustryName
+	//}
 	condition = ` AND a.article_type_id > 0  `
 	listSubjcet, err := models.GetThemeHeatSubjectList(condition)
 	if err != nil {
@@ -192,9 +194,22 @@ func (this *ResearchController) HotList() {
 	for _, v := range listHot {
 		mapHot[v.IndustryName] = v.IndustrialManagementId
 	}
+	nowTime := time.Now().Local()
+	threeMonBefore := nowTime.AddDate(0, -3, 0)
 	for k, v := range list {
-		if newMap[v.IndustrialManagementId] != "" {
-			list[k].IsNew = true
+		//if newMap[v.IndustrialManagementId] != "" {
+		//	list[k].IsNew = true
+		//}
+		// 关联报告发布时间均在3个月内则标记New
+		if v.MinReportTime != "" {
+			t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
+			if e != nil {
+				err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
+				return
+			}
+			if t.After(threeMonBefore) {
+				list[k].IsNew = true
+			}
 		}
 		if v.FllowNum > 0 {
 			list[k].IsFollw = true

+ 36 - 0
controllers/user.go

@@ -1686,3 +1686,39 @@ func (this *UserController) MicroRoadshowCollectList() {
 	br.Success = true
 	br.Data = resp
 }
+
+// @Title 新增埋点
+// @Description 新增埋点接口
+// @Success 200 "新增成功!"
+// @router /tracking [get]
+func (this *UserController) Tracking() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+
+	//item := new(models.CygxPageHistoryRecord)
+	//item.UserId = user.UserId
+	//item.CreateTime = time.Now()
+	//item.Mobile = user.Mobile
+	//item.Email = user.Email
+	//item.CompanyId = user.CompanyId
+	//item.CompanyName = user.CompanyName
+	//item.Router = this.Ctx.Request.RequestURI
+	//item.PageRouter = this.Ctx.Input.Query("PageRouter")
+	//
+	//go models.AddCygxPageHistoryRecord(item)
+	//
+
+	br.Msg = "新增成功!"
+	br.Ret = 200
+	br.Success = true
+}

+ 3 - 0
models/db.go

@@ -128,6 +128,9 @@ func init() {
 		new(CygxArticleData),
 		new(CygxArticleComment),
 		new(CygxResourceData),
+		new(CygxResearchSummaryVoiceHistory),
+		new(CygxMinutesSummaryVoiceHistory),
+		new(CygxReportSelectionVoiceHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 1 - 0
models/industrial_management.go

@@ -62,6 +62,7 @@ func GetIndustrialManagementAll(uid int, condition, orderSrt string, startSize,
 	o := orm.NewOrm()
 	sql := `SELECT
 			man.*,re.chart_permission_name as permission_name,
+			MAX(art.article_id ) AS article_id, 
            	man.new_art_publish_date AS update_time , MIN(art.publish_date) AS min_report_time,(
 			SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(uid) + ` AND rec.article_id = art.article_id ) AS readnum ,
 		    (SELECT COUNT( 1 )  FROM cygx_industry_fllow AS f WHERE f.user_id = ` + strconv.Itoa(uid) + ` AND f.industrial_management_id = man.industrial_management_id AND f.type = 1) AS is_follow

+ 43 - 0
models/minutes_summary_voice_history.go

@@ -0,0 +1,43 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxMinutesSummaryVoiceHistory struct {
+	Id          int       `orm:"column(id);pk"`
+	ArticleId  int       `description:"文章ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName      string    `description:"所属销售"`
+	PlaySeconds     string    `description:"播放时间 单位s"`
+	ModifyTime      time.Time `description:"视频修改时间"`
+}
+
+//添加
+func AddCygxMinutesSummaryVoiceHistory(item *CygxMinutesSummaryVoiceHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func GetLastCygxMinutesSummaryVoiceHistory(articleId, userId int) (item *CygxMinutesSummaryVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_minutes_summary_voice_history WHERE article_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, articleId, userId).QueryRow(&item)
+	return
+}
+
+func UpdateLastCygxMinutesSummaryVoiceHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_minutes_summary_voice_history SET play_seconds =? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}
+

+ 7 - 0
models/page_history_record.go

@@ -17,6 +17,9 @@ type CygxPageHistoryRecord struct {
 	ChartPermissionId      int       `description:"行业ID"`
 	IndustrialManagementId string    `description:"产业ID"`
 	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars,已结束活动:OverActivity"`
+	Router                 string    `description:"路由"`
+	PageRouter             string    `description:"前端页面路径"`
+	Parameter              string    `description:"参数"`
 }
 
 type CygxPageHistoryRecordRep struct {
@@ -42,3 +45,7 @@ func AddCygxPageHistoryRecord(item *CygxPageHistoryRecord) (lastId int64, err er
 	lastId, err = o.Insert(item)
 	return
 }
+
+type PageRouter struct {
+	PageRouter string
+}

+ 23 - 7
models/report.go

@@ -150,7 +150,7 @@ func IndustrialUserRecordArticleCount(userId, industrialManagementId, categoryId
 FROM
 	cygx_article_history_record 
 WHERE
-	article_id = ( SELECT article_id FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND category_id = ? ORDER BY publish_date DESC LIMIT 0, 1 ) 
+	article_id = ( SELECT article_id FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ORDER BY publish_date DESC LIMIT 0, 1 ) 
 	AND user_id = ? `
 	err = o.Raw(sql, industrialManagementId, categoryId, userId).QueryRow(&count)
 	return
@@ -159,7 +159,7 @@ WHERE
 //获取最新文章
 func GetNewIndustrialUserRecordArticle(industrialManagementId, categoryId int) (item *ArticleDetail, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND category_id = ? ORDER BY publish_date DESC LIMIT 0, 1`
+	sql := ` SELECT * FROM cygx_article WHERE article_id IN (SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id = ? ) AND match_type_name = any( SELECT match_type_name FROM cygx_report_mapping WHERE category_id = ? ) ORDER BY publish_date DESC LIMIT 0, 1`
 	err = o.Raw(sql, industrialManagementId, categoryId).QueryRow(&item)
 	return
 }
@@ -404,7 +404,10 @@ type IndustrialManagementHotResp struct {
 	FllowNum               int                   `description:"关注数量"`
 	IsNew                  bool                  `description:"是否新标签"`
 	IsHot                  bool                  `description:"是否新标签"`
+	IsRed                  bool                  `description:"是否标记红点"`
+	Readnum                int                   `description:"阅读数量"`
 	PublishDate            string                `description:"发布时间"`
+	MinReportTime          string                `description:"报告最早发布时间"`
 	ArticleReadNum         int                   `description:"文章阅读数量"`
 	Source                 int                   `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
 	IndustrialSubjectList  []*IndustrialSubject  `description:"标的列表"`
@@ -425,6 +428,7 @@ func GetThemeHeatList(userId int, condition string, startSize, pageSize int) (it
 			m.industrial_management_id,
 			m.article_read_num,
           	MAX( a.publish_date ) AS publish_date,
+			MIN(a.publish_date) AS min_report_time,
 			( SELECT count( 1 ) FROM cygx_industry_fllow AS f  WHERE f.industrial_management_id = m.industrial_management_id  AND user_id =? AND f.type = 1  ) AS fllow_num,
 			m.article_read_num + ( SELECT count( 1 ) FROM cygx_activity_meet_detail_log AS la  WHERE la.activity_id  IN  (SELECT activity_id FROM cygx_industrial_activity_group_management WHERE industrial_management_id = m.industrial_management_id  ) AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( la.activity_time ) ) AS sum_num
 		FROM
@@ -719,13 +723,15 @@ type SearchReportAndResourceResp struct {
 }
 
 //产业列表
-func GetSearchResourceList(condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
+func GetSearchResourceList(userId int, condition string, startSize, pageSize int) (items []*IndustrialManagementHotResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 			m.industry_name,
 			m.industrial_management_id,
  			MAX( a.publish_date ) as publish_date_order,
-			date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date 
+			MIN(a.publish_date) AS min_report_time,
+			date_format( MAX( a.publish_date ), '%Y-%m-%d' ) AS publish_date,
+			(SELECT COUNT(1) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND  rec.article_id=a.article_id) AS readnum 
 		FROM
 			cygx_industrial_management AS m
 			INNER JOIN cygx_industrial_article_group_management AS mg ON mg.industrial_management_id = m.industrial_management_id
@@ -859,10 +865,12 @@ type TimeLineReportItem struct {
 	IsHaveVideo     bool   `description:"是否包含视频"`
 	ImgUrlPc        string `description:"pc图片"`
 	SubCategoryName string `description:"二级分类"`
+	IsRed           bool   `description:"是否标红"`
+	Readnum         int    `description:"阅读数量"`
 }
 
 //获取产业报告+晨会点评列表
-func GetTimeLineReportIndustrialList(industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
+func GetTimeLineReportIndustrialList(userId, industrialManagementId, startSize, pageSize int) (items []*TimeLineReportItem, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT
 	* 
@@ -874,7 +882,8 @@ FROM
 		a.publish_date AS publish_time,
 		a.video_url,
 		a.sub_category_name,
-		'' AS content 
+		'' AS content,
+		( SELECT COUNT( 1 ) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND rec.article_id = a.article_id ) AS readnum 
 	FROM
 		cygx_article AS a
 		INNER JOIN cygx_industrial_article_group_management AS man_g ON man_g.article_id = a.article_id 
@@ -888,7 +897,8 @@ FROM
 		mm.meeting_time AS publish_time,
 		'' AS video_url,
 		'时间线' AS sub_category_name,
-		mmc.content 
+		mmc.content,
+		0  AS readnum 
 	FROM
 		cygx_morning_meeting_review_chapter AS mmc
 		INNER JOIN cygx_morning_meeting_reviews AS mm 
@@ -903,3 +913,9 @@ FROM
 	_, err = o.Raw(sql, industrialManagementId, industrialManagementId, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+type ArticleIdReq struct {
+	ArticleId   int    `description:"文章id"`
+	PlaySeconds int    `description:"播放时长"`
+	PageRouter  string `description:"页面路径"`
+}

+ 43 - 0
models/report_selection_voice_history.go

@@ -0,0 +1,43 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportSelectionVoiceHistory struct {
+	Id          int       `orm:"column(id);pk"`
+	ArticleId  int       `description:"文章ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName      string    `description:"所属销售"`
+	PlaySeconds     string    `description:"播放时间 单位s"`
+	ModifyTime      time.Time `description:"视频修改时间"`
+}
+
+//添加
+func AddCygxReportSelectionVoiceHistory(item *CygxReportSelectionVoiceHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func GetLastCygxReportSelectionVoiceHistory(articleId, userId int) (item *CygxReportSelectionVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_report_selection_voice_history WHERE article_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, articleId, userId).QueryRow(&item)
+	return
+}
+
+func UpdateLastCygxReportSelectionVoiceHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_report_selection_voice_history SET play_seconds =? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}
+

+ 21 - 0
models/researchSummary.go

@@ -109,3 +109,24 @@ func GetResearchSummarylogSonListThird(articleId, chartPermissionId int, artType
 	_, err = o.Raw(sql, articleId, artType, chartPermissionId).QueryRows(&items)
 	return
 }
+
+func UpdateResearchSummaryVoiceCounts(articleId int) (err error) {
+	sql := `UPDATE cygx_research_summary SET voice_counts = voice_counts+1 WHERE article_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, articleId).Exec()
+	return
+}
+
+func UpdateMinutesSummaryVoiceCounts(articleId int) (err error) {
+	sql := `UPDATE cygx_minutes_summary SET voice_counts = voice_counts+1 WHERE article_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, articleId).Exec()
+	return
+}
+
+func UpdateReportSelectionVoiceCounts(articleId int) (err error) {
+	sql := `UPDATE cygx_report_selection SET voice_counts = voice_counts+1 WHERE article_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, articleId).Exec()
+	return
+}

+ 43 - 0
models/research_summary_voice_history.go

@@ -0,0 +1,43 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxResearchSummaryVoiceHistory struct {
+	Id          int       `orm:"column(id);pk"`
+	ArticleId  int       `description:"文章ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName      string    `description:"所属销售"`
+	PlaySeconds     string    `description:"播放时间 单位s"`
+	ModifyTime      time.Time `description:"视频修改时间"`
+}
+
+//添加
+func AddCygxResearchSummaryVoiceHistory(item *CygxResearchSummaryVoiceHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func GetLastCygxResearchSummaryVoiceHistory(articleId, userId int) (item *CygxResearchSummaryVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_research_summary_voice_history WHERE article_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, articleId, userId).QueryRow(&item)
+	return
+}
+
+func UpdateLastCygxResearchSummaryVoiceHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_research_summary_voice_history SET play_seconds =? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}
+

+ 18 - 0
routers/commentsRouter.go

@@ -997,6 +997,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportController"],
+        beego.ControllerComments{
+            Method: "ResearchSummaryVoiceHistoryAdd",
+            Router: `/voiceHistory/add`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
         beego.ControllerComments{
             Method: "ArticleHotList",
@@ -1303,6 +1312,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "Tracking",
+            Router: `/tracking`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:WechatCommonController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:WechatCommonController"],
         beego.ControllerComments{
             Method: "GetSmsCode",

+ 56 - 0
services/page_history_record.go

@@ -0,0 +1,56 @@
+package services
+
+import (
+	"encoding/json"
+	"fmt"
+	"github.com/beego/beego/v2/server/web/context"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strings"
+	"time"
+)
+
+func AddCygxPageHistoryRecord(user *models.WxUserItem, Ctx *context.Context)  {
+	item := new(models.CygxPageHistoryRecord)
+	item.UserId = user.UserId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.Router = Ctx.Request.RequestURI
+	item.PageRouter = Ctx.Input.Query("PageRouter")
+	index := strings.Index(item.Router, "?")
+	if index != -1 {
+		item.Parameter = item.Router[index+1:]
+	}
+	if Ctx.Input.Method() == "POST" {
+		item.Parameter = string(Ctx.Input.RequestBody)
+		var pr models.PageRouter
+		err := json.Unmarshal(Ctx.Input.RequestBody, &pr)
+		if err != nil {
+			fmt.Println(err)
+			utils.FileLog.Info(err.Error())
+		}
+		item.PageRouter = pr.PageRouter
+	}
+	if strings.Contains(item.Router, "/api/article/detail") {
+		cacheKey := fmt.Sprint("uid:", user.UserId, "_Parameter:", item.Parameter)
+		isExist := utils.Rc.IsExist(cacheKey)
+		if !isExist {
+			setNX := utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*10)
+			if !setNX {
+				go utils.SendAlarmMsg("记录用户阅读文章,设置Redis Key 过期时间失败:key"+cacheKey, 3)
+			}
+			return
+		}
+	}
+
+
+	_, err := models.AddCygxPageHistoryRecord(item)
+	if err != nil {
+		fmt.Println(err)
+		utils.FileLog.Info(err.Error())
+		return
+	}
+}

+ 8 - 0
utils/common.go

@@ -812,3 +812,11 @@ func GetLastMonthLastDay() time.Time {
 	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
 	return nowMonthLastDay
 }
+
+//字符串转换为time
+func StrDateToTime(strTime string) time.Time {
+	timeLayout := "2006-01-02"  //转化所需模板
+	loc, _ := time.LoadLocation("Local") //重要:获取时区
+	resultTime, _ := time.ParseInLocation(timeLayout, strTime, loc)
+	return resultTime
+}