From 62748d309f91c0cd871997ae8c1b2cb61b5d7e63 Mon Sep 17 00:00:00 2001 From: luoyang Date: Wed, 8 Apr 2020 18:42:03 +0800 Subject: [PATCH] add rservice app notify --- pom.xml | 2 +- .../core/impls/RetailRSvcServiceImpl.java | 79 ++++++++++--------- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/pom.xml b/pom.xml index 965456436..1844054ec 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 manage - 1.4.35 + 1.4.36 UTF-8 1.8.0 diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java index 56698f217..15dba879d 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailRSvcServiceImpl.java @@ -217,7 +217,10 @@ public class RetailRSvcServiceImpl implements RetailRSvcService { String title = params.getString("title"); String body = params.getString("body"); String url = decData(params.getString("url"), key, svcInfo.getString("platform_pri_key")); - sendRServiceNotifyMessage(client, title, body, url); + if (StringUtils.equalsIgnoreCase("PINE", client.getString("client_moniker"))|| + StringUtils.equalsIgnoreCase("TUTU", client.getString("client_moniker"))) { + sendRServiceNotifyMessage(client, title, body, url); + } result.put("result_status", "SUCCESS"); } catch (Exception e) { logger.error("geek notify app fail:{} - {}",sourceCode,e.getMessage()); @@ -254,45 +257,43 @@ public class RetailRSvcServiceImpl implements RetailRSvcService { private void sendRServiceNotifyMessage(JSONObject client, String title, String body, String url) { logger.debug("sendGeekMessage Begin"); -// List clientTokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id")); -// for (JSONObject token : clientTokens) { -// -// } - JSONObject devToken = clientDeviceTokenMapper.getTestTokens(); - Runnable task = () -> { - String token = devToken.getString("token"); - JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), - devToken.getIntValue("client_id"), - "annual_bill" + devToken.getString("client_type"), - token, - "跨境商城推送" - ); - try { - JSONObject type = new JSONObject(); - type.put("send_type", "annual_bill"); - type.put("id", devToken.getString("dev_token_id")); - AppMsgSender sender = senderMap.get((devToken.getString("client_type"))); - if (StringUtils.isBlank(token) || sender == null) { - return; + List clientTokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id")); + for (JSONObject tokenJson : clientTokens) { + Runnable task = () -> { + String token = tokenJson.getString("token"); + JSONObject log = saveAppMessageLog(tokenJson.getString("dev_id"), + tokenJson.getIntValue("client_id"), + "annual_bill" + tokenJson.getString("client_type"), + token, + "跨境商城推送" + ); + try { + JSONObject type = new JSONObject(); + type.put("send_type", "annual_bill"); + type.put("id", tokenJson.getString("dev_token_id")); + AppMsgSender sender = senderMap.get((tokenJson.getString("client_type"))); + if (StringUtils.isBlank(token) || sender == null) { + return; + } + JSONObject managerMsg = new JSONObject(); + managerMsg.put("title", title); + managerMsg.put("body", body); + managerMsg.put("type", type); + JSONObject messageData = new JSONObject(); + messageData.put("url", url); + managerMsg.put("data", messageData); + managerMsg.put("msgType", "annual_bill"); + AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); + sender.sendMessage(appMessage, tokenJson); + log.put("status", 2); + appMessageLogMapper.update(log); + } catch (Exception e) { + logger.error("出错了:" + e.getMessage()); + appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); } - JSONObject managerMsg = new JSONObject(); - managerMsg.put("title", title); - managerMsg.put("body", body); - managerMsg.put("type", type); - JSONObject messageData = new JSONObject(); - messageData.put("url", url); - managerMsg.put("data", messageData); - managerMsg.put("msgType", "annual_bill"); - AppMessage appMessage = new AppManagerMessageBuilder(managerMsg).buildMessage(); - sender.sendMessage(appMessage, devToken); - log.put("status", 2); - appMessageLogMapper.update(log); - } catch (Exception e) { - logger.error("出错了:" + e.getMessage()); - appMessageLogMapper.updateStatus(log.getString("send_id"), 1, e.getMessage()); - } - }; - sendingAppleMsgPool.execute(task); + }; + sendingAppleMsgPool.execute(task); + } } private String encData(String data, Key key, String publicKey) {