From 2407f355b8f120b5e5a904bdc20b170d284d297e Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 12 Jul 2023 16:50:16 +0800 Subject: [PATCH 1/6] 1 --- business/jxutils/unipush/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/business/jxutils/unipush/push.go b/business/jxutils/unipush/push.go index 14d290e64..8fdb9f290 100644 --- a/business/jxutils/unipush/push.go +++ b/business/jxutils/unipush/push.go @@ -234,7 +234,7 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo "title": storeName, "body": msg, "click_type": "startapp", - "notify_id": rand.Int(), // 每次通知需要不一样 范围:0-2147483647 + "notify_id": rand.Intn(1000000000), // 每次通知需要不一样 范围:0-2147483647 }, "options": options, }, From 6ab899ea0da699c8be458f2fab647128dbdc4555 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 12 Jul 2023 16:57:55 +0800 Subject: [PATCH 2/6] 1 --- business/jxutils/unipush/push.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/business/jxutils/unipush/push.go b/business/jxutils/unipush/push.go index 8fdb9f290..8a9003001 100644 --- a/business/jxutils/unipush/push.go +++ b/business/jxutils/unipush/push.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "math/rand" "time" "git.rosy.net.cn/jx-callback/business/authz/autils" @@ -234,7 +233,8 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo "title": storeName, "body": msg, "click_type": "startapp", - "notify_id": rand.Intn(1000000000), // 每次通知需要不一样 范围:0-2147483647 + //"notify_id": rand.Intn(1000000000), + "notify_id": time.Now().Unix(), // 每次通知需要不一样 范围:0-2147483647 }, "options": options, }, From 58da22323f9ced9706a9e5e023da4e180fefc54c Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 12 Jul 2023 17:09:03 +0800 Subject: [PATCH 3/6] 1 --- business/jxutils/unipush/push.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/business/jxutils/unipush/push.go b/business/jxutils/unipush/push.go index 8a9003001..f347ce5c8 100644 --- a/business/jxutils/unipush/push.go +++ b/business/jxutils/unipush/push.go @@ -182,6 +182,7 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo var ( errs []error options = make(map[string]interface{}, 0) + offMsg MsgContext ) if flag == FlagOrder { options = map[string]interface{}{ @@ -214,6 +215,9 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo }, } } + if err := json.Unmarshal([]byte(body), &offMsg); err != nil { + globals.SugarLogger.Debugf("pushMsgByUniApp marshal err") + } for _, v := range cID { param := map[string]interface{}{ "request_id": utils.Int64ToStr(time.Now().Unix()) + "_" + utils.Int2Str(storeId), @@ -231,10 +235,9 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo "ups": map[string]interface{}{ "notification": map[string]interface{}{ "title": storeName, - "body": msg, + "body": offMsg.Context + "(" + offMsg.VendorName + offMsg.OrderSqs + "号订单)", "click_type": "startapp", - //"notify_id": rand.Intn(1000000000), - "notify_id": time.Now().Unix(), // 每次通知需要不一样 范围:0-2147483647 + "notify_id": time.Now().Unix(), // 每次通知需要不一样 范围:0-2147483647 }, "options": options, }, From 0cf862d60075dd980150d76b434d2d3cf3686ee6 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 12 Jul 2023 17:09:57 +0800 Subject: [PATCH 4/6] 1 --- business/jxutils/unipush/push.go | 1 - 1 file changed, 1 deletion(-) diff --git a/business/jxutils/unipush/push.go b/business/jxutils/unipush/push.go index f347ce5c8..905799af2 100644 --- a/business/jxutils/unipush/push.go +++ b/business/jxutils/unipush/push.go @@ -259,7 +259,6 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo } if err := api.UniAppApi.SendMsgByUinApp(param); err != nil { - globals.SugarLogger.Debugf("SendMsgByUinApp err=%v", err) errs = append(errs, err) } } From ff7e9aa343e08aca128d6c1ce2d350a319495e93 Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 12 Jul 2023 17:15:07 +0800 Subject: [PATCH 5/6] 1 --- business/jxutils/unipush/push.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/business/jxutils/unipush/push.go b/business/jxutils/unipush/push.go index 905799af2..9d2a6f2bf 100644 --- a/business/jxutils/unipush/push.go +++ b/business/jxutils/unipush/push.go @@ -138,7 +138,7 @@ func NotifyImNewMessage(vendorStoreID string, vendorID int) error { msg.Context = "老板,你有新的用户消息,请及时查看!" context, _ := json.Marshal(msg) - pushMsgByUniApp(store.ID, store.Name, cid, string(context), "", SoundsFileNewImMsg, FlagIm) + pushMsgByUniApp(store.ID, store.Name, cid, string(context), string(context), SoundsFileNewImMsg, FlagIm) return err } @@ -183,8 +183,13 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo errs []error options = make(map[string]interface{}, 0) offMsg MsgContext + sub string ) + if err := json.Unmarshal([]byte(body), &offMsg); err != nil { + globals.SugarLogger.Debugf("pushMsgByUniApp marshal err") + } if flag == FlagOrder { + sub = "号订单" options = map[string]interface{}{ "XM": map[string]interface{}{ "/extra.channel_id": "108892", // 订单类填写:108892,消息通知类填写:108898 @@ -200,6 +205,7 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo }, } } else if flag == FlagIm { + sub = " " options = map[string]interface{}{ "XM": map[string]interface{}{ "/extra.channel_id": "108898", // 订单类填写:108892,消息通知类填写:108898 @@ -215,9 +221,7 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo }, } } - if err := json.Unmarshal([]byte(body), &offMsg); err != nil { - globals.SugarLogger.Debugf("pushMsgByUniApp marshal err") - } + for _, v := range cID { param := map[string]interface{}{ "request_id": utils.Int64ToStr(time.Now().Unix()) + "_" + utils.Int2Str(storeId), @@ -235,7 +239,7 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo "ups": map[string]interface{}{ "notification": map[string]interface{}{ "title": storeName, - "body": offMsg.Context + "(" + offMsg.VendorName + offMsg.OrderSqs + "号订单)", + "body": offMsg.Context + "(" + offMsg.VendorName + offMsg.OrderSqs + sub + ")", "click_type": "startapp", "notify_id": time.Now().Unix(), // 每次通知需要不一样 范围:0-2147483647 }, From f0635405b41797e347b482232a8f7485e9ae899e Mon Sep 17 00:00:00 2001 From: richboo111 Date: Wed, 12 Jul 2023 17:22:30 +0800 Subject: [PATCH 6/6] 1 --- business/jxutils/unipush/push.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/business/jxutils/unipush/push.go b/business/jxutils/unipush/push.go index 9d2a6f2bf..e6e026562 100644 --- a/business/jxutils/unipush/push.go +++ b/business/jxutils/unipush/push.go @@ -137,8 +137,8 @@ func NotifyImNewMessage(vendorStoreID string, vendorID int) error { msg.StoreTitle = store.Name msg.Context = "老板,你有新的用户消息,请及时查看!" context, _ := json.Marshal(msg) - - pushMsgByUniApp(store.ID, store.Name, cid, string(context), string(context), SoundsFileNewImMsg, FlagIm) + body := fmt.Sprintf(msg.Context+"(%s)", model.VendorChineseNames[vendorID]) + pushMsgByUniApp(store.ID, store.Name, cid, string(context), body, SoundsFileNewImMsg, FlagIm) return err } @@ -183,13 +183,12 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo errs []error options = make(map[string]interface{}, 0) offMsg MsgContext - sub string ) if err := json.Unmarshal([]byte(body), &offMsg); err != nil { globals.SugarLogger.Debugf("pushMsgByUniApp marshal err") } + globals.SugarLogger.Debugf("pushMsgByUniApp body") if flag == FlagOrder { - sub = "号订单" options = map[string]interface{}{ "XM": map[string]interface{}{ "/extra.channel_id": "108892", // 订单类填写:108892,消息通知类填写:108898 @@ -205,7 +204,6 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo }, } } else if flag == FlagIm { - sub = " " options = map[string]interface{}{ "XM": map[string]interface{}{ "/extra.channel_id": "108898", // 订单类填写:108892,消息通知类填写:108898 @@ -239,7 +237,7 @@ func pushMsgByUniApp(storeId int, storeName string, cID []string, msg string, bo "ups": map[string]interface{}{ "notification": map[string]interface{}{ "title": storeName, - "body": offMsg.Context + "(" + offMsg.VendorName + offMsg.OrderSqs + sub + ")", + "body": body, "click_type": "startapp", "notify_id": time.Now().Unix(), // 每次通知需要不一样 范围:0-2147483647 },