Browse Source

查研观向9.0

xingzai 2 years ago
parent
commit
e7cffadabe

+ 0 - 3
controllers/activity.go

@@ -381,15 +381,12 @@ func (this *ActivityCoAntroller) ActivityList() {
 		}
 	}
 	resp := new(models.GetCygxActivityListRep)
-
 	//处理音频回放
 	mapActivityVoice, err := services.GetActivityVoiceResp(mapActivityId)
 	if err != nil {
 		br.Msg = "获取信息失败"
 		br.ErrMsg = "GetActivityVoiceResp,Err:" + err.Error()
 	}
-	fmt.Println(mapActivityId)
-	fmt.Println(mapActivityVoice)
 	//处理列表的标签是否展示逻辑
 	for k, v := range list {
 		if mapActivityVoice[v.ActivityId] != nil {

+ 180 - 52
controllers/home.go

@@ -9,6 +9,7 @@ import (
 	"html"
 	"strconv"
 	"strings"
+	"time"
 )
 
 type HomeController struct {
@@ -569,72 +570,199 @@ func (this *HomeController) ListHomeArtAndChart() {
 			list = homeList
 		}
 
-		//研选的五张图片
-		detailResearch, err := models.GetConfigByCode("category_research_img_url")
+		////研选的五张图片
+		//detailResearch, err := models.GetConfigByCode("category_research_img_url")
+		//if err != nil {
+		//	br.Msg = "获取数据失败"
+		//	br.ErrMsg = "获取数据研选分类图片失败,Err:" + err.Error()
+		//	return
+		//}
+		//researchList := strings.Split(detailResearch.ConfigValue, "{|}")
+		////对应分类的所图片
+		//detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
+		//if err != nil {
+		//	br.Msg = "获取数据失败"
+		//	br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+		//	return
+		//}
+		//categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+		//mapCategoryUrl := make(map[string]string)
+		//var categoryId string
+		//var imgUrlChart string
+		//for _, v := range categoryUrlList {
+		//	vslice := strings.Split(v, "_")
+		//	categoryId = vslice[0]
+		//	imgUrlChart = vslice[len(vslice)-1]
+		//	mapCategoryUrl[categoryId] = imgUrlChart
+		//}
+		//
+		//for k, v := range list {
+		//	if v.HomeType != 0 {
+		//		continue
+		//	}
+		//	item := list[k]
+		//	//如果文章一开始的内容是图片,优先展示第一张图片
+		//	imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))
+		//	newBody, _ := services.GetReportContentTextSubByarticle(item.Body, item.Annotation, item.ArticleId)
+		//	list[k].Body = newBody
+		//	if imgurl != "" {
+		//		list[k].BodyHtml = imgurl
+		//	}
+		//	list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+		//	if strings.Contains(item.CategoryName, utils.CHART_PERMISSION_NAME_YANXUAN) {
+		//		list[k].IsResearch = true
+		//	}
+		//	if item.Pv > 999 {
+		//		list[k].Pv = 999
+		//	}
+		//	//如果是研选系列的任意取五张图片的中的一张
+		//	if v.CategoryId == "0" {
+		//		knum := v.ArticleId % 5
+		//		list[k].ImgUrlPc = researchList[knum]
+		//	} else {
+		//		list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+		//	}
+		//	if list[k].ArticleId < utils.SummaryArticleId {
+		//		list[k].HttpUrl = utils.StrategyPlatform + strconv.Itoa(v.ArticleId)
+		//		list[k].IsNeedJump = true
+		//	}
+		//	list[k].Source = 1
+		//}
+		resp.List, err = services.HandleArticleCategoryImg(list)
 		if err != nil {
-			br.Msg = "获取数据失败"
-			br.ErrMsg = "获取数据研选分类图片失败,Err:" + err.Error()
+			br.Msg = "获取信息失败"
+			br.Msg = "处理封面图片失败,HandleArticleCategoryImg,Err:" + err.Error()
+			return
+		}
+		resp.List = list
+	}
+	if chartTotal > total {
+		total = chartTotal
+	}
+
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// @Title 首页列表接口
+// @Description 首页列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.HomeArtAndChartListResp
+// @router /new [get]
+func (this *HomeController) NewList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	startSize = paging.StartIndex(currentIndex, pageSize)
+
+	var condition string
+	var conditionInit string
+	var pars []interface{}
+	var total int
+	resp := new(models.HomeResourceDataListResp)
+
+	//condition += " AND source = 'article' "
+	//查询近一个月的数据
+	conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
+	if user.CompanyId <= 1 {
+		condition += " AND source IN ('roadshow','article','activityvideo','activityvoice') " + conditionInit
+		if user.Mobile == "" && user.Email == "" {
+			startSize = 0
+			pageSize = 4
+		}
+	} else {
+		condition += ` AND source NOT IN ('activity','activityspecial','newchart') ` + conditionInit
+		conditionActivity, err := services.GetActivityonditionList(user, "", "", "", "1,2,3", "", 0, 0, "", 0)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
 			return
 		}
-		researchList := strings.Split(detailResearch.ConfigValue, "{|}")
-		//对应分类的所图片
-		detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
+		conditionActivity += ` AND art.is_limit_people = 1 AND art.publish_status = 1 `
+		var conditionOrder string
+		conditionOrder = ` ORDER BY art.activity_time DESC ,  art.active_state ASC   `
+		conditionActivity += conditionOrder
+		listActivity, err := models.GetActivityListHomeNew(conditionActivity, 0, 200)
 		if err != nil {
-			br.Msg = "获取数据失败"
-			br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取可见活动数据失败,Err:" + err.Error()
 			return
 		}
-		categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
-		mapCategoryUrl := make(map[string]string)
-		var categoryId string
-		var imgUrlChart string
-		for _, v := range categoryUrlList {
-			vslice := strings.Split(v, "_")
-			categoryId = vslice[0]
-			imgUrlChart = vslice[len(vslice)-1]
-			mapCategoryUrl[categoryId] = imgUrlChart
+
+		var activityIds []int
+		for _, v := range listActivity {
+			activityIds = append(activityIds, v.ActivityId)
+		}
+		lenActivityIds := len(activityIds)
+		if lenActivityIds > 0 {
+			condition += ` OR ( source = 'activity' AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) ` + conditionInit + ` )    `
+			pars = append(pars, activityIds)
 		}
 
-		for k, v := range list {
-			if v.HomeType != 0 {
-				continue
-			}
-			item := list[k]
-			//如果文章一开始的内容是图片,优先展示第一张图片
-			imgurl, _ := services.FixArticleImgUrl(html.UnescapeString(list[k].Body))
-			newBody, _ := services.GetReportContentTextSubByarticle(item.Body, item.Annotation, item.ArticleId)
-			list[k].Body = newBody
-			if imgurl != "" {
-				list[k].BodyHtml = imgurl
-			}
-			list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
-			if strings.Contains(item.CategoryName, utils.CHART_PERMISSION_NAME_YANXUAN) {
-				list[k].IsResearch = true
-			}
-			if item.Pv > 999 {
-				list[k].Pv = 999
-			}
-			//如果是研选系列的任意取五张图片的中的一张
-			if v.CategoryId == "0" {
-				knum := v.ArticleId % 5
-				list[k].ImgUrlPc = researchList[knum]
-			} else {
-				list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
-			}
-			if list[k].ArticleId < utils.SummaryArticleId {
-				list[k].HttpUrl = utils.StrategyPlatform + strconv.Itoa(v.ArticleId)
-				list[k].IsNeedJump = true
-			}
-			list[k].Source = 1
+		listActivitySpecial, _, err := services.GetActivitySpecialList(user, 1, 200, "")
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取专项调研可见权限失败失败,Err:" + err.Error()
+			return
+		}
+
+		var activityspecialIds []int
+		for _, v := range listActivitySpecial {
+			activityspecialIds = append(activityspecialIds, v.ActivityId)
+		}
+		lenActivityspecialIds := len(activityspecialIds)
+		if lenActivityspecialIds > 0 {
+			condition += ` OR ( source = 'activityspecial' AND source_id IN (` + utils.GetOrmInReplace(lenActivityspecialIds) + `) ` + conditionInit + ` )   `
+			pars = append(pars, activityspecialIds)
 		}
-		resp.List = list
 	}
-	if chartTotal > total {
-		total = chartTotal
+	total, err := models.GetResourceDataCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
 	}
 
+	if user.Mobile == "" && user.Email == "" {
+		total = pageSize
+	}
+
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	list, err := services.GetResourceDataList(condition, pars, startSize, pageSize, user)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	resp.Paging = page
+	resp.List = list
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 16 - 1
models/activity.go

@@ -1074,7 +1074,22 @@ func GetActivityListNew(condition string, pars []interface{}, uid, startSize, pa
 		tempCondition = strings.TrimRight(tempCondition, ",")
 		sql = `SELECT * FROM(` + sql + `) AS t WHERE t.activity_type_name IN (` + tempCondition + `)`
 	}
-	_, err = o.Raw(sql, pars, uid, uid, uid, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, uid, uid, uid, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//列表
+func GetActivityListHomeNew(condition string, startSize, pageSize int) (items []*ActivityDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT activity_id
+		FROM cygx_activity as art
+		INNER JOIN cygx_activity_type  as t ON t.activity_type_id = art.activity_type_id
+		INNER JOIN  chart_permission  AS c ON c.chart_permission_id = art.chart_permission_id  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 28 - 0
models/activity_video.go

@@ -16,6 +16,18 @@ type CygxActivityVideo struct {
 	CreateTime    string `description:"创建时间"`
 }
 
+type CygxActivityVideoResp struct {
+	VideoId           int    `orm:"column(video_id);pk"description:"视频id"`
+	ChartPermissionId int    `description:"权限id"`
+	VideoName         string `description:"视频名称"`
+	ActivityId        int    ` description:"活动ID"`
+	ModifyDate        string `description:"更新时间"`
+	VideoDuration     string `description:"视频时长"`
+	VideoCounts       int    `description:"播放量"`
+	VideoUrl          string `description:"视频地址"`
+	CreateTime        string `description:"创建时间"`
+}
+
 type CygxActivityVideoReq struct {
 	VideoName     string `description:"视频名称"`
 	VideoDuration string `description:"视频时长"`
@@ -69,3 +81,19 @@ func GetCygxActivityVideoById(activityId int) (item *CygxActivityVideo, err erro
 	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
 	return
 }
+
+//列表
+func GetActivityVideoList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	v.*,art.chart_permission_id
+FROM
+	cygx_activity_video AS v 
+	INNER JOIN cygx_activity as art ON art.activity_id = v.activity_id    WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 30 - 0
models/activity_voice.go

@@ -18,6 +18,20 @@ type CygxActivityVoice struct {
 	CreateTime       time.Time `description:"创建时间"`
 }
 
+// ActivityVoice 活动语音表结构体
+type CygxActivityVoiceResp struct {
+	ActivityVoiceId     int    `orm:"column(activity_voice_id);pk" description:"活动音频ID"`
+	ActivityId          int    ` description:"活动ID"`
+	VoiceUrl            string `description:"音频地址"`
+	VoiceName           string `description:"音频名称"`
+	VoicePlaySeconds    string `description:"音频时长"`
+	VoiceCounts         int    `description:"播放量"`
+	ModifyTime          string `description:"更新时间"`
+	CreateTime          string `description:"创建时间"`
+	ChartPermissionId   int    `description:"权限id"`
+	ChartPermissionName string `description:"行业名称"`
+}
+
 // ActivityVoiceReq 音频数据
 type CygxActivityVoiceReq struct {
 	ActivityId      int    ` description:"活动ID"`
@@ -83,3 +97,19 @@ func GetCygxActivityVoiceByActivityId(activityId int) (item *CygxActivityVoice,
 	err = orm.NewOrm().Raw(sql, activityId).QueryRow(&item)
 	return
 }
+
+//列表
+func GetActivityVoiceList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVoiceResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+	v.*,art.chart_permission_id
+FROM
+	cygx_activity_voice AS v 
+	INNER JOIN cygx_activity as art ON art.activity_id = v.activity_id    WHERE 1= 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 27 - 22
models/article.go

@@ -84,28 +84,33 @@ func AddCygxArticle(item *CygxArticle) (lastId int64, err error) {
 }
 
 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:"核心观点"`
-	HomeType         int                  `description:"数据类型:0-纪要(默认); 1-微路演音频"`
-	MicroAudio       *MicroAudioUnionList `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:"微路演音频"`
+	ChartPermissionName string               `description:"权限名称"`
+	ArticleTypeName     string               `description:"权限名称"`
+	IsReport            int                  `description:"是否属于报告,1是,0否"`
+	ArticleResponse     int                  `description:"报告类型 0:啥也不是,1研选报告,2:研选纪要,3:研选沙龙,4;研选观点"`
+	List                []*IndustrialManagementIdInt
 }
 
 type ArticleDetail struct {

+ 25 - 0
models/chart.go

@@ -219,6 +219,31 @@ func GetChartListCollection(chartIds string, userId, startSize, pageSize int) (i
 	return
 }
 
+//获取图表列表
+func GetChartListCollectionNew(condition string, pars []interface{}, userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT a.*,
+			t.create_time AS t_create_time,
+			c.create_time AS c_create_time,
+			( SELECT COUNT(*) FROM cygx_chart_top AS t WHERE t.chart_id = a.chart_id AND t.user_id = ? ) AS is_top,
+			( SELECT COUNT(*) FROM cygx_chart_collect AS c WHERE c.chart_id = a.chart_id AND c.user_id = ? ) AS num_c 
+		FROM
+			cygx_chart_all AS a
+			LEFT JOIN cygx_chart_top AS t ON t.chart_id = a.chart_id
+			LEFT JOIN cygx_chart_collect AS c ON c.chart_id = a.chart_id 
+		WHERE
+ 1=1
+			` + condition + `
+			
+		GROUP BY
+			a.chart_id 
+		ORDER BY
+			t_create_time DESC,
+			c_create_time DESC LIMIT ?,? `
+	_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 //获取图表列表本地
 func GetChartListCollectionWithCygx(userId, startSize, pageSize int) (items []*HomeChartListResp, err error) {
 	o := orm.NewOrm()

+ 1 - 0
models/industrial_management.go

@@ -246,6 +246,7 @@ type IndustrialManagementIdInt struct {
 	SubjectName            string `description:"标的名称"`
 	ArticleId              int    `description:"文章ID"`
 	IsResearch             bool   `description:"是否属于研选"`
+	ChartPermissionId      int    `description:"权限id"`
 }
 
 type IndustrialManagementIdInts struct {

+ 11 - 0
models/micro_roadshow.go

@@ -318,6 +318,17 @@ type MicroRoadshowCollectReq struct {
 	SourceType int `description:"视频来源: 1-音频; 2-活动视频; 3-微路演视频 (不传默认为1)"`
 }
 
+// GetMicroRoadshowVideoListBycondition 根据搜索条件获取搜索列表
+func GetMicroRoadshowVideoListBycondition(condition string, pars []interface{}, startSize, pageSize int) (list []*MicroRoadshowVideo, err error) {
+	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE  1 =1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `  LIMIT ?,? `
+	_, err = orm.NewOrm().Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}
+
 // GetMicroRoadshowVideoList 获取已经发布的微路演视频
 func GetMicroRoadshowVideoList() (list []*MicroRoadshowVideo, err error) {
 	sql := `SELECT * FROM cygx_micro_roadshow_video WHERE  publish_status = 1`

+ 41 - 0
models/resource_data.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
 )
 
@@ -16,6 +17,46 @@ type CygxResourceData struct {
 	Abstract    string    `description:"摘要"`
 }
 
+type CygxResourceDataResp struct {
+	Id              int                        `orm:"column(id);pk"`
+	SourceId        int                        `description:"资源ID"`
+	Source          string                     `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	PublishDate     string                     `description:"发布时间"`
+	Article         *HomeArticle               `description:"文章"`
+	Newchart        *HomeChartListResp         `description:"图表"`
+	Roadshow        *MicroRoadShowPageList     `description:"微路演"`
+	Activity        *ActivityDetail            `description:"活动"`
+	Activityvideo   *MicroRoadShowPageList     `description:"活动视频"`
+	Activityvoice   *MicroRoadShowPageList     `description:"活动音频"`
+	Activityspecial *CygxActivitySpecialDetail `description:"专项调研活动"`
+}
+
+//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+type HomeResourceDataListResp struct {
+	Paging *paging.PagingItem
+	List   []*CygxResourceDataResp `description:"列表"`
+}
+
+//列表
+func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxResourceData, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT	 *   FROM cygx_resource_data  WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` ORDER BY publish_date  DESC ,  id  DESC   LIMIT ?,? `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+//获取用户报名成功数量
+func GetResourceDataCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := `SELECT COUNT(1) AS count FROM cygx_resource_data    WHERE 1= 1 ` + condition
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
 //添加
 func AddCygxResourceData(item *CygxResourceData) (lastId int64, err error) {
 	o := orm.NewOrm()

+ 9 - 0
routers/commentsRouter.go

@@ -691,6 +691,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:HomeController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:HomeController"],
+        beego.ControllerComments{
+            Method: "NewList",
+            Router: `/new`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:MicroRoadShowController"],
         beego.ControllerComments{
             Method: "Collect",

+ 47 - 39
services/activity.go

@@ -1490,60 +1490,68 @@ func ActivityButtonShow(item *models.ActivityDetail) (articleDetail *models.Acti
 		articleDetail.IsShowDetails = true
 		return
 	}
+
+	articleDetail.Expert, _ = GetReportContentTextSub(item.Expert)
+
+	//专家电话会 1
+	if articleDetail.ActivityTypeId == 1 && articleDetail.IsLimitPeople == 0 && (articleDetail.ActiveState == "1" || articleDetail.ActiveState == "2") {
+		articleDetail.IsShowHelpSsk = true
+	}
 	//新的是否展示规则
 	if articleDetail.IsCanAppointmentMinutes == 1 {
 		articleDetail.IsShowAppointment = true
 	} else {
 		articleDetail.IsShowAppointment = false
 	}
-
-	//专家电话会 1
-	if articleDetail.ActivityTypeId == 1 {
-		articleDetail.IsShowOutboundCall = true
-		//if articleDetail.LimitPeopleNum == 0 {
-		//	articleDetail.IsShowMeetingReminder = true
-		//	articleDetail.IsShowHelpSsk = true
-		//}
-		articleDetail.IsShowMeetingReminder = true
-		articleDetail.IsShowHelpSsk = true
-	}
-
-	//分析师电话会 2
-	if articleDetail.ActivityTypeId == 2 {
-		articleDetail.IsShowOutboundCall = true
-		if articleDetail.LimitPeopleNum == 0 {
+	if articleDetail.ActiveState == "1" {
+		//专家电话会 1
+		if articleDetail.ActivityTypeId == 1 {
+			articleDetail.IsShowOutboundCall = true
+			//if articleDetail.LimitPeopleNum == 0 {
+			//	articleDetail.IsShowMeetingReminder = true
+			//	articleDetail.IsShowHelpSsk = true
+			//}
 			articleDetail.IsShowMeetingReminder = true
+			articleDetail.IsShowHelpSsk = true
 		}
-	}
 
-	//公司调研电话会 3
-	if articleDetail.ActivityTypeId == 3 {
-		if articleDetail.LimitPeopleNum == 0 {
-			articleDetail.IsShowMeetingReminder = true
+		//分析师电话会 2
+		if articleDetail.ActivityTypeId == 2 {
 			articleDetail.IsShowOutboundCall = true
-		} else {
-			articleDetail.IsShowSignup = true
+			if articleDetail.LimitPeopleNum == 0 {
+				articleDetail.IsShowMeetingReminder = true
+			}
 		}
-	}
 
-	//公司线下调研 4
-	if articleDetail.ActivityTypeId == 4 {
-		articleDetail.IsShowSignup = true
-	}
+		//公司调研电话会 3
+		if articleDetail.ActivityTypeId == 3 {
+			if articleDetail.LimitPeopleNum == 0 {
+				articleDetail.IsShowMeetingReminder = true
+				articleDetail.IsShowOutboundCall = true
+			} else {
+				articleDetail.IsShowSignup = true
+			}
+		}
 
-	//专家线下沙龙 5
-	if articleDetail.ActivityTypeId == 5 {
-		articleDetail.IsShowSignup = true
-	}
+		//公司线下调研 4
+		if articleDetail.ActivityTypeId == 4 {
+			articleDetail.IsShowSignup = true
+		}
 
-	//分析师线下沙龙 6
-	if articleDetail.ActivityTypeId == 6 {
-		articleDetail.IsShowSignup = true
-	}
+		//专家线下沙龙 5
+		if articleDetail.ActivityTypeId == 5 {
+			articleDetail.IsShowSignup = true
+		}
+
+		//分析师线下沙龙 6
+		if articleDetail.ActivityTypeId == 6 {
+			articleDetail.IsShowSignup = true
+		}
 
-	//分析师电话会(C类) 7
-	if articleDetail.ActivityTypeId == 7 {
-		articleDetail.IsShowSignup = true
+		//分析师电话会(C类) 7
+		if articleDetail.ActivityTypeId == 7 {
+			articleDetail.IsShowSignup = true
+		}
 	}
 	articleDetail.SourceType = 1
 	activityTimeText := articleDetail.ActivityTimeText

+ 252 - 0
services/article.go

@@ -11,6 +11,8 @@ import (
 	"hongze/hongze_cygx/utils"
 	"html"
 	"net/url"
+	"regexp"
+	"sort"
 	"strconv"
 	"strings"
 	"time"
@@ -1661,3 +1663,253 @@ func GetArticNewLabelWhithActivity3Month() (labelMap map[int]bool, err error) {
 	}
 	return
 }
+
+//HandleArticleCategoryImg 预处理文章的封面图片
+func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeArticle, err error) {
+	//研选的五张图片
+	detailResearch, e := models.GetConfigByCode("category_research_img_url")
+	if e != nil {
+		err = errors.New("获取研选的五张图片失败" + e.Error())
+		return
+	}
+	researchList := strings.Split(detailResearch.ConfigValue, "{|}")
+	//对应分类的所图片
+	detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
+	if err != nil {
+		err = errors.New("获取对应分类的所图片失败" + err.Error())
+		return
+	}
+	categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
+	mapCategoryUrl := make(map[string]string)
+	var categoryId string
+	var imgUrlChart string
+	for _, v := range categoryUrlList {
+		vslice := strings.Split(v, "_")
+		categoryId = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapCategoryUrl[categoryId] = imgUrlChart
+	}
+
+	mapChartPerssion := make(map[string]string)
+	reportMappingList, err := models.GetReportMappingStrategyAll()
+	if err != nil {
+		err = errors.New("GetReportMappingStrategyAll err" + err.Error())
+		return
+	}
+
+	for _, v := range reportMappingList {
+		mapChartPerssion[strconv.Itoa(v.CategoryId)] = v.ChartPermissionName
+	}
+	for k, v := range list {
+		list[k].Abstract, _ = GetReportContentTextSub(v.Abstract)
+		item := list[k]
+		//如果文章一开始的内容是图片,优先展示第一张图片
+		if list[k].Annotation == "" {
+			imgurl, _ := FixArticleImgUrl(html.UnescapeString(list[k].Body))
+			if imgurl != "" {
+				list[k].BodyHtml = imgurl
+			}
+		}
+
+		//newBody, _ := GetReportContentTextSubByarticle(item.Body, item.Annotation, item.ArticleId)
+		list[k].Annotation = ArticleAnnotation(item)
+		list[k].Body = ""
+		list[k].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式
+		if item.Pv > 999 {
+			list[k].Pv = 999
+		}
+
+		list[k].ChartPermissionName = mapChartPerssion[v.CategoryId]
+		//如果是研选系列的任意取五张图片的中的一张
+		if v.CategoryId == "0" || v.ArticleId > utils.SummaryArticleId {
+			knum := v.ArticleId % 5
+			list[k].ImgUrlPc = researchList[knum]
+		} else {
+			list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
+		}
+		list[k].ArticleResponse = 4 //  默认展示核心观点
+		//ArticleResponse     int                  `description:"报告类型 0:啥也不是,1研选报告,2:研选纪要,3:研选沙龙,4;核心观点"`
+		if list[k].ArticleId >= utils.SummaryArticleId {
+			list[k].HttpUrl = utils.StrategyPlatform + strconv.Itoa(v.ArticleId)
+			list[k].IsNeedJump = true
+			list[k].ArticleResponse = 1
+			//if v.IsReport == 1 {
+			//	list[k].ArticleResponse = 1
+			//} else if v.ArticleTypeName == "纪要" {
+			//	list[k].ArticleResponse = 2
+			//} else if v.ArticleTypeName == "观点" {
+			//	list[k].ArticleResponse = 3
+			//} else if v.ArticleTypeName == "沙龙" {
+			//	list[k].ArticleResponse = 3
+			//} else if v.ArticleTypeName == "路演精华" {
+			//	list[k].ArticleResponse = 1
+			//}
+		}
+		list[k].Source = 1
+		//添加行业默认图片
+		if v.ImgUrlPc == "" {
+			if v.ChartPermissionName == utils.YI_YAO_NAME {
+				list[k].ImgUrlPc = utils.YI_YAO_OTHER_IMG
+			} else if v.ChartPermissionName == utils.XIAO_FEI_NAME {
+				list[k].ImgUrlPc = utils.XIAO_FEI_OTHER_IMG
+			} else if v.ChartPermissionName == utils.KE_JI_NAME {
+				list[k].ImgUrlPc = utils.KE_JI_OTHER_IMG
+			} else if v.ChartPermissionName == utils.ZHI_ZAO_NAME {
+				list[k].ImgUrlPc = utils.ZHI_ZAO_OTHER_IMG
+			}
+		}
+
+	}
+
+	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 {
+			err = errors.New("GetIndustrialListByarticleId" + 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)
+		}
+	}
+
+	if len(list) == 0 {
+		list = make([]*models.HomeArticle, 0)
+	}
+	items = list
+	return
+}
+
+//处理核心观点的展示规则
+func ArticleAnnotation(item *models.HomeArticle) (annotation string) {
+	if item.ArticleId >= utils.SummaryArticleId {
+		item.Annotation = YxArticleAnnotation(item)
+	}
+	if item.Annotation != "" {
+		annotation = strings.Replace(item.Annotation, "<br>", "", -1)
+	} else {
+		return
+	}
+
+	bodyText, _ := GetReportContentTextSubNew(annotation)
+	if bodyText == "" {
+		return
+	}
+	if annotation != "" {
+		annotation = html.UnescapeString(annotation)
+		doc, _ := goquery.NewDocumentFromReader(strings.NewReader(annotation))
+		docText := doc.Text()
+		mapDoc := make(map[int]string)
+		var mapSort []int
+		p := doc.Find("p")
+		p.Each(func(tk int, pd *goquery.Selection) {
+			pdText := pd.Text()
+			if pdText != "" {
+				textLen := strings.Index(docText, pdText)
+				mapDoc[(strings.Index(docText, pdText))] = pdText
+				mapSort = append(mapSort, textLen)
+			}
+		})
+		li := doc.Find("li")
+		li.Each(func(tk int, li *goquery.Selection) {
+			liText := li.Text()
+			if liText != "" {
+				textLen := strings.Index(docText, liText)
+				mapDoc[(strings.Index(docText, liText))] = strconv.Itoa(tk+1) + "." + liText
+				mapSort = append(mapSort, textLen)
+			}
+		})
+		if len(mapSort) == 0 {
+			return
+		} else {
+			//排序
+			sort.Ints(mapSort)
+			var annotationHtml string
+			for _, vSort := range mapSort {
+				for k, v := range mapDoc {
+					if k == vSort && v != "" {
+						annotationHtml += v + "<br>"
+					}
+				}
+			}
+			annotationHtml = strings.TrimRight(annotationHtml, "<br>")
+			annotationHtml = "<p>" + annotationHtml + "</p>"
+			annotation = annotationHtml
+		}
+	}
+	return
+}
+
+//解析研选内容中的核心观点
+func YxArticleAnnotation(article *models.HomeArticle) (annotation string) {
+	//如果不规范,就获取内容主体
+	if strings.Count(article.Body, "<hr") == 0 {
+		//如果内容不规范而且,还有图片,就把核心观点置空
+		if article.BodyHtml != "" {
+			return
+		}
+		annotation, _ = GetReportContentTextSub(article.Body)
+		return
+	}
+	body := strings.ReplaceAll(article.Body, "<strong>", "")
+	body = strings.ReplaceAll(body, "</strong>", "")
+	body = strings.ReplaceAll(body, "</ol>", "</div>")
+	body = strings.ReplaceAll(body, "<ol>", "<div>")
+	body = strings.ReplaceAll(body, "</li>", "</p>")
+	body = strings.ReplaceAll(body, "<li>", "<p>")
+	re, _ := regexp.Compile("<strong.*?>")
+	body = re.ReplaceAllString(body, "")
+	reLi, _ := regexp.Compile("<li.*?>")
+	body = reLi.ReplaceAllString(body, "")
+	var plus int
+	coreIndex := strings.Index(body, "核心观点:")
+	plus = 15
+	if coreIndex == -1 {
+		coreIndex = strings.Index(body, "核心观点:")
+		plus = 13
+	}
+	if coreIndex == -1 {
+		coreIndex = strings.Index(body, "核心观点")
+		plus = 12
+	}
+	if coreIndex == -1 {
+		coreIndex = strings.Index(body, "核心结论:")
+		plus = 15
+	}
+	if coreIndex == -1 {
+		coreIndex = strings.Index(body, "核心结论:")
+		plus = 13
+	}
+	if coreIndex == -1 {
+		coreIndex = strings.Index(body, "核心结论")
+		plus = 12
+	}
+	endIndex := strings.Index(body, "<hr")
+	if coreIndex != -1 && endIndex != -1 {
+		body = body[coreIndex+plus : endIndex]
+	}
+	annotation = body
+	return
+}

+ 326 - 0
services/resource_data.go

@@ -1,13 +1,339 @@
 package services
 
 import (
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
+func GetResourceDataList(condition string, pars []interface{}, startSize, pageSize int, user *models.WxUserItem) (items []*models.CygxResourceDataResp, err error) {
+
+	uid := user.UserId
+	list, e := models.GetResourceDataList(condition, pars, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetResourceDataList, Err: " + e.Error())
+		return
+	}
+	mapItems := make(map[string]*models.CygxResourceDataResp)
+	for _, v := range list {
+		//预处理文章
+		item := new(models.CygxResourceDataResp)
+		item.Id = v.Id
+		item.SourceId = v.SourceId
+		item.Source = v.Source
+		item.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+		mapItems[fmt.Sprint(v.Source, v.SourceId)] = item
+	}
+
+	var articleIds []int
+	var newchartIds []int
+	var roadshowIds []string
+	var activityIds []int
+	var activityvideoIds []string
+	var activityvoiceIds []string
+	var activityspecialIds []int
+	//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+	for _, v := range list {
+		if v.Source == "article" {
+			articleIds = append(articleIds, v.SourceId)
+		} else if v.Source == "newchart" {
+			newchartIds = append(newchartIds, v.SourceId)
+		} else if v.Source == "roadshow" {
+			roadshowIds = append(roadshowIds, strconv.Itoa(v.SourceId))
+		} else if v.Source == "activity" {
+			activityIds = append(activityIds, v.SourceId)
+		} else if v.Source == "activityvideo" {
+			activityvideoIds = append(activityvideoIds, strconv.Itoa(v.SourceId))
+		} else if v.Source == "activityvoice" {
+			activityvoiceIds = append(activityvoiceIds, strconv.Itoa(v.SourceId))
+		} else if v.Source == "activityspecial" {
+			activityspecialIds = append(activityspecialIds, v.SourceId)
+		}
+	}
+
+	//处理文章
+	if len(articleIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.article_id IN (` + utils.GetOrmInReplace(len(articleIds)) + `)`
+		pars = append(pars, articleIds)
+
+		listArticle, e := models.GetHomeList(condition, pars, 0, len(articleIds))
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+
+		listArticle, e = HandleArticleCategoryImg(listArticle)
+		if e != nil {
+			err = errors.New("HandleArticleCategoryImg, Err: " + e.Error())
+			return
+		}
+		for _, v := range listArticle {
+			v.Body = ""
+			mapItems[fmt.Sprint("article", v.ArticleId)].Article = v
+		}
+	}
+
+	detail, e := models.GetConfigByCode("city_img_url")
+	if e != nil {
+		err = errors.New("GetResourceDataList, Err: " + e.Error())
+		return
+	}
+	detailChart, e := models.GetConfigByCode("chart_img_url")
+	if e != nil {
+		err = errors.New("GetResourceDataList, Err: " + e.Error())
+		return
+	}
+	addressList := strings.Split(detail.ConfigValue, "{|}")
+	mapAddress := make(map[string]string)
+	chartList := strings.Split(detailChart.ConfigValue, "{|}")
+	mapChart := make(map[string]string)
+	var cityName string
+	var chartName string
+	var imgUrl string
+	var imgUrlChart string
+	for _, v := range addressList {
+		vslice := strings.Split(v, "_")
+		cityName = vslice[0]
+		imgUrl = vslice[len(vslice)-1]
+		mapAddress[cityName] = imgUrl
+	}
+	for _, v := range chartList {
+		vslice := strings.Split(v, "_")
+		chartName = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapChart[chartName] = imgUrlChart
+	}
+	var imgUrlResp string
+
+	//处理活动
+	if len(activityIds) > 0 {
+		for _, vss := range activityIds {
+			imgUrlResp += strconv.Itoa(vss) + ","
+		}
+		pars = make([]interface{}, 0)
+		condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `)`
+		pars = append(pars, activityIds)
+		activityList, e := models.GetActivityListNew(condition, pars, uid, 0, len(activityIds), 0, 0, "")
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+		var activityListRersp []*models.ActivityDetail
+		for _, v := range activityList {
+			activityListRersp = append(activityListRersp, ActivityButtonShow(v))
+		}
+		for _, v := range activityListRersp {
+			if v == nil {
+				continue
+			}
+			if v.ActivityType == 0 {
+				if mapAddress[v.City] != "" {
+					imgUrlResp = mapAddress[v.City]
+				} else {
+					imgUrlResp = mapAddress["其它"]
+				}
+			} else {
+				if mapChart[v.ChartPermissionName] != "" {
+					imgUrlResp = mapChart[v.ChartPermissionName]
+				}
+			}
+			mapItems[fmt.Sprint("activity", v.ActivityId)].Activity = v
+		}
+	}
+
+	//处理图表
+	if len(newchartIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND a.chart_id IN (` + utils.GetOrmInReplace(len(newchartIds)) + `)`
+		pars = append(pars, newchartIds)
+		chartDateList, e := models.GetChartListCollectionNew(condition, pars, uid, 0, len(newchartIds))
+		if e != nil {
+			err = errors.New("GetResourceDataList, Err: " + e.Error())
+			return
+		}
+		for _, v := range chartDateList {
+			mapItems[fmt.Sprint("newchart", v.ChartId)].Newchart = v
+		}
+	}
+
+	//处理专项调研
+	if len(activityspecialIds) > 0 {
+		pars = make([]interface{}, 0)
+		condition = ` AND art.activity_id IN (` + utils.GetOrmInReplace(len(activityspecialIds)) + `)`
+		pars = append(pars, activityspecialIds)
+		activitySpeciallist, e := models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, 0, len(activityspecialIds))
+		if e != nil {
+			err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+			return
+		}
+		UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
+		if e != nil {
+			err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+			return
+		}
+		for _, v := range activitySpeciallist {
+			if mapChart[v.ChartPermissionName] != "" {
+				imgUrlResp = mapChart[v.ChartPermissionName]
+			}
+			if _, ok := UserMap[v.ActivityId]; ok {
+				v.IsTrip = 1
+			}
+			if v.Days == 0 {
+				v.TripStatus = 1
+				v.TripImgLink = v.TripImgLink
+			} else {
+				v.TripStatus = 2
+				v.TripImgLink = v.TripImgLinkFix
+			}
+			resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
+			resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
+			if resultTimeStart.After(time.Now()) {
+				v.ActiveState = 1
+			} else if time.Now().After(resultTimeEnd) {
+				v.ActiveState = 3
+			} else {
+				v.ActiveState = 2
+			}
+			v.ImgUrl = imgUrlResp
+			mapItems[fmt.Sprint("activityspecial", v.ActivityId)].Activityspecial = v
+
+		}
+	}
+
+	if len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds) > 0 {
+
+		audioIdstr := strings.Join(activityvoiceIds, ",")
+		ideoIdsStr := strings.Join(roadshowIds, ",")
+		activityVideoIdsStr := strings.Join(activityvideoIds, ",")
+
+		list, _, e := GetMicroRoadShowMycollect(len(roadshowIds)+len(activityvideoIds)+len(activityvoiceIds), 0, audioIdstr, ideoIdsStr, activityVideoIdsStr)
+		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 {
+			err = errors.New("GetUserRaiPermissionInfo, Err: " + e.Error())
+			return
+		}
+
+		// 获取默认图配置
+		audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
+		if e != nil {
+			err = errors.New("GetMicroRoadShowDefaultImgConfig, Err: " + e.Error())
+			return
+		}
+		//Source      string    `description:"资源类型 报告 :article 、图表 :newchart、微路演 :roadshow、活动 :activity、活动视频:activityvideo、活动音频:activityvoice、专项调研活动:activityspecial"`
+		for i := range list {
+			// 权限
+			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 list[i].ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, list[i].ChartPermissionName) {
+					au.HasPermission = 2
+				}
+			}
+			// 无权限的弹框提示
+			if au.HasPermission != 1 {
+				if au.OperationMode == UserPermissionOperationModeCall {
+					if list[i].Type == 1 {
+						au.PopupMsg = UserPermissionPopupMsgCallActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgCallMicroVideo
+					}
+				} else {
+					if list[i].Type == 1 {
+						au.PopupMsg = UserPermissionPopupMsgApplyActivity
+					} else {
+						au.PopupMsg = UserPermissionPopupMsgApplyMicroVideo
+					}
+				}
+			}
+			list[i].AuthInfo = au
+			list[i].PublishTime = utils.StrTimeToTime(list[i].PublishTime).Format(utils.FormatDate)
+			// 默认图
+			if list[i].BackgroundImg == "" {
+				if list[i].Type == 1 {
+					list[i].BackgroundImg = audioMap[list[i].ChartPermissionId]
+				} else {
+					list[i].BackgroundImg = videoMap[list[i].ChartPermissionId]
+				}
+			}
+			// 分享图
+			if list[i].ShareImg == "" {
+				if list[i].Type == 1 {
+					list[i].ShareImg = audioShareMap[list[i].ChartPermissionId]
+				} else {
+					list[i].ShareImg = videoShareMap[list[i].ChartPermissionId]
+				}
+			}
+		}
+		//Type                int    `description:"类型: 1-音频; 2-活动视频; 3-产业视频"`
+		for _, item := range list {
+			if item.Type == 1 {
+				mapItems[fmt.Sprint("activityvoice", item.Id)].Activityvoice = item
+			} else if item.Type == 2 {
+				mapItems[fmt.Sprint("activityvideo", item.Id)].Activityvideo = item
+			} else if item.Type == 3 {
+				mapItems[fmt.Sprint("roadshow", item.Id)].Roadshow = item
+			}
+		}
+	}
+
+	for _, vList := range list {
+		for _, v := range mapItems {
+			if v.SourceId == vList.SourceId {
+				items = append(items, v)
+			}
+		}
+	}
+	return
+}
+
 //同步活动到最新数据表
 func UpdateResourceData(sourceId int, source, doType, publishDate string) (err error) {
 	defer func() {

+ 4 - 0
utils/constants.go

@@ -82,12 +82,16 @@ const (
 	CE_LUE_NAME                      string = "策略"
 	CE_LUE_ID                        int    = 23
 	YI_YAO_NAME                      string = "医药"
+	YI_YAO_OTHER_IMG                 string = "https://hzstatic.hzinsights.com/static/temp/20221118202211/20221118/qzPm61bVf40Je7c5iL1s4CbrDcpv.png" //医药其它图片
 	YI_YAO_ID                        int    = 22
 	XIAO_FEI_NAME                    string = "消费"
+	XIAO_FEI_OTHER_IMG               string = "https://hzstatic.hzinsights.com/static/temp/20221118202211/20221118/BxOfzECjhqjipJCWwAa9Ep99OTMA.png" //消费其它图片
 	XIAO_FEI_ID                      int    = 21
 	KE_JI_NAME                       string = "科技"
+	KE_JI_OTHER_IMG                  string = "https://hzstatic.hzinsights.com/static/temp/20221118202211/20221118/vr7eTXIrl6YjJ80DDTVbdnFRQ9mJ.png" //科技其它图片
 	KE_JI_ID                         int    = 20
 	ZHI_ZAO_NAME                     string = "智造"
+	ZHI_ZAO_OTHER_IMG                string = "https://hzstatic.hzinsights.com/static/temp/20221118202211/20221118/SSaQcWzMk5slN3FkCwZifK3qcAWd.png" //智造其它图片
 	ZHI_ZAO_ID                       int    = 19
 	LINK_WX_EXPLAIN                         = "https://mp.weixin.qq.com/s?__biz=Mzg2OTYzODk0Nw==&mid=2247483662&idx=1&sn=3752df99025189b9d77fe658bfc0edbd&chksm=ce98b742f9ef3e54b49986e647dd951a3aad74f323174b252174e0938c264c0562c8ec455106#rd" //用户阅读数据
 	ACTIVITY_SPECIAL_EXPLAIN                = "预报名专项调研行程持续更新中,满10家即开团,欢迎点击感兴趣预报名"                                                                                                                                                                //用户阅读数据