Ver código fonte

Merge branch 'master' of http://8.136.199.33:3000/cxzhang/hongze_clpt into cygx_12.7

xingzai 1 ano atrás
pai
commit
106bbdf314

+ 1 - 235
controllers/home.go

@@ -296,210 +296,8 @@ func (this *MobileHomeController) NewList() {
 	var err error
 	resp := new(models.HomeResourceDataListNewResp)
 
-	//var articleTypes, activityTypes, industries, subjectNames string
-	//articleTypeCondSlice := make([]string, 0)
-	//activityTypesCondSlice := make([]string, 0)
-	//industriesCondSlice := make([]string, 0)
-	//subjectNamesSlice := make([]string, 0)
-	//articleTypeSlice := make([]string, 0)
-	//if tagIds != "" {
-	//	tags := strings.Split(tagIds, ",")
-	//	for _, tagIdStr := range tags {
-	//		tagId, err := strconv.Atoi(tagIdStr)
-	//		if err != nil {
-	//			br.Msg = "转换失败"
-	//			br.ErrMsg = "tagid转换失败,Err:" + err.Error()
-	//			return
-	//		}
-	//		tagInfo, err := models.GetCygxTagByTagId(tagId)
-	//		if err != nil && err.Error() != utils.ErrNoRow() {
-	//			br.Msg = "获取失败"
-	//			br.ErrMsg = "GetCygxTagByTagId,Err:" + err.Error()
-	//			return
-	//		}
-	//		// 只有AB或CD的情况
-	//		if (tagInfo.ActivityTypes == "" && tagInfo.ArticleTypes == "") || (tagInfo.Industries == "" && tagInfo.SubjectNames == "") {
-	//			if tagInfo.ActivityTypes != "" {
-	//				activityTypes += tagInfo.ActivityTypes + ","
-	//			}
-	//			if tagInfo.ArticleTypes != "" {
-	//				articleTypes += tagInfo.ArticleTypes + ","
-	//			}
-	//			if tagInfo.Industries != "" {
-	//				industries += tagInfo.Industries + ","
-	//			}
-	//			if tagInfo.SubjectNames != "" {
-	//				subjectNames += tagInfo.SubjectNames + ","
-	//			}
-	//		} else {
-	//			// ABCD都有的情况
-	//			// 每一个tag都单独处理
-	//			var articleType, activityType, industry, subjectName string
-	//
-	//			if tagInfo.ActivityTypes != "" {
-	//				activityType = tagInfo.ActivityTypes
-	//			}
-	//			if tagInfo.ArticleTypes != "" {
-	//				articleType = tagInfo.ArticleTypes
-	//			}
-	//			if tagInfo.Industries != "" {
-	//				industry = tagInfo.Industries
-	//			}
-	//			if tagInfo.SubjectNames != "" {
-	//				subjectName = tagInfo.SubjectNames
-	//			}
-	//			articleTypeCond := ``
-	//			var articleTypeStr string
-	//			if articleType != "" {
-	//				articleTypeSlice := strings.Split(articleType, ",")
-	//				newArticleTypeSlice := make([]string, 0)
-	//				for _, s := range articleTypeSlice {
-	//					newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
-	//				}
-	//				articleTypeStr = strings.Join(newArticleTypeSlice, ",")
-	//				articleTypeStr = strings.TrimRight(articleTypeStr, ",")
-	//				articleTypeCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
-	//			}
-	//			activityTypesCond := ``
-	//			if activityType != "" {
-	//				activityTypeSlice := strings.Split(activityType, ",")
-	//				newActivityTypeSlice := make([]string, 0)
-	//				for _, s := range activityTypeSlice {
-	//					newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
-	//				}
-	//				activityTypeStr := strings.Join(newActivityTypeSlice, ",")
-	//				activityTypeStr = strings.TrimRight(activityTypeStr, ",")
-	//				activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
-	//			}
-	//			industriesCond := ``
-	//			var industryStr string
-	//			if industry != "" {
-	//				industrieSlice := strings.Split(industry, ",")
-	//				newIndustrieSlice := make([]string, 0)
-	//				for _, s := range industrieSlice {
-	//					newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
-	//				}
-	//				industryStr = strings.Join(newIndustrieSlice, ",")
-	//				industryStr = strings.TrimRight(industryStr, ",")
-	//				industriesCond += ` AND im.industry_name In (` + industryStr + `) `
-	//			}
-	//			subjectNamesCond := ``
-	//			var subjectNameStr string
-	//			if subjectName != "" {
-	//				subjectNameSlice := strings.Split(subjectName, ",")
-	//				newSubjectNameSlice := make([]string, 0)
-	//				for _, s := range subjectNameSlice {
-	//					newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
-	//				}
-	//				subjectNameStr = strings.Join(newSubjectNameSlice, ",")
-	//				subjectNameStr = strings.TrimRight(subjectNameStr, ",")
-	//				subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
-	//			}
-	//			articleTypeCondSlice = append(articleTypeCondSlice, articleTypeCond)
-	//			activityTypesCondSlice = append(activityTypesCondSlice, activityTypesCond)
-	//			industriesCondSlice = append(industriesCondSlice, industryStr)
-	//			subjectNamesSlice = append(subjectNamesSlice, subjectNameStr)
-	//			articleTypeSlice = append(articleTypeSlice, articleType)
-	//		}
-	//
-	//	}
-	//}
-	//
-	//// 先拿abdc都有的tag取合集的ids。。。
-	//soloTagArticleIds, soloTagActivityIds, soloMmIds, err := models.GetCygxCygxArticleListByConditionSoloTag(articleTypeCondSlice, activityTypesCondSlice, industriesCondSlice, subjectNamesSlice, articleTypeSlice)
-	//if err != nil && err.Error() != utils.ErrNoRow() {
-	//	br.Msg = "获取失败"
-	//	br.ErrMsg = "获取活动权限数据失败,Err:" + err.Error()
-	//	return
-	//}
-	//
-	//articleTypes = strings.TrimRight(articleTypes, ",")
-	//activityTypes = strings.TrimRight(activityTypes, ",")
-	//industries = strings.TrimRight(industries, ",")
-	//subjectNames = strings.TrimRight(subjectNames, ",")
-	//
-	//articleTypesCond := ``
-	//var articleTypeStr string
-	//if articleTypes != "" {
-	//	articleTypeSlice := strings.Split(articleTypes, ",")
-	//	newArticleTypeSlice := make([]string, 0)
-	//	for _, s := range articleTypeSlice {
-	//		newArticleTypeSlice = append(newArticleTypeSlice, "'"+s+"'")
-	//	}
-	//	articleTypeStr = strings.Join(newArticleTypeSlice, ",")
-	//	articleTypeStr = strings.TrimRight(articleTypeStr, ",")
-	//	articleTypesCond += ` AND (art.sub_category_name In (` + articleTypeStr + `) OR (art.article_type_name In (` + articleTypeStr + `) AND art.article_type_name <> '路演精华' AND art.article_type_id <> 0 ) ) `
-	//}
-	//activityTypesCond := ``
-	//if activityTypes != "" {
-	//	activityTypeSlice := strings.Split(activityTypes, ",")
-	//	newActivityTypeSlice := make([]string, 0)
-	//	for _, s := range activityTypeSlice {
-	//		newActivityTypeSlice = append(newActivityTypeSlice, "'"+s+"'")
-	//	}
-	//	activityTypeStr := strings.Join(newActivityTypeSlice, ",")
-	//	activityTypeStr = strings.TrimRight(activityTypeStr, ",")
-	//	activityTypesCond += ` AND act.activity_type_name In (` + activityTypeStr + `) `
-	//}
-	//industriesCond := ``
-	//var industryStr string
-	//if industries != "" {
-	//	industrieSlice := strings.Split(industries, ",")
-	//	newIndustrieSlice := make([]string, 0)
-	//	for _, s := range industrieSlice {
-	//		newIndustrieSlice = append(newIndustrieSlice, "'"+s+"'")
-	//	}
-	//	industryStr = strings.Join(newIndustrieSlice, ",")
-	//	industryStr = strings.TrimRight(industryStr, ",")
-	//	industriesCond += ` AND im.industry_name In (` + industryStr + `) `
-	//}
-	//subjectNamesCond := ``
-	//var subjectNameStr string
-	//if subjectNames != "" {
-	//	subjectNameSlice := strings.Split(subjectNames, ",")
-	//	newSubjectNameSlice := make([]string, 0)
-	//	for _, s := range subjectNameSlice {
-	//		newSubjectNameSlice = append(newSubjectNameSlice, "'"+s+"'")
-	//	}
-	//	subjectNameStr = strings.Join(newSubjectNameSlice, ",")
-	//	subjectNameStr = strings.TrimRight(subjectNameStr, ",")
-	//	subjectNamesCond += ` AND cis.subject_name In (` + subjectNameStr + `) `
-	//}
-	//
-	//var tagArticleIds, tagActivityIds, mmIds string
-	//if articleTypesCond != "" || activityTypesCond != "" || industryStr != "" || subjectNameStr != "" {
-	//	tagArticleIds, tagActivityIds, mmIds, err = models.GetCygxCygxArticleListByCondition(articleTypesCond, activityTypesCond, industryStr, subjectNameStr, articleTypeStr)
-	//	if err != nil && err.Error() != utils.ErrNoRow() {
-	//		br.Msg = "获取失败"
-	//		br.ErrMsg = "获取单个标签ids失败,Err:" + err.Error()
-	//		return
-	//	}
-	//}
-	//
-	//if soloTagArticleIds != "" {
-	//	if tagArticleIds != "" {
-	//		tagArticleIds += "," + soloTagArticleIds
-	//	} else {
-	//		tagArticleIds = soloTagArticleIds
-	//	}
-	//}
-	//if soloTagActivityIds != "" {
-	//	if tagActivityIds != "" {
-	//		tagActivityIds += "," + soloTagActivityIds
-	//	} else {
-	//		tagActivityIds = soloTagActivityIds
-	//	}
-	//}
-	//if soloMmIds != "" {
-	//	if mmIds != "" {
-	//		mmIds += "," + soloMmIds
-	//	} else {
-	//		mmIds = soloMmIds
-	//	}
-	//}
-
 	if tagIds != "" {
-		conditionTagIdsInit, err := services.GetConditionInitByTagIds(tagIds)
+		conditionTagIdsInit, err := services.GetConditionInitByTagIds(tagIds, chartPermissionId)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "获取活动权限数据失败,GetConditionInitByTagIds Err:" + err.Error()
@@ -565,38 +363,6 @@ func (this *MobileHomeController) NewList() {
 		}
 		lenActivityspecialIds := len(activityspecialIds)
 
-		//if tagIds != "" {
-		//	if tagArticleIds != "" {
-		//		condition = ` AND ((source = 'article' AND source_id IN (` + tagArticleIds + `) ) `
-		//		if mmIds != "" {
-		//			condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
-		//		}
-		//		if tagActivityIds != "" && lenActivityIds > 0 {
-		//			condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) )) `
-		//			pars = append(pars, activityIds)
-		//		} else {
-		//			// 无可见活动
-		//			condition += ` OR (source = 'activity' AND source_id IN (0))) `
-		//		}
-		//	} else if tagActivityIds != "" {
-		//		condition = ` AND ((source = 'article' AND source_id IN (0))  `
-		//		if mmIds != "" {
-		//			condition += ` OR ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
-		//		}
-		//		if tagActivityIds != "" && lenActivityIds > 0 {
-		//			condition += ` OR (source = 'activity' AND source_id IN (` + tagActivityIds + `) AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `))) `
-		//			pars = append(pars, activityIds)
-		//		} else {
-		//			// 无可见活动
-		//			condition += ` OR (source = 'activity' AND source_id IN (0))) `
-		//		}
-		//	} else if mmIds != "" {
-		//		condition = ` AND ( source = 'meetingreviewchapt' AND source_id IN (` + mmIds + `) )   `
-		//	} else {
-		//		condition += ` AND ((source = 'article' AND source_id IN (0)) OR (source = 'activity' AND source_id IN (0))) `
-		//	}
-		//}
-
 		//if lenActivityIds > 0 && tagIds == "" {
 		if lenActivityIds > 0 {
 			condition += ` OR ( source = 'activity' AND source_id IN (` + utils.GetOrmInReplace(lenActivityIds) + `) ` + conditionInit + ` )    `

+ 12 - 8
controllers/report.go

@@ -830,6 +830,7 @@ func (this *MobileReportController) SearchReport() {
 	keyWord := this.GetString("KeyWord")
 	isAll, _ := this.GetBool("IsAll")
 	var condition string
+	var conditionYxSpecial string
 	var pars []interface{}
 	//var conditionSql string
 	var total int
@@ -940,13 +941,16 @@ func (this *MobileReportController) SearchReport() {
 		}
 	} else {
 
-		//condition = `AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
-		if articleType == 1 {
-			condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id NOT IN (` + articleTypeIds + `)  `
-			total, err = models.GetReoprtSearchCountHz(condition)
-		} else {
-			condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id  IN (` + articleTypeIds + `)  `
-			total, err = models.GetReoprtSearchCountYx(condition)
+		if keyWord != "" {
+			if articleType == 1 {
+				condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id NOT IN (` + articleTypeIds + `)  `
+				total, err = models.GetReoprtSearchCountHz(condition)
+			} else {
+				condition = `  AND ( a.title LIKE '%` + keyWord + `%' OR  a.body LIKE '%` + keyWord + `%' OR  a.annotation LIKE '%` + keyWord + `%' OR  a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1  AND a.article_type_id  IN (` + articleTypeIds + `)  `
+				total, err = models.GetReoprtSearchCountYx(condition)
+			}
+
+			conditionYxSpecial = `   AND ( a.title LIKE '%` + keyWord + `%' OR  a.content LIKE '%` + keyWord + `%')  `
 		}
 		if err != nil {
 			br.Msg = "获取信息失败"
@@ -958,7 +962,7 @@ func (this *MobileReportController) SearchReport() {
 		if articleType == 1 {
 			list, err = models.GetArticleResearchListHz(condition, pars, startSize, pageSize, user.UserId)
 		} else {
-			list, err = models.GetArticleResearchList(condition, pars, startSize, pageSize, user.UserId, true)
+			total, list, err = models.GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial, pars, startSize, pageSize, user.UserId, true)
 		}
 		if err != nil {
 			br.Msg = "获取信息失败"

+ 5 - 4
controllers/tag.go

@@ -56,21 +56,22 @@ func (this *TagController) TagCustomizeList() {
 	}
 	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")
 		}
+
+		//固定标签默认都属于,前端互斥使用
+		if v.TagType > 0 {
+			v.CheckList = []string{"A", "B", "C", "D"}
+		}
 	}
 	//var condition string
 	condition = ` AND permission_name IN ('医药','消费','科技','智造','策略') `

+ 1 - 4
models/cygx_tag.go

@@ -46,11 +46,8 @@ type CygxTagList struct {
 	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勾选了哪几列
+	TagType       int      `description:"1:热门活动、2:海外研究、3:路演回放、4:语音问答"`
 }
 
 // 列表

+ 69 - 0
models/report.go

@@ -935,6 +935,75 @@ func GetArticleResearchList(condition string, pars []interface{}, startSize, pag
 	return
 }
 
+func GetArticleResearchAndYxSpecialList(condition, conditionYxSpecial string, pars []interface{}, startSize, pageSize, userId int, needYanxuanSpecial bool) (total int, items []*ArticleListResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.article_id,
+			a.title,
+			a.body,
+			a.annotation,
+			a.abstract,
+			a.publish_date,
+			a.article_type_id,
+			d.nick_name,
+			d.department_id,
+			( SELECT count( 1 ) FROM cygx_article_history_record_newpv AS h WHERE h.article_id = a.article_id ) AS pv,
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac    WHERE ac.article_id = a.article_id  ) AS collect_num, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac   WHERE ac.article_id = a.article_id AND DATE_SUB( CURDATE(), INTERVAL 30 DAY ) <= date( ac.create_time )  ) AS collect_num_order, 
+			( SELECT count( 1 ) FROM cygx_article_collect AS ac WHERE ac.article_id = a.article_id  AND user_id = ? ) AS my_collect_num,
+			0 AS is_special,
+			0 AS special_type,
+			0 AS special_column_id,
+			'' AS company_tags, 
+			'' AS industry_tags
+		FROM
+			cygx_article AS a
+			LEFT JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
+			LEFT JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id
+			INNER JOIN cygx_article_department AS d ON d.department_id = a.department_id 
+		WHERE
+			1 = 1  AND a.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	if needYanxuanSpecial {
+		sql += `UNION ALL
+	SELECT
+		a.id AS article_id,
+		a.title AS title,
+		'' AS body,
+		a.content AS annotation,
+		'' AS abstract,
+		a.publish_time AS publish_date,
+		-1 AS article_type_id,
+		b.nick_name AS nick_name,
+		0 AS department_id,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_record AS h WHERE h.yanxuan_special_id = a.id ) AS pv,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac   WHERE ac.yanxuan_special_id = a.id  ) AS collect_num,
+		0 AS collect_num_order,
+		( SELECT count( 1 ) FROM cygx_yanxuan_special_collect AS ac WHERE ac.yanxuan_special_id = a.id  AND user_id = ? ) AS my_collect_num,
+		1 AS is_special,
+		a.type AS special_type,
+		b.id AS special_column_id,
+		a.company_tags AS company_tags, 
+		a.industry_tags AS industry_tags 
+	FROM
+	cygx_yanxuan_special AS a
+	JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
+	WHERE
+	1 = 1  AND a.status = 3 ` + conditionYxSpecial
+
+		totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+		err = o.Raw(totalSql, userId, userId, pars).QueryRow(&total)
+		sql += ` GROUP BY article_id ORDER  BY publish_date DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, userId, userId, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		sql += ` GROUP BY a.article_id ORDER  BY a.publish_date DESC  LIMIT ?,? `
+		_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	}
+	return
+}
+
 func GetArticleResearchListHz(condition string, pars []interface{}, startSize, pageSize, userId int) (items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT

+ 4 - 4
services/micro_roadshow.go

@@ -369,14 +369,14 @@ func GetMicroRoadShowPageListV12(pageSize, currentIndex, sourceId, tableType int
 		// @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 `
+			audioAct += ` AND a.file_type = 1 `
+			videoAct += ` AND a.file_type = 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) )  `
+			audioAct += ` AND  a.file_type = 2 `
+			videoAct += ` AND  a.file_type = 2 `
 		}
 
 		if !strings.Contains(searchType, "2") {

+ 1 - 1
services/resource_data.go

@@ -447,7 +447,7 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			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 {
+			if v.SourceId == vList.SourceId && v.Source == vList.Source {
 				items = append(items, v)
 			}
 		}

+ 151 - 70
services/tag.go

@@ -46,7 +46,7 @@ func AddCygxTagHistory(user *models.WxUserItem, tagId int) (err error) {
 //	fmt.Println(conditionInit)
 //}
 
-func GetConditionInitByTagIds(tagIds string) (conditionInit string, err error) {
+func GetConditionInitByTagIds(tagIds string, chartPermissionId int) (conditionInit string, err error) {
 	if tagIds == "" {
 		return
 	}
@@ -58,10 +58,11 @@ func GetConditionInitByTagIds(tagIds string) (conditionInit string, err error) {
 	pars = append(pars, tagslice)
 	listTag, e := models.GetCygxTagListCondition(condition, pars, 0, 0)
 	if e != nil {
-		err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+		err = errors.New("GetCygxTagListCondition, Err: " + e.Error())
 		return
 	}
 
+	var tagType int // 定义特殊标签的类型,判断传过来的参数是否有固定标签的搜索
 	for _, tagInfo := range listTag {
 		//ActivityTypes 与 ArticleTypes 进行合并
 		if tagInfo.ActivityTypes != "" {
@@ -90,92 +91,172 @@ func GetConditionInitByTagIds(tagIds string) (conditionInit string, err error) {
 			}
 			//subjectNames = append(subjectNames, tagInfo.SubjectNames)
 		}
-	}
 
-	//拼接search_tag 搜索内容
-	if len(searchTag) > 0 {
-		//search_tag_two 兼容报告类型一对多的这种,时间不够,产品也有可能变先这么做
-		conditionInit += " AND ( search_tag IN  ('" + strings.Join(searchTag, "','") + "')  OR search_tag_two IN( '" + strings.Join(searchTag, "','") + "' )  )"
+		if tagType == 0 && tagInfo.TagType > 0 {
+			tagType = tagInfo.TagType
+		}
 	}
 
-	var resourceDataIds []int //cygx_resource_data 主键ID
-	//如果产业有组合,那么就去捞产业相关的内容
-	if len(industries) > 0 {
-		var conditionIndustry string
-		var parsIndustry []interface{}
-		conditionIndustry += " AND industry_name IN  ('" + strings.Join(industries, "','") + "')"
-		listIndustry, e := models.GetTopOneMonthArtReadNumIndustryAll(conditionIndustry, parsIndustry)
-		if e != nil {
-			err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
-			return
-		}
-		var industrialManagementIds []int // 产业ID合集
-		for _, v := range listIndustry {
-			industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+	switch tagType {
+	case 0: // 无固定标签
+		//拼接search_tag 搜索内容
+		if len(searchTag) > 0 {
+			//search_tag_two 兼容报告类型一对多的这种,时间不够,产品也有可能变先这么做
+			conditionInit += " AND ( search_tag IN  ('" + strings.Join(searchTag, "','") + "')  OR search_tag_two IN( '" + strings.Join(searchTag, "','") + "' )  )"
 		}
 
-		var conditionIndustryResource string
-		var parsIndustryResource []interface{}
-		lenArrindustrial := len(industrialManagementIds)
-		conditionIndustryResource = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(lenArrindustrial) + `)`
-		parsIndustryResource = append(parsIndustryResource, industrialManagementIds)
-
-		if lenArrindustrial > 0 {
-			listResourceDataIndustrial, e := models.GetCygxResourceDataIndustrialGroupManagementList(conditionIndustryResource, parsIndustryResource, 0, 0)
-			//return
+		var resourceDataIds []int //cygx_resource_data 主键ID
+		//如果产业有组合,那么就去捞产业相关的内容
+		if len(industries) > 0 {
+			var conditionIndustry string
+			var parsIndustry []interface{}
+			conditionIndustry += " AND industry_name IN  ('" + strings.Join(industries, "','") + "')"
+			listIndustry, e := models.GetTopOneMonthArtReadNumIndustryAll(conditionIndustry, parsIndustry)
 			if e != nil {
-				err = errors.New("GetCygxResourceDataIndustrialGroupManagementList, Err: " + e.Error())
+				err = errors.New("GetTopOneMonthArtReadNumIndustryAll, Err: " + e.Error())
 				return
 			}
-			for _, v := range listResourceDataIndustrial {
-				resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+			var industrialManagementIds []int // 产业ID合集
+			for _, v := range listIndustry {
+				industrialManagementIds = append(industrialManagementIds, v.IndustrialManagementId)
+			}
+
+			var conditionIndustryResource string
+			var parsIndustryResource []interface{}
+			lenArrindustrial := len(industrialManagementIds)
+			conditionIndustryResource = ` AND industrial_management_id IN (` + utils.GetOrmInReplace(lenArrindustrial) + `)`
+			parsIndustryResource = append(parsIndustryResource, industrialManagementIds)
+
+			if lenArrindustrial > 0 {
+				listResourceDataIndustrial, e := models.GetCygxResourceDataIndustrialGroupManagementList(conditionIndustryResource, parsIndustryResource, 0, 0)
+				//return
+				if e != nil {
+					err = errors.New("GetCygxResourceDataIndustrialGroupManagementList, Err: " + e.Error())
+					return
+				}
+				for _, v := range listResourceDataIndustrial {
+					resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+				}
 			}
 		}
-	}
-	//return
-	//如果标的有组合,那么就去捞标的相关的内容
-	if len(subjectNames) > 0 {
-		var conditionsubject string
-		var parssubject []interface{}
-		conditionsubject += " AND subject_name IN  ('" + strings.Join(subjectNames, "','") + "')"
-		listsubject, e := models.GetCygxIndustrialSubjectListCondition(conditionsubject, parssubject)
-		if e != nil {
-			err = errors.New("GetTopOneMonthArtReadNumIndustry, Err: " + e.Error())
-			return
-		}
-		var industrialsubjectIds []int // 标的ID集合
-		for _, v := range listsubject {
-			industrialsubjectIds = append(industrialsubjectIds, v.IndustrialSubjectId)
-		}
-		var conditionsubjectResource string
-		var parssubjectResource []interface{}
-		lenArrsubject := len(industrialsubjectIds)
-		conditionsubjectResource = ` AND industrial_subject_id IN (` + utils.GetOrmInReplace(lenArrsubject) + `)`
-		parssubjectResource = append(parssubjectResource, industrialsubjectIds)
-		if lenArrsubject > 0 {
-			listResourceDatasubject, e := models.GetCygxResourceDataIndustrialGroupSubjectList(conditionsubjectResource, parssubjectResource, 0, 0)
+		//return
+		//如果标的有组合,那么就去捞标的相关的内容
+		if len(subjectNames) > 0 {
+			var conditionsubject string
+			var parssubject []interface{}
+			conditionsubject += " AND subject_name IN  ('" + strings.Join(subjectNames, "','") + "')"
+			listsubject, e := models.GetCygxIndustrialSubjectListCondition(conditionsubject, parssubject)
 			if e != nil {
-				err = errors.New("GetCygxResourceDataIndustrialGroupSubjectList, Err: " + e.Error())
+				err = errors.New("GetTopOneMonthArtReadNumIndustry, Err: " + e.Error())
 				return
 			}
-			for _, v := range listResourceDatasubject {
-				resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+			var industrialsubjectIds []int // 标的ID集合
+			for _, v := range listsubject {
+				industrialsubjectIds = append(industrialsubjectIds, v.IndustrialSubjectId)
+			}
+			var conditionsubjectResource string
+			var parssubjectResource []interface{}
+			lenArrsubject := len(industrialsubjectIds)
+			conditionsubjectResource = ` AND industrial_subject_id IN (` + utils.GetOrmInReplace(lenArrsubject) + `)`
+			parssubjectResource = append(parssubjectResource, industrialsubjectIds)
+			if lenArrsubject > 0 {
+				listResourceDatasubject, e := models.GetCygxResourceDataIndustrialGroupSubjectList(conditionsubjectResource, parssubjectResource, 0, 0)
+				if e != nil {
+					err = errors.New("GetCygxResourceDataIndustrialGroupSubjectList, Err: " + e.Error())
+					return
+				}
+				for _, v := range listResourceDatasubject {
+					resourceDataIds = append(resourceDataIds, v.ResourceDataId)
+				}
 			}
 		}
-	}
 
-	//拼接 cygx_resource_data 表主键查询ID
-	if len(resourceDataIds) > 0 {
-		var resourceDataIdStrs []string
-		resourceDataIdMap := make(map[int]bool)
-		for _, v := range resourceDataIds {
-			if resourceDataIdMap[v] {
-				continue
+		//拼接 cygx_resource_data 表主键查询ID
+		if len(resourceDataIds) > 0 {
+			var resourceDataIdStrs []string
+			resourceDataIdMap := make(map[int]bool)
+			for _, v := range resourceDataIds {
+				if resourceDataIdMap[v] {
+					continue
+				}
+				resourceDataIdStrs = append(resourceDataIdStrs, strconv.Itoa(v))
+				resourceDataIdMap[v] = true
+			}
+			conditionInit += " AND id IN  (" + strings.Join(resourceDataIdStrs, ",") + ") "
+		}
+	case 1: // 热门活动
+		conf, e := models.GetConfigByCode(utils.CYGX_TAG_HOT_ACTIVITY_ID)
+		if e != nil {
+			err = errors.New("GetConfigByCode, Err: " + e.Error())
+			return
+		}
+		//主键ID赋值为0,进行空查询
+		if conf.ConfigValue == "" {
+			conditionInit += " AND id = 0  "
+			return
+		}
+		pars = make([]interface{}, 0)
+		condition = " AND activity_id IN ( " + conf.ConfigValue + ")  AND publish_status = 1   AND active_state  IN (1,2) "
+		listActivity, e := models.GetActivityListByCondition(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+			return
+		}
+		if len(listActivity) == 0 {
+			conditionInit += " AND id = 0  "
+			return
+		}
+
+		//拼接查询热门活动的SQL、
+		var activityIds []string
+		for _, v := range listActivity {
+			activityIds = append(activityIds, strconv.Itoa(v.ActivityId))
+		}
+		conditionInit = " AND source_id IN ( " + strings.Join(activityIds, ",") + ")  AND source = '" + utils.CYGX_OBJ_ACTIVITY + "'"
+
+	case 2: //海外研究 查询海外研究的文章,以及海外的活动
+		condition = " AND category_id IN ( SELECT category_id_celue FROM cygx_report_mapping_group WHERE id_cygx IN ( 35,39 ) ) AND publish_status = 1"
+		pars = make([]interface{}, 0)
+		articleList, e := models.GetArticleList(condition, pars)
+		if e != nil {
+			err = errors.New("GetArticleList, Err: " + e.Error())
+			return
+		}
+		//文章一定会有值,这里就不做为空判断了 。。。
+		var articleIds []string
+		for _, v := range articleList {
+			articleIds = append(articleIds, strconv.Itoa(v.ArticleId))
+		}
+
+		//海外举办的活动查询
+		condition = " AND  area_type = 2  AND publish_status = 1   "
+		listActivity, e := models.GetActivityListByCondition(condition, pars)
+		if e != nil {
+			err = errors.New("GetActivityListByCondition, Err: " + e.Error())
+			return
+		}
+		//判断是否有海外活动,如果有就拼接,报告与活动的查询SQL
+		if len(listActivity) == 0 {
+			conditionInit = " AND source_id IN ( " + strings.Join(articleIds, ",") + ")  AND source = '" + utils.CYGX_OBJ_ARTICLE + "'"
+		} else {
+			var activityIds []string
+			for _, v := range listActivity {
+				activityIds = append(activityIds, strconv.Itoa(v.ActivityId))
+			}
+			var conditionchartInit string
+			//行业筛选
+			if chartPermissionId > 0 {
+				conditionchartInit += " AND chart_permission_id  =  " + strconv.Itoa(chartPermissionId)
 			}
-			resourceDataIdStrs = append(resourceDataIdStrs, strconv.Itoa(v))
-			resourceDataIdMap[v] = true
+			conditionInit = " AND  ( source_id IN ( " + strings.Join(articleIds, ",") + ") " + conditionchartInit + "  AND source = '" + utils.CYGX_OBJ_ARTICLE + "') OR   (source_id IN ( " + strings.Join(activityIds, ",") + ") " + conditionchartInit + "   AND source = '" + utils.CYGX_OBJ_ACTIVITY + " ' )"
 		}
-		conditionInit += " AND id IN  (" + strings.Join(resourceDataIdStrs, ",") + ") "
+
+	case 3: // 路演回放
+		conditionInit = "  AND source  IN('activityvoice','activityvideo')  AND  search_tag = '路演回放' "
+
+	case 4: // 语音问答
+		conditionInit = "   AND source = '" + utils.CYGX_OBJ_ASKSERIEVIDEO + "'"
 	}
+
 	return
 }

+ 5 - 4
utils/constants.go

@@ -213,10 +213,11 @@ const (
 )
 
 const (
-	TPL_MSG_WANG_YANG           = "tpl_msg_wang_yang"           //汪洋手机号地址参数
-	TPL_MSG_WANG_FANG_WANG_YANG = "tpl_msg_wang_fang_wang_yang" //权限模板消息接收人,王芳,汪洋
-	TPL_MSG                     = "tpl_msg"                     //王芳手机号地址参数
-	TPL_MSG_NEI_RONG_ZU         = "tpl_msg_nei_rong_zu"         //内容组四人
+	TPL_MSG_WANG_YANG                  = "tpl_msg_wang_yang"           //汪洋手机号地址参数
+	TPL_MSG_WANG_FANG_WANG_YANG        = "tpl_msg_wang_fang_wang_yang" //权限模板消息接收人,王芳,汪洋
+	TPL_MSG                            = "tpl_msg"                     //王芳手机号地址参数
+	TPL_MSG_NEI_RONG_ZU                = "tpl_msg_nei_rong_zu"         //内容组四人
+	CYGX_TAG_HOT_ACTIVITY_ID    string = "cygx_tag_hot_activity_id"    //标签管理自定义的热门活动ID
 )
 
 const (