Browse Source

no message

xingzai 11 months ago
parent
commit
820e83e744

+ 7 - 0
controllers/yanxuan_special.go

@@ -80,6 +80,12 @@ func (this *BaseAuthMobileController) List() {
 		br.ErrMsg = "获取失败, Err:" + err.Error()
 		return
 	}
+	var yanxuanSpecialIds []int
+	for _, v := range list {
+		yanxuanSpecialIds = append(yanxuanSpecialIds, v.Id)
+	}
+
+	yanxuanSpecialPv := services.GetYanxuanSpecialRecordByYanxuanSpecialId(yanxuanSpecialIds)
 	for _, v := range list {
 		hasImg, err := utils.ArticleHasImgUrl(v.Content)
 		if err != nil {
@@ -118,6 +124,7 @@ func (this *BaseAuthMobileController) List() {
 			}
 			v.Tags += v.IndustryTags
 		}
+		v.Pv = yanxuanSpecialPv[v.Id]
 		//if sysUser.UserId == 0 {
 		//	v.Content = utils.InterceptHtmlLength(v.Content, 242) // 截取前80个字
 		//}

+ 32 - 0
models/article_history_record_newpv.go

@@ -339,6 +339,38 @@ func GetCygxArticleHistoryRecordNewpvListPv(condition string, pars []interface{}
 	return
 }
 
+// 查研PV列表
+func GetCygxArticleHistoryRecordNewpvListPvCy(condition string, pars []interface{}) (items []*ListPvUvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			article_id
+		FROM
+			cygx_article_history_record_all  WHERE 1 = 1  AND platfor = 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY article_id `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
+// 策略PV列表
+func GetCygxArticleHistoryRecordNewpvListPvCl(condition string, pars []interface{}) (items []*ListPvUvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			article_id
+		FROM
+			cygx_article_history_record_all  WHERE 1 = 1  AND platfor = 2 AND is_del = 0 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY article_id `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}
+
 // 获取数量
 func GetCygxArticleHistoryRecordAllCount(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_history_record_all  WHERE 1= 1  `

+ 2 - 2
models/cygx_yanxuan_special.go

@@ -101,8 +101,8 @@ type CygxYanxuanSpecialCenterResp struct {
 	Docs                []Doc
 	Annotation          string   `description:"核心观点"`
 	Source              string   `description:"来源"`
-	Pv                  string   `description:"Pv"`
-	Uv                  string   `description:"Uv"`
+	Pv                  int      `description:"Pv"`
+	Uv                  int      `description:"Uv"`
 	PublishDate         string   // 提审过审或驳回时间      string `description:"核心观点"`
 	BodyHighlight       []string `description:"搜索高亮展示结果"`
 	LabelKeyword        string   `description:"标签关键词"`

+ 22 - 0
models/cygx_yanxuan_special_record.go

@@ -110,3 +110,25 @@ func GetCygxYanxuanSpecialRecordRespList(condition string, pars []interface{}, s
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+type LisYanxuanSpecialRecordPvResp struct {
+	YanxuanSpecialId int `description:"文章ID"`
+	Pv               int `description:"pv"`
+	Uv               int `description:"pv"`
+}
+
+// pv 列表
+func GetCygxYanxuanSpecialRecordListPv(condition string, pars []interface{}) (items []*LisYanxuanSpecialRecordPvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			yanxuan_special_id
+		FROM
+			cygx_yanxuan_special_record  WHERE 1 = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` GROUP BY yanxuan_special_id  `
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 5 - 15
services/article.go

@@ -218,10 +218,6 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 		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 {
@@ -236,17 +232,6 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 			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
 		//添加行业默认图片
@@ -280,6 +265,7 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 	for i := range list {
 		articleIds = append(articleIds, list[i].ArticleId)
 	}
+	articleMapPv := GetArticleHistoryByArticleId(articleIds) //文章Pv
 	// 报告关联产业信息
 	industryMap := make(map[int][]*models.IndustrialManagementIdInt, 0)
 	if len(articleIds) > 0 {
@@ -308,6 +294,10 @@ func HandleArticleCategoryImg(list []*models.HomeArticle) (items []*models.HomeA
 		} else {
 			list[k].List = make([]*models.IndustrialManagementIdInt, 0)
 		}
+		v.Pv = articleMapPv[v.ArticleId]
+		if v.Pv > 999 {
+			list[k].Pv = 999
+		}
 	}
 
 	if len(list) == 0 {

+ 13 - 3
services/article_history.go

@@ -25,14 +25,24 @@ func GetArticleHistoryByArticleId(articleIds []int) (mapResp map[int]int) {
 	var pars []interface{}
 	condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
 	pars = append(pars, articleIds)
-	list, err := models.GetCygxArticleHistoryRecordNewpvListPv(condition, pars)
-	if err != nil {
+	listCy, e := models.GetCygxArticleHistoryRecordNewpvListPvCy(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
 		return
 	}
 	mapResp = make(map[int]int, 0)
-	for _, v := range list {
+	for _, v := range listCy {
 		mapResp[v.ArticleId] = v.Pv
 	}
+
+	listCl, e := models.GetCygxArticleHistoryRecordNewpvListPvCl(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCl, Err: " + e.Error())
+		return
+	}
+	for _, v := range listCl {
+		mapResp[v.ArticleId] += v.Pv
+	}
 	return
 }
 

+ 29 - 0
services/cygx_yanxuan_special_company.go

@@ -108,3 +108,32 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	}
 	return
 }
+
+// GetYanxuanSpecialRecordByYanxuanSpecialId 获取研选专栏阅读 pv map
+func GetYanxuanSpecialRecordByYanxuanSpecialId(articleIds []int) (mapResp map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取研选专栏阅读,信息失败,GetYanxuanSpecialRecordByYanxuanSpecialId Err:"+err.Error(), 3)
+		}
+	}()
+	lenIds := len(articleIds)
+	if lenIds == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND yanxuan_special_id IN (` + utils.GetOrmInReplace(lenIds) + `) `
+	pars = append(pars, articleIds)
+	listPv, e := models.GetCygxYanxuanSpecialRecordListPv(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]int, 0)
+	for _, v := range listPv {
+		mapResp[v.YanxuanSpecialId] = v.Pv
+	}
+	return
+}