浏览代码

feat:p459发送消息调整

fuwencai 1 年之前
父节点
当前提交
afad445cdb

+ 1 - 1
.gitignore

@@ -1,2 +1,2 @@
 /.output/
-.idea
+.idea/

+ 6 - 5
rpc/etc/message.yaml

@@ -6,8 +6,8 @@ Etcd:
   - 127.0.0.1:2379
   Key: message.rpc
 Timeout: 10000
-PushGrpcServer: 192.168.3.11:5566
-Mysql: root:=PDT49#80Z!RVv52_z@tcp(192.168.3.217:4000)/messagetest?charset=utf8mb4&parseTime=true&loc=Local
+PushGrpcServer: 192.168.3.206:5566
+Mysql: root:=PDT49#80Z!RVv52_z@tcp(192.168.3.217:4000)/messageCenter?charset=utf8mb4&parseTime=true&loc=Local
 Mongodb:
   Address: 192.168.3.206:27080
   Size: 10
@@ -18,7 +18,7 @@ Mongodb:
   Collection:
   Collection_back:
 DataSource:
-    DbName: messagetest
+    DbName: messageCenter
     Address: 192.168.3.217:4000
     UserName: root
     PassWord: =PDT49#80Z!RVv52_z
@@ -51,7 +51,7 @@ mail:
     user: public03@topnet.net.cn
 
 #发送微信模版消息
-WxWebdomain: "https://web-wky.jydev.jianyu360.com/" #微信域名
+WxWebdomain: "https://jybx2-webtest.jydev.jianyu360.com/" #微信域名
 WxTmplConfig:
   rpcAddr: 192.168.3.206:8201 #微信rpc地址
   closeNotice: "如不再接收此类信息,请在我的-设置-推送设置关闭设置。"
@@ -63,6 +63,7 @@ WxTmplConfig:
       nums: [ 150000,250000 ] #告警数量
       toMail: [ "wangkaiyue@topnet.net.cn" ] #告警邮箱收件地址
       ccMail: [ "duxin@topnet.net.cn" ] #告警邮箱抄送地址
-Tidb: "root:=PDT49#80Z!RVv52_z@tcp(192.168.3.217:4000)/messagetest?charset=utf8mb4&parseTime=true&loc=Local"
+Tidb: "root:=PDT49#80Z!RVv52_z@tcp(192.168.3.217:4000)/messageCenter?charset=utf8mb4&parseTime=true&loc=Local"
 ClassSearchList: # 需要按照messageClass 查询的groupId
   - 11  # 待办 group id
+EquityInfoMsgType: 13 #营销权益消息需要特殊处理

+ 19 - 1
rpc/internal/common/sendMsg.go

@@ -1,6 +1,7 @@
 package common
 
 import (
+	"app.yhyue.com/moapp/MessageCenter/rpc/internal/config"
 	"fmt"
 	"log"
 	"strconv"
@@ -458,6 +459,18 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
 	if class != nil && len(*class) > 0 {
 		group_id = util.IntAll((*class)["group_id"])
 	}
+	//p459 特殊处理 传过来的消息内容格式为 消息内容#jy#微信模板项目名称#jy#服务地址
+	equityName, equityAddr := "", ""
+	if this.MsgType == config.ConfigJson.EquityInfoMsgType {
+		equityRs := strings.Split(this.Content, "#jy#")
+		if len(equityRs) != 3 {
+			log.Println("消息内容格式有误:", this.Content)
+			return 0, "无效的消息内容格式"
+		}
+		this.Content = equityRs[0]
+		equityName = equityRs[1]
+		equityAddr = equityRs[2]
+	}
 	for i := 0; i < len(userIdArr); i++ {
 		if userIdArr[i] == "" {
 			continue
@@ -528,7 +541,12 @@ func MultSave(this message.MultipleSaveMsgReq) (int64, string) {
 				}
 				// 消息模版 工单类型 {{thing19.DATA}} 工单标题 {{thing6.DATA}} 项目名称 {{thing13.DATA}} 服务时间 {{time25.DATA}} 服务地址 {{thing26.DATA}}
 				if this.MsgType != 1 && this.MsgType != 10 {
-					err = p.SendMsg(this.WxPushUrl, this.Title, this.Content, nTime, this.Row4)
+					if this.MsgType == config.ConfigJson.EquityInfoMsgType {
+						// p459 服务地址特殊处理
+						err = p.SendMsg(this.WxPushUrl, this.Title, equityName, nTime, this.Row4, equityAddr)
+					} else {
+						err = p.SendMsg(this.WxPushUrl, this.Title, this.Content, nTime, this.Row4, "")
+					}
 					if err != nil {
 						logx.Error(fmt.Sprintf("SendWxTmplMsg uId %s  Error %s", v, err.Error()))
 					} else {

+ 8 - 4
rpc/internal/common/sendWxTmplMsg.go

@@ -85,7 +85,7 @@ func GetWxTmplConfig(msgType int64) (*WxTmplConfig, error) {
 	return nil, fmt.Errorf("未知消息类型")
 }
 
-func (stm *WxTmplPush) SendMsg(link, title, detail, date, row4 string) error {
+func (stm *WxTmplPush) SendMsg(link, title, detail, date, row4 string, note string) error {
 	if stm.Config == nil || stm.Config.TmplId == "" || (stm.MgoId != "" && stm.OpenId != "" && stm.Position != "") || link == "" {
 		return fmt.Errorf("缺少参数 stm.Config.TmplId:%v stm.MgoId:%v  stm.OpenId:%v stm.Position:%v link:%v ", stm.Config.TmplId, stm.MgoId, stm.OpenId, stm.Position, link)
 	}
@@ -105,7 +105,7 @@ func (stm *WxTmplPush) SendMsg(link, title, detail, date, row4 string) error {
 		}
 	} else {
 		// 获取消息
-		msgTemp, err := stm.getMessage(title, detail, date, row4)
+		msgTemp, err := stm.getMessage(title, detail, date, row4, note)
 		if err != nil {
 			return err
 		}
@@ -135,7 +135,7 @@ var (
 )
 
 // getMessage 获取消息内容
-func (stm *WxTmplPush) getMessage(title, detail, date, row4 string) (map[string]*qrpc.TmplItem, error) {
+func (stm *WxTmplPush) getMessage(title, detail, date, row4 string, note string) (map[string]*qrpc.TmplItem, error) {
 	var formatValue string = stm.Config.TmplValue
 	for _, key := range allMsgValueKeys {
 		switch key {
@@ -150,7 +150,11 @@ func (stm *WxTmplPush) getMessage(title, detail, date, row4 string) (map[string]
 		case "$row4":
 			formatValue = strings.ReplaceAll(formatValue, key, regSpecial.ReplaceAllString(row4, ""))
 		case "$note":
-			formatValue = strings.ReplaceAll(formatValue, key, regSpecial.ReplaceAllString(config.ConfigJson.WxTmplConfig.CloseNotice, ""))
+			if note == "" {
+				formatValue = strings.ReplaceAll(formatValue, key, regSpecial.ReplaceAllString(config.ConfigJson.WxTmplConfig.CloseNotice, ""))
+			} else {
+				formatValue = strings.ReplaceAll(formatValue, key, regSpecial.ReplaceAllString(note, ""))
+			}
 		}
 	}
 	bValue := map[string]*qrpc.TmplItem{}

+ 3 - 2
rpc/internal/config/config.go

@@ -23,8 +23,9 @@ type Config struct {
 		Pwd  string `json:"pwd"`
 		User string `json:"user"`
 	} `json:"mail"`
-	TidbEng         string  `json:"Tidb"`
-	ClassSearchList []int64 `json:"ClassSearchList"` // 需要按照messageclass 查询的groupId
+	TidbEng           string  `json:"Tidb"`
+	ClassSearchList   []int64 `json:"ClassSearchList"`   // 需要按照messageclass 查询的groupId
+	EquityInfoMsgType int64   `json:"EquityInfoMsgType"` // 营销权益消息需要特殊处理的消息类型
 }
 
 type mysqlConfig struct {

+ 1 - 1
rpc/internal/logic/sendwxtmplmsglogic.go

@@ -64,7 +64,7 @@ func (l *SendWxTmplMsgLogic) SendWxTmplMsg(in *message.WxTmplMsgRequest) (*messa
 			p.Position = uId
 		}
 		// 消息模版 工单类型 {{thing19.DATA}} 工单标题 {{thing6.DATA}} 项目名称 {{thing13.DATA}} 服务时间 {{time25.DATA}} 服务地址 {{thing26.DATA}}
-		err = p.SendMsg(in.Url, in.Title, in.Detail, in.Date, in.Row4)
+		err = p.SendMsg(in.Url, in.Title, in.Detail, in.Date, in.Row4, "")
 		if err != nil {
 			logx.Error(fmt.Sprintf("SendWxTmplMsg uId %s  Error %s", uId, err.Error()))
 		} else {