@ -146,15 +146,25 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
@Override
public List < JSONObject > getRiskEventOrderList ( String orderIds ) {
public List < JSONObject > getRiskEventOrderList ( JSONObject riskEvent ) {
String orderIds = riskEvent . getString ( "order_ids" ) ;
List < JSONObject > tradeLogs = new ArrayList < > ( ) ;
if ( StringUtils . isNotBlank ( orderIds ) ) {
String [ ] orderIdArray = orderIds . trim ( ) . split ( "," ) ;
JSONObject query = new JSONObject ( ) ;
JSONObject orderInfo = new JSONObject ( ) ;
String realOrderId = "" ;
// 获取订单信息
for ( int i = 0 ; i < orderIdArray . length ; i + + ) {
JSONObject orderInfo = orderMapper . findOrderById ( orderIdArray [ i ] ) ;
tradeLogs . add ( orderInfo ) ;
if ( riskEvent . getIntValue ( "order_type" ) = = 3 ) {
for ( int i = 0 ; i < orderIdArray . length ; i + + ) {
realOrderId = orderMapper . findOrderById ( orderIdArray [ i ] ) . getString ( "order_id" ) ;
orderInfo = tradeLogService . getOrderDetail ( new JSONObject ( ) , riskEvent . getString ( "client_moniker" ) , realOrderId , null ) ;
tradeLogs . add ( orderInfo ) ;
}
} else {
for ( int i = 0 ; i < orderIdArray . length ; i + + ) {
orderInfo = orderMapper . findOrderById ( orderIdArray [ i ] ) ;
tradeLogs . add ( orderInfo ) ;
}
}
}
return tradeLogs ;
@ -370,7 +380,8 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
}
private Context getMailContext ( JSONObject event ) throws IOException {
JSONObject client = clientMapper . findClientByMonikerAll ( event . getString ( "client_moniker" ) ) ;
String clientMoniker = event . getString ( "client_moniker" ) ;
JSONObject client = clientMapper . findClientByMonikerAll ( clientMoniker ) ;
if ( client = = null ) {
throw new InvalidShortIdException ( ) ;
}
@ -379,12 +390,20 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
codeKey = RandomStringUtils . random ( 20 , true , true ) ;
}
String codeKeyValue = RandomStringUtils . random ( 10 , true , true ) ;
/ *
String expireDay = "7" ;
if ( event . getIntValue ( "order_type" ) > 2 ) {
expireDay = "3" ;
}
) * /
// 原来设定的过期时间是7天, 现在改成一个月
String expireDay = "30" ;
stringRedisTemplate . boundValueOps ( getRiskUploadKey ( codeKey ) ) . set ( codeKeyValue , Long . parseLong ( expireDay ) , TimeUnit . DAYS ) ;
String uploadUrl = PlatformEnvironment . getEnv ( ) . concatUrl ( "/risk/upload/" ) + event . getString ( "risk_id" ) + "/" + codeKey ;
int orderType = event . getIntValue ( "order_type" ) ;
if ( orderType = = 1 | | orderType = = 2 )
uploadUrl = PlatformEnvironment . getEnv ( ) . concatUrl ( "/manage.html#/analysis/monitoring/" ) + event . getString ( "risk_id" ) + "/bd/detail" ;
//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 < String > bdNames = new ArrayList < > ( ) ;
List < String > bdEmails = new ArrayList < > ( ) ;
@ -403,8 +422,10 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
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_english = DateFormatUtils . format ( DateUtils . addDays ( event . getDate ( "reply_email_date" ) , - 1 ) , "dd/MM/yyyy" ) ;
GregorianCalendar gregorianCalendar = new GregorianCalendar ( ) ;
String hello = gregorianCalendar . get ( GregorianCalendar . AM_PM ) = = 0 ? "上午好" : "下午好" ;
Context ctx = new Context ( ) ;
ctx . setVariable ( "hello" , hello ) ;
ctx . setVariable ( "order_type" , event . getIntValue ( "order_type" ) ) ;
ctx . setVariable ( "bdNamesStr" , bdNamesStr ) ;
ctx . setVariable ( "reply_date" , reply_date ) ;
@ -413,11 +434,11 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
ctx . setVariable ( "uploadUrl" , uploadUrl ) ;
ctx . setVariable ( "royalpay_order_type" , event . getIntValue ( "royalpay_order_type" ) ) ;
ctx . setVariable ( "warning_order_type" , event . getIntValue ( "warning_order_type" ) ) ;
String [ ] orderIds = event . getString ( "order_ids" ) . split ( "," ) ;
List < JSONObject > orders = new ArrayList ( ) ;
switch ( event . getIntValue ( "order_type" ) ) {
case 1 :
case 2 :
String [ ] orderIds = event . getString ( "order_ids" ) . split ( "," ) ;
List < JSONObject > orders = new ArrayList ( ) ;
for ( String orderId : orderIds ) {
JSONObject order = orderMapper . findOrderById ( orderId ) ;
if ( order = = null ) {
@ -430,6 +451,24 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
ctx . setVariable ( "emailsTos" , bdEmails ) ;
break ;
case 3 :
String realOrderId = "" ;
for ( String orderId : orderIds ) {
realOrderId = orderMapper . findOrderById ( orderId ) . getString ( "order_id" ) ;
JSONObject order = tradeLogService . getOrderDetail ( new JSONObject ( ) , clientMoniker , realOrderId , null ) ;
if ( order = = null ) {
throw new BadRequestException ( "Order: " + orderId + " not exists" ) ;
}
order . put ( "order_description" , StringUtils . defaultString ( order . getString ( "order_description" ) ) ) ;
order . put ( "gateway" , getGateWay ( order . getIntValue ( "gateway" ) ) ) ;
order . put ( "status" , getStatus ( order . getIntValue ( "status" ) ) ) ;
order . put ( "order_detail" , StringUtils . defaultString ( order . getString ( "order_detail" ) ) ) ;
order . put ( "total_amount" , order . getString ( "currency" ) + " " + order . getString ( "total_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 ( "clearing_amount" , "AUD " + order . getString ( "clearing_amount" ) ) ;
orders . add ( order ) ;
}
ctx . setVariable ( "orders" , orders ) ;
List < JSONObject > attachList = new ArrayList < > ( ) ;
JSONObject file = new JSONObject ( ) ;
file . put ( "name" , client . getString ( "short_name" ) + "被查单号相关信息.xlsx" ) ;
@ -473,11 +512,15 @@ public class RiskBusinessServiceImpl implements RiskBusinessService, ManagerTodo
return null ;
}
private byte [ ] generateRiskOrders ( JSONObject event ) throws IOException {
String [ ] orderIds = event . getString ( "order_ids" ) . split ( "," ) ;
Workbook wb = new XSSFWorkbook ( ) ;
String realOrderId = "" ;
for ( String orderId : orderIds ) {
JSONObject orderDetail = tradeLogService . getOrderDetail ( new JSONObject ( ) , event . getString ( "client_moniker" ) , orderId , null ) ;
realOrderId = orderMapper . findOrderById ( orderId ) . getString ( "order_id" ) ;
JSONObject orderDetail = tradeLogService . getOrderDetail ( new JSONObject ( ) , event . getString ( "client_moniker" ) , realOrderId , null ) ;
Sheet sheet = wb . createSheet ( orderId ) ;
sheet . setDefaultColumnWidth ( ( short ) 40 ) ;
Row row0 = sheet . createRow ( 0 ) ;