Browse Source

no message

xingzai 1 year ago
parent
commit
bc09ae594f
3 changed files with 64 additions and 16 deletions
  1. 36 13
      controllers/report.go
  2. 27 2
      models/product_interior_history.go
  3. 1 1
      services/product_interior.go

+ 36 - 13
controllers/report.go

@@ -2088,7 +2088,7 @@ func (this *MobileReportController) TacticsList() {
 					Abstract:    v.Abstract,
 					Body:        v.Body,
 					PublishDate: v.PublishDate,
-					Resource:    v.Resource,
+					Resource:    1,
 				})
 			}
 
@@ -2134,30 +2134,53 @@ func (this *MobileReportController) TacticsList() {
 	}
 
 	var articleIds []int
+	var productInteriorIs []int
 
 	for _, v := range listPublic {
 		if v.Resource == 1 {
 			articleIds = append(articleIds, v.ArticleId)
 		}
+		if v.Resource == 2 {
+			productInteriorIs = append(productInteriorIs, v.ArticleId)
+		}
 	}
 
 	articleMapPv := services.GetArticleHistoryByArticleId(articleIds)                       //文章Pv
 	articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)                  //用户收藏的文章
 	articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
+
+	productInteriorMapPv := services.GetCygxProductInteriorHistoryListPvMap(productInteriorIs) //产品内测Pv
 	listResp := make([]*models.HomeArticle, 0)
 	for _, v := range listPublic {
-		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],
-		})
+		item := new(models.HomeArticle)
+		item.ArticleId = v.ArticleId
+		item.Title = v.Title
+		item.Annotation = v.Annotation
+		item.Abstract = v.Abstract
+		item.ImgUrlPc = v.ImgUrlPc
+		item.PublishDate = v.PublishDate
+		item.Resource = v.Resource
+		if v.Resource == 1 {
+			item.Pv = articleMapPv[v.ArticleId]
+			item.IsCollect = articleCollectMap[v.ArticleId]
+			item.CollectNum = articleCollectNumMap[v.ArticleId]
+		}
+		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 {
 		listResp = make([]*models.HomeArticle, 0)

+ 27 - 2
models/product_interior_history.go

@@ -28,13 +28,38 @@ func AddCygxProductInteriorHistory(item *CygxProductInteriorHistory) (lastId int
 	return
 }
 
+//
+//// 列表
+//func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*CygxProductInteriorHistory, err error) {
+//	o := orm.NewOrm()
+//	sql := `SELECT * FROM cygx_product_interior_history as art WHERE 1= 1 `
+//	if condition != "" {
+//		sql += condition
+//	}
+//	_, err = o.Raw(sql, pars).QueryRows(&items)
+//	return
+//}
+//
+//
+
+type ListProductInteriorPvUvResp struct {
+	ProductInteriorId int `description:"文章ID"`
+	Pv                int `description:"pv"`
+	Uv                int `description:"pv"`
+}
+
 // 列表
-func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*CygxProductInteriorHistory, err error) {
+func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (items []*ListProductInteriorPvUvResp, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM cygx_product_interior_history as art WHERE 1= 1 `
+	sql := `SELECT
+			COUNT( 1 ) AS pv,
+			product_interior_id
+		FROM
+			cygx_product_interior_history  WHERE 1 = 1  `
 	if condition != "" {
 		sql += condition
 	}
+	sql += ` GROUP BY product_interior_id `
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }

+ 1 - 1
services/product_interior.go

@@ -158,7 +158,7 @@ func GetCygxProductInteriorHistoryListPvMap(productInteriorIs []int) (mapPv map[
 	}
 	mapPv = make(map[int]int, 0)
 	for _, v := range list {
-		mapPv[v.ProductInteriorId]++
+		mapPv[v.ProductInteriorId] = v.Pv
 	}
 	return
 }