Explorar o código

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_12.6

xingzai hai 1 ano
pai
achega
22234ebfd9

+ 1 - 49
controllers/activity.go

@@ -3694,7 +3694,6 @@ func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
 	var req models.ActivityIdRep
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
@@ -3717,55 +3716,8 @@ func (this *ActivityCoAntroller) ActivityVoiceHistoryAdd() {
 		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.CygxActivityVoiceHistory{
-		ActivityId:  activityId,
-		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.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
-		if err != nil {
-			br.Msg = "操作失败"
-			br.ErrMsg = "操作失败,GetLastCygxActivityVoiceHistory Err:" + err.Error()
-			return
-		}
-		err = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
-		if err != nil {
-			br.Msg = "更新失败"
-			br.ErrMsg = "更新失败,UpdateLastCygxActivityVoiceHistory Err:" + err.Error()
-			return
-		}
-	} else {
-		err = models.AddCygxActivityVoiceHistory(&item)
-		if err != nil {
-			br.Msg = "操作失败"
-			br.ErrMsg = "操作失败,Err:" + err.Error()
-			return
-		}
-		err = models.UpdateCygxActivityVoiceCounts(activityId)
-		if err != nil {
-			br.Msg = "更新失败"
-			br.ErrMsg = "更新失败,Err:" + err.Error()
-			return
-		}
-		go services.ActivityVideoUserRmind(user, activityId, 2)
-	}
+	go services.AddActivityVoiceHistory(user, activityId, playSeconds)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"

+ 10 - 2
controllers/home.go

@@ -582,6 +582,7 @@ func (this *HomeController) ListHomeArtAndChart() {
 // @Title 首页列表接口
 // @Description 首页列表接口
 // @Param   TagIds   query   string  true       "标签选择"
+// @Param   ChartPermissionId   query   int	  false     "行业id"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Success 200 {object} models.HomeArtAndChartListResp
@@ -602,6 +603,7 @@ func (this *HomeController) NewList() {
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	tagIds := this.GetString("TagIds")
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
 
 	var startSize int
 	if pageSize <= 0 {
@@ -837,9 +839,15 @@ func (this *HomeController) NewList() {
 			return
 		}
 		conditionInit += conditionTagIdsInit
-	} else {
+	}
+	//行业筛选
+	if chartPermissionId > 0 {
+		conditionInit += " AND chart_permission_id  =  " + strconv.Itoa(chartPermissionId)
+	}
+
+	if tagIds == "" && chartPermissionId == 0 {
 		//查询近一个月的数据
-		conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
+		conditionInit += " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
 	}
 
 	//conditionInit += `  AND source IN ('newchart')`

+ 181 - 169
controllers/micro_roadshow.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"encoding/json"
+	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/services"
@@ -21,14 +22,11 @@ type MicroRoadShowController struct {
 // @Param   PageSize		query	int		true	"每页数据条数"
 // @Param   CurrentIndex	query	int		true	"当前页页码,从1开始"
 // @Param   KeyWord			query	string	false	"搜索关键词"
-// @Param   AudioId			query	int		false	"音频ID"
-// @Param   VideoId			query	int		false	"视频ID"
-// @Param   AudioIds			query	string		false	"活动音频IDs"
-// @Param   ActivityVideoIds	query	string		false	"活动视频IDs"
-// @Param   VideoIds			query	string		false	"视频IDs"
-// @Param   ActivityVideoId			query	int		false	"活动视频ID"
-// @Param   Filter			query	string		false	"筛选条件 为空:全部 1:视频 2:音频 3:逻辑解析 4:路演回放 多个用 , 隔开"
+// @Param   Filter			query	string		false	"筛选条件 为空:全部 1:视频 2:音频  多个用 , 隔开"
 // @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   SourceId		query	int		true	"资源ID"
+// @Param   SourceType		query	int		true	" 1:活动音频  2:活动视频 3:产业视频 4:问答系列"
+// @Param   SearchType	string	int		true	"搜索类型: 1-路演回放; 2-问答系列; 3-调研反馈   多个用 , 隔开"
 // @Success 200 {object} models.HomeListResp
 // @router /list [get]
 func (this *MicroRoadShowController) List() {
@@ -47,14 +45,11 @@ func (this *MicroRoadShowController) List() {
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	keywords := this.GetString("KeyWord")
-	audioId, _ := this.GetInt("AudioId")
-	videoId, _ := this.GetInt("VideoId")
-	audioIds := this.GetString("AudioIds")
-	videoIds := this.GetString("VideoIds")
-	activityVideoIds := this.GetString("ActivityVideoIds")
-	activityVideoId, _ := this.GetInt("ActivityVideoId")
 	filter := this.GetString("Filter")
 	chartPermissionIds := this.GetString("ChartPermissionIds")
+	sourceId, _ := this.GetInt("SourceId")
+	sourceType, _ := this.GetInt("SourceType")
+	searchType := this.GetString("SearchType")
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
 	}
@@ -76,41 +71,13 @@ func (this *MicroRoadShowController) List() {
 	var total int
 	var e error
 	// 微路演列表
-	list, total, e = services.GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId, filter, keywords, audioIds, videoIds, activityVideoIds, chartPermissionIds)
+	list, total, e = services.GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, sourceType, filter, keywords, searchType, chartPermissionIds)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
 		return
 	}
-	if keywords != "" {
-		var pageSizeIk int
-		//获取总的数量
-		totalIk, e := services.CountMicroRoadShowPageListIkWord(audioId, videoId, activityVideoId, keyWordArr, filter, audioIds, videoIds, activityVideoIds)
-		if e != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取微路演联想词列表失败, Err: " + e.Error()
-			return
-		}
-		pageSizeIk = totalIk - len(list)
-		//处理IK分词部分的分页获取条数
-		startSizeIk := utils.StartIndex(currentIndex, pageSize)
-		startSizeIk = startSizeIk - total
-		if startSizeIk < 0 {
-			startSizeIk = 0
-		}
-		if pageSizeIk > 0 {
-			lisIk, e := services.GetMicroRoadShowPageListIkWord(startSizeIk, pageSizeIk, audioId, videoId, activityVideoId, keyWordArr, filter, audioIds, videoIds, activityVideoIds, keywords)
-			if e != nil {
-				br.Msg = "获取失败"
-				br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
-				return
-			}
-			for _, item := range lisIk {
-				list = append(list, item)
-			}
-		}
-		total = totalIk
-	}
+
 	userId := user.UserId
 	listMycollect, err := models.GetUserMicroRoadshowCollectList(userId)
 	if err != nil {
@@ -121,15 +88,30 @@ func (this *MicroRoadShowController) List() {
 	mapaudioIds := make(map[int]int)         //活动音频
 	mapvideoIds := make(map[int]int)         // 微路演视频
 	mapactivityVideoIds := make(map[int]int) // 活动视频
+	mapAskserieVideoIds := make(map[int]int) // 问答系列音频
 	for _, item := range listMycollect {
 		if item.ActivityVoiceId > 0 {
 			mapaudioIds[item.ActivityVoiceId] = item.ActivityVoiceId
 		} else if item.VideoId > 0 {
 			mapvideoIds[item.VideoId] = item.VideoId
 		} else if item.ActivityVideoId > 0 {
-			mapactivityVideoIds[item.ActivityVoiceId] = item.ActivityVoiceId
+			mapactivityVideoIds[item.ActivityVideoId] = item.ActivityVideoId
+		}
+	}
+
+	listAskserieVideoCollect, err := models.GetUserCygxAskserieVideoCollectList(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
+	for _, v := range listAskserieVideoCollect {
+		if v.AskserieVideoId > 0 {
+			mapAskserieVideoIds[v.AskserieVideoId] = v.AskserieVideoId
 		}
 	}
+
 	for _, item := range list {
 		if item.Type == 1 {
 			//音频
@@ -146,6 +128,11 @@ func (this *MicroRoadShowController) List() {
 			if mapvideoIds[item.Id] > 0 {
 				item.IsCollect = true
 			}
+		} else if item.Type == 4 {
+			//系列问答视频
+			if mapAskserieVideoIds[item.SourceId] > 0 {
+				item.IsCollect = true
+			}
 		}
 	}
 	// 用户权限
@@ -242,7 +229,6 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
 	var req models.AddVideoHistoryReq
 	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
 	if err != nil {
@@ -250,71 +236,25 @@ func (this *MicroRoadShowController) VideoHistoryAdd() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-
-	videoId := req.VideoId
+	sourceId := req.SourceId
 	playSeconds := req.PlaySeconds
 	sourceType := req.SourceType
-
 	if sourceType == 0 {
 		sourceType = 1
 	}
-	var sellerName string
-	sellerName, err = models.GetCompanySellerName(user.CompanyId)
-	if err != nil {
-		br.Msg = "报名失败!"
-		br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
-		return
-	}
 	if sourceType == 1 {
-		item := models.CygxMicroRoadshowVideoHistory{
-			VideoId:     videoId,
-			UserId:      uid,
-			Mobile:      user.Mobile,
-			Email:       user.Email,
-			CompanyId:   user.CompanyId,
-			CompanyName: user.CompanyName,
-			RealName:    user.RealName,
-			SellerName:  sellerName,
-			PlaySeconds: strconv.Itoa(playSeconds),
-			CreateTime:  time.Now(),
-			ModifyTime:  time.Now(),
-		}
-		if playSeconds != 0 {
-			lastItem, err := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
-			if err != nil {
-				br.Msg = "操作失败"
-				br.ErrMsg = "操作失败,GetLastCygxMicroRoadshowVideoHistory Err:" + err.Error()
-				return
-			}
-			err = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
-			if err != nil {
-				br.Msg = "更新失败"
-				br.ErrMsg = "更新失败,UpdateLastCygxActivityVideoHistory Err:" + err.Error()
-				return
-			}
-		} else {
-			err = models.AddCygxMicroRoadshowVideoHistory(&item)
-			if err != nil {
-				br.Msg = "操作失败"
-				br.ErrMsg = "操作失败,Err:" + err.Error()
-				return
-			}
-			err = models.UpdateCygxActivityVideoCounts(videoId)
-			if err != nil {
-				br.Msg = "更新失败"
-				br.ErrMsg = "更新失败,Err:" + err.Error()
-				return
-			}
-		}
-		go services.MicroRoadshowVideoUserRmind(user, videoId)
+		//添加活动音频的播放记录
+		go services.AddActivityVoiceHistory(user, sourceId, playSeconds)
 	} else if sourceType == 2 {
-		err = services.AddActivityVideoHistory(user, videoId)
-		if err != nil {
-			br.Msg = "更新失败"
-			br.ErrMsg = "更新失败,AddActivityVideoHistory Err:" + err.Error()
-			return
-		}
+		//添加活动视频的播放记录
+		go services.AddActivityVideoHistory(user, sourceId, playSeconds)
+	} else if sourceType == 3 {
+		// 添加产业视频播放记录
+		go services.AddMicroRoadshowVideoRecord(user, sourceId, playSeconds)
+	} else if sourceType == 4 {
+		go services.AddAskserieVideoHistoryRecord(user, sourceId, playSeconds)
 	}
+	go services.AddAllCygxVoiceAndVideoHistory(user, sourceId, sourceType, playSeconds)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
@@ -353,6 +293,7 @@ func (this *MicroRoadShowController) CommentAdd() {
 	if sourceType == 0 {
 		sourceType = 1
 	}
+	fmt.Println(sourceType)
 	item := models.CygxArticleComment{
 		UserId:      uid,
 		CreateTime:  time.Now(),
@@ -364,45 +305,58 @@ func (this *MicroRoadShowController) CommentAdd() {
 		Content:     req.Content,
 		Title:       req.Title,
 	}
-
+	sourceId := req.SourceId
 	//var resourceId int
 	if sourceType == 1 {
-		activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(req.Id)
+		activityVoiceInfo, _ := models.GetCygxActivityVoiceByActivityId(sourceId)
 		if activityVoiceInfo == nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
 			return
 		}
-		item.ActivityId = req.Id
+		item.ActivityId = sourceId
 		item.ActivityVoiceId = activityVoiceInfo.ActivityVoiceId
-		//resourceId = activityVoiceInfo.ActivityId
+		err = models.UpdateActivityVoiceCommentNum(sourceId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败 ,更新活动音频留言次数失败:" + strconv.Itoa(sourceId)
+			return
+		}
 	} else if sourceType == 2 {
-		activityInfo, _ := models.GetCygxActivityVideoByActivityId(req.Id)
+		activityInfo, _ := models.GetCygxActivityVideoByActivityId(sourceId)
 		if activityInfo == nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
 			return
 		}
 		item.VideoId = activityInfo.VideoId
-		item.ActivityId = req.Id
-		//resourceId = activityInfo.ActivityId
+		item.ActivityId = sourceId
+		err = models.UpdateActivityVideoCommentNum(sourceId)
+		if err != nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "操作失败 ,更新活动视频留言次数失败:" + strconv.Itoa(sourceId)
+			return
+		}
 	} else if sourceType == 3 {
-		item.VideoId = req.Id
-		microVideo, e := models.GetMicroRoadshowVideoById(req.Id)
+		item.VideoId = sourceId
+		microVideo, e := models.GetMicroRoadshowVideoById(sourceId)
 		if e != nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(req.Id)
+			br.ErrMsg = "微路演视频信息有误, 不存在的VideoId: " + strconv.Itoa(sourceId)
 			return
 		}
 		item.IndustryId = microVideo.IndustryId
 		//resourceId = microVideo.IndustryId
+	} else if sourceType == 4 {
+		item.AskserieVideoId = sourceId
+		go services.AddCygxAskserieVideoCollection(user, item.AskserieVideoId, req.Content)
 	}
 
-	if sourceType == 2 || sourceType == 3 {
-		detail, err := models.GetAddActivityInfoById(req.Id)
+	if sourceType == 1 || sourceType == 2 {
+		detail, err := models.GetAddActivityInfoById(sourceId)
 		if err != nil {
 			br.Msg = "操作失败"
-			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(req.Id)
+			br.ErrMsg = "活动ID错误,不存在activityId:" + strconv.Itoa(sourceId)
 			return
 		}
 		if strings.Contains(detail.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
@@ -448,15 +402,15 @@ func (this *MicroRoadShowController) Collect() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-
+	sourceId := req.SourceId
 	if req.SourceType == 1 {
-		_, err := models.GetCygxActivityVoiceById(req.Id)
+		detail, err := models.GetCygxActivityVoiceByActivityId(sourceId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
-		count, err := models.GetVoiceCollectCount(uid, req.Id)
+		count, err := models.GetVoiceCollectCount(uid, detail.ActivityVoiceId)
 		if err != nil {
 			br.Msg = "获取数据失败!"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -465,7 +419,7 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxArticleCollect)
-			item.ActivityVoiceId = req.Id
+			item.ActivityVoiceId = detail.ActivityVoiceId
 			item.UserId = uid
 			item.CreateTime = time.Now()
 			item.Mobile = user.Mobile
@@ -484,7 +438,7 @@ func (this *MicroRoadShowController) Collect() {
 			// 文章收藏消息发送
 			//go services.ArticleUserRemind(user, detail, 2)
 		} else {
-			err = models.RemoveVoiceCollect(uid, req.Id)
+			err = models.RemoveVoiceCollect(uid, detail.ActivityVoiceId)
 			if err != nil {
 				br.Msg = "取消收藏失败"
 				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
@@ -493,7 +447,7 @@ func (this *MicroRoadShowController) Collect() {
 			br.Msg = "已取消收藏"
 			resp.Status = 2
 		}
-		collectTotal, err := models.GetVoiceCollectUsersCount(req.Id)
+		collectTotal, err := models.GetVoiceCollectUsersCount(detail.ActivityVoiceId)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -504,13 +458,13 @@ func (this *MicroRoadShowController) Collect() {
 		br.Success = true
 		br.Data = resp
 	} else if req.SourceType == 2 {
-		_, err := models.GetCygxActivityVideoById(req.Id)
+		detail, err := models.GetCygxActivityVideoByActivityIdInfo(sourceId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
-		count, err := models.GetActivityVideoCollectCount(uid, req.Id)
+		count, err := models.GetActivityVideoCollectCount(uid, detail.Id)
 		if err != nil {
 			br.Msg = "获取数据失败!"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -519,9 +473,10 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxArticleCollect)
-			item.ActivityVideoId = req.Id
+			item.ActivityVideoId = detail.Id
 			item.UserId = uid
 			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
 			item.Mobile = user.Mobile
 			item.Email = user.Email
 			item.CompanyId = user.CompanyId
@@ -538,7 +493,7 @@ func (this *MicroRoadShowController) Collect() {
 			// 文章收藏消息发送
 			//go services.ArticleUserRemind(user, detail, 2)
 		} else {
-			err = models.RemoveActivityVideoCollect(uid, req.Id)
+			err = models.RemoveActivityVideoCollect(uid, detail.Id)
 			if err != nil {
 				br.Msg = "取消收藏失败"
 				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
@@ -547,7 +502,7 @@ func (this *MicroRoadShowController) Collect() {
 			br.Msg = "已取消收藏"
 			resp.Status = 2
 		}
-		collectTotal, err := models.GetActivityVideoCollectUsersCount(req.Id)
+		collectTotal, err := models.GetActivityVideoCollectUsersCount(detail.Id)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -558,13 +513,13 @@ func (this *MicroRoadShowController) Collect() {
 		br.Success = true
 		br.Data = resp
 	} else if req.SourceType == 3 {
-		_, err := models.GetMicroRoadshowVideoById(req.Id)
+		_, err := models.GetMicroRoadshowVideoById(sourceId)
 		if err != nil {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取信息失败,Err:" + err.Error()
 			return
 		}
-		count, err := models.GetVideoCollectCount(uid, req.Id)
+		count, err := models.GetVideoCollectCount(uid, sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败!"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -573,7 +528,7 @@ func (this *MicroRoadShowController) Collect() {
 		resp := new(models.ArticleCollectResp)
 		if count <= 0 {
 			item := new(models.CygxArticleCollect)
-			item.VideoId = req.Id
+			item.VideoId = sourceId
 			item.UserId = uid
 			item.CreateTime = time.Now()
 			item.Mobile = user.Mobile
@@ -592,7 +547,7 @@ func (this *MicroRoadShowController) Collect() {
 			// 文章收藏消息发送
 			//go services.ArticleUserRemind(user, detail, 2)
 		} else {
-			err = models.RemoveVideoCollect(uid, req.Id)
+			err = models.RemoveVideoCollect(uid, sourceId)
 			if err != nil {
 				br.Msg = "取消收藏失败"
 				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
@@ -601,7 +556,7 @@ func (this *MicroRoadShowController) Collect() {
 			br.Msg = "已取消收藏"
 			resp.Status = 2
 		}
-		collectTotal, err := models.GetVideoCollectUsersCount(req.Id)
+		collectTotal, err := models.GetVideoCollectUsersCount(sourceId)
 		if err != nil {
 			br.Msg = "获取数据失败"
 			br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -611,6 +566,49 @@ func (this *MicroRoadShowController) Collect() {
 		br.Ret = 200
 		br.Success = true
 		br.Data = resp
+	} else if req.SourceType == 4 {
+		// 系列问答视频收藏
+		count, err := models.GetAskserieVideoCount(uid, sourceId)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "获取数据失败,Err:" + err.Error()
+			return
+		}
+		resp := new(models.ArticleCollectResp)
+		if count <= 0 {
+			item := new(models.CygxAskserieVideoCollect)
+			item.AskserieVideoId = sourceId
+			item.UserId = uid
+			item.CreateTime = time.Now()
+			item.Mobile = user.Mobile
+			item.Email = user.Email
+			item.CompanyId = user.CompanyId
+			item.CompanyName = user.CompanyName
+			item.RealName = user.RealName
+			item.RegisterPlatform = utils.REGISTER_PLATFORM
+			err = models.AddCygxAskserieVideoCollect(item)
+			if err != nil {
+				br.Msg = "收藏失败"
+				br.ErrMsg = "收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "收藏成功"
+			resp.Status = 1
+			// 文章收藏消息发送
+			//go services.ArticleUserRemind(user, detail, 2)
+		} else {
+			err = models.RemoveAskserieVideoCollect(uid, sourceId)
+			if err != nil {
+				br.Msg = "取消收藏失败"
+				br.ErrMsg = "取消收藏失败,Err:" + err.Error()
+				return
+			}
+			br.Msg = "已取消收藏"
+			resp.Status = 2
+		}
+		br.Ret = 200
+		br.Success = true
+		br.Data = resp
 	}
 }
 
@@ -650,9 +648,17 @@ func (this *MicroRoadShowController) Mycollect() {
 		return
 	}
 
+	listAskserieVideoCollect, err := models.GetUserCygxAskserieVideoCollectList(userId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+
 	var audioIds []string
 	var videoIds []string
 	var activityVideoIds []string
+	var askserieVideoIds []string //问答系列视频
 	for _, item := range listMycollect {
 		if item.ActivityVoiceId > 0 {
 			audioIds = append(audioIds, strconv.Itoa(item.ActivityVoiceId))
@@ -662,7 +668,10 @@ func (this *MicroRoadShowController) Mycollect() {
 			activityVideoIds = append(activityVideoIds, strconv.Itoa(item.ActivityVideoId))
 		}
 	}
-	if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 {
+	for _, item := range listAskserieVideoCollect {
+		askserieVideoIds = append(askserieVideoIds, strconv.Itoa(item.AskserieVideoId))
+	}
+	if len(audioIds) == 0 && len(videoIds) == 0 && len(activityVideoIds) == 0 && len(askserieVideoIds) == 0 {
 		resp := new(models.MicroRoadShowListResp)
 		page := paging.GetPaging(currentIndex, pageSize, 0)
 		resp.List = make([]*models.MicroRoadShowPageList, 0)
@@ -677,48 +686,51 @@ func (this *MicroRoadShowController) Mycollect() {
 	audioIdstr := strings.Join(audioIds, ",")
 	ideoIdsStr := strings.Join(videoIds, ",")
 	activityVideoIdsStr := strings.Join(activityVideoIds, ",")
+	askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
 	// 微路演列表
-	list, total, e := services.GetMicroRoadShowMycollect(pageSize, currentIndex, audioIdstr, ideoIdsStr, activityVideoIdsStr)
+	list, total, e := services.GetMicroRoadShowMycollectV12(pageSize, currentIndex, audioIdstr, activityVideoIdsStr, ideoIdsStr, askserieVideoIdsStr, user)
 	if e != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取微路演列表失败, Err: " + e.Error()
 		return
 	}
 	for _, item := range list {
-		if item.Type == 1 {
-			//音频
-			count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
-			if err != nil {
-				br.Msg = "获取数据失败!"
-				br.ErrMsg = "获取数据失败,Err:" + err.Error()
-				return
-			}
-			if count > 0 {
-				item.IsCollect = true
-			}
-		} else if item.Type == 2 {
-			//活动视频
-			count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
-			if err != nil {
-				br.Msg = "获取数据失败!"
-				br.ErrMsg = "获取数据失败,Err:" + err.Error()
-				return
-			}
-			if count > 0 {
-				item.IsCollect = true
-			}
-		} else if item.Type == 3 {
-			//微路演视频
-			count, err := models.GetVideoCollectCount(user.UserId, item.Id)
-			if err != nil {
-				br.Msg = "获取数据失败!"
-				br.ErrMsg = "获取数据失败,Err:" + err.Error()
-				return
-			}
-			if count > 0 {
-				item.IsCollect = true
-			}
-		}
+		//if item.Type == 1 {
+		//	//音频
+		//	count, err := models.GetVoiceCollectCount(user.UserId, item.Id)
+		//	if err != nil {
+		//		br.Msg = "获取数据失败!"
+		//		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		//		return
+		//	}
+		//	if count > 0 {
+		//		item.IsCollect = true
+		//	}
+		//} else if item.Type == 2 {
+		//	//活动视频
+		//	count, err := models.GetActivityVideoCollectCount(user.UserId, item.Id)
+		//	if err != nil {
+		//		br.Msg = "获取数据失败!"
+		//		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		//		return
+		//	}
+		//	if count > 0 {
+		//		item.IsCollect = true
+		//	}
+		//} else if item.Type == 3 {
+		//	//微路演视频
+		//	count, err := models.GetVideoCollectCount(user.UserId, item.Id)
+		//	if err != nil {
+		//		br.Msg = "获取数据失败!"
+		//		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		//		return
+		//	}
+		//	if count > 0 {
+		//		item.IsCollect = true
+		//	}
+		//}
+
+		item.IsCollect = true
 	}
 	// 用户权限
 	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)

+ 14 - 5
controllers/tag.go

@@ -49,19 +49,15 @@ func (this *TagController) TagCustomizeList() {
 	list, err := models.GetCygxTagList(condition)
 	for _, v := range list {
 		if v.ArticleTypes != "" {
-			v.Atag = true
 			v.CheckList = append(v.CheckList, "A")
 		}
 		if v.ActivityTypes != "" {
-			v.Btag = true
 			v.CheckList = append(v.CheckList, "B")
 		}
 		if v.Industries != "" {
-			v.Ctag = true
 			v.CheckList = append(v.CheckList, "C")
 		}
 		if v.SubjectNames != "" {
-			v.Dtag = true
 			v.CheckList = append(v.CheckList, "D")
 		}
 	}
@@ -71,10 +67,23 @@ func (this *TagController) TagCustomizeList() {
 		return
 	}
 
+	//var condition string
+	condition = ` AND permission_name IN ('医药','消费','科技','智造','策略') `
+	listPermission, err := models.GetChartPermissionReportAll(condition)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(models.CygxTagListResp)
+
+	resp.List = list
+	resp.ListPermission = listPermission
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"
-	br.Data = list
+	br.Data = resp
 }
 
 // @Title 记录点击信息

+ 39 - 0
models/activity_video.go

@@ -122,6 +122,45 @@ func GetActivityVideoActivityIds() (activityIds string, err error) {
 	return
 }
 
+type CygxActivityVideoDetailResp struct {
+	ActivityId          int    ` description:"活动ID"`
+	Id                  int    `description:"视频ID"`
+	Title               string `description:"标题"`
+	ResourceUrl         string `description:"链接"`
+	BackgroundImg       string `description:"背景图"`
+	PlaySeconds         int    `description:"音视频时长"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频 、 4-系列问答视频"`
+}
+
+// GetCygxActivityVideoById 获取活动视频
+func GetCygxActivityVideoByActivityIdInfo(activityId int) (item *CygxActivityVideoDetailResp, err error) {
+	sql := `SELECT
+			v.video_id AS id,
+			v.video_name AS title,
+			v.video_url AS resource_url,
+			v.video_duration AS play_seconds,
+			v.activity_id,
+			a.chart_permission_id,
+			a.chart_permission_name
+		FROM
+			cygx_activity_video AS v
+			INNER JOIN cygx_activity AS a  ON  v.activity_id = a.activity_id
+		WHERE
+			 v.activity_id = ? 
+			LIMIT 1 `
+	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
+	return
+}
+
+func UpdateActivityVideoCommentNum(activityId int) (err error) {
+	sql := `UPDATE cygx_activity_video SET comment_num = comment_num+1 WHERE activity_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}
+
 // 修改
 func UpdateCygxActivityVideo(item *CygxActivityVideo) (err error) {
 	to := orm.NewOrm()

+ 38 - 16
models/activity_video_history.go

@@ -6,29 +6,30 @@ import (
 )
 
 type CygxActivityVideoHistory struct {
-	Id          int       `orm:"column(id);pk"description:"音频id"`
-	VideoId     int       `description:"微路演音频id"`
-	ActivityId  int       `description:"活动id"`
-	UserId      int       `description:"用户id"`
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司Id"`
-	CompanyName string    `description:"公司名称"`
-	RealName    string    `description:"用户实际名称"`
-	SellerName  string    `description:"所属销售"`
-	PlaySeconds string    `description:"播放时间 单位s"`
-	CreateTime  time.Time `description:"视频创建时间"`
-	ModifyTime  time.Time `description:"视频修改时间"`
+	Id               int       `orm:"column(id);pk"description:"音频id"`
+	VideoId          int       `description:"微路演音频id"`
+	ActivityId       int       `description:"活动id"`
+	UserId           int       `description:"用户id"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司Id"`
+	CompanyName      string    `description:"公司名称"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	PlaySeconds      string    `description:"播放时间 单位s"`
+	CreateTime       time.Time `description:"视频创建时间"`
+	ModifyTime       time.Time `description:"视频修改时间"`
+	RegisterPlatform int       // 来源 1小程序,2:网页
 }
 
-//添加
+// 添加
 func AddCygxActivityVideoHistory(item *CygxActivityVideoHistory) (err error) {
 	o := orm.NewOrm()
 	_, err = o.Insert(item)
 	return
 }
 
-//获取列表信息根据手机号分组
+// 获取列表信息根据手机号分组
 func GetActivityVideoHistoryByMobileList(condition string) (items []*CygxActivityVideoHistory, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_activity_video_history  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
@@ -36,7 +37,7 @@ func GetActivityVideoHistoryByMobileList(condition string) (items []*CygxActivit
 	return
 }
 
-//修改用户浏览活动视频的相关信息
+// 修改用户浏览活动视频的相关信息
 func UpdateCygxActivityVideoHistory(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string
@@ -49,3 +50,24 @@ func UpdateCygxActivityVideoHistory(wxUser *WxUserItem) (err error) {
 	}
 	return
 }
+
+func GetLastCygxActivityVideoHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_activity_video_history WHERE activity_id=?  AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, activityId, userId).QueryRow(&item)
+	return
+}
+
+//func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
+//	o := orm.NewOrm()
+//	sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
+//	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+//	return
+//}
+
+func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_activity_video_history SET play_seconds = play_seconds +? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}

+ 7 - 0
models/activity_voice.go

@@ -130,6 +130,13 @@ func GetActivityVoiceActivityIds() (activityIds string, err error) {
 	return
 }
 
+func UpdateActivityVoiceCommentNum(activityId int) (err error) {
+	sql := `UPDATE cygx_activity_voice SET comment_num = comment_num+1 WHERE activity_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, activityId).Exec()
+	return
+}
+
 // 修改
 func UpdateCygxActivityVoice(item *CygxActivityVoice) (err error) {
 	to := orm.NewOrm()

+ 18 - 17
models/activity_voice_history.go

@@ -6,21 +6,22 @@ import (
 )
 
 type CygxActivityVoiceHistory struct {
-	Id          int       `orm:"column(id);pk"`
-	ActivityId  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:"视频修改时间"`
+	Id               int       `orm:"column(id);pk"`
+	ActivityId       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:"视频修改时间"`
+	RegisterPlatform int       // 来源 1小程序,2:网页
 }
 
-//添加
+// 添加
 func AddCygxActivityVoiceHistory(item *CygxActivityVoiceHistory) (err error) {
 	o := orm.NewOrm()
 	_, err = o.Insert(item)
@@ -29,19 +30,19 @@ func AddCygxActivityVoiceHistory(item *CygxActivityVoiceHistory) (err error) {
 
 func GetLastCygxActivityVoiceHistory(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * FROM cygx_activity_voice_history WHERE activity_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	sql := ` SELECT * FROM cygx_activity_voice_history WHERE activity_id=?  AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
 	err = o.Raw(sql, activityId, userId).QueryRow(&item)
 	return
 }
 
 func UpdateLastCygxActivityVoiceHistory(playSeconds string, lastId int) (err error) {
 	o := orm.NewOrm()
-	sql := ` UPDATE cygx_activity_voice_history SET play_seconds =? WHERE id=? `
+	sql := ` UPDATE cygx_activity_voice_history SET play_seconds = play_seconds +? WHERE id=? `
 	_, err = o.Raw(sql, playSeconds, lastId).Exec()
 	return
 }
 
-//获取列表信息根据手机号分组
+// 获取列表信息根据手机号分组
 func GetActivityVoiceHistoryByMobileList(condition string) (items []*CygxActivityVoiceHistory, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_activity_voice_history  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
@@ -49,7 +50,7 @@ func GetActivityVoiceHistoryByMobileList(condition string) (items []*CygxActivit
 	return
 }
 
-//修改用户浏览活动音频的相关信息
+// 修改用户浏览活动音频的相关信息
 func UpdateCygxActivityVoiceHistory(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string

+ 25 - 0
models/article_category_mapping.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"time"
 	//"time"
 )
 
@@ -79,3 +80,27 @@ func GetCygxReportMappingCygxByCategoryId(categoryId int) (item *CygxReportMappi
 	err = o.Raw(sql, categoryId).QueryRow(&item)
 	return
 }
+
+type CygxReportMappingCelue struct {
+	Id                  int       `orm:"column(id);pk" description:"id"`
+	ChartPermissionId   int       `description:"行业ID"`
+	CategoryId          int       `description:"分类ID"`
+	ChartPermissionName string    `description:"行业名称"`
+	SubCategoryName     string    `description:"主题"`
+	ReportType          int       `description:"报告类型,2产业报告,1行业报告"`
+	Sort                int       `description:"排序"`
+	IsCustom            int       `description:"是否属于自定义的匹配类型 ,1是,0否"`
+	IsSummary           int       `description:"是否是纪要库,1是,0否"`
+	IsReport            int       `description:"是否是报告,1是,0否"`
+	PermissionType      int       `description:"1主观,2客观"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"更新时间"`
+}
+
+// 通过 categoryId 获取详情
+func GetCygxReportMappingCelueMaxDetailByCategoryId(categoryId int) (item *CygxReportMappingCelue, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  * FROM cygx_report_mapping_celue  WHERE  category_id = ?  LIMIT 1 `
+	err = o.Raw(sql, categoryId).QueryRow(&item)
+	return
+}

+ 6 - 5
models/article_collect.go

@@ -14,11 +14,12 @@ type CygxArticleCollect struct {
 	VideoId         int
 	UserId          int
 	CreateTime      time.Time
-	Mobile          string `description:"手机号"`
-	Email           string `description:"邮箱"`
-	CompanyId       int    `description:"公司id"`
-	CompanyName     string `description:"公司名称"`
-	RealName        string `description:"用户实际名称"`
+	ModifyTime      time.Time `description:"更新时间"`
+	Mobile          string    `description:"手机号"`
+	Email           string    `description:"邮箱"`
+	CompanyId       int       `description:"公司id"`
+	CompanyName     string    `description:"公司名称"`
+	RealName        string    `description:"用户实际名称"`
 }
 
 // 添加收藏信息

+ 1 - 0
models/article_comment.go

@@ -13,6 +13,7 @@ type CygxArticleComment struct {
 	ActivityId      int       `description:"活动id"`
 	VideoId         int       `description:"视频id"`
 	ActivityVoiceId int       `description:"活动音频ID"`
+	AskserieVideoId int       `description:" 系列问答视频ID askserie_video_id"`
 	IndustryId      int       `description:"产业id"`
 	CreateTime      time.Time `description:"创建时间"`
 	Mobile          string    `description:"手机号"`

+ 49 - 0
models/askserie_video_collect.go

@@ -0,0 +1,49 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxAskserieVideoCollect struct {
+	Id               int       `orm:"column(id);pk"`
+	AskserieVideoId  int       `description:"askserie_video_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:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	ModifyTime       time.Time `description:"更新时间"`
+}
+
+// 添加
+func AddCygxAskserieVideoCollect(item *CygxAskserieVideoCollect) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func RemoveAskserieVideoCollect(userId, askserieVideoId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_askserie_video_collect WHERE user_id=? AND askserie_video_id=? `
+	_, err = o.Raw(sql, userId, askserieVideoId).Exec()
+	return
+}
+
+func GetAskserieVideoCount(userId, askserieVideoId int) (count int, err error) {
+	sql := `SELECT COUNT(1) AS count FROM cygx_askserie_video_collect WHERE user_id=? AND askserie_video_id=? `
+	err = orm.NewOrm().Raw(sql, userId, askserieVideoId).QueryRow(&count)
+	return
+}
+
+func GetUserCygxAskserieVideoCollectList(userId int) (items []*CygxAskserieVideoCollect, err error) {
+	sql := `SELECT a.* FROM cygx_askserie_video_collect AS a 
+			WHERE a.user_id=?
+           ORDER BY a.id DESC `
+	_, err = orm.NewOrm().Raw(sql, userId).QueryRows(&items)
+	return
+}

+ 36 - 0
models/askserie_video_collection.go

@@ -0,0 +1,36 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxAskserieVideoCollection struct {
+	Id               int       `orm:"column(id);pk"`
+	AskserieVideoId  int       `description:"askserie_video_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:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	ModifyTime       time.Time `description:"更新时间"`
+	Content          string    `description:"留言内容"`
+}
+
+// 添加
+func AddCygxAskserieVideoCollection(item *CygxAskserieVideoCollection) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func UpdateAskserieVideoCommentNum(askserieVideoId int) (err error) {
+	sql := `UPDATE cygx_askserie_video SET comment_num = comment_num+1 WHERE askserie_video_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, askserieVideoId).Exec()
+	return
+}

+ 50 - 0
models/askserie_video_history_record.go

@@ -0,0 +1,50 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxAskserieVideoHistoryRecord struct {
+	Id               int       `orm:"column(id);pk"`
+	AskserieVideoId  int       `description:"askserie_video_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:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	ModifyTime       time.Time `description:"更新时间"`
+	VideoDuration    int       `description:"播放时长"`
+}
+
+// 添加
+func AddCygxAskserieVideoHistoryRecord(item *CygxAskserieVideoHistoryRecord) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+func UpdateAskserieVideoCounts(askserieVideoId int) (err error) {
+	sql := `UPDATE cygx_askserie_video SET video_counts = video_counts+1 WHERE askserie_video_id = ?  `
+	o := orm.NewOrm()
+	_, err = o.Raw(sql, askserieVideoId).Exec()
+	return
+}
+
+func GetLastCygxAskserieVideoHistoryRecord(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_askserie_video_history_record WHERE askserie_video_id=?  AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, activityId, userId).QueryRow(&item)
+	return
+}
+
+func UpdateLastCygxAskserieVideoHistoryRecord(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_askserie_video_history_record SET video_duration = video_duration+? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
+	return
+}

+ 1 - 0
models/chart_permission.go

@@ -10,6 +10,7 @@ type ChartPermission struct {
 	PermissionName    string `description:"权限名称"`
 	IsShowSustainable bool   `description:"是否展示限免标签"`
 	ImageUrlM         string `description:"图片地址"`
+	IsChoose          bool   `description:"是否选择"`
 }
 
 type ActivityChartPermission struct {

+ 22 - 24
models/cygx_tag.go

@@ -20,13 +20,6 @@ type CygxTag struct {
 	Status        int       `orm:"column(status);NOT NULL"`         // 状态:0-禁用 1-启用
 }
 
-// 添加标签
-func AddCygxTag(item *CygxTag) (id int64, err error) {
-	o := orm.NewOrm()
-	id, err = o.Insert(item)
-	return
-}
-
 func (m *CygxTag) Update(cols []string) (err error) {
 	o := orm.NewOrm()
 	_, err = o.Update(m, cols...)
@@ -34,23 +27,28 @@ func (m *CygxTag) Update(cols []string) (err error) {
 }
 
 type CygxTagList struct {
-	TagId         int64    `orm:"column(tag_id);pk"`
-	TagName       string   `orm:"column(tag_name);NOT NULL"`       // 标签名
-	ArticleTypes  string   `orm:"column(article_types);NOT NULL"`  // 报告系列
-	ActivityTypes string   `orm:"column(activity_types);NOT NULL"` // 活动类型
-	Industries    string   `orm:"column(industries);NOT NULL"`     // 产业
-	SubjectNames  string   `orm:"column(subject_names);NOT NULL"`  // 标的
-	Sort          int      `orm:"column(sort);"`                   // 优先级
-	ModifyTime    string   `orm:"column(modify_time)"`             // 修改时间
-	CreateTime    string   `orm:"column(create_time)"`             // 创建时间
-	OnlineTime    string   `orm:"column(online_time)"`             // 上线时间
-	OfflineTime   string   `orm:"column(offline_time)"`            // 下线时间
-	Status        int      `orm:"column(status);NOT NULL"`         // 状态:0-禁用 1-启用
-	Atag          bool     // A标签是否有值
-	Btag          bool     // A标签是否有值
-	Ctag          bool     // A标签是否有值
-	Dtag          bool     // A标签是否有值
-	CheckList     []string // ABCD勾选了哪几列
+	TagId         int64  `orm:"column(tag_id);pk"`
+	TagName       string `orm:"column(tag_name);NOT NULL"`       // 标签名
+	ArticleTypes  string `orm:"column(article_types);NOT NULL"`  // 报告系列
+	ActivityTypes string `orm:"column(activity_types);NOT NULL"` // 活动类型
+	Industries    string `orm:"column(industries);NOT NULL"`     // 产业
+	SubjectNames  string `orm:"column(subject_names);NOT NULL"`  // 标的
+	Sort          int    `orm:"column(sort);"`                   // 优先级
+	ModifyTime    string `orm:"column(modify_time)"`             // 修改时间
+	CreateTime    string `orm:"column(create_time)"`             // 创建时间
+	OnlineTime    string `orm:"column(online_time)"`             // 上线时间
+	OfflineTime   string `orm:"column(offline_time)"`            // 下线时间
+	Status        int    `orm:"column(status);NOT NULL"`         // 状态:0-禁用 1-启用
+	//Atag          bool     // A标签是否有值
+	//Btag          bool     // A标签是否有值
+	//Ctag          bool     // A标签是否有值
+	//Dtag          bool     // A标签是否有值
+	CheckList []string // ABCD勾选了哪几列
+}
+
+type CygxTagListResp struct {
+	List           []*CygxTagList
+	ListPermission []*ChartPermission
 }
 
 // 列表

+ 4 - 0
models/db.go

@@ -180,6 +180,10 @@ func init() {
 		new(CygxQuestionnaireVote),
 		new(CygxQuestionnaireVoteOtherTheme),
 		new(CygxMorningMeetingReviewChapterHistory),
+		new(CygxAskserieVideoHistoryRecord),
+		new(CygxAskserieVideoCollection),
+		new(CygxAskserieVideoCollect),
+		new(CygxVoiceAndVideoHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 132 - 14
models/micro_roadshow.go

@@ -44,9 +44,10 @@ func GetMicroRoadshowVideoByVideoId(videoId int) (item *CygxMicroRoadshowVideo,
 // MicroRoadShowPageList 微路演列表
 type MicroRoadShowPageList struct {
 	Id                  int    `description:"音视频ID"`
+	SourceId            int    `description:"资源ID"`
 	Title               string `description:"标题"`
 	ResourceUrl         string `description:"链接"`
-	Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
+	Type                int    `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
 	PublishTime         string `description:"发布时间"`
 	BackgroundImg       string `description:"背景图"`
 	ShareImg            string `description:"分享封面图"`
@@ -152,6 +153,120 @@ func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string,
 	return
 }
 
+// GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
+func GetMicroRoadShowVideoPageListV12(startSize, pageSize int, audioAct string, audioActPars []interface{}, videoAct string, videoActPars []interface{}, videoMico string, videoMicoPars []interface{}, conditionAskserie string, askseriePars []interface{}) (total int, list []*MicroRoadShowPageList, err error) {
+	o := orm.NewOrm()
+	var sql string
+
+	//活动音频1
+	sql += `
+			SELECT
+			a.activity_voice_id AS id,
+			a.activity_id AS source_id,
+			a.voice_name AS title,
+			a.voice_url AS resource_url,
+			1 AS type,
+			b.activity_time AS publish_time,
+			b.chart_permission_id,
+			b.chart_permission_name,
+			a.voice_play_seconds AS play_seconds,
+			a.background_img,
+			"" AS industry_name,
+			0 AS  industry_id,
+			a.share_img,
+			a.activity_id 
+		FROM
+			cygx_activity_voice AS a
+			JOIN cygx_activity AS b ON a.activity_id = b.activity_id  WHERE 1= 1  `
+	if audioAct != `` {
+		sql += audioAct
+	}
+
+	//活动视频2
+	sql += `  UNION ALL `
+	sql += `
+		SELECT
+			a.video_id AS id,
+			a.activity_id AS source_id,
+			a.video_name AS title,
+			a.video_url AS resource_url,
+			2 AS type,
+	    	b.activity_time as publish_time,
+			b.chart_permission_id,
+			b.chart_permission_name,
+			"" AS play_seconds,
+			a.background_img,
+			"" AS industry_name,
+			0 AS  industry_id,
+			a.share_img,
+			a.activity_id
+		FROM
+			cygx_activity_video as a
+			INNER JOIN cygx_activity as b on a.activity_id = b.activity_id WHERE 1= 1  `
+	if videoAct != `` {
+		sql += videoAct
+	}
+	sql += `  UNION ALL `
+
+	// 产业视频3
+	sql += `SELECT
+			video_id AS id,
+			video_id AS source_id,
+			video_name AS title,
+			video_url AS resource_url,
+			3 AS type,
+			publish_date AS publish_time,
+			chart_permission_id,
+			chart_permission_name,
+			video_duration AS play_seconds,
+			img_url AS background_img,            
+			industry_name,
+			industry_id,
+			share_img_url AS share_img,
+			"" as  activity_id
+		FROM
+			cygx_micro_roadshow_video  as a
+		WHERE
+			publish_status = 1 `
+	if videoMico != `` {
+		sql += videoMico
+	}
+
+	//系列问答
+	sql += `  UNION ALL `
+	sql += `
+			SELECT
+			a.askserie_video_id AS id,
+			a.askserie_video_id AS source_id,
+			a.video_name AS title,
+			a.video_url AS resource_url,
+			4 AS type,
+			a.publish_date AS publish_time,
+			a.chart_permission_id,
+			a.chart_permission_name,
+			a.video_duration AS play_seconds,
+			a.background_img,
+			"" AS industry_name,
+			0 AS  industry_id,
+			a.share_img,
+			0  as activity_id 
+		FROM
+			cygx_askserie_video AS a WHERE 1= 1 `
+	if conditionAskserie != `` {
+		sql += conditionAskserie
+	}
+
+	sql += ` ORDER BY publish_time DESC`
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql, audioActPars, videoActPars, videoMicoPars, askseriePars).QueryRow(&total)
+	if err != nil {
+		return
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, audioActPars, videoActPars, videoMicoPars, askseriePars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
 // CountMicroRoadShowVideoPageList 获取微路演视频数量
 func CountMicroRoadShowVideoPageList(condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}) (total int, err error) {
 	o := orm.NewOrm()
@@ -310,9 +425,11 @@ func GetMicroRoadShowVideoPageListIkWord(startSize, pageSize int, condition stri
 }
 
 type AddVideoHistoryReq struct {
-	VideoId     int `description:"视频ID"`
+	SourceId int `description:"资源ID"`
+	//VideoId     int `description:"视频ID"`
 	PlaySeconds int `description:"播放时长"`
-	SourceType  int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
+	//SourceType  int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
+	SourceType int `description:"音视频来源: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
 }
 
 func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
@@ -426,13 +543,6 @@ func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count in
 	return
 }
 
-func UpdateLastCygxActivityVideoHistory(playSeconds string, lastId int) (err error) {
-	o := orm.NewOrm()
-	sql := ` UPDATE cygx_micro_roadshow_video_history SET play_seconds =? WHERE id=? `
-	_, err = o.Raw(sql, playSeconds, lastId).Exec()
-	return
-}
-
 // MicroRoadshowVideo 微路演视频
 type MicroRoadshowVideo struct {
 	VideoId             int       `orm:"column(video_id);pk" description:"视频ID"`
@@ -459,10 +569,17 @@ func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error
 	return
 }
 
-func UpdateCygxActivityVideoCounts(activityId int) (err error) {
+func UpdateCygxMicroRoadshowVideo(videoId int) (err error) {
 	sql := `UPDATE cygx_micro_roadshow_video SET video_counts = video_counts+1 WHERE video_id = ?  `
 	o := orm.NewOrm()
-	_, err = o.Raw(sql, activityId).Exec()
+	_, err = o.Raw(sql, videoId).Exec()
+	return
+}
+
+func UpdateLastCygxMicroRoadshowVideoHistory(playSeconds string, lastId int) (err error) {
+	o := orm.NewOrm()
+	sql := ` UPDATE cygx_micro_roadshow_video SET play_seconds = play_seconds +? WHERE id=? `
+	_, err = o.Raw(sql, playSeconds, lastId).Exec()
 	return
 }
 
@@ -481,14 +598,15 @@ func GetMicroRoadshowVideoByIndustryId(industryId int) (item *MicroRoadshowVideo
 }
 
 type AddVideoCommnetReq struct {
-	Id         int    `description:"活动或产业ID"`
+	//Id         int    `description:"活动或产业ID"`
+	SourceId   int    `description:"资源ID"`
 	SourceType int    `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
 	Content    string `description:"内容"`
 	Title      string `description:"标题"`
 }
 
 type MicroRoadshowCollectReq struct {
-	Id         int `description:"音频或视频ID"`
+	SourceId   int `description:"音频或视频ID"`
 	SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
 }
 

+ 15 - 14
models/micro_roadshow_video_history.go

@@ -6,21 +6,22 @@ import (
 )
 
 type CygxMicroRoadshowVideoHistory struct {
-	Id          int       `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
-	VideoId     int       `description:"微路演视频id"`
-	UserId      int       `description:"用户id"`
-	Mobile      string    `description:"手机号"`
-	Email       string    `description:"邮箱"`
-	CompanyId   int       `description:"公司Id"`
-	CompanyName string    `description:"公司名称"`
-	RealName    string    `description:"用户实际名称"`
-	SellerName  string    `description:"所属销售"`
-	PlaySeconds string    `description:"播放时间 单位s"`
-	CreateTime  time.Time `description:"视频创建时间"`
-	ModifyTime  time.Time `description:"视频修改时间"`
+	Id               int       `orm:"column(id);pk"description:"微路演视频浏览记录表id"`
+	VideoId          int       `description:"微路演视频id"`
+	UserId           int       `description:"用户id"`
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司Id"`
+	CompanyName      string    `description:"公司名称"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	PlaySeconds      string    `description:"播放时间 单位s"`
+	CreateTime       time.Time `description:"视频创建时间"`
+	ModifyTime       time.Time `description:"视频修改时间"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 
-//获取列表信息根据手机号分组
+// 获取列表信息根据手机号分组
 func GetMicroRoadshowVideoHistoryByMobileList(condition string) (items []*CygxMicroRoadshowVideoHistory, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM cygx_micro_roadshow_video_history  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
@@ -28,7 +29,7 @@ func GetMicroRoadshowVideoHistoryByMobileList(condition string) (items []*CygxMi
 	return
 }
 
-//修改用户浏览产业视频的相关信息
+// 修改用户浏览产业视频的相关信息
 func UpdateCygxMicroRoadshowVideoHistory(wxUser *WxUserItem) (err error) {
 	o := orm.NewOrm()
 	var sql string

+ 11 - 9
models/resource_data.go

@@ -7,15 +7,16 @@ import (
 )
 
 type CygxResourceData struct {
-	Id          int       `orm:"column(id);pk"`
-	SourceId    int       `description:"资源ID"`
-	Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
-	Title       string    `description:"标题"`
-	Annotation  string    `description:"核心观点"`
-	CreateTime  time.Time `description:"创建时间"`
-	PublishDate string    `description:"发布时间"`
-	Abstract    string    `description:"摘要"`
-	SearchTag   string    `description:"搜索标签"`
+	Id                int       `orm:"column(id);pk"`
+	ChartPermissionId int       `description:"行业ID"`
+	SourceId          int       `description:"资源ID"`
+	Source            string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	Title             string    `description:"标题"`
+	Annotation        string    `description:"核心观点"`
+	CreateTime        time.Time `description:"创建时间"`
+	PublishDate       string    `description:"发布时间"`
+	Abstract          string    `description:"摘要"`
+	SearchTag         string    `description:"搜索标签"`
 }
 
 type CygxResourceDataResp struct {
@@ -39,6 +40,7 @@ type CygxResourceDataResp struct {
 	IndustrialResource *IndustrialManagementHotResp            `description:"产业资源包"`
 	ReportSelection    *CygxReportSelectionRep                 `description:"重点公司(原报告精选)"`
 	YanxuanSpecial     *CygxYanxuanSpecialCenterResp           `description:"研选专栏"`
+	AskserieVideo      *MicroRoadShowPageList                  `description:"活动音频"`
 }
 
 // Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`

+ 31 - 0
models/voice_and_video_history.go

@@ -0,0 +1,31 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxVoiceAndVideoHistory struct {
+	Id               int `orm:"column(id);pk"`
+	SourceId         int `description:"资源ID"`
+	SourceType       int `description:"资源类型 1:活动音频、2 活动视频 、3 产业视频 、 4 问答系列 "`
+	UserId           int
+	CreateTime       time.Time
+	Mobile           string    `description:"手机号"`
+	Email            string    `description:"邮箱"`
+	CompanyId        int       `description:"公司id"`
+	CompanyName      string    `description:"公司名称"`
+	ModifyTime       time.Time `description:"修改时间"`
+	RealName         string    `description:"用户实际名称"`
+	SellerName       string    `description:"所属销售"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	PlaySeconds      string    `description:"播放时间 单位s"`
+}
+
+// 添加历史信息
+func AddCygxVoiceAndVideoHistory(item *CygxVoiceAndVideoHistory) (lastId int64, err error) {
+	o := orm.NewOrm()
+	item.ModifyTime = time.Now()
+	lastId, err = o.Insert(item)
+	return
+}

+ 2 - 2
services/activity_points.go

@@ -190,8 +190,8 @@ func YanXuanActivityPointsBillSignupAddReduce(log models.YanXuanActivityPointsRe
 			go utils.SendAlarmMsg("用户报名活动扣点,处理Redis队列消息失败:"+err.Error()+fmt.Sprint("ActivityId", log.ActivityId, "userId", log.UserId), 2)
 		}
 	}()
-	//加500毫秒的延迟
-	time.Sleep(500 * time.Millisecond)
+	//加2000毫秒的延迟
+	time.Sleep(2 * time.Second)
 	activityId := log.ActivityId
 	userId := log.UserId
 

+ 5 - 4
services/article.go

@@ -709,10 +709,11 @@ func GetArticleListByApi(cont context.Context) (err error) {
 //	//		HandleArticleListByApi(v.ArticleId)
 //	//	}
 //
-//	for i := 8648; i < 9004; i++ {
-//		HandleArticleListByApi(i)
-//	}
-//
+//	//for i := 8648; i < 9004; i++ {
+//	//	HandleArticleListByApi(9552)
+//	//}
+//	HandleArticleListByApi(9551)
+//	//UpdateArticleResourceData(9551)
 //}
 
 // 处理同步过来的文章

+ 149 - 0
services/askserie_video.go

@@ -0,0 +1,149 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"time"
+)
+
+// 记录用户活动音频播放记录
+func AddAskserieVideoHistoryRecord(user *models.WxUserItem, askserieVideoId, playSeconds int) {
+	if playSeconds == 0 {
+		return
+	}
+	key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ASKSERIEVIDEO + strconv.Itoa(askserieVideoId) + "_" + strconv.Itoa(user.UserId)
+
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddAskserieVideoHistoryRecord Err:", err.Error(), "askserieVideoId:", askserieVideoId, "UserId:", user.UserId), 2)
+		}
+	}()
+	item := new(models.CygxAskserieVideoHistoryRecord)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.AskserieVideoId = askserieVideoId
+	item.VideoDuration = playSeconds
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.CreateTime = time.Now().Add(-time.Duration(playSeconds) * time.Second) //减去观看时长当做,阅读时间
+	item.ModifyTime = time.Now()
+	item.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+		return
+	}
+	if sellerItem != nil {
+		item.SellerName = sellerItem.RealName
+	}
+	fmt.Println(utils.Rc.IsExist(key))
+	if !utils.Rc.IsExist(key) {
+		fmt.Println("添加")
+		//添加记录
+		e = models.AddCygxAskserieVideoHistoryRecord(item)
+		if e != nil {
+			err = errors.New("AddCygxAskserieVideoHistoryRecord, Err: " + e.Error())
+			return
+		}
+		//播放记录加1
+		e = models.UpdateAskserieVideoCounts(askserieVideoId)
+		if e != nil {
+			err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
+			return
+		}
+		utils.Rc.Put(key, 1, 10*time.Minute)
+	} else {
+		fmt.Println("更新")
+		//更新停留时长
+		lastItem, e := models.GetLastCygxAskserieVideoHistoryRecord(askserieVideoId, user.UserId)
+		if e != nil {
+			err = errors.New("GetLastCygxActivityVideoHistory, Err: " + e.Error())
+			return
+		}
+		//更新播放时间
+		e = models.UpdateLastCygxAskserieVideoHistoryRecord(strconv.Itoa(playSeconds), lastItem.Id)
+		if e != nil {
+			err = errors.New("UpdateLastCygxAskserieVideoHistoryRecord, Err: " + e.Error())
+			return
+		}
+	}
+
+	//if playSeconds != 0 {
+	//	//lastItem, e := models.GetLastCygxAskserieVideoHistoryRecord(askserieVideoId, user.UserId)
+	//	//if e != nil {
+	//	//	err = errors.New("GetLastCygxActivityVideoHistory, Err: " + e.Error())
+	//	//	return
+	//	//}
+	//	////更新播放时间
+	//	//e = models.UpdateLastCygxAskserieVideoHistoryRecord(strconv.Itoa(playSeconds), lastItem.Id)
+	//	//if e != nil {
+	//	//	err = errors.New("UpdateLastCygxAskserieVideoHistoryRecord, Err: " + e.Error())
+	//	//	return
+	//	//}
+	//
+	//} else {
+	//	//添加记录
+	//	e = models.AddCygxAskserieVideoHistoryRecord(item)
+	//	if e != nil {
+	//		err = errors.New("AddCygxAskserieVideoHistoryRecord, Err: " + e.Error())
+	//		return
+	//	}
+	//	//播放记录加1
+	//	e = models.UpdateAskserieVideoCounts(askserieVideoId)
+	//	if e != nil {
+	//		err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
+	//		return
+	//	}
+	//}
+
+	return
+}
+
+// 系列问答视频留言记录
+func AddCygxAskserieVideoCollection(user *models.WxUserItem, askserieVideoId int, content string) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddAskserieVideoHistoryRecord Err:", err.Error(), "askserieVideoId:", askserieVideoId, "UserId:", user.UserId), 2)
+		}
+	}()
+	item := new(models.CygxAskserieVideoCollection)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.AskserieVideoId = askserieVideoId
+	item.Content = content
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+		return
+	}
+	if sellerItem != nil {
+		item.SellerName = sellerItem.RealName
+	}
+	//添加记录
+	e = models.AddCygxAskserieVideoCollection(item)
+	if e != nil {
+		err = errors.New("AddCygxAskserieVideoCollection, Err: " + e.Error())
+		return
+	}
+	//播放记录加1
+	e = models.UpdateAskserieVideoCommentNum(askserieVideoId)
+	if e != nil {
+		err = errors.New("UpdateAskserieVideoCommentNum, Err: " + e.Error())
+		return
+	}
+	return
+}

+ 244 - 25
services/cygx_activity_video_history.go

@@ -1,45 +1,264 @@
 package services
 
 import (
+	"errors"
+	"fmt"
 	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"strconv"
 	"time"
 )
 
-//添加活动的视频播放记录
-func AddActivityVideoHistory(user *models.WxUserItem, activityId int) (err error) {
-	activityInfo, errInfo := models.GetCygxActivityVideoByActivityId(activityId)
-	if activityInfo == nil {
+// 添加活动的视频播放记录
+//func AddActivityVideoHistory(user *models.WxUserItem, activityId int) (err error) {
+//	activityInfo, errInfo := models.GetCygxActivityVideoByActivityId(activityId)
+//	if activityInfo == nil {
+//		return
+//	}
+//	if errInfo != nil {
+//		return
+//	}
+//	var sellerName string
+//	sellerName, err = models.GetCompanySellerName(user.CompanyId)
+//	if err != nil {
+//		return
+//	}
+//	item := models.CygxActivityVideoHistory{
+//		ActivityId:  activityInfo.ActivityId,
+//		VideoId:     activityInfo.VideoId,
+//		UserId:      user.UserId,
+//		CreateTime:  time.Now(),
+//		Mobile:      user.Mobile,
+//		Email:       user.Email,
+//		CompanyId:   user.CompanyId,
+//		CompanyName: user.CompanyName,
+//		RealName:    user.RealName,
+//		SellerName:  sellerName,
+//		ModifyTime:  time.Now(),
+//	}
+//	err = models.AddCygxActivityVideoHistory(&item)
+//	if err != nil {
+//		return
+//	}
+//	err = models.UpdateActivityVideoCounts(activityInfo.ActivityId)
+//	if err != nil {
+//		return
+//	}
+//	go ActivityVideoUserRmind(user, activityId, 1)
+//	return
+//}
+
+// 添加活动视频的播放记录
+func AddActivityVideoHistory(user *models.WxUserItem, activityId, playSeconds int) {
+	// 十分钟之内的合并
+	key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ACTIVITYVIDEO + strconv.Itoa(activityId) + "_" + strconv.Itoa(user.UserId)
+	if utils.Rc.IsExist(key) {
 		return
 	}
-	if errInfo != nil {
+	utils.Rc.Put(key, 1, 10*time.Minute)
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("添加活动视频的播放记录失败 AddActivityVideoHistory Err:", err.Error(), "活动ID:", activityId, "UserId:", user.UserId), 2)
+		}
+	}()
+	activityVideoInfo, e := models.GetCygxActivityVideoByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
 		return
 	}
-	var sellerName string
-	sellerName, err = models.GetCompanySellerName(user.CompanyId)
-	if err != nil {
+	item := new(models.CygxActivityVideoHistory)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.ActivityId = activityId
+	item.VideoId = activityVideoInfo.VideoId
+	item.PlaySeconds = strconv.Itoa(playSeconds)
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
 		return
 	}
-	item := models.CygxActivityVideoHistory{
-		ActivityId:  activityInfo.ActivityId,
-		VideoId:     activityInfo.VideoId,
-		UserId:      user.UserId,
-		CreateTime:  time.Now(),
-		Mobile:      user.Mobile,
-		Email:       user.Email,
-		CompanyId:   user.CompanyId,
-		CompanyName: user.CompanyName,
-		RealName:    user.RealName,
-		SellerName:  sellerName,
-		ModifyTime:  time.Now(),
-	}
-	err = models.AddCygxActivityVideoHistory(&item)
-	if err != nil {
+	if sellerItem != nil {
+		item.SellerName = sellerItem.RealName
+	}
+	//添加记录
+	e = models.AddCygxActivityVideoHistory(item)
+	if e != nil {
+		err = errors.New("AddCygxActivityVideoHistory, Err: " + e.Error())
 		return
 	}
-	err = models.UpdateActivityVideoCounts(activityInfo.ActivityId)
-	if err != nil {
+	//播放记录加1
+	e = models.UpdateActivityVideoCounts(activityId)
+	if e != nil {
+		err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
 		return
 	}
+	//设置消息提醒
 	go ActivityVideoUserRmind(user, activityId, 1)
+
+	//if !utils.Rc.IsExist(key) {
+	//	//添加记录
+	//	e = models.AddCygxActivityVideoHistory(item)
+	//	if e != nil {
+	//		err = errors.New("AddCygxActivityVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	//播放记录加1
+	//	e = models.UpdateActivityVideoCounts(activityId)
+	//	if e != nil {
+	//		err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
+	//		return
+	//	}
+	//	//设置消息提醒
+	//	go ActivityVideoUserRmind(user, activityId, 1)
+	//
+	//	utils.Rc.Put(key, 1, 10*time.Minute)
+	//} else {
+	//	lastItem, e := models.GetLastCygxActivityVideoHistory(activityId, user.UserId)
+	//	if e != nil {
+	//		err = errors.New("GetLastCygxActivityVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	//更新播放时长
+	//	e = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
+	//	if e != nil {
+	//		err = errors.New("UpdateLastCygxActivityVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//}
+
+	////小程序端的回传两次,第一次没有播放时长,第二次有播放时长
+	//if playSeconds != 0 {
+	//	lastItem, e := models.GetLastCygxActivityVideoHistory(activityId, user.UserId)
+	//	if e != nil {
+	//		err = errors.New("GetLastCygxActivityVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	//更新播放时长
+	//	e = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
+	//	if e != nil {
+	//		err = errors.New("UpdateLastCygxActivityVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//
+	//	utils.Rc.Put(key, 1, 10*time.Minute)
+	//} else {
+	//	//添加记录
+	//	e = models.AddCygxActivityVideoHistory(item)
+	//	if e != nil {
+	//		err = errors.New("AddCygxActivityVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	//播放记录加1
+	//	e = models.UpdateActivityVideoCounts(activityId)
+	//	if e != nil {
+	//		err = errors.New("UpdateActivityVideoCounts, Err: " + e.Error())
+	//		return
+	//	}
+	//	//设置消息提醒
+	//	go ActivityVideoUserRmind(user, activityId, 1)
+	//}
+	return
+}
+
+// 记录用户活动音频播放记录
+func AddActivityVoiceHistory(user *models.WxUserItem, activityId, playSeconds int) {
+	if playSeconds == 0 {
+		return
+	}
+	key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ACTIVITYVOICE + strconv.Itoa(activityId) + "_" + strconv.Itoa(user.UserId)
+
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddActivityVoiceHistory Err:", err.Error(), "活动ID:", activityId, "UserId:", user.UserId), 2)
+		}
+	}()
+	item := new(models.CygxActivityVoiceHistory)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.ActivityId = activityId
+	item.PlaySeconds = strconv.Itoa(playSeconds)
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+		return
+	}
+	if sellerItem != nil {
+		item.SellerName = sellerItem.RealName
+	}
+
+	if !utils.Rc.IsExist(key) {
+		//添加记录
+		e = models.AddCygxActivityVoiceHistory(item)
+		if e != nil {
+			err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
+			return
+		}
+		//播放记录加1
+		e = models.UpdateCygxActivityVoiceCounts(activityId)
+		if e != nil {
+			err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
+			return
+		}
+		utils.Rc.Put(key, 1, 10*time.Minute)
+		//设置消息提醒
+		go ActivityVideoUserRmind(user, activityId, 2)
+	} else {
+		lastItem, e := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
+		if e != nil {
+			err = errors.New("GetLastCygxActivityVoiceHistory, Err: " + e.Error())
+			return
+		}
+		e = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(playSeconds), lastItem.Id)
+		if e != nil {
+			err = errors.New("UpdateLastCygxActivityVoiceHistory, Err: " + e.Error())
+			return
+		}
+	}
+
+	//小程序端的回传两次,第一次没有播放时长,第二次有播放时长
+	//if playSeconds != 0 {
+	//	lastItem, e := models.GetLastCygxActivityVoiceHistory(activityId, user.UserId)
+	//	if e != nil {
+	//		err = errors.New("GetLastCygxActivityVoiceHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	e = models.UpdateLastCygxActivityVoiceHistory(strconv.Itoa(playSeconds), lastItem.Id)
+	//	if e != nil {
+	//		err = errors.New("UpdateLastCygxActivityVoiceHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	utils.Rc.Put(key, 1, 10*time.Second)
+	//} else {
+	//	//添加记录
+	//	e = models.AddCygxActivityVoiceHistory(item)
+	//	if e != nil {
+	//		err = errors.New("AddCygxActivityVoiceHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	//播放记录加1
+	//	e = models.UpdateCygxActivityVoiceCounts(activityId)
+	//	if e != nil {
+	//		err = errors.New("UpdateCygxActivityVoiceCounts, Err: " + e.Error())
+	//		return
+	//	}
+	//	//设置消息提醒
+	//	go ActivityVideoUserRmind(user, activityId, 2)
+	//}
 	return
 }

+ 11 - 38
services/es_comprehensive.go

@@ -998,6 +998,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	var industrialResourceIdsHz []int // 弘则产业资源包
 	var industrialResourceIdsYx []int // 研选产业资源包
 	var yanxuanSpecialIds []int       // 研选专栏
+	var askserieVideoIds []string     //问答系列视频
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -1028,6 +1029,8 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 			industrialResourceIdsYx = append(industrialResourceIdsYx, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
+		} else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
+			askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
 		}
 	}
 	//处理文章
@@ -1339,51 +1342,19 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 		}
 	}
 
-	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds) > 0 {
+	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
 
 		audioIdstr := strings.Join(activityvoiceIds, ",")
-		ideoIdsStr := strings.Join(roadshowIds, ",")
 		activityVideoIdsStr := strings.Join(activityvideoIds, ",")
+		roadshowIdsStr := strings.Join(roadshowIds, ",")
+		askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
 
-		list, _, e := GetMicroRoadShowMycollect(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds), 0, audioIdstr, ideoIdsStr, activityVideoIdsStr)
+		list, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
 		if e != nil {
-			err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
+			err = errors.New("GetMicroRoadShowMycollectV12, Err: " + e.Error())
 			return
 		}
 
-		for _, item := range list {
-			if item.Type == 1 {
-				//音频
-				count, e := models.GetVoiceCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVoiceCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 2 {
-				//活动视频
-				count, e := models.GetActivityVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetActivityVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 3 {
-				//微路演视频
-				count, e := models.GetVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			}
-		}
 		// 用户权限
 		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
 		if e != nil {
@@ -1454,6 +1425,8 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 				mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
 			} else if item.Type == 3 {
 				mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
+			} else if item.Type == 4 {
+				mapItems[fmt.Sprint(utils.CYGX_OBJ_ASKSERIEVIDEO, item.Id)].AskserieVideo = item
 			}
 		}
 	}
@@ -1483,7 +1456,7 @@ func GetResourceDataEsList(list []*SearchComprehensiveItem, user *models.WxUserI
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil {
+			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil {
 				continue
 			}
 			if v.Article != nil && v.SourceId == vList.SourceId {

+ 361 - 0
services/micro_roadshow.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_cygx/utils"
 	"strconv"
 	"strings"
+	"time"
 )
 
 // GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
@@ -291,6 +292,112 @@ func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activi
 	return
 }
 
+// GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
+func GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, tableType int, filter, keywords, searchType, chartPermissionIds string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	//Type                int    `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
+	var e error
+	// 根据每页数据量获取音视频配比
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+
+	var audioAct string // 活动音频 1
+	var audioActPars []interface{}
+
+	var videoAct string // 活动视频 2
+	var videoActPars []interface{}
+
+	//视频的处理
+	var videoMico string //产业视频 3
+	var videoMicoPars []interface{}
+
+	var conditionAskserie string // 系列问答 4
+	var askseriePars []interface{}
+
+	if sourceId > 0 && tableType > 0 {
+		//先给不相干的表查询ID = 0
+		audioAct += ` AND b.chart_permission_id  = 0 `
+		videoAct += ` AND b.chart_permission_id = 0`
+		videoMico += ` AND a.chart_permission_id  = 0 `
+		conditionAskserie += ` AND a.chart_permission_id   = 0 `
+		switch tableType {
+		case 1:
+			audioAct += ` OR  a.activity_id =  ` + strconv.Itoa(sourceId)
+		case 2:
+			videoAct += ` OR  a.activity_id =  ` + strconv.Itoa(sourceId)
+		case 3:
+			videoMico += ` OR  a.video_id =  ` + strconv.Itoa(sourceId)
+		case 4:
+			conditionAskserie += ` OR  a.askserie_video_id =  ` + strconv.Itoa(sourceId)
+		}
+	}
+
+	if filter == "1" {
+		audioAct += ` AND b.chart_permission_id  = 0 `
+	} else if filter == "2" {
+		videoAct += ` AND b.chart_permission_id = 0 `
+		videoMico += ` AND a.chart_permission_id  = 0 `
+		conditionAskserie += ` AND a.chart_permission_id = 0 `
+	}
+
+	if searchType != "" {
+		// @Param   SearchType	string	int		true	"搜索类型: 1-路演回放; 2-问答系列; 3-调研反馈   多个用 , 隔开"
+		videoMico += ` AND a.chart_permission_id  = 0 ` // 产业视频不在搜索范围内
+		if strings.Contains(searchType, "1") && !strings.Contains(searchType, "3") {
+			audioAct += ` AND b.activity_type_id IN (2,7)  AND b.is_yidong_conduct = 1 `
+			videoAct += ` AND b.activity_type_id IN (2,7)  AND b.is_yidong_conduct = 1 `
+		}
+
+		if !strings.Contains(searchType, "1") && strings.Contains(searchType, "3") {
+
+			audioAct += ` AND  (    b.is_yidong_conduct = 0   OR 	b.activity_type_id   NOT  IN (2,7) )  `
+			videoAct += ` AND  (     b.is_yidong_conduct = 0  OR 	b.activity_type_id   NOT  IN (2,7) )  `
+		}
+
+		if !strings.Contains(searchType, "2") {
+			conditionAskserie += ` AND a.chart_permission_id   = 0 `
+		}
+
+		if !strings.Contains(searchType, "3") && !strings.Contains(searchType, "1") {
+			audioAct += ` AND b.chart_permission_id  = 0  `
+			videoAct += ` AND b.chart_permission_id  = 0 `
+		}
+	}
+
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+
+		audioAct += ` AND  a.voice_name LIKE ? `
+		videoAct += ` AND  a.video_name LIKE ? `
+		videoMico += ` AND  a.video_name LIKE ? `
+		conditionAskserie += ` AND  a.video_name LIKE ? `
+
+		audioActPars = append(audioActPars, keywords)
+		videoActPars = append(videoActPars, keywords)
+		videoMicoPars = append(videoMicoPars, keywords)
+		askseriePars = append(askseriePars, keywords)
+	}
+	//行业筛选
+	if chartPermissionIds != "" {
+		audioAct += ` AND  b.chart_permission_id IN (` + chartPermissionIds + `)`
+		videoAct += ` AND b.chart_permission_id IN (` + chartPermissionIds + `)`
+		videoMico += ` AND a.chart_permission_id IN (` + chartPermissionIds + `)`
+		conditionAskserie += ` AND a.chart_permission_id IN (` + chartPermissionIds + `)`
+	}
+	//发布状态
+	audioAct += ` AND  b.publish_status = 1 `
+	videoAct += ` AND  b.publish_status = 1 `
+	videoMico += ` AND  a.publish_status = 1 `
+	conditionAskserie += ` AND  a.publish_status = 1 `
+
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV12(startSize, pageSize, audioAct, audioActPars, videoAct, videoActPars, videoMico, videoMicoPars, conditionAskserie, askseriePars)
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+	respList = videoList
+	return
+}
+
 // GetMicroRoadShowPageListIkWord  添加IK分词联想词 获取微路演列表添加活动视频 更新与8.1版本
 func CountMicroRoadShowPageListIkWord(audioId, videoId, activityVideoId int, keywordArr []string, filter, audioIds, videoIds, activityVideoIds string) (total int, err error) {
 	var e error
@@ -593,6 +700,126 @@ func GetMicroRoadShowMycollect(pageSize, currentIndex int, audioIds, videoIds, a
 	return
 }
 
+// 我的收藏
+func GetMicroRoadShowMycollectV12(pageSize, currentIndex int, audioIds, activityVideoIds, roadshowIdsStr, askserieVideoIds string, user *models.WxUserItem) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	//Type                int    `description:"类型: 1-活动音频; 2-活动视频; 3-产业视频; 4-系列问答"`
+	var e error
+	// 根据每页数据量获取音视频配比
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+
+	var audioAct string // 活动音频 1
+	var audioActPars []interface{}
+
+	var videoAct string // 活动视频 2
+	var videoActPars []interface{}
+
+	//视频的处理
+	var videoMico string //产业视频 3
+	var videoMicoPars []interface{}
+
+	var conditionAskserie string // 系列问答 4
+	var askseriePars []interface{}
+
+	if audioIds != "" {
+		sliceId := strings.Split(audioIds, ",")
+		audioAct += ` AND a.activity_voice_id IN (` + strings.Join(sliceId, ",") + `)`
+	} else {
+		audioAct += ` AND a.activity_voice_id = 0 `
+	}
+
+	if activityVideoIds != "" {
+		sliceId := strings.Split(activityVideoIds, ",")
+		videoAct += ` AND a.video_id IN (` + strings.Join(sliceId, ",") + `)`
+	} else {
+		videoAct += ` AND a.video_id = 0 `
+	}
+
+	if roadshowIdsStr != "" {
+		sliceId := strings.Split(roadshowIdsStr, ",")
+		videoMico += ` AND a.video_id IN (` + strings.Join(sliceId, ",") + `)`
+	} else {
+		videoMico += ` AND a.video_id = 0 `
+	}
+
+	if askserieVideoIds != "" {
+		sliceId := strings.Split(askserieVideoIds, ",")
+		conditionAskserie += ` AND a.askserie_video_id IN (` + strings.Join(sliceId, ",") + `)`
+	} else {
+		conditionAskserie += ` AND a.askserie_video_id = 0 `
+	}
+
+	//发布状态
+	audioAct += ` AND  b.publish_status = 1 `
+	videoAct += ` AND  b.publish_status = 1 `
+	videoMico += ` AND  a.publish_status = 1 `
+	conditionAskserie += ` AND  a.publish_status = 1 `
+
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV12(startSize, pageSize, audioAct, audioActPars, videoAct, videoActPars, videoMico, videoMicoPars, conditionAskserie, askseriePars)
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+	userId := user.UserId
+	listMycollect, e := models.GetUserMicroRoadshowCollectList(userId)
+	if e != nil {
+		err = errors.New("GetUserMicroRoadshowCollectList, Err: " + e.Error())
+		return
+	}
+	mapaudioIds := make(map[int]int)         //活动音频
+	mapvideoIds := make(map[int]int)         // 微路演视频
+	mapactivityVideoIds := make(map[int]int) // 活动视频
+	mapAskserieVideoIds := make(map[int]int) // 活动视频
+	for _, item := range listMycollect {
+		if item.ActivityVoiceId > 0 {
+			mapaudioIds[item.ActivityVoiceId] = item.ActivityVoiceId
+		} else if item.VideoId > 0 {
+			mapvideoIds[item.VideoId] = item.VideoId
+		} else if item.ActivityVideoId > 0 {
+			mapactivityVideoIds[item.ActivityVideoId] = item.ActivityVideoId
+		}
+	}
+
+	listAskserieVideoCollect, e := models.GetUserCygxAskserieVideoCollectList(userId)
+	if e != nil {
+		err = errors.New("GetUserCygxAskserieVideoCollectList, Err: " + e.Error())
+		return
+	}
+
+	for _, v := range listAskserieVideoCollect {
+		if v.AskserieVideoId > 0 {
+			mapAskserieVideoIds[v.AskserieVideoId] = v.AskserieVideoId
+		}
+	}
+
+	for _, item := range videoList {
+		if item.Type == 1 {
+			//音频
+			if mapaudioIds[item.Id] > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 2 {
+			//活动视频
+			if mapactivityVideoIds[item.Id] > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 3 {
+			//微路演视频
+			if mapvideoIds[item.Id] > 0 {
+				item.IsCollect = true
+			}
+		} else if item.Type == 4 {
+			//系列问答视频
+			if mapAskserieVideoIds[item.SourceId] > 0 {
+				item.IsCollect = true
+			}
+		}
+	}
+
+	respList = videoList
+	return
+}
+
 // GetMicroRoadshowVideoMap 获取已经发布的微路演的产业ID
 func GetMicroRoadshowVideoMap() (items map[int]int, err error) {
 	list, e := models.GetMicroRoadshowVideoList()
@@ -740,3 +967,137 @@ func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err erro
 	}
 	return
 }
+
+// 记录产业视频播放记录
+func AddMicroRoadshowVideoRecord(user *models.WxUserItem, videoId, playSeconds int) {
+	//if playSeconds == 0 {
+	//	return
+	//}
+	key := utils.CYGX_VIDEO_HISTORY_KEY + utils.CYGX_OBJ_ROADSHOW + strconv.Itoa(videoId) + "_" + strconv.Itoa(user.UserId)
+	if utils.Rc.IsExist(key) {
+		return
+	}
+	utils.Rc.Put(key, 1, 10*time.Minute)
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录用户活动音频播放记录失败 AddMicroRoadshowVideoRecord Err:", err.Error(), "videoId:", videoId, "UserId:", user.UserId), 2)
+		}
+	}()
+	item := new(models.CygxMicroRoadshowVideoHistory)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.VideoId = videoId
+	item.PlaySeconds = strconv.Itoa(playSeconds)
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+		return
+	}
+	if sellerItem != nil {
+		item.SellerName = sellerItem.RealName
+	}
+
+	//if !utils.Rc.IsExist(key) {
+	//添加记录
+	e = models.AddCygxMicroRoadshowVideoHistory(item)
+	if e != nil {
+		err = errors.New("AddCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+		return
+	}
+	//播放记录加1
+	e = models.UpdateCygxMicroRoadshowVideo(videoId)
+	if e != nil {
+		err = errors.New("UpdateCygxActivityVideoCounts, Err: " + e.Error())
+		return
+	}
+	go MicroRoadshowVideoUserRmind(user, videoId)
+
+	//utils.Rc.Put(key, 1, 10*time.Minute)
+	//} else {
+	//	//更新停留时长
+	//	lastItem, e := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
+	//	if e != nil {
+	//		err = errors.New("GetLastCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	//更新播放时间
+	//	e = models.UpdateLastCygxMicroRoadshowVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
+	//	if e != nil {
+	//		err = errors.New("UpdateLastCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//}
+
+	//if playSeconds != 0 {
+	//	lastItem, e := models.GetLastCygxMicroRoadshowVideoHistory(videoId, user.UserId)
+	//	if e != nil {
+	//		err = errors.New("GetLastCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	e = models.UpdateLastCygxActivityVideoHistory(strconv.Itoa(playSeconds), lastItem.Id)
+	//	if e != nil {
+	//		err = errors.New("UpdateLastCygxActivityVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	utils.Rc.Put(key, 1, 10*time.Second)
+	//} else {
+	//	e = models.AddCygxMicroRoadshowVideoHistory(item)
+	//	if e != nil {
+	//		err = errors.New("AddCygxMicroRoadshowVideoHistory, Err: " + e.Error())
+	//		return
+	//	}
+	//	e = models.UpdateCygxMicroRoadshowVideo(videoId)
+	//	if e != nil {
+	//		err = errors.New("UpdateCygxActivityVideoCounts, Err: " + e.Error())
+	//		return
+	//	}
+	//	go MicroRoadshowVideoUserRmind(user, videoId)
+	//}
+
+	return
+}
+
+// 记录所有微路演音视频播放记录
+func AddAllCygxVoiceAndVideoHistory(user *models.WxUserItem, sourceId, sourceType, playSeconds int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg(fmt.Sprint("记录所有微路演音视频播放记录失败 AddAllCygxVoiceAndVideoHistory Err:", err.Error(), "sourceId:", sourceId, "UserId:", user.UserId), 2)
+		}
+	}()
+	item := new(models.CygxVoiceAndVideoHistory)
+	item.UserId = user.UserId
+	item.RealName = user.RealName
+	item.SourceId = sourceId
+	item.SourceType = sourceType
+	item.PlaySeconds = strconv.Itoa(playSeconds)
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.CreateTime = time.Now()
+	item.ModifyTime = time.Now()
+	item.RegisterPlatform = utils.REGISTER_PLATFORM
+	sellerItem, e := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetSellerByCompanyIdCheckFicc, Err: " + e.Error())
+		return
+	}
+	if sellerItem != nil {
+		item.SellerName = sellerItem.RealName
+	}
+	_, e = models.AddCygxVoiceAndVideoHistory(item)
+	if e != nil {
+		err = errors.New("AddCygxVoiceAndVideoHistory, Err: " + e.Error())
+		return
+	}
+	return
+}

+ 18 - 39
services/resource_data.go

@@ -40,8 +40,9 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 	var minutessummaryIds []int
 	var meetingreviewchaptIds []int
 	var productinteriorIds []int
-	var reportselectionIds []int // 报告精选
-	var yanxuanSpecialIds []int  // 研选专栏
+	var reportselectionIds []int  // 报告精选
+	var yanxuanSpecialIds []int   // 研选专栏
+	var askserieVideoIds []string //问答系列视频
 	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial 、 本周研究汇总: researchsummary 、 上周纪要汇总 :minutessummary 、晨会精华 :meetingreviewchapt "`
 	for _, v := range list {
 		if v.Source == "article" {
@@ -70,7 +71,10 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			reportselectionIds = append(reportselectionIds, v.SourceId)
 		} else if v.Source == utils.CYGX_OBJ_YANXUANSPECIAL {
 			yanxuanSpecialIds = append(yanxuanSpecialIds, v.SourceId)
+		} else if v.Source == utils.CYGX_OBJ_ASKSERIEVIDEO {
+			askserieVideoIds = append(askserieVideoIds, strconv.Itoa(v.SourceId))
 		}
+
 	}
 	//处理文章
 	if len(articleIds) > 0 {
@@ -310,51 +314,19 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 		}
 	}
 
-	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds) > 0 {
+	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds) > 0 {
 
 		audioIdstr := strings.Join(activityvoiceIds, ",")
-		ideoIdsStr := strings.Join(roadshowIds, ",")
 		activityVideoIdsStr := strings.Join(activityvideoIds, ",")
+		roadshowIdsStr := strings.Join(roadshowIds, ",")
+		askserieVideoIdsStr := strings.Join(askserieVideoIds, ",")
 
-		list, _, e := GetMicroRoadShowMycollect(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds), 0, audioIdstr, ideoIdsStr, activityVideoIdsStr)
+		list, _, e := GetMicroRoadShowMycollectV12(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds)+len(askserieVideoIds), 0, audioIdstr, activityVideoIdsStr, roadshowIdsStr, askserieVideoIdsStr, user)
 		if e != nil {
 			err = errors.New("GetMicroRoadShowMycollect, Err: " + e.Error())
 			return
 		}
 
-		for _, item := range list {
-			if item.Type == 1 {
-				//音频
-				count, e := models.GetVoiceCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVoiceCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 2 {
-				//活动视频
-				count, e := models.GetActivityVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetActivityVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			} else if item.Type == 3 {
-				//微路演视频
-				count, e := models.GetVideoCollectCount(user.UserId, item.Id)
-				if e != nil {
-					err = errors.New("GetVideoCollectCount, Err: " + e.Error())
-					return
-				}
-				if count > 0 {
-					item.IsCollect = true
-				}
-			}
-		}
 		// 用户权限
 		authInfo, permissionArr, e := GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
 		if e != nil {
@@ -425,6 +397,8 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 				mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
 			} else if item.Type == 3 {
 				mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
+			} else if item.Type == 4 {
+				mapItems[fmt.Sprint(utils.CYGX_OBJ_ASKSERIEVIDEO, item.Id)].AskserieVideo = item
 			}
 		}
 	}
@@ -475,7 +449,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 	for _, vList := range list {
 		for _, v := range mapItems {
 			//如果这些类型都为空,那么就不合并
-			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil && v.YanxuanSpecial == nil {
+			if v.Article == nil && v.Newchart == nil && v.Roadshow == nil && v.Activity == nil && v.Activityvideo == nil && v.Activityvoice == nil && v.Activityspecial == nil && v.Researchsummary == nil && v.Minutessummary == nil && v.Meetingreviewchapt == nil && v.ProductInterior == nil && v.IndustrialResource == nil && v.ReportSelection == nil && v.YanxuanSpecial == nil && v.AskserieVideo == nil {
 				continue
 			}
 			if v.SourceId == vList.SourceId {
@@ -583,6 +557,11 @@ func UpdateArticleResourceData(sourceId int) {
 			item.SearchTag = detail.ArticleTypeName // 研选类型名称
 		} else {
 			item.SearchTag = detail.MatchTypeName
+			//获取文章分类详情
+			detailCategory, _ := models.GetCygxReportMappingCelueMaxDetailByCategoryId(detail.CategoryId)
+			if detailCategory != nil {
+				item.ChartPermissionId = detailCategory.ChartPermissionId
+			}
 		}
 		item.SourceId = sourceId
 		item.Source = source

+ 3 - 3
services/wx_template_msg.go

@@ -735,11 +735,11 @@ func SendWxMsgWithMicroRoadshowAsk(req models.AddVideoCommnetReq, user *models.W
 	defer func() {
 		if err != nil || msg != "" {
 			go utils.SendEmail("发送模版消息失败"+"【"+utils.APPNAME+"】"+time.Now().Format("2006-01-02 15:04:05"), msg+";Err:"+err.Error(), utils.EmailSendToUsers)
-			go utils.SendAlarmMsg(fmt.Sprint("发送微路演新增留言提问消息提醒失败,用户名", req.Title, "ID:", req.Id), 2)
+			go utils.SendAlarmMsg(fmt.Sprint("发送微路演新增留言提问消息提醒失败,用户名", req.Title, "ID:", req.SourceId), 2)
 			utils.FileLog.Info("发送模版消息失败,Err:%s", err.Error())
 		}
 	}()
-
+	sourceId := req.SourceId
 	companyItem, e := models.GetSellerDetailAllByCompanyId(user.CompanyId)
 	if e != nil {
 		return
@@ -808,7 +808,7 @@ func SendWxMsgWithMicroRoadshowAsk(req models.AddVideoCommnetReq, user *models.W
 	sendInfo.TemplateId = utils.WxMsgTemplateIdApplyXzs
 	sendInfo.RedirectUrl = redirectUrl
 	sendInfo.RedirectTarget = 3
-	sendInfo.Resource = strconv.Itoa(req.Id)
+	sendInfo.Resource = strconv.Itoa(sourceId)
 	sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_COMMENT
 	sendInfo.OpenIdArr = openIdArr
 	err = PublicSendTemplateMsg(sendInfo)

+ 4 - 2
utils/constants.go

@@ -242,11 +242,13 @@ const (
 	CYGX_OBJ_RESEARCHSUMMARY    string = "researchsummary"    // 对象类型:本周研究汇总
 	CYGX_OBJ_MINUTESSUMMARY     string = "minutessummary"     // 对象类型:上周纪要汇总
 	CYGX_OBJ_YANXUANSPECIAL     string = "yanxuanspecial"     // 对象类型:研选专栏
+	CYGX_OBJ_ASKSERIEVIDEO      string = "askserievideo"      // 对象类型:问答系列视频
 )
 
 const (
-	CYGX_YANXUAN_SPECIAL = "研选专栏" //用户阅读数据
-	CYGX_YANXUAN_ARTICLE = "买方研选" //用户阅读数据
+	CYGX_YANXUAN_SPECIAL   = "研选专栏"                   //用户阅读数据
+	CYGX_YANXUAN_ARTICLE   = "买方研选"                   //用户阅读数据
+	CYGX_VIDEO_HISTORY_KEY = "CYGX_VIDEO_HISTORY_XCX" //路演播放Key 小程序、web端
 )
 
 const (