Browse Source

no message

xingzai 11 months ago
parent
commit
d8cac843f9

+ 0 - 12
controllers/report.go

@@ -2197,18 +2197,6 @@ func (this *MobileReportController) TacticsList() {
 		if v.Resource == 2 {
 			item.Pv = productInteriorMapPv[v.ArticleId]
 		}
-		//listResp = append(listResp, &models.HomeArticle{
-		//	ArticleId:   v.ArticleId,
-		//	Title:       v.Title,
-		//	Annotation:  "核心观点:" + v.Annotation,
-		//	Abstract:    v.Abstract,
-		//	ImgUrlPc:    v.ImgUrlPc,
-		//	PublishDate: v.PublishDate,
-		//	Resource:    v.Resource,
-		//	Pv:          articleMapPv[v.ArticleId],
-		//	IsCollect:   articleCollectMap[v.ArticleId],
-		//	CollectNum:  articleCollectNumMap[v.ArticleId],
-		//})
 		listResp = append(listResp, item)
 	}
 	if len(listResp) == 0 {

+ 7 - 0
controllers/yanxuan_special.go

@@ -82,6 +82,12 @@ func (this *YanxuanSpecialNoLoginController) List() {
 		br.ErrMsg = "获取失败, Err:" + err.Error()
 		return
 	}
+	var yanxuanSpecialIds []int
+	for _, v := range list {
+		yanxuanSpecialIds = append(yanxuanSpecialIds, v.Id)
+	}
+
+	pvMap := services.GetYanxuanSpecialRecordByYanxuanSpecialId(yanxuanSpecialIds)
 	for _, v := range list {
 		hasImg, err := utils.ArticleHasImgUrl(v.Content)
 		if err != nil {
@@ -132,6 +138,7 @@ func (this *YanxuanSpecialNoLoginController) List() {
 		if len(v.TagList) == 0 {
 			v.TagList = []string{}
 		}
+		v.Pv = pvMap[v.Id]
 	}
 	specialAuthorCheck := services.GetYanxuanSpecialAuthorInfo(sysUser) //用户是否没开通研选专栏以及,专栏信息是否完善
 	resp.IsAuthor = specialAuthorCheck.IsAuthor

+ 32 - 0
models/article_history_record_newpv.go

@@ -227,3 +227,35 @@ func GetCygxArticleHistoryRecordNewpvListPv(condition string, pars []interface{}
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	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
+}

+ 2 - 2
models/cygx_yanxuan_special.go

@@ -58,8 +58,8 @@ type CygxYanxuanSpecialItem struct {
 	IndustryTags    string
 	Docs            []Doc
 	Annotation      string   `description:"核心观点"`
-	Pv              string   `description:"Pv"`
-	Uv              string   `description:"Uv"`
+	Pv              int      `description:"Pv"`
+	Uv              int      `description:"Uv"`
 	BodyHighlight   []string `description:"搜索高亮展示结果"`
 }
 

+ 22 - 0
models/cygx_yanxuan_special_record.go

@@ -62,3 +62,25 @@ func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId i
 	lastId, err = o.Insert(item)
 	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
+}

+ 1 - 1
models/home.go

@@ -174,7 +174,7 @@ WHERE
 
 func GetHomeListPublic(condition string, pars []interface{}, startSize, pageSize int) (items []*ArticleListResp, err error) {
 	o := orm.NewOrm()
-	sql := ` SELECT * ,(SELECT count(1) FROM cygx_article_history_record_newpv as h WHERE h.article_id = a.article_id ) as pv
+	sql := ` SELECT * 
                  FROM cygx_article AS a
                 WHERE a.publish_status=1 `
 	if condition != "" {

+ 15 - 4
services/article_history.go

@@ -94,12 +94,13 @@ func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUse
 	return
 }
 
+// GetArticleHistoryByArticleId 获取文章阅读 pv map
 func GetArticleHistoryByArticleId(articleIds []int) (mapResp map[int]int) {
 	var err error
 	defer func() {
 		if err != nil {
 			fmt.Println(err)
-			go utils.SendAlarmMsg("获取用户的阅读数据,信息失败,Err:"+err.Error(), 3)
+			go utils.SendAlarmMsg("获取用户的阅读数据,信息失败,GetArticleHistoryByArticleId Err:"+err.Error(), 3)
 		}
 	}()
 	lenIds := len(articleIds)
@@ -110,13 +111,23 @@ 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("GetCygxArticleHistoryRecordNewpvListPvCy, Err: " + e.Error())
+		return
+	}
+	for _, v := range listCl {
+		mapResp[v.ArticleId] += v.Pv
+	}
 	return
 }

+ 29 - 0
services/cygx_yanxuan_special_company.go

@@ -175,3 +175,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
+}