- 门店状态变化添加发送微信通知消息
This commit is contained in:
@@ -196,7 +196,7 @@ func SendMsg2Somebody(ctx *jxcontext.Context, mobileNum, verifyCode, msgType, ms
|
|||||||
for _, v := range receiveMsgUsersMap[msgType] {
|
for _, v := range receiveMsgUsersMap[msgType] {
|
||||||
user, err2 := dao.GetUserByID(db, "name", v)
|
user, err2 := dao.GetUserByID(db, "name", v)
|
||||||
if err2 == nil {
|
if err2 == nil {
|
||||||
msg.SendUserMessage(dingdingapi.MsgTyeText, user.GetID(), msgType, msgContent)
|
msg.SendUserMessage(dingdingapi.MsgTyeText, user, msgType, msgContent)
|
||||||
} else if err == nil {
|
} else if err == nil {
|
||||||
err = err2
|
err = err2
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||||
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
||||||
@@ -99,14 +99,6 @@ var (
|
|||||||
"11:00:00",
|
"11:00:00",
|
||||||
"15:00:00",
|
"15:00:00",
|
||||||
}
|
}
|
||||||
|
|
||||||
mobileGroupMap = map[string]map[string]int{
|
|
||||||
"18650801532": map[string]int{ // 陈磊
|
|
||||||
"13540967462": 1, // 蒋龙丹
|
|
||||||
"13708196093": 1, // 顾子杭
|
|
||||||
"13980795039": 1, // 赵凌兰
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样
|
// todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样
|
||||||
@@ -1537,9 +1529,9 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
|||||||
}
|
}
|
||||||
curSnapshotMap := make(map[string]*model.VendorStoreSnapshot)
|
curSnapshotMap := make(map[string]*model.VendorStoreSnapshot)
|
||||||
curSnapshotMap2 := make(map[int]map[int]*model.VendorStoreSnapshot)
|
curSnapshotMap2 := make(map[int]map[int]*model.VendorStoreSnapshot)
|
||||||
alarmSnapshotMap := make(map[int][]*model.VendorStoreSnapshot)
|
|
||||||
curSnapshotGroupMap := make(map[int][]*model.VendorStoreSnapshot)
|
curSnapshotGroupMap := make(map[int][]*model.VendorStoreSnapshot)
|
||||||
|
|
||||||
|
alarmSnapshotMap := make(map[int][]*model.VendorStoreSnapshot)
|
||||||
txtAlarmSnapshotMap := make(map[int][]*model.VendorStoreSnapshot)
|
txtAlarmSnapshotMap := make(map[int][]*model.VendorStoreSnapshot)
|
||||||
// 之前是开店当前是关店的,或营业时间缩短的
|
// 之前是开店当前是关店的,或营业时间缩短的
|
||||||
for _, v := range curSnapshotList {
|
for _, v := range curSnapshotList {
|
||||||
@@ -1579,6 +1571,7 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
|||||||
|
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
storeDetailMap := make(map[int]*dao.StoreDetail)
|
storeDetailMap := make(map[int]*dao.StoreDetail)
|
||||||
|
userMap2 := make(map[string]*model.User)
|
||||||
userMap := make(map[string]map[int]int)
|
userMap := make(map[string]map[int]int)
|
||||||
userMapTxt := make(map[string][]*model.VendorStoreSnapshot)
|
userMapTxt := make(map[string][]*model.VendorStoreSnapshot)
|
||||||
for storeID, list := range alarmSnapshotMap {
|
for storeID, list := range alarmSnapshotMap {
|
||||||
@@ -1586,57 +1579,51 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
|||||||
if storeDetail != nil {
|
if storeDetail != nil {
|
||||||
storeDetailMap[storeID] = storeDetail
|
storeDetailMap[storeID] = storeDetail
|
||||||
|
|
||||||
// userList, _ := GetRoleUserList(ctx, autils.NewStoreBossRole(storeID))
|
var userList []*model.User
|
||||||
// for _, mobile := range []string{storeDetail.Tel1, storeDetail.MarketManPhone, storeDetail.OperatorPhone} {
|
if roleUserIDList, err := GetRoleUserList(ctx, autils.NewStoreBossRole(storeID)); err == nil {
|
||||||
// if mobile != "" {
|
userList, _, _ = dao.GetUsers(db, 0, "", roleUserIDList, "", "", 0, -1)
|
||||||
// if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil {
|
}
|
||||||
// userList = append(userList, user.GetID())
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// for _, userID := range userList {
|
|
||||||
// if userID != "" {
|
|
||||||
// if userMap[userID] == nil {
|
|
||||||
// userMap[userID] = make(map[int]int)
|
|
||||||
// }
|
|
||||||
// userMap[userID][storeID] = 1
|
|
||||||
// if txtAlarmSnapshotMap[storeID] != nil {
|
|
||||||
// userMapTxt[userID] = append(userMapTxt[userID], txtAlarmSnapshotMap[storeID]...)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
for _, mobile := range []string{storeDetail.Tel1, storeDetail.MarketManPhone, storeDetail.OperatorPhone} {
|
for _, mobile := range []string{storeDetail.Tel1, storeDetail.MarketManPhone, storeDetail.OperatorPhone} {
|
||||||
if mobile != "" {
|
if mobile != "" {
|
||||||
if userMap[mobile] == nil {
|
if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil {
|
||||||
userMap[mobile] = make(map[int]int)
|
userList = append(userList, user)
|
||||||
}
|
}
|
||||||
userMap[mobile][storeID] = 1
|
}
|
||||||
|
}
|
||||||
|
processedUser := make(map[string]int)
|
||||||
|
for _, user := range userList {
|
||||||
|
userID := user.GetID()
|
||||||
|
if processedUser[userID] == 0 {
|
||||||
|
processedUser[userID] = 1
|
||||||
|
if userMap[userID] == nil {
|
||||||
|
userMap[userID] = make(map[int]int)
|
||||||
|
userMap2[userID] = user
|
||||||
|
}
|
||||||
|
userMap[userID][storeID] = 1
|
||||||
if txtAlarmSnapshotMap[storeID] != nil {
|
if txtAlarmSnapshotMap[storeID] != nil {
|
||||||
userMapTxt[mobile] = append(userMapTxt[mobile], txtAlarmSnapshotMap[storeID]...)
|
userMapTxt[userID] = append(userMapTxt[userID], txtAlarmSnapshotMap[storeID]...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var mobileList []string
|
var userList []*model.User
|
||||||
for mobile := range userMap {
|
for _, user := range userMap2 {
|
||||||
if mobile != "" && !shouldSkipMobile4SendStoreStatusInfo(mobile) {
|
userList = append(userList, user)
|
||||||
mobileList = append(mobileList, mobile)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(mobileList) > 0 {
|
if len(userList) > 0 {
|
||||||
const fixTitle = "门店状态变化"
|
const fixTitle = "门店状态变化"
|
||||||
title := fmt.Sprintf("%s:%s-->%s", fixTitle, utils.Time2Str(prevSnapshotList[0].SnapshotAt), utils.Time2Str(curSnapshotList[0].SnapshotAt))
|
title := fmt.Sprintf("%s:%s-->%s", fixTitle, utils.Time2Str(prevSnapshotList[0].SnapshotAt), utils.Time2Str(curSnapshotList[0].SnapshotAt))
|
||||||
task := tasksch.NewParallelTask("SendAlarmVendorSnapshot", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
task := tasksch.NewParallelTask("SendAlarmVendorSnapshot", tasksch.NewParallelConfig().SetIsContinueWhenError(true), ctx,
|
||||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
mobile := batchItemList[0].(string)
|
user := batchItemList[0].(*model.User)
|
||||||
|
var excelURL string
|
||||||
|
if user.Type&model.UserTypeOperator != 0 {
|
||||||
var dataList []map[string]interface{}
|
var dataList []map[string]interface{}
|
||||||
captionList := []string{"京西门店ID", "门店名", "城市"}
|
captionList := []string{"京西门店ID", "门店名", "城市"}
|
||||||
isFirstRow := true
|
isFirstRow := true
|
||||||
for storeID := range userMap[mobile] {
|
for storeID := range userMap[user.GetID()] {
|
||||||
prevAlarmMap := prevSnapshotMap2[storeID]
|
prevAlarmMap := prevSnapshotMap2[storeID]
|
||||||
curAlarmMap := curSnapshotMap2[storeID]
|
curAlarmMap := curSnapshotMap2[storeID]
|
||||||
data := map[string]interface{}{
|
data := map[string]interface{}{
|
||||||
@@ -1692,17 +1679,17 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
|||||||
excelBin := excel.Obj2Excel([]*excel.Obj2ExcelSheetConfig{excelConf})
|
excelBin := excel.Obj2Excel([]*excel.Obj2ExcelSheetConfig{excelConf})
|
||||||
keyPart := []string{
|
keyPart := []string{
|
||||||
"store_status",
|
"store_status",
|
||||||
mobile,
|
user.GetMobile(),
|
||||||
time.Now().Format("20060102T150405") + ".xlsx",
|
time.Now().Format("20060102T150405") + ".xlsx",
|
||||||
}
|
}
|
||||||
key := "export/" + strings.Join(keyPart, "_")
|
key := "export/" + strings.Join(keyPart, "_")
|
||||||
excelURL, err2 := jxutils.UploadExportContent(excelBin, key)
|
excelURL, err = jxutils.UploadExportContent(excelBin, key)
|
||||||
if err2 != nil {
|
if err != nil {
|
||||||
globals.SugarLogger.Warnf("SendAlarmVendorSnapshot, send %s failed with error:%v", key, err2)
|
globals.SugarLogger.Warnf("SendAlarmVendorSnapshot, %s upload %s failed with error:%v", user.GetName(), key, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var txtAlarm []string
|
var txtAlarm []string
|
||||||
for _, v := range userMapTxt[mobile] {
|
|
||||||
|
for _, v := range userMapTxt[user.GetID()] {
|
||||||
curSnapshot := curSnapshotMap[v.GenMapKey()]
|
curSnapshot := curSnapshotMap[v.GenMapKey()]
|
||||||
storeDetail := storeDetailMap[v.StoreID]
|
storeDetail := storeDetailMap[v.StoreID]
|
||||||
curStoreStatus := "无店"
|
curStoreStatus := "无店"
|
||||||
@@ -1722,31 +1709,31 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
|
|||||||
`, storeDetail.Store.Name, v.StoreID, storeDetail.CityName, model.VendorChineseNames[v.VendorID], v.VendorStoreID, model.StoreStatusName[v.Status], curStoreStatus, jxutils.OperationTimeStr4VendorStore(v), curOpTimeStr))
|
`, storeDetail.Store.Name, v.StoreID, storeDetail.CityName, model.VendorChineseNames[v.VendorID], v.VendorStoreID, model.StoreStatusName[v.Status], curStoreStatus, jxutils.OperationTimeStr4VendorStore(v), curOpTimeStr))
|
||||||
}
|
}
|
||||||
alarmTextStr := "# " + title + " \n" + fmt.Sprintf("[详情点我](%s/billshow/?normal=true&path=%s) \n", globals.BackstageHost, excelURL) + strings.Join(txtAlarm, " \n")
|
alarmTextStr := "# " + title + " \n" + fmt.Sprintf("[详情点我](%s/billshow/?normal=true&path=%s) \n", globals.BackstageHost, excelURL) + strings.Join(txtAlarm, " \n")
|
||||||
sendStoreStatusInfo2Mobile(mobile, title, alarmTextStr)
|
sendStoreStatusInfo2Mobile(user, dingdingapi.MsgTypeMarkdown, title, alarmTextStr)
|
||||||
|
} else if len(userMapTxt[user.GetID()]) > 0 {
|
||||||
|
var txtAlarm []string
|
||||||
|
for _, v := range userMapTxt[user.GetID()] {
|
||||||
|
curSnapshot := curSnapshotMap[v.GenMapKey()]
|
||||||
|
// storeDetail := storeDetailMap[v.StoreID]
|
||||||
|
curStoreStatus := "下线"
|
||||||
|
if curSnapshot != nil && curSnapshot.Status == model.StoreStatusOpened {
|
||||||
|
curStoreStatus = "上线"
|
||||||
|
}
|
||||||
|
txtAlarm = append(txtAlarm, fmt.Sprintf("您的门店:%s,平台:%s,%s了", v.StoreName, model.VendorChineseNames[v.VendorID], curStoreStatus))
|
||||||
|
}
|
||||||
|
alarmTextStr := strings.Join(txtAlarm, ",\n")
|
||||||
|
sendStoreStatusInfo2Mobile(user, dingdingapi.MsgTyeText, title, alarmTextStr)
|
||||||
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}, mobileList)
|
}, userList)
|
||||||
tasksch.HandleTask(task, parentTask, true).Run()
|
tasksch.HandleTask(task, parentTask, true).Run()
|
||||||
_, err = task.GetResult(0)
|
_, err = task.GetResult(0)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldSkipMobile4SendStoreStatusInfo(mobile string) bool {
|
func sendStoreStatusInfo2Mobile(user *model.User, msgType, title, txtAlarm string) {
|
||||||
return userProvider.GetUser(mobile, auth2.AuthTypeMobile) == nil
|
msg.SendUserMessage(msgType, user, title, txtAlarm)
|
||||||
}
|
|
||||||
|
|
||||||
func sendStoreStatusInfo2Mobile(mobile, title, txtAlarm string) {
|
|
||||||
mobileList := []string{mobile}
|
|
||||||
for mobile := range mobileGroupMap[mobile] {
|
|
||||||
mobileList = append(mobileList, mobile)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, mobile := range mobileList {
|
|
||||||
if user := userProvider.GetUser(mobile, auth2.AuthTypeMobile); user != nil {
|
|
||||||
globals.SugarLogger.Debugf("sendStoreStatusInfo2Mobile %s, txtAlarm:\n%s", mobile, txtAlarm)
|
|
||||||
msg.SendUserMessage(dingdingapi.MsgTypeMarkdown, user.GetID(), title, txtAlarm)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync bool) (err error) {
|
func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync bool) (err error) {
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ func TestGetStoresVendorSnapshot(t *testing.T) {
|
|||||||
|
|
||||||
func TestSendAlarmVendorSnapshot(t *testing.T) {
|
func TestSendAlarmVendorSnapshot(t *testing.T) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
prevSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-07-16 10:00:00"))
|
prevSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-09 10:00:00"))
|
||||||
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-07-16 11:00:00"))
|
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-09 11:00:00"))
|
||||||
err := SendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, prevSnapshotList, curSnapshotList)
|
err := SendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, prevSnapshotList, curSnapshotList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
|||||||
49
business/jxutils/ddmsg/ddmsg.go
Normal file
49
business/jxutils/ddmsg/ddmsg.go
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
package ddmsg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"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 SendDDUserMessage(msgType, ddUserID, title, content string) (err error) {
|
||||||
|
globals.SugarLogger.Debugf("SendDDUserMessage ddUserID:%s, title:%s, content:%s", ddUserID, title, content)
|
||||||
|
if globals.IsProductEnv() {
|
||||||
|
if msgType == dingdingapi.MsgTyeText {
|
||||||
|
err = api.DingDingAPI.CorpAsyncSendSimple(ddUserID, content)
|
||||||
|
} else if msgType == dingdingapi.MsgTypeMarkdown {
|
||||||
|
err = api.DingDingAPI.CorpAsyncSendMarkdown([]string{ddUserID}, nil, false, title, content)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
if err == nil {
|
||||||
|
for _, auth := range authList {
|
||||||
|
if auth.Type == dingding.AuthTypeStaff || auth.Type == weixin.AuthTypeMP {
|
||||||
|
findOneMethod = true
|
||||||
|
if msgType == dingdingapi.MsgTypeMarkdown && len(content) > dingdingapi.MaxWorkContentLen {
|
||||||
|
content = content[:dingdingapi.MaxWorkContentLen-4] + "..."
|
||||||
|
}
|
||||||
|
err = SendDDUserMessage(msgType, auth.AuthID, title, content)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !findOneMethod {
|
||||||
|
err = fmt.Errorf("用户[%s]找不到至少一个有效的通讯方式", userID)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
globals.SugarLogger.Infof("SendUserMessage userID:%s, title:%s, content:%s failed with error:%v", userID, title, content, err)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
@@ -3,33 +3,39 @@ package msg
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"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/baseapi/platformapi/dingdingapi"
|
||||||
"git.rosy.net.cn/jx-callback/business/auth2"
|
"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/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"
|
||||||
"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)
|
globals.SugarLogger.Debugf("SendUserMessage userID:%s, title:%s, content:%s", userID, title, content)
|
||||||
authList, err := auth2.GetUserBindAuthInfo(userID)
|
authList, err := auth2.GetUserBindAuthInfo(userID)
|
||||||
findOneMethod := false
|
findOneMethod := false
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if title != "" {
|
|
||||||
content = title + "\n" + content
|
|
||||||
}
|
|
||||||
for _, auth := range authList {
|
for _, auth := range authList {
|
||||||
if auth.Type == dingding.AuthTypeStaff {
|
if auth.Type == dingding.AuthTypeStaff || auth.Type == weixin.AuthTypeMP {
|
||||||
findOneMethod = true
|
findOneMethod = true
|
||||||
if len(content) > dingdingapi.MaxWorkContentLen {
|
if len(content) > dingdingapi.MaxWorkContentLen {
|
||||||
content = content[:dingdingapi.MaxWorkContentLen-4] + "..."
|
content = content[:dingdingapi.MaxWorkContentLen-4] + "..."
|
||||||
}
|
}
|
||||||
if globals.IsProductEnv() {
|
if auth.Type == dingding.AuthTypeStaff {
|
||||||
if msgType == dingdingapi.MsgTyeText {
|
if title != "" {
|
||||||
err = api.DingDingAPI.CorpAsyncSendSimple(auth.AuthID, content)
|
content = title + "\n" + content
|
||||||
} else if msgType == dingdingapi.MsgTypeMarkdown {
|
|
||||||
err = api.DingDingAPI.CorpAsyncSendMarkdown([]string{auth.AuthID}, nil, false, title, 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
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/msg"
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -442,7 +442,7 @@ func (t *BaseTask) run(taskHandler func()) {
|
|||||||
} else {
|
} else {
|
||||||
content += ",\n" + t.Error()
|
content += ",\n" + t.Error()
|
||||||
}
|
}
|
||||||
msg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content)
|
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ const (
|
|||||||
|
|
||||||
WX_AFS_ORDER_WAIT4APPROVE_TEMPLATE_ID = "X29udtANvhX6x1Lyh-T40NGNjRXBbUj5oSBTfDhZAqU"
|
WX_AFS_ORDER_WAIT4APPROVE_TEMPLATE_ID = "X29udtANvhX6x1Lyh-T40NGNjRXBbUj5oSBTfDhZAqU"
|
||||||
WX_AFS_ORDER_STATUS_CHANGED_TEMPLATE_ID = "99T33rrXX0VboO1hljs4x8dDoLiSj3QX_rOikPHIXkg"
|
WX_AFS_ORDER_STATUS_CHANGED_TEMPLATE_ID = "99T33rrXX0VboO1hljs4x8dDoLiSj3QX_rOikPHIXkg"
|
||||||
|
|
||||||
|
WS_NOTIFY_STORE_STATUS_CHHANGED_TEMPLATE_ID = "Fl0vOnBKTQqRFx3-shGKxdCnxMdQXNeODzgkuwd7oxw"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -80,7 +82,6 @@ var (
|
|||||||
debugOpenIDMap = map[string]int{
|
debugOpenIDMap = map[string]int{
|
||||||
"oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
|
"oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
|
||||||
"oYN_ust9hXKEvEv0X6Mq6nlAWs_E": 1, // me
|
"oYN_ust9hXKEvEv0X6Mq6nlAWs_E": 1, // me
|
||||||
"oYN_usvnObzrPweIgHTad9-uMf78": 1, // 老赵
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -177,7 +178,7 @@ func SmartMessageTemplateSend(userOpenID, templateID, downloadURL, miniPageURL s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("SmartMessageTemplateSend openID:%s, templateID:%s, downloadURL:%s, miniProgram:%s", userOpenID, templateID, downloadURL, utils.Format4Output(miniProgram, true))
|
globals.SugarLogger.Debugf("SmartMessageTemplateSend openID:%s, templateID:%s, downloadURL:%s, miniProgram:%s", userOpenID, templateID, downloadURL, utils.Format4Output(miniProgram, true))
|
||||||
if globals.ReallySendWeixinMsg {
|
if globals.ReallySendWeixinMsg || debugOpenIDMap[userOpenID] == 1 {
|
||||||
if err = api.WeixinAPI.CBMessageTemplateSend(userOpenID, templateID, downloadURL, miniProgram, data); err != nil {
|
if err = api.WeixinAPI.CBMessageTemplateSend(userOpenID, templateID, downloadURL, miniProgram, data); err != nil {
|
||||||
globals.SugarLogger.Debugf("SmartMessageTemplateSend openID:%s, templateID:%s, downloadURL:%s, miniProgram:%s, failed with error:%v", userOpenID, templateID, downloadURL, utils.Format4Output(miniProgram, true), err)
|
globals.SugarLogger.Debugf("SmartMessageTemplateSend openID:%s, templateID:%s, downloadURL:%s, miniProgram:%s, failed with error:%v", userOpenID, templateID, downloadURL, utils.Format4Output(miniProgram, true), err)
|
||||||
}
|
}
|
||||||
@@ -555,3 +556,33 @@ func genJdCommentRemark(comment *legacymodel.JxBadComments) string {
|
|||||||
sb.WriteString(comment.Scorecontent)
|
sb.WriteString(comment.Scorecontent)
|
||||||
return sb.String()
|
return sb.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NotifyStoreStatusChanged(openUserID, title, content string) (err error) {
|
||||||
|
SmartMessageTemplateSend(openUserID, WS_NOTIFY_STORE_STATUS_CHHANGED_TEMPLATE_ID, "", "", map[string]interface{}{
|
||||||
|
"first": map[string]interface{}{
|
||||||
|
"value": title,
|
||||||
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
|
},
|
||||||
|
"keyword1": map[string]interface{}{
|
||||||
|
"value": "",
|
||||||
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
|
},
|
||||||
|
"keyword2": map[string]interface{}{
|
||||||
|
"value": utils.Time2Str(time.Now()),
|
||||||
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
|
},
|
||||||
|
"keyword3": map[string]interface{}{
|
||||||
|
"value": content,
|
||||||
|
"color": WX_HIGHLEVEL_TEMPLATE_COLOR,
|
||||||
|
},
|
||||||
|
"keyword4": map[string]interface{}{
|
||||||
|
"value": "",
|
||||||
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
|
},
|
||||||
|
"remark": map[string]interface{}{
|
||||||
|
"value": "",
|
||||||
|
"color": WX_NEW_ORDER_TEMPLATE_COLOR,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, typeList []stri
|
|||||||
sql += " AND t1.auth_id2 = ?"
|
sql += " AND t1.auth_id2 = ?"
|
||||||
sqlParams = append(sqlParams, authID2)
|
sqlParams = append(sqlParams, authID2)
|
||||||
}
|
}
|
||||||
|
sql += " ORDER BY t1.type"
|
||||||
err = GetRows(db, &authList, sql, sqlParams...)
|
err = GetRows(db, &authList, sql, sqlParams...)
|
||||||
return authList, err
|
return authList, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user