@ -395,14 +395,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
@Override
public List < JSONObject > getXlsx ( Date dt , String bank , List < String > clearIds ) throws IOException {
List < JSONObject > logs = clearingLogMapper . findByDate ( dt ) ;
logs = logs . stream ( ) . filter ( log - > log . getBooleanValue ( "editable" ) )
. filter ( log - > clearIds . isEmpty ( ) | | clearIds . contains ( log . getString ( "clearing_id" ) ) )
. collect ( Collectors . toList ( ) ) ;
if ( logs . isEmpty ( ) ) {
throw new NotFoundException ( ) ;
}
public List < JSONObject > getXlsx ( Date dt , String bank , List < JSONObject > logs ) throws IOException {
List < JSONObject > result = new ArrayList < > ( ) ;
int fileIndex = 1 ;
if ( logs . size ( ) > 1 ) {
@ -431,6 +424,17 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
return result ;
}
public List < JSONObject > getSettleLogs ( Date dt , List < String > clearIds ) {
List < JSONObject > logs = clearingLogMapper . findByDate ( dt ) ;
logs = logs . stream ( ) . filter ( log - > log . getBooleanValue ( "editable" ) )
. filter ( log - > clearIds . isEmpty ( ) | | clearIds . contains ( log . getString ( "clearing_id" ) ) )
. collect ( Collectors . toList ( ) ) ;
if ( logs . isEmpty ( ) ) {
throw new NotFoundException ( ) ;
}
return logs ;
}
private List < JSONObject > mergeBatchSettleClients ( List < JSONObject > details ) {
Map < String , List < JSONObject > > sameBankDetails = details . stream ( )
. filter ( this : : detailEnabledMergeSettle )
@ -493,14 +497,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
@Override
public List < ABAFile > getAba ( Date dt , String bank , List < String > clearIds ) {
List < JSONObject > logs = clearingLogMapper . findByDate ( dt ) ;
logs = logs . stream ( ) . filter ( log - > log . getBooleanValue ( "editable" ) )
. filter ( log - > clearIds . isEmpty ( ) | | clearIds . contains ( log . getString ( "clearing_id" ) ) )
. collect ( Collectors . toList ( ) ) ;
if ( logs . isEmpty ( ) ) {
throw new NotFoundException ( ) ;
}
public List < ABAFile > getAba ( Date dt , String bank , List < JSONObject > logs ) {
List < ABAFile > files = new ArrayList < > ( ) ;
for ( JSONObject log : logs ) {
List < JSONObject > details = clearingDetailMapper . listReportsOfSettlement ( log . getIntValue ( "clearing_id" ) ) ;
@ -1112,7 +1109,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
}
@Override
public JSONObject sendSettlementMail ( Date date , List < String > clearIds ) {
public JSONObject sendSettlementMail ( Date date , List < String > clearIds , boolean autoMarkSent ) {
JSONObject result = new JSONObject ( ) ;
try {
String title = "Royalpay Settlement File " + DateFormatUtils . format ( date , "yyyyMMdd" ) ;
@ -1121,7 +1118,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
String fileName1 = "Merchant_Settlement_Info_xlsx_" + DateFormatUtils . format ( date , "yyyyMMdd" ) ;
List < JSONObject > attachList = new ArrayList < > ( ) ;
JSONObject attach1 = new JSONObject ( ) ;
List < JSONObject > xlsxFileList = getXlsx ( date , "CBA" , clearIds ) ;
List < JSONObject > clearLogs = getSettleLogs ( date , clearIds ) ;
List < JSONObject > xlsxFileList = getXlsx ( date , "CBA" , clearLogs ) ;
if ( xlsxFileList . size ( ) > 1 ) {
fileName1 + = ".zip" ;
attach1 . put ( "content" , Base64 . encodeBase64String ( getZipByteArr ( xlsxFileList ) ) ) ;
@ -1133,7 +1131,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
attachList . add ( attach1 ) ;
JSONObject attach2 = new JSONObject ( ) ;
List < ABAFile > abaFileList = getAba ( date , "CBA" , clear Id s) ;
List < ABAFile > abaFileList = getAba ( date , "CBA" , clear Log s) ;
String fileName2 = "Merchant_Settlement_Info_aba_" + DateFormatUtils . format ( date , "yyyyMMdd" ) ;
if ( abaFileList . size ( ) > 1 ) {
fileName2 + = ".zip" ;
@ -1182,7 +1180,13 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
logSettleMailMapper . save ( settleMailRecord ) ;
}
sendTaskFinishMessages ( ManagerRole . FINANCIAL_STAFF , "清算文件已发送清算方" , "发送清算通知" ) ;
clearingLogMapper . lockSettlements ( date ) ;
if ( autoMarkSent ) {
if ( ! clearIds . isEmpty ( ) ) {
clearingLogMapper . lockSettlementsById ( clearLogs . stream ( ) . map ( log - > log . getString ( "clearing_id" ) ) . collect ( Collectors . toList ( ) ) ) ;
} else {
clearingLogMapper . lockSettlements ( date ) ;
}
}
} catch ( IOException e ) {
logger . error ( "生成excel字节数组发生错误" ) ;
} catch ( URISyntaxException e ) {