Merge branch 'jdshop' of e.coding.net:rosydev/jx-callback into jdshop
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
@@ -52,7 +53,7 @@ func NotifyNewOrder(order *model.GoodsOrder) {
|
||||
msg.Context = "老板,你有新的订单了!"
|
||||
msg.VendorOrderId = order.VendorOrderID
|
||||
context, _ := json.Marshal(msg)
|
||||
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[order.VendorID]+"#"+msg.OrderSqs)
|
||||
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[order.VendorID]+"#"+msg.OrderSqs+"号订单")
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewOrder, FlagOrder)
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
|
||||
msg.StoreTitle = storeDetail.Name
|
||||
msg.Context = "老板订单申请退款了!"
|
||||
context, _ := json.Marshal(msg)
|
||||
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[afsOrder.VendorID]+"#"+msg.OrderSqs)
|
||||
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[afsOrder.VendorID]+"#"+msg.OrderSqs+"号订单")
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewAfsOrder, FlagOrder)
|
||||
return err
|
||||
}
|
||||
@@ -109,13 +110,13 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
|
||||
msg.StoreTitle = storeDetail.Name
|
||||
msg.Context = "老板订单被取消了!"
|
||||
context, _ := json.Marshal(msg)
|
||||
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[order.VendorID]+"#"+msg.OrderSqs)
|
||||
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[order.VendorID]+"#"+msg.OrderSqs+"号订单")
|
||||
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewCancelOrder, FlagOrder)
|
||||
return err
|
||||
}
|
||||
|
||||
// NotifyImNewMessage IM 新消息通知
|
||||
func NotifyImNewMessage(vendorStoreID string, vendorID int) error {
|
||||
func NotifyImNewMessage(vendorStoreID string, vendorID int, offMsg string) error {
|
||||
if len(vendorStoreID) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -136,9 +137,9 @@ func NotifyImNewMessage(vendorStoreID string, vendorID int) error {
|
||||
msg.VendorName = model.VendorChineseNames[vendorID]
|
||||
msg.StoreTitle = store.Name
|
||||
msg.Context = "老板,你有新的用户消息,请及时查看!"
|
||||
context, _ := json.Marshal(msg)
|
||||
//context, _ := json.Marshal(msg)
|
||||
body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[vendorID])
|
||||
pushMsgByUniApp(store.ID, store.Name, cid, string(context), body, SoundsFileNewImMsg, FlagIm)
|
||||
pushMsgByUniApp(store.ID, store.Name, cid, offMsg, body, SoundsFileNewImMsg, FlagIm)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -182,12 +183,7 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo
|
||||
var (
|
||||
errs []error
|
||||
options = make(map[string]interface{}, 0)
|
||||
offMsg MsgContext
|
||||
)
|
||||
if err := json.Unmarshal([]byte(body), &offMsg); err != nil {
|
||||
globals.SugarLogger.Debugf("pushMsgByUniApp marshal err")
|
||||
}
|
||||
globals.SugarLogger.Debugf("pushMsgByUniApp body")
|
||||
if flag == FlagOrder {
|
||||
options = map[string]interface{}{
|
||||
"XM": map[string]interface{}{
|
||||
@@ -265,6 +261,6 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo
|
||||
}
|
||||
}
|
||||
if len(errs) != 0 {
|
||||
globals.SugarLogger.Errorf("uinapp 消息推送错误:%s", utils.Format4Output(errs, false))
|
||||
log.Printf("uinapp 消息推送错误:%s", utils.Format4Output(errs, false))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
|
||||
errList errlist.ErrList
|
||||
userList = &UserMessageList{}
|
||||
)
|
||||
if string(msg) == "" {
|
||||
if len(string(msg)) == 0 {
|
||||
errList.AddErr(fmt.Errorf("读取平台数据为空,请检查"))
|
||||
}
|
||||
if vendorID == VendorIDMT {
|
||||
@@ -151,7 +151,7 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
|
||||
errList.AddErr(fmt.Errorf("存储STU聊天记录错误:%v", err))
|
||||
}
|
||||
//3 cid推送新消息
|
||||
if err = PushMsgByCid(vendorStoreID, vendorID); err != nil {
|
||||
if err = PushMsgByCid(vendorStoreID, vendorID, string(msg)); err != nil {
|
||||
errList.AddErr(fmt.Errorf("向商家cid推送新消息错误:%v", err))
|
||||
}
|
||||
|
||||
@@ -162,8 +162,8 @@ func ReadMsgFromVendor(vendorID int, elmAppID string, msg []byte) error {
|
||||
}
|
||||
|
||||
// PushMsgByCid 通过cid push用户
|
||||
func PushMsgByCid(vendorStoreID string, vendorID int) error {
|
||||
if err := push.NotifyImNewMessage(vendorStoreID, vendorID); err != nil {
|
||||
func PushMsgByCid(vendorStoreID string, vendorID int, msg string) error {
|
||||
if err := push.NotifyImNewMessage(vendorStoreID, vendorID, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@@ -360,9 +360,7 @@ func DecryptIm(appID int, msg string) (string, error) {
|
||||
data, _ := base64.StdEncoding.DecodeString(msg)
|
||||
key := utils.LimitUTF8StringLen2(rel[appID], 16)
|
||||
res, err := utils.AESCBCDecpryt(data, []byte(key), []byte(key))
|
||||
globals.SugarLogger.Debugf("DecryptIm err=%v", err)
|
||||
if len(string(res)) > 0 && err == nil {
|
||||
globals.SugarLogger.Debugf("DecryptIm res=%v", string(res))
|
||||
return string(res), nil
|
||||
}
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user