- 门店状态变化添加发送微信通知消息
This commit is contained in:
@@ -3,33 +3,39 @@ package msg
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/weixinmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/dingding"
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func SendUserMessage(msgType, userID, title, content string) (err error) {
|
||||
const weixinTemplateID4StoreStatusChanged = "Fl0vOnBKTQqRFx3-shGKxdCnxMdQXNeODzgkuwd7oxw"
|
||||
|
||||
// todo msgType不依赖于钉钉
|
||||
func SendUserMessage(msgType string, user *model.User, title, content string) (err error) {
|
||||
userID := user.GetID()
|
||||
globals.SugarLogger.Debugf("SendUserMessage userID:%s, title:%s, content:%s", userID, title, content)
|
||||
authList, err := auth2.GetUserBindAuthInfo(userID)
|
||||
findOneMethod := false
|
||||
if err == nil {
|
||||
if title != "" {
|
||||
content = title + "\n" + content
|
||||
}
|
||||
for _, auth := range authList {
|
||||
if auth.Type == dingding.AuthTypeStaff {
|
||||
if auth.Type == dingding.AuthTypeStaff || auth.Type == weixin.AuthTypeMP {
|
||||
findOneMethod = true
|
||||
if len(content) > dingdingapi.MaxWorkContentLen {
|
||||
content = content[:dingdingapi.MaxWorkContentLen-4] + "..."
|
||||
}
|
||||
if globals.IsProductEnv() {
|
||||
if msgType == dingdingapi.MsgTyeText {
|
||||
err = api.DingDingAPI.CorpAsyncSendSimple(auth.AuthID, content)
|
||||
} else if msgType == dingdingapi.MsgTypeMarkdown {
|
||||
err = api.DingDingAPI.CorpAsyncSendMarkdown([]string{auth.AuthID}, nil, false, title, content)
|
||||
if auth.Type == dingding.AuthTypeStaff {
|
||||
if title != "" {
|
||||
content = title + "\n" + content
|
||||
}
|
||||
err = ddmsg.SendDDUserMessage(msgType, auth.AuthID, title, content)
|
||||
} else if auth.Type == weixin.AuthTypeMP && msgType != dingdingapi.MsgTypeMarkdown {
|
||||
err = weixinmsg.NotifyStoreStatusChanged(auth.AuthID, title, content)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user