- 门店状态报警格式调整,使用markdown语法
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/mobile"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/msg"
|
||||
|
||||
@@ -185,7 +187,7 @@ func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, ms
|
||||
for _, v := range receiveMsgUsersMap[msgType] {
|
||||
user, err2 := dao.GetUserByID(db, "name", v)
|
||||
if err2 == nil {
|
||||
msg.SendUserMessage(user.GetID(), msgType, msgContent)
|
||||
msg.SendUserMessage(dingdingapi.MsgTyeText, user.GetID(), msgType, msgContent)
|
||||
} else if err == nil {
|
||||
err = err2
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -1546,19 +1547,23 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
||||
curSnapshot := curSnapshotMap[v.GenMapKey()]
|
||||
storeDetail := storeDetailMap[v.StoreID]
|
||||
curStoreStatus := "无店"
|
||||
curOpTimeStr := "无店"
|
||||
if curSnapshot != nil {
|
||||
curStoreStatus = model.StoreStatusName[curSnapshot.Status]
|
||||
curOpTimeStr = jxutils.OperationTimeStr4VendorStore(curSnapshot)
|
||||
}
|
||||
txtAlarm = append(txtAlarm, fmt.Sprintf(`
|
||||
城市: %s
|
||||
门店: %s
|
||||
京西ID: %d
|
||||
平台: %s
|
||||
平台ID: %s
|
||||
之前状态: %s
|
||||
当前状态: %s`, storeDetail.CityName, storeDetail.Store.Name, v.StoreID, model.VendorChineseNames[v.VendorID], v.VendorStoreID, model.StoreStatusName[v.Status], curStoreStatus))
|
||||
txtAlarm = append(txtAlarm, fmt.Sprintf(`## 门店: %s(%d)
|
||||
- 城市: %s
|
||||
- 平台: %s
|
||||
- 平台ID: %s
|
||||
- 之前状态: %s
|
||||
- 当前状态: %s
|
||||
- 之前营业时间: %s
|
||||
- 当前营业时间: %s
|
||||
`, storeDetail.Store.Name, v.StoreID, storeDetail.CityName, model.VendorChineseNames[v.VendorID], v.VendorStoreID, model.StoreStatusName[v.Status], curStoreStatus, jxutils.OperationTimeStr4VendorStore(v), curOpTimeStr))
|
||||
}
|
||||
sendStoreStatusInfo2Mobile(mobile, title, excelURL, strings.Join(txtAlarm, "\n"))
|
||||
alarmTextStr := "# " + title + " \n \n" + strings.Join(txtAlarm, " \n") + fmt.Sprintf("[详情点我](%s/billshow/?normal=true&path=%s)\n", globals.BackstageHost, excelURL)
|
||||
sendStoreStatusInfo2Mobile(mobile, title, alarmTextStr)
|
||||
return nil, nil
|
||||
}, mobileList)
|
||||
tasksch.HandleTask(task, parentTask, true).Run()
|
||||
@@ -1571,7 +1576,7 @@ func shouldSkipMobile4SendStoreStatusInfo(mobile string) bool {
|
||||
return userProvider.GetUser(mobile, auth2.AuthTypeMobile) == nil
|
||||
}
|
||||
|
||||
func sendStoreStatusInfo2Mobile(mobile, title, excelURL, txtAlarm string) {
|
||||
func sendStoreStatusInfo2Mobile(mobile, title, txtAlarm string) {
|
||||
mobileList := []string{mobile}
|
||||
for mobile := range mobileGroupMap[mobile] {
|
||||
mobileList = append(mobileList, mobile)
|
||||
@@ -1579,8 +1584,8 @@ func sendStoreStatusInfo2Mobile(mobile, title, excelURL, txtAlarm string) {
|
||||
|
||||
for _, mobile := range mobileList {
|
||||
if user := userProvider.GetUser(mobile, auth2.AuthTypeMobile); user != nil {
|
||||
globals.SugarLogger.Debugf("sendStoreStatusInfo2Mobile %s:%s, txtAlarm:\n%s", mobile, excelURL, txtAlarm)
|
||||
msg.SendUserMessage(user.GetID(), title, fmt.Sprintf("门店状态报警\n%s\n详情见: \n%s", txtAlarm, excelURL))
|
||||
globals.SugarLogger.Debugf("sendStoreStatusInfo2Mobile %s, txtAlarm:\n%s", mobile, txtAlarm)
|
||||
msg.SendUserMessage(dingdingapi.MsgTypeMarkdown, user.GetID(), title, txtAlarm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
func SendUserMessage(userID, title, content string) (err error) {
|
||||
func SendUserMessage(msgType, userID, title, content string) (err error) {
|
||||
globals.SugarLogger.Debugf("SendUserMessage userID:%s, title:%s, content:%s", userID, title, content)
|
||||
authList, err := auth2.GetUserBindAuthInfo(userID)
|
||||
findOneMethod := false
|
||||
@@ -25,7 +25,11 @@ func SendUserMessage(userID, title, content string) (err error) {
|
||||
content = content[:dingdingapi.MaxWorkContentLen-4] + "..."
|
||||
}
|
||||
if globals.IsProductEnv() {
|
||||
err = api.DingDingAPI.CorpAsyncSendSimple(auth.AuthID, content)
|
||||
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)
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/msg"
|
||||
@@ -352,7 +353,7 @@ func (t *BaseTask) run(taskHandler func()) {
|
||||
content = fmt.Sprintf("%s执行失败,%s", taskDesc, t.Err.Error())
|
||||
}
|
||||
}
|
||||
msg.SendUserMessage(authInfo.UserID, "异步任务完成", content)
|
||||
msg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user