Browse Source

no message

xingzai 2 years ago
parent
commit
d2281b22c4

+ 125 - 30
controllers/report.go

@@ -136,6 +136,7 @@ func (this *MobileReportController) TradeList() {
 // @Param   RecommendFocus   query   int  false       "是否选择推荐关注,1是,0否 不填默认为0"
 // @Param   PageSize   query   int  true       "每页数据条数"
 // @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Param   IsBillboard   query   bool  false       "是否属于榜单 是true 否 false"
 // @Success 200 {object} models.IndustrialManagementList
 // @router /industryList [get]
 func (this *MobileReportController) IndustryList() {
@@ -154,10 +155,13 @@ func (this *MobileReportController) IndustryList() {
 	ChartPermissionId, _ := this.GetInt("ChartPermissionId")
 	orderColumn := this.GetString("OrderColumn")
 	orderColumnNew := this.GetString("OrderColumn")
+	isNewLabel := this.GetString("IsNewLabel")
+	isDeepLabel := this.GetString("IsDeepLabel")
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	deepCover, _ := this.GetInt("DeepCover")
 	recommendFocus, _ := this.GetInt("RecommendFocus")
+	isBillboard, _ := this.GetBool("IsBillboard", false)
 	var orderSrt string
 	var condition string
 	var startSize int
@@ -169,6 +173,11 @@ func (this *MobileReportController) IndustryList() {
 		currentIndex = 1
 	}
 
+	if isBillboard {
+		pageSize = utils.PageSize15
+		currentIndex = 1
+	}
+
 	startSize = paging.StartIndex(currentIndex, pageSize)
 	if ChartPermissionId > 0 {
 		condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
@@ -220,7 +229,7 @@ func (this *MobileReportController) IndustryList() {
 	}
 	// 推荐关注
 	if recommendFocus == 1 {
-		condition += ` AND man.recommended_index >= 50`
+		condition += ` AND man.recommended_index >= 80`
 	}
 
 	var list []*models.IndustrialManagement
@@ -230,7 +239,7 @@ func (this *MobileReportController) IndustryList() {
 		br.ErrMsg = "获取数量失败,Err:" + err.Error()
 		return
 	}
-	page := paging.GetPaging(currentIndex, pageSize, total)
+
 	if orderColumn == "" {
 		orderColumn = "NewTime"
 	}
@@ -242,15 +251,8 @@ func (this *MobileReportController) IndustryList() {
 	if ChartPermissionId == 0 {
 		ChartPermissionId = 20
 	}
-	//获取产业下阅读数量第三的产业详情
-	//detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
-	//if err != nil && err.Error() != utils.ErrNoRow() {
-	//	br.Msg = "获取信息失败"
-	//	br.ErrMsg = "获取信息失败,Err:" + err.Error()
-	//	return
-	//}
 
-	list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
+	list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize, isBillboard)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
@@ -260,9 +262,6 @@ func (this *MobileReportController) IndustryList() {
 	industrialIdArr := make([]int, 0)
 	for k, v := range list {
 		industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
-		//if v.ArticleReadNum >= detailHot3.ArticleReadNum {
-		//	list[k].IsHot = true
-		//}
 		if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
 			list[k].IsHot = true
 		}
@@ -277,7 +276,6 @@ func (this *MobileReportController) IndustryList() {
 		br.ErrMsg = "获取信息失败 GetNewArticleDetailByIndustrialIds ,Err:" + err.Error()
 		return
 	}
-	fmt.Println(listUpdateTime)
 	for _, v := range listUpdateTime {
 		mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
 		articleIdArr = append(articleIdArr, v.ArticleId)
@@ -329,27 +327,124 @@ func (this *MobileReportController) IndustryList() {
 		}
 		list[k].IndustrialSubjectList = industrialSubjectList
 	}
-	//记录用户搜索的筛选条件
+
+	//查询产业视频
+	industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
+	var industrialManagementIds []int
+	for _, v := range list {
+		if v.IndustrialManagementId > 0 {
+			industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+		}
+	}
+
+	// 用户权限
+	authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
+		return
+	}
+
+	if len(industrialManagementIds) > 0 {
+		// 获取默认图配置
+		_, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			br.Msg = "获取视频默认配置图失败"
+			br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
+			return
+		}
+		videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialManagementIds)
+		if err != nil {
+			br.Msg = "产业视频列表失败"
+			br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
+			return
+		}
+		for _, v := range videoList {
+			tmp := &models.MicroVideoSimpleInfo{
+				Id:                  v.VideoId,
+				Title:               "5min逻辑【" + v.IndustryName + "】解析",
+				ResourceUrl:         v.VideoUrl,
+				BackgroundImg:       v.ImgUrl,
+				PlaySeconds:         v.VideoDuration,
+				DetailImgUrl:        v.DetailImgUrl,
+				ChartPermissionId:   v.ChartPermissionId,
+				ChartPermissionName: v.ChartPermissionName,
+			}
+			if tmp.BackgroundImg == "" {
+				tmp.BackgroundImg = videoMap[v.ChartPermissionId]
+			}
+			industrialVideoMap[v.IndustryId] = tmp
+		}
+	}
+
+	//nowTime := time.Now().Local()
+	//threeMonBefore := nowTime.AddDate(0, -3, 0)
+	for k, v := range list {
+		list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
+		// 关联报告发布时间均在3个月内则标记New
+		if v.MinReportTime != "" {
+			t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "报告最早发布时间有误, Err: " + e.Error()
+				return
+			}
+			if t.After(threeMonBefore) {
+				list[k].IsNew = true
+			}
+		}
+		//展示产业视频
+		if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
+			//控制用户权限
+			// 权限
+			au := new(models.UserPermissionAuthInfo)
+			au.SellerName = authInfo.SellerName
+			au.SellerMobile = authInfo.SellerMobile
+			au.HasPermission = authInfo.HasPermission
+			au.OperationMode = authInfo.OperationMode
+			if au.HasPermission == 1 {
+				// 非宏观权限进一步判断是否有权限
+				if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == services.UserPermissionOperationModeCall {
+					au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
+				} else {
+					au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
+				}
+				video.ResourceUrl = ""
+			}
+			list[k].AuthInfo = au
+			list[k].IndustryVideo = video
+		}
+	}
 	if orderColumnNew != "" {
-		//item := new(models.CygxReportIndustrialSeaarchHistory)
-		//item.UserId = user.UserId
-		//item.Mobile = user.Mobile
-		//item.CompanyId = user.CompanyId
-		//item.CompanyName = user.CompanyName
-		//item.CreateTime = time.Now()
-		//item.IsDeepLabel = isDeepLabel
-		//item.IsNewLabel = isNewLabel
-		//item.ChartPermissionId = ChartPermissionId
-		//if orderColumnNew == "NewTime" {
-		//	item.OrderColumn = "0"
-		//} else {
-		//	item.OrderColumn = "1"
-		//}
-		//go models.AddCygxReportIndustrialSeaarchHistory(item)
+		item := new(models.CygxReportIndustrialSeaarchHistory)
+		item.UserId = user.UserId
+		item.Mobile = user.Mobile
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.CreateTime = time.Now()
+		item.IsDeepLabel = isDeepLabel
+		item.IsNewLabel = isNewLabel
+		item.ChartPermissionId = ChartPermissionId
+		if orderColumnNew == "NewTime" {
+			item.OrderColumn = "0"
+		} else {
+			item.OrderColumn = "1"
+		}
+		go models.AddCygxReportIndustrialSeaarchHistory(item)
 	}
 	if len(list) == 0 {
 		list = make([]*models.IndustrialManagement, 0)
 	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	if isBillboard {
+		total = len(list)
+	}
 	resp.List = list
 	resp.Paging = page
 	br.Ret = 200

+ 137 - 0
controllers/report_billboard.go

@@ -0,0 +1,137 @@
+package controllers
+
+import (
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+//报告
+type ReportBillboardController struct {
+	BaseAuthController
+}
+
+type ReportBillboardCommonController struct {
+	BaseCommonController
+}
+
+type MobileReportBillboardController struct {
+	BaseAuthMobileController
+}
+
+// @Title 阅读飙升榜/报告收藏榜
+// @Description 获取阅读飙升榜/报告收藏榜接口
+// @Param   ChartPermissionId   query   int  false       "分类ID"
+// @Param   Source   query   int  true       "来源 1:阅读飙升 ,2:报告收藏"
+// @Success 200 {object} models.ArticleReportBillboardLIstResp
+// @router /list [get]
+func (this *MobileReportBillboardController) ReadList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请重新登录"
+		br.Ret = 408
+		return
+	}
+	chartPermissionId, _ := this.GetInt("ChartPermissionId")
+	source, _ := this.GetInt("Source")
+	sourceArr := []int{1, 2}
+	if !utils.InArrayByInt(sourceArr, source) {
+		br.Msg = "来源有误"
+		return
+	}
+
+	topNum := utils.PageSize15
+	list := make([]*models.HomeArticle, 0)
+
+	// 阅读飙升榜
+	if source == 1 {
+		var topCond string
+		var topPars []interface{}
+		if chartPermissionId > 0 {
+			topCond += ` AND chart_permission_id = ?`
+			topPars = append(topPars, chartPermissionId)
+		}
+		topList, e := models.GetTopReadRecordArticleListByCondition(topNum, topCond, topPars)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取报告阅读增量排行榜失败, Err:" + e.Error()
+			return
+		}
+		for i := range topList {
+			list = append(list, &models.HomeArticle{
+				ArticleId:   topList[i].ArticleId,
+				Title:       topList[i].Title,
+				PublishDate: topList[i].PublishDate,
+			})
+		}
+	}
+
+	// 报告收藏榜
+	if source == 2 {
+		var collectCond string
+		var collectPars []interface{}
+		if chartPermissionId > 0 {
+			collectCond += ` AND m.chart_permission_id = ?`
+			collectPars = append(collectPars, chartPermissionId)
+		}
+		// 根据关注时间一个月前至昨日的增量数据排序
+		nowTime := time.Now().Local()
+		startTime := nowTime.AddDate(0, -1, 0)
+		endTime := nowTime.AddDate(0, 0, -1)
+		collectCond += ` AND ac.create_time BETWEEN ? AND ?`
+		collectPars = append(collectPars, startTime, endTime)
+		collectList, e := models.GetReportCollectionBillboardList(topNum, collectPars, collectCond)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取报告收藏排行榜失败, Err:" + e.Error()
+			return
+		}
+		list = collectList
+	}
+	articleIds := make([]int, 0)
+	for i := range list {
+		articleIds = append(articleIds, list[i].ArticleId)
+	}
+
+	// 报告关联产业信息
+	industryMap := make(map[int][]*models.IndustrialManagementIdInt, 0)
+	if len(articleIds) > 0 {
+		var industryCond string
+		var industryPars []interface{}
+		industryCond += ` AND mg.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+		industryPars = append(industryPars, articleIds)
+		industryList, e := models.GetIndustrialListByarticleId(industryPars, industryCond)
+		if e != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取报告关联的产业信息失败, Err: " + e.Error()
+			return
+		}
+		for i := range industryList {
+			v := industryList[i]
+			industryMap[v.ArticleId] = append(industryMap[v.ArticleId], &models.IndustrialManagementIdInt{
+				ArticleId:              v.ArticleId,
+				IndustrialManagementId: v.IndustrialManagementId,
+				IndustryName:           v.IndustryName,
+				ChartPermissionId:      v.ChartPermissionId,
+			})
+		}
+	}
+	for k, v := range list {
+		if len(industryMap[v.ArticleId]) > 0 {
+			list[k].List = industryMap[v.ArticleId]
+		} else {
+			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
+		}
+	}
+	resp := new(models.HomeArtAndChartListResp)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 24 - 0
models/article_history_record.go

@@ -3,6 +3,7 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_clpt/utils"
+	"time"
 )
 
 type CygxArticleHistoryResp struct {
@@ -11,6 +12,18 @@ type CygxArticleHistoryResp struct {
 	Num       int `description:"数量"`
 }
 
+// ArticleTopHistoryRecord 报告阅读飙升榜
+type ArticleTopHistoryRecord struct {
+	Id                int       `orm:"column(id);pk"`
+	ArticleId         int       `description:"文章ID"`
+	Title             string    `description:"文章标题"`
+	PublishDate       string    `description:"发布日期"`
+	ChartPermissionId int       `description:"行业ID"`
+	PermissionName    string    `description:"行业名称"`
+	Pv                int       `description:"PV"`
+	CreateTime        time.Time `description:"创建时间"`
+}
+
 //获取用户阅读记录
 func GetUserToArticleCount(uid, articleId int) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_article_history_record WHERE user_id=? AND article_id=? `
@@ -39,3 +52,14 @@ func GetUserToArticleHistory(uid int, articleIdArr []int) (items []*CygxArticleH
 	_, err = o.Raw(sql, uid, articleIdArr).QueryRows(&items)
 	return
 }
+
+// GetTopReadRecordArticleListByCondition 获取阅读量排行榜
+func GetTopReadRecordArticleListByCondition(limit int, condition string, pars []interface{}) (list []*ArticleTopHistoryRecord, err error) {
+	sql := `SELECT * FROM cygx_article_top_history_record WHERE 1 = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` ORDER BY pv DESC, publish_date DESC LIMIT ?`
+	_, err = orm.NewOrm().Raw(sql, pars, limit).QueryRows(&list)
+	return
+}

+ 21 - 0
models/config.go

@@ -5,6 +5,13 @@ import (
 	"time"
 )
 
+var (
+	HomeHeaderTabConfigKey              = "home_header_tab"
+	MicroRoadShowListDataRatioConfigKey = "micro_roadshow_list_data_ratio"
+	HomeNewListAudioNumKey              = "home_new_list_audio_num"
+	MicroRoadshowDefaultImgKey          = "micro_roadshow_default_img"
+)
+
 type CygxConfig struct {
 	ConfigId    int    `json:"-" orm:"column(config_id);pk"`
 	ConfigCode  string `json:"-"`
@@ -63,3 +70,17 @@ func GetHotSearch() (permission string, err error) {
 	err = o.Raw(sql).QueryRow(&permission)
 	return
 }
+
+// MicroRoadShowDefaultImgList 微路演行业默认背景图列表
+type MicroRoadShowDefaultImgList struct {
+	Audio []*MicroRoadShowDefaultImg `description:"音频"`
+	Video []*MicroRoadShowDefaultImg `description:"视频"`
+}
+
+// MicroRoadShowDefaultImg 微路演行业默认背景图
+type MicroRoadShowDefaultImg struct {
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	ImgUrl              string `description:"背景图"`
+	ShareImg            string `description:"分享图"`
+}

+ 1 - 0
models/db.go

@@ -40,6 +40,7 @@ func init() {
 		new(CygxSearchKeyWordLog),
 		new(Resource),
 		new(CygxXzsChooseCategory),
+		new(CygxReportIndustrialSeaarchHistory),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 23 - 20
models/home.go

@@ -12,26 +12,29 @@ type HomeArtAndChartListResp struct {
 }
 
 type HomeArticle struct {
-	ArticleId        int    `description:"文章id"`
-	Title            string `description:"标题"`
-	TitleEn          string `description:"英文标题 "`
-	UpdateFrequency  string `description:"更新周期"`
-	CreateDate       string `description:"创建时间"`
-	PublishDate      string `description:"发布时间"`
-	Body             string `description:"内容"`
-	BodyHtml         string `description:"内容带有HTML标签"`
-	Abstract         string `description:"摘要"`
-	CategoryName     string `description:"一级分类"`
-	SubCategoryName  string `description:"二级分类"`
-	ExpertBackground string `description:"专家背景"`
-	IsResearch       bool   `description:"是否属于研选"`
-	Pv               int    `description:"PV"`
-	ImgUrlPc         string `description:"图片链接"`
-	CategoryId       string `description:"文章分类"`
-	HttpUrl          string `description:"文章链接跳转地址"`
-	IsNeedJump       bool   `description:"是否需要跳转链接地址"`
-	Source           int    `description:"来源  1:文章, 2:图表"`
-	Annotation       string `description:"核心观点"`
+	ArticleId        int                  `description:"文章id"`
+	Title            string               `description:"标题"`
+	TitleEn          string               `description:"英文标题 "`
+	UpdateFrequency  string               `description:"更新周期"`
+	CreateDate       string               `description:"创建时间"`
+	PublishDate      string               `description:"发布时间"`
+	Body             string               `description:"内容"`
+	BodyHtml         string               `description:"内容带有HTML标签"`
+	Abstract         string               `description:"摘要"`
+	CategoryName     string               `description:"一级分类"`
+	SubCategoryName  string               `description:"二级分类"`
+	ExpertBackground string               `description:"专家背景"`
+	IsResearch       bool                 `description:"是否属于研选"`
+	Pv               int                  `description:"PV"`
+	ImgUrlPc         string               `description:"图片链接"`
+	CategoryId       string               `description:"文章分类"`
+	HttpUrl          string               `description:"文章链接跳转地址"`
+	IsNeedJump       bool                 `description:"是否需要跳转链接地址"`
+	Source           int                  `description:"来源  1:文章, 2:图表"`
+	Annotation       string               `description:"核心观点"`
+	HomeType         int                  `description:"数据类型:0-纪要(默认); 1-微路演音频"`
+	MicroAudio       *MicroAudioUnionList `description:"微路演音频"`
+	List             []*IndustrialManagementIdInt
 }
 
 type HomeChartListResp struct {

+ 10 - 2
models/industrial_management.go

@@ -4,6 +4,7 @@ import (
 	"github.com/beego/beego/v2/client/orm"
 	"hongze/hongze_clpt/utils"
 	"strconv"
+	"time"
 )
 
 type IndustrialManagementRep struct {
@@ -108,12 +109,19 @@ func GetIndustrialManagementHot3(chartPermissionId int) (item *IndustrialManagem
 }
 
 //产业列表
-func GetIndustrialManagementAll(uid int, condition, orderSrt string, startSize, pageSize int) (items []*IndustrialManagement, err error) {
+func GetIndustrialManagementAll(uid int, condition, orderSrt string, startSize, pageSize int, isBillboard bool) (items []*IndustrialManagement, err error) {
 	o := orm.NewOrm()
+	var conditionBillboard string
+	if isBillboard {
+		var startTime string
+		startTime = time.Now().AddDate(0, 0, -30).Format(utils.FormatDate)
+		conditionBillboard = ` 	( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS f WHERE f.industrial_management_id = man.industrial_management_id AND f.create_time > '` + startTime + `'  ) AS follow_num, `
+	}
 	sql := `SELECT
 			man.*,
+			re.chart_permission_name,
             MAX( art.publish_date ) AS update_time ,
-			MIN(art.publish_date) AS min_report_time,
+			MIN(art.publish_date) AS min_report_time,` + conditionBillboard + `
 		    (SELECT COUNT( 1 )  FROM cygx_industry_fllow AS f WHERE f.user_id = ` + strconv.Itoa(uid) + ` AND f.industrial_management_id = man.industrial_management_id AND f.type = 1) AS is_follow
 			FROM
 			cygx_industrial_management AS man

+ 306 - 0
models/micro_roadshow.go

@@ -0,0 +1,306 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+// MicroRoadShowListResp 微路演列表响应体
+type MicroRoadShowListResp struct {
+	Paging *paging.PagingItem
+	List   []*MicroRoadShowPageList
+}
+
+// MicroRoadShowPageList 微路演列表
+type MicroRoadShowPageList struct {
+	Id                  int    `description:"音视频ID"`
+	Title               string `description:"标题"`
+	ResourceUrl         string `description:"链接"`
+	Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
+	PublishTime         string `description:"发布时间"`
+	BackgroundImg       string `description:"背景图"`
+	ShareImg            string `description:"分享封面图"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
+	IndustryName        string `description:"产业名称"`
+	PlaySeconds         string `description:"音视频时长"`
+	ActivityId          int    `description:"活动ID"`
+	AuthInfo            *UserPermissionAuthInfo
+}
+
+// GetMicroRoadShowVideoPageList 获取微路演视频列表-分页
+func GetMicroRoadShowVideoPageListV8(startSize, pageSize int, condition string, pars []interface{}, conditionAct string, parsAct []interface{}, conditionAudio string, parsAudio []interface{}, audioId, videoId, activityVideoId int) (total int, list []*MicroRoadShowPageList, err error) {
+	o := orm.NewOrm()
+	var sql string
+	if audioId+activityVideoId == 0 {
+		sql += `SELECT
+			video_id AS id,
+			video_name AS title,
+			video_url AS resource_url,
+			3 AS type,
+			publish_date AS publish_time,
+			chart_permission_id,
+			chart_permission_name,
+            industry_name,
+			video_duration AS play_seconds,
+			img_url AS background_img,
+			share_img_url AS share_img,
+			"" as  activity_id
+		FROM
+			cygx_micro_roadshow_video 
+		WHERE
+			publish_status = 1 `
+		if condition != `` {
+			sql += condition
+		}
+	}
+	if audioId+videoId+activityVideoId == 0 {
+		sql += `  UNION ALL `
+	}
+
+	if audioId+videoId == 0 {
+		sql += `
+		SELECT
+			video_id AS id,
+			video_name AS title,
+			video_url AS resource_url,
+			2 AS type,
+		art.activity_time as publish_time,
+			art.chart_permission_id,
+			art.chart_permission_name,
+			"" AS play_seconds,
+			"" AS background_img,
+			"" AS share_img,
+			"" AS industry_name,
+			v.activity_id
+		FROM
+			cygx_activity_video as v
+			INNER JOIN cygx_activity as art on art.activity_id = v.activity_id WHERE 1= 1  `
+		if conditionAct != `` {
+			sql += conditionAct
+		}
+	}
+	if audioId+videoId+activityVideoId == 0 {
+		sql += `  UNION ALL `
+	}
+
+	if videoId+activityVideoId == 0 {
+		sql += `
+			SELECT
+			a.activity_voice_id AS 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.img_url AS background_img,
+			"" AS share_img,
+            "" AS industry_name,
+			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 conditionAudio != `` {
+			sql += conditionAudio
+		}
+	}
+	sql += ` ORDER BY publish_time DESC`
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql, pars, parsAct, parsAudio).QueryRow(&total)
+	if err != nil {
+		return
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, parsAct, parsAudio, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+type AddVideoHistoryReq struct {
+	VideoId     int `description:"视频ID"`
+	PlaySeconds int `description:"播放时长"`
+	SourceType  int `description:"视频来源: 1-微路演; 2-活动 (不传默认为1)"`
+}
+
+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:"视频修改时间"`
+}
+
+func GetLastCygxMicroRoadshowVideoHistory(videoId, userId int) (item *CygxMicroRoadshowVideoHistory, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT * FROM cygx_micro_roadshow_video_history WHERE video_id=? AND user_id=? ORDER BY create_time DESC limit 1 `
+	err = o.Raw(sql, videoId, userId).QueryRow(&item)
+	return
+}
+
+func AddCygxMicroRoadshowVideoHistory(item *CygxMicroRoadshowVideoHistory) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}
+
+// MicroAudioUnionList 微路演音频联合列表
+type MicroAudioUnionList struct {
+	Id                       int    `description:"音视频ID"`
+	AudioTitle               string `description:"标题"`
+	AudioResourceUrl         string `description:"链接"`
+	AudioType                int    `description:"类型: 1-音频; 2-视频"`
+	AudioPublishTime         string `description:"发布时间"`
+	AudioImgUrl              string `description:"背景图"`
+	AudioShareImg            string `description:"分享图"`
+	AudioChartPermissionId   int    `description:"行业ID"`
+	AudioChartPermissionName string `description:"行业名称"`
+	AudioPlaySeconds         string `description:"音视频时长"`
+	AudioActivityId          int    `description:"活动ID"`
+	AuthInfo                 *UserPermissionAuthInfo
+}
+
+// HomeNewestUnionList 首页最新纪要-音频联合查询结果
+type HomeNewestUnionList struct {
+	ArticleId        int    `description:"文章id"`
+	Title            string `description:"标题"`
+	TitleEn          string `description:"英文标题 "`
+	UpdateFrequency  string `description:"更新周期"`
+	CreateDate       string `description:"创建时间"`
+	PublishDate      string `description:"发布时间"`
+	Body             string `description:"内容"`
+	BodyHtml         string `description:"内容带有HTML标签"`
+	Abstract         string `description:"摘要"`
+	CategoryName     string `description:"一级分类"`
+	SubCategoryName  string `description:"二级分类"`
+	ExpertBackground string `description:"专家背景"`
+	IsResearch       bool   `description:"是否属于研选"`
+	Pv               int    `description:"PV"`
+	ImgUrlPc         string `description:"图片链接"`
+	CategoryId       string `description:"文章分类"`
+	HttpUrl          string `description:"文章链接跳转地址"`
+	IsNeedJump       bool   `description:"是否需要跳转链接地址"`
+	Source           int    `description:"来源  1:文章, 2:图表"`
+	Annotation       string `description:"核心观点"`
+	HomeType         int    `description:"数据类型:0-纪要(默认); 1-微路演音频"`
+	MicroAudioUnionList
+}
+
+// GetHomeNewestListUnionList 首页最新纪要-音频联合查询
+func GetHomeNewestListUnionList(condition string, pars []interface{}, startSize, pageSize int) (list []*HomeNewestUnionList, err error) {
+	sql := `SELECT
+				id, article_id, title, title_en, update_frequency, create_date, publish_date, body, abstract, category_name, sub_category_name, expert_background, category_id, source, annotation,
+				(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = art.article_id ) as pv,
+				0 AS home_type, "" AS audio_title, "" AS audio_resource_url, 0 AS audio_type, "" AS audio_publish_time, 0 AS audio_chart_permission_id, "" AS audio_chart_permission_name,
+				"" AS audio_play_seconds, "" AS audio_img_url, 0 AS audio_activity_id
+			FROM
+				cygx_article AS art
+			WHERE
+				art.publish_status = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` UNION ALL
+			
+			SELECT
+				a.activity_voice_id, 0, "", "", "", "", b.activity_time, "", "", "", "", "", 0, 0, "",
+				0, 1, a.voice_name, a.voice_url, 1, b.activity_time,
+				b.chart_permission_id, b.chart_permission_name, a.voice_play_seconds AS audio_play_seconds, a.img_url AS audio_img_url, a.activity_id AS audio_activity_id
+			FROM
+				cygx_activity_voice AS a
+			JOIN cygx_activity AS b ON a.activity_id = b.activity_id`
+	sql += ` ORDER BY publish_date DESC`
+	sql += ` LIMIT ?,?`
+	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// GetHomeNewestListUnionCount 首页最新纪要-音频联合查询总数
+func GetHomeNewestListUnionCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+				COUNT(1) AS count
+			FROM
+				(
+					SELECT
+						art.id
+					FROM
+						cygx_article AS art
+					WHERE
+						art.publish_status = 1 `
+	if condition != `` {
+		sql += condition
+	}
+	sql += ` UNION ALL
+				SELECT
+					a.activity_voice_id
+				FROM
+					cygx_activity_voice AS a
+				JOIN cygx_activity AS b ON a.activity_id = b.activity_id
+			) z `
+	err = o.Raw(sql, pars).QueryRow(&count)
+	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"`
+	VideoName           string    `description:"视频标题"`
+	ChartPermissionId   int       `description:"行业ID"`
+	ChartPermissionName string    `description:"行业名称"`
+	IndustryId          int       `description:"产业ID"`
+	IndustryName        string    `description:"产业名称"`
+	PublishStatus       int       `description:"发布状态:0-未发布;1-已发布"`
+	ModifyDate          time.Time `description:"更新时间"`
+	PublishDate         time.Time `description:"发布时间"`
+	VideoCounts         int       `description:"视频播放量"`
+	VideoDuration       int       `description:"视频时长"`
+	VideoUrl            string    `description:"视频地址"`
+	CreateTime          time.Time `description:"创建时间"`
+	ImgUrl              string    `description:"背景图链接"`
+	DetailImgUrl        string    `description:"产业详情页背景图"`
+}
+
+// GetMicroRoadshowVideoById 主键获取微路演视频
+func GetMicroRoadshowVideoById(videoId int) (item *MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE video_id = ? LIMIT 1`
+	err = orm.NewOrm().Raw(sql, videoId).QueryRow(&item)
+	return
+}
+
+func UpdateCygxActivityVideoCounts(activityId 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()
+	return
+}
+
+// GetMicroRoadshowVideoByIndustryIds 根据行业ID查询产业视频列表
+func GetMicroRoadshowVideoByIndustryIds(industrialIdArr []int) (list []*MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id in (` + utils.GetOrmInReplace(len(industrialIdArr)) + `)  and publish_status = 1 `
+	_, err = orm.NewOrm().Raw(sql, industrialIdArr).QueryRows(&list)
+	return
+}
+
+// GetMicroRoadshowVideoByIndustryId 根据行业ID查询产业视频列表
+func GetMicroRoadshowVideoByIndustryId(industryId int) (item *MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE industry_id = ? and publish_status = 1`
+	err = orm.NewOrm().Raw(sql, industryId).QueryRow(&item)
+	return
+}

+ 41 - 0
models/report.go

@@ -15,6 +15,8 @@ type IndustrialManagement struct {
 	IndustrialManagementId int                  `orm:"column(industrial_management_id);pk" description:"产业id"`
 	IndustryName           string               `description:"产业名称"`
 	ChartPermissionId      int                  `description:"权限id"`
+	ChartPermissionName    string               `description:"权限名称"`
+	LayoutTime             string               `description:"布局时间"`
 	UpdateTime             string               `description:"更新时间"`
 	IsRed                  bool                 `description:"是否标记红点"`
 	IsHot                  bool                 `description:"是否是热门"`
@@ -26,6 +28,19 @@ type IndustrialManagement struct {
 	Source                 int                  `description:"来源 1:弘则资源包(报告)、2:研选主题(报告)"`
 	IndustrialSubjectList  []*IndustrialSubject `description:"标的列表"`
 	MinReportTime          string               `description:"报告最早发布时间"`
+	IndustryVideo          *MicroVideoSimpleInfo
+	AuthInfo               *UserPermissionAuthInfo
+}
+
+type MicroVideoSimpleInfo struct {
+	Id                  int    `description:"视频ID"`
+	Title               string `description:"标题"`
+	ResourceUrl         string `description:"链接"`
+	BackgroundImg       string `description:"背景图"`
+	PlaySeconds         int    `description:"音视频时长"`
+	DetailImgUrl        string `description:"产业详情页背景图"`
+	ChartPermissionId   int    `description:"行业ID"`
+	ChartPermissionName string `description:"行业名称"`
 }
 
 type TacticsListResp struct {
@@ -262,3 +277,29 @@ type SearchReportAndResourceResp struct {
 	ListHzReport   []*ArticleCollectionResp `description:"弘则报告"`
 	Paging         *paging.PagingItem       `description:"弘则报告分页"`
 }
+
+//报告收藏榜单列表
+func GetReportCollectionBillboardList(limit int, pars []interface{}, condition string) (items []*HomeArticle, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			ac.id,
+			a.article_id,
+			a.title,
+			date_format(a.publish_date, '%Y-%m-%d') AS publish_date,
+			m.chart_permission_name AS permission_name,
+			COUNT(ac.id) AS collection_num
+		FROM
+			cygx_article AS a
+			INNER JOIN cygx_report_mapping AS m ON m.category_id = a.category_id
+			INNER JOIN cygx_article_collect AS ac ON ac.article_id = a.article_id 
+		WHERE
+			1 = 1 
+			AND a.publish_status = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY a.article_id ORDER BY collection_num DESC, ac.id DESC, a.publish_date DESC`
+	sql += ` LIMIT ?`
+	_, err = o.Raw(sql, pars, limit).QueryRows(&items)
+	return
+}

+ 26 - 0
models/report_industrial_seaarch_history.go

@@ -0,0 +1,26 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportIndustrialSeaarchHistory struct {
+	Id                int `orm:"column(id);pk"`
+	UserId            int
+	CreateTime        time.Time
+	Mobile            string `description:"手机号"`
+	CompanyId         int    `description:"公司id"`
+	CompanyName       string `description:"公司名称"`
+	ChartPermissionId int    `description:"表chart_permission中id"`
+	IsNewLabel        string `description:"是否属于新标签,1是,0否"`
+	IsDeepLabel       string `description:"是否属于深标签,1是,0否"`
+	OrderColumn       string `description:"排序字段 ,0 最近更新 ,1弘则推荐"`
+}
+
+//添加
+func AddCygxReportIndustrialSeaarchHistory(item *CygxReportIndustrialSeaarchHistory) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}

+ 8 - 0
models/user.go

@@ -239,3 +239,11 @@ func BindUserOutboundMobile(mobile, countryCode string, userId int) (err error)
 	_, err = o.Raw(sql, mobile, countryCode, countryCode, userId).Exec()
 	return
 }
+
+type UserPermissionAuthInfo struct {
+	HasPermission int    `description:"是否有权限:1-有权限; 2-无权限; 3-潜在客户未提交申请; 4-潜在客户已提交申请 5-仅有FICC权限"`
+	SellerMobile  string `description:"销售手机号"`
+	SellerName    string `description:"销售名称"`
+	OperationMode string `description:"操作方式:Apply-立即申请; Call-拨号"`
+	PopupMsg      string `description:"权限弹窗信息"`
+}

+ 9 - 0
routers/commentsRouter.go

@@ -88,6 +88,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportBillboardController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportBillboardController"],
+        beego.ControllerComments{
+            Method: "ReadList",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"] = append(beego.GlobalControllerRouter["hongze/hongze_clpt/controllers:MobileReportController"],
         beego.ControllerComments{
             Method: "List",

+ 7 - 0
routers/router.go

@@ -73,6 +73,13 @@ func init() {
 				&controllers.MobileReportController{},
 			),
 		),
+		web.NSNamespace("/report_billboard",
+			web.NSInclude(
+				&controllers.ReportBillboardController{},
+				&controllers.ReportBillboardCommonController{},
+				&controllers.MobileReportBillboardController{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 240 - 0
services/micro_roadshow.go

@@ -0,0 +1,240 @@
+package services
+
+import (
+	"encoding/json"
+	"errors"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+)
+
+// GetMicroRoadShowDefaultImgConfig 获取微路演默认图/分享图配置
+func GetMicroRoadShowDefaultImgConfig() (audioMap, videoMap, audioShareMap, videoShareMap map[int]string, err error) {
+	audioMap = make(map[int]string, 0)
+	videoMap = make(map[int]string, 0)
+	audioShareMap = make(map[int]string, 0)
+	videoShareMap = make(map[int]string, 0)
+	key := models.MicroRoadshowDefaultImgKey
+	conf, e := models.GetConfigByCode(key)
+	if e != nil {
+		err = errors.New("获取微路演默认图配置失败, Err: " + e.Error())
+		return
+	}
+	if conf.ConfigValue == "" {
+		err = errors.New("获取微路演默认图配置有误")
+		return
+	}
+	list := new(models.MicroRoadShowDefaultImgList)
+	if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
+		err = errors.New("微路演默认图配置配置值解析失败, Err: " + e.Error())
+		return
+	}
+	audioList := list.Audio
+	for i := range audioList {
+		audioMap[audioList[i].ChartPermissionId] = audioList[i].ImgUrl
+		audioShareMap[audioList[i].ChartPermissionId] = audioList[i].ShareImg
+	}
+	videoList := list.Video
+	for i := range videoList {
+		videoMap[videoList[i].ChartPermissionId] = videoList[i].ImgUrl
+		videoShareMap[videoList[i].ChartPermissionId] = videoList[i].ShareImg
+	}
+	return
+}
+
+// GetHomeNewestList 获取首页最新列表
+func GetHomeNewestList(userId, companyId, startSize, pageSize int, condition string, pars []interface{}) (resp []*models.HomeArticle, total int, err error) {
+	resp = make([]*models.HomeArticle, 0)
+	unionList, e := models.GetHomeNewestListUnionList(condition, pars, startSize, pageSize)
+	if e != nil {
+		err = errors.New("获取首页最新列表失败")
+		return
+	}
+	unionTotal, e := models.GetHomeNewestListUnionCount(condition, pars)
+	if e != nil {
+		err = errors.New("获取首页最新列表总数失败")
+		return
+	}
+	total = unionTotal
+
+	// 用户权限
+	authInfo, permissionArr, e := GetUserRaiPermissionInfo(userId, companyId)
+	if e != nil {
+		err = errors.New("获取用户权限失败, Err: " + e.Error())
+		return
+	}
+
+	// 获取默认图配置
+	audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
+	if e != nil {
+		err = errors.New("获取微路演默认图配置失败, Err: " + e.Error())
+		return
+	}
+
+	// 此处没有直接使用HomeArticle结构体而是多加了一层, 纯粹是为了方便前端区分纪要和微路演音频=_=!
+	for _, v := range unionList {
+		item := new(models.HomeArticle)
+		item.HomeType = v.HomeType
+		// 纪要
+		if item.HomeType == 0 {
+			item.ArticleId = v.ArticleId
+			item.Title = v.Title
+			item.TitleEn = v.TitleEn
+			item.UpdateFrequency = v.UpdateFrequency
+			item.CreateDate = v.CreateDate
+			item.PublishDate = v.PublishDate
+			item.Body = v.Body
+			item.BodyHtml = v.BodyHtml
+			item.Abstract = v.Abstract
+			item.CategoryName = v.CategoryName
+			item.SubCategoryName = v.SubCategoryName
+			item.ExpertBackground = v.ExpertBackground
+			item.IsResearch = v.IsResearch
+			item.Pv = v.Pv
+			item.ImgUrlPc = v.ImgUrlPc
+			item.CategoryId = v.CategoryId
+			item.HttpUrl = v.HttpUrl
+			item.IsNeedJump = v.IsNeedJump
+			item.Source = v.Source
+			item.Annotation = v.Annotation
+		}
+		// 音频
+		if v.HomeType == 1 {
+			ad := new(models.MicroAudioUnionList)
+			ad.Id = v.Id
+			ad.AudioTitle = v.AudioTitle
+			ad.AudioResourceUrl = v.AudioResourceUrl
+			ad.AudioType = v.AudioType
+			ad.AudioPublishTime = utils.StrTimeToTime(v.AudioPublishTime).Format(utils.FormatDate)
+			ad.AudioImgUrl = v.AudioImgUrl
+			ad.AudioChartPermissionId = v.AudioChartPermissionId
+			ad.AudioChartPermissionName = v.AudioChartPermissionName
+			ad.AudioPlaySeconds = v.AudioPlaySeconds
+			ad.AudioPlaySeconds = v.AudioPlaySeconds
+			ad.AudioActivityId = v.AudioActivityId
+			item.MicroAudio = ad
+			// 默认图
+			if ad.AudioImgUrl == "" {
+				if ad.AudioType == 1 {
+					ad.AudioImgUrl = audioMap[ad.AudioChartPermissionId]
+				} else {
+					ad.AudioImgUrl = videoMap[ad.AudioChartPermissionId]
+				}
+			}
+			// 分享图
+			if ad.AudioType == 1 {
+				ad.AudioShareImg = audioShareMap[ad.AudioChartPermissionId]
+			} else {
+				ad.AudioShareImg = videoShareMap[ad.AudioChartPermissionId]
+			}
+			// 权限
+			au := new(models.UserPermissionAuthInfo)
+			au.SellerName = authInfo.SellerName
+			au.SellerMobile = authInfo.SellerMobile
+			au.HasPermission = authInfo.HasPermission
+			au.OperationMode = authInfo.OperationMode
+			if au.HasPermission == 1 {
+				// 非宏观权限进一步判断是否有权限
+				if ad.AudioChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, ad.AudioChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == UserPermissionOperationModeCall {
+					if ad.AudioType == 1 {
+						au.PopupMsg = UserPermissionPopupMsgCallActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+					}
+				} else {
+					if ad.AudioType == 1 {
+						au.PopupMsg = UserPermissionPopupMsgApplyActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+					}
+				}
+			}
+			ad.AuthInfo = au
+		}
+		resp = append(resp, item)
+	}
+	return
+}
+
+// GetMicroRoadShowPageList 获取微路演列表添加活动视频 更新与8.1版本
+func GetMicroRoadShowPageListV8(pageSize, currentIndex, audioId, videoId, activityVideoId int, keywords string) (respList []*models.MicroRoadShowPageList, total int, err error) {
+	var e error
+	// 根据每页数据量获取音视频配比
+	startSize := utils.StartIndex(currentIndex, pageSize)
+	videoList := make([]*models.MicroRoadShowPageList, 0)
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+	}
+
+	//音频的查询
+	var audioCond string
+	var audioPars []interface{}
+	// 如果筛选条件为指定视频ID则不做音频查询
+	if videoId > 0 || activityVideoId > 0 {
+		audioCond = ""
+	} else {
+		// 活动已发布且已结束
+		audioCond += ` AND b.publish_status = 1 AND b.active_state = 3`
+		//活动音频,设置有效时间为30天,失效后该活动就不再支持音频回放。有效期起始时间为活动的开始时间
+		//endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+		//audioCond += ` AND b.activity_time > ? `
+		//audioPars = append(audioPars, endTime)
+		if keywords != "" {
+			audioCond += ` AND a.voice_name LIKE ? OR b.label LIKE ?`
+			audioPars = append(audioPars, keywords, keywords)
+		}
+		if audioId > 0 {
+			audioCond += ` AND a.activity_voice_id = ?`
+			audioPars = append(audioPars, audioId)
+		}
+	}
+	//视频的处理
+	var videoCond string
+	var videoCondAct string
+	var videoPars []interface{}
+	var videoParsAct []interface{}
+	if audioId > 0 {
+		videoCond = ""
+	} else {
+		if keywords != "" {
+			videoCond += ` AND video_name LIKE ?`
+			videoPars = append(videoPars, keywords)
+			videoCondAct += ` AND video_name LIKE ?`
+			videoParsAct = append(videoParsAct, keywords)
+		}
+		if videoId > 0 {
+			videoCond += ` AND video_id = ?`
+			videoPars = append(videoPars, videoId)
+		}
+		if activityVideoId > 0 {
+			videoCondAct += ` AND video_id = ?`
+			videoParsAct = append(videoParsAct, activityVideoId)
+		}
+
+		//如果传了路演的或者活动的视频ID只查询一个
+		if videoId > 0 {
+			videoCondAct += ` AND video_id = 0 `
+		}
+		if activityVideoId > 0 {
+			videoCond += ` AND video_id = 0 `
+		}
+		//if videoId == 0 {
+		//	endTime := time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05")
+		//	videoCondAct += ` AND art.activity_time > ? `
+		//	videoParsAct = append(videoParsAct, endTime)
+		//}
+		videoCond += ` AND publish_status = 1`
+	}
+	total, videoList, e = models.GetMicroRoadShowVideoPageListV8(startSize, pageSize, videoCond, videoPars, videoCondAct, videoParsAct, audioCond, audioPars, audioId, videoId, activityVideoId)
+	if e != nil {
+		err = errors.New("获取微路演音视频列表失败, Err: " + e.Error())
+		return
+	}
+	respList = videoList
+	return
+}

+ 87 - 0
services/user_permission.go

@@ -0,0 +1,87 @@
+package services
+
+import (
+	"errors"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"strings"
+)
+
+var (
+	UserPermissionOperationModeApply      = "Apply"
+	UserPermissionOperationModeCall       = "Call"
+	UserPermissionPopupMsgApplyActivity   = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+	UserPermissionPopupMsgCallActivity    = "您暂无权限参加此活动,若想参加可以联系对口销售"
+	UserPermissionPopupMsgApplyMicroVideo = "您暂无权限查看此视频,若想查看可以申请开通对应的试用权限"
+	UserPermissionPopupMsgCallMicroVideo  = "您暂无权限查看此视频若想查看可以联系对口销售"
+)
+
+// GetUserRaiPermissionInfo 获取权限类型及信息
+// HasPermission 是否有权限:1-有权限; 2-无权限; 3-潜在客户未提交申请; 4-潜在客户已提交申请 5-仅有FICC权限
+func GetUserRaiPermissionInfo(userId, companyId int) (authInfo models.UserPermissionAuthInfo, permissionArr []string, err error) {
+	// 用户申请记录
+	applyCount, e := models.GetApplyRecordCount(userId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取用户申请信息失败, Err: " + e.Error())
+		return
+	}
+
+	// 潜在用户
+	if companyId <= 1 {
+		authInfo.HasPermission = 3
+		if applyCount > 0 {
+			authInfo.HasPermission = 4
+		}
+		authInfo.OperationMode = UserPermissionOperationModeApply
+		authInfo.PopupMsg = UserPermissionPopupMsgApplyActivity
+		return
+	}
+
+	// 销售信息
+	ficcSeller, e := models.GetSellerByCompanyIdCheckFicc(companyId, utils.COMPANY_PRODUCT_FICC_ID)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取FICC销售信息失败, Err: " + e.Error())
+		return
+	}
+	raiSeller, e := models.GetSellerByCompanyIdCheckFicc(companyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("获取权益销售信息失败, Err: " + e.Error())
+		return
+	}
+	if raiSeller != nil {
+		authInfo.SellerMobile = raiSeller.Mobile
+		authInfo.SellerName = raiSeller.RealName
+	}
+	// 仅有FICC权限
+	if ficcSeller != nil && raiSeller == nil {
+		authInfo.HasPermission = 5
+		authInfo.OperationMode = UserPermissionOperationModeApply
+		authInfo.PopupMsg = UserPermissionPopupMsgApplyActivity
+		return
+	}
+
+	// permissions示例: 医药,消费,科技,智造,策略,专家,买方研选
+	permissions, e := models.GetCompanyPermission(companyId)
+	if e != nil {
+		err = errors.New("获取客户权限失败, Err: " + e.Error())
+		return
+	}
+	if permissions == "" {
+		// 无权益权限
+		if raiSeller != nil {
+			// 有销售信息
+			authInfo.HasPermission = 2
+			authInfo.OperationMode = UserPermissionOperationModeCall
+			authInfo.PopupMsg = UserPermissionPopupMsgCallActivity
+			return
+		}
+		// 无销售信息, 无申请, 视作潜在用户
+		authInfo.HasPermission = 3
+		authInfo.OperationMode = UserPermissionOperationModeApply
+		return
+	}
+	// 有基本的权益权限
+	authInfo.HasPermission = 1
+	permissionArr = strings.Split(permissions, ",")
+	return
+}

+ 22 - 0
utils/common.go

@@ -651,3 +651,25 @@ func GetOrmInReplace(num int) string {
 	}
 	return strings.Join(template, ",")
 }
+
+// InArrayByStr php中的in_array(判断String类型的切片中是否存在该string值)
+func InArrayByStr(idStrList []string, searchId string) (has bool) {
+	for _, id := range idStrList {
+		if id == searchId {
+			has = true
+			return
+		}
+	}
+	return
+}
+
+// InArrayByInt php中的in_array(判断Int类型的切片中是否存在该int值)
+func InArrayByInt(idIntList []int, searchId int) (has bool) {
+	for _, id := range idIntList {
+		if id == searchId {
+			has = true
+			return
+		}
+	}
+	return
+}

+ 8 - 0
utils/constants.go

@@ -77,6 +77,7 @@ const (
 	DefaultHeadimgurl                string = "https://hzstatic.hzinsights.com/static/temp/20220426202204/20220426/P5qLR2zzfBdKItp3eX2Du1tvq9Ba.jpg"
 	OPEN_TOKEN_KEY                   string = "CLPT_OPEN_TOKEN_KEY" //策略品台开放平台的token key
 	OnlineTime                       string = "2021-06-01 00:00:01" //上线时间
+	HONG_GUAN_ID                     int    = 1
 )
 
 //模板消息推送类型
@@ -85,3 +86,10 @@ const (
 	TEMPLATE_MSG_CYGX_ARTICLE_ADD  = 13 //查研观向报告更新推送  13
 	TEMPLATE_MSG_CYGX_APPLY        = 14 //查研观向审批通知
 )
+
+const (
+	COMPANY_PRODUCT_FICC_ID   = 1
+	COMPANY_PRODUCT_FICC_NAME = "ficc"
+	COMPANY_PRODUCT_RAI_ID    = 2
+	COMPANY_PRODUCT_RAI_NAME  = "权益"
+)