Browse Source

no message

xingzai 1 năm trước cách đây
mục cha
commit
952a552ded

+ 2 - 2
controllers/report.go

@@ -900,8 +900,8 @@ func (this *ReportController) Fllow() {
 		}
 	}
 
-	//处理是否关注全部赛道字段
-	go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
+	go services.IndustryFllowWithTrack(industrialManagementId, count, uid)       //处理是否关注全部赛道字段
+	go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
 	br.Msg = "操作成功"
 	br.Ret = 200
 	br.Success = true

+ 40 - 0
models/user_label.go

@@ -0,0 +1,40 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxUserLabelLogRedis struct {
+	UserId     int       `description:"用户ID"`
+	SourceId   int       `description:"资源ID"`
+	SourceType int       `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
+	IsFllow    int       `description:"1关注、0取消关注"`
+	CreateTime time.Time `description:"创建时间"`
+}
+
+type CygxUserLabel struct {
+	Id         int       `orm:"column(id);pk"`
+	UserId     int       `description:"用户ID"`
+	CompanyId  int       `description:"公司id"`
+	RealName   string    `description:"用户实际名称"`
+	Mobile     string    `description:"手机号"`
+	Email      string    `description:"邮箱"`
+	Label      string    `description:"标签内容"`
+	Weight     int       `description:"权重"`
+	SourceId   int       `description:"来源ID(产业ID,系列ID)"`
+	Source     int       `description:"来源1:产业、2:系列"`
+	CreateTime time.Time `description:"创建时间"`
+	ModifyTime time.Time `description:"更新时间"`
+}
+
+// 获取数量
+func GetCygxUserLabelCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_user_label as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}

+ 30 - 0
services/industrial_management.go

@@ -299,6 +299,36 @@ func IndustryFllowWithTrack(industrialManagementId, count, uid int) (err error)
 	return err
 }
 
+func init() {
+	//IndustryFllowUserLabel(136, 16, 5660)
+	//UserLabelLogReduce()
+}
+
+// 1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。
+func IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid int) (err error) {
+	var isFllow int
+	if count == 0 {
+		isFllow = 1
+	} else {
+		isFllow = 0
+	}
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("industrialManagementId:", industrialManagementId, "isFllow:", isFllow, "userId:", uid)
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	log := &models.CygxUserLabelLogRedis{UserId: uid, SourceId: industrialManagementId, SourceType: 2, IsFllow: isFllow, CreateTime: time.Now()}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.CYGX_USER_KEY_LABEL, log)
+		if err != nil {
+			fmt.Println("RecordNewLogs LPush Err:" + err.Error())
+		}
+	}
+	return
+}
+
 // GetIndustryNewLabelMap 获取产业【新】标签Map
 func GetIndustryNewLabelMap(industryIds []int) (labelMap map[int]bool, err error) {
 	labelMap = make(map[int]bool, 0)

+ 63 - 0
services/user_label.go

@@ -0,0 +1,63 @@
+package services
+
+import (
+	"encoding/json"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+)
+
+func UserLabelLogReduce() (err error) {
+	for {
+		//SourceType int       `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
+		utils.Rc.Brpop(utils.CYGX_USER_KEY_LABEL, func(b []byte) {
+			var log models.CygxUserLabelLogRedis
+			if err := json.Unmarshal(b, &log); err != nil {
+				fmt.Println("json unmarshal wrong!")
+				go utils.SendAlarmMsg("用户更新相关标签处理Redis队列消息失败:"+err.Error()+string(b), 2)
+			}
+			switch log.SourceType {
+			case 1:
+				fmt.Println("文章阅读")
+				break
+			case 2:
+				go IndustryFllowUserLabelLogReduce(log)
+				fmt.Println("2产业关注")
+				break
+			case 3:
+				fmt.Println("活动到会")
+				break
+			case 4:
+				fmt.Println("4系列关注")
+				break
+			case 5:
+				fmt.Println("5专项调研活动到会")
+				break
+			default:
+				fmt.Println(string(b))
+				go utils.SendAlarmMsg("用户更新相关标签处理Redis队列消息失败:"+string(b), 2)
+			}
+		})
+	}
+}
+
+func IndustryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			//msg := fmt.Sprint("industrialManagementId:", industrialManagementId, "isFllow:", isFllow, "userId:", uid)
+			msg := ""
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+
+	//type CygxActivitySigninLogRedis struct {
+	//	UserId     int       `description:"用户ID"`
+	//	SourceId   int       `description:"资源ID"`
+	//	SourceType int       `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
+	//	IsFllow    int       `description:"1关注、0取消关注"`
+	//	CreateTime time.Time `description:"创建时间"`
+	//}
+
+	return
+}

+ 1 - 0
utils/constants.go

@@ -121,6 +121,7 @@ const (
 
 const (
 	YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY = "YI_DONG_ZHENG_TONG_YUN_TOKEN_KEY" //易董证通云的token,存Redis使用
+	CYGX_USER_KEY_LABEL              = "CYGX_USER_KEY_LABEL"              //查研观向用户标签
 )
 
 const (