xingzai 1 an în urmă
părinte
comite
e7d410425a
2 a modificat fișierele cu 44 adăugiri și 19 ștergeri
  1. 19 19
      controllers/report.go
  2. 25 0
      models/report_mapping.go

+ 19 - 19
controllers/report.go

@@ -41,7 +41,7 @@ func (this *MobileReportController) TradeList() {
 		br.Ret = 408
 		return
 	}
-	uid := user.UserId
+	//uid := user.UserId
 	ChartPermissionId, _ := this.GetInt("ChartPermissionId")
 	if ChartPermissionId < 1 {
 		br.Msg = "请输入分类ID"
@@ -52,7 +52,7 @@ func (this *MobileReportController) TradeList() {
 	var err error
 	mapCategory := make(map[int]int)
 	if ChartPermissionId == utils.CE_LUE_ID || ChartPermissionId == utils.GU_SHOU_ID {
-		listTrade, errTrade := models.GetReportMappingStrategyHomeAll(user.UserId, ChartPermissionId)
+		listTrade, errTrade := models.GetReportMappingStrategyHomeAllByCygx(user.UserId, ChartPermissionId)
 		list = listTrade
 		err = errTrade
 
@@ -68,23 +68,23 @@ func (this *MobileReportController) TradeList() {
 				mapCategory[v.CategoryId] = v.CategoryId
 			}
 		}
-		for k, v := range list {
-			count, err := models.GetUserIsReadThisNewCategoryArticleCount(v.CategoryId, uid)
-			if err != nil && err.Error() != utils.ErrNoRow() {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
-				return
-			}
-			Newdetail, err := models.GetNewArticleByCategoryId(v.CategoryId)
-			if err != nil {
-				br.Msg = "获取信息失败"
-				br.ErrMsg = "获取信息失败,Err:" + err.Error()
-				return
-			}
-			if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
-				list[k].IsRed = true
-			}
-		}
+		//for k, v := range list {
+		//count, err := models.GetUserIsReadThisNewCategoryArticleCount(v.CategoryId, uid)
+		//if err != nil && err.Error() != utils.ErrNoRow() {
+		//	br.Msg = "获取信息失败"
+		//	br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
+		//	return
+		//}
+		//Newdetail, err := models.GetNewArticleByCategoryId(v.CategoryId)
+		//if err != nil {
+		//	br.Msg = "获取信息失败"
+		//	br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		//	return
+		//}
+		//if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
+		//	list[k].IsRed = true
+		//}
+		//}
 	} else {
 		listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
 		if err != nil {

+ 25 - 0
models/report_mapping.go

@@ -78,6 +78,31 @@ func GetReportMappingStrategyHomeAll(userId, ChartPermissionId int) (items []*Tr
 	return
 }
 
+// 获取策略下面的所有分类
+func GetReportMappingStrategyHomeAllByCygx(userId, chartPermissionId int) (items []*TradeReportMapping, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			MAX( art.publish_date ) AS update_time,
+			(SELECT COUNT(1) FROM cygx_article_history_record AS rec WHERE rec.user_id = ` + strconv.Itoa(userId) + ` AND  rec.article_id=art.article_id) AS readnum,
+			re.id AS category_id,
+			re.match_type_name 
+		FROM
+			cygx_report_mapping_cygx AS re
+			INNER JOIN cygx_report_mapping_group AS mg ON mg.id_cygx = re.id
+			INNER JOIN cygx_article AS art ON art.category_id = mg.category_id_celue 
+		WHERE
+			1 = 1 
+			AND re.chart_permission_id = ? 
+			AND re.report_type = 1 
+		GROUP BY
+			re.match_type_name 
+		ORDER BY
+			sort DESC,
+			art.publish_date DESC`
+	_, err = o.Raw(sql, chartPermissionId).QueryRows(&items)
+	return
+}
+
 // 行业列表
 func GetTradeAll(ChartPermissionId int) (items []*TradeReportMapping, err error) {
 	o := orm.NewOrm()