- 门店状态报警格式调整,使用markdown语法

This commit is contained in:
gazebo
2019-07-17 09:22:30 +08:00
parent 13409e141f
commit b50c505336
4 changed files with 28 additions and 16 deletions

View File

@@ -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
}

View File

@@ -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)
}
}
}