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