finish refactor the message

master
wangning 7 years ago
parent 835246c24a
commit 2323459f31

@ -469,22 +469,15 @@ public class RetailAppServiceImp implements RetailAppService {
JSONObject type = new JSONObject(); JSONObject type = new JSONObject();
type.put("send_type", "payment"); type.put("send_type", "payment");
type.put("id", order.getString("order_id")); 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"), apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.payment"),
LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"), token, LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"),
order, type); token, order, type);
} }
if("android".equals(devToken.getString("client_type"))) { if ("android".equals(devToken.getString("client_type"))) {
JPushClient jPushClient= JpushMessageHelper.getPush(); jpushMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.payment"),
JpushMessage jpushMessage = new JpushMessage(); LocaleSupport.localeMessage("app.message.body.payment") + order.getString("currency") + order.getDoubleValue("total_amount"),
jpushMessage.setTitle(LocaleSupport.localeMessage("app.message.title.payment")); token, order, type);
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);
} }
log.put("status", 2); log.put("status", 2);
appMessageLogMapper.update(log); appMessageLogMapper.update(log);
@ -529,13 +522,13 @@ public class RetailAppServiceImp implements RetailAppService {
JSONObject type = new JSONObject(); JSONObject type = new JSONObject();
type.put("send_type", "refund"); type.put("send_type", "refund");
type.put("id", order.getString("order_id")); type.put("id", order.getString("order_id"));
if("iphone".equals(devToken.getString("client_type"))) { if ("iphone".equals(devToken.getString("client_type"))) {
apnsMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount, token, apnsMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount,
order, type); token, order, type);
} }
if("android".equals(devToken.getString("client_type"))) { if ("android".equals(devToken.getString("client_type"))) {
jpushMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount,token, jpushMessageHelper.sendAppleMessage("Refund JpushMessage", LocaleSupport.localeMessage("app.message.body.refund") + refundAmount,
order, type); token, order, type);
} }
log.put("status", 2); log.put("status", 2);
appMessageLogMapper.update(log); appMessageLogMapper.update(log);
@ -569,21 +562,13 @@ public class RetailAppServiceImp implements RetailAppService {
JSONObject type = new JSONObject(); JSONObject type = new JSONObject();
type.put("send_type", "notice"); type.put("send_type", "notice");
type.put("id", notice.getNotice_id()); 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, apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), notice.getTitle(), token, noticeObj,
type); type);
} }
if("android".equals(devToken.getString("client_type"))){ if ("android".equals(devToken.getString("client_type"))) {
JPushClient jPushClient= JpushMessageHelper.getPush(); jpushMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), notice.getTitle(), token,
JpushMessage jpushMessage = new JpushMessage(); noticeObj, type);
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);
} }
log.put("status", 2); log.put("status", 2);
@ -616,10 +601,19 @@ public class RetailAppServiceImp implements RetailAppService {
JSONObject type = new JSONObject(); JSONObject type = new JSONObject();
type.put("send_type", "cashback"); type.put("send_type", "cashback");
type.put("id", order.getString("order_id")); type.put("id", order.getString("order_id"));
if ("iphone".equals(devToken.getString("client_type"))) {
apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"), apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.notice"),
LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + " " LocaleSupport.localeMessage("app.message.body.cashback") + PlatformEnvironment.getEnv().getForeignCurrency() + " "
+ cashbackAmount, + cashbackAmount,
token, order, type); 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); log.put("status", 2);
appMessageLogMapper.update(log); appMessageLogMapper.update(log);
} catch (Exception e) { } catch (Exception e) {
@ -653,9 +647,20 @@ public class RetailAppServiceImp implements RetailAppService {
JSONObject type = new JSONObject(); JSONObject type = new JSONObject();
type.put("send_type", "clean"); type.put("send_type", "clean");
type.put("id", log_clearing_detail_id); type.put("id", log_clearing_detail_id);
apnsMessageHelper.sendAppleMessage(LocaleSupport.localeMessage("app.message.title.clean"), LocaleSupport.localeMessage("app.message.body.clean") if ("iphone".equals(devToken.getString("client_type"))) {
+ PlatformEnvironment.getEnv().getForeignCurrency() + " " + clearing_amount + " (" + settle_date_from + "-" + settle_date_to + ")",
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); 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); log.put("status", 2);
appMessageLogMapper.update(log); appMessageLogMapper.update(log);
} catch (Exception e) { } catch (Exception e) {
@ -698,7 +703,6 @@ public class RetailAppServiceImp implements RetailAppService {
} }
} }
@Override @Override
public void updateReadStatus(JSONObject device, String noticeId) { public void updateReadStatus(JSONObject device, String noticeId) {
String clientType = device.getString("client_type"); String clientType = device.getString("client_type");
@ -1125,9 +1129,13 @@ public class RetailAppServiceImp implements RetailAppService {
} }
public void sending(String devToken, JSONObject params, JSONObject log) { public void sending(String devToken, JSONObject params, JSONObject log) {
try { try {
if ("iphone".equals(params.getString("client_type"))) {
apnsMessageHelper.sendAppleMessage(params.getString("title"), params.getString("content"), devToken, new JSONObject(), new JSONObject()); 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); log.put("status", 2);
appMessageLogMapper.update(log); appMessageLogMapper.update(log);
} catch (Exception e) { } catch (Exception e) {
@ -1197,8 +1205,7 @@ public class RetailAppServiceImp implements RetailAppService {
return str.matches(regex); return str.matches(regex);
} }
private void sendJpush(int client_id,JpushMessage message){ private void sendJpush(int client_id, JpushMessage message) {
} }
} }

@ -216,6 +216,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
app.controller('devSendMessageCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) { app.controller('devSendMessageCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {
$scope.params = {type:'Merchant'}; $scope.params = {type:'Merchant'};
alert($scope.params.client_type);
$scope.sendMessage = function () { $scope.sendMessage = function () {
var params = angular.copy($scope.params); var params = angular.copy($scope.params);
$http.put('/dev/send_message',params).then(function (resp) { $http.put('/dev/send_message',params).then(function (resp) {

@ -31,6 +31,13 @@
<label>DevToken</label> <label>DevToken</label>
<input ng-model="params.code" class="form-control" type="text" /> <input ng-model="params.code" class="form-control" type="text" />
</div> </div>
<div class="form-group" ng-if="params.type=='Personal'">
<label>Client Type</label>
<select ng-model="params.client_type">
<option value="iphone"></option>
<option value="android"></option>
</select>
</div>
<div class="form-group"> <div class="form-group">
<label>Title</label> <label>Title</label>
<input ng-model="params.title" class="form-control" type="text" /> <input ng-model="params.title" class="form-control" type="text" />

Loading…
Cancel
Save