Browse Source

1,把弘则机构的阅读记录加入到用户统计
2,取消关注作者,直接删除对应数据
3,完善用户互动详情定时任务

xingzai 2 years ago
parent
commit
43ce729ef7

+ 1 - 1
controllers/article.go

@@ -690,7 +690,7 @@ func (this *ArticleController) AddStopTime() {
 				}
 
 				//不统计本公司的阅读记录、正常退出的不做时间差统计
-				if user.CompanyId != 16 && stopTime > 3 {
+				if stopTime > 3 {
 					key := "CYGX_ARTICLE_PV" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid) + "_" + strconv.Itoa(user.CompanyId) + "_" + strconv.Itoa(outType)
 					record := new(models.CygxArticleHistoryRecordNewpv)
 					record.UserId = uid

+ 16 - 0
models/activity_signup.go

@@ -547,3 +547,19 @@ func AddCygxActivityRestrictSignup(item *CygxActivityRestrictSignup) (err error)
 	_, err = o.Insert(item)
 	return
 }
+
+//获取列表信息根据手机号分组
+func GetCygxActivitySignupByMobileList(condition string) (items []*CygxActivitySignup, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_signup  WHERE  1= 1 ` + condition + `  GROUP BY mobile  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户关注作者的相关信息
+func UpdateCygxActivitySignup(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_activity_signup SET email=?,company_id=?,company_name=?,mobile=?,real_name=? WHERE  user_id=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.Mobile, wxUser.RealName, wxUser.UserId).Exec()
+	return
+}

+ 15 - 0
models/article_collect.go

@@ -67,3 +67,18 @@ type ArticleCollectList struct {
 	CategoryName    string `description:"一级分类"`
 	SubCategoryName string `description:"二级分类"`
 }
+
+func GetCygxArticleCollectList(condition string) (items []*CygxArticleCollect, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_collect  WHERE 1 =1   ` + condition + ` GROUP BY user_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户收藏文章的相关信息
+func UpdateCygxArticleCollect(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_article_collect SET email=?,company_id=?,company_name=?,mobile=?,real_name=? WHERE user_id=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.Mobile, wxUser.RealName, wxUser.UserId).Exec()
+	return
+}

+ 18 - 2
models/article_department_follow.go

@@ -37,8 +37,8 @@ type CygxArticleDepartmentFollowResp struct {
 
 func RemoveArticleDepartmentFollow(userId, industrialManagementId, doType int) (err error) {
 	o := orm.NewOrm()
-	sql := `UPDATE cygx_article_department_follow SET type = ? ,modify_time=? WHERE user_id=? AND department_id=? `
-	_, err = o.Raw(sql, doType, time.Now(), userId, industrialManagementId).Exec()
+	sql := `DELETE FROM cygx_article_department_follow WHERE user_id=? AND department_id=? `
+	_, err = o.Raw(sql, userId, industrialManagementId).Exec()
 	return
 }
 
@@ -55,3 +55,19 @@ func GetArticleDepartmentFollowByUid(userId int) (count int, err error) {
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
 	return
 }
+
+//获取列表信息根据手机号分组
+func GetArticleDepartmentFollowByMobileList(condition string) (items []*CygxArticleDepartmentFollow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_department_follow  WHERE 1 =1  ` + condition + `  GROUP BY user_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户关注作者的相关信息
+func UpdateCygxArticleDepartmentFollow(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_article_department_follow SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	return
+}

+ 17 - 1
models/article_history_record_newpv.go

@@ -43,7 +43,7 @@ func AddCygxArticleViewRecordNewpv(item *CygxArticleHistoryRecordNewpv) (lastId
 	record := new(CygxArticleHistoryRecordAll)
 	record.UserId = item.UserId
 	record.ArticleId = item.ArticleId
-	record.CreateTime = time.Now().Format(utils.FormatDateTime)
+	record.CreateTime = item.CreateTime.Format(utils.FormatDateTime)
 	record.ModifyTime = item.ModifyTime
 	record.Mobile = item.Mobile
 	record.Email = item.Email
@@ -158,3 +158,19 @@ func GetArticleHistoryRecordAllList() (items []*CygxArticleHistoryRecordNewpv, e
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+//获取列表信息根据手机号分组
+func GetArticleHistoryRecordAllByMobileList(condition string) (items []*CygxArticleHistoryRecordAll, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_article_history_record_all  WHERE 1 = 1 ` + condition + `  GROUP BY mobile   `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户阅读的相关信息
+func UpdateCygxArticleHistoryRecordAll(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_article_history_record_all SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	return
+}

+ 3 - 2
models/chart.go

@@ -27,8 +27,9 @@ type Pagination struct {
 }
 
 type ChartInfo struct {
-	ChartInfo *ChartResultApidate `json:"chart_info"`
-	ChartId   int                 `json:"chart_id"`
+	ChartInfo  *ChartResultApidate `json:"chart_info"`
+	ChartId    int                 `json:"chart_id"`
+	CreateDate string              `json:"add_favorites_time"`
 }
 
 type ChartResultApidate struct {

+ 95 - 2
models/chart_collect.go

@@ -17,11 +17,50 @@ type CygxChartCollect struct {
 	RealName    string    `description:"用户实际名称"`
 	SellerName  string    `description:"所属销售"`
 }
+type CygxChartCollectByCygx struct {
+	Id          int       `orm:"column(id);pk"`
+	ChartId     int       `description:"图表ID"`
+	UserId      int       `description:"用户ID"`
+	CreateTime  time.Time `description:"创建时间"`
+	Mobile      string    `description:"手机号"`
+	Email       string    `description:"邮箱"`
+	CompanyId   int       `description:"公司id"`
+	CompanyName string    `description:"公司名称"`
+	RealName    string    `description:"用户实际名称"`
+	SellerName  string    `description:"所属销售"`
+}
 
 //添加收藏信息
 func AddCygxChartCollect(item *CygxChartCollect) (lastId int64, err error) {
-	o := orm.NewOrm()
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
 	lastId, err = o.Insert(item)
+	if err != nil {
+		return
+	}
+	//添加查研观向来源的记录
+	itemCygx := new(CygxChartCollectByCygx)
+	itemCygx.ChartId = item.ChartId
+	itemCygx.UserId = item.UserId
+	itemCygx.RealName = item.RealName
+	itemCygx.CreateTime = time.Now()
+	itemCygx.Mobile = item.Mobile
+	itemCygx.Email = item.Email
+	itemCygx.CompanyId = item.CompanyId
+	itemCygx.CompanyName = item.CompanyName
+	lastId, err = o.Insert(itemCygx)
+	if err != nil {
+		return
+	}
 	return
 }
 
@@ -30,10 +69,26 @@ type ChartCollectResp struct {
 	CollectCount int `description:"收藏总数"`
 }
 
+//移除
 func RemoveChartCollect(userId, ChartId int) (err error) {
-	o := orm.NewOrm()
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
 	sql := `DELETE FROM cygx_chart_collect WHERE user_id=? AND chart_id=? `
 	_, err = o.Raw(sql, userId, ChartId).Exec()
+	if err != nil {
+		return
+	}
+	sql = `DELETE FROM cygx_chart_collect_by_cygx WHERE user_id=? AND chart_id=? `
+	_, err = o.Raw(sql, userId, ChartId).Exec()
 	return
 }
 
@@ -86,3 +141,41 @@ func GetChartTopCountByUserId(userId, chartID int) (count int, err error) {
 	err = orm.NewOrm().Raw(sql, userId, chartID).QueryRow(&count)
 	return
 }
+
+func RemoveChartCollectByMobile(mobile string) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_chart_collect WHERE mobile IN  (` + mobile + `)`
+	_, err = o.Raw(sql).Exec()
+	return
+}
+
+//批量添加收藏信息
+func AddCygxChartCollectList(items []*CygxChartCollect) (lastId int64, err error) {
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}
+
+//获取列表信息根据手机号分组
+func GetCygxChartCollectByMobileList() (items []*CygxChartCollect, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_chart_collect GROUP BY mobile  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户收藏文章的相关信息
+func UpdateCygxChartCollect(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_chart_collect SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.UserId, wxUser.RealName, wxUser.Mobile).Exec()
+	return
+}
+
+//获取列表
+func GetCygxChartCollectList() (items []*CygxChartCollect, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_chart_collect   `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 8 - 0
models/company.go

@@ -209,3 +209,11 @@ func GetCompanyByThirdName(tripartiteCompanyCode string) (item *Company, err err
 	err = o.Raw(sql, tripartiteCompanyCode).QueryRow(&item)
 	return
 }
+
+//更新机构互动量
+func UpdateComapanyInteractionNum(interactionNum, companyId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company SET interaction_num = ? WHERE company_id=? `
+	_, err = o.Raw(sql, interactionNum, companyId).Exec()
+	return
+}

+ 2 - 0
models/db.go

@@ -106,6 +106,8 @@ func init() {
 		new(CygxArticleHistoryRecordAll),
 		new(CygxActivityAppointment),
 		new(UserTemplateRecord),
+		new(CygxUserInteractionNum),
+		new(CygxChartCollectByCygx),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 18 - 2
models/industry_fllow.go

@@ -37,8 +37,8 @@ type CygxIndustryFllowResp struct {
 
 func RemoveCygxIndustryFllow(userId, industrialManagementId, doType int) (err error) {
 	o := orm.NewOrm()
-	sql := `UPDATE cygx_industry_fllow SET type = ? ,modify_time=? WHERE user_id=? AND industrial_management_id=? `
-	_, err = o.Raw(sql, doType, time.Now(), userId, industrialManagementId).Exec()
+	sql := `DELETE FROM cygx_industry_fllow WHERE user_id=? AND industrial_management_id=? `
+	_, err = o.Raw(sql, userId, industrialManagementId).Exec()
 	return
 }
 
@@ -55,3 +55,19 @@ func GetCountCygxIndustryFllowByUid(userId int) (count int, err error) {
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
 	return
 }
+
+//获取列表信息根据手机号分组
+func GetCygxIndustryFllowList(condition string) (items []*CygxIndustryFllow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_industry_fllow  WHERE 1 =1   ` + condition + `  GROUP BY user_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户关注的相关信息
+func UpdateCygxIndustryFllow(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_industry_fllow SET email=?,company_id=?,company_name=?,user_id=?,real_name=? WHERE mobile=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.Mobile, wxUser.RealName, wxUser.UserId).Exec()
+	return
+}

+ 15 - 0
models/search_key_word.go

@@ -39,3 +39,18 @@ func GetSearchKeyWordTop() (items []*CygxSearchKeyWord, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+func GetCygxSearchKeyWordList(condition string) (items []*CygxSearchKeyWord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_search_key_word   WHERE 1 = 1 ` + condition + `  GROUP BY user_id  `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//修改用户收藏文章的相关信息
+func UpdateCygxSearchKeyWord(wxUser *WxUserItem) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE cygx_search_key_word SET email=?,company_id=?,company_name=?,mobile=?,real_name=? WHERE user_id=? `
+	_, err = o.Raw(sql, wxUser.Email, wxUser.CompanyId, wxUser.CompanyName, wxUser.Mobile, wxUser.RealName, wxUser.UserId).Exec()
+	return
+}

+ 11 - 1
models/send_company_user.go

@@ -217,7 +217,9 @@ func GetSendUserList(condition string) (items []*UserJson, err error) {
 }
 
 type WxUserOpLogResp struct {
-	CompanyId int `description:"客户ID"`
+	CompanyId int    `description:"客户ID"`
+	UserId    int    `description:"用户ID"`
+	Mobile    string `description:"用户ID"`
 }
 
 //获取指定时间内更新的用户
@@ -227,3 +229,11 @@ func GetWxUserOpLog(createTime string) (items []*WxUserOpLogResp, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+//获取指定时间内被移动的用户
+func GetWxUserOpLogList(createTime string) (items []*WxUserOpLogResp, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT company_id,user_id,mobile FROM wx_user_op_log WHERE  log_type IN ('move','add') AND create_time >=  '` + createTime + `' AND company_id > 1 GROUP BY user_id `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 8 - 0
models/user.go

@@ -455,3 +455,11 @@ func UpdateUserLabel(userLabel string, userId int) (err error) {
 	_, err = o.Raw(sql, userLabel, userId).Exec()
 	return
 }
+
+//更新用户互动量
+func UpdateUserInteractionNum(interactionNum, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE wx_user SET interaction_num = ? WHERE user_id=? `
+	_, err = o.Raw(sql, interactionNum, userId).Exec()
+	return
+}

+ 64 - 0
models/user_interaction_num.go

@@ -0,0 +1,64 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserInteractionNum struct {
+	Id                  int       `orm:"column(id);pk"`
+	UserId              int       `description:"用户ID"`
+	ArticleHistoryNum   int       `description:"文章浏览数量"`
+	ArticleCountNum     int       `description:"文章收藏数量"`
+	ChartCountNum       int       `description:"图表收藏"`
+	IndustryFllowNum    int       `description:"产业关注数量"`
+	DepartmentFollowNum int       `description:"作者关注数量"`
+	KeyWordNum          int       `description:"关键词搜索次数"`
+	ActivityOnLineNum   int       `description:"线上活动报名次数"`
+	ActivityOfficeNum   int       `description:"线下活动报名次数"`
+	ActivityNum         int       `description:"活动报名次数"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"更新时间"`
+}
+
+//添加
+func AddCygxUserInteractionNum(item *CygxUserInteractionNum) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}
+
+//修改
+func UpdateCygxUserInteractionNum(item *CygxUserInteractionNum) (err error) {
+	updateParams := make(map[string]interface{})
+	updateParams["UserId"] = item.UserId
+	updateParams["ArticleHistoryNum"] = item.ArticleHistoryNum
+	updateParams["ArticleCountNum"] = item.ArticleCountNum
+	updateParams["ChartCountNum"] = item.ChartCountNum
+	updateParams["IndustryFllowNum"] = item.IndustryFllowNum
+	updateParams["DepartmentFollowNum"] = item.DepartmentFollowNum
+	updateParams["KeyWordNum"] = item.KeyWordNum
+	updateParams["ActivityOnLineNum"] = item.ActivityOnLineNum
+	updateParams["ActivityOfficeNum"] = item.ActivityOfficeNum
+	updateParams["ActivityNum"] = item.ActivityNum
+	updateParams["CreateTime"] = time.Now()
+	updateParams["ModifyTime"] = time.Now()
+	whereParam := map[string]interface{}{"user_id": item.UserId}
+	err = UpdateByExpr(CygxUserInteractionNum{}, whereParam, updateParams)
+	return
+}
+
+//获取列表
+func GetCygxUserInteractionNumList() (items []*CygxUserInteractionNum, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_interaction_num   `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+//批量添加用户互动信息
+func AddCygxUserInteractionNumList(items []*CygxUserInteractionNum) (lastId int64, err error) {
+	o := orm.NewOrm()
+	_, err = o.InsertMulti(1, items)
+	return
+}

+ 74 - 4
models/wx_user.go

@@ -91,6 +91,7 @@ func GetWxUserItemByUnionid(unionid string) (item *WxUserItem, err error) {
 	return
 }
 
+//根据用户ID获取相关信息
 func GetWxUserItemByUserId(userId int) (item *WxUserItem, err error) {
 	sql := `SELECT a.*,b.company_name FROM wx_user AS a
 			LEFT JOIN company AS b on a.company_id=b.company_id
@@ -184,11 +185,12 @@ type WxGetPhoneNumberResp struct {
 	CountryCode     string `description:"区号"`
 }
 
+//根据用户手机号获取相关信息
 func GetWxUserItemByMobile(mobile string) (item *WxUserItem, err error) {
 	sql := `SELECT a.*,b.company_name FROM wx_user AS a
 			LEFT JOIN company AS b on a.company_id=b.company_id
-			WHERE a.mobile=? `
-	err = orm.NewOrm().Raw(sql, mobile).QueryRow(&item)
+			WHERE a.mobile=  '` + mobile + `'  ORDER BY a.company_id DESC LIMIT 1 `
+	err = orm.NewOrm().Raw(sql).QueryRow(&item)
 	return
 }
 
@@ -317,9 +319,9 @@ func GetUserRegisterList() (items []*WxUser, err error) {
 				AND cp.product_id = 2 
 			) 
 			AND u.register_time IS NOT NULL
-			AND cp.product_id = 2 
+			AND cp.product_id = 2
 		GROUP BY
-			u.user_id`
+			u.user_id `
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
@@ -446,3 +448,71 @@ func GetActivitySignCount(mobile, dateTime string) (item []*ActivityLabelCountRe
 	_, err = o.Raw(sql, mobile, dateTime).QueryRows(&item)
 	return
 }
+
+type CygxUserInteractionNumDetail struct {
+	UserId              int64  `orm:"column(user_id);pk"`
+	Mobile              string `description:"手机号"`
+	Email               string `description:"邮箱"`
+	CompanyId           int    `description:"公司id"`
+	CompanyName         string `description:"公司名称"`
+	RealName            string `description:"姓名"`
+	CreatedTime         string `description:"创建时间"`
+	IsMaker             int    `description:"是否决策人,1:是,0:否"`
+	IsRegister          bool   `description:"是否注册,true:已注册,false:未注册"`
+	Status              string `description:"客户状态"`
+	RegisterTime        string `description:"注册时间"`
+	SellerName          string `description:"销售名称"`
+	InteractionNum      int    `description:"互动量"`
+	Labels              string `description:"标签,用英文,隔开"`
+	ActivityLabel       string `description:"活动标签,用英文,隔开"`
+	IsShowSee           bool   `description:"是否展示查看"`
+	IsShowSeeNum        int    `description:"是否展示查看"`
+	HistoryNum          int    `description:"报告阅读"`
+	CountNum            int    `description:"报告收藏"`
+	ChartCountNum       int    `description:"图表收藏"`
+	IndustryFllowNum    int    `description:"产业关注"`
+	DepartmentFollowNum int    `description:"作者关注"`
+	KeyWordNum          int    `description:"搜索关键词"`
+	OnLineNum           int    `description:"线上互动活动"`
+	OfficeNum           int    `description:"线下互动活动"`
+	PackageType         int    `description:"套餐类型,0:无,1:大套餐,2:小套餐"`
+	TryStage            int    `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
+}
+
+//获取用户的互动量
+func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInteractionNumDetail, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			u.user_id,
+			u.company_id,
+			( 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.mobile = u.mobile AND h.is_del = 0   AND h.mobile <>'' ) AS history_num,
+			( SELECT COUNT( 1 ) FROM cygx_article_collect AS h WHERE h.user_id = u.user_id  ) AS count_num,
+			( SELECT COUNT( 1 ) FROM cygx_chart_collect AS h WHERE h.user_id = u.user_id  ) AS chart_count_num,
+			( SELECT COUNT( 1 ) FROM cygx_industry_fllow AS h WHERE h.user_id = u.user_id  ) AS industry_fllow_num,
+			( SELECT COUNT( 1 ) FROM cygx_article_department_follow AS h WHERE h.user_id = u.user_id   ) AS department_follow_num,
+			( SELECT COUNT( 1 ) FROM cygx_search_key_word AS h WHERE h.user_id = u.user_id  ) AS key_word_num,
+			( SELECT COUNT( 1 ) FROM cygx_activity_signup 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.mobile = u.mobile  
+					 AND t.activity_type = 1  AND h.do_fail_type = 0 ) AS on_line_num,
+			( SELECT COUNT( 1 ) FROM cygx_activity_signup 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.mobile = u.mobile  
+					  AND t.activity_type = 0 AND h.do_fail_type = 0 ) AS office_num,
+			(
+			SELECT
+				GROUP_CONCAT( DISTINCT man.industry_name SEPARATOR ',' ) 
+			FROM
+				cygx_industrial_management AS man 
+			WHERE
+				man.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industry_fllow AS f WHERE f.user_id = u.user_id  AND f.type = 1 ) 
+			) AS labels,
+			(
+			SELECT
+				GROUP_CONCAT( DISTINCT man.label SEPARATOR ',' ) 
+			FROM
+				cygx_activity AS man 
+			WHERE
+				man.activity_id IN ( SELECT activity_id FROM cygx_activity_signup AS f WHERE f.user_id = u.user_id  AND label != '') 
+			) AS activity_label
+		FROM
+			wx_user AS u WHERE  u.user_id IN( ` + userIds + `) `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 22 - 0
services/article.go

@@ -1092,6 +1092,28 @@ func GetCeLueArticlePv(cont context.Context) (err error) {
 			}
 		}
 	}
+
+	//处理同步过来的阅读记录所属用户
+	var condition string
+	condition = ` AND create_time  > ` + "'" + startTime + "'"
+	listArticlePv, err := models.GetArticleHistoryRecordAllByMobileList(condition)
+	if err != nil {
+		fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
+	}
+	for _, v := range listArticlePv {
+		if v.Mobile != "" {
+			user, err := models.GetWxUserItemByMobile(v.Mobile)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+			}
+			if user != nil {
+				err = models.UpdateCygxArticleHistoryRecordAll(user)
+				if err != nil {
+					fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+				}
+			}
+		}
+	}
 	return
 
 }

+ 129 - 2
services/chart.go

@@ -194,7 +194,7 @@ func GetUserTokenByMobile(mobile string) (token string, err error) {
 func GetChartCollectionByApi(mobile string, take, skip int) (items []*models.HomeChartListResp, err error, total int) {
 	defer func() {
 		if err != nil {
-			go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetChartPtagByApi ErrMsg:"+err.Error(), utils.EmailSendToUsers)
+			//go utils.SendEmail(utils.APPNAME+"【"+utils.RunMode+"】"+"失败提醒", "GetChartPtagByApi ErrMsg:"+err.Error(), utils.EmailSendToUsers)
 		}
 	}()
 	url := utils.ApiUrl + "charts/favorites?take=" + strconv.Itoa(take) + "&skip=" + strconv.Itoa(skip)
@@ -217,7 +217,7 @@ func GetChartCollectionByApi(mobile string, take, skip int) (items []*models.Hom
 		item.ChartId = v.ChartId
 		item.Title = v.ChartInfo.Title
 		item.TitleEn = v.ChartInfo.TitleEn
-		item.CreateDate = v.ChartInfo.CreateDate
+		item.CreateDate = v.CreateDate
 		item.PtagName = v.ChartInfo.Ptag.Name
 		item.CtagName = v.ChartInfo.Ctag.Name
 		item.BodyHtml = v.ChartInfo.Cover
@@ -303,3 +303,130 @@ func DeleteCollectionChart(mobile string, chartId int) (err error) {
 	}
 	return
 }
+
+func DoCompany() {
+
+	//listCollect, err := models.GetCygxArticleCollectList()
+	//if err != nil {
+	//	fmt.Println("GetAddCygxArticleCollectList ,Err" + err.Error())
+	//}
+	//for _, v := range listCollect {
+	//	user, err := models.GetWxUserItemByUserId(v.UserId)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//	}
+	//	if user != nil {
+	//		fmt.Println(user.RealName)
+	//		err = models.UpdateCygxArticleCollect(user)
+	//		if err != nil {
+	//			fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+	//		}
+	//	}
+	//}
+
+	//listCollect, err := models.GetCygxSearchKeyWordList()
+	//if err != nil {
+	//	fmt.Println("GetAddCygxArticleCollectList ,Err" + err.Error())
+	//}
+	//for _, v := range listCollect {
+	//	user, err := models.GetWxUserItemByUserId(v.UserId)
+	//	if err != nil && err.Error() != utils.ErrNoRow() {
+	//		fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//	}
+	//	if user != nil {
+	//		fmt.Println(user.RealName)
+	//		err = models.UpdateCygxSearchKeyWord(user)
+	//		if err != nil {
+	//			fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+	//		}
+	//	}
+	//}
+	//var condition string
+	////updateTime := time.Now().Add(-time.Hour * 25).Format(utils.FormatDateTime)
+	//condition = ` AND real_name  = '' `
+	//listArticlePv, err := models.GetArticleHistoryRecordAllByMobileList(condition)
+	//if err != nil {
+	//	fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
+	//}
+	//fmt.Println("长度", len(listArticlePv))
+	//for k, v := range listArticlePv {
+	//	if v.Mobile != "" {
+	//		user, err := models.GetWxUserItemByMobile(v.Mobile)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//		}
+	//		if user != nil {
+	//			fmt.Println(user.RealName, k)
+	//			err = models.UpdateCygxArticleHistoryRecordAll(user)
+	//			if err != nil {
+	//				fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+	//			}
+	//		}
+	//	}
+	//}
+
+	//listIndustryFllow, err := models.GetCygxIndustryFllowList("")
+	//if err != nil {
+	//	fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
+	//}
+	//fmt.Println("长度", len(listIndustryFllow))
+	//for k, v := range listIndustryFllow {
+	//	if v.Mobile != "" {
+	//		user, err := models.GetWxUserItemByMobile(v.Mobile)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//		}
+	//		if user != nil {
+	//			fmt.Println(user.RealName, k)
+	//			err = models.UpdateCygxIndustryFllow(user)
+	//			if err != nil {
+	//				fmt.Println("UpdateCygxIndustryFllow ,Err" + err.Error())
+	//			}
+	//		}
+	//	}
+	//}
+	//
+	//lisDepartmentF, err := models.GetArticleDepartmentFollowByMobileList("")
+	//if err != nil {
+	//	fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
+	//}
+	//fmt.Println("长度", len(lisDepartmentF))
+	//for k, v := range lisDepartmentF {
+	//	if v.Mobile != "" {
+	//		user, err := models.GetWxUserItemByMobile(v.Mobile)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//		}
+	//		if user != nil {
+	//			fmt.Println(user.RealName, k)
+	//			err = models.UpdateCygxArticleDepartmentFollow(user)
+	//			if err != nil {
+	//				fmt.Println("UpdateCygxArticleDepartmentFollow ,Err" + err.Error())
+	//			}
+	//		}
+	//	}
+	//}
+
+	//listChartCollect, err := models.GetCygxChartCollectByMobileList()
+	//if err != nil {
+	//	fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
+	//}
+	//fmt.Println("长度", len(listChartCollect))
+	//for k, v := range listChartCollect {
+	//	if v.Mobile != "" {
+	//		user, err := models.GetWxUserItemByMobile(v.Mobile)
+	//		if err != nil && err.Error() != utils.ErrNoRow() {
+	//			fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+	//		}
+	//		if user != nil {
+	//			fmt.Println(user.RealName, k)
+	//			err = models.UpdateCygxChartCollect(user)
+	//			if err != nil {
+	//				fmt.Println("UpdateCygxChartCollect ,Err" + err.Error())
+	//			}
+	//		}
+	//	}
+	//}
+
+	fmt.Println("end")
+}

+ 2 - 1
services/task.go

@@ -66,7 +66,7 @@ func Task() {
 		sendEmailFileForAskMsg := task.NewTask("sendEmailFileForAskMsg", "0 */5 8-22 * * *", SendEmailFileForAskMsg) //非研选系列专家电话会,根据主持人姓名,会前15分钟将问题列表发送给至该主持人对应邮箱
 		task.AddTask("sendEmailFileForAskMsg", sendEmailFileForAskMsg)
 
-		updateWxUserLabel := task.NewTask("updateWxUserLabel", "0 50 3 * * *", UpdateWxUserLabel) //更新用户的标签
+		updateWxUserLabel := task.NewTask("updateWxUserLabel", "0 01 0 * * *", UpdateWxUserLabel) //更新用户的标签
 		task.AddTask("updateWxUserLabel", updateWxUserLabel)
 
 		getCeLueArticlePv := task.NewTask("getCeLueArticlePv", "0 */10 * * * *", GetCeLueArticlePv) //通过三方接口获取策略平台上的阅读记录
@@ -77,6 +77,7 @@ func Task() {
 		task.AddTask("getArticleListByApi", getArticleListByApi)
 	}
 
+	//DoCompany()
 	//ActivityAttendanceDetail()
 	//SynchronizationArthistory()//同步原有的阅读记录
 	//GetAddpArticle() //同步日度点评数据

+ 377 - 10
services/wx_user.go

@@ -14,17 +14,258 @@ import (
 func UpdateWxUserLabel(cont context.Context) (err error) {
 	defer func() {
 		if err != nil {
-			go utils.SendAlarmMsg("更新用户标签失败", 2)
+			go utils.SendAlarmMsg("更新用户标签失败;Err:"+err.Error(), 2)
 			go utils.SendEmail("更新用户标签失败"+"【"+utils.APPNAME+"】"+time.Now().Format(utils.FormatDateTime), ";Err:"+err.Error(), utils.EmailSendToUsers)
 			utils.FileLog.Info("更新用户标签失败,Err:%s", err.Error())
 		}
 	}()
+	//获取需要处理的权益客户
 	listUser, err := models.GetUserRegisterList()
 	if err != nil {
 		fmt.Println("GetUserRegisterList Err", err)
+		return err
 	}
+
+	mapChartCollect := make(map[string]int)
+	//获取已经处理记录的用户并记录切片
+	listChartCollectL, err := models.GetCygxChartCollectList()
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		fmt.Println("GetCygxUserInteractionNumList Err", err)
+		return err
+	}
+	for _, v := range listChartCollectL {
+		mapChartCollect[fmt.Sprint("m:", v.Mobile, "u:", v.ChartId)] = v.UserId
+	}
+
+	var interactionNum int //  互动量
+	mapComapnyInteractionNum := make(map[int]int)
+
+	//拉取策略平台用户同步的图表信息
+
+	{
+		var chartMobile string
+		var chartItems []*models.CygxChartCollect
+
+		if utils.RunMode == "release" {
+			for k, vUser := range listUser {
+				if vUser.Mobile != "" {
+					mobile := vUser.Mobile
+					fmt.Println(vUser.Mobile, "_", k)
+					chartMobile += mobile + ","
+					listChart, _, _ := GetChartCollectionByApi(mobile, 9999, 0)
+					if len(listChart) > 0 {
+						for _, vChart := range listChart {
+							if mapChartCollect[fmt.Sprint("m:", mobile, "u:", vChart.ChartId)] == 0 {
+								item := new(models.CygxChartCollect)
+								item.ChartId = vChart.ChartId
+								t1, _ := time.Parse("2006-01-02T15:04:05Z", vChart.CreateDate)
+								item.CreateTime = t1
+								item.Mobile = mobile
+								chartItems = append(chartItems, item)
+							}
+						}
+					}
+				}
+			}
+		}
+		//如果有数据就添加
+		if len(chartItems) > 0 {
+			_, err = models.AddCygxChartCollectList(chartItems)
+			if err != nil {
+				fmt.Println(" RemoveChartCollectByMobile Err", err)
+			}
+		}
+
+		//处理图表关注后的用户
+		{
+
+			listChartCollect, err := models.GetCygxChartCollectByMobileList()
+			if err != nil {
+				fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
+			}
+			for k, v := range listChartCollect {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByMobile(v.Mobile)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxChartCollect(user)
+						if err != nil {
+							fmt.Println("UpdateCygxChartCollect ,Err" + err.Error())
+						}
+					}
+				}
+			}
+		}
+	}
+
+	//处理 前一天移动之后的用户的公司记录信息
+	{
+		updateTime := time.Now().Add(-time.Hour * 25).Format("2006-01-02 15:04:05")
+		listUpdateUser, err := models.GetWxUserOpLogList(updateTime)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			return err
+		}
+		var userIds string
+		var mobiles string
+		if len(listUpdateUser) > 0 {
+			for _, v := range listUpdateUser {
+				userIds += strconv.Itoa(v.UserId) + ","
+				mobiles += "'" + v.Mobile + "',"
+			}
+		}
+		userIds = strings.TrimRight(userIds, ",")
+		mobiles = strings.TrimRight(mobiles, ",")
+
+		//如果用户ID不为空那么就处理这些用户的记录信息
+		if userIds != "" {
+			var condition string
+			condition = ` AND user_id IN (` + userIds + `)`
+
+			//处理用户的文章收藏
+			listCollect, err := models.GetCygxArticleCollectList(condition)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				fmt.Println("GetAddCygxArticleCollectList ,Err" + err.Error())
+			}
+			if len(listCollect) > 0 {
+				for _, v := range listCollect {
+					user, err := models.GetWxUserItemByUserId(v.UserId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName)
+						err = models.UpdateCygxArticleCollect(user)
+						if err != nil {
+							fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+						}
+					}
+				}
+			}
+			//处理用户的文章收藏 end
+
+			//修改用户关注的产业
+			listIndustryFllow, err := models.GetCygxIndustryFllowList(condition)
+			if err != nil {
+				fmt.Println("GetCygxIndustryFllowList ,Err" + err.Error())
+			}
+			for k, v := range listIndustryFllow {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByUserId(v.UserId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxIndustryFllow(user)
+						if err != nil {
+							fmt.Println("UpdateCygxIndustryFllow ,Err" + err.Error())
+						}
+					}
+				}
+			}
+
+			//修改用户产业关注的产业end
+
+			//修改用户的阅读记录
+			listArticlePv, err := models.GetArticleHistoryRecordAllByMobileList(condition)
+			if err != nil {
+				fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
+			}
+			for k, v := range listArticlePv {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByMobile(v.Mobile)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxArticleHistoryRecordAll(user)
+						if err != nil {
+							fmt.Println("UpdateCygxArticleCollect ,Err" + err.Error())
+						}
+					}
+				}
+			}
+			//修改用户的阅读记录end
+
+			//处理用户的搜索记录
+			listSearch, err := models.GetCygxSearchKeyWordList(condition)
+			if err != nil {
+				fmt.Println("GetArticleHistoryRecordAllByMobileList ,Err" + err.Error())
+			}
+
+			for k, v := range listSearch {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByUserId(v.UserId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxSearchKeyWord(user)
+						if err != nil {
+							fmt.Println("UpdateCygxSearchKeyWord ,Err" + err.Error())
+						}
+					}
+				}
+			}
+
+			// 处理用户的作者关注
+			lisDepartmentF, err := models.GetArticleDepartmentFollowByMobileList(condition)
+			if err != nil {
+				fmt.Println("GetArticleDepartmentFollowByMobileList ,Err" + err.Error())
+				return err
+			}
+			for k, v := range lisDepartmentF {
+				if v.Mobile != "" {
+					user, err := models.GetWxUserItemByUserId(v.UserId)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+					}
+					if user != nil {
+						fmt.Println(user.RealName, k)
+						err = models.UpdateCygxArticleDepartmentFollow(user)
+						if err != nil {
+							fmt.Println("UpdateCygxArticleDepartmentFollow ,Err" + err.Error())
+						}
+					}
+				}
+			}
+			// 处理用户的作者关注end
+
+			//如果手机号不为空,则更新用户的报名信息
+			if mobiles != "" {
+				condition = ` AND mobile IN (` + mobiles + `)`
+				listSingUp, err := models.GetCygxActivitySignupByMobileList(condition)
+				if err != nil {
+					fmt.Println("GetCygxChartCollectByMobileList ,Err" + err.Error())
+				}
+				//fmt.Println("更新用户的报名信息长度", len(listSingUp))
+				for _, v := range listSingUp {
+					if v.Mobile != "" {
+						user, err := models.GetWxUserItemByMobile(v.Mobile)
+						if err != nil && err.Error() != utils.ErrNoRow() {
+							fmt.Println("GetWxUserItemByUserId ,Err" + err.Error())
+						}
+						if user != nil {
+							err = models.UpdateCygxActivitySignup(user)
+							if err != nil {
+								fmt.Println("UpdateCygxActivitySignup ,Err" + err.Error())
+								//return err
+							}
+						}
+					}
+				}
+			}
+
+		}
+	}
+
+	//处理用户标签
 	for _, vUser := range listUser {
-		//fmt.Println(vUser.Mobile)
 		labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
 		if err != nil {
 			fmt.Println("GetCygxCompanyUserListSplit Err", err)
@@ -32,9 +273,7 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 		}
 		mapLabels := make(map[string]string)
 		var labelsListStr []*models.UserLabel
-
 		mapActivityLabels := make(map[string]string)
-
 		labelsList := strings.Split(labels, ",")
 		for _, vL := range labelsList {
 			if mapLabels[vL] == "" && vL != "" {
@@ -44,7 +283,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 				labelsListStr = append(labelsListStr, item)
 			}
 		}
-
 		dateTime := time.Now().AddDate(0, -3, 0).Format(utils.FormatDate)
 		listArticlePv, err := models.GetArticlePvCount(vUser.Mobile, vUser.Email, dateTime)
 		if err != nil && err.Error() != utils.ErrNoRow() {
@@ -95,7 +333,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 				}
 			}
 		}
-
 		articleIds, err = models.GetCygxArticleCollectId(vUser.UserId, dateTime)
 		if err != nil && err.Error() != utils.ErrNoRow() {
 			fmt.Println("GetCygxArticleCollectId Err", err)
@@ -137,7 +374,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 				}
 			}
 		}
-
 		//活动标签计算
 		listActivityPv, err := models.GetActivitySignCount(vUser.Mobile, dateTime)
 		if err != nil && err.Error() != utils.ErrNoRow() {
@@ -160,7 +396,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 				}
 			}
 		}
-
 		//对标签数量进行排序
 		type KvPair struct {
 			Key string
@@ -181,7 +416,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 				labelsListStr = append(labelsListStr, item)
 			}
 		}
-
 		var labelNew string
 		for _, v := range labelsListStr {
 			labelNew += v.Label + ","
@@ -194,7 +428,140 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
 				return err
 			}
 		}
-		//fmt.Println(labelNew)
+	}
+
+	//处理用户、机构互动量数据
+	{
+		var userIds string
+		var itemsInteraction []*models.CygxUserInteractionNum
+		mapUserInteraction := make(map[int]int)
+		//获取已经处理记录的用户并记录切片
+		listUserInteractionNum, err := models.GetCygxUserInteractionNumList()
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			fmt.Println("GetCygxUserInteractionNumList Err", err)
+			return err
+		}
+		for _, v := range listUserInteractionNum {
+			mapUserInteraction[v.UserId] = v.UserId
+		}
+
+		//处理用户互动量数据
+		for kUser, vUser := range listUser {
+			userIds += strconv.Itoa(vUser.UserId) + ","
+			//一次查询一百个避免用户过多
+			if kUser%100 == 0 {
+				userIds = strings.TrimRight(userIds, ",")
+				userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
+				if err != nil {
+					fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
+					return err
+				}
+				//处理用户的互动量
+				if len(userUserInteractionList) > 0 {
+					for _, vsplit := range userUserInteractionList {
+						interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum
+						if interactionNum > 0 {
+							//更改用户的互动量
+							err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
+							if err != nil {
+								fmt.Println("UpdateUserInteractionNum Err", err)
+								return err
+							}
+							mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
+
+							itemInteraction := new(models.CygxUserInteractionNum)
+							itemInteraction.UserId = int(vsplit.UserId)
+							itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
+							itemInteraction.ArticleCountNum = vsplit.CountNum
+							itemInteraction.ChartCountNum = vsplit.ChartCountNum
+							itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
+							itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
+							itemInteraction.KeyWordNum = vsplit.KeyWordNum
+							itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
+							itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
+							itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
+							itemInteraction.CreateTime = time.Now()
+							itemInteraction.ModifyTime = time.Now()
+							//如果存在就修改不存在就新增
+							if mapUserInteraction[int(vsplit.UserId)] == 0 {
+								itemsInteraction = append(itemsInteraction, itemInteraction)
+							} else {
+								err = models.UpdateCygxUserInteractionNum(itemInteraction)
+								if err != nil {
+									fmt.Println("UpdateCygxUserInteractionNum Err", err)
+									return err
+								}
+								fmt.Println(itemInteraction.UserId)
+							}
+						}
+					}
+				}
+				userIds = ""
+			}
+		}
+
+		userIds = strings.TrimRight(userIds, ",")
+		if userIds != "" {
+			userUserInteractionList, err := models.GetCygxCompanyUserUserInteraction(userIds)
+			if err != nil {
+				fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
+				return err
+			}
+			//fmt.Println("处理用户剩余的")
+			//处理用户的互动量
+			if len(userUserInteractionList) > 0 {
+				for _, vsplit := range userUserInteractionList {
+					interactionNum = vsplit.HistoryNum + vsplit.CountNum + vsplit.IndustryFllowNum + vsplit.DepartmentFollowNum + vsplit.KeyWordNum + vsplit.OnLineNum + vsplit.OfficeNum + vsplit.ChartCountNum
+					if interactionNum > 0 {
+						err = models.UpdateUserInteractionNum(interactionNum, int(vsplit.UserId))
+						if err != nil {
+							fmt.Println("UpdateUserInteractionNum Err", err)
+							return err
+						}
+						mapComapnyInteractionNum[vsplit.CompanyId] += interactionNum
+
+						itemInteraction := new(models.CygxUserInteractionNum)
+						itemInteraction.UserId = int(vsplit.UserId)
+						itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
+						itemInteraction.ArticleCountNum = vsplit.CountNum
+						itemInteraction.ChartCountNum = vsplit.ChartCountNum
+						itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
+						itemInteraction.DepartmentFollowNum = vsplit.DepartmentFollowNum
+						itemInteraction.KeyWordNum = vsplit.KeyWordNum
+						itemInteraction.ActivityOnLineNum = vsplit.OnLineNum
+						itemInteraction.ActivityOfficeNum = vsplit.OfficeNum
+						itemInteraction.ActivityNum = vsplit.OnLineNum + vsplit.OfficeNum
+						itemInteraction.CreateTime = time.Now()
+						itemInteraction.ModifyTime = time.Now()
+						//如果存在就修改不存在就新增
+						if mapUserInteraction[int(vsplit.UserId)] == 0 {
+							itemsInteraction = append(itemsInteraction, itemInteraction)
+						} else {
+							err = models.UpdateCygxUserInteractionNum(itemInteraction)
+							if err != nil {
+								fmt.Println("UpdateCygxUserInteractionNum Err", err)
+								return err
+							}
+							fmt.Println(itemInteraction.UserId)
+							err = models.UpdateCygxUserInteractionNum(itemInteraction)
+						}
+					}
+				}
+			}
+		}
+		////修改机构互动量信息
+		if len(mapComapnyInteractionNum) > 0 {
+			for k, v := range mapComapnyInteractionNum {
+				err = models.UpdateComapanyInteractionNum(v, k)
+			}
+		}
+		// 批量添加用户互动量信息
+		if len(itemsInteraction) > 0 {
+			_, err = models.AddCygxUserInteractionNumList(itemsInteraction)
+			if err != nil {
+				fmt.Println(" RemoveChartCollectByMobile Err", err)
+			}
+		}
 	}
 	return
 }