Browse Source

增加一个消息模板

jiaojiao7 5 năm trước cách đây
mục cha
commit
b6cb2aea76
1 tập tin đã thay đổi với 48 bổ sung1 xóa
  1. 48 1
      weixin/src/qfw/weixin/rpc/rpc.go

+ 48 - 1
weixin/src/qfw/weixin/rpc/rpc.go

@@ -26,7 +26,7 @@ const (
 	//msgnotify_tplid = "b7iuAMiTCIolnPhTdueKBVYThEMf2D-Bh2M_9v3J-68" //消息提醒
 )
 
-var identify_tplid, offLineMsg_tplid, msgnotify_tplid, managernotify_tplid, feedbacknotify_tplid, entservicenotify_tplid string
+var identify_tplid, offLineMsg_tplid, msgnotify_tplid, managernotify_tplid, feedbacknotify_tplid, entservicenotify_tplid, entservicenoticenotify_tplid string
 
 //读取配置
 func InitTpl() {
@@ -36,6 +36,7 @@ func InitTpl() {
 	managernotify_tplid = wf.SysConfig.MessageTpl["managernotifytplid"]
 	feedbacknotify_tplid = wf.SysConfig.MessageTpl["feedbacknotifytplid"]
 	entservicenotify_tplid = wf.SysConfig.MessageTpl["entservicenotifytplid"]
+	entservicenoticenotify_tplid = wf.SysConfig.MessageTpl["entservicenoticenotifytplid"]
 }
 
 //企业服务通知消息
@@ -85,6 +86,52 @@ func (wxrpc *WeiXinRpc) SendEntServiceMsg(param *qrpc.NotifyMsg, ret *qrpc.RpcRe
 	return
 }
 
+func (wxrpc *WeiXinRpc) SendEntNoticeMsg(param *qrpc.NotifyMsg, ret *qrpc.RpcResult) (err error) {
+	log.Println("tpl::", entservicenoticenotify_tplid)
+	//构造自定义消息文本
+	var msg struct {
+		ToUser   string `json:"touser"`
+		TplId    string `json:"template_id"`
+		Url      string `json:"url"`
+		Topcolor string `json:"topcolor"`
+		Data     struct {
+			Title struct {
+				Value string `json:"value"`
+			} `json:"first"`
+			Detail struct {
+				Value string `json:"value"`
+			} `json:"keyword1"`
+			Result struct {
+				Value string `json:"value"`
+			} `json:"keyword2"`
+			Remark struct {
+				Value string `json:"value"`
+			} `json:"keyword3"`
+			Service struct {
+				Value string `json:"value"`
+			} `json:"remark"`
+		} `json:"data"`
+	}
+	msg.ToUser = param.Openid
+	msg.TplId = entservicenoticenotify_tplid
+	msg.Url = param.Url
+	msg.Data.Title.Value = param.Title
+	msg.Data.Detail.Value = param.Detail
+	msg.Data.Result.Value = param.Result
+	//办理情况 由remark 换成了keyword3  适应正式环境模板
+	msg.Data.Remark.Value = param.Remark
+	//办理情况 由service 换成了remark  适应正式环境模板
+	msg.Data.Service.Value = param.Service
+	log.Println(msg)
+	err = wxrpc.wx.PostTextCustom(tplapi_url, &msg)
+	if err != nil {
+		log.Println(err.Error())
+	} else {
+		log.Println("send tplmsg success!")
+	}
+	return
+}
+
 func (wxrpc *WeiXinRpc) SendPushTplMsg(param *qrpc.NotifyMsg, ret *qrpc.RpcResult) (err error) {
 	//构造自定义消息文本
 	var msg struct {