This commit is contained in:
richboo111
2023-04-25 09:46:26 +08:00
parent 69040cd1cf
commit a5f750ad67
21 changed files with 1552 additions and 32 deletions

View File

@@ -4,9 +4,10 @@ import (
"encoding/json"
"errors"
"fmt"
"time"
"git.rosy.net.cn/jx-callback/business/authz/autils"
"git.rosy.net.cn/jx-callback/globals/api2"
"time"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
@@ -19,6 +20,7 @@ const (
SoundsFileNewOrder = "newOrder.caf"
SoundsFileNewAfsOrder = "afsOrder.caf"
SoundsFileNewCancelOrder = "cancelOrder.caf"
SoundsFileNewImMsg = "" //TODO 待定
)
// NotifyNewOrder 推送新订单
@@ -108,6 +110,43 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
return err
}
// NotifyImNewMessage IM 新消息通知
func NotifyImNewMessage(vendorStoreID string, vendorID int) error {
if len(vendorStoreID) == 0 {
return nil
}
var (
temp = 0
msg = MsgContext{}
)
if vendorID == 10 { //美团
temp = 1
} else if vendorID == 11 { //饿了么
temp = 3
}
store, err := dao.GetStoreBaseByVendorStoreID(vendorStoreID, temp)
if err != nil {
return fmt.Errorf("未查到此门店:%s", vendorStoreID)
}
cid, err := GetStoreBoosCID(store.ID)
if err != nil {
globals.SugarLogger.Errorf("IM消息推送,获取门店老板CID错误 %v", err)
return err
}
fmt.Print(cid)
msg.MsgType = "newImMsg"
msg.VendorName = model.VendorChineseNames[temp]
msg.StoreTitle = store.Name
msg.Context = "老板,你有新的用户消息,请及时查看!"
context, _ := json.Marshal(msg)
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[temp])
pushMsgByUniApp(store.ID, store.Name, cid, string(context), body, SoundsFileNewImMsg)
return err
}
// GetStoreBoosCID /************************************************************/
func GetStoreBoosCID(storeId int) ([]string, error) {
// 根据订单获取门店的老板cid