|
|
|
@ -211,7 +211,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
addBigDecimal(total, log, "wechat_charge");
|
|
|
|
|
addBigDecimal(total, log, "royalpay_charge");
|
|
|
|
|
addBigDecimal(total, log, "net_amount");
|
|
|
|
|
List<JSONObject> logDetails = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
|
int clearingId = log.getIntValue("clearing_id");
|
|
|
|
|
List<JSONObject> logDetails = clearingDetailMapper.listReportsOfSettlement(clearingId);
|
|
|
|
|
details.addAll(logDetails);
|
|
|
|
|
List<String> banks = logDetails.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
|
|
|
|
|
List<JSONObject> bankStatistics = banks.stream().map(bank -> {
|
|
|
|
@ -219,13 +220,14 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
data.put("bank", bank);
|
|
|
|
|
data.put("total_settle", logDetails.stream()
|
|
|
|
|
.filter(detail -> bank.equals(detail.getString("settle_bank")))
|
|
|
|
|
.map(detail -> detail.getBigDecimal("net_amount"))
|
|
|
|
|
.map(detail -> detail.getBigDecimal("clearing_amount"))
|
|
|
|
|
.reduce(BigDecimal::add)
|
|
|
|
|
);
|
|
|
|
|
return data;
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
log.put("bank_statistics", bankStatistics);
|
|
|
|
|
log.put("editable", DateUtils.isSameDay(log.getDate("settle_date"), new Date()) && log.getBooleanValue("editable"));
|
|
|
|
|
log.put("channel_analysis", clearingDetailAnalysisMapper.analysisChannelReport(clearingId));
|
|
|
|
|
}
|
|
|
|
|
total.put("logs", logs);
|
|
|
|
|
total.put("details", details);
|
|
|
|
@ -340,7 +342,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
String filename = "Merchant_Settlement_Info_" + dateString + RandomStringUtils.random(8, false, true) + ".xlsx";
|
|
|
|
|
zos.putNextEntry(new ZipEntry(filename));
|
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
|
byte[] xlsx = generateSettleXlsxFile(dt, details);
|
|
|
|
|
byte[] xlsx = generateSettleXlsxFile(dt, details, null);
|
|
|
|
|
IOUtils.write(xlsx, zos);
|
|
|
|
|
}
|
|
|
|
|
zos.flush();
|
|
|
|
@ -348,7 +350,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<JSONObject> getXlsx(Date dt) throws IOException {
|
|
|
|
|
public List<JSONObject> getXlsx(Date dt, String bank) throws IOException {
|
|
|
|
|
List<JSONObject> logs = clearingLogMapper.findByDate(dt);
|
|
|
|
|
if (logs.isEmpty()) {
|
|
|
|
|
throw new NotFoundException();
|
|
|
|
@ -360,7 +362,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + "_" + fileIndex + ".xlsx";
|
|
|
|
|
JSONObject file = new JSONObject();
|
|
|
|
|
file.put("name", filename);
|
|
|
|
|
file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"))));
|
|
|
|
|
file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")), bank));
|
|
|
|
|
result.add(file);
|
|
|
|
|
fileIndex++;
|
|
|
|
|
}
|
|
|
|
@ -369,7 +371,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + ".xlsx";
|
|
|
|
|
JSONObject file = new JSONObject();
|
|
|
|
|
file.put("name", filename);
|
|
|
|
|
file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"))));
|
|
|
|
|
file.put("byteArr", generateSettleXlsxFile(dt, clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")), bank));
|
|
|
|
|
result.add(file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -391,7 +393,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
return files.stream().filter(file -> bank.equals(file.bank())).collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private byte[] generateSettleXlsxFile(Date dt, List<JSONObject> settlements) throws IOException {
|
|
|
|
|
private byte[] generateSettleXlsxFile(Date dt, List<JSONObject> settlements, String bank) throws IOException {
|
|
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMM"));
|
|
|
|
|
int rowNum = 0;
|
|
|
|
@ -399,6 +401,9 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (bank != null && Objects.equals(settle.getString("settle_bank"), bank)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Row row = sheet.createRow(rowNum++);
|
|
|
|
|
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("bsb_no"));
|
|
|
|
|
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("account_no"));
|
|
|
|
@ -931,7 +936,7 @@ 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);
|
|
|
|
|
List<JSONObject> xlsxFileList = getXlsx(date, "CBA");
|
|
|
|
|
if (xlsxFileList.size() > 1) {
|
|
|
|
|
fileName1 += ".zip";
|
|
|
|
|
attach1.put("content", Base64.encodeBase64String(getZipByteArr(xlsxFileList)));
|
|
|
|
|