|
|
@@ -1,5 +1,7 @@
|
|
|
package com.ruoyi.app.order;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSON;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.ruoyi.app.user.MerchantTokenSessionService;
|
|
|
import com.ruoyi.app.push.BusinessPushService;
|
|
|
import com.ruoyi.app.push.RecipientApp;
|
|
|
@@ -53,6 +55,20 @@ public class MerchantNotificationRouter {
|
|
|
public void sendStoreNotification(Long storeId, Long ownerUserId,
|
|
|
String titleKey, String contentKey,
|
|
|
String body, String orderNo) {
|
|
|
+ sendStoreNotification(storeId, ownerUserId, titleKey, contentKey, body, orderNo, null);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** Only native new-order pushes receive a voice scene; persisted and uni bodies stay unchanged. */
|
|
|
+ public void sendStoreNewOrder(Long storeId, Long ownerUserId, String titleKey, String contentKey,
|
|
|
+ String body, String orderNo, Long orderType) {
|
|
|
+ String scene = Long.valueOf(0L).equals(orderType) ? "NEW_ORDER_DELIVERY"
|
|
|
+ : Long.valueOf(1L).equals(orderType) ? "NEW_ORDER_PICKUP"
|
|
|
+ : Long.valueOf(2L).equals(orderType) ? "NEW_ORDER_DINE_IN" : null;
|
|
|
+ sendStoreNotification(storeId, ownerUserId, titleKey, contentKey, body, orderNo, scene);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendStoreNotification(Long storeId, Long ownerUserId, String titleKey, String contentKey,
|
|
|
+ String body, String orderNo, String voiceScene) {
|
|
|
StoreRoute route = resolveRoute(storeId, ownerUserId);
|
|
|
Long resolvedOwnerId = route.ownerUserId();
|
|
|
InfoUser owner = resolvedOwnerId == null ? null : infoUserService.getById(resolvedOwnerId);
|
|
|
@@ -78,7 +94,7 @@ public class MerchantNotificationRouter {
|
|
|
|
|
|
Set<String> pushedAddresses = new LinkedHashSet<>();
|
|
|
for (InfoUser recipient : recipients.values()) {
|
|
|
- sendToRecipient(recipient, titleKey, contentKey, body, orderNo, pushedAddresses);
|
|
|
+ sendToRecipient(recipient, titleKey, contentKey, body, orderNo, voiceScene, pushedAddresses);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -120,7 +136,7 @@ public class MerchantNotificationRouter {
|
|
|
}
|
|
|
|
|
|
private void sendToRecipient(InfoUser recipient, String titleKey, String contentKey,
|
|
|
- String body, String orderNo, Set<String> pushedAddresses) {
|
|
|
+ String body, String orderNo, String voiceScene, Set<String> pushedAddresses) {
|
|
|
String title = localize(titleKey, recipient.getUserId());
|
|
|
String content = localize(contentKey, recipient.getUserId());
|
|
|
if (StringUtils.isNotEmpty(orderNo)) {
|
|
|
@@ -137,8 +153,16 @@ public class MerchantNotificationRouter {
|
|
|
return;
|
|
|
}
|
|
|
try {
|
|
|
+ String pushBody = body;
|
|
|
+ if (voiceScene != null && businessPushService.isNativeMode()) {
|
|
|
+ JSONObject nativeBody = JSON.parseObject(body);
|
|
|
+ if (nativeBody != null) {
|
|
|
+ nativeBody.put("eventScene", voiceScene);
|
|
|
+ pushBody = nativeBody.toJSONString();
|
|
|
+ }
|
|
|
+ }
|
|
|
businessPushService.send(RecipientApp.MERCHANT, recipient.getUserId(), recipient.getCid(),
|
|
|
- title, content, body);
|
|
|
+ title, content, pushBody);
|
|
|
} catch (Exception exception) {
|
|
|
log.error("Store notification external push failed, userId={}", recipient.getUserId(), exception);
|
|
|
}
|