Browse Source

no message

xingzai 2 years ago
parent
commit
b0fa6fce0a
2 changed files with 47 additions and 43 deletions
  1. 3 0
      controllers/activity.go
  2. 44 43
      services/activity.go

+ 3 - 0
controllers/activity.go

@@ -4836,6 +4836,9 @@ func (this *ActivityCoAntroller) OverActivityList() {
 		if _, ok := mapKeyWord[keyWord]; ok {
 			continue
 		}
+		if keyWord == "" {
+			continue
+		}
 		v.KeyWord = keyWord
 		resp.List = append(resp.List, v)
 		mapKeyWord[keyWord] = keyWord

+ 44 - 43
services/activity.go

@@ -1556,51 +1556,52 @@ func ActivityButtonShow(item *models.ActivityDetail) (articleDetail *models.Acti
 func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryNewMap map[int]bool, err error) {
 	labelMap = make(map[int]bool, 0)
 	industryNewMap = make(map[int]bool, 0)
-	//if len(activityIds) == 0 {
-	//	return
-	//}
-	//
-	//// 获取活动关联的产业
-	//var groupCond string
-	//var groupPars []interface{}
-	//groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1 `
-	//groupPars = append(groupPars, activityIds)
-	//groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
-	//if e != nil {
-	//	err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
-	//	return
-	//}
-	//activityIndustryMap := make(map[int][]int, 0)
-	//industryIds := make([]int, 0)
-	//for i := range groups {
-	//	industryIds = append(industryIds, groups[i].IndustrialManagementId)
-	//	activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
-	//}
-	//
-	//// 获取新产业Map
-	//industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
-	//if e != nil {
-	//	err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
-	//	return
-	//}
-	//
-	//// 判断活动是否为新
-	//for k := range industryLabelMap {
-	//	for k2, v2 := range activityIndustryMap {
-	//		if labelMap[k2] {
-	//			continue
-	//		}
-	//		// 活动的产业ID中存在一个新产业即为新活动
-	//		if utils.InArrayByInt(v2, k) {
-	//			labelMap[k2] = true
-	//		}
-	//	}
-	//}
+	if len(activityIds) == 0 {
+		return
+	}
 
-	for k := range activityIds {
-		labelMap[k] = true
+	// 获取活动关联的产业
+	var groupCond string
+	var groupPars []interface{}
+	groupCond += ` AND a.activity_id IN (` + utils.GetOrmInReplace(len(activityIds)) + `) AND b.source = 1 `
+	groupPars = append(groupPars, activityIds)
+	groups, e := models.GetActivityIndustryRelationList(groupCond, groupPars)
+	if e != nil {
+		err = errors.New("获取活动产业关联列表失败, Err: " + e.Error())
+		return
+	}
+	activityIndustryMap := make(map[int][]int, 0)
+	industryIds := make([]int, 0)
+	for i := range groups {
+		industryIds = append(industryIds, groups[i].IndustrialManagementId)
+		activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
 	}
-	//产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
+
+	// 获取新产业Map
+	industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
+	if e != nil {
+		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
+		return
+	}
+
+	// 判断活动是否为新
+	for k := range industryLabelMap {
+		for k2, v2 := range activityIndustryMap {
+			if labelMap[k2] {
+				continue
+			}
+			// 活动的产业ID中存在一个新产业即为新活动
+			if utils.InArrayByInt(v2, k) {
+				labelMap[k2] = true
+			}
+		}
+	}
+
+	//for _, v := range activityIds {
+	//	labelMap[v] = true
+	//}
+	//fmt.Println(labelMap)
+	////产业关联的弘则报告发布日期在三个月以内的活动、产业显示 NEW标签
 	articNewLabel, e := GetArticNewLabelWhithActivity3Month()
 	if e != nil {
 		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())