@ -1,8 +1,9 @@
package au.com.royalpay.payment.manage.riskbusiness.core.impl ;
package au.com.royalpay.payment.manage.riskbusiness.core.impl ;
import au.com.royalpay.payment.core.CardSecureService ;
import au.com.royalpay.payment.core.beans.ChargebackStatus ;
import au.com.royalpay.payment.core.exceptions.EmailException ;
import au.com.royalpay.payment.core.exceptions.EmailException ;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException ;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException ;
import au.com.royalpay.payment.core.exceptions.OrderNotExistsException ;
import au.com.royalpay.payment.core.exceptions.OrderNotMatchException ;
import au.com.royalpay.payment.core.exceptions.OrderNotMatchException ;
import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper ;
import au.com.royalpay.payment.manage.mappers.log.AppMessageLogMapper ;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper ;
import au.com.royalpay.payment.manage.mappers.payment.OrderMapper ;
@ -20,11 +21,11 @@ import au.com.royalpay.payment.manage.riskbusiness.core.RiskMaterialService;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService ;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService ;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskUploadService ;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskUploadService ;
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskEmailStatusEnum ;
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskEmailStatusEnum ;
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskOrderTypeEnum ;
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum ;
import au.com.royalpay.payment.manage.riskbusiness.enums.RiskResultTypeEnum ;
import au.com.royalpay.payment.manage.signin.beans.TodoNotice ;
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.tools.connections.mpsupport.MpWechatApi ;
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.MpWechatApiProvider ;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage ;
import au.com.royalpay.payment.tools.connections.mpsupport.beans.TemplateMessage ;
@ -34,23 +35,28 @@ 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.env.SysConfigManager ;
import au.com.royalpay.payment.tools.env.SysConfigManager ;
import au.com.royalpay.payment.tools.exceptions.BadRequestException ;
import au.com.royalpay.payment.tools.exceptions.BadRequestException ;
import au.com.royalpay.payment.tools.exceptions.NotFoundException ;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException ;
import au.com.royalpay.payment.tools.exceptions.event.WechatExceptionEvent ;
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.mappers.CommonRiskEventMapper ;
import au.com.royalpay.payment.tools.mappers.RiskEventDAO ;
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. risk.RiskEvent ;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor ;
import au.com.royalpay.payment.tools.threadpool.RoyalThreadPoolExecutor ;
import au.com.royalpay.payment.tools.utils.PageListUtils ;
import au.com.royalpay.payment.tools.utils.PageListUtils ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONObject ;
import com.alibaba.fastjson.JSONObject ;
import com.github.miemiedev.mybatis.paginator.domain.Order ;
import com.github.miemiedev.mybatis.paginator.domain.Order ;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds ;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds ;
import com.github.miemiedev.mybatis.paginator.domain.PageList ;
import com.github.miemiedev.mybatis.paginator.domain.PageList ;
import org.apache.commons.codec.binary.Base64 ;
import org.apache.commons.lang3.RandomStringUtils ;
import org.apache.commons.lang3.RandomStringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.commons.lang3.time.DateFormatUtils ;
import org.apache.commons.lang3.time.DateFormatUtils ;
import org.apache.commons.lang3.time.DateUtils ;
import org.apache.commons.lang3.time.DateUtils ;
import org.apache.poi.ss.usermodel.* ;
import org.apache.poi.ss.usermodel.Cell ;
import org.apache.poi.ss.usermodel.Row ;
import org.apache.poi.ss.usermodel.Sheet ;
import org.apache.poi.ss.usermodel.Workbook ;
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 ;
@ -62,17 +68,19 @@ import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.context.Context ;
import org.thymeleaf.context.Context ;
import org.thymeleaf.spring5.SpringTemplateEngine ;
import org.thymeleaf.spring5.SpringTemplateEngine ;
import javax.annotation.Resource ;
import javax.servlet.http.HttpServletResponse ;
import javax.servlet.http.HttpServletResponse ;
import java.io.* ;
import java.io.ByteArrayOutputStream ;
import java.io.IOException ;
import java.io.InputStream ;
import java.net.URL ;
import java.net.URL ;
import java.text.ParseException ;
import java.text.ParseException ;
import java.util.* ;
import java.util.* ;
import javax.annotation.Resource ;
import java.util.concurrent.LinkedBlockingQueue ;
import java.util.concurrent.LinkedBlockingQueue ;
import java.util.concurrent.ThreadPoolExecutor ;
import java.util.concurrent.ThreadPoolExecutor ;
import java.util.concurrent.TimeUnit ;
import java.util.zip.ZipEntry ;
import java.util.zip.ZipEntry ;
import java.util.zip.ZipOutputStream ;
import java.util.zip.ZipOutputStream ;
import java.util.concurrent.TimeUnit ;
/ * *
/ * *
* @Author lvjian
* @Author lvjian
@ -80,12 +88,20 @@ import java.util.concurrent.TimeUnit;
* /
* /
@Service
@Service
public class RiskBusinessServiceImpl implements RiskBusinessService , ManagerTodoNoticeProvider , ApplicationEventPublisherAware {
public class RiskBusinessServiceImpl implements RiskBusinessService , ManagerTodoNoticeProvider , ApplicationEventPublisherAware {
public static final int RISK_ORDER_TYPE_WX = 1 ;
public static final int RISK_ORDER_TYPE_ALIPAY = 2 ;
public static final int RISK_ORDER_TYPE_RP = 3 ;
public static final int RISK_ORDER_TYPE_WARN = 4 ;
public static final int RISK_ORDER_TYPE_COMMON_MID = 5 ;
public static final int RISK_ORDER_TYPE_CHARGEBACK = 6 ;
private Logger logger = LoggerFactory . getLogger ( RiskBusinessServiceImpl . class ) ;
private Logger logger = LoggerFactory . getLogger ( RiskBusinessServiceImpl . class ) ;
@Resource
@Resource
private RiskEventMapper riskEventMapper ;
private RiskEventMapper riskEventMapper ;
@Resource
@Resource
private CommonRiskEventMapper commonRiskEventMapper ;
@Resource
private ClientMapper clientMapper ;
private ClientMapper clientMapper ;
@Resource
@Resource
private ClientBDMapper clientBDMapper ;
private ClientBDMapper clientBDMapper ;
@ -123,11 +139,13 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
@Resource
@Resource
private AppMessageLogMapper appMessageLogMapper ;
private AppMessageLogMapper appMessageLogMapper ;
private Map < String , AppMsgSender > senderMap = new HashMap < > ( ) ;
private final Map < String , AppMsgSender > senderMap = new HashMap < > ( ) ;
@Resource
@Resource
private APNSMessageHelper apnsMessageHelper ;
private APNSMessageHelper apnsMessageHelper ;
@Resource
@Resource
private CardSecureService cardSecureService ;
@Resource
private ManagerMapper managerMapper ;
private ManagerMapper managerMapper ;
@Resource
@Resource
private ClientAccountMapper clientAccountMapper ;
private ClientAccountMapper clientAccountMapper ;
@ -144,7 +162,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
Arrays . stream ( senders ) . forEach ( appMsgSender - > senderMap . put ( appMsgSender . devType ( ) , appMsgSender ) ) ;
Arrays . stream ( senders ) . forEach ( appMsgSender - > senderMap . put ( appMsgSender . devType ( ) , appMsgSender ) ) ;
}
}
private ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor ( 10 , 30 , 5 , TimeUnit . SECONDS , new LinkedBlockingQueue < Runnable > ( ) ) ;
private final ThreadPoolExecutor sendingAppleMsgPool = new ThreadPoolExecutor ( 10 , 30 , 5 , TimeUnit . SECONDS , new LinkedBlockingQueue < Runnable > ( ) ) ;
@Override
@Override
public List < JSONObject > getRiskEvents ( JSONObject params ) {
public List < JSONObject > getRiskEvents ( JSONObject params ) {
@ -158,7 +176,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
if ( manager ! = null & & ManagerRole . BD_USER . hasRole ( manager . getIntValue ( "role" ) ) ) {
if ( manager ! = null & & ManagerRole . BD_USER . hasRole ( manager . getIntValue ( "role" ) ) ) {
params . put ( "bd_id" , manager . getString ( "manager_id" ) ) ;
params . put ( "bd_id" , manager . getString ( "manager_id" ) ) ;
List < Integer > orderTypes = Arrays . asList ( RiskOrderTypeEnum . WECHAT_ORDER . getOrderType ( ) ,
List < Integer > orderTypes = Arrays . asList ( RiskOrderTypeEnum . WECHAT_ORDER . getOrderType ( ) ,
RiskOrderTypeEnum . ALIPAY_ORDER . getOrderType ( ) , RiskOrderTypeEnum . ROYALPAY_ORDER . getOrderType ( ) ) ;
RiskOrderTypeEnum . ALIPAY_ORDER . getOrderType ( ) , RiskOrderTypeEnum . ROYALPAY_ORDER . getOrderType ( ) ) ;
params . put ( "order_types" , orderTypes ) ;
params . put ( "order_types" , orderTypes ) ;
List < Integer > resultTypes = Arrays . asList ( RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) ,
List < Integer > resultTypes = Arrays . asList ( RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) ,
@ -176,8 +194,10 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 微 信 调 单 、 支 付 宝 调 单 、 royalpay 调 单
* 微 信 调 单 、 支 付 宝 调 单 、 royalpay 调 单
* 未 处 理 、 已 发 送 、 待 审 核 、 打 回
* 未 处 理 、 已 发 送 、 待 审 核 、 打 回
* /
* /
Date currentDate = new Date ( ) , replyDate ;
Date currentDate = new Date ( ) ;
Integer resultType , orderType ;
Date replyDate ;
Integer resultType ;
Integer orderType ;
boolean isPassTimeout = false ;
boolean isPassTimeout = false ;
for ( JSONObject riskEvent : riskEvents ) {
for ( JSONObject riskEvent : riskEvents ) {
try {
try {
@ -206,15 +226,15 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
@Override
@Override
public List < JSONObject > analysisByIndustry ( JSONObject params , JSONObject manager ) {
public List < JSONObject > analysisByIndustry ( JSONObject params , JSONObject manager ) {
List < JSONObject > industryAnalysis = riskEventMapper . analysisByIndustry ( params ) ;
List < JSONObject > industryAnalysis = riskEventMapper . analysisByIndustry ( params ) ;
for ( JSONObject industry : industryAnalysis ) {
for ( JSONObject industry : industryAnalysis ) {
if ( StringUtils . isBlank ( industry . getString ( "industry" ) ) ) {
if ( StringUtils . isBlank ( industry . getString ( "industry" ) ) ) {
industry . put ( "industry" , "未知行业" ) ;
industry . put ( "industry" , "未知行业" ) ;
}
}
}
}
return industryAnalysis ;
return industryAnalysis ;
}
}
private List < String > industryArray ( ) {
private List < String > industryArray ( ) {
List < String > industryArray = new ArrayList < > ( ) ;
List < String > industryArray = new ArrayList < > ( ) ;
industryArray . add ( "鞋包服饰" ) ;
industryArray . add ( "鞋包服饰" ) ;
industryArray . add ( "机票行业" ) ;
industryArray . add ( "机票行业" ) ;
@ -278,13 +298,13 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 通 用 号 调 单 与 其 他 类 型 的 调 单 , 订 单 格 式 不 一 样 , 所 以 区 分
* 通 用 号 调 单 与 其 他 类 型 的 调 单 , 订 单 格 式 不 一 样 , 所 以 区 分
* /
* /
if ( riskEvent . getIntValue ( "order_type" ) = = 3 ) {
if ( riskEvent . getIntValue ( "order_type" ) = = 3 ) {
for ( int i = 0 ; i < orderIdArray . length ; i + + ) {
for ( String orderId : orderIdArray ) {
orderInfo = tradeLogService . getOrderDetail ( new JSONObject ( ) , riskEvent . getString ( "client_moniker" ) , orderId Array[ i ] , null ) ;
orderInfo = tradeLogService . getOrderDetail ( new JSONObject ( ) , riskEvent . getString ( "client_moniker" ) , orderId , null ) ;
tradeLogs . add ( orderInfo ) ;
tradeLogs . add ( orderInfo ) ;
}
}
} else {
} else {
for ( int i = 0 ; i < orderIdArray . length ; i + + ) {
for ( String orderId : orderIdArray ) {
orderInfo = orderMapper . findOrderById ( orderId Array[ i ] , client . getIntValue ( "client_id" ) ) ;
orderInfo = orderMapper . findOrderById ( orderId , client . getIntValue ( "client_id" ) ) ;
tradeLogs . add ( orderInfo ) ;
tradeLogs . add ( orderInfo ) ;
}
}
}
}
@ -298,7 +318,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
String clientMoniker = params . getString ( "client_moniker" ) ;
String clientMoniker = params . getString ( "client_moniker" ) ;
if ( clientMoniker ! = null ) {
if ( clientMoniker ! = null ) {
client = clientMapper . findClientByMonikerAll ( clientMoniker ) ;
client = clientMapper . findClientByMonikerAll ( clientMoniker ) ;
if ( client = = null ) {
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
throw new InvalidShortIdException ( ) ;
}
}
}
}
@ -322,7 +342,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
PageList < JSONObject > transactionList = transactionMapper . findByClientIdAndSystemTransactionId ( client . getIntValue ( "client_id" ) , orderIdArray [ i ] , new PageBounds ( Order . formString ( "transaction_time.desc" ) ) ) ;
PageList < JSONObject > transactionList = transactionMapper . findByClientIdAndSystemTransactionId ( client . getIntValue ( "client_id" ) , orderIdArray [ i ] , new PageBounds ( Order . formString ( "transaction_time.desc" ) ) ) ;
// 判断该笔订单是否存在,是否属于该商户
// 判断该笔订单是否存在,是否属于该商户
// 由于查询订单时已经关联商户了,所以只会抛出订单不匹配的异常
// 由于查询订单时已经关联商户了,所以只会抛出订单不匹配的异常
if ( transactionList = = null | | transactionList . size( ) < = 0 )
if ( transactionList = = null | | transactionList . isEmpty( ) )
throw new OrderNotMatchException ( ) ;
throw new OrderNotMatchException ( ) ;
/ *
/ *
else {
else {
@ -349,6 +369,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 添 加 风 控 事 件
* 添 加 风 控 事 件
* 更 新 risk_orders 表
* 更 新 risk_orders 表
* 记 录 风 控 日 志
* 记 录 风 控 日 志
*
* @param params
* @param params
* @param manager
* @param manager
* /
* /
@ -364,38 +385,51 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
RiskResultTypeEnum . NOT_HANDLED . getRemark ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getRemark ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ) ;
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ) ;
int orderType = params . getIntValue ( "order_type" ) ;
if ( orderType = = RISK_ORDER_TYPE_CHARGEBACK ) {
logger . info ( "Chargeback event" ) ;
RiskEvent evt = getRiskEvent ( params . getString ( "risk_id" ) ) ;
if ( evt = = null ) {
return ;
}
cardSecureService . submitChargeBackReport ( evt ) ;
}
}
private RiskEvent getRiskEvent ( String riskId ) {
return Optional . ofNullable ( commonRiskEventMapper . findById ( riskId ) ) . map ( RiskEventDAO : : convert ) . orElse ( null ) ;
}
}
private void setRiskOrders ( JSONObject params ) {
private void setRiskOrders ( JSONObject params ) {
if ( StringUtils . isNotBlank ( params . getString ( "real_order_ids" ) ) ) {
if ( StringUtils . isNotBlank ( params . getString ( "real_order_ids" ) ) ) {
String riskId = params . getString ( "risk_id" ) ;
String riskId = params . getString ( "risk_id" ) ;
String orderIds = params . getString ( "real_order_ids" ) ;
String orderIds = params . getString ( "real_order_ids" ) ;
for ( String orderId : orderIds . split ( "," ) ) {
for ( String orderId : orderIds . split ( "," ) ) {
JSONObject order = transactionMapper . findByOrderId ( orderId ) ;
JSONObject order = transactionMapper . findByOrderId ( orderId ) ;
JSONObject riskOrder = new JSONObject ( ) ;
JSONObject riskOrder = new JSONObject ( ) ;
riskOrder . put ( "risk_id" , riskId ) ;
riskOrder . put ( "risk_id" , riskId ) ;
riskOrder . put ( "order_id" , orderId ) ;
riskOrder . put ( "order_id" , orderId ) ;
riskOrder . put ( "clearing_amount" , order . getString ( "clearing_amount" ) ) ;
riskOrder . put ( "clearing_amount" , order . getString ( "clearing_amount" ) ) ;
riskOrdersMapper . save ( riskOrder ) ;
riskOrdersMapper . save ( riskOrder ) ;
}
}
}
}
}
}
@Override
@Override
public void updateRiskEvent ( JSONObject params , JSONObject manager ) {
public void updateRiskEvent ( JSONObject params , JSONObject manager ) {
if ( StringUtils . isNotBlank ( params . getString ( "channel_result" ) ) ) {
if ( StringUtils . isNotBlank ( params . getString ( "channel_result" ) ) ) {
JSONObject risk = riskEventMapper . findById ( params . getString ( "risk_id" ) ) ;
JSONObject risk = riskEventMapper . findById ( params . getString ( "risk_id" ) ) ;
//填写渠道处理结果时候,支付宝、微信和内部调单在材料审核通过前无法填写渠道处理结果
//填写渠道处理结果时候,支付宝、微信和内部调单在材料审核通过前无法填写渠道处理结果
if ( params . getIntValue ( "result_type" ) < RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getResultType ( ) & & params . getIntValue ( "order_type" ) < RiskOrderTypeEnum . WARNING_ORDER . getOrderType ( ) ) {
if ( params . getIntValue ( "result_type" ) < RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getResultType ( ) & & params . getIntValue ( "order_type" ) < RiskOrderTypeEnum . WARNING_ORDER . getOrderType ( ) ) {
throw new BadRequestException ( "请先提交渠道方材料进行审核!" ) ;
throw new BadRequestException ( "请先提交渠道方材料进行审核!" ) ;
}
}
//渠道处理结果不一样,才会记录操作并更改事件单状态为渠道方处理结果
//渠道处理结果不一样,才会记录操作并更改事件单状态为渠道方处理结果
if ( risk . getString ( "channel_result" ) = = null | | ! risk . getString ( "channel_result" ) . equals ( params . getString ( "channel_result" ) ) ) {
if ( risk . getString ( "channel_result" ) = = null | | ! risk . getString ( "channel_result" ) . equals ( params . getString ( "channel_result" ) ) ) {
params . put ( "result_type" , RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
params . put ( "result_type" , RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
riskProcessLogService . addRiskProcessLog ( params . getString ( "risk_id" ) ,
riskProcessLogService . addRiskProcessLog ( params . getString ( "risk_id" ) ,
manager . getString ( "manager_id" ) ,
manager . getString ( "manager_id" ) ,
manager . getString ( "display_name" ) ,
manager . getString ( "display_name" ) ,
RiskResultTypeEnum . ALREADY_HANDLED . getRemark ( ) + ":" + params . getString ( "channel_result" ) ,
RiskResultTypeEnum . ALREADY_HANDLED . getRemark ( ) + ":" + params . getString ( "channel_result" ) ,
params . getIntValue ( "result_type" ) ,
params . getIntValue ( "result_type" ) ,
RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
}
}
@ -411,12 +445,12 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
public void sendWxMess ( JSONObject params , String channel , int result_type ) {
public void sendWxMess ( JSONObject params , String channel , int result_type ) {
String type = "禁用" ;
String type = "禁用" ;
if ( params . get ( "temporary_close_merchant" ) ! = null ) {
if ( params . get ( "temporary_close_merchant" ) ! = null ) {
if ( params . getBoolean ( "temporary_close_merchant" ) ) {
if ( params . getBoolean Value ( "temporary_close_merchant" ) ) {
type = "临时禁用" ;
type = "临时禁用" ;
}
}
}
}
if ( params . get ( "temporary_close_channel" ) ! = null ) {
if ( params . get ( "temporary_close_channel" ) ! = null ) {
if ( params . getBoolean ( "temporary_close_channel" ) ) {
if ( params . getBoolean Value ( "temporary_close_channel" ) ) {
type = "临时禁用" ;
type = "临时禁用" ;
}
}
}
}
@ -437,14 +471,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
for ( String bdId : bdIdArray ) {
for ( String bdId : bdIdArray ) {
JSONObject bd = managerMapper . findById ( bdId ) ;
JSONObject bd = managerMapper . findById ( bdId ) ;
if ( bd ! = null ) {
if ( bd ! = null ) {
if ( bd . get ( "wx_openid" ) ! = null ) {
if ( bd . get ( "wx_openid" ) ! = null ) {
if ( StringUtils . isNotBlank ( bd . getString ( "wx_openid" ) ) ) {
if ( StringUtils . isNotBlank ( bd . getString ( "wx_openid" ) ) ) {
try {
try {
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
TemplateMessage msg = initSendBDCloseChannelAndPartnerTemplate ( bd . getString ( "wx_openid" ) , paymentApi . getTemplateId ( "risk-forbidden-channelAndPartner" ) , client ) ;
TemplateMessage msg = initSendBDCloseChannelAndPartnerTemplate ( bd . getString ( "wx_openid" ) , paymentApi . getTemplateId ( "risk-forbidden-channelAndPartner" ) , client ) ;
paymentApi . sendTemplateMessage ( msg ) ;
paymentApi . sendTemplateMessage ( msg ) ;
} catch ( WechatException e ) {
} catch ( WechatException e ) {
logger . error ( "Wechat Message Error,风控关闭通道 " + e . getMessage ( ) ) ;
logger . error ( "Wechat Message Error,风控关闭通道 {}", e . getMessage ( ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "风控关闭通道" ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "风控关闭通道" ) ) ;
}
}
}
}
@ -455,14 +489,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
List < JSONObject > accounts = clientAccountMapper . listRiskNoticeAccounts ( client . getIntValue ( "client_id" ) ) ;
List < JSONObject > accounts = clientAccountMapper . listRiskNoticeAccounts ( client . getIntValue ( "client_id" ) ) ;
if ( accounts ! = null ) {
if ( accounts ! = null ) {
for ( JSONObject account : accounts ) {
for ( JSONObject account : accounts ) {
if ( account . get ( "wechat_openid" ) ! = null ) {
if ( account . get ( "wechat_openid" ) ! = null ) {
if ( StringUtils . isNotBlank ( account . getString ( "wechat_openid" ) ) ) {
if ( StringUtils . isNotBlank ( account . getString ( "wechat_openid" ) ) ) {
try {
try {
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
MpWechatApi paymentApi = mpWechatApiProvider . getNewPaymentApi ( ) ;
TemplateMessage msg = initSendPartnerCloseChannelAndPartnerTemplate ( account . getString ( "wechat_openid" ) , paymentApi . getTemplateId ( "risk-forbidden-channelAndPartner" ) , client ) ;
TemplateMessage msg = initSendPartnerCloseChannelAndPartnerTemplate ( account . getString ( "wechat_openid" ) , paymentApi . getTemplateId ( "risk-forbidden-channelAndPartner" ) , client ) ;
paymentApi . sendTemplateMessage ( msg ) ;
paymentApi . sendTemplateMessage ( msg ) ;
} catch ( WechatException e ) {
} catch ( WechatException e ) {
logger . error ( "Wechat Message Error,风控关闭通道 " + e . getMessage ( ) ) ;
logger . error ( "Wechat Message Error,风控关闭通道 ,{}", e . getMessage ( ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "风控关闭通道" ) ) ;
publisher . publishEvent ( new WechatExceptionEvent ( this , e , "风控关闭通道" ) ) ;
}
}
}
}
@ -473,26 +507,27 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
private TemplateMessage initSendBDCloseChannelAndPartnerTemplate ( String wxopenid , String templateId , JSONObject client ) {
private TemplateMessage initSendBDCloseChannelAndPartnerTemplate ( String wxopenid , String templateId , JSONObject client ) {
TemplateMessage msg = new TemplateMessage ( wxopenid , templateId , null ) ;
TemplateMessage msg = new TemplateMessage ( wxopenid , templateId , null ) ;
//1:关闭渠道;2:关闭商户
//1:关闭渠道;2:关闭商户
if ( client . getIntValue ( "result_type" ) = = 1 ) {
if ( client . getIntValue ( "result_type" ) = = 1 ) {
msg . put ( "first" , "您的商户(" + client . getString ( "client_moniker" ) + ")" + client . getString ( "channel" ) + "支付渠道已" + client . getString ( "close_type" ) , "#000000" ) ;
msg . put ( "first" , "您的商户(" + client . getString ( "client_moniker" ) + ")" + client . getString ( "channel" ) + "支付渠道已" + client . getString ( "close_type" ) , "#000000" ) ;
} else {
} else {
msg . put ( "first" , "您的商户(" + client . getString ( "client_moniker" ) + ")已" + client . getString ( "close_type" ) , "#000000" ) ;
msg . put ( "first" , "您的商户(" + client . getString ( "client_moniker" ) + ")已" + client . getString ( "close_type" ) , "#000000" ) ;
}
}
msg . put ( "keyword1" , client . getString ( "channel" ) + "风控调单" , "#0000ff" ) ;
msg . put ( "keyword1" , client . getString ( "channel" ) + "风控调单" , "#0000ff" ) ;
msg . put ( "keyword2" , DateFormatUtils . format ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) , "#000000" ) ;
msg . put ( "keyword2" , DateFormatUtils . format ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) , "#000000" ) ;
msg . put ( "remark" , "请联系商户尽快配合风控部门上传相应资料,以免影响支付" , "#0000FF" ) ;
msg . put ( "remark" , "请联系商户尽快配合风控部门上传相应资料,以免影响支付" , "#0000FF" ) ;
return msg ;
return msg ;
}
}
private TemplateMessage initSendPartnerCloseChannelAndPartnerTemplate ( String wxopenid , String templateId , JSONObject client ) {
TemplateMessage msg = new TemplateMessage ( wxopenid , templateId , null ) ;
private TemplateMessage initSendPartnerCloseChannelAndPartnerTemplate ( String wxopenid , String templateId , JSONObject client ) {
TemplateMessage msg = new TemplateMessage ( wxopenid , templateId , null ) ;
//1:关闭渠道;2:关闭商户
//1:关闭渠道;2:关闭商户
if ( client . getIntValue ( "result_type" ) = = 1 ) {
if ( client . getIntValue ( "result_type" ) = = 1 ) {
msg . put ( "first" , "您的商户" + client . getString ( "channel" ) + "支付渠道已" + client . getString ( "close_type" ) , "#000000" ) ;
msg . put ( "first" , "您的商户" + client . getString ( "channel" ) + "支付渠道已" + client . getString ( "close_type" ) , "#000000" ) ;
} else {
} else {
msg . put ( "first" , "您的商户(" + client . getString ( "client_moniker" ) + ")已" + client . getString ( "close_type" ) , "#000000" ) ;
msg . put ( "first" , "您的商户(" + client . getString ( "client_moniker" ) + ")已" + client . getString ( "close_type" ) , "#000000" ) ;
}
}
msg . put ( "keyword1" , client . getString ( "channel" ) + "风控调单" , "#0000ff" ) ;
msg . put ( "keyword1" , client . getString ( "channel" ) + "风控调单" , "#0000ff" ) ;
msg . put ( "keyword2" , DateFormatUtils . format ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) , "#000000" ) ;
msg . put ( "keyword2" , DateFormatUtils . format ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" ) , "#000000" ) ;
@ -507,6 +542,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* 下 载 审 核 材 料
* 下 载 审 核 材 料
*
* @param riskId
* @param riskId
* @param response
* @param response
* /
* /
@ -524,11 +560,11 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
response . setContentType ( "application/octet-stream" ) ;
response . setContentType ( "application/octet-stream" ) ;
response . setHeader ( "Content-Disposition" , "attachment;filename=" + downloadFilename ) ;
response . setHeader ( "Content-Disposition" , "attachment;filename=" + downloadFilename ) ;
ZipOutputStream zos = new ZipOutputStream ( response . getOutputStream ( ) ) ;
ZipOutputStream zos = new ZipOutputStream ( response . getOutputStream ( ) ) ;
for ( int i = 1 ; i < = 6 ; i + + ) {
for ( int i = 1 ; i < = 6 ; i + + ) {
if ( riskMaterial . containsKey ( "file" + i ) ) {
if ( riskMaterial . containsKey ( "file" + i ) ) {
List < String > fileList = ( List < String > ) riskMaterial . get ( "file" + i ) ;
List < String > fileList = ( List < String > ) riskMaterial . get ( "file" + i ) ;
for ( String fileUrl : fileList ) {
for ( String fileUrl : fileList ) {
zos . putNextEntry ( new ZipEntry ( "file" + i + fileUrl . substring ( fileUrl . lastIndexOf ( "/" ) ) ) ) ;
zos . putNextEntry ( new ZipEntry ( "file" + i + fileUrl . substring ( fileUrl . lastIndexOf ( "/" ) ) ) ) ;
InputStream inputStream = new URL ( fileUrl ) . openConnection ( ) . getInputStream ( ) ;
InputStream inputStream = new URL ( fileUrl ) . openConnection ( ) . getInputStream ( ) ;
byte [ ] buffer = new byte [ 1024 ] ;
byte [ ] buffer = new byte [ 1024 ] ;
int result = 0 ;
int result = 0 ;
@ -551,6 +587,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 更 新 事 件 信 息
* 更 新 事 件 信 息
* 记 录 风 控 日 志
* 记 录 风 控 日 志
* App 推 送 消 息
* App 推 送 消 息
*
* @param riskId
* @param riskId
* @throws IOException
* @throws IOException
* /
* /
@ -558,22 +595,22 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
public void sendUploadEmail ( String riskId ) throws IOException {
public void sendUploadEmail ( String riskId ) throws IOException {
JSONObject event = getRiskEventDetail ( riskId ) ;
JSONObject event = getRiskEventDetail ( riskId ) ;
Context ctx = getMailContext ( event ) ;
Context ctx = getMailContext ( event ) ;
final List < String > emailsTos = ( List < String > ) ctx . getVariable ( "emailsTos" ) ;
final List < String > emailsTos = ( List < String > ) ctx . getVariable ( "emailsTos" ) ;
final List < String > emailsCcs = ctx . getVariable ( "emailsCcs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsCcs" ) ;
final List < String > emailsCcs = ctx . getVariable ( "emailsCcs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsCcs" ) ;
final List < String > emailsBccs = ctx . getVariable ( "emailsBccs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsBccs" ) ;
final List < String > emailsBccs = ctx . getVariable ( "emailsBccs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsBccs" ) ;
final String title = ( String ) ctx . getVariable ( "title" ) ;
final String title = ( String ) ctx . getVariable ( "title" ) ;
final String content = thymeleaf . process ( "mail/risk_upload_mail.html" , ctx ) ;
final String content = thymeleaf . process ( "mail/risk_upload_mail.html" , ctx ) ;
final String uploadUrl = ( String ) ctx . getVariable ( "uploadUrl" ) ;
final String uploadUrl = ( String ) ctx . getVariable ( "uploadUrl" ) ;
royalThreadPoolExecutor . execute ( ( ) - > {
royalThreadPoolExecutor . execute ( ( ) - > {
try {
try {
String emailId = mailService . sendRiskEmail ( title ,
String emailId = mailService . sendRiskEmail ( title ,
emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) ,
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) ,
emailsBccs . isEmpty ( ) ? "" : StringUtils . join ( emailsBccs , "," ) ,
emailsBccs . isEmpty ( ) ? "" : StringUtils . join ( emailsBccs , "," ) ,
content , null , event . getIntValue ( "order_type" ) ) ;
content , null , event . getIntValue ( "order_type" ) ) ;
event . put ( "email_status" , RiskEmailStatusEnum . ALREADY_SEND . getEmailStatus ( ) ) ;
event . put ( "email_status" , RiskEmailStatusEnum . ALREADY_SEND . getEmailStatus ( ) ) ;
event . put ( "result_type" , RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) ) ;
event . put ( "result_type" , RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) ) ;
event . put ( "submit_url" , uploadUrl ) ;
event . put ( "submit_url" , uploadUrl ) ;
Integer orderType = event . getInteger ( "order_type" ) ;
Integer orderType = event . getInteger ( "order_type" ) ;
if ( orderType . equals ( RiskOrderTypeEnum . WARNING_ORDER . getOrderType ( ) ) ) {
if ( orderType . equals ( RiskOrderTypeEnum . WARNING_ORDER . getOrderType ( ) ) ) {
event . put ( "result_type" , RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
event . put ( "result_type" , RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
@ -585,7 +622,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
RiskResultTypeEnum . SEND_EMAIL_TO_BD . getRemark ( ) ,
RiskResultTypeEnum . SEND_EMAIL_TO_BD . getRemark ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ,
RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) ) ;
RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) ) ;
if ( event . getIntValue ( "is_send_client" ) = = 1 ) {
if ( event . getIntValue ( "is_send_client" ) = = 1 ) {
sendAppRiskMessage ( event ) ;
sendAppRiskMessage ( event ) ;
}
}
} catch ( Exception e ) {
} catch ( Exception e ) {
@ -597,11 +634,12 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* App 推 送 消 息
* App 推 送 消 息
* 推 送 类 型 risk
* 推 送 类 型 risk
*
* @param event
* @param event
* /
* /
private void sendAppRiskMessage ( JSONObject event ) {
private void sendAppRiskMessage ( JSONObject event ) {
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- {}-risk_id:{}", client . getString ( "client_moniker" ) , 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 ( JSONObject devToken : tokens ) {
for ( JSONObject devToken : tokens ) {
Runnable task = ( ) - > {
Runnable task = ( ) - > {
@ -634,7 +672,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
log . put ( "status" , 2 ) ;
log . put ( "status" , 2 ) ;
appMessageLogMapper . update ( log ) ;
appMessageLogMapper . update ( log ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
logger . error ( "出错了: " + e . getMessage ( ) ) ;
logger . error ( "出错了: {}", e . getMessage ( ) ) ;
appMessageLogMapper . updateStatus ( log . getString ( "send_id" ) , 1 , e . getMessage ( ) ) ;
appMessageLogMapper . updateStatus ( log . getString ( "send_id" ) , 1 , e . getMessage ( ) ) ;
throw new ServerErrorException ( "Send App " + devToken . getString ( "client_type" ) + " Failed" + ",token" + token , e ) ;
throw new ServerErrorException ( "Send App " + devToken . getString ( "client_type" ) + " Failed" + ",token" + token , e ) ;
}
}
@ -645,6 +683,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* 记 录 消 息 推 送 日 志
* 记 录 消 息 推 送 日 志
*
* @param dev_id
* @param dev_id
* @param client_id
* @param client_id
* @param messageType
* @param messageType
@ -670,6 +709,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 判 断 当 前 事 件 处 理 状 态 是 否 合 理
* 判 断 当 前 事 件 处 理 状 态 是 否 合 理
* 更 新 事 件
* 更 新 事 件
* 记 录 风 控 日 志
* 记 录 风 控 日 志
*
* @param riskId
* @param riskId
* @param refuseDescription 拒 绝 说 明
* @param refuseDescription 拒 绝 说 明
* @throws IOException
* @throws IOException
@ -683,29 +723,29 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
throw new BadRequestException ( "Refused Already!" ) ;
throw new BadRequestException ( "Refused Already!" ) ;
} else if ( RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getResultType ( ) . intValue ( ) = = resultType ) {
} else if ( RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getResultType ( ) . intValue ( ) = = resultType ) {
throw new BadRequestException ( "Passed Already!" ) ;
throw new BadRequestException ( "Passed Already!" ) ;
} else if ( RiskResultTypeEnum . WAIT_FOR_AUDIT . getResultType ( ) . intValue ( ) ! = resultType ) {
} else if ( RiskResultTypeEnum . WAIT_FOR_AUDIT . getResultType ( ) . intValue ( ) ! = resultType ) {
throw new BadRequestException ( ) ;
throw new BadRequestException ( ) ;
}
}
riskMaterialService . updateRiskMaterial ( riskId , refuseDescription ) ;
riskMaterialService . updateRiskMaterial ( riskId , refuseDescription ) ;
Context ctx = getMailContext ( event ) ;
Context ctx = getMailContext ( event ) ;
ctx . setVariable ( "refuse" , true ) ;
ctx . setVariable ( "refuse" , true ) ;
List < JSONObject > findAllMaterials = riskMaterialMapper . findAllMaterials ( riskId ) ;
List < JSONObject > findAllMaterials = riskMaterialMapper . findAllMaterials ( riskId ) ;
if ( findAllMaterials = = null | | findAllMaterials . size( ) = = 0 ) {
if ( findAllMaterials = = null | | findAllMaterials . isEmpty( ) ) {
ctx . setVariable ( "refuse_description" , "" ) ;
ctx . setVariable ( "refuse_description" , "" ) ;
} else {
} else {
ctx . setVariable ( "refuse_description" , findAllMaterials . get ( 0 ) . getString ( "refuse_description" ) ) ;
ctx . setVariable ( "refuse_description" , findAllMaterials . get ( 0 ) . getString ( "refuse_description" ) ) ;
}
}
final List < String > emailsTos = ( List < String > ) ctx . getVariable ( "emailsTos" ) ;
final List < String > emailsTos = ( List < String > ) ctx . getVariable ( "emailsTos" ) ;
final List < String > emailsCcs = ctx . getVariable ( "emailsCcs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsCcs" ) ;
final List < String > emailsCcs = ctx . getVariable ( "emailsCcs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsCcs" ) ;
final String uploadUrl = ( String ) ctx . getVariable ( "uploadUrl" ) ;
final String uploadUrl = ( String ) ctx . getVariable ( "uploadUrl" ) ;
final String content = thymeleaf . process ( "mail/risk_upload_mail.html" , ctx ) ;
final String content = thymeleaf . process ( "mail/risk_upload_mail.html" , ctx ) ;
royalThreadPoolExecutor . execute ( ( ) - > {
royalThreadPoolExecutor . execute ( ( ) - > {
try {
try {
String emailId = mailService . sendRiskEmail ( "You need to resubmit risk materials" , emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
String emailId = mailService . sendRiskEmail ( "You need to resubmit risk materials" , emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) , "" , content , null , event . getIntValue ( "order_type" ) ) ;
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) , "" , content , null , event . getIntValue ( "order_type" ) ) ;
event . put ( "email_status" , RiskEmailStatusEnum . BACK_AND_SEND . getEmailStatus ( ) ) ;
event . put ( "email_status" , RiskEmailStatusEnum . BACK_AND_SEND . getEmailStatus ( ) ) ;
event . put ( "result_type" , RiskResultTypeEnum . MATERIAL_NOT_PASS . getResultType ( ) ) ;
event . put ( "result_type" , RiskResultTypeEnum . MATERIAL_NOT_PASS . getResultType ( ) ) ;
event . put ( "submit_url" , uploadUrl ) ;
event . put ( "submit_url" , uploadUrl ) ;
riskEventMapper . update ( event ) ;
riskEventMapper . update ( event ) ;
riskProcessLogService . addRiskProcessLog ( riskId ,
riskProcessLogService . addRiskProcessLog ( riskId ,
event . getString ( "fillin_id" ) ,
event . getString ( "fillin_id" ) ,
@ -721,6 +761,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* 发 送 催 促 邮 件
* 发 送 催 促 邮 件
*
* @param riskId
* @param riskId
* @throws IOException
* @throws IOException
* /
* /
@ -728,14 +769,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
public void sendUrgeEmail ( String riskId ) throws IOException {
public void sendUrgeEmail ( String riskId ) throws IOException {
JSONObject event = getRiskEventDetail ( riskId ) ;
JSONObject event = getRiskEventDetail ( riskId ) ;
Context ctx = getMailContext ( event ) ;
Context ctx = getMailContext ( event ) ;
final List < String > emailsTos = ( List < String > ) ctx . getVariable ( "emailsTos" ) ;
final List < String > emailsTos = ( List < String > ) ctx . getVariable ( "emailsTos" ) ;
final List < String > emailsCcs = ctx . getVariable ( "emailsCcs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsCcs" ) ;
final List < String > emailsCcs = ctx . getVariable ( "emailsCcs" ) = = null ? new ArrayList < > ( ) : ( List < String > ) ctx . getVariable ( "emailsCcs" ) ;
final String content = thymeleaf . process ( "mail/risk_urge_mail.html" , ctx ) ;
final String content = thymeleaf . process ( "mail/risk_urge_mail.html" , ctx ) ;
royalThreadPoolExecutor . execute ( ( ) - > {
royalThreadPoolExecutor . execute ( ( ) - > {
try {
try {
String emailId = mailService . sendRiskEmail ( "Please submit risk materials as soon as possible" , emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
String emailId = mailService . sendRiskEmail ( "Please submit risk materials as soon as possible" , emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) , "" , content , null , event . getIntValue ( "order_type" ) ) ;
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) , "" , content , null , event . getIntValue ( "order_type" ) ) ;
event . put ( "email_status" , 3 ) ;
event . put ( "email_status" , 3 ) ;
riskEventMapper . update ( event ) ;
riskEventMapper . update ( event ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
throw new EmailException ( "Email Sending Failed" , e ) ;
throw new EmailException ( "Email Sending Failed" , e ) ;
@ -750,20 +791,14 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
throw new InvalidShortIdException ( ) ;
throw new InvalidShortIdException ( ) ;
}
}
String codeKey = RandomStringUtils . random ( 20 , true , true ) ;
String codeKey = RandomStringUtils . random ( 20 , true , true ) ;
while ( stringRedisTemplate . boundValueOps ( getRiskUploadKey ( codeKey ) ) . get ( ) ! = null ) {
while ( stringRedisTemplate . boundValueOps ( getRiskUploadKey ( codeKey ) ) . get ( ) ! = null ) {
codeKey = RandomStringUtils . random ( 20 , true , true ) ;
codeKey = RandomStringUtils . random ( 20 , true , true ) ;
}
}
String codeKeyValue = RandomStringUtils . random ( 10 , true , true ) ;
String codeKeyValue = RandomStringUtils . random ( 10 , true , true ) ;
/ *
String expireDay = "7" ;
if ( event . getIntValue ( "order_type" ) > 2 ) {
expireDay = "3" ;
}
) * /
// 原来设定的过期时间是7天
// 原来设定的过期时间是7天
String expireDay = "3650" ;
String expireDay = "3650" ;
stringRedisTemplate . boundValueOps ( getRiskUploadKey ( codeKey ) ) . set ( codeKeyValue , Long . parseLong ( expireDay ) , TimeUnit . DAYS ) ;
stringRedisTemplate . boundValueOps ( getRiskUploadKey ( codeKey ) ) . set ( codeKeyValue , Long . parseLong ( expireDay ) , TimeUnit . DAYS ) ;
String uploadUrl = PlatformEnvironment . getEnv ( ) . concatUrl ( "/risk/upload/" ) + event . getString ( "risk_id" ) + "/" + codeKey ;
String uploadUrl = PlatformEnvironment . getEnv ( ) . concatUrl ( "/risk/upload/" ) + event . getString ( "risk_id" ) + "/" + codeKey ;
int orderType = event . getIntValue ( "order_type" ) ;
int orderType = event . getIntValue ( "order_type" ) ;
if ( orderType = = 1 | | orderType = = 2 )
if ( orderType = = 1 | | orderType = = 2 )
uploadUrl = PlatformEnvironment . getEnv ( ) . concatUrl ( "/manage.html#/analysis/monitoring/" ) + event . getString ( "risk_id" ) + "/bd/detail?codeKey=" + codeKey ;
uploadUrl = PlatformEnvironment . getEnv ( ) . concatUrl ( "/manage.html#/analysis/monitoring/" ) + event . getString ( "risk_id" ) + "/bd/detail?codeKey=" + codeKey ;
@ -782,10 +817,10 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
List < String > clientEmails = new ArrayList < > ( ) ;
List < String > clientEmails = new ArrayList < > ( ) ;
clientEmails . add ( client . getString ( "contact_email" ) ) ;
clientEmails . add ( client . getString ( "contact_email" ) ) ;
client . put ( "is_resend" , new Date ( ) . compareTo ( event . getDate ( "reply_email_date" ) ) ) ;
client . put ( "is_resend" , new Date ( ) . compareTo ( event . getDate ( "reply_email_date" ) ) ) ;
String bdNamesStr = bdNames . isEmpty ( ) ? "" : StringUtils . join ( bdNames , "," ) ;
String bdNamesStr = bdNames . isEmpty ( ) ? "" : StringUtils . join ( bdNames , "," ) ;
String reply_date = DateFormatUtils . format ( DateUtils . addDays ( event . getDate ( "reply_email_date" ) , - 1 ) , "yyyy年MM月dd日" ) ;
String reply_date = DateFormatUtils . format ( DateUtils . addDays ( event . getDate ( "reply_email_date" ) , - 1 ) , "yyyy年MM月dd日" ) ;
String reply_date_english = DateFormatUtils . format ( DateUtils . addDays ( event . getDate ( "reply_email_date" ) , - 1 ) , "dd/MM/yyyy" ) ;
String reply_date_english = DateFormatUtils . format ( DateUtils . addDays ( event . getDate ( "reply_email_date" ) , - 1 ) , "dd/MM/yyyy" ) ;
GregorianCalendar gregorianCalendar = new GregorianCalendar ( ) ;
GregorianCalendar gregorianCalendar = new GregorianCalendar ( ) ;
String hello = gregorianCalendar . get ( GregorianCalendar . AM_PM ) = = 0 ? "上午好" : "下午好" ;
String hello = gregorianCalendar . get ( GregorianCalendar . AM_PM ) = = 0 ? "上午好" : "下午好" ;
Context ctx = new Context ( ) ;
Context ctx = new Context ( ) ;
@ -799,9 +834,9 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
ctx . setVariable ( "royalpay_order_type" , event . getIntValue ( "royalpay_order_type" ) ) ;
ctx . setVariable ( "royalpay_order_type" , event . getIntValue ( "royalpay_order_type" ) ) ;
ctx . setVariable ( "warning_order_type" , event . getIntValue ( "warning_order_type" ) ) ;
ctx . setVariable ( "warning_order_type" , event . getIntValue ( "warning_order_type" ) ) ;
ctx . setVariable ( "description" , event . getString ( "description" ) ) ;
ctx . setVariable ( "description" , event . getString ( "description" ) ) ;
ctx . setVariable ( "is_send_client" , event . getIntValue ( "is_send_client" ) ) ;
ctx . setVariable ( "is_send_client" , event . getIntValue ( "is_send_client" ) ) ;
ctx . setVariable ( "mail_template" , event . get ( "mail_template" ) = = null ? 0 : event . getIntValue ( "mail_template" ) ) ;
ctx . setVariable ( "mail_template" , event . get ( "mail_template" ) = = null ? 0 : event . getIntValue ( "mail_template" ) ) ;
ctx . setVariable ( "send_clean_days" , event . getIntValue ( "send_clean_days" ) ) ;
ctx . setVariable ( "send_clean_days" , event . getIntValue ( "send_clean_days" ) ) ;
String realOrderIdsStr = event . getString ( "real_order_ids" ) ;
String realOrderIdsStr = event . getString ( "real_order_ids" ) ;
String [ ] realOrderIds = { } ;
String [ ] realOrderIds = { } ;
if ( StringUtils . isNotBlank ( realOrderIdsStr ) ) {
if ( StringUtils . isNotBlank ( realOrderIdsStr ) ) {
@ -857,24 +892,24 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
}
}
switch ( event . getIntValue ( "order_type" ) ) {
switch ( event . getIntValue ( "order_type" ) ) {
case 1 :
case 1 :
case 2 :
case 2 :
for ( String orderId : realOrderIds ) {
for ( String orderId : realOrderIds ) {
JSONObject order = orderMapper . findOrderById ( orderId , client . getIntValue ( "client_id" ) ) ;
JSONObject order = orderMapper . findOrderById ( orderId , client . getIntValue ( "client_id" ) ) ;
if ( order = = null ) {
if ( order = = null ) {
throw new BadRequestException ( "Order: " + orderId + " not exists" ) ;
throw new BadRequestException ( "Order: " + orderId + " not exists" ) ;
}
}
orders . add ( order ) ;
orders . add ( order ) ;
}
}
ctx . setVariable ( "orders" , orders ) ;
ctx . setVariable ( "orders" , orders ) ;
ctx . setVariable ( "title" , "Your merchants needs to submit risk materials" ) ;
ctx . setVariable ( "title" , "Your merchants needs to submit risk materials" ) ;
break ;
break ;
case 3 :
case 3 :
for ( String orderId : realOrderIds ) {
for ( String orderId : realOrderIds ) {
JSONObject order = tradeLogService . getOrderDetail ( new JSONObject ( ) , clientMoniker , orderId , null ) ;
JSONObject order = tradeLogService . getOrderDetail ( new JSONObject ( ) , clientMoniker , orderId , null ) ;
if ( order = = null ) {
if ( order = = null ) {
throw new BadRequestException ( "Order: " + orderId + " not exists" ) ;
throw new BadRequestException ( "Order: " + orderId + " not exists" ) ;
}
}
order . put ( "order_description" , StringUtils . defaultString ( order . getString ( "order_description" ) ) ) ;
order . put ( "order_description" , StringUtils . defaultString ( order . getString ( "order_description" ) ) ) ;
order . put ( "gateway" , getGateWay ( order . getIntValue ( "gateway" ) ) ) ;
order . put ( "gateway" , getGateWay ( order . getIntValue ( "gateway" ) ) ) ;
@ -883,45 +918,41 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
order . put ( "total_amount" , order . getString ( "currency" ) + " " + order . getString ( "total_amount" ) ) ;
order . put ( "total_amount" , order . getString ( "currency" ) + " " + order . getString ( "total_amount" ) ) ;
order . put ( "display_amount" , order . getString ( "currency" ) + " " + order . getString ( "display_amount" ) ) ;
order . put ( "display_amount" , order . getString ( "currency" ) + " " + order . getString ( "display_amount" ) ) ;
order . put ( "customer_payment_amount" , order . getString ( "currency" ) + " " + order . getString ( "customer_payment_amount" ) ) ;
order . put ( "customer_payment_amount" , order . getString ( "currency" ) + " " + order . getString ( "customer_payment_amount" ) ) ;
order . put ( "clearing_amount" , "AUD " + order . getString ( "clearing_amount" ) ) ;
order . put ( "clearing_amount" , "AUD " + order . getString ( "clearing_amount" ) ) ;
orders . add ( order ) ;
orders . add ( order ) ;
}
}
ctx . setVariable ( "orders" , orders ) ;
ctx . setVariable ( "orders" , orders ) ;
// List<JSONObject> attachList = new ArrayList<>();
// JSONObject file = new JSONObject();
// file.put("name", client.getString("short_name")+ "被查单号相关信息.xlsx");
// file.put("content", Base64.encodeBase64String(generateRiskOrders(event)));
// attachList.add(file);
// ctx.setVariable("files",attachList);
case 4 :
case 4 :
ctx . setVariable ( "title" , "RoyalPay风控调查 — " + client . getString ( "short_name" ) ) ;
ctx . setVariable ( "title" , "RoyalPay风控调查 — " + client . getString ( "short_name" ) ) ;
break ;
break ;
}
}
return ctx ;
return ctx ;
}
}
private String getRiskUploadKey ( String codeKey ) {
private String getRiskUploadKey ( String codeKey ) {
return UPLOAD_MAIL_PREFIX + codeKey ;
return UPLOAD_MAIL_PREFIX + codeKey ;
}
}
/ * *
/ * *
* 获 取 风 控 事 件 上 传 的 材 料
* 获 取 风 控 事 件 上 传 的 材 料
*
* @param param
* @param param
* @return
* @return
* /
* /
@Override
@Override
public JSONObject getRiskMaterial ( JSONObject param ) {
public JSONObject getRiskMaterial ( JSONObject param ) {
List < JSONObject > riskMaterialList = riskMaterialMapper . findAllMaterials ( param . getString ( "risk_id" ) ) ;
List < JSONObject > riskMaterialList = riskMaterialMapper . findAllMaterials ( param . getString ( "risk_id" ) ) ;
if ( riskMaterialList ! = null & & riskMaterialList . size ( ) > 0 ) {
if ( riskMaterialList ! = null & & ! riskMaterialList . isEmpty ( ) ) {
JSONObject fileNew = riskMaterialList . get ( 0 ) ;
JSONObject fileNew = riskMaterialList . get ( 0 ) ;
List < JSONObject > files = riskFileMapper . findAllFiles ( fileNew . getString ( "material_id" ) ) ;
List < JSONObject > files = riskFileMapper . findAllFiles ( fileNew . getString ( "material_id" ) ) ;
for ( JSONObject file : files ) {
for ( JSONObject file : files ) {
int fileType = file . getIntValue ( "file_type" ) ;
int fileType = file . getIntValue ( "file_type" ) ;
if ( ! fileNew . containsKey ( "file" + fileType ) ) {
if ( ! fileNew . containsKey ( "file" + fileType ) ) {
List < String > fileList = new ArrayList < > ( ) ;
List < String > fileList = new ArrayList < > ( ) ;
fileList . add ( file . getString ( "file_url" ) ) ;
fileList . add ( file . getString ( "file_url" ) ) ;
fileNew . put ( "file" + fileType , fileList ) ;
fileNew . put ( "file" + fileType , fileList ) ;
} else {
} else {
List < String > fileList = ( List < String > ) fileNew . get ( "file" + fileType ) ;
List < String > fileList = ( List < String > ) fileNew . get ( "file" + fileType ) ;
fileList . add ( file . getString ( "file_url" ) ) ;
fileList . add ( file . getString ( "file_url" ) ) ;
fileNew . put ( "file" + fileType , fileList ) ;
fileNew . put ( "file" + fileType , fileList ) ;
}
}
@ -942,7 +973,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
@Transactional
@Transactional
public void completeEventRealOrderIds ( ) {
public void completeEventRealOrderIds ( ) {
List < JSONObject > riskEventList = getRiskEvents ( null ) ;
List < JSONObject > riskEventList = getRiskEvents ( null ) ;
if ( riskEventList ! = null & & riskEventList . size ( ) > 0 ) {
if ( riskEventList ! = null & & ! riskEventList . isEmpty ( ) ) {
for ( JSONObject riskEvent : riskEventList ) {
for ( JSONObject riskEvent : riskEventList ) {
String clientMoniker = riskEvent . getString ( "client_moniker" ) ;
String clientMoniker = riskEvent . getString ( "client_moniker" ) ;
JSONObject client = clientMapper . findClientByMonikerAll ( clientMoniker ) ;
JSONObject client = clientMapper . findClientByMonikerAll ( clientMoniker ) ;
@ -958,7 +989,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
client . getIntValue ( "client_id" ) ,
client . getIntValue ( "client_id" ) ,
systemTransactionIdArr [ i ] ,
systemTransactionIdArr [ i ] ,
new PageBounds ( Order . formString ( "transaction_time.desc" ) ) ) ;
new PageBounds ( Order . formString ( "transaction_time.desc" ) ) ) ;
if ( transactionList ! = null & & transactionList . size ( ) > 0 )
if ( transactionList ! = null & & ! transactionList . isEmpty ( ) )
realOrderIds . add ( transactionList . get ( 0 ) . getString ( "order_id" ) ) ;
realOrderIds . add ( transactionList . get ( 0 ) . getString ( "order_id" ) ) ;
}
}
riskEvent . put ( "real_order_ids" , StringUtils . join ( realOrderIds , "," ) ) ;
riskEvent . put ( "real_order_ids" , StringUtils . join ( realOrderIds , "," ) ) ;
@ -973,7 +1004,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
String [ ] orderIds = event . getString ( "order_ids" ) . split ( "," ) ;
String [ ] orderIds = event . getString ( "order_ids" ) . split ( "," ) ;
JSONObject client = clientMapper . findClientByMonikerAll ( event . getString ( "client_moniker" ) ) ;
JSONObject client = clientMapper . findClientByMonikerAll ( event . getString ( "client_moniker" ) ) ;
Workbook wb = new XSSFWorkbook ( ) ;
Workbook wb = new XSSFWorkbook ( ) ;
for ( String orderId : orderIds ) {
for ( String orderId : orderIds ) {
JSONObject orderDetail = tradeLogService . getOrderDetail ( new JSONObject ( ) , event . getString ( "client_moniker" ) , orderId , null ) ;
JSONObject orderDetail = tradeLogService . getOrderDetail ( new JSONObject ( ) , event . getString ( "client_moniker" ) , orderId , null ) ;
Sheet sheet = wb . createSheet ( orderId ) ;
Sheet sheet = wb . createSheet ( orderId ) ;
sheet . setDefaultColumnWidth ( ( short ) 40 ) ;
sheet . setDefaultColumnWidth ( ( short ) 40 ) ;
@ -993,45 +1024,46 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
Row row13 = sheet . createRow ( 13 ) ;
Row row13 = sheet . createRow ( 13 ) ;
Row row14 = sheet . createRow ( 14 ) ;
Row row14 = sheet . createRow ( 14 ) ;
Row row15 = sheet . createRow ( 15 ) ;
Row row15 = sheet . createRow ( 15 ) ;
row0 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Partner" ) ;
row0 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Partner" ) ;
row0 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getJSONObject ( "client" ) . getString ( "short_name" ) + "(" + orderDetail . getJSONObject ( "client" ) . getString ( "client_moniker" ) + ")" ) ;
row0 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getJSONObject ( "client" ) . getString ( "short_name" ) + "(" + orderDetail . getJSONObject ( "client" ) . getString ( "client_moniker" ) + ")" ) ;
row1 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Order ID" ) ;
row1 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Order ID" ) ;
row1 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "order_id" ) ) ;
row1 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "order_id" ) ) ;
row2 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Platform Transaction ID" ) ;
row2 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Platform Transaction ID" ) ;
row2 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "system_transaction_id" ) ) ;
row2 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "system_transaction_id" ) ) ;
row3 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Order Description" ) ;
row3 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Order Description" ) ;
row3 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( StringUtils . defaultString ( orderDetail . getString ( "order_description" ) ) ) ;
row3 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( StringUtils . defaultString ( orderDetail . getString ( "order_description" ) ) ) ;
row4 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Customer ID" ) ;
row4 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Customer ID" ) ;
row4 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "customer_id" ) ) ;
row4 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "customer_id" ) ) ;
row5 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "IP" ) ;
row5 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "IP" ) ;
row5 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "customer_ip" ) ) ;
row5 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "customer_ip" ) ) ;
row6 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Total Amount" ) ;
row6 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Total Amount" ) ;
row6 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "currency" ) + " " + orderDetail . getString ( "total_amount" ) ) ;
row6 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "currency" ) + " " + orderDetail . getString ( "total_amount" ) ) ;
row7 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Input Amount" ) ;
row7 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Input Amount" ) ;
row7 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "currency" ) + " " + orderDetail . getString ( "display_amount" ) ) ;
row7 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "currency" ) + " " + orderDetail . getString ( "display_amount" ) ) ;
row8 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Pay Amount" ) ;
row8 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Pay Amount" ) ;
row8 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "currency" ) + " " + orderDetail . getString ( "customer_payment_amount" ) ) ;
row8 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "currency" ) + " " + orderDetail . getString ( "customer_payment_amount" ) ) ;
row9 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Exchange Rate" ) ;
row9 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Exchange Rate" ) ;
row9 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "exchange_rate" ) ) ;
row9 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "exchange_rate" ) ) ;
row10 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Clearing Amount" ) ;
row10 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Clearing Amount" ) ;
row10 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( "AUD " + orderDetail . getString ( "clearing_amount" ) ) ;
row10 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( "AUD " + orderDetail . getString ( "clearing_amount" ) ) ;
row11 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Gateway" ) ;
row11 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Gateway" ) ;
row11 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( getGateWay ( orderDetail . getIntValue ( "gateway" ) ) ) ;
row11 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( getGateWay ( orderDetail . getIntValue ( "gateway" ) ) ) ;
row12 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Create Time" ) ;
row12 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Create Time" ) ;
row12 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "create_time" ) ) ;
row12 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "create_time" ) ) ;
row13 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Status" ) ;
row13 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Status" ) ;
row13 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( getStatus ( orderDetail . getIntValue ( "status" ) ) ) ;
row13 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( getStatus ( orderDetail . getIntValue ( "status" ) ) ) ;
row14 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Pay Time" ) ;
row14 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Pay Time" ) ;
row14 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "transaction_time" ) ) ;
row14 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( orderDetail . getString ( "transaction_time" ) ) ;
row15 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Order Detail" ) ;
row15 . createCell ( 0 , Cell . CELL_TYPE_STRING ) . setCellValue ( "Order Detail" ) ;
row15 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( StringUtils . defaultString ( orderDetail . getString ( "order_detail" ) ) ) ;
row15 . createCell ( 1 , Cell . CELL_TYPE_STRING ) . setCellValue ( StringUtils . defaultString ( orderDetail . getString ( "order_detail" ) ) ) ;
}
}
ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ;
ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ;
wb . write ( bos ) ;
wb . write ( bos ) ;
bos . flush ( ) ;
bos . flush ( ) ;
return bos . toByteArray ( ) ;
return bos . toByteArray ( ) ;
}
}
private String getGateWay ( int gateWay ) {
private String getGateWay ( int gateWay ) {
switch ( gateWay ) {
switch ( gateWay ) {
case 0 :
case 0 :
return "线下扫码" ;
return "线下扫码" ;
@ -1067,7 +1099,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
return "" ;
return "" ;
}
}
private String getStatus ( int status ) {
private String getStatus ( int status ) {
switch ( status ) {
switch ( status ) {
case 0 :
case 0 :
return "Creating" ;
return "Creating" ;
@ -1091,6 +1123,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* 检 查 是 否 有 需 要 的 调 单 事 件 待 处 理 , 由 前 端 弹 框 提 醒
* 检 查 是 否 有 需 要 的 调 单 事 件 待 处 理 , 由 前 端 弹 框 提 醒
*
* @param manager
* @param manager
* @param notices
* @param notices
* /
* /
@ -1138,6 +1171,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* 某 个 商 户 是 否 存 在 调 单 事 件
* 某 个 商 户 是 否 存 在 调 单 事 件
*
* @param clientId
* @param clientId
* @return
* @return
* /
* /
@ -1145,7 +1179,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
public JSONObject getNoticeInfo ( int clientId ) {
public JSONObject getNoticeInfo ( int clientId ) {
JSONObject client = clientMapper . findClient ( clientId ) ;
JSONObject client = clientMapper . findClient ( clientId ) ;
if ( client = = null ) {
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
throw new InvalidShortIdException ( ) ;
}
}
JSONObject params = new JSONObject ( ) ;
JSONObject params = new JSONObject ( ) ;
@ -1158,7 +1192,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
JSONObject result = new JSONObject ( ) ;
JSONObject result = new JSONObject ( ) ;
result . put ( "notice_flag" , false ) ;
result . put ( "notice_flag" , false ) ;
if ( riskEventList ! = null & & riskEventList . size ( ) > 0 ) {
if ( riskEventList ! = null & & ! riskEventList . isEmpty ( ) ) {
result . put ( "notice_flag" , true ) ;
result . put ( "notice_flag" , true ) ;
}
}
return result ;
return result ;
@ -1168,6 +1202,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 调 单 事 件 需 要 上 传 的 材 料 说 明
* 调 单 事 件 需 要 上 传 的 材 料 说 明
* 微 信 调 单 与 内 部 调 单 是 固 定 的
* 微 信 调 单 与 内 部 调 单 是 固 定 的
* 支 付 宝 调 单 由 风 控 人 员 录 入
* 支 付 宝 调 单 由 风 控 人 员 录 入
*
* @param riskId
* @param riskId
* @return
* @return
* /
* /
@ -1197,7 +1232,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
String alipayMaterials = riskEvent . getString ( "alipay_materials" ) ;
String alipayMaterials = riskEvent . getString ( "alipay_materials" ) ;
if ( StringUtils . isNotBlank ( alipayMaterials ) ) {
if ( StringUtils . isNotBlank ( alipayMaterials ) ) {
List < JSONObject > alipayMaterialRemarkList = JSONObject . parseArray ( alipayMaterials , JSONObject . class ) ;
List < JSONObject > alipayMaterialRemarkList = JSONObject . parseArray ( alipayMaterials , JSONObject . class ) ;
if ( alipayMaterialRemarkList ! = null & & alipayMaterialRemarkList . size ( ) > 0 ) {
if ( alipayMaterialRemarkList ! = null & & ! alipayMaterialRemarkList . isEmpty ( ) ) {
for ( int i = 0 ; i < alipayMaterialRemarkList . size ( ) ; i + + ) {
for ( int i = 0 ; i < alipayMaterialRemarkList . size ( ) ; i + + ) {
materialsRemark . add ( alipayMaterialRemarkList . get ( i ) . getString ( "question" + ( i + 1 ) ) ) ;
materialsRemark . add ( alipayMaterialRemarkList . get ( i ) . getString ( "question" + ( i + 1 ) ) ) ;
}
}
@ -1230,6 +1265,9 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
case 3 :
case 3 :
materialsRemark = getStudyTemplate ( ) ;
materialsRemark = getStudyTemplate ( ) ;
break ;
break ;
case 4 :
materialsRemark = getChargebackTemplate ( ) ;
break ;
default :
default :
break ;
break ;
}
}
@ -1257,18 +1295,18 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
@Override
@Override
public void banRiskEvent ( String riskId ) {
public void banRiskEvent ( String riskId ) {
JSONObject params = new JSONObject ( ) ;
JSONObject params = new JSONObject ( ) ;
params . put ( "risk_id" , riskId ) ;
params . put ( "risk_id" , riskId ) ;
params . put ( "is_valid" , 0 ) ;
params . put ( "is_valid" , 0 ) ;
riskEventMapper . update ( params ) ;
riskEventMapper . update ( params ) ;
}
}
@Override
@Override
public void commitWaitRiskStatus ( String riskId , String codeKey , JSONObject manager ) {
public void commitWaitRiskStatus ( String riskId , String codeKey , JSONObject manager ) {
JSONObject event = riskEventMapper . findById ( riskId ) ;
JSONObject event = riskEventMapper . findById ( riskId ) ;
if ( event . getIntValue ( "result_type" ) ! = RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) & & event . getIntValue ( "result_type" ) ! = RiskResultTypeEnum . MATERIAL_NOT_PASS . getResultType ( ) ) {
if ( event . getIntValue ( "result_type" ) ! = RiskResultTypeEnum . SEND_EMAIL_TO_BD . getResultType ( ) & & event . getIntValue ( "result_type" ) ! = RiskResultTypeEnum . MATERIAL_NOT_PASS . getResultType ( ) ) {
throw new BadRequestException ( "风控调单不存在或资料已补全" ) ;
throw new BadRequestException ( "风控调单不存在或资料已补全" ) ;
}
}
if ( event . getIntValue ( "result_type" ) ! = RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getResultType ( ) ) {
if ( event . getIntValue ( "result_type" ) ! = RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getResultType ( ) ) {
event . put ( "result_type" , RiskResultTypeEnum . WAIT_FOR_AUDIT . getResultType ( ) ) ;
event . put ( "result_type" , RiskResultTypeEnum . WAIT_FOR_AUDIT . getResultType ( ) ) ;
riskEventMapper . update ( event ) ;
riskEventMapper . update ( event ) ;
}
}
@ -1315,29 +1353,50 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
@Override
@Override
public void completeOrderAmount ( ) {
public void completeOrderAmount ( ) {
List < JSONObject > riskEventList = getRiskEvents ( null ) ;
List < JSONObject > riskEventList = getRiskEvents ( null ) ;
for ( JSONObject riskEvent : riskEventList ) {
for ( JSONObject riskEvent : riskEventList ) {
if ( riskEvent . getIntValue ( "order_type" ) = = 4 | | StringUtils . isBlank ( riskEvent . getString ( "real_order_ids" ) ) ) {
if ( riskEvent . getIntValue ( "order_type" ) = = 4 | | StringUtils . isBlank ( riskEvent . getString ( "real_order_ids" ) ) ) {
continue ;
continue ;
}
}
String [ ] order _ids= riskEvent . getString ( "real_order_ids" ) . split ( "," ) ;
String [ ] order Ids = riskEvent . getString ( "real_order_ids" ) . split ( "," ) ;
for ( String orderId : order _ids) {
for ( String orderId : order Ids) {
JSONObject transaction = transactionMapper . findByOrderId ( orderId ) ;
JSONObject transaction = transactionMapper . findByOrderId ( orderId ) ;
JSONObject riskOrder = new JSONObject ( ) ;
JSONObject riskOrder = new JSONObject ( ) ;
riskOrder . put ( "risk_id" , riskEvent . getString ( "risk_id" ) ) ;
riskOrder . put ( "risk_id" , riskEvent . getString ( "risk_id" ) ) ;
riskOrder . put ( "order_id" , transaction . getString ( "order_id" ) ) ;
riskOrder . put ( "order_id" , transaction . getString ( "order_id" ) ) ;
riskOrder . put ( "clearing_amount" , transaction . getString ( "clearing_amount" ) ) ;
riskOrder . put ( "clearing_amount" , transaction . getString ( "clearing_amount" ) ) ;
riskOrdersMapper . save ( riskOrder ) ;
riskOrdersMapper . save ( riskOrder ) ;
}
}
}
}
}
}
@Override
@Override
public void U pdateRiskEventRemark( String riskId , String remark ) {
public void u pdateRiskEventRemark( String riskId , String remark ) {
JSONObject event = riskEventMapper . findById ( riskId ) ;
JSONObject event = riskEventMapper . findById ( riskId ) ;
event . put ( "remark" , remark ) ;
event . put ( "remark" , remark ) ;
riskEventMapper . update ( event ) ;
riskEventMapper . update ( event ) ;
}
}
@Override
public void markChargebackStatus ( String riskId , JSONObject manager , ChargebackStatus status ) {
RiskEvent risk = getRiskEvent ( riskId ) ;
if ( risk = = null ) {
throw new NotFoundException ( "Risk Event not found" ) ;
}
if ( risk . getOrderType ( ) ! = RISK_ORDER_TYPE_CHARGEBACK ) {
throw new BadRequestException ( "Not Chargeback event" ) ;
}
if ( status = = null | | status = = ChargebackStatus . PROCESSING ) {
throw new BadRequestException ( "Invalid status" ) ;
}
riskProcessLogService . addRiskProcessLog ( riskId ,
manager . getString ( "manager_id" ) ,
manager . getString ( "display_name" ) ,
RiskResultTypeEnum . ALREADY_HANDLED . getRemark ( ) ,
RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ,
RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
cardSecureService . changeChargebackReportStatus ( riskId , status ) ;
}
private List < String > getShopTemplate ( ) {
private List < String > getShopTemplate ( ) {
return Arrays . asList ( "1.与调查交易金额对应的购物小票/发票存根照片 要求:照片应清晰,必须显示商户名称、商户地址、购物时间、物品名称、购物金额等;\n" +
return Arrays . asList ( "1.与调查交易金额对应的购物小票/发票存根照片 要求:照片应清晰,必须显示商户名称、商户地址、购物时间、物品名称、购物金额等;\n" +
"Photos of shopping receipts/ invoice stubs Requirement corresponding with the investigated orders Requirement: The photos should be clear and must show Merchant name, Business address, Transaction time, Product information, Quantity purchased, etc;" ,
"Photos of shopping receipts/ invoice stubs Requirement corresponding with the investigated orders Requirement: The photos should be clear and must show Merchant name, Business address, Transaction time, Product information, Quantity purchased, etc;" ,
@ -1375,4 +1434,19 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
"Other materials including onboarding materials as task description required; Explanation of business model for your merchant including actual selling-goods or services, per customer transaction, business hours, etc;"
"Other materials including onboarding materials as task description required; Explanation of business model for your merchant including actual selling-goods or services, per customer transaction, business hours, etc;"
) ;
) ;
}
}
private List < String > getChargebackTemplate ( ) {
return Arrays . asList ( "1.A legible copy of the signed authority and/or receipts from the Cardholder. \n" +
"持卡人签名授权书和/或收据的清晰副本。" ,
"2.Copy of any tax invoice/s and/or signed disclosure of cancellation policy. \n" +
"任何税务发票和/或签署的披露取消政策的副本。" ,
"3.Any transaction Information relating to the sale of any digital goods purchased online.\n" +
"与在线购买的任何数字商品的销售有关的任何交易信息。" ,
"4.Description of the goods/services supplied and/or proof of delivery/collection of goods.\n" +
"提供的商品/服务的说明和/或交付/收货的证明。(消费者买了什么,商家卖了什么,消费者收没收到货,如何收到的)" ,
"5.Copy of Mail Order/telephone order transaction receipt.\n" +
"邮件订单/电话订单交易收据的副本。" ,
"6.Cardholder identification or any form of communication with the Cardholder, including email correspondence. \n" +
"持卡人身份或与持卡人的任何形式的通信,包括电子邮件通信。" ) ;
}
}
}