Merge branch 'develop'

master
luoyang 6 years ago
commit adb3ca051b

@ -5,7 +5,7 @@
<parent>
<groupId>au.com.royalpay.payment</groupId>
<artifactId>payment-parent</artifactId>
<version>0.2.0</version>
<version>0.2.0-dev</version>
</parent>
<modelVersion>4.0.0</modelVersion>

@ -78,4 +78,8 @@ public interface ClientAccountMapper {
List<JSONObject> query(JSONObject params);
List<JSONObject> partnerAndSubPartnerAccounts(@Param("client_id") int clientId);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1 and (role=1 or role=2) and wechat_openid is not null", excludeColumns = {"salt", "password_hash"})
List<JSONObject> listRiskNoticeAccounts(@Param("client_id") int clientId);
}

@ -67,6 +67,13 @@ public interface RiskBusinessService {
*/
void updateRiskEvent(JSONObject params);
/**
*
* @param params
* @param channel
*/
void sendWxMess(JSONObject params, String channel, int result_type);
/**
* zip
* @param riskId

@ -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.RiskMaterialMapper;
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.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
import au.com.royalpay.payment.manage.mappers.system.*;
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;
@ -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.tradelog.core.TradeLogService;
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.AppMsgSender;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
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.permission.enums.ManagerRole;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -72,7 +77,7 @@ import java.util.concurrent.TimeUnit;
* @Date 2018/10/10 10:30
*/
@Service
public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodoNoticeProvider {
public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodoNoticeProvider, ApplicationEventPublisherAware {
private Logger logger = LoggerFactory.getLogger(RiskBusinessServiceImpl.class);
@ -118,6 +123,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
@Resource
private APNSMessageHelper apnsMessageHelper;
@Resource
private ManagerMapper managerMapper;
@Resource
private ClientAccountMapper clientAccountMapper;
@Resource
private MpWechatApiProvider mpWechatApiProvider;
private ApplicationEventPublisher publisher;
@Resource
public void setAppMsgSenders(AppMsgSender[] senders) {
@ -276,7 +289,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
JSONObject client = null;
String clientMoniker = params.getString("client_moniker");
if (clientMoniker != null) {
client = clientMapper.findClientByMoniker(clientMoniker);
client = clientMapper.findClientByMonikerAll(clientMoniker);
if(client == null){
throw new InvalidShortIdException();
}
@ -366,6 +379,105 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
riskEventMapper.update(params);
riskOrdersMapper.clearOrders(params.getString("risk_id"));
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.findClientByMonikerAll(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("wechat_openid")!=null){
if (StringUtils.isNotBlank(account.getString("wechat_openid"))) {
try {
MpWechatApi paymentApi = mpWechatApiProvider.getNewPaymentApi();
TemplateMessage msg = initSendPartnerCloseChannelAndPartnerTemplate(account.getString("wechat_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;
}
/**

@ -131,8 +131,12 @@ public class RiskBusinessController {
@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchChannelPermission(manager, params.getString("client_moniker"), channel, channelFlag);
if (channelFlag)
if (channelFlag) {
params.put("result_type", RiskResultTypeEnum.ALREADY_HANDLED.getResultType());
} else {
//1:禁用渠道;2:禁用商户
riskBusinessService.sendWxMess(params, channel, 1);
}
riskBusinessService.updateRiskEvent(params);
}
@ -143,6 +147,7 @@ public class RiskBusinessController {
String clientMoniker = params.getString("client_moniker");
if (isValid) {
clientManager.disableClient(clientMoniker, manager);
riskBusinessService.sendWxMess(params, "-", 2);
Integer temporaryCloseMerchant = params.getInteger("temporary_close_merchant");
if (temporaryCloseMerchant != 1) {
params.put("result_type", RiskResultTypeEnum.ALREADY_HANDLED.getResultType());

@ -32,6 +32,7 @@ public class WepayWechatApiImpl extends AbstractMpWechatClientApi implements MpW
registerTemplateId("daily-green-channel", "vjeNnggHnnRHvBP80lkEEtPk8ouf7JnvrQYDCyxqx4g");
registerTemplateId("client-postpone", "5eNJ5ZTKWitC1TJClb2coymtNCmOC7d86h0zCrxmGig");
registerTemplateId("test-merchant-password","cF_zIhB4VmjdOaDS2_RNVFforyywsKcfjS1yNNgYmWw");
registerTemplateId("risk-forbidden-channelAndPartner","g79Sf5FOQT6PoCvRVzm7YlgtzbZ_EUD1z6E4Xp2Jwp4");
}
@Override

@ -432,9 +432,9 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
return function (gateway) {
switch (gateway + '') {
case '0':
return '线下码';
return '线下C端付款码';
case '1':
return '线下码';
return '线下B端二维码';
case '2':
return '商户静态码';
case '3':
@ -442,9 +442,9 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
case '4':
return 'WeChat HTML5';
case '5':
return '线下网关';
return '线下网关(C端付款码)';
case '6':
return '线下网关';
return '线下网关(B端二维码)';
case '7':
return '商户静态码';
case '8':

@ -449,9 +449,9 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
return function (gateway) {
switch (gateway + '') {
case '0':
return '线下码';
return '线下C端付款码';
case '1':
return '线下码';
return '线下B端二维码';
case '2':
return '商户静态码';
case '3':
@ -459,9 +459,9 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
case '4':
return 'WeChat HTML5';
case '5':
return '线下网关';
return '线下网关(C端付款码)';
case '6':
return '线下网关';
return '线下网关(B端二维码)';
case '7':
return '商户静态码';
case '8':

Loading…
Cancel
Save