|
@@ -1,7 +1,9 @@
|
|
|
package models
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
+ "hongze/hongze_cygx/utils"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
@@ -74,3 +76,259 @@ func AddCygxUserInteractionNumList(items []*CygxUserInteractionNum) (lastId int6
|
|
|
_, err = o.InsertMulti(1, items)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+// 联系人互动数量
|
|
|
+type CygxUserInteractionNumResp struct {
|
|
|
+ UserId int `description:"用户ID"`
|
|
|
+ CompanyId int `description:"公司ID"`
|
|
|
+ InteractionNum int `description:"互动数量"`
|
|
|
+}
|
|
|
+
|
|
|
+// 用户阅读记录数量统计
|
|
|
+func GetCygxArticleHistoryRecordInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_article_history_record_all AS h
|
|
|
+ INNER JOIN cygx_article AS art ON art.article_id = h.article_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户收藏文章数量统计
|
|
|
+func GetCygxArticleCollectInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_article_collect AS h
|
|
|
+ INNER JOIN cygx_article AS art ON art.article_id = h.article_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户收藏图表数量统计
|
|
|
+func GetCygxChartCollectInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_chart_collect AS h
|
|
|
+ INNER JOIN cygx_chart_all AS art ON art.chart_id = h.chart_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户关注产业数量统计
|
|
|
+func GetCygxIndustryFllowInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_industry_fllow AS h
|
|
|
+ INNER JOIN cygx_industrial_management AS art ON art.industrial_management_id = h.industrial_management_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 AND h.type = 1 AND h.source IN (0,1,2) ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户搜索关键词数量统计
|
|
|
+func GetCygxSearchKeyWordInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_search_key_word AS h
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户活动报名参会数量统计
|
|
|
+func GetCygxActivitySignupInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_activity_signup_detail AS h
|
|
|
+ INNER JOIN cygx_activity AS art ON art.activity_id = h.activity_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户专项调研活动报名参会数量统计
|
|
|
+func GetCygxActivitySpecialSignupInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_activity_special_meeting_detail AS h
|
|
|
+ INNER JOIN cygx_activity_special AS art ON art.activity_id = h.activity_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户路演精华播放数量统计
|
|
|
+func GetCygxMicroRoadshowVideoHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_micro_roadshow_video_history AS h
|
|
|
+ INNER JOIN cygx_micro_roadshow_video AS art ON art.video_id = h.video_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户活动视频播放数量统计
|
|
|
+func GetCygxActivityVideoHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_activity_video_history AS h
|
|
|
+ INNER JOIN cygx_activity_video AS art ON art.activity_id = h.activity_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户活动音频播放数量统计
|
|
|
+func GetCygxActivityVoiceHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_activity_voice_history AS h
|
|
|
+ INNER JOIN cygx_activity_voice AS art ON art.activity_id = h.activity_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户首页标签点击量数量统计
|
|
|
+func GetCygxTagHistoryInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_tag_history AS h
|
|
|
+ INNER JOIN cygx_tag AS art ON art.tag_id = h.tag_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户关注研选作者数量统计
|
|
|
+func GetCygxArticleDepartmentFollowInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_article_department_follow AS h
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户关注研选专栏作者数量统计
|
|
|
+func GetCygxYanxuanSpecialFollowInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_follow AS h
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// 用户研选专栏阅读数量数量统计
|
|
|
+func GetCygxYanxuanSpecialRecordInteractionNum(condition string) (items []*CygxUserInteractionNumResp, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ var sql string
|
|
|
+ sql += ` SELECT
|
|
|
+ COUNT( 1 ) AS interaction_num,
|
|
|
+ w.user_id,
|
|
|
+ w.company_id
|
|
|
+ FROM
|
|
|
+ cygx_yanxuan_special_record AS h
|
|
|
+ INNER JOIN cygx_yanxuan_special AS art ON art.id = h.yanxuan_special_id
|
|
|
+ INNER JOIN %s.wx_user AS w ON w.user_id = h.user_id WHERE 1=1 ` + condition + ` GROUP BY w.user_id `
|
|
|
+ databaseName := utils.GetWeeklyDatabase()
|
|
|
+ sql = fmt.Sprintf(sql, databaseName)
|
|
|
+ _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ return
|
|
|
+}
|