|
|
|
@ -4,11 +4,7 @@ import au.com.royalpay.payment.core.PaymentApi;
|
|
|
|
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
|
|
|
|
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
|
|
|
|
import au.com.royalpay.payment.core.tasksupport.SettlementSupport;
|
|
|
|
import au.com.royalpay.payment.core.tasksupport.SettlementSupport;
|
|
|
|
import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
|
|
|
|
import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.*;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ValidationLogMapper;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.CalendarMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.CalendarMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
|
|
|
|
@ -20,6 +16,7 @@ import au.com.royalpay.payment.manage.notice.core.MailService;
|
|
|
|
import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
|
|
|
|
import au.com.royalpay.payment.manage.signin.beans.TodoNotice;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.ManagerTodoNoticeProvider;
|
|
|
|
import au.com.royalpay.payment.manage.support.abafile.ABAFile;
|
|
|
|
import au.com.royalpay.payment.manage.support.abafile.ABAFile;
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.support.abafile.ABATemplate;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.beans.ClearingLogQuery;
|
|
|
|
import au.com.royalpay.payment.manage.tradelog.beans.ClearingLogQuery;
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
|
|
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
|
|
|
|
@ -34,14 +31,12 @@ import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent;
|
|
|
|
import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
import org.apache.commons.csv.CSVFormat;
|
|
|
|
import org.apache.commons.csv.CSVFormat;
|
|
|
|
import org.apache.commons.csv.CSVPrinter;
|
|
|
|
import org.apache.commons.csv.CSVPrinter;
|
|
|
|
@ -50,12 +45,7 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.joda.time.DateTime;
|
|
|
|
import org.joda.time.DateTime;
|
|
|
|
import org.joda.time.Days;
|
|
|
|
import org.joda.time.Days;
|
|
|
|
@ -72,13 +62,9 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
import org.thymeleaf.spring4.SpringTemplateEngine;
|
|
|
|
import org.thymeleaf.spring4.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
|
|
|
import java.io.Writer;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
@ -90,9 +76,6 @@ import java.util.stream.Collectors;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
|
|
|
|
import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -226,8 +209,22 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
addBigDecimal(total, log, "wechat_charge");
|
|
|
|
addBigDecimal(total, log, "wechat_charge");
|
|
|
|
addBigDecimal(total, log, "royalpay_charge");
|
|
|
|
addBigDecimal(total, log, "royalpay_charge");
|
|
|
|
addBigDecimal(total, log, "net_amount");
|
|
|
|
addBigDecimal(total, log, "net_amount");
|
|
|
|
details.addAll(clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id")));
|
|
|
|
List<JSONObject> logDetails = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
}
|
|
|
|
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 -> {
|
|
|
|
|
|
|
|
JSONObject data = new JSONObject();
|
|
|
|
|
|
|
|
data.put("bank", bank);
|
|
|
|
|
|
|
|
data.put("total_settle", logDetails.stream()
|
|
|
|
|
|
|
|
.filter(detail -> bank.equals(detail.getString("settle_bank")))
|
|
|
|
|
|
|
|
.map(detail -> detail.getBigDecimal("net_amount"))
|
|
|
|
|
|
|
|
.reduce(BigDecimal::add)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
log.put("bank_statistics", bankStatistics);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
total.put("logs", logs);
|
|
|
|
total.put("details", details);
|
|
|
|
total.put("details", details);
|
|
|
|
List<JSONObject> channels = clearingDetailAnalysisMapper.analysisChannelReportDaily(settleDate);
|
|
|
|
List<JSONObject> channels = clearingDetailAnalysisMapper.analysisChannelReportDaily(settleDate);
|
|
|
|
total.put("channel_analysis", channels);
|
|
|
|
total.put("channel_analysis", channels);
|
|
|
|
@ -378,34 +375,17 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<JSONObject> getAba(Date dt) throws IOException {
|
|
|
|
public List<ABAFile> getAba(Date dt, String bank) {
|
|
|
|
List<JSONObject> logs = clearingLogMapper.findByDate(dt);
|
|
|
|
List<JSONObject> logs = clearingLogMapper.findByDate(dt);
|
|
|
|
if (logs.isEmpty()) {
|
|
|
|
if (logs.isEmpty()) {
|
|
|
|
throw new NotFoundException();
|
|
|
|
throw new NotFoundException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<JSONObject> result = new ArrayList<>();
|
|
|
|
List<ABAFile> files = new ArrayList<>();
|
|
|
|
int index = 1;
|
|
|
|
|
|
|
|
if (logs.size() > 1) {
|
|
|
|
|
|
|
|
// todo email edit
|
|
|
|
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
JSONObject file = new JSONObject();
|
|
|
|
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + "_" + index + ".aba";
|
|
|
|
files.addAll(generateSettleAbaFiles(dt, details, log.getDate("operate_time")));
|
|
|
|
file.put("name", filename);
|
|
|
|
|
|
|
|
file.put("byteArr", generateSettleAbaFile(dt, details, index++));
|
|
|
|
|
|
|
|
result.add(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
|
|
|
|
String filename = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + ".aba";
|
|
|
|
|
|
|
|
JSONObject file = new JSONObject();
|
|
|
|
|
|
|
|
file.put("name", filename);
|
|
|
|
|
|
|
|
file.put("byteArr", generateSettleAbaFile(dt, details, index++));
|
|
|
|
|
|
|
|
result.add(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
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) throws IOException {
|
|
|
|
@ -434,34 +414,56 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
if (logs.isEmpty()) {
|
|
|
|
if (logs.isEmpty()) {
|
|
|
|
throw new NotFoundException();
|
|
|
|
throw new NotFoundException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
List<ABAFile> files = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
|
|
|
|
files.addAll(generateSettleAbaFiles(dt, details, log.getDate("operate_time")));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputStream ous = resp.getOutputStream();
|
|
|
|
|
|
|
|
if (files.size() == 1) {
|
|
|
|
|
|
|
|
ABAFile file = files.get(0);
|
|
|
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
|
|
|
resp.addHeader("Content-Disposition", "attachment; filename=" + file.filename());
|
|
|
|
|
|
|
|
ous.write(file.output(1));
|
|
|
|
|
|
|
|
ous.flush();
|
|
|
|
|
|
|
|
IOUtils.closeQuietly(ous);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
String zipName = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + RandomStringUtils.random(8, false, true) + "_aba.zip";
|
|
|
|
String zipName = "Merchant_Settlement_Info_" + DateFormatUtils.format(dt, "yyyyMMdd") + RandomStringUtils.random(8, false, true) + "_aba.zip";
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
resp.addHeader("Content-Disposition", "attachment; filename=" + zipName);
|
|
|
|
resp.addHeader("Content-Disposition", "attachment; filename=" + zipName);
|
|
|
|
OutputStream ous = resp.getOutputStream();
|
|
|
|
|
|
|
|
ZipOutputStream zos = new ZipOutputStream(ous);
|
|
|
|
ZipOutputStream zos = new ZipOutputStream(ous);
|
|
|
|
int index = 1;
|
|
|
|
Map<String, Integer> bankCounts = new HashMap<>();
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
for (ABAFile file : files) {
|
|
|
|
String dateString = DateFormatUtils.format(log.getDate("operate_time"), "yyyyMMddHHmmss");
|
|
|
|
String filename = file.filename();
|
|
|
|
String filename = "Merchant_Settlement_Info_" + dateString + RandomStringUtils.random(8, false, true) + ".aba";
|
|
|
|
|
|
|
|
zos.putNextEntry(new ZipEntry(filename));
|
|
|
|
zos.putNextEntry(new ZipEntry(filename));
|
|
|
|
List<JSONObject> details = clearingDetailMapper.listReportsOfSettlement(log.getIntValue("clearing_id"));
|
|
|
|
int serializeNo = bankCounts.get(file.bank()) == null ? 1 : bankCounts.get(file.bank()) + 1;
|
|
|
|
byte[] file = generateSettleAbaFile(dt, details, index++);
|
|
|
|
bankCounts.put(file.bank(), serializeNo);
|
|
|
|
IOUtils.write(file, zos);
|
|
|
|
IOUtils.write(file.output(serializeNo), zos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
zos.flush();
|
|
|
|
zos.flush();
|
|
|
|
IOUtils.closeQuietly(zos);
|
|
|
|
IOUtils.closeQuietly(zos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<ABAFile> generateSettleAbaFiles(Date dt, List<JSONObject> settlements, Date operateTime) {
|
|
|
|
|
|
|
|
List<String> banks = settlements.stream().map(detail -> detail.getString("settle_bank")).distinct().collect(Collectors.toList());
|
|
|
|
|
|
|
|
return banks.stream().map(bank -> generateSettleAbaFile(bank, dt, settlements)).peek(file -> file.setOperateTime(operateTime)).collect(Collectors.toList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private byte[] generateSettleAbaFile(Date dt, List<JSONObject> settlements, int index) {
|
|
|
|
private ABAFile generateSettleAbaFile(String bank, Date dt, List<JSONObject> settlements) {
|
|
|
|
ABAFile aba = new ABAFile(dt, index);
|
|
|
|
ABAFile aba = ABATemplate.getConfig().initFile(bank, dt);
|
|
|
|
for (JSONObject settle : settlements) {
|
|
|
|
for (JSONObject settle : settlements) {
|
|
|
|
|
|
|
|
if (!bank.equals(settle.getString("settle_bank"))) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aba.addSettleMerchant(settle.getString("bsb_no"), settle.getString("account_no"), settle.getString("account_name"),
|
|
|
|
aba.addSettleMerchant(settle.getString("bsb_no"), settle.getString("account_no"), settle.getString("account_name"),
|
|
|
|
settle.getBigDecimal("clearing_amount"));
|
|
|
|
settle.getBigDecimal("clearing_amount"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return aba.output();
|
|
|
|
return aba;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private byte[] generateSettleCSVFile(Date settleDate, List<JSONObject> details) throws IOException {
|
|
|
|
private byte[] generateSettleCSVFile(Date settleDate, List<JSONObject> details) throws IOException {
|
|
|
|
@ -474,10 +476,10 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
if (detail.getDoubleValue("clearing_amount") == 0) {
|
|
|
|
if (detail.getDoubleValue("clearing_amount") == 0) {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String grossAmount = detail.getBigDecimal("gross_amount").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + " @ "
|
|
|
|
String grossAmount = detail.getBigDecimal("gross_amount").setScale(2, RoundingMode.HALF_UP).toPlainString() + " @ "
|
|
|
|
+ detail.getBigDecimal("rate").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%";
|
|
|
|
+ detail.getBigDecimal("rate").setScale(2, RoundingMode.HALF_UP).toPlainString() + "%";
|
|
|
|
String totalCharge = detail.getBigDecimal("total_charge").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
|
|
|
|
String totalCharge = detail.getBigDecimal("total_charge").setScale(2, RoundingMode.HALF_UP).toPlainString();
|
|
|
|
String clearingAmount = detail.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
|
|
|
|
String clearingAmount = detail.getBigDecimal("clearing_amount").setScale(2, RoundingMode.HALF_UP).toPlainString();
|
|
|
|
String[] values = {detail.getString("client_moniker"), "AUD", grossAmount, totalCharge, clearingAmount, detail.getString("bsb_no"),
|
|
|
|
String[] values = {detail.getString("client_moniker"), "AUD", grossAmount, totalCharge, clearingAmount, detail.getString("bsb_no"),
|
|
|
|
detail.getString("account_no"), detail.getString("account_name"), settlementDate};
|
|
|
|
detail.getString("account_no"), detail.getString("account_name"), settlementDate};
|
|
|
|
csv.printRecord((Object[]) values);
|
|
|
|
csv.printRecord((Object[]) values);
|
|
|
|
@ -708,16 +710,17 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
BigDecimal tax_amount_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("tax_amount")).map(t -> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
BigDecimal tax_amount_debit = transactionsOfDay.stream().filter(t -> t.getString("transaction_type").equals("Debit")).filter(t -> t.containsKey("tax_amount")).map(t -> t.getBigDecimal("tax_amount")).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal tax_amount = tax_amount_credit.subtract(tax_amount_debit);
|
|
|
|
BigDecimal tax_amount = tax_amount_credit.subtract(tax_amount_debit);
|
|
|
|
analysis.put("total_credit",total_credit.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
analysis.put("total_credit", total_credit.setScale(2, RoundingMode.HALF_UP));
|
|
|
|
analysis.put("total_debit",total_debit.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
analysis.put("total_debit", total_debit.setScale(2, RoundingMode.HALF_UP));
|
|
|
|
analysis.put("net_amount",net_amount_credit.subtract(net_amount_debit).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
analysis.put("net_amount", net_amount_credit.subtract(net_amount_debit).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
analysis.put("tax_amount",tax_amount.setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
analysis.put("tax_amount", tax_amount.setScale(2, RoundingMode.HALF_UP));
|
|
|
|
analysis.put("total_charge",total_charge_credit.subtract(total_charge_debit).add(tax_amount).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
analysis.put("total_charge", total_charge_credit.subtract(total_charge_debit).add(tax_amount).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
analysis.put("gross_amount",total_credit.subtract(total_debit).setScale(2,BigDecimal.ROUND_HALF_UP));
|
|
|
|
analysis.put("gross_amount", total_credit.subtract(total_debit).setScale(2, RoundingMode.HALF_UP));
|
|
|
|
dayAnalysisMap.put(entry.getKey(), analysis);
|
|
|
|
dayAnalysisMap.put(entry.getKey(), analysis);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dayAnalysisMap;
|
|
|
|
return dayAnalysisMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp) {
|
|
|
|
public void exportListClearingTransactions(int client_id, String clearingDetailId, JSONObject partner, HttpServletResponse resp) {
|
|
|
|
OutputStream ous = null;
|
|
|
|
OutputStream ous = null;
|
|
|
|
@ -937,15 +940,23 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
attachList.add(attach1);
|
|
|
|
attachList.add(attach1);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject attach2 = new JSONObject();
|
|
|
|
JSONObject attach2 = new JSONObject();
|
|
|
|
List<JSONObject> abaFileList = getAba(date);
|
|
|
|
List<ABAFile> abaFileList = getAba(date, "CBA");
|
|
|
|
String fileName2 = "Merchant_Settlement_Info_aba_" + DateFormatUtils.format(date, "yyyyMMdd");
|
|
|
|
String fileName2 = "Merchant_Settlement_Info_aba_" + DateFormatUtils.format(date, "yyyyMMdd");
|
|
|
|
if (abaFileList.size() > 1) {
|
|
|
|
if (abaFileList.size() > 1) {
|
|
|
|
fileName2 += ".zip";
|
|
|
|
fileName2 += ".zip";
|
|
|
|
attach2.put("content", Base64.encodeBase64String(getZipByteArr(abaFileList)));
|
|
|
|
List<JSONObject> entities = new ArrayList<>();
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
for (ABAFile file : abaFileList) {
|
|
|
|
|
|
|
|
JSONObject entity = new JSONObject();
|
|
|
|
|
|
|
|
entity.put("name", file.filename());
|
|
|
|
|
|
|
|
entity.put("byteArr", file.output(index++));
|
|
|
|
|
|
|
|
entities.add(entity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
attach2.put("content", Base64.encodeBase64String(getZipByteArr(entities)));
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
fileName2 += ".aba";
|
|
|
|
fileName2 += ".aba";
|
|
|
|
attach2.put("content", Base64.encodeBase64String((byte[]) abaFileList.get(0).get("byteArr")));
|
|
|
|
attach2.put("content", Base64.encodeBase64String(abaFileList.get(0).output(1)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
attach2.put("name", fileName2);
|
|
|
|
attach2.put("name", fileName2);
|
|
|
|
attachList.add(attach2);
|
|
|
|
attachList.add(attach2);
|
|
|
|
|