xingzai 1 yıl önce
ebeveyn
işleme
c7cde1a8b3
3 değiştirilmiş dosya ile 54 ekleme ve 15 silme
  1. 15 8
      controllers/cygx/user.go
  2. 35 7
      models/cygx/cygx_user.go
  3. 4 0
      services/cygx/article.go

+ 15 - 8
controllers/cygx/user.go

@@ -738,13 +738,16 @@ func (this *UserController) TableDetail() {
 		if wxUser.Mobile == "" {
 			wxUser.Mobile = wxUser.Email
 		}
-		total, err = cygx.GetCygxArticleHistoryCount(wxUser.Mobile, wxUser.Email, condition)
-		if err != nil {
-			br.Msg = "获取信息失败"
-			br.ErrMsg = "获取用户阅读记录总数失败,Err:" + err.Error()
-			return
-		}
-		list, err = cygx.GetCygxArticleHistoryRecordByUserNew(wxUser.Mobile, wxUser.Email, condition, startSize, pageSize)
+		//total, err = cygx.GetCygxArticleHistoryCount(wxUser.Mobile, wxUser.Email, condition)
+		//if err != nil {
+		//	br.Msg = "获取信息失败"
+		//	br.ErrMsg = "获取用户阅读记录总数失败,Err:" + err.Error()
+		//	return
+		//}
+
+		condition += " 	AND (r.mobile = '" + wxUser.Mobile + "'  OR  r.email = '" + wxUser.Mobile + "')  "
+
+		total, list, err = cygx.GetCygxArticleHistoryRecordByUserNew(condition, startSize, pageSize)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取信息失败"
 			br.ErrMsg = "获取用户阅读记录,Err:" + err.Error()
@@ -792,7 +795,11 @@ func (this *UserController) TableDetail() {
 			//行业
 			mapPerssionName := cygxService.GetCygxArticlePerssionNameListMap(articleIdArr)
 			for k, v := range list {
-				list[k].PermissionName = mapPerssionName[v.ArticleId]
+				if v.SpecialType > 0 {
+					list[k].PermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN
+				} else {
+					list[k].PermissionName = mapPerssionName[v.ArticleId]
+				}
 			}
 		}
 

+ 35 - 7
models/cygx/cygx_user.go

@@ -446,9 +446,10 @@ func GetCygxArticleHistoryRecordByUser(mobile, email, condition string, startSiz
 }
 
 // 用户阅读记录列表 2023-08-02 优化拆分
-func GetCygxArticleHistoryRecordByUserNew(mobile, email, condition string, startSize, pageSize int) (items []*UserInteraction, err error) {
+func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := ` SELECT
+	var sql string
+	sql += `SELECT
 			art.title,
 			art.article_id,
 			art.article_id_md5,
@@ -456,17 +457,44 @@ func GetCygxArticleHistoryRecordByUserNew(mobile, email, condition string, start
 			art.category_name,
 			r.create_time,
 			r.stop_time,
-			r.source as source_platform
+			r.source AS source_platform,
+			'' AS register_platform,
+			'' AS special_type
 		FROM
 			cygx_article_history_record_all AS r
-			INNER JOIN cygx_article AS art ON art.article_id = r.article_id
+			INNER JOIN cygx_article AS art ON art.article_id = r.article_id 
 		WHERE
-			 r.mobile  = ?  AND is_del = 0 ` + condition + `  OR ( email = ? AND email <>''  AND is_del = 0 ` + condition + `  )
-			 ORDER BY  r.create_time DESC   `
+		1= 1
+			AND is_del = 0  ` + condition
+
+	sql += `  UNION ALL `
+	sql += ` 	SELECT
+			art.title,
+			art.id AS article_id,
+			'' AS article_id_md5,
+			art.publish_time AS publish_date,
+			'' AS category_name,
+			r.create_time,
+			r.stop_time,
+			r.register_platform AS source_platform,
+			r.register_platform,
+			art.type AS special_type
+		FROM
+			cygx_yanxuan_special_record AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id 
+		WHERE 1 = 1 ` + condition
+
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql += ` ORDER BY create_time DESC, article_id DESC   `
 	if startSize > 0 || pageSize > 0 {
 		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
 	}
-	_, err = o.Raw(sql, mobile, email).QueryRows(&items)
+	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
 

+ 4 - 0
services/cygx/article.go

@@ -84,6 +84,10 @@ func GetArticleSourcePlatform(SourcePlatform string) (sourcePlatformResp int) {
 		sourcePlatformResp = 2
 	} else if SourcePlatform == "CELUE" {
 		sourcePlatformResp = 3
+	} else if SourcePlatform == "1" {
+		sourcePlatformResp = 1
+	} else if SourcePlatform == "2" {
+		sourcePlatformResp = 2
 	}
 	return
 }