添加uniapp消息通知,删除老版本消息通知

This commit is contained in:
邹宗楠
2023-03-20 17:28:21 +08:00
parent 522997137c
commit 024cd86425
6 changed files with 5 additions and 123 deletions

View File

@@ -6,66 +6,17 @@ import (
"fmt"
"git.rosy.net.cn/jx-callback/business/authz/autils"
"git.rosy.net.cn/jx-callback/globals/api2"
"strings"
"time"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
beego "github.com/astaxie/beego/server/web"
)
//
//func pushToSingle(content, title string, storeID int) {
// var (
// db = dao.GetDB()
// )
// if !globals.IsProductEnv() {
// return
// }
// if storeID == 0 {
// return
// }
// storePushs, err := dao.GetStorePushClient(db, storeID, "")
// if err != nil {
// return
// }
// for _, v := range storePushs {
//
// status, err2 := api.PushAPI.PushToSingle(v.ClientID, false, &unipushapi.Notification{
// Title: title,
// Body: content,
// })
// if err = err2; err != nil {
// continue
// }
// if status == unipushapi.SuccessOffLine {
// _, err = api.PushAPI.PushToSingle(v.ClientID, true, &unipushapi.Notification{
// Body: content,
// })
// if err != nil {
// globals.SugarLogger.Debugf("NotifyNewOrder push2 error: [%v]", err)
// continue
// }
// }
//
// }
//}
// NotifyNewOrder 推送新订单
func NotifyNewOrder(order *model.GoodsOrder) {
//if order == nil || len(order.Skus) == 0 {
// return
//}
//sb := new(strings.Builder)
//sb.WriteString("老板,")
//sb.WriteString(order.ConsigneeName)
//sb.WriteString("购买了商品")
//sb.WriteString(getOrderDetailBrief(order))
//pushToSingle(sb.String(), "京西菜市新订单推送", jxutils.GetSaleStoreIDFromOrder(order))
storeId := order.StoreID
if storeId <= model.NO {
storeId = order.JxStoreID
@@ -83,7 +34,7 @@ func NotifyNewOrder(order *model.GoodsOrder) {
return
}
msg.MsgType = "新订单"
msg.MsgType = "newOrder"
msg.VendorName = model.VendorChineseNames[order.VendorID]
msg.OrderSqs = utils.Int2Str(order.OrderSeq)
msg.StoreTitle = storeDetail.Name
@@ -92,30 +43,6 @@ func NotifyNewOrder(order *model.GoodsOrder) {
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
}
func getOrderDetailBrief(order *model.GoodsOrder) (brief string) {
sb := new(strings.Builder)
sb.WriteString(order.Skus[0].SkuName)
sb.WriteString("等共")
sb.WriteString(utils.Int2Str(order.Skus[0].Count))
sb.WriteString("份(")
sb.WriteString(jxutils.IntPrice2StandardString(order.Skus[0].SalePrice))
sb.WriteString("元/份)等,预计收入")
//TODO 2020-07-20 果园和菜市不同
var price int64
if beego.BConfig.RunMode == "jxgy" {
price = order.EarningPrice
} else {
if order.EarningType == model.EarningTypePoints {
price = order.ActualPayPrice
} else {
price = order.EarningPrice
}
}
sb.WriteString(jxutils.IntPrice2StandardString(price))
sb.WriteString("元")
return sb.String()
}
func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
storeId := afsOrder.StoreID
if storeId <= model.NO {
@@ -134,14 +61,13 @@ func NotifyAfsOrder(afsOrder *model.AfsOrder) (err error) {
return
}
msg.MsgType = "售后订单"
msg.MsgType = "newAfsOrder"
msg.VendorName = model.VendorChineseNames[afsOrder.VendorID]
msg.OrderSqs = "0"
msg.StoreTitle = storeDetail.Name
msg.Context = "老板订单申请退款了"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
//pushToSingle("老板,您有新的售后单,请尽快处理!", "京西菜市售后单推送", jxutils.GetSaleStoreIDFromAfsOrder(afsOrder))
return err
}
@@ -163,15 +89,13 @@ func NotifyOrderCanceled(order *model.GoodsOrder) (err error) {
return
}
msg.MsgType = "取消订单"
msg.MsgType = "newCancelOrder"
msg.VendorName = model.VendorChineseNames[order.VendorID]
msg.OrderSqs = "0"
msg.StoreTitle = storeDetail.Name
msg.Context = "老板订单被取消了"
context, _ := json.Marshal(msg)
pushMsgByUniApp(storeDetail.ID, storeDetail.Name, cid, string(context))
//title := fmt.Sprintf("老板,您的订单%s第%d号订单, %s被取消了", model.VendorChineseNames[order.VendorID], order.OrderSeq, order.VendorOrderID)
//pushToSingle(title, "京西菜市取消单推送", jxutils.GetSaleStoreIDFromOrder(order))
return err
}