@ -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 ) {
@ -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 {
@ -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 ) ;
}
}
}
}
@ -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,6 +385,19 @@ 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 ) {
@ -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 = "临时禁用" ;
}
}
}
}
@ -444,7 +478,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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 , "风控关闭通道" ) ) ;
}
}
}
}
@ -462,7 +496,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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 , "风控关闭通道" ) ) ;
}
}
}
}
@ -486,6 +520,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
msg . put ( "remark" , "请联系商户尽快配合风控部门上传相应资料,以免影响支付" , "#0000FF" ) ;
msg . put ( "remark" , "请联系商户尽快配合风控部门上传相应资料,以免影响支付" , "#0000FF" ) ;
return msg ;
return msg ;
}
}
private TemplateMessage initSendPartnerCloseChannelAndPartnerTemplate ( String wxopenid , String templateId , JSONObject client ) {
private TemplateMessage initSendPartnerCloseChannelAndPartnerTemplate ( String wxopenid , String templateId , JSONObject client ) {
TemplateMessage msg = new TemplateMessage ( wxopenid , templateId , null ) ;
TemplateMessage msg = new TemplateMessage ( wxopenid , templateId , null ) ;
//1:关闭渠道;2:关闭商户
//1:关闭渠道;2:关闭商户
@ -507,6 +542,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* 下 载 审 核 材 料
* 下 载 审 核 材 料
*
* @param riskId
* @param riskId
* @param response
* @param response
* /
* /
@ -551,6 +587,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 更 新 事 件 信 息
* 更 新 事 件 信 息
* 记 录 风 控 日 志
* 记 录 风 控 日 志
* App 推 送 消 息
* App 推 送 消 息
*
* @param riskId
* @param riskId
* @throws IOException
* @throws IOException
* /
* /
@ -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
@ -721,6 +761,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
/ * *
/ * *
* 发 送 催 促 邮 件
* 发 送 催 促 邮 件
*
* @param riskId
* @param riskId
* @throws IOException
* @throws IOException
* /
* /
@ -754,12 +795,6 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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 ) ;
@ -887,24 +922,20 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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
* /
* /
@ -1031,6 +1062,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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 :
@ -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
* /
* /
@ -1168,6 +1202,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
* 调 单 事 件 需 要 上 传 的 材 料 说 明
* 调 单 事 件 需 要 上 传 的 材 料 说 明
* 微 信 调 单 与 内 部 调 单 是 固 定 的
* 微 信 调 单 与 内 部 调 单 是 固 定 的
* 支 付 宝 调 单 由 风 控 人 员 录 入
* 支 付 宝 调 单 由 风 控 人 员 录 入
*
* @param riskId
* @param riskId
* @return
* @return
* /
* /
@ -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 ;
}
}
@ -1319,8 +1357,8 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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" ) ) ;
@ -1332,12 +1370,33 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
@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" +
"持卡人身份或与持卡人的任何形式的通信,包括电子邮件通信。" ) ;
}
}
}