|
@@ -24,7 +24,6 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
fmt.Println("GetUserRegisterList Err", err)
|
|
|
return err
|
|
|
}
|
|
|
- var userIds string
|
|
|
|
|
|
var interactionNum int // 互动量
|
|
|
mapComapnyInteractionNum := make(map[int]int)
|
|
@@ -33,7 +32,7 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
{
|
|
|
var chartMobile string
|
|
|
var chartItems []*models.CygxChartCollect
|
|
|
- for k, vUser := range listUser {
|
|
|
+ for _, vUser := range listUser {
|
|
|
if vUser.Mobile != "" {
|
|
|
mobile := vUser.Mobile
|
|
|
chartMobile += mobile + ","
|
|
@@ -48,11 +47,8 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
chartItems = append(chartItems, item)
|
|
|
}
|
|
|
}
|
|
|
- fmt.Println(mobile, "长度", len(listChart), "条数", k)
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- fmt.Println("总长度", len(chartItems))
|
|
|
chartMobile = strings.TrimRight(chartMobile, ",")
|
|
|
err = models.RemoveChartCollectByMobile(chartMobile)
|
|
|
if err != nil {
|
|
@@ -65,12 +61,11 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
|
|
|
//处理图表关注后的用户
|
|
|
{
|
|
|
- fmt.Println("处理图表关注后的用户")
|
|
|
+
|
|
|
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)
|
|
@@ -89,6 +84,170 @@ func UpdateWxUserLabel(cont context.Context) (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())
|
|
|
+ }
|
|
|
+ fmt.Println("修改用户关注的产业长度", len(listIndustryFllow))
|
|
|
+ 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())
|
|
|
+ }
|
|
|
+ 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())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //修改用户的阅读记录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 {
|
|
|
labels, err := models.GetCygxCompanyUserListSplit(strconv.Itoa(vUser.UserId))
|
|
@@ -257,6 +416,7 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
|
|
|
//处理用户、机构互动量数据
|
|
|
{
|
|
|
+ var userIds string
|
|
|
var itemsInteraction []*models.CygxUserInteractionNum
|
|
|
mapUserInteraction := make(map[int]int)
|
|
|
//获取已经处理记录的用户并记录切片
|
|
@@ -326,7 +486,7 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
fmt.Println("GetCygxCompanyUserUserInteraction Err", err)
|
|
|
return err
|
|
|
}
|
|
|
- fmt.Println("处理用户剩余的")
|
|
|
+ //fmt.Println("处理用户剩余的")
|
|
|
//处理用户的互动量
|
|
|
if len(userUserInteractionList) > 0 {
|
|
|
for _, vsplit := range userUserInteractionList {
|
|
@@ -341,7 +501,7 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
|
|
|
itemInteraction := new(models.CygxUserInteractionNum)
|
|
|
itemInteraction.UserId = int(vsplit.UserId)
|
|
|
- itemInteraction.ArticleCountNum = vsplit.HistoryNum
|
|
|
+ itemInteraction.ArticleHistoryNum = vsplit.HistoryNum
|
|
|
itemInteraction.ArticleCountNum = vsplit.CountNum
|
|
|
itemInteraction.ChartCountNum = vsplit.ChartCountNum
|
|
|
itemInteraction.IndustryFllowNum = vsplit.IndustryFllowNum
|
|
@@ -362,12 +522,10 @@ func UpdateWxUserLabel(cont context.Context) (err error) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
//修改机构互动量信息
|
|
|
if len(mapComapnyInteractionNum) > 0 {
|
|
|
for k, v := range mapComapnyInteractionNum {
|
|
|
err = models.UpdateComapanyInteractionNum(v, k)
|
|
|
- fmt.Println(k, "修改", v)
|
|
|
}
|
|
|
}
|
|
|
// 批量添加用户互动量信息
|