|
|
|
@ -104,7 +104,7 @@ import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.chec
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider, ApplicationEventPublisherAware {
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
@Resource
|
|
|
|
|
private SettlementSupport settlementSupport;
|
|
|
|
|
@Resource
|
|
|
|
@ -114,6 +114,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
@Resource
|
|
|
|
|
private ClearingDetailMapper clearingDetailMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private CustomizedSettleLogMapper customizedSettleLogMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClearingDetailAnalysisMapper clearingDetailAnalysisMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private TaskManualSettleMapper taskManualSettleMapper;
|
|
|
|
@ -665,6 +667,33 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getCustomizedSettleABA(int logId, HttpServletResponse response) {
|
|
|
|
|
JSONObject log = customizedSettleLogMapper.find(logId);
|
|
|
|
|
if (log == null) {
|
|
|
|
|
throw new NotFoundException("Settle log not found");
|
|
|
|
|
}
|
|
|
|
|
String bank = log.getString("settle_bank");
|
|
|
|
|
BalanceGroup group = BalanceGroup.valueOf(log.getString("balance_group"));
|
|
|
|
|
JSONObject settle = new JSONObject();
|
|
|
|
|
settle.put("settle_bank", bank);
|
|
|
|
|
settle.put("clearing_amount", log.getBigDecimal("amount"));
|
|
|
|
|
settle.put("client_id", log.getIntValue("client_id"));
|
|
|
|
|
settle.put("bsb_no", log.getString("bsb_no"));
|
|
|
|
|
settle.put("account_no", log.getString("account_no"));
|
|
|
|
|
settle.put("account_name", log.getString("account_name"));
|
|
|
|
|
settle.put("client_moniker", log.getString("client_moniker"));
|
|
|
|
|
ABAFile file = generateSettleAbaFile(bank, group, new Date(), Collections.singletonList(settle));
|
|
|
|
|
response.setContentType("application/octet-stream;");
|
|
|
|
|
response.addHeader("Content-Disposition", "attachment; filename=" + file.filename());
|
|
|
|
|
try (OutputStream ous = response.getOutputStream()) {
|
|
|
|
|
ous.write(file.output(1));
|
|
|
|
|
ous.flush();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new ServerErrorException("Output failed", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void getSettlementFilesForBatch(String batchId, HttpServletResponse resp) throws IOException {
|
|
|
|
|
int clearingId = Integer.parseInt(batchId);
|
|
|
|
@ -1649,20 +1678,27 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
if (!log.getBooleanValue("editable")) {
|
|
|
|
|
throw new ForbiddenException("Settlement log has been sent and unable to edit");
|
|
|
|
|
}
|
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(clearingId);
|
|
|
|
|
List<JSONObject> detailsWithDistributedSurcharge = details.stream().filter(detail -> detail.getBigDecimal("distributed_surcharge").compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
|
|
|
|
|
if (!detailsWithDistributedSurcharge.isEmpty()) {
|
|
|
|
|
for (JSONObject detail : detailsWithDistributedSurcharge) {
|
|
|
|
|
releaseDistributedSurcharge(detail);
|
|
|
|
|
if (!locker.lock("settle_task", 3600_000)) {
|
|
|
|
|
throw new ServerErrorException("Settle Task Running!");
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(clearingId);
|
|
|
|
|
List<JSONObject> detailsWithDistributedSurcharge = details.stream().filter(detail -> detail.getBigDecimal("distributed_surcharge").compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
|
|
|
|
|
if (!detailsWithDistributedSurcharge.isEmpty()) {
|
|
|
|
|
for (JSONObject detail : detailsWithDistributedSurcharge) {
|
|
|
|
|
releaseDistributedSurcharge(detail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
transactionMapper.deleteSettlementTransaction(clearingId);
|
|
|
|
|
transactionMapper.removeSettleRemark(clearingId);
|
|
|
|
|
preSettleTaskMapper.resetClearStatus(clearingId);
|
|
|
|
|
clearingDetailAnalysisMapper.clearAnalysis(clearingId);
|
|
|
|
|
taskManualSettleMapper.rollbackExecutedTask(clearingId);
|
|
|
|
|
clearingDetailMapper.deleteSettleLogs(clearingId);
|
|
|
|
|
clearingLogMapper.deleteSettleLogs(clearingId);
|
|
|
|
|
} finally {
|
|
|
|
|
locker.unlock("settle_task");
|
|
|
|
|
}
|
|
|
|
|
transactionMapper.deleteSettlementTransaction(clearingId);
|
|
|
|
|
transactionMapper.removeSettleRemark(clearingId);
|
|
|
|
|
preSettleTaskMapper.resetClearStatus(clearingId);
|
|
|
|
|
clearingDetailAnalysisMapper.clearAnalysis(clearingId);
|
|
|
|
|
taskManualSettleMapper.rollbackExecutedTask(clearingId);
|
|
|
|
|
clearingDetailMapper.deleteSettleLogs(clearingId);
|
|
|
|
|
clearingLogMapper.deleteSettleLogs(clearingId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -1724,7 +1760,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
public TransactionStatus getTransactionStatus(String transactionId) {
|
|
|
|
|
TransactionStatus transactionStatus = transactionMapper.getTransactionStatusById(transactionId);
|
|
|
|
|
if (transactionStatus == null) {
|
|
|
|
|
throw new ParamInvalidException("date","The transaction was not found");
|
|
|
|
|
throw new ParamInvalidException("date", "The transaction was not found");
|
|
|
|
|
}
|
|
|
|
|
return transactionStatus.toSet();
|
|
|
|
|
}
|
|
|
|
|