Browse Source

Merge branch 'crm/crm_14.7.1' of http://8.136.199.33:3000/hongze/hz_crm_api

xingzai 7 months ago
parent
commit
223a108b56

File diff suppressed because it is too large
+ 554 - 122
controllers/cygx/user.go


+ 94 - 2
models/cygx/article_and_yanxuan_record.go

@@ -26,7 +26,9 @@ type CygxArticleAndYanxuanRecordResp struct {
 // 获取数量
 func GetCygxArticleAndYanxuanRecordCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_and_yanxuan_record as r WHERE 1= 1  `
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_and_yanxuan_record as r
+                  INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id 
+                  WHERE 1= 1  `
 	if condition != "" {
 		sqlCount += condition
 	}
@@ -39,6 +41,7 @@ func GetCygxArticleAndYanxuanRecordCountWeekly(condition string, pars []interfac
 	o := orm.NewOrmUsingDB("hz_cygx")
 	databaseName := utils.GetWeeklyDatabase()
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_and_yanxuan_record as r 
+                             INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id
 				  INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
 		WHERE 1= 1  `
 	sqlCount = fmt.Sprintf(sqlCount, databaseName)
@@ -52,7 +55,8 @@ func GetCygxArticleAndYanxuanRecordCountWeekly(condition string, pars []interfac
 // 列表
 func GetCygxArticleAndYanxuanRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxArticleAndYanxuanRecordResp, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT * FROM cygx_article_and_yanxuan_record as r WHERE 1= 1 `
+	sql := `SELECT r.* ,art.title  FROM cygx_article_and_yanxuan_record as r 
+          INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id  WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}
@@ -66,6 +70,7 @@ func GetCygxArticleAndYanxuanRecordRespListWeekly(condition string, pars []inter
 	o := orm.NewOrmUsingDB("hz_cygx")
 	databaseName := utils.GetWeeklyDatabase()
 	sql := `SELECT r.* FROM cygx_article_and_yanxuan_record as r 
+     		INNER JOIN cygx_article  as art  ON  art.article_id = r.source_id 
 			INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
 		WHERE 1= 1   `
 	sql = fmt.Sprintf(sql, databaseName)
@@ -76,3 +81,90 @@ func GetCygxArticleAndYanxuanRecordRespListWeekly(condition string, pars []inter
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
+
+// 获取研选专栏阅读数量
+func GetCygxYanxuanSpecialRecordCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM 	cygx_yanxuan_special_record AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+		WHERE 1 = 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 获取研选专栏阅读数量
+func GetCygxYanxuanSpecialRecordCountWeekly(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM 	cygx_yanxuan_special_record AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+			INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
+		WHERE 1 = 1  `
+	databaseName := utils.GetWeeklyDatabase()
+	sqlCount = fmt.Sprintf(sqlCount, databaseName)
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 收藏的专栏文章
+func GetCygxYanxuanSpecialCollectCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM 	cygx_yanxuan_special_collect AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+		WHERE 1 = 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 收藏的专栏文章
+func GetCygxYanxuanSpecialCollectCountWeekly(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM 	cygx_yanxuan_special_collect AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+			INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
+		WHERE 1 = 1  `
+	databaseName := utils.GetWeeklyDatabase()
+	sqlCount = fmt.Sprintf(sqlCount, databaseName)
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 关注的专栏作者
+func GetCygxYanxuanSpecialFollowCount(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM 	cygx_yanxuan_special_follow AS r
+			INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
+		WHERE 1 = 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 关注的专栏作者
+func GetCygxYanxuanSpecialFollowCountWeekly(condition string, pars []interface{}) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT COUNT(1) AS count  FROM 	cygx_yanxuan_special_follow AS r
+			INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
+			INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2 
+		WHERE 1 = 1  `
+	databaseName := utils.GetWeeklyDatabase()
+	sqlCount = fmt.Sprintf(sqlCount, databaseName)
+	if condition != "" {
+		sqlCount += condition
+	}
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 271 - 36
models/cygx/cygx_user.go

@@ -1,6 +1,7 @@
 package cygx
 
 import (
+	"fmt"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"hongze/hz_crm_api/models/company"
@@ -352,6 +353,7 @@ type UserInteraction struct {
 	IsEnd                 bool   `description:"是否最后一页,配合前端分页添加的参数"`
 	CurrentIndex          int    `description:"当前页页码,配合前端分页添加的参数"`
 	RegisterPlatform      int    `description:"来源 1小程序,2:网页 ,3:策略平台"`
+	RegisterPlatformText  string `description:"阅读来源(文本描述)"`
 	SourcePlatform        string `description:"来源 'MOBILE:移动端小程序','PC:PC端小程序','CELUE:上海策略平台','WEB:查研观向网页版'"`
 	TagId                 int
 	TagName               string // 标签名
@@ -360,6 +362,8 @@ type UserInteraction struct {
 	Industries            string // 产业
 	SubjectNames          string // 标的
 	SpecialType           int    `description:"专栏类型 1:笔记,2:观点"`
+	ArticleNum            int    // 已发布的文章数量
+	FansNum               int    // 粉丝数量
 }
 
 // 查研观向图表
@@ -455,21 +459,58 @@ func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize
 		1= 1
 			AND is_del = 0  ` + condition
 
-	sql += `  UNION ALL `
+	//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).QueryRows(&items)
+	return
+}
+
+// 用户阅读记录列表
+func GetCygxYanxuaSspecialHistoryRecordByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
 	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.user_id,
+			r.mobile,
+			r.company_id,
+			r.company_name,
+			r.real_name,
 			r.register_platform AS source_platform,
-			r.register_platform,
-			art.type AS special_type
+			art.type AS special_type,
+			art.industry_tags as  industry_name
 		FROM
 			cygx_yanxuan_special_record AS r
-			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id 
+			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 `
@@ -486,10 +527,183 @@ func GetCygxArticleHistoryRecordByUserNew(condition string, startSize, pageSize
 	return
 }
 
+// 用户阅读记录列表
+func GetCygxYanxuaSspecialHistoryRecordByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.title,
+			art.id AS article_id,
+			art.publish_time AS publish_date,
+			r.create_time,
+			r.stop_time,
+			r.user_id,
+			r.mobile,
+			r.company_id,
+			r.company_name,
+			r.real_name,
+			r.register_platform AS source_platform,
+			art.type AS special_type,
+			art.industry_tags as  industry_name
+		FROM
+			cygx_yanxuan_special_record AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+	    	INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2
+		WHERE 1 = 1 ` + condition
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	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).QueryRows(&items)
+	return
+}
+
+// 用户阅读记录列表
+func GetCygxYanxuanSpecialCollectByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.title,
+			art.id AS article_id,
+			art.publish_time AS publish_date,
+			r.create_time,
+			r.register_platform AS source_platform,
+			art.type AS special_type,
+			art.industry_tags as  industry_name
+		FROM
+			cygx_yanxuan_special_collect 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).QueryRows(&items)
+	return
+}
+
+// 用户阅读记录列表
+func GetCygxYanxuanSpecialCollectByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.title,
+			art.id AS article_id,
+			art.publish_time AS publish_date,
+			r.create_time,
+			r.register_platform AS source_platform,
+			art.type AS special_type,
+			art.industry_tags as  industry_name
+		FROM
+			cygx_yanxuan_special_collect AS r
+			INNER JOIN cygx_yanxuan_special AS art ON art.id = r.yanxuan_special_id
+		    INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2
+		WHERE 1 = 1 ` + condition
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	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).QueryRows(&items)
+	return
+}
+
+// 用户阅读记录列表
+func GetCygxYanxuanSpecialAuthorByUser(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.special_name as  title,
+			art.id AS department_id,
+			art.nick_name,
+			art.article_num,
+			art.fans_num,
+			art.company_id,
+			art.company_name,
+			art.mobile_init as  mobile,
+			r.create_time,
+			r.register_platform AS source_platform
+		FROM
+			cygx_yanxuan_special_follow AS r
+			INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_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, department_id DESC   `
+	if startSize > 0 || pageSize > 0 {
+		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
+	}
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// 用户阅读记录列表
+func GetCygxYanxuanSpecialAuthorByUserWeekly(condition string, startSize, pageSize int) (total int, items []*UserInteraction, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	var sql string
+	sql += ` 	SELECT
+			art.special_name as  title,
+			art.id AS department_id,
+			art.nick_name,
+			art.article_num,
+			art.fans_num,
+			art.company_id,
+			art.company_name,
+			art.mobile_init as  mobile,
+			r.create_time,
+			r.register_platform AS source_platform
+		FROM
+			cygx_yanxuan_special_follow AS r
+			INNER JOIN cygx_yanxuan_special_author AS art ON art.user_id = r.follow_user_id
+		   INNER JOIN %s.user_seller_relation AS us ON us.user_id = r.user_id   AND us.product_id = 2
+		WHERE 1 = 1 ` + condition
+	databaseName := utils.GetWeeklyDatabase()
+	sql = fmt.Sprintf(sql, databaseName)
+	totalSql := `SELECT COUNT(1) total FROM (` + sql + `) z `
+	err = o.Raw(totalSql).QueryRow(&total)
+	if err != nil {
+		return
+	}
+
+	sql += ` ORDER BY create_time DESC, department_id DESC   `
+	if startSize > 0 || pageSize > 0 {
+		sql += ` LIMIT ` + strconv.Itoa(startSize) + "," + strconv.Itoa(pageSize)
+	}
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
 // 收藏列表数量
-func GetCygxArticleCollectCount(uid int) (count int, err error) {
+func GetCygxArticleCollectCount(uid int, condition string) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_collect as r INNER JOIN cygx_article AS art ON art.article_id = r.article_id  WHERE   user_id = ?  `
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_article_collect as r INNER JOIN cygx_article AS art ON art.article_id = r.article_id  WHERE   user_id = ?  ` + condition
 	err = o.Raw(sqlCount, uid).QueryRow(&count)
 	return
 }
@@ -571,21 +785,21 @@ func GetCygArticleDepartmentFollowByUser(uid, startSize, pageSize int) (items []
 }
 
 // 用户搜索关键词统计
-func GetCygxSearchKeyWordCount(uid int) (count int, err error) {
+func GetCygxSearchKeyWordCount(uid int, condition string) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_search_key_word  WHERE   user_id = ?  `
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_search_key_word  WHERE   user_id = ?  ` + condition
 	err = o.Raw(sqlCount, uid).QueryRow(&count)
 	return
 }
 
 // 用户搜索关键词列表
-func GetCygxSearchKeyWordByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
+func GetCygxSearchKeyWordByUser(condition string, uid, startSize, pageSize int) (items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT
 			key_word,create_time
 		FROM
 			cygx_search_key_word as k
-			WHERE user_id = ?
+			WHERE user_id = ? ` + condition + `
 			ORDER BY  k.create_time DESC LIMIT ?,? `
 	_, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
 	return
@@ -903,45 +1117,66 @@ ORDER BY
 }
 
 type GetUserInteractionTableCountResp struct {
-	HistoryNum          int `description:"报告阅读"`
-	CountNum            int `description:"报告收藏"`
-	IndustryFllowNum    int `description:"产业关注"`
-	DepartmentFollowNum int `description:"作者关注"`
-	KeyWordNum          int `description:"搜索关键词"`
-	OnLineNum           int `description:"线上互动活动"`
-	OfficeNum           int `description:"线下互动活动"`
-	ActivityNum         int `description:"活动数量"`
-	ChartNum            int `description:"图表数量"`
-	TripNum             int `description:"图表数量"`
-	RoadshowVideoNum    int `description:"产业视频播放量"`
-	ActivityVideoNum    int `description:"活动视频播放量"`
-	ActivityVoiceNum    int `description:"活动音频播放量"`
-	TagNum              int `description:"首页标签点击量"`
-	YanxuanSpecialNum   int `description:"研选专栏阅读数量"`
+	HistoryNum               int `description:"报告阅读"`
+	CountNum                 int `description:"报告收藏"`
+	IndustryFllowNum         int `description:"产业关注"`
+	DepartmentFollowNum      int `description:"作者关注"`
+	KeyWordNum               int `description:"搜索关键词"`
+	OnLineNum                int `description:"线上互动活动"`
+	OfficeNum                int `description:"线下互动活动"`
+	ActivityNum              int `description:"活动数量"`
+	ChartNum                 int `description:"图表数量"`
+	TripNum                  int `description:"图表数量"`
+	RoadshowVideoNum         int `description:"产业视频播放量"`
+	ActivityVideoNum         int `description:"活动视频播放量"`
+	ActivityVoiceNum         int `description:"活动音频播放量"`
+	TagNum                   int `description:"首页标签点击量"`
+	YanxuanSpecialNum        int `description:"研选专栏阅读数量"`
+	YanxuanSpecialCollectNum int `description:"研选专栏收藏数量"`
+	YanxuanSpecialFollowNum  int `description:"研选专栏作者关注数量"`
 }
 
 // 用户互动总数统计
 func GetUserInteractionTableCount(uid int) (item *GetUserInteractionTableCountResp, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT
-			( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.user_id = ?  AND h.is_del = 0 ) AS history_num,
-			( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.user_id = ? AND  h.article_id > 0  ) AS count_num,
+			( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.user_id = ?  AND h.is_del = 0    AND art.article_type_id = 0   ) AS history_num,
+			( SELECT COUNT( 1 ) FROM cygx_article_collect AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.user_id = ?  AND art.article_type_id = 0   ) AS count_num,
 			( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h INNER JOIN cygx_chart_all AS a ON h.chart_id = a.chart_id WHERE h.user_id = ?  ) AS chart_num,
-			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = ? AND h.type = 1  AND  h.source   IN (0,1,2)  ) AS industry_fllow_num,
-			( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = ?  AND h.type = 1  ) AS department_follow_num,
-			( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ?  ) AS key_word_num,
+			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h INNER JOIN   cygx_industrial_management  as   a  ON a.industrial_management_id  = h.industrial_management_id   WHERE h.user_id = ? AND h.type = 1  AND  h.source   IN (0,1,2)  AND a.chart_permission_id  != 31   ) AS industry_fllow_num,
+			( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ?   AND  h.register_platform IN(1,2) ) AS key_word_num,
 			( SELECT 	COUNT( DISTINCT a.activity_id )  as count  FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.user_id = ? 
-					  AND t.activity_type=1 AND h.do_fail_type = 0   ) AS on_line_num,
+					  AND t.activity_type=1 AND h.do_fail_type = 0  AND  a.chart_permission_id  != 31  ) AS on_line_num,
 			( SELECT  	COUNT( DISTINCT a.activity_id )  as count  FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.user_id = ?
-				  AND t.activity_type = 0 AND h.do_fail_type = 0  ) AS office_num,
+				  AND t.activity_type = 0 AND h.do_fail_type = 0  AND a.chart_permission_id  != 31 ) AS office_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_special_meeting_detail AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.user_id = ?  AND a.publish_status = 1 AND a.activity_time_end < NOW()) AS trip_num,
 			( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h  INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE  h.user_id = ?  ) AS roadshow_video_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS h  INNER JOIN cygx_activity_video as v ON v.video_id = h.video_id WHERE  h.user_id = ?  ) AS activity_video_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h  INNER JOIN cygx_activity_voice as v ON v.activity_id = h.activity_id WHERE  h.user_id = ?  ) AS activity_voice_num,
-			( SELECT COUNT(1) FROM cygx_tag_history as h INNER JOIN cygx_tag AS b ON h.tag_id = b.tag_id WHERE h.user_id = ?  ) AS tag_num,
+			( SELECT COUNT(1) FROM cygx_tag_history as h INNER JOIN cygx_tag AS b ON h.tag_id = b.tag_id WHERE h.user_id = ?  ) AS tag_num
+			FROM  dual `
+	err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
+	return
+}
+
+// 用户互动总数统计
+func GetUserInteractionTableCountByYanXuan(uid int) (item *GetUserInteractionTableCountResp, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT
+			( SELECT COUNT( 1 ) FROM cygx_article_history_record_all AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.user_id = ?  AND h.is_del = 0    AND art.article_type_id > 0   ) AS history_num,
+			( SELECT COUNT( 1 ) FROM cygx_article_collect AS h  INNER JOIN cygx_article  as art  ON  art.article_id = h.article_id  WHERE h.user_id = ?  AND art.article_type_id > 0   ) AS count_num,
+			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h INNER JOIN   cygx_industrial_management  as   a  ON a.industrial_management_id  = h.industrial_management_id   WHERE h.user_id = ? AND h.type = 1  AND  h.source   IN (0,1,2)  AND a.chart_permission_id  = 31   ) AS industry_fllow_num,
+			( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = ?  AND h.type = 1  ) AS department_follow_num,
+			( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = ?   AND  h.register_platform IN(5,6) ) AS key_word_num,
+			( SELECT 	COUNT( DISTINCT a.activity_id )  as count  FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.user_id = ? 
+					  AND t.activity_type=1 AND h.do_fail_type = 0  AND  a.chart_permission_id  = 31    ) AS on_line_num,
+			( SELECT  	COUNT( DISTINCT a.activity_id )  as count  FROM cygx_activity_signup_detail AS h INNER JOIN cygx_activity as a ON a.activity_id = h.activity_id  INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id   WHERE h.user_id = ?
+				  AND t.activity_type = 0 AND h.do_fail_type = 0  AND  a.chart_permission_id  = 31    ) AS office_num,
+			( SELECT COUNT(1) FROM cygx_yanxuan_special_collect as h INNER JOIN cygx_yanxuan_special AS b ON h.yanxuan_special_id = b.id WHERE h.user_id = ?  ) AS yanxuan_special_collect_num,
+			( SELECT COUNT(1) FROM cygx_yanxuan_special_follow as h WHERE h.user_id = ?  ) AS yanxuan_special_follow_num,
 			( SELECT COUNT(1) FROM cygx_yanxuan_special_record as h INNER JOIN cygx_yanxuan_special AS b ON h.yanxuan_special_id = b.id WHERE h.user_id = ?  ) AS yanxuan_special_num
 			FROM  dual `
-	err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
+	err = o.Raw(sql, uid, uid, uid, uid, uid, uid, uid, uid, uid, uid).QueryRow(&item)
 	return
 }
 

+ 0 - 128
models/cygx/cygx_user_company.go

@@ -1105,134 +1105,6 @@ func GetCygxActivitySpecialTripByCompanyList(condition string, startSize, pageSi
 	return
 }
 
-// 通过纪要ID获取活动详情
-func GetTableCompanyList() (item *GetUserInteractionTableCountResp, err error) {
-	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT
-	SUM( article_history_num ) AS history_num,
-	SUM( article_count_num ) AS count_num,
-	SUM( industry_fllow_num ) AS industry_fllow_num,
-	SUM( department_follow_num ) AS department_follow_num,
-	SUM( key_word_num ) AS key_word_num,
-	SUM( activity_num ) AS activity_num,
-	SUM( chart_count_num ) AS chart_num 
-FROM
-	cygx_company_interaction_num 
-	LIMIT 1`
-	err = o.Raw(sql).QueryRow(&item)
-	return
-}
-
-// 获取用户参会记录根据销售分组
-func GetActivityMeetBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	return
-	o := orm.NewOrm()
-	sqlCount := `				SELECT
-				p.seller_id as admin_id,count(DISTINCT(r.company_id)) num,GROUP_CONCAT(DISTINCT r.company_id SEPARATOR ',') AS company_ids
-			FROM
-				cygx_activity_signup AS r
-				INNER JOIN cygx_activity AS a ON a.activity_id = r.activity_id
-				INNER JOIN cygx_activity_type as t ON t.activity_type_id = a.activity_type_id
-				INNER JOIN wx_user AS u ON u.user_id = r.user_id 
-				INNER JOIN company_product AS p ON p.company_id=r.company_id
-			WHERE
-				1 = 1 
-				AND r.do_fail_type = 0
-				AND p.product_id = 2
-				`
-	if condition != "" {
-		sqlCount += condition
-	}
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 收藏列表数量根据销售分组
-func GetCygxArticleCollectCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	return // 没有使用了
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id as admin_id,count(DISTINCT(r.company_id)) num,GROUP_CONCAT(DISTINCT r.company_id SEPARATOR ',') AS company_ids
-FROM
-	cygx_article_collect AS r
-	INNER JOIN cygx_article AS art ON art.article_id = r.article_id
-	INNER JOIN wx_user AS u ON u.user_id = r.user_id 
-	INNER JOIN company_product AS p ON p.company_id=r.company_id
-WHERE
-	1 = 1
-	AND p.product_id=2  ` + condition
-
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 关注产业数量根据销售分组
-func GetCygxIndustryFllowCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id AS admin_id,
-	count(
-	DISTINCT ( r.company_id )) num,
-	GROUP_CONCAT( DISTINCT r.company_id SEPARATOR ',' ) AS company_ids 
-FROM
-	cygx_industry_fllow AS r
-	INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = r.industrial_management_id
-	INNER JOIN wx_user AS u ON u.user_id = r.user_id
-	INNER JOIN company_product AS p ON p.company_id = r.company_id 
-WHERE
-	type = 1 
-	AND p.product_id = 2 
-  ` + condition
-
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 关注作者数量根据销售分组
-func GetCygArticleDepartmentFollowCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	return // 没有使用了
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id AS admin_id,
-	count(
-	DISTINCT ( r.company_id )) num,
-	GROUP_CONCAT( DISTINCT r.company_id SEPARATOR ',' ) AS company_ids 
-FROM
-	cygx_article_department_follow AS r
-	INNER JOIN cygx_article_department AS m ON m.department_id = r.department_id
-	INNER JOIN wx_user AS u ON u.user_id = r.user_id
-	INNER JOIN company_product AS p ON p.company_id = r.company_id 
-WHERE
-	type = 1 
-	AND p.product_id = 2  ` + condition
-
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
-// 用户搜索关键词统计根据销售分组
-func GetCygxSearchKeyWordCountBySeller(condition string) (list []*company.CompanyReportRecordGroup, err error) {
-	o := orm.NewOrm()
-	sqlCount := ` SELECT
-	p.seller_id AS admin_id,
-	count(
-	DISTINCT ( r.company_id )) num,
-	GROUP_CONCAT( DISTINCT r.company_id SEPARATOR ',' ) AS company_ids 
-FROM
-	cygx_search_key_word AS r 
-	INNER JOIN company_product AS p ON p.company_id = r.company_id 
-WHERE
-	1 = 1
-	AND p.product_id = 2  ` + condition
-	sqlCount += ` GROUP BY p.seller_id `
-	_, err = o.Raw(sqlCount).QueryRows(&list)
-	return
-}
-
 type CompanyAndCount struct {
 	CompanyId int
 	Count     int

+ 12 - 10
models/cygx/industry_fllow.go

@@ -38,29 +38,31 @@ func GetCygxIndustryFllowList(condition string, pars []interface{}, startSize, p
 }
 
 // 关注产业列表
-func GetCygxIndustryFllowByUser(uid, startSize, pageSize int) (items []*UserInteraction, err error) {
+func GetCygxIndustryFllowByUser(uid, startSize, pageSize int, condition string) (items []*UserInteraction, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
 	sql := `SELECT
-			m.industry_name,
+			a.industry_name,
 			f.modify_time as create_time,
-			( SELECT GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' ) FROM cygx_industrial_subject AS s WHERE s.industrial_management_id = m.industrial_management_id ) AS subject_name_str 
+			( SELECT GROUP_CONCAT( DISTINCT s.subject_name SEPARATOR '/' ) FROM cygx_industrial_subject AS s WHERE s.industrial_management_id = f.industrial_management_id ) AS subject_name_str 
 		FROM
 			cygx_industry_fllow AS f
-			INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = f.industrial_management_id 
+			INNER JOIN cygx_industrial_management AS a ON a.industrial_management_id = f.industrial_management_id 
 		WHERE
-			user_id = ? 
-			AND type = 1 
-			AND f.source  IN (0,1,2)
-		ORDER BY
+			f.user_id = ? 
+			AND f.type = 1 
+			AND f.source  IN (0,1,2) ` + condition +
+		`ORDER BY
 			f.create_time DESC  LIMIT ?,? `
 	_, err = o.Raw(sql, uid, startSize, pageSize).QueryRows(&items)
 	return
 }
 
 // 关注产业数量
-func GetCygxIndustryFllowCount(uid int) (count int, err error) {
+func GetCygxIndustryFllowCount(uid int, condition string) (count int, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_industry_fllow  WHERE   user_id = ?  AND type = 1 AND  source   IN (0,1,2)  `
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_industry_fllow  as  f
+                           INNER JOIN   cygx_industrial_management  as   a  ON a.industrial_management_id  = f.industrial_management_id 
+                           WHERE   f.user_id = ?  AND f.type = 1 AND  f.source   IN (0,1,2)  ` + condition
 	err = o.Raw(sqlCount, uid).QueryRow(&count)
 	return
 }

+ 22 - 0
services/cygx/article.go

@@ -88,6 +88,27 @@ func GetArticleSourcePlatform(SourcePlatform string) (sourcePlatformResp int) {
 		sourcePlatformResp = 1
 	} else if SourcePlatform == "2" {
 		sourcePlatformResp = 2
+	} else {
+		sourcePlatformResp = 1
+	}
+	return
+}
+
+// 处理文章来源类型
+func GetArticleSourcePlatformText(sourcePlatformResp int) (sourcePlatformText string) {
+	switch sourcePlatformResp {
+	case 1:
+		sourcePlatformText = "查研小程序"
+	case 2:
+		sourcePlatformText = "查研网页版"
+	case 3:
+		sourcePlatformText = "策略平台"
+	case 5:
+		sourcePlatformText = "研选小程序"
+	case 6:
+		sourcePlatformText = "研选网页版"
+	default:
+		sourcePlatformText = "查研小程序"
 	}
 	return
 }
@@ -291,6 +312,7 @@ func HandleArticleAndYanxuanRecordList(items []*cygx.CygxArticleAndYanxuanRecord
 			item.CompanyName = v.CompanyName
 			item.SellerName = sellNameMap[v.CompanyId]
 			item.RegisterPlatform = v.RegisterPlatform
+			item.RegisterPlatformText = GetArticleSourcePlatformText(v.RegisterPlatform)
 			item.StopTime = strconv.Itoa(v.StopTime)
 			itemsResp = append(itemsResp, item)
 		}

Some files were not shown because too many files changed in this diff