Browse Source

Merge branch 'crm/crm_16.5' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

zhangchuanxing 2 months ago
parent
commit
0f138b9a3f
2 changed files with 131 additions and 1 deletions
  1. 36 0
      models/wx_user_rai_label.go
  2. 95 1
      services/wx_user_rai_label.go

+ 36 - 0
models/wx_user_rai_label.go

@@ -3,6 +3,7 @@ package models
 import (
 	"fmt"
 	"github.com/beego/beego/v2/client/orm"
+	"strings"
 	"time"
 )
 
@@ -60,3 +61,38 @@ func AddWxUserRaiLabel(item *WxUserRaiLabel) (err error) {
 	_, err = o.Insert(item)
 	return
 }
+
+// 批量插入
+func AddWxUserRaiLabelMulti(items []*WxUserRaiLabel, label []string, userId int) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+
+	if len(label) > 0 {
+		//删除老的数据信息
+		sql := ` DELETE FROM wx_user_rai_label WHERE user_id = ? AND  label IN ('` + strings.Join(label, "','") + `')  `
+		_, err = o.Raw(sql, userId).Exec()
+		if err != nil {
+			return
+		}
+	}
+
+	//批量插入新的关联数据
+	if len(items) > 0 {
+		//批量添加流水信息
+		_, err = o.InsertMulti(len(items), items)
+		if err != nil {
+			return
+		}
+	}
+
+	return
+}

+ 95 - 1
services/wx_user_rai_label.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
+	"strconv"
 	"time"
 )
 
@@ -164,8 +165,14 @@ func ArticleWxUserRaiLabelRedisAddReduce(log models.WxUserRaiLabelRedis) (err er
 	}
 	articlePermissionName := articlePermission.PermissionName
 	matchTypeName := articlePermission.MatchTypeName
+	matchTypeNameArr := []string{"季度策略", "科技前沿(周报)", "本周荟", "智造精粹"}
 
-	if articlePermissionName == utils.CE_LUE_NAME || articlePermissionName == utils.GU_SHOU_NAME { // 策略、固收的所有报告,以报告类型做标签
+	//1;四大行业汇总类报告:季度策略、科技前沿(周报)、本周荟、智造精粹以报告类型做标签
+	//2:策略、固收的所有报告,以报告类型做标签
+	if articlePermissionName == utils.CE_LUE_NAME || articlePermissionName == utils.GU_SHOU_NAME || utils.InArrayByStr(matchTypeNameArr, matchTypeName) { // 策略、固收的所有报告,以报告类型做标签
+		if matchTypeName == "季度策略" {
+			matchTypeName = articlePermissionName + matchTypeName //其中季度策略以:xx行业季度策略  呈现
+		}
 		item := new(models.WxUserRaiLabel)
 		item.UserId = wxUser.UserId
 		item.RealName = wxUser.RealName
@@ -175,6 +182,7 @@ func ArticleWxUserRaiLabelRedisAddReduce(log models.WxUserRaiLabelRedis) (err er
 		item.CompanyName = wxUser.CompanyName
 		item.Label = matchTypeName
 		item.SourceType = 8
+		item.SourceId = sourceId
 		item.CreateTime = log.CreateTime
 		item.ModifyTime = time.Now()
 		item.RegisterPlatform = log.RegisterPlatform
@@ -184,6 +192,92 @@ func ArticleWxUserRaiLabelRedisAddReduce(log models.WxUserRaiLabelRedis) (err er
 			err = errors.New("AddWxUserRaiLabel" + e.Error())
 			return
 		}
+	} else if articlePermissionName == utils.ZHOU_QI_NAME {
+		//周期的行业深度、调研纪要、产业跟踪这些系列的报告用领域做标签,其余的周期报告,都用报告类型(也就是ficc定义的类型)做标签
+		//其中周期的周度观点,以 周期周度观点 呈现
+		matchTypeNameArrZhouqi := []string{"行业深度", "调研纪要", "产业跟踪"}
+		if utils.InArrayByStr(matchTypeNameArrZhouqi, matchTypeName) {
+			matchTypeName = articleDetail.FieldName
+		}
+		item := new(models.WxUserRaiLabel)
+		item.UserId = wxUser.UserId
+		item.RealName = wxUser.RealName
+		item.Mobile = wxUser.Mobile
+		item.Email = wxUser.Email
+		item.CompanyId = wxUser.CompanyId
+		item.CompanyName = wxUser.CompanyName
+		item.Label = matchTypeName
+		item.SourceType = 8
+		item.SourceId = sourceId
+		item.CreateTime = log.CreateTime
+		item.ModifyTime = time.Now()
+		item.RegisterPlatform = log.RegisterPlatform
+		item.TableName = "cygx_article"
+		e = models.AddWxUserRaiLabel(item)
+		if e != nil {
+			err = errors.New("AddWxUserRaiLabel" + e.Error())
+			return
+		}
+	} else {
+		//正常的有产业报告
+		var labelArr []string
+		//建立首页资源表,与产业的关系
+		industrialList, e := models.GetIndustrialArticleGroupManagementListByArticleId(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetIndustrialArticleGroupManagementListByArticleId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		var items []*models.WxUserRaiLabel
+		for _, v := range industrialList {
+			item := new(models.WxUserRaiLabel)
+			item.UserId = wxUser.UserId
+			item.RealName = wxUser.RealName
+			item.Mobile = wxUser.Mobile
+			item.Email = wxUser.Email
+			item.CompanyId = wxUser.CompanyId
+			item.CompanyName = wxUser.CompanyName
+			item.Label = v.IndustryName
+			item.SourceType = 7
+			item.SourceId = sourceId
+			item.CreateTime = log.CreateTime
+			item.ModifyTime = time.Now()
+			item.RegisterPlatform = log.RegisterPlatform
+			item.TableName = "cygx_article"
+			items = append(items, item)
+			labelArr = append(labelArr, v.IndustryName)
+		}
+
+		//建立首页资源表,与标的 的关系
+		subjectList, e := models.GetSubjectArticleGroupManagementListByArtcileId(sourceId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetSubjectArticleGroupManagementListByArtcileId, Err: " + e.Error() + "sourceId:" + strconv.Itoa(sourceId))
+			return
+		}
+
+		for _, v := range subjectList {
+			item := new(models.WxUserRaiLabel)
+			item.UserId = wxUser.UserId
+			item.RealName = wxUser.RealName
+			item.Mobile = wxUser.Mobile
+			item.Email = wxUser.Email
+			item.CompanyId = wxUser.CompanyId
+			item.CompanyName = wxUser.CompanyName
+			item.Label = v.SubjectName
+			item.SourceType = 7
+			item.SourceId = sourceId
+			item.CreateTime = log.CreateTime
+			item.ModifyTime = time.Now()
+			item.RegisterPlatform = log.RegisterPlatform
+			item.TableName = "cygx_article"
+			items = append(items, item)
+			labelArr = append(labelArr, v.SubjectName)
+		}
+		e = models.AddWxUserRaiLabelMulti(items, labelArr, userId)
+		if e != nil {
+			err = errors.New("AddWxUserRaiLabelMulti" + e.Error())
+			return
+		}
 	}
 
 	return