Browse Source

no message

zhangchuanxing 1 month ago
parent
commit
a87e403263

+ 9 - 0
controllers/report_selection.go

@@ -264,6 +264,7 @@ func (this *ReportSelectionController) ClickHistory() {
 		br.ErrMsg = "记录失败,Err:" + err.Error()
 		return
 	}
+	go services.GetReportSelectionLabelName(req, user.UserId) //记录用户在重点公司单独点了某一个标签
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "记录成功"
@@ -300,10 +301,15 @@ func (this *ReportSelectionController) AddStopTime() {
 	outType := req.OutType
 	source := req.Source
 	var reportType string
+	var tableName, label string
 	if source == 1 {
 		reportType = "bgjx"
+		tableName = "cygx_report_selection"
+		label = "重点推荐"
 	} else if source == 2 {
 		reportType = "bzyjhz"
+		tableName = "cygx_research_summary"
+		label = "本周研究汇总"
 	} else if source == 3 {
 		reportType = "szjyhz"
 	}
@@ -337,6 +343,9 @@ func (this *ReportSelectionController) AddStopTime() {
 			historyRecord.SellerName = sellerItem.RealName
 		}
 		go services.AddCygxReportHistoryRecord(historyRecord)
+		if tableName != "" {
+			go services.ReportSelectionWxUserRaiLabelRedisAdd(articleId, uid, historyRecord.CreateTime, tableName, label)
+		}
 	}
 
 	br.Ret = 200

+ 16 - 13
models/report_selection_log.go

@@ -6,19 +6,22 @@ import (
 )
 
 type CygxReportSelectionLog struct {
-	ArticleSunId           int       `description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	PermissionName         string    `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    int       `description:"标的ID"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	SubjectName            string    `description:"标的名称"`
-	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
-	CompanyLabel           []string  `description:"公司标签"`
-	Label                  string    `description:"公司标签"`
-	OverviewArticleId      int       `description:"综述报告Id"`
+	ArticleSunId              int       `description:"子级报告id"`
+	ArticleId                 int       `description:"父级报告Id"`
+	ChartPermissionId         int       `description:"行业ID"`
+	PermissionName            string    `description:"行业ID"`
+	CreateTime                time.Time `description:"创建时间"`
+	Body                      string    `description:"内容"`
+	IndustrialSubjectId       int       `description:"标的ID"`
+	IndustrialManagementId    string    `description:"产业资源包Id  多个用 , 隔开"`
+	IndustrialManagementNames string    `description:"产业资源包名称  多个用 , 隔开"`
+	SubjectName               string    `description:"标的名称"`
+	IcoLink                   string    `orm:"column(image_url)"description:"图标链接"`
+	CompanyLabel              []string  `description:"公司标签"`
+	Label                     string    `description:"公司标签"`
+	OverviewArticleId         int       `description:"综述报告Id"`
+	ThirdId                   int       `description:"类似产业、标的的三方ID"`
+	ThirdName                 string    `description:"类似产业、标的的三方名称"`
 }
 
 type CygxReportSelectionLogResp struct {

+ 13 - 0
models/wx_user_rai_label.go

@@ -0,0 +1,13 @@
+package models
+
+import "time"
+
+type WxUserRaiLabelRedis struct {
+	UserId           int       `description:"用户ID"`
+	SourceId         int       `description:"资源ID"`
+	Label            string    `description:"标签内容"`
+	SourceType       int       `description:"来源1:搜索关键字标签、2:产业/个股标签(线下活动)、3:产业/个股标签(线下路演)、4:产业/个股标签(线上活动)、5:产业/个股标签(线上路演)、6:销售输入标签、7:产业/个股标签(报告)、8:报告类型标签"`
+	CreateTime       time.Time `description:"创建时间"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
+	TableName        string    `description:"数据来源的表名"`
+}

+ 1 - 0
services/article_history.go

@@ -89,6 +89,7 @@ func ArticleHistoryStopTime(articleId, stopTime, outType int, user *models.WxUse
 		recordRedis.OutId = int(newId)
 		recordRedis.CreateTime = record.CreateTime
 		go PushViewRecordNewRedisData(recordRedis, user.CompanyId)
+		go ArticleWxUserRaiLabelRedisAdd(articleId, user.UserId, record.CreateTime)
 		utils.Rc.Put(key, 1, 2*time.Second)
 	}
 	go ArticleHistoryUserLabelLogAdd(articleId, uid)

+ 1 - 0
services/keyword.go

@@ -35,6 +35,7 @@ func AddSearchKeyWord(user *models.WxUserItem, keyWord string, source int) (err
 	_, err = models.AddSearchKeyWord(keyWordItem)
 	go AddUserSearchLog(user, keyWord, source)
 	go SearchKeywordUserRmind(user, keyWord)
+	go KeyWordsWxUserRaiLabelRedisAdd(0, user.UserId, keyWord)
 	//一分钟之内的相同搜索词不重复记录
 	//setNX := utils.Rc.SetNX(cacheKey, keyWord, time.Second*3)
 	//if !setNX {

+ 34 - 0
services/report_selection.go

@@ -68,3 +68,37 @@ func SendCygxReportSelectionLogApplyTemplateMsg(user *models.WxUserItem, content
 	err = PublicSendTemplateMsg(sendInfo)
 	return
 }
+
+// 记录用户在重点公司单独点了某一个标签
+func GetReportSelectionLabelName(req models.AddCygxReportSelectionSubjectHistoryReq, userId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go utils.SendAlarmMsg("SendCygxReportSelectionLogApplyTemplateMsg Err"+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition = ` AND article_id = ?  AND industrial_subject_id = ? AND  industrial_management_id = ? AND  third_id = ? `
+	pars = append(pars, req.ArticleId, req.IndustrialSubjectId, req.IndustrialManagementId, req.ThirdId)
+	listLog, e := models.GetCygxReportSelectionLog(condition, pars, 0, 9999)
+	if e != nil {
+		err = errors.New("GetCygxReportSelectionLog, Err: " + e.Error())
+		return
+	}
+	var labelName string
+	for _, v2 := range listLog {
+		if v2.ThirdId > 0 {
+			labelName = v2.ThirdName
+		} else if v2.IndustrialSubjectId == 0 && v2.IndustrialManagementId != "" {
+			labelName = v2.IndustrialManagementNames
+		} else {
+			labelName = v2.SubjectName
+		}
+	}
+	if labelName == "" {
+		return
+	}
+	ReportSelectionWxUserRaiLabelRedisAdd(req.ArticleId, userId, time.Now(), "cygx_report_selection", labelName)
+	return
+}

+ 65 - 0
services/wx_user_rai_label.go

@@ -0,0 +1,65 @@
+package services
+
+import (
+	"fmt"
+	"hongze/hongze_clpt/models"
+	"hongze/hongze_clpt/utils"
+	"time"
+)
+
+// 添加用户搜索标签到Redis
+func KeyWordsWxUserRaiLabelRedisAdd(sourceId, uid int, label string) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("sourceId:", sourceId, "userId:", uid)
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	log := &models.WxUserRaiLabelRedis{UserId: uid, SourceId: sourceId, SourceType: 1, Label: label, CreateTime: time.Now(), RegisterPlatform: utils.REGISTER_PLATFORM}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.WX_USER_RAI_LABEL_KEY, log)
+		if err != nil {
+			fmt.Println("WxUserRaiLabelRedis LPush Err:" + err.Error())
+		}
+	}
+	return
+}
+
+// 添加用户阅读文章标签到Redis
+func ArticleWxUserRaiLabelRedisAdd(sourceId, uid int, createTime time.Time) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("sourceId:", sourceId, "userId:", uid)
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	log := &models.WxUserRaiLabelRedis{UserId: uid, SourceId: sourceId, SourceType: 1, TableName: utils.CYGX_OBJ_ARTICLE, CreateTime: createTime, RegisterPlatform: utils.REGISTER_PLATFORM}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.WX_USER_RAI_LABEL_KEY, log)
+		if err != nil {
+			fmt.Println("WxUserRaiLabelRedis LPush Err:" + err.Error())
+		}
+	}
+	return
+}
+
+// 添加用户阅读本周研究汇总,与重点公司标签到Redis
+func ReportSelectionWxUserRaiLabelRedisAdd(sourceId, uid int, createTime time.Time, tableName, label string) (err error) {
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			msg := fmt.Sprint("sourceId:", sourceId, "userId:", uid)
+			go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
+		}
+	}()
+	log := &models.WxUserRaiLabelRedis{UserId: uid, SourceId: sourceId, SourceType: 1, TableName: tableName, Label: label, CreateTime: createTime, RegisterPlatform: utils.REGISTER_PLATFORM}
+	if utils.Re == nil {
+		err := utils.Rc.LPush(utils.WX_USER_RAI_LABEL_KEY, log)
+		if err != nil {
+			fmt.Println("ReportSelectionWxUserRaiLabelRedisAdd LPush Err:" + err.Error())
+		}
+	}
+	return
+}

+ 2 - 1
utils/constants.go

@@ -150,7 +150,8 @@ var YAN_XUAN_ARTICLE_TYPE_ID = []int{1, 2, 12}
 var ACTIVITY_SPECIAL_TRIP_PERMISSION_NAME_OTHER = []string{"策略", "固收", "周期"} //专项调研活动带扣点的行业
 
 const (
-	YAN_XUAN_TAB_KEY = "yanxuan_header_tab"
+	YAN_XUAN_TAB_KEY      = "yanxuan_header_tab"
+	WX_USER_RAI_LABEL_KEY = "WX_USER_RAI_LABEL_KEY" //用户列表标签key
 )
 const (
 	YD_TOKEN                = "yidong_token"