- 门店状态变化添加发送微信通知消息

This commit is contained in:
gazebo
2019-09-10 11:23:39 +08:00
parent 7dd0da9f97
commit fb8732c94c
8 changed files with 224 additions and 151 deletions

View File

@@ -196,7 +196,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(dingdingapi.MsgTyeText, user.GetID(), msgType, msgContent)
msg.SendUserMessage(dingdingapi.MsgTyeText, user, msgType, msgContent)
} else if err == nil {
err = err2
}

View File

@@ -8,7 +8,7 @@ import (
"strings"
"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/baidunavi"
@@ -99,14 +99,6 @@ var (
"11:00:00",
"15:00:00",
}
mobileGroupMap = map[string]map[string]int{
"18650801532": map[string]int{ // 陈磊
"13540967462": 1, // 蒋龙丹
"13708196093": 1, // 顾子杭
"13980795039": 1, // 赵凌兰
},
}
)
// todo 门店绑定信息可以考虑以数组形式返回,而不是现在这样
@@ -1537,9 +1529,9 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
}
curSnapshotMap := make(map[string]*model.VendorStoreSnapshot)
curSnapshotMap2 := make(map[int]map[int]*model.VendorStoreSnapshot)
alarmSnapshotMap := make(map[int][]*model.VendorStoreSnapshot)
curSnapshotGroupMap := make(map[int][]*model.VendorStoreSnapshot)
alarmSnapshotMap := make(map[int][]*model.VendorStoreSnapshot)
txtAlarmSnapshotMap := make(map[int][]*model.VendorStoreSnapshot)
// 之前是开店当前是关店的,或营业时间缩短的
for _, v := range curSnapshotList {
@@ -1579,6 +1571,7 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
db := dao.GetDB()
storeDetailMap := make(map[int]*dao.StoreDetail)
userMap2 := make(map[string]*model.User)
userMap := make(map[string]map[int]int)
userMapTxt := make(map[string][]*model.VendorStoreSnapshot)
for storeID, list := range alarmSnapshotMap {
@@ -1586,132 +1579,126 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
if storeDetail != nil {
storeDetailMap[storeID] = storeDetail
// userList, _ := GetRoleUserList(ctx, autils.NewStoreBossRole(storeID))
// for _, mobile := range []string{storeDetail.Tel1, storeDetail.MarketManPhone, storeDetail.OperatorPhone} {
// if mobile != "" {
// 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]...)
// }
// }
// }
var userList []*model.User
if roleUserIDList, err := GetRoleUserList(ctx, autils.NewStoreBossRole(storeID)); err == nil {
userList, _, _ = dao.GetUsers(db, 0, "", roleUserIDList, "", "", 0, -1)
}
for _, mobile := range []string{storeDetail.Tel1, storeDetail.MarketManPhone, storeDetail.OperatorPhone} {
if mobile != "" {
if userMap[mobile] == nil {
userMap[mobile] = make(map[int]int)
if user, err2 := dao.GetUserByID(db, "mobile", mobile); err2 == nil {
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 {
userMapTxt[mobile] = append(userMapTxt[mobile], txtAlarmSnapshotMap[storeID]...)
userMapTxt[userID] = append(userMapTxt[userID], txtAlarmSnapshotMap[storeID]...)
}
}
}
}
}
var mobileList []string
for mobile := range userMap {
if mobile != "" && !shouldSkipMobile4SendStoreStatusInfo(mobile) {
mobileList = append(mobileList, mobile)
}
var userList []*model.User
for _, user := range userMap2 {
userList = append(userList, user)
}
if len(mobileList) > 0 {
if len(userList) > 0 {
const fixTitle = "门店状态变化"
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,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
mobile := batchItemList[0].(string)
var dataList []map[string]interface{}
captionList := []string{"京西门店ID", "门店名", "城市"}
isFirstRow := true
for storeID := range userMap[mobile] {
prevAlarmMap := prevSnapshotMap2[storeID]
curAlarmMap := curSnapshotMap2[storeID]
data := map[string]interface{}{
"京西门店ID": storeID,
"门店名": storeDetailMap[storeID].Store.Name,
"城市": storeDetailMap[storeID].CityName,
}
for _, vendorID := range []int{model.VendorIDJD, model.VendorIDEBAI, model.VendorIDMTWM} {
if isFirstRow {
captionList = append(captionList, model.VendorChineseNames[vendorID]+"ID",
model.VendorChineseNames[vendorID]+"之前状态", model.VendorChineseNames[vendorID]+"当前状态",
model.VendorChineseNames[vendorID]+"之前营业时间", model.VendorChineseNames[vendorID]+"当前营业时间")
user := batchItemList[0].(*model.User)
var excelURL string
if user.Type&model.UserTypeOperator != 0 {
var dataList []map[string]interface{}
captionList := []string{"京西门店ID", "门店名", "城市"}
isFirstRow := true
for storeID := range userMap[user.GetID()] {
prevAlarmMap := prevSnapshotMap2[storeID]
curAlarmMap := curSnapshotMap2[storeID]
data := map[string]interface{}{
"京西门店ID": storeID,
"门店名": storeDetailMap[storeID].Store.Name,
"城市": storeDetailMap[storeID].CityName,
}
if prevAlarmMap != nil {
data[model.VendorChineseNames[vendorID]+"当前状态"] = ""
data[model.VendorChineseNames[vendorID]+"当前营业时间"] = ""
if prevSnapshot := prevAlarmMap[vendorID]; prevSnapshot != nil {
data[model.VendorChineseNames[vendorID]+"ID"] = prevSnapshot.VendorStoreID
data[model.VendorChineseNames[vendorID]+"之前状态"] = model.StoreStatusName[prevSnapshot.Status]
data[model.VendorChineseNames[vendorID]+"之前营业时间"] = jxutils.OperationTimeStr4VendorStore(prevSnapshot)
if snapshot := curSnapshotMap[prevSnapshot.GenMapKey()]; snapshot != nil {
data[model.VendorChineseNames[vendorID]+"当前状态"] = model.StoreStatusName[snapshot.Status]
data[model.VendorChineseNames[vendorID]+"当前营业时间"] = jxutils.OperationTimeStr4VendorStore(snapshot)
}
} else {
data[model.VendorChineseNames[vendorID]+"ID"] = ""
data[model.VendorChineseNames[vendorID]+"之前状态"] = ""
data[model.VendorChineseNames[vendorID]+"之前营业时间"] = ""
for _, vendorID := range []int{model.VendorIDJD, model.VendorIDEBAI, model.VendorIDMTWM} {
if isFirstRow {
captionList = append(captionList, model.VendorChineseNames[vendorID]+"ID",
model.VendorChineseNames[vendorID]+"之前状态", model.VendorChineseNames[vendorID]+"当前状态",
model.VendorChineseNames[vendorID]+"之前营业时间", model.VendorChineseNames[vendorID]+"当前营业时间")
}
} else if curAlarmMap != nil {
data[model.VendorChineseNames[vendorID]+"之前状态"] = ""
data[model.VendorChineseNames[vendorID]+"之前营业时间"] = ""
if curSnapshot := curAlarmMap[vendorID]; curSnapshot != nil {
data[model.VendorChineseNames[vendorID]+"ID"] = curSnapshot.VendorStoreID
data[model.VendorChineseNames[vendorID]+"当前状态"] = model.StoreStatusName[curSnapshot.Status]
data[model.VendorChineseNames[vendorID]+"当前营业时间"] = jxutils.OperationTimeStr4VendorStore(curSnapshot)
} else {
data[model.VendorChineseNames[vendorID]+"ID"] = ""
if prevAlarmMap != nil {
data[model.VendorChineseNames[vendorID]+"当前状态"] = ""
data[model.VendorChineseNames[vendorID]+"当前营业时间"] = ""
if prevSnapshot := prevAlarmMap[vendorID]; prevSnapshot != nil {
data[model.VendorChineseNames[vendorID]+"ID"] = prevSnapshot.VendorStoreID
data[model.VendorChineseNames[vendorID]+"之前状态"] = model.StoreStatusName[prevSnapshot.Status]
data[model.VendorChineseNames[vendorID]+"之前营业时间"] = jxutils.OperationTimeStr4VendorStore(prevSnapshot)
if snapshot := curSnapshotMap[prevSnapshot.GenMapKey()]; snapshot != nil {
data[model.VendorChineseNames[vendorID]+"当前状态"] = model.StoreStatusName[snapshot.Status]
data[model.VendorChineseNames[vendorID]+"当前营业时间"] = jxutils.OperationTimeStr4VendorStore(snapshot)
}
} else {
data[model.VendorChineseNames[vendorID]+"ID"] = ""
data[model.VendorChineseNames[vendorID]+"之前状态"] = ""
data[model.VendorChineseNames[vendorID]+"之前营业时间"] = ""
}
} else if curAlarmMap != nil {
data[model.VendorChineseNames[vendorID]+"之前状态"] = ""
data[model.VendorChineseNames[vendorID]+"之前营业时间"] = ""
if curSnapshot := curAlarmMap[vendorID]; curSnapshot != nil {
data[model.VendorChineseNames[vendorID]+"ID"] = curSnapshot.VendorStoreID
data[model.VendorChineseNames[vendorID]+"当前状态"] = model.StoreStatusName[curSnapshot.Status]
data[model.VendorChineseNames[vendorID]+"当前营业时间"] = jxutils.OperationTimeStr4VendorStore(curSnapshot)
} else {
data[model.VendorChineseNames[vendorID]+"ID"] = ""
data[model.VendorChineseNames[vendorID]+"当前状态"] = ""
data[model.VendorChineseNames[vendorID]+"当前营业时间"] = ""
}
}
}
}
dataList = append(dataList, data)
dataList = append(dataList, data)
isFirstRow = false
}
excelConf := &excel.Obj2ExcelSheetConfig{
Title: fixTitle,
Data: dataList,
CaptionList: captionList,
}
excelBin := excel.Obj2Excel([]*excel.Obj2ExcelSheetConfig{excelConf})
keyPart := []string{
"store_status",
mobile,
time.Now().Format("20060102T150405") + ".xlsx",
}
key := "export/" + strings.Join(keyPart, "_")
excelURL, err2 := jxutils.UploadExportContent(excelBin, key)
if err2 != nil {
globals.SugarLogger.Warnf("SendAlarmVendorSnapshot, send %s failed with error:%v", key, err2)
}
var txtAlarm []string
for _, v := range userMapTxt[mobile] {
curSnapshot := curSnapshotMap[v.GenMapKey()]
storeDetail := storeDetailMap[v.StoreID]
curStoreStatus := "无店"
curOpTimeStr := "无店"
if curSnapshot != nil {
curStoreStatus = model.StoreStatusName[curSnapshot.Status]
curOpTimeStr = jxutils.OperationTimeStr4VendorStore(curSnapshot)
isFirstRow = false
}
txtAlarm = append(txtAlarm, fmt.Sprintf(`## 门店: %s(%d)
excelConf := &excel.Obj2ExcelSheetConfig{
Title: fixTitle,
Data: dataList,
CaptionList: captionList,
}
excelBin := excel.Obj2Excel([]*excel.Obj2ExcelSheetConfig{excelConf})
keyPart := []string{
"store_status",
user.GetMobile(),
time.Now().Format("20060102T150405") + ".xlsx",
}
key := "export/" + strings.Join(keyPart, "_")
excelURL, err = jxutils.UploadExportContent(excelBin, key)
if err != nil {
globals.SugarLogger.Warnf("SendAlarmVendorSnapshot, %s upload %s failed with error:%v", user.GetName(), key, err)
}
var txtAlarm []string
for _, v := range userMapTxt[user.GetID()] {
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(%d)
- 城市: %s
- 平台: %s
- 平台ID: %s
@@ -1720,33 +1707,33 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
- 之前营业时间: %s
- 当前营业时间: %s
`, 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")
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)
}
alarmTextStr := "# " + title + " \n" + fmt.Sprintf("[详情点我](%s/billshow/?normal=true&path=%s) \n", globals.BackstageHost, excelURL) + strings.Join(txtAlarm, " \n")
sendStoreStatusInfo2Mobile(mobile, title, alarmTextStr)
return nil, nil
}, mobileList)
}, userList)
tasksch.HandleTask(task, parentTask, true).Run()
_, err = task.GetResult(0)
}
return err
}
func shouldSkipMobile4SendStoreStatusInfo(mobile string) bool {
return userProvider.GetUser(mobile, auth2.AuthTypeMobile) == nil
}
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 sendStoreStatusInfo2Mobile(user *model.User, msgType, title, txtAlarm string) {
msg.SendUserMessage(msgType, user, title, txtAlarm)
}
func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs []int, isAsync bool) (err error) {

View File

@@ -20,8 +20,8 @@ func TestGetStoresVendorSnapshot(t *testing.T) {
func TestSendAlarmVendorSnapshot(t *testing.T) {
db := dao.GetDB()
prevSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-07-16 10:00:00"))
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-07-16 11:00:00"))
prevSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-09 10:00:00"))
curSnapshotList, _ := dao.GetVendorStoreSnapshot(db, utils.Str2Time("2019-09-09 11:00:00"))
err := SendAlarmVendorSnapshot(jxcontext.AdminCtx, nil, prevSnapshotList, curSnapshotList)
if err != nil {
t.Fatal(err)

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

View File

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

View File

@@ -9,8 +9,8 @@ import (
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"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/msg"
"git.rosy.net.cn/jx-callback/globals"
)
@@ -442,7 +442,7 @@ func (t *BaseTask) run(taskHandler func()) {
} else {
content += ",\n" + t.Error()
}
msg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content)
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, authInfo.UserID, "异步任务完成", content)
}
}
})

View File

@@ -61,6 +61,8 @@ const (
WX_AFS_ORDER_WAIT4APPROVE_TEMPLATE_ID = "X29udtANvhX6x1Lyh-T40NGNjRXBbUj5oSBTfDhZAqU"
WX_AFS_ORDER_STATUS_CHANGED_TEMPLATE_ID = "99T33rrXX0VboO1hljs4x8dDoLiSj3QX_rOikPHIXkg"
WS_NOTIFY_STORE_STATUS_CHHANGED_TEMPLATE_ID = "Fl0vOnBKTQqRFx3-shGKxdCnxMdQXNeODzgkuwd7oxw"
)
var (
@@ -80,7 +82,6 @@ var (
debugOpenIDMap = map[string]int{
"oYN_usk0AeGc_C6VEZfmFQP5VHMQ": 1, // 周小扬
"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))
if globals.ReallySendWeixinMsg {
if globals.ReallySendWeixinMsg || debugOpenIDMap[userOpenID] == 1 {
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)
}
@@ -555,3 +556,33 @@ func genJdCommentRemark(comment *legacymodel.JxBadComments) string {
sb.WriteString(comment.Scorecontent)
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
}

View File

@@ -56,7 +56,7 @@ func GetUserBindAuthInfo(db *DaoDB, userID string, bindType int, typeList []stri
sql += " AND t1.auth_id2 = ?"
sqlParams = append(sqlParams, authID2)
}
sql += " ORDER BY t1.type"
err = GetRows(db, &authList, sql, sqlParams...)
return authList, err
}