|
|
@ -14,6 +14,7 @@ import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.MailService;
|
|
|
|
import au.com.royalpay.payment.manage.notice.core.MailService;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper;
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
|
|
|
|
import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService;
|
|
|
|
import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService;
|
|
|
|
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum;
|
|
|
|
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum;
|
|
|
@ -104,6 +105,9 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, AppMsgSender> senderMap = new HashMap<>();
|
|
|
|
private Map<String, AppMsgSender> senderMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private APNSMessageHelper apnsMessageHelper;
|
|
|
|
|
|
|
|
|
|
|
|
private ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
private ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor(10, 30, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -311,41 +315,40 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
|
|
|
|
JSONObject client = clientMapper.findClientByMoniker(event.getString("client_moniker"));
|
|
|
|
JSONObject client = clientMapper.findClientByMoniker(event.getString("client_moniker"));
|
|
|
|
logger.debug("sendRiskAppMessage-" + client.getString("client_moniker") + "-" + "risk_id:"+event.getString("risk_id"));
|
|
|
|
logger.debug("sendRiskAppMessage-" + client.getString("client_moniker") + "-" + "risk_id:"+event.getString("risk_id"));
|
|
|
|
List<JSONObject> tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id"));
|
|
|
|
List<JSONObject> tokens = clientDeviceTokenMapper.listTokensByClient_id(client.getIntValue("client_id"));
|
|
|
|
for (final JSONObject devToken : tokens) {
|
|
|
|
for (JSONObject devToken : tokens) {
|
|
|
|
Runnable task = () -> {
|
|
|
|
String token = devToken.getString("token");
|
|
|
|
String token = devToken.getString("token");
|
|
|
|
if (token == null) {
|
|
|
|
if (token == null) {
|
|
|
|
continue;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "risk", token,
|
|
|
|
JSONObject log = saveAppMessageLog(devToken.getString("dev_id"), devToken.getIntValue("client_id"), "risk", token,
|
|
|
|
event.getString("risk_id"));
|
|
|
|
event.getString("risk_id"));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
event.put("send_type", "risk");
|
|
|
|
type.put("send_type", "risk");
|
|
|
|
JSONObject type = new JSONObject();
|
|
|
|
type.put("id", event.getString("risk_id"));
|
|
|
|
type.put("send_type", "risk");
|
|
|
|
apnsMessageHelper.sendAppleMessageDetail(
|
|
|
|
type.put("id", event.getString("risk_id"));
|
|
|
|
LocaleSupport.localeMessage("app.message.title.risk"), LocaleSupport.localeMessage("app.message.body.risk"),
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
token, event, type);
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
AppMsgSender sender = senderMap.get(devToken.getString("client_type"));
|
|
|
|
return;
|
|
|
|
if (token == null || sender == null) {
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
|
|
|
|
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.risk"));
|
|
|
|
|
|
|
|
managerMsg.put("body",
|
|
|
|
|
|
|
|
LocaleSupport.localeMessage("app.message.body.risk"));
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", event);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "risk");
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
JSONObject managerMsg = new JSONObject();
|
|
|
|
sendingAppleMsgPool.execute(task);
|
|
|
|
managerMsg.put("title", LocaleSupport.localeMessage("app.message.title.risk"));
|
|
|
|
|
|
|
|
managerMsg.put("body",
|
|
|
|
|
|
|
|
LocaleSupport.localeMessage("app.message.body.risk"));
|
|
|
|
|
|
|
|
managerMsg.put("type", type);
|
|
|
|
|
|
|
|
managerMsg.put("data", event);
|
|
|
|
|
|
|
|
managerMsg.put("msgType", "risk");
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
throw new ServerErrorException("Send App " + devToken.getString("client_type") + " Failed", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|