|
|
|
|
package workwechat
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"key_performance_indicators/middleware/wechatapp/wechatstatice"
|
|
|
|
|
"key_performance_indicators/models/modelskpi"
|
|
|
|
|
"key_performance_indicators/overall/publicmethod"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 发送文本通知消息
|
|
|
|
|
func (s *SentMessage) SendMessage() (callBackByte []byte, err error) {
|
|
|
|
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl("kpi", "send")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%v---------sendUrl, token----------->%v\n", sendUrl, token)
|
|
|
|
|
|
|
|
|
|
sendDate, _ := json.Marshal(s)
|
|
|
|
|
callBackByte = publicmethod.CurlPostJosn(sendUrl, sendDate)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 发送迷你信息设定
|
|
|
|
|
func (sendMsg *SentSmallMessage) InitMes() *SentSmallMessage {
|
|
|
|
|
sendMsg.MsgType = "template_card"
|
|
|
|
|
sendMsg.AgentId = 1000036
|
|
|
|
|
sendMsg.EnableIdTrans = 0
|
|
|
|
|
sendMsg.EnableDuplicateCheck = 0
|
|
|
|
|
sendMsg.DuplicateCheckInterval = 1800
|
|
|
|
|
|
|
|
|
|
// var templateCard TemplateCardMsgContMini
|
|
|
|
|
sendMsg.TemplateCard.CardType = "text_notice"
|
|
|
|
|
//头部左标题部分
|
|
|
|
|
sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
|
|
|
sendMsg.TemplateCard.Source.DescColor = 1
|
|
|
|
|
//引用文献样式
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Type = 0
|
|
|
|
|
//整体卡片的点击跳转事件,text_notice必填本字段
|
|
|
|
|
sendMsg.TemplateCard.CardAction.Type = 1
|
|
|
|
|
// sendMsg.TemplateCard = templateCard
|
|
|
|
|
return sendMsg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 发送迷你信息设定
|
|
|
|
|
func (sendMsg *SentMiniMessage) InitMes() *SentMiniMessage {
|
|
|
|
|
sendMsg.MsgType = "template_card"
|
|
|
|
|
sendMsg.AgentId = 1000036
|
|
|
|
|
sendMsg.EnableIdTrans = 0
|
|
|
|
|
sendMsg.EnableDuplicateCheck = 0
|
|
|
|
|
sendMsg.DuplicateCheckInterval = 1800
|
|
|
|
|
|
|
|
|
|
// var templateCard TemplateCardMsgContMini
|
|
|
|
|
sendMsg.TemplateCard.CardType = "text_notice"
|
|
|
|
|
//头部左标题部分
|
|
|
|
|
sendMsg.TemplateCard.Source.IconUrl = "https://docu.hxgk.group/images/2022_01/3f7a1120a559e9bee3991b85eb34d103.png"
|
|
|
|
|
sendMsg.TemplateCard.Source.DescColor = 1
|
|
|
|
|
//引用文献样式
|
|
|
|
|
sendMsg.TemplateCard.QuoteArea.Type = 0
|
|
|
|
|
//整体卡片的点击跳转事件,text_notice必填本字段
|
|
|
|
|
sendMsg.TemplateCard.CardAction.Type = 1
|
|
|
|
|
// sendMsg.TemplateCard = templateCard
|
|
|
|
|
return sendMsg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 发送迷你文本通知消息
|
|
|
|
|
func (s *SentMiniMessage) SendMessage() (callBackByte []byte, err error) {
|
|
|
|
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl("kpi", "send")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%v---------sendUrl, token----------->%v\n", sendUrl, token)
|
|
|
|
|
|
|
|
|
|
sendDate, _ := json.Marshal(s)
|
|
|
|
|
callBackByte = publicmethod.CurlPostJosn(sendUrl, sendDate)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 发送迷你文本通知消息
|
|
|
|
|
func (s *SentSmallMessage) SendMessage() (callBackByte []byte, err error) {
|
|
|
|
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl("kpi", "send")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%v---------sendUrl, token----------->%v\n", sendUrl, token)
|
|
|
|
|
|
|
|
|
|
sendDate, _ := json.Marshal(s)
|
|
|
|
|
callBackByte = publicmethod.CurlPostJosn(sendUrl, sendDate)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新文本通知消息
|
|
|
|
|
func (s *UpdateMessage) UpdateMessage() (callBackByte []byte, err error) {
|
|
|
|
|
sendUrl, token, err := wechatstatice.GetSendMsgTokenUrl("kpi", "update")
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("%v---------sendUrl, token----------->%v\n", sendUrl, token)
|
|
|
|
|
|
|
|
|
|
sendDate, _ := json.Marshal(s)
|
|
|
|
|
callBackByte = publicmethod.CurlPostJosn(sendUrl, sendDate)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-04-24 08:22:22
|
|
|
|
|
@ 功能: 写入企业微信模版信息发送回调
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#wechatCallBack 文本发送回调
|
|
|
|
|
#sendMsg 发送文本信息
|
|
|
|
|
#typeClass 类型(1:文本通知型;2:图文展示型;3:按钮交互型;4:投票选择型;5:多项选择型)
|
|
|
|
|
#ordeeId 审批记录Id
|
|
|
|
|
#enforcer 接收人
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#err
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#func WriteUpdateWechatTempmsg(wechatCallBack []byte, sendMsg SentMiniMessage, typeClass int, ordeeId int64, enforcer []string) (err error)
|
|
|
|
|
*/
|
|
|
|
|
func WriteUpdateWechatTempmsg(wechatCallBack []byte, sendMsg SentMiniMessage, typeClass int, ordeeId int64, enforcer []string) (err error) {
|
|
|
|
|
var weChatCallBack publicmethod.WechatCallBack
|
|
|
|
|
err = json.Unmarshal(wechatCallBack, &weChatCallBack)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if weChatCallBack.Errcode != 0 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
sendMsgJson, err := json.Marshal(sendMsg)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var insetCont modelskpi.UpdateWechatTempmsg
|
|
|
|
|
insetCont.Type = typeClass //类型(1:文本通知型;2:图文展示型;3:按钮交互型;4:投票选择型;5:多项选择型)"`
|
|
|
|
|
insetCont.Sendmsgcont = string(sendMsgJson) //发送文件信息"`
|
|
|
|
|
insetCont.Msgid = weChatCallBack.MsgId //消息id,用于撤回应用消息"`
|
|
|
|
|
insetCont.ResponseCode = weChatCallBack.ResponseCode //仅消息类型为“按钮交互型”,“投票选择型”和“多项选择型”的模板卡片消息返回,应用可使用response_code调用更新模版卡片消息接口,72小时内有效,且只能使用一次"`
|
|
|
|
|
insetCont.Orderkey = ordeeId //流程id"`
|
|
|
|
|
insetCont.Enforcer = strings.Join(enforcer, ",") //执行人"`
|
|
|
|
|
insetCont.State = 2 //状态(1:已执行更新;2:未执行更新)"`
|
|
|
|
|
insetCont.TaskId = sendMsg.TemplateCard.TaskId //任务id,同一个应用任务id不能重复,只能由数字、字母和“_-@”组成,最长128字节,填了action_menu字段的话本字段必填"`
|
|
|
|
|
insetCont.Time = time.Now().Unix() //写入时间"`
|
|
|
|
|
err = insetCont.AddCont()
|
|
|
|
|
return
|
|
|
|
|
}
|