|
|
@ -11,9 +11,7 @@ import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskEventMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskFileMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskFileMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskMaterialMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskMaterialMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskOrdersMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskOrdersMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.*;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
|
|
|
|
|
|
|
|
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.APNSMessageHelper;
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
|
|
|
|
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder;
|
|
|
@ -26,10 +24,15 @@ import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
|
|
|
|
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskOrderTypeEnum;
|
|
|
|
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskOrderTypeEnum;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.exceptions.WechatException;
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMessage;
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMessage;
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMsgSender;
|
|
|
|
import au.com.royalpay.payment.tools.device.message.AppMsgSender;
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.event.WechatExceptionEvent;
|
|
|
|
import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
|
import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
|
|
|
@ -49,6 +52,8 @@ import org.apache.poi.ss.usermodel.*;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
|
|
|
|
import org.springframework.context.ApplicationEventPublisherAware;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@ -72,7 +77,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
* @Date 2018/10/10 10:30
|
|
|
|
* @Date 2018/10/10 10:30
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodoNoticeProvider {
|
|
|
|
public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodoNoticeProvider, ApplicationEventPublisherAware {
|
|
|
|
|
|
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(RiskBusinessServiceImpl.class);
|
|
|
|
private Logger logger = LoggerFactory.getLogger(RiskBusinessServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
|
@ -118,6 +123,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
private APNSMessageHelper apnsMessageHelper;
|
|
|
|
private APNSMessageHelper apnsMessageHelper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private ClientAccountMapper clientAccountMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private MpWechatApiProvider mpWechatApiProvider;
|
|
|
|
|
|
|
|
private ApplicationEventPublisher publisher;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
@Resource
|
|
|
|
public void setAppMsgSenders(AppMsgSender[] senders) {
|
|
|
|
public void setAppMsgSenders(AppMsgSender[] senders) {
|
|
|
@ -366,6 +379,105 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
|
|
|
|
riskEventMapper.update(params);
|
|
|
|
riskEventMapper.update(params);
|
|
|
|
riskOrdersMapper.clearOrders(params.getString("risk_id"));
|
|
|
|
riskOrdersMapper.clearOrders(params.getString("risk_id"));
|
|
|
|
setRiskOrders(params);
|
|
|
|
setRiskOrders(params);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void sendWxMess(JSONObject params, String channel, int result_type) {
|
|
|
|
|
|
|
|
String type = "禁用";
|
|
|
|
|
|
|
|
if (params.get("temporary_close_merchant") != null) {
|
|
|
|
|
|
|
|
if (params.getBoolean("temporary_close_merchant")) {
|
|
|
|
|
|
|
|
type = "临时禁用";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (params.get("temporary_close_channel") != null) {
|
|
|
|
|
|
|
|
if (params.getBoolean("temporary_close_channel")) {
|
|
|
|
|
|
|
|
type = "临时禁用";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String clientMoniker = params.getString("client_moniker");
|
|
|
|
|
|
|
|
if (clientMoniker == null) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JSONObject client = clientMapper.findClientByMoniker(clientMoniker);
|
|
|
|
|
|
|
|
if (client == null) {
|
|
|
|
|
|
|
|
throw new InvalidShortIdException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
client.put("close_type", type);
|
|
|
|
|
|
|
|
client.put("result_type", result_type);
|
|
|
|
|
|
|
|
client.put("channel", channel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String bd_id = client.getString("bd_user");
|
|
|
|
|
|
|
|
String[] bdIdArray = bd_id.split(",");
|
|
|
|
|
|
|
|
for (String bdId : bdIdArray) {
|
|
|
|
|
|
|
|
JSONObject bd = managerMapper.findById(bdId);
|
|
|
|
|
|
|
|
if (bd != null) {
|
|
|
|
|
|
|
|
if (bd.get("wx_openid")!=null){
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(bd.getString("wx_openid"))) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
|
|
|
TemplateMessage msg = initSendBDCloseChannelAndPartnerTemplate(bd.getString("wx_openid"), paymentApi.getTemplateId("risk-forbidden-channelAndPartner"),client);
|
|
|
|
|
|
|
|
paymentApi.sendTemplateMessage(msg);
|
|
|
|
|
|
|
|
} catch (WechatException e) {
|
|
|
|
|
|
|
|
logger.error("Wechat Message Error,风控关闭通道" + e.getMessage());
|
|
|
|
|
|
|
|
publisher.publishEvent(new WechatExceptionEvent(this, e, "风控关闭通道"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<JSONObject> accounts = clientAccountMapper.listRiskNoticeAccounts(client.getIntValue("client_id"));
|
|
|
|
|
|
|
|
if (accounts != null) {
|
|
|
|
|
|
|
|
for (JSONObject account : accounts) {
|
|
|
|
|
|
|
|
if (account.get("wx_openid")!=null){
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(account.getString("wx_openid"))) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
|
|
|
|
|
|
|
|
TemplateMessage msg = initSendPartnerCloseChannelAndPartnerTemplate(account.getString("wx_openid"), paymentApi.getTemplateId("risk-forbidden-channelAndPartner"),client);
|
|
|
|
|
|
|
|
paymentApi.sendTemplateMessage(msg);
|
|
|
|
|
|
|
|
} catch (WechatException e) {
|
|
|
|
|
|
|
|
logger.error("Wechat Message Error,风控关闭通道" + e.getMessage());
|
|
|
|
|
|
|
|
publisher.publishEvent(new WechatExceptionEvent(this, e, "风控关闭通道"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TemplateMessage initSendBDCloseChannelAndPartnerTemplate(String wxopenid, String templateId,JSONObject client) {
|
|
|
|
|
|
|
|
TemplateMessage msg = new TemplateMessage(wxopenid, templateId,null);
|
|
|
|
|
|
|
|
//1:关闭渠道;2:关闭商户
|
|
|
|
|
|
|
|
if (client.getIntValue("result_type") == 1) {
|
|
|
|
|
|
|
|
msg.put("first", "您的商户("+client.getString("client_moniker")+")" + client.getString("channel") + "支付渠道已"+client.getString("close_type"), "#000000");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
msg.put("first", "您的商户("+client.getString("client_moniker")+")已"+client.getString("close_type"), "#000000");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.put("keyword1", client.getString("channel") + "风控调单", "#0000ff");
|
|
|
|
|
|
|
|
msg.put("keyword2", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"), "#000000");
|
|
|
|
|
|
|
|
msg.put("remark", "请联系商户尽快配合风控部门上传相应资料,以免影响支付", "#0000FF");
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private TemplateMessage initSendPartnerCloseChannelAndPartnerTemplate(String wxopenid, String templateId,JSONObject client) {
|
|
|
|
|
|
|
|
TemplateMessage msg = new TemplateMessage(wxopenid, templateId,null);
|
|
|
|
|
|
|
|
//1:关闭渠道;2:关闭商户
|
|
|
|
|
|
|
|
if (client.getIntValue("result_type") == 1) {
|
|
|
|
|
|
|
|
msg.put("first", "您的商户" + client.getString("channel") + "支付渠道已"+client.getString("close_type"), "#000000");
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
msg.put("first", "您的商户("+client.getString("client_moniker")+")已"+client.getString("close_type"), "#000000");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.put("keyword1", client.getString("channel") + "风控调单", "#0000ff");
|
|
|
|
|
|
|
|
msg.put("keyword2", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"), "#000000");
|
|
|
|
|
|
|
|
msg.put("remark", "请尽快配合风控部门上传相应资料,以免影响支付", "#0000FF");
|
|
|
|
|
|
|
|
return msg;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
|
|
|
|
|
|
|
|
this.publisher = applicationEventPublisher;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|