@ -10,6 +10,7 @@ import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskEventMapper ;
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskEventMapper ;
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskFileMapper ;
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskFileMapper ;
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskMaterialMapper ;
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskMaterialMapper ;
import au.com.royalpay.payment.manage.mappers.riskbusiness.RiskOrdersMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper ;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper ;
@ -17,6 +18,8 @@ import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper ;
import au.com.royalpay.payment.manage.pushMessage.APNSMessageHelper ;
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder ;
import au.com.royalpay.payment.manage.pushMessage.bean.AppManagerMessageBuilder ;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService ;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskBusinessService ;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskMaterialService ;
import au.com.royalpay.payment.manage.riskbusiness.core.RiskProcessLogService ;
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.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 ;
@ -95,11 +98,18 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
private RoyalThreadPoolExecutor royalThreadPoolExecutor ;
private RoyalThreadPoolExecutor royalThreadPoolExecutor ;
private final String UPLOAD_MAIL_PREFIX = "UPLOAD_MAIL" ;
private final String UPLOAD_MAIL_PREFIX = "UPLOAD_MAIL" ;
@Resource
private RiskProcessLogService riskProcessLogService ;
@Resource
@Resource
private RiskMaterialMapper riskMaterialMapper ;
private RiskMaterialMapper riskMaterialMapper ;
@Resource
@Resource
private RiskMaterialService riskMaterialService ;
@Resource
private RiskFileMapper riskFileMapper ;
private RiskFileMapper riskFileMapper ;
@Resource
@Resource
private RiskOrdersMapper riskOrdersMapper ;
@Resource
private ClientDeviceTokenMapper clientDeviceTokenMapper ;
private ClientDeviceTokenMapper clientDeviceTokenMapper ;
@Resource
@Resource
private AppMessageLogMapper appMessageLogMapper ;
private AppMessageLogMapper appMessageLogMapper ;
@ -172,6 +182,49 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
return PageListUtils . buildPageListResult ( riskEvents ) ;
return PageListUtils . buildPageListResult ( riskEvents ) ;
}
}
@Override
public List < JSONObject > analysisByIndustry ( JSONObject params , JSONObject manager ) {
List < JSONObject > industryAnalysis = riskEventMapper . analysisByIndustry ( params ) ;
for ( JSONObject industry : industryAnalysis ) {
if ( StringUtils . isBlank ( industry . getString ( "industry" ) ) ) {
industry . put ( "industry" , "未知行业" ) ;
}
}
return industryAnalysis ;
}
private List < String > industryArray ( ) {
List < String > industryArray = new ArrayList < > ( ) ;
industryArray . add ( "鞋包服饰" ) ;
industryArray . add ( "机票行业" ) ;
industryArray . add ( "软件服务" ) ;
industryArray . add ( "旅游票务" ) ;
industryArray . add ( "国际租车" ) ;
industryArray . add ( "医疗服务(出国)" ) ;
industryArray . add ( "医疗服务(不出国)" ) ;
industryArray . add ( "留学教育(网络教育)" ) ;
industryArray . add ( "留学教育(一年及以下)" ) ;
industryArray . add ( "其它货物贸易行业" ) ;
industryArray . add ( "文具/办公用品" ) ;
industryArray . add ( "综合商城" ) ;
industryArray . add ( "酒店行业" ) ;
industryArray . add ( "教育行业" ) ;
industryArray . add ( "国际物流" ) ;
industryArray . add ( "数码电器" ) ;
industryArray . add ( "母婴" ) ;
industryArray . add ( "化妆品" ) ;
industryArray . add ( "食品" ) ;
industryArray . add ( "留学教育(一年以上)" ) ;
industryArray . add ( "其它服务行业" ) ;
industryArray . add ( "未知行业" ) ;
return industryArray ;
}
@Override
public List < JSONObject > analysisByAmount ( JSONObject params , JSONObject manager ) {
return riskEventMapper . analysisByAmount ( params ) ;
}
@Override
@Override
public JSONObject getRiskEventDetail ( String riskId ) {
public JSONObject getRiskEventDetail ( String riskId ) {
@ -259,7 +312,7 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
// 将订单order_id存入数据库方便后面快速查询
// 将订单order_id存入数据库方便后面快速查询
JSONObject orderInfo = transactionList . get ( 0 ) ;
JSONObject orderInfo = transactionList . get ( 0 ) ;
realOrderIdList . add ( orderInfo . getString ( "order_id" ) ) ;
realOrderIdList . add ( orderInfo . getString ( "order_id" ) ) ;
orderAmountList . add ( orderInfo . getString ( " transaction _amount") ) ;
orderAmountList . add ( orderInfo . getString ( " clearing _amount") ) ;
}
}
params . put ( "order_amounts" , StringUtils . join ( orderAmountList , "," ) ) ;
params . put ( "order_amounts" , StringUtils . join ( orderAmountList , "," ) ) ;
params . put ( "real_order_ids" , StringUtils . join ( realOrderIdList , "," ) ) ;
params . put ( "real_order_ids" , StringUtils . join ( realOrderIdList , "," ) ) ;
@ -271,12 +324,37 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
public void addRiskEvent ( JSONObject params , JSONObject manager ) {
public void addRiskEvent ( JSONObject params , JSONObject manager ) {
params = getEvent ( params ) ;
params = getEvent ( params ) ;
riskEventMapper . save ( params ) ;
riskEventMapper . save ( params ) ;
setRiskOrders ( params ) ;
params = riskEventMapper . findAll ( params ) . get ( 0 ) ;
riskProcessLogService . addRiskProcessLog ( params . getString ( "risk_id" ) ,
params . getString ( "fillin_id" ) ,
params . getString ( "fillin_person" ) ,
RiskResultTypeEnum . NOT_HANDLED . getRemark ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ,
RiskResultTypeEnum . NOT_HANDLED . getResultType ( ) ) ;
}
private void setRiskOrders ( JSONObject params ) {
if ( StringUtils . isNotBlank ( params . getString ( "order_ids" ) ) ) {
String riskId = params . getString ( "risk_id" ) ;
String orderIds = params . getString ( "real_order_ids" ) ;
for ( String orderId : orderIds . split ( "," ) ) {
JSONObject order = transactionMapper . findByOrderId ( orderId ) ;
JSONObject riskOrder = new JSONObject ( ) ;
riskOrder . put ( "risk_id" , riskId ) ;
riskOrder . put ( "order_id" , orderId ) ;
riskOrder . put ( "clearing_amount" , order . getString ( "clearing_amount" ) ) ;
riskOrdersMapper . save ( riskOrder ) ;
}
}
}
}
@Override
@Override
public void updateRiskEvent ( JSONObject params ) {
public void updateRiskEvent ( JSONObject params ) {
params = getEvent ( params ) ;
params = getEvent ( params ) ;
riskEventMapper . update ( params ) ;
riskEventMapper . update ( params ) ;
riskOrdersMapper . clearOrders ( params . getString ( "risk_id" ) ) ;
setRiskOrders ( params ) ;
}
}
@Override
@Override
@ -321,13 +399,17 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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 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 , emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
String emailId = mailService . sendRiskEmail ( title ,
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) , "" , content , null , event . getIntValue ( "order_type" ) ) ;
emailsTos . isEmpty ( ) ? "" : StringUtils . join ( emailsTos , "," ) ,
emailsCcs . isEmpty ( ) ? "" : StringUtils . join ( emailsCcs , "," ) ,
emailsBccs . isEmpty ( ) ? "" : StringUtils . join ( emailsBccs , "," ) ,
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 ) ;
@ -336,6 +418,12 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
event . put ( "result_type" , RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
event . put ( "result_type" , RiskResultTypeEnum . ALREADY_HANDLED . getResultType ( ) ) ;
}
}
riskEventMapper . update ( event ) ;
riskEventMapper . update ( event ) ;
riskProcessLogService . addRiskProcessLog ( event . getString ( "risk_id" ) ,
event . getString ( "fillin_id" ) ,
event . getString ( "fillin_person" ) ,
RiskResultTypeEnum . SEND_EMAIL_TO_BD . getRemark ( ) ,
RiskResultTypeEnum . NOT_HANDLED . 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 ) ;
}
}
@ -403,8 +491,11 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
@Override
@Override
public void sendRefuseEmail ( String riskId ) throws IOException {
public void sendRefuseEmail ( String riskId , String refuseDescription ) throws IOException {
JSONObject event = getRiskEventDetail ( riskId ) ;
JSONObject event = getRiskEventDetail ( riskId ) ;
if ( RiskResultTypeEnum . MATERIAL_NOT_PASS . getResultType ( ) . intValue ( ) = = event . getIntValue ( "result_type" ) ) {
throw new BadRequestException ( "Refused Already!" ) ;
}
Context ctx = getMailContext ( event ) ;
Context ctx = getMailContext ( event ) ;
ctx . setVariable ( "refuse" , true ) ;
ctx . setVariable ( "refuse" , true ) ;
ctx . setVariable ( "refuse_description" , riskMaterialMapper . findAllMaterials ( riskId ) . get ( 0 ) . getString ( "refuse_description" ) ) ;
ctx . setVariable ( "refuse_description" , riskMaterialMapper . findAllMaterials ( riskId ) . get ( 0 ) . getString ( "refuse_description" ) ) ;
@ -416,10 +507,18 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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" , 2 ) ;
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 ) ;
riskMaterialService . updateRiskMaterial ( riskId , refuseDescription ) ;
// 日志记录
riskProcessLogService . addRiskProcessLog ( riskId ,
event . getString ( "fillin_id" ) ,
event . getString ( "fillin_person" ) ,
RiskResultTypeEnum . MATERIAL_NOT_PASS . getRemark ( ) ,
RiskResultTypeEnum . WAIT_FOR_AUDIT . getResultType ( ) ,
RiskResultTypeEnum . MATERIAL_NOT_PASS . getResultType ( ) ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
throw new EmailException ( "Email Sending Failed" , e ) ;
throw new EmailException ( "Email Sending Failed" , e ) ;
}
}
@ -462,14 +561,13 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
expireDay = "3" ;
expireDay = "3" ;
}
}
) * /
) * /
// 原来设定的过期时间是7天 ,现在改成半个月
// 原来设定的过期时间是7天
String expireDay = " 18 0";
String expireDay = " 365 0";
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 ;
//uploadUrl = "localhost:9009" + "/manage.html#/analysis/monitoring/" + event.getString("risk_id") + "/bd/detail";
List < JSONObject > bds = clientBDMapper . listClientBDInfoAvailable ( client . getIntValue ( "client_id" ) , new Date ( ) ) ;
List < JSONObject > bds = clientBDMapper . listClientBDInfoAvailable ( client . getIntValue ( "client_id" ) , new Date ( ) ) ;
List < String > bdNames = new ArrayList < > ( ) ;
List < String > bdNames = new ArrayList < > ( ) ;
List < String > bdEmails = new ArrayList < > ( ) ;
List < String > bdEmails = new ArrayList < > ( ) ;
@ -509,6 +607,19 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
List < JSONObject > orders = new ArrayList ( ) ;
List < JSONObject > orders = new ArrayList ( ) ;
int isSendClient = event . getIntValue ( "is_send_client" ) ;
int isSendClient = event . getIntValue ( "is_send_client" ) ;
ctx . setVariable ( "emailsTos" , bdEmails ) ;
if ( isSendClient = = 1 ) {
ctx . setVariable ( "emailsTos" , clientEmails ) ;
ctx . setVariable ( "emailsCcs" , bdEmails ) ;
if ( orderType = = RiskOrderTypeEnum . ROYALPAY_ORDER . getOrderType ( ) . intValue ( ) ) {
ctx . setVariable ( "emailsBccs" , Arrays . asList (
// "locky@royalpay.com.au ", "zoe.tao@royalpay.com.au", "leo.huang@royalpay.com.au",
// "mona.zhang@royalpay.com.au", "weixinfengkong@royalpay.com.au", "thomas.li@royalpay.com.au"
"18852852189@139.com" , "1370256381@qq.com"
) ) ;
}
}
switch ( event . getIntValue ( "order_type" ) ) {
switch ( event . getIntValue ( "order_type" ) ) {
case 1 :
case 1 :
case 2 :
case 2 :
@ -521,7 +632,6 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
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" ) ;
ctx . setVariable ( "emailsTos" , bdEmails ) ;
break ;
break ;
case 3 :
case 3 :
for ( String orderId : realOrderIds ) {
for ( String orderId : realOrderIds ) {
@ -548,12 +658,6 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
// ctx.setVariable("files",attachList);
// ctx.setVariable("files",attachList);
case 4 :
case 4 :
ctx . setVariable ( "title" , "RoyalPay风控调查 — " + client . getString ( "short_name" ) ) ;
ctx . setVariable ( "title" , "RoyalPay风控调查 — " + client . getString ( "short_name" ) ) ;
ctx . setVariable ( "emailsTos" , bdEmails ) ;
if ( isSendClient = = 1 ) {
ctx . setVariable ( "emailsTos" , clientEmails ) ;
ctx . setVariable ( "emailsCcs" , bdEmails ) ;
}
break ;
break ;
}
}
return ctx ;
return ctx ;
@ -861,11 +965,27 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
}
JSONObject result = new JSONObject ( ) ;
JSONObject result = new JSONObject ( ) ;
result . put ( "material" , materialItemList ) ;
result . put ( "material" , materialItemList ) ;
if ( material ! = null & & material . containsKey ( "description" ) )
if ( material ! = null & & material . containsKey ( "description" ) ) {
result . put ( "description" , material . getString ( "description" ) ) ;
result . put ( "description" , material . getString ( "description" ) ) ;
}
if ( material ! = null & & material . containsKey ( "refuse_description" ) ) {
result . put ( "refuse_description" , material . getString ( "refuse_description" ) ) ;
}
return result ;
return result ;
}
}
@Override
public JSONObject riskEventMaterialPass ( JSONObject params , JSONObject manager ) {
riskEventMapper . update ( params ) ;
riskProcessLogService . addRiskProcessLog ( params . getString ( "risk_id" ) ,
manager . getString ( "manager_id" ) ,
manager . getString ( "display_name" ) ,
RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getRemark ( ) ,
params . getIntValue ( "result_type" ) ,
RiskResultTypeEnum . MATERIAL_AUDIT_PASS . getResultType ( ) ) ;
return params ;
}
@Override
@Override
public JSONObject updateIsSendClient ( String riskId ) {
public JSONObject updateIsSendClient ( String riskId ) {
JSONObject event = riskEventMapper . findById ( riskId ) ;
JSONObject event = riskEventMapper . findById ( riskId ) ;
@ -874,4 +994,23 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
event = riskEventMapper . findById ( riskId ) ;
event = riskEventMapper . findById ( riskId ) ;
return event ;
return event ;
}
}
@Override
public void completeOrderAmount ( ) {
List < JSONObject > riskEventList = getRiskEvents ( null ) ;
for ( JSONObject riskEvent : riskEventList ) {
if ( riskEvent . getIntValue ( "order_type" ) = = 4 | | StringUtils . isBlank ( riskEvent . getString ( "real_order_ids" ) ) ) {
continue ;
}
String [ ] order_ids = riskEvent . getString ( "real_order_ids" ) . split ( "," ) ;
for ( String orderId : order_ids ) {
JSONObject transaction = transactionMapper . findByOrderId ( orderId ) ;
JSONObject riskOrder = new JSONObject ( ) ;
riskOrder . put ( "risk_id" , riskEvent . getString ( "risk_id" ) ) ;
riskOrder . put ( "order_id" , transaction . getString ( "order_id" ) ) ;
riskOrder . put ( "clearing_amount" , transaction . getString ( "clearing_amount" ) ) ;
riskOrdersMapper . save ( riskOrder ) ;
}
}
}
}
}