瀏覽代碼

no message

xingzai 1 年之前
父節點
當前提交
5807f4a4d1

+ 1 - 0
models/product_interior.go

@@ -54,6 +54,7 @@ type CygxProductInteriorResp struct {
 	VisibleRange      int                       `description:"设置可见范围1全部,0内部"`
 	Abstract          string                    `description:"摘要"`
 	Department        string                    `description:"作者"`
+	Pv                int                       `description:"PV"`
 }
 
 type ProductInteriorUrlResp struct {

+ 17 - 0
models/product_interior_history.go

@@ -37,3 +37,20 @@ func GetCygxProductInteriorHistoryList(condition string, pars []interface{}) (it
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+type ListProductInteriorPvResp struct {
+	ProductInteriorId int `description:"文章ID"`
+	Pv                int `description:"pv"`
+}
+
+// 列表
+func GetCygxProductInteriorHistoryListPv(condition string, pars []interface{}) (items []*ListProductInteriorPvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  product_interior_id ,COUNT(*)  as  pv  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
+}

+ 17 - 0
models/report_history_record.go

@@ -56,3 +56,20 @@ func AddCygxReportHistoryRecordLog(item *CygxReportHistoryRecordLog) (lastId int
 	lastId, err = o.Insert(item)
 	return
 }
+
+type ListPvResp struct {
+	ArticleId int `description:"文章ID"`
+	Pv        int `description:"pv"`
+}
+
+// 列表
+func GetCygxReportHistoryRecordListPv(condition string, pars []interface{}) (items []*ListPvResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  article_id ,COUNT(*)  as  pv  FROM cygx_report_history_record WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += " GROUP BY article_id "
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 1 - 0
models/report_selection.go

@@ -18,6 +18,7 @@ type CygxReportSelectionRep struct {
 	SubjectName       string `description:"标的名称"`
 	Periods           string `description:"期数"`
 	MarketStrategy    string `description:"市场策略核心逻辑汇总"`
+	Pv                int    `description:"pv"`
 }
 
 type CygxReportSelectionListPublicRep struct {

+ 28 - 0
services/product_interior.go

@@ -219,3 +219,31 @@ func GetCygxProductInteriorHistoryListMap(productInteriorIs []int, user *models.
 	}
 	return
 }
+
+// 获取产品内测的阅读数据
+func GetCygxProductInteriorHistoryListPvMap(productInteriorIs []int) (mapPv map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("获取产品内测的阅读数据,信息失败,Err:"+err.Error(), 3)
+		}
+	}()
+	lenproductInteriorIs := len(productInteriorIs)
+	if lenproductInteriorIs == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND product_interior_id IN (` + utils.GetOrmInReplace(lenproductInteriorIs) + `) `
+	pars = append(pars, productInteriorIs)
+	list, err := models.GetCygxProductInteriorHistoryList(condition, pars)
+	if err != nil {
+		return
+	}
+	mapPv = make(map[int]int, 0)
+	for _, v := range list {
+		mapPv[v.ProductInteriorId]++
+	}
+	return
+}

+ 27 - 0
services/report_history_record.go

@@ -39,3 +39,30 @@ func AddCygxReportHistoryRecord(item *models.CygxReportHistoryRecord) (err error
 	}
 	return
 }
+
+// 获取 报告精选,本周研究汇总、上周纪要汇总Pv 阅读数据
+func GetCygxReportHistoryRecordListMap(articleIds []int, reportType string) (mapPv map[int]int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("获取产品内测的阅读数据,信息失败,Err:"+err.Error(), 3)
+		}
+	}()
+	lenArr := len(articleIds)
+	if lenArr == 0 {
+		return
+	}
+	var condition string
+	var pars []interface{}
+	condition = ` AND article_id IN (` + utils.GetOrmInReplace(lenArr) + `) AND  report_type = ?`
+	pars = append(pars, articleIds, reportType)
+	list, e := models.GetCygxReportHistoryRecordListPv(condition, pars)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		return
+	}
+	mapPv = make(map[int]int, 0)
+	for _, v := range list {
+		mapPv[v.ArticleId] = v.Pv
+	}
+	return
+}

+ 8 - 0
services/resource_data.go

@@ -125,7 +125,9 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			err = errors.New("GetResourceDataList, Err: " + e.Error())
 			return
 		}
+		mapPv := GetCygxReportHistoryRecordListMap(minutessummaryIds, "szjyhz")
 		for _, v := range listresearchsummary {
+			v.Pv = mapPv[v.ArticleId]
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
 			mapItems[fmt.Sprint("minutessummary", v.ArticleId)].Minutessummary = v
 		}
@@ -142,7 +144,9 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			err = errors.New("GetReportSelectionListHome, Err: " + e.Error())
 			return
 		}
+		mapPv := GetCygxReportHistoryRecordListMap(minutessummaryIds, "bzyjhz")
 		for _, v := range listresearchsummary {
+			v.Pv = mapPv[v.ArticleId]
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
 			mapItems[fmt.Sprint("researchsummary", v.ArticleId)].Researchsummary = v
 		}
@@ -158,8 +162,10 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			err = errors.New("GetCygxProductInteriorList, Err: " + e.Error())
 			return
 		}
+		ProductInteriorHistoryMap := GetCygxProductInteriorHistoryListPvMap(articleIds)
 		for _, v := range listProductInterior {
 			v.Body = ProductInteriorHtml(v.Body)
+			v.Pv = ProductInteriorHistoryMap[v.ProductInteriorId]
 			v.PublishTime = utils.TimeRemoveHms2(v.PublishTime)
 			mapItems[fmt.Sprint("productinterior", v.ProductInteriorId)].ProductInterior = v
 		}
@@ -434,10 +440,12 @@ func GetResourceDataList(condition string, pars []interface{}, startSize, pageSi
 			err = errors.New("GetReportSelectionList, Err: " + e.Error())
 			return
 		}
+		mapPv := GetCygxReportHistoryRecordListMap(reportselectionIds, "bgjx")
 		for _, v := range listreportselection {
 			v.Title += "(第" + v.Periods + "期)"
 			v.MarketStrategy = AnnotationHtml(v.MarketStrategy)
 			v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+			v.Pv = mapPv[v.ArticleId]
 			mapItems[fmt.Sprint("reportselection", v.ArticleId)].ReportSelection = v
 		}
 	}