From 2323459f31d1208b98f966e1e79cef0279b336ac Mon Sep 17 00:00:00 2001 From: wangning <164851225@qq.com> Date: Fri, 5 Jan 2018 16:55:41 +0800 Subject: [PATCH] finish refactor the message --- .../core/impls/RetailAppServiceImp.java | 99 ++++++++++--------- .../ui/static/config/devtools/devtools.js | 1 + .../devtools/templates/send_message.html | 7 ++ 3 files changed, 61 insertions(+), 46 deletions(-) diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 93d7933f1..0c8713957 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -469,24 +469,17 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject type = new JSONObject(); type.put("send_type", "payment"); type.put("id", order.getString("order_id")); - if("iphone".equals(devToken.getString("client_type"))) { + if ("iphone".equals(devToken.getString("client_type"))) { apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.payment"), - LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"), token, - order, type); + LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"), + token, order, type); } - if("android".equals(devToken.getString("client_type"))) { - JPushClient jPushClient= JpushMessageHelper.getPush(); - JpushMessage jpushMessage = new JpushMessage(); - jpushMessage.setTitle(LocaleSupport.localeMessage("app.message.title.payment")); - jpushMessage.setText(LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount")); - JSONObject param = new JSONObject(); - param.put("data",order); - param.put("type",type); - jpushMessage.setParams(param); - PushPayload pushPayload =JpushMessageHelper.generateSinglePayload(token,jpushMessage); - jPushClient.sendPush(pushPayload); + if ("android".equals(devToken.getString("client_type"))) { + jpushMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.payment"), + LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"), + token, order, type); } - log.put("status", 2); + log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { logger.error("出错了:" + e.getMessage()); @@ -529,15 +522,15 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject type = new JSONObject(); type.put("send_type", "refund"); type.put("id", order.getString("order_id")); - if("iphone".equals(devToken.getString("client_type"))) { - apnsMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount, token, - order, type); + if ("iphone".equals(devToken.getString("client_type"))) { + apnsMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount, + token, order, type); } - if("android".equals(devToken.getString("client_type"))) { - jpushMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount,token, - order, type); + if ("android".equals(devToken.getString("client_type"))) { + jpushMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount, + token, order, type); } - log.put("status", 2); + log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { logger.error("出错了:" + e.getMessage()); @@ -569,21 +562,13 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject type = new JSONObject(); type.put("send_type", "notice"); type.put("id", notice.getNotice_id()); - if("iphone".equals(devToken.getString("client_type"))){ + if ("iphone".equals(devToken.getString("client_type"))) { apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), notice.getTitle(), token, noticeObj, type); } - if("android".equals(devToken.getString("client_type"))){ - JPushClient jPushClient= JpushMessageHelper.getPush(); - JpushMessage jpushMessage = new JpushMessage(); - jpushMessage.setTitle(notice.getTitle()); - jpushMessage.setText(LocaleSupport.localeMessage("app.message.title.notice")); - JSONObject param = new JSONObject(); - param.put("data",noticeObj); - param.put("type",type); - jpushMessage.setParams(param); - PushPayload pushPayload =JpushMessageHelper.generateSinglePayload(token,jpushMessage); - jPushClient.sendPush(pushPayload); + if ("android".equals(devToken.getString("client_type"))) { + jpushMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), notice.getTitle(), token, + noticeObj, type); } log.put("status", 2); @@ -616,10 +601,19 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject type = new JSONObject(); type.put("send_type", "cashback"); type.put("id", order.getString("order_id")); - apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), - LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + " " - + cashbackAmount, - token, order, type); + if ("iphone".equals(devToken.getString("client_type"))) { + + apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), + LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + + cashbackAmount, + token, order, type); + } + if ("android".equals(devToken.getString("client_type"))) { + jpushMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), + LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + + cashbackAmount, + token, order, type); + } log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { @@ -653,9 +647,20 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject type = new JSONObject(); type.put("send_type", "clean"); type.put("id", log_clearing_detail_id); - apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.clean"), LocaleSupport.localeMessage("app.message.body.clean") - + PlatformEnvironment.getEnv().getForeignCurrency() + " " + clearing_amount + " (" + settle_date_from + "-" + settle_date_to + ")", - token, log_clearing_detail, type); + if ("iphone".equals(devToken.getString("client_type"))) { + + apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.clean"), + LocaleSupport.localeMessage("app.message.body.clean") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + clearing_amount + + " (" + settle_date_from + "-" + settle_date_to + ")", + token, log_clearing_detail, type); + } + + if ("android".equals(devToken.getString("client_type"))) { + jpushMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.clean"), + LocaleSupport.localeMessage("app.message.body.clean") + PlatformEnvironment.getEnv().getForeignCurrency() + " " + clearing_amount + + " (" + settle_date_from + "-" + settle_date_to + ")", + token, log_clearing_detail, type); + } log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { @@ -698,7 +703,6 @@ public class RetailAppServiceImp implements RetailAppService { } } - @Override public void updateReadStatus(JSONObject device, String noticeId) { String clientType = device.getString("client_type"); @@ -1125,9 +1129,13 @@ public class RetailAppServiceImp implements RetailAppService { } public void sending(String devToken, JSONObject params, JSONObject log) { - try { - apnsMessageHelper.sendAppleMessage(params.getString("title"), params.getString("content"), devToken, new JSONObject(), new JSONObject()); + if ("iphone".equals(params.getString("client_type"))) { + apnsMessageHelper.sendAppleMessage(params.getString("title"), params.getString("content"), devToken, new JSONObject(), new JSONObject()); + } + if ("android".equals(params.getString("client_type"))) { + jpushMessageHelper.sendAppleMessage(params.getString("title"), params.getString("content"), devToken, new JSONObject(), new JSONObject()); + } log.put("status", 2); appMessageLogMapper.update(log); } catch (Exception e) { @@ -1197,8 +1205,7 @@ public class RetailAppServiceImp implements RetailAppService { return str.matches(regex); } - private void sendJpush(int client_id,JpushMessage message){ - + private void sendJpush(int client_id, JpushMessage message) { } } diff --git a/src/main/ui/static/config/devtools/devtools.js b/src/main/ui/static/config/devtools/devtools.js index cd653273d..709fc4f53 100644 --- a/src/main/ui/static/config/devtools/devtools.js +++ b/src/main/ui/static/config/devtools/devtools.js @@ -216,6 +216,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) { app.controller('devSendMessageCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) { $scope.params = {type:'Merchant'}; + alert($scope.params.client_type); $scope.sendMessage = function () { var params = angular.copy($scope.params); $http.put('/dev/send_message',params).then(function (resp) { diff --git a/src/main/ui/static/config/devtools/templates/send_message.html b/src/main/ui/static/config/devtools/templates/send_message.html index 378f1bbcb..dc37ff46a 100644 --- a/src/main/ui/static/config/devtools/templates/send_message.html +++ b/src/main/ui/static/config/devtools/templates/send_message.html @@ -31,6 +31,13 @@ +
+ + +