添加自动创建分类

This commit is contained in:
邹宗楠
2023-03-21 15:20:47 +08:00
parent 4bbef41a0a
commit 5e2bca840d
13 changed files with 98 additions and 89 deletions

View File

@@ -15,6 +15,12 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
const (
SoundsFileNewOrder = "newOrder.mp4"
SoundsFileNewAfsOrder = "newAfsOrder.mp4"
SoundsFileNewCancelOrder = "newCancelOrder.mp4"
)
// NotifyNewOrder 推送新订单
func NotifyNewOrder(order *model.GoodsOrder) {
storeId := order.StoreID
@@ -38,9 +44,10 @@ func NotifyNewOrder(order *model.GoodsOrder) {
msg.VendorName = model.VendorChineseNames[order.VendorID]
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
msg.StoreTitle = storeDetail.Name
msg.Context = "老板,你有新的订单了"
msg.Context = "老板,你有新的订单了!"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
body := msg.Context + model.VendorChineseNames[order.VendorID] + "#" + msg.OrderSqs
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewOrder)
}
func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
@@ -63,11 +70,12 @@ func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
msg.MsgType = "newAfsOrder"
msg.VendorName = model.VendorChineseNames[afsOrder.VendorID]
msg.OrderSqs = "0"
msg.OrderSqs = afsOrder.VendorOrderID
msg.StoreTitle = storeDetail.Name
msg.Context = "老板订单申请退款了"
msg.Context = "老板订单申请退款了!"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
body := msg.Context + model.VendorChineseNames[afsOrder.VendorID] + "#" + msg.OrderSqs
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewAfsOrder)
return err
}
@@ -91,11 +99,12 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
msg.MsgType = "newCancelOrder"
msg.VendorName = model.VendorChineseNames[order.VendorID]
msg.OrderSqs = "0"
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
msg.StoreTitle = storeDetail.Name
msg.Context = "老板订单被取消了"
msg.Context = "老板订单被取消了!"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
body := msg.Context + model.VendorChineseNames[order.VendorID] + "#" + msg.OrderSqs
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context), body, SoundsFileNewCancelOrder)
return err
}
@@ -134,7 +143,7 @@ type MsgContext struct {
OrderSqs string `json:"order_sqs"` // 订单流水号
}
func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string) {
func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, body string, soundsFileName string) {
var errs []error
for _, v := range cID {
param := map[string]interface{}{
@@ -160,10 +169,10 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string) {
"aps": map[string]interface{}{
"alert": map[string]interface{}{
"title": storeName,
"body": msg,
"body": body,
},
"content-available": 0,
"sound": "ring.mp3",
"sound": soundsFileName,
},
"auto_badge": "+1",
},