Răsfoiți Sursa

fix: PC接口

hsun 2 ani în urmă
părinte
comite
8e955caea3
4 a modificat fișierele cu 126 adăugiri și 52 ștergeri
  1. 74 25
      controllers/activity.go
  2. 1 0
      models/activity.go
  3. 13 27
      services/activity.go
  4. 38 0
      services/industrial_management.go

+ 74 - 25
controllers/activity.go

@@ -94,6 +94,10 @@ func (this *ActivityCoAntroller) ActivityList() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if activityTypeIds == "undefined" {
 		activityTypeIds = ""
 	}
@@ -887,22 +891,24 @@ func (this *ActivityCoAntroller) Detail() {
 			item.IndustryName = activityInfo.Label
 			industrialList = append(industrialList, item)
 		} else {
-			// 查研观向7.4-行业新标签
-			actIds := []int{activityId}
-			_, industryNewMap, e := services.GetActivityNewLabelMap(actIds)
-			if e != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取活动产业新标签失败, Err: " + e.Error()
-				return
-			}
-
+			industryIds := make([]int, 0)
 			var industrialManagementId string
 			for k, v := range industrialList {
 				if v.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
 					industrialList[k].IsResearch = true
 				}
+				industryIds = append(industryIds, v.IndustrialManagementId)
 				industrialManagementId += strconv.Itoa(v.IndustrialManagementId) + ","
 			}
+
+			// 查研观向7.4-行业新标签
+			industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
+				return
+			}
+
 			//判断产业下是否有关联的报告,并处理是否跳转
 			industrialManagementId = strings.TrimRight(industrialManagementId, ",")
 			if industrialManagementId != "" {
@@ -1991,6 +1997,10 @@ func (this *ActivityCoAntroller) LabelList() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if activityTypeIds == "undefined" {
 		activityTypeIds = ""
 	}
@@ -2344,6 +2354,10 @@ func (this *ActivityCoAntroller) LabelTypeList() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if whichDay == "undefined" {
 		whichDay = ""
 	}
@@ -2715,7 +2729,6 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
-
 	// 查研观向7.4-始终查询宏观的活动
 	if chartPermissionIds != "" {
 		chartPermissionIds += ",1"
@@ -2876,6 +2889,15 @@ func (this *ActivityCoAntroller) ActivityListNew() {
 			if sourceIndustry.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
 				resp.IsResearch = true
 			}
+			// 产业新标签
+			industryIds := []int{sourceIndustry.IndustrialManagementId}
+			industryNewMap, e := services.GetIndustryNewLabelMap(industryIds)
+			if e != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取产业新标签失败, Err: " + e.Error()
+				return
+			}
+			resp.IndustryNewLabel = industryNewMap[sourceIndustry.IndustrialManagementId]
 		}
 	}
 
@@ -2918,6 +2940,10 @@ func (this *ActivityCoAntroller) LabelTypeListPc() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if whichDay == "undefined" {
 		whichDay = ""
 	}
@@ -4302,6 +4328,10 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 	if chartPermissionIds == "undefined" {
 		chartPermissionIds = ""
 	}
+	// 查研观向7.4-始终查询宏观的活动
+	if chartPermissionIds != "" {
+		chartPermissionIds += ",1"
+	}
 	if whichDay == "undefined" {
 		whichDay = ""
 	}
@@ -4309,11 +4339,6 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 		activeState = "1,2"
 	}
 
-	// 查研观向7.4-始终查询宏观的活动
-	if chartPermissionIds != "" {
-		chartPermissionIds += ",1"
-	}
-
 	//adminIds, err := models.GetSelleridWhichGroup(user.CompanyId, 2)
 	//if err != nil {
 	//	br.Msg = "获取失败"
@@ -4462,17 +4487,41 @@ func (this *ActivityCoAntroller) LabelTypeListV6Pc() {
 		itemList.ImgUrlBgPc = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/rFwAM1c4fIMJM0EGoUkUYl25XH9L.png"
 		list = append(list, itemList)
 	}
+
+	// 查研观向7.4-活动【新】标签
+	activityIds := make([]int, 0)
+	for _, v := range list {
+		if len(v.List) > 0 {
+			for i := range v.List {
+				activityIds = append(activityIds, v.List[i].ActivityId)
+			}
+		}
+	}
+	newLabelMap, _, e := services.GetActivityNewLabelMap(activityIds)
+	if e != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取活动【新】标签Map失败, Err: " + e.Error()
+		return
+	}
+	for k := range list {
+		for k2 := range list[k].List {
+			list[k].List[k2].IsNew = newLabelMap[list[k].List[k2].ActivityId]
+		}
+	}
+
 	//记录用户搜索的筛选条件
-	item := new(models.CygxActivitySearchHistory)
-	item.UserId = user.UserId
-	item.Mobile = user.Mobile
-	item.CompanyId = user.CompanyId
-	item.CompanyName = user.CompanyName
-	item.CreateTime = time.Now()
-	item.ChartPermissionIds = chartPermissionIds
-	item.IsPower = isPower
-	item.WhichDay = whichDay
-	go models.AddCygxActivitySearchHistory(item)
+	{
+		item := new(models.CygxActivitySearchHistory)
+		item.UserId = user.UserId
+		item.Mobile = user.Mobile
+		item.CompanyId = user.CompanyId
+		item.CompanyName = user.CompanyName
+		item.CreateTime = time.Now()
+		item.ChartPermissionIds = chartPermissionIds
+		item.IsPower = isPower
+		item.WhichDay = whichDay
+		go models.AddCygxActivitySearchHistory(item)
+	}
 
 	resp.List = list
 	br.Ret = 200

+ 1 - 0
models/activity.go

@@ -266,6 +266,7 @@ type GetCygxActivityListRep struct {
 	IsResearch             bool   `description:"是否属于研选"`
 	IsJump                 bool   `description:"是否跳转"`
 	IndustrialManagementId int    `description:"产业ID"`
+	IndustryNewLabel       bool   `description:"产业是否新标签"`
 }
 
 //列表

+ 13 - 27
services/activity.go

@@ -1397,7 +1397,7 @@ func ActivityButtonShow(item *models.ActivityDetail) (articleDetail *models.Acti
 	return
 }
 
-// GetActivityNewLabelMap 获取活动【新】标签Map, 行业【新】标签Map
+// GetActivityNewLabelMap 获取活动【新】标签Map
 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)
@@ -1421,37 +1421,23 @@ func GetActivityNewLabelMap(activityIds []int) (labelMap map[int]bool, industryN
 		industryIds = append(industryIds, groups[i].IndustrialManagementId)
 		activityIndustryMap[groups[i].ActivityId] = append(activityIndustryMap[groups[i].ActivityId], groups[i].IndustrialManagementId)
 	}
-	industryIdLen := len(industryIds)
 
-	// 获取产业关联的报告最早发布时间及最近的发布时间
-	var timeCond string
-	var timePars []interface{}
-	timeCond += ` AND b.publish_status = 1`
-	if industryIdLen > 0 {
-		timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
-		timePars = append(timePars, industryIds)
-	}
-	industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
+	// 获取新产业Map
+	industryLabelMap, e := GetIndustryNewLabelMap(industryIds)
 	if e != nil {
-		err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
+		err = errors.New("获取产业新标签Map失败, Err: " + e.Error())
 		return
 	}
 
-	// 判断产业是否为新
-	nowTime := time.Now().Local()
-	threeMonthBefore := nowTime.AddDate(0, -3, 0)
-	nullTime, _ := time.Parse(utils.FormatDateTime, "0001-01-01 00:00:00")
-	for i := range industryTimeList {
-		// 最早发布时间为空 / 最早发布时间在三个月前之后
-		if industryTimeList[i].MinPublishTime == nullTime || (industryTimeList[i].MinPublishTime.After(threeMonthBefore)) {
-			industryNewMap[industryTimeList[i].IndustrialManagementId] = true
-			for k, v := range activityIndustryMap {
-				if labelMap[k] {
-					continue
-				}
-				if utils.InArrayByInt(v, industryTimeList[i].IndustrialManagementId) {
-					labelMap[k] = true
-				}
+	// 判断活动是否为新
+	for k := range industryLabelMap {
+		for k2, v2 := range activityIndustryMap {
+			if labelMap[k2] {
+				continue
+			}
+			// 活动的产业ID中存在一个新产业即为新活动
+			if utils.InArrayByInt(v2, k) {
+				labelMap[k2] = true
 			}
 		}
 	}

+ 38 - 0
services/industrial_management.go

@@ -2,10 +2,12 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strings"
+	"time"
 )
 
 //修改标签状态
@@ -214,3 +216,39 @@ func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error)
 	}
 	return err
 }
+
+// GetIndustryNewLabelMap 获取产业【新】标签Map
+func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error) {
+	labelMap = make(map[int]bool, 0)
+	industryIdLen := len(industryIds)
+	if industryIdLen == 0 {
+		return
+	}
+
+	// 获取产业关联的报告最早发布时间及最近的发布时间
+	var timeCond string
+	var timePars []interface{}
+	timeCond += ` AND b.publish_status = 1`
+	if industryIdLen > 0 {
+		timeCond += ` AND a.industrial_management_id IN (` + utils.GetOrmInReplace(industryIdLen) + `)`
+		timePars = append(timePars, industryIds)
+	}
+	industryTimeList, e := models.GetIndustryArticleMinMaxPublishTime(timeCond, timePars)
+	if e != nil {
+		err = errors.New("获取产业文章最大最小发布时间失败, Err: " + e.Error())
+		return
+	}
+
+	// 判断产业是否为新
+	nowTime := time.Now().Local()
+	threeMonthBefore := nowTime.AddDate(0, -3, 0)
+	nullTime, _ := time.Parse(utils.FormatDateTime, "0001-01-01 00:00:00")
+	for i := range industryTimeList {
+		// 最早发布时间为空 / 最早发布时间在三个月前之后
+		if industryTimeList[i].MinPublishTime == nullTime || (industryTimeList[i].MinPublishTime.After(threeMonthBefore)) {
+			labelMap[industryTimeList[i].IndustrialManagementId] = true
+		}
+	}
+
+	return
+}