You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
4.9 KiB
151 lines
4.9 KiB
|
3 years ago
|
package wechatcallback
|
||
|
|
|
||
|
|
import (
|
||
|
|
"encoding/json"
|
||
|
|
"encoding/xml"
|
||
|
|
"fmt"
|
||
|
|
"key_performance_indicators/middleware/wechatapp/wechatsendmsg"
|
||
|
|
"key_performance_indicators/models/modelskpi"
|
||
|
|
"key_performance_indicators/overall"
|
||
|
|
"strconv"
|
||
|
|
"strings"
|
||
|
|
|
||
|
|
"github.com/gin-gonic/gin"
|
||
|
|
)
|
||
|
|
|
||
|
|
// 事件处理
|
||
|
|
func EventProcessing(msg []byte, c *gin.Context) {
|
||
|
|
//通用类型判断是回调的什么事件
|
||
|
|
var commonType CurrencyMessage
|
||
|
|
xml.Unmarshal(msg, &commonType)
|
||
|
|
switch commonType.Event {
|
||
|
|
case "subscribe": //关注
|
||
|
|
case "unsubscribe": //取消关注
|
||
|
|
case "enter_agent": //本事件在成员进入企业微信的应用时触发
|
||
|
|
case "LOCATION": //上报地理位置
|
||
|
|
GeographicalPosition(msg)
|
||
|
|
case "batch_job_result": //异步任务完成事件推送
|
||
|
|
case "change_contact": //通讯录变更事件
|
||
|
|
// WorkWechatMailList(msgContent.ChangeType, decryptMsg)
|
||
|
|
case "click": //点击菜单拉取消息的事件推送
|
||
|
|
case "view": //点击菜单跳转链接的事件推送
|
||
|
|
case "scancode_push": //扫码推事件的事件推送
|
||
|
|
case "scancode_waitmsg": //扫码推事件且弹出“消息接收中”提示框的事件推送
|
||
|
|
case "pic_sysphoto": //弹出系统拍照发图的事件推送
|
||
|
|
case "pic_photo_or_album": //弹出拍照或者相册发图的事件推送
|
||
|
|
case "pic_weixin": //弹出微信相册发图器的事件推送
|
||
|
|
case "location_select": //弹出地理位置选择器的事件推送
|
||
|
|
case "open_approval_change": //审批状态通知事件 自建应用
|
||
|
|
// OpenApprovalChange(decryptMsg)
|
||
|
|
case "sys_approval_change": //系统审批应用
|
||
|
|
case "share_agent_change": //企业互联共享应用事件回调
|
||
|
|
case "share_chain_change": //上下游共享应用事件回调
|
||
|
|
case "template_card_event": //模板卡片事件推送
|
||
|
|
TemplateEvent(msg)
|
||
|
|
case "template_card_menu_event": //通用模板卡片右上角菜单事件推送
|
||
|
|
default:
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// 模板事件处理
|
||
|
|
func TemplateEvent(msg []byte) {
|
||
|
|
var msgCont ButtonEventQuestion
|
||
|
|
err := xml.Unmarshal(msg, &msgCont)
|
||
|
|
if err != nil {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
eventKeyAry := strings.Split(msgCont.EventKey, "_")
|
||
|
|
buttionLen := len(eventKeyAry)
|
||
|
|
if buttionLen >= 5 {
|
||
|
|
// for i, v := range eventKeyAry {
|
||
|
|
|
||
|
|
// fmt.Printf("eventKeyAry:%v====================>%v==================>%v\n", i, v, eventKeyAry[i])
|
||
|
|
// }
|
||
|
|
switch eventKeyAry[0] {
|
||
|
|
case "school":
|
||
|
|
default: //默认系统
|
||
|
|
if eventKeyAry[1] == "post" {
|
||
|
|
//岗位考核
|
||
|
|
} else {
|
||
|
|
//部门考核
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
jsonStr, _ := json.Marshal(msgCont)
|
||
|
|
fmt.Printf("TemplateEvent======>%v\n", string(jsonStr))
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/*
|
||
|
|
*
|
||
|
|
@ 作者: 秦东
|
||
|
|
@ 时间: 2022-10-05 15:46:05
|
||
|
|
@ 功能: 岗位按钮模板回调处理
|
||
|
|
@ 参数
|
||
|
|
|
||
|
|
#orderId 流程Key
|
||
|
|
#clickEnter 1:同意;2:驳回
|
||
|
|
#systemApp 系统
|
||
|
|
#step 步进位
|
||
|
|
|
||
|
|
@ 返回值
|
||
|
|
|
||
|
|
#
|
||
|
|
*/
|
||
|
|
func (b *ButtonEventQuestion) PostTemolateCallBack(orderId, clickEnter, systemApp, step string) {
|
||
|
|
//1、判断当前流程状态
|
||
|
|
var flowCont modelskpi.PostWorkflowOrders
|
||
|
|
err := flowCont.GetCont(map[string]interface{}{"`order_id`": orderId})
|
||
|
|
if err != nil {
|
||
|
|
var sendMsgText wechatsendmsg.SendTextCard
|
||
|
|
sendMsgText.Touser = b.FromUsername
|
||
|
|
sendMsgText.Msgtype = "textcard"
|
||
|
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
|
||
|
|
sendMsgText.Agentid = agentIdInt
|
||
|
|
sendMsgText.EnableDuplicateCheck = 0
|
||
|
|
sendMsgText.DuplicateCheckInterval = 1800
|
||
|
|
sendMsgText.EnableIdTrans = 0
|
||
|
|
sendMsgText.MsgBody.Title = "流程关闭"
|
||
|
|
sendMsgText.MsgBody.Description = "此审批流程已经关闭!请联系发起人!"
|
||
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId)
|
||
|
|
sendMsgText.MsgBody.URL = jumpUrl
|
||
|
|
sendMsgText.MsgBody.BtnTxt = ""
|
||
|
|
sendMsgText.SendMsg(systemApp)
|
||
|
|
return
|
||
|
|
} else {
|
||
|
|
var sendMsgText wechatsendmsg.SendTextCard
|
||
|
|
sendMsgText.Touser = b.FromUsername
|
||
|
|
sendMsgText.Msgtype = "textcard"
|
||
|
|
agentIdInt, _ := strconv.ParseInt(overall.CONSTANT_CONFIG.WechatKpi.Agentid, 10, 64)
|
||
|
|
sendMsgText.Agentid = agentIdInt
|
||
|
|
sendMsgText.EnableDuplicateCheck = 0
|
||
|
|
sendMsgText.DuplicateCheckInterval = 1800
|
||
|
|
sendMsgText.EnableIdTrans = 0
|
||
|
|
|
||
|
|
jumpUrl := fmt.Sprintf("http://new.hxgk.group/#/responsible?id=%v", orderId)
|
||
|
|
sendMsgText.MsgBody.URL = jumpUrl
|
||
|
|
sendMsgText.MsgBody.BtnTxt = "查看详情"
|
||
|
|
switch flowCont.State {
|
||
|
|
case 4:
|
||
|
|
sendMsgText.MsgBody.Title = "流程归档"
|
||
|
|
sendMsgText.MsgBody.Description = "此审批流程已经归档!不可继续操作!"
|
||
|
|
sendMsgText.SendMsg(systemApp)
|
||
|
|
return
|
||
|
|
case 5:
|
||
|
|
sendMsgText.MsgBody.Title = "流程废弃"
|
||
|
|
sendMsgText.MsgBody.Description = "此审批流程已经废弃!不可继续操作!"
|
||
|
|
sendMsgText.SendMsg(systemApp)
|
||
|
|
return
|
||
|
|
case 6:
|
||
|
|
sendMsgText.MsgBody.Title = "流程不存在"
|
||
|
|
sendMsgText.MsgBody.Description = "此审批流程不存在!请联系发起人!"
|
||
|
|
sendMsgText.SendMsg(systemApp)
|
||
|
|
return
|
||
|
|
default:
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//判断当前步进位是否已经被操作
|
||
|
|
var operatorIsTreu modelskpi.OpenApprovalChangeLog
|
||
|
|
err = operatorIsTreu.GetCont(map[string]interface{}{"`orderid`": orderId, `stepper`: step})
|
||
|
|
}
|