|
|
|
@ -4,7 +4,11 @@ import au.com.royalpay.payment.core.PaymentApi;
|
|
|
|
|
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
|
|
|
|
|
import au.com.royalpay.payment.core.tasksupport.SettlementSupport;
|
|
|
|
|
import au.com.royalpay.payment.manage.management.clearing.core.CleanService;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.*;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailAnalysisMapper;
|
|
|
|
|
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.system.CalendarMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
|
|
|
|
@ -28,12 +32,15 @@ import au.com.royalpay.payment.tools.locale.LocaleSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
|
|
|
|
|
import au.com.royalpay.payment.tools.tasksupport.TaskFinishNotifyEvent;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.PageListUtils;
|
|
|
|
|
import au.com.royalpay.payment.tools.utils.TimeZoneUtils;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageList;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
import org.apache.commons.csv.CSVFormat;
|
|
|
|
|
import org.apache.commons.csv.CSVPrinter;
|
|
|
|
@ -42,7 +49,12 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
|
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.joda.time.DateTime;
|
|
|
|
|
import org.joda.time.Days;
|
|
|
|
@ -59,19 +71,32 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.thymeleaf.context.Context;
|
|
|
|
|
import org.thymeleaf.spring4.SpringTemplateEngine;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
import java.io.Writer;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.net.URISyntaxException;
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.text.NumberFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Currency;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.GregorianCalendar;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -122,7 +147,7 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
@Value("${app.redis.settle.check-code.prefix}")
|
|
|
|
|
private String reidsCheckCodeKey;
|
|
|
|
|
|
|
|
|
|
private final String[] open_ids = {"o32MzuEeb5ZT_DJQYbzZf6VCu1HQ", "o32MzuIsa3OBOkvC9pL90h9pgHPg", "o32MzuCpqGQJTlvTK7VQ7m_LVXiQ"};
|
|
|
|
|
private final String[] open_ids = { "o32MzuEeb5ZT_DJQYbzZf6VCu1HQ", "o32MzuIsa3OBOkvC9pL90h9pgHPg", "o32MzuCpqGQJTlvTK7VQ7m_LVXiQ" };
|
|
|
|
|
private ApplicationEventPublisher publisher;
|
|
|
|
|
// private final String[] open_ids = { "o32MzuO4s8c7iFOVxnxejkbhMoEc" };
|
|
|
|
|
|
|
|
|
@ -441,8 +466,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
+ detail.getBigDecimal("rate").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "%";
|
|
|
|
|
String totalCharge = detail.getBigDecimal("total_charge").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
|
|
|
|
|
String clearingAmount = detail.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
|
|
|
|
|
String[] values = {detail.getString("client_moniker"), "AUD", grossAmount, totalCharge, clearingAmount, detail.getString("bsb_no"),
|
|
|
|
|
detail.getString("account_no"), detail.getString("account_name"), settlementDate};
|
|
|
|
|
String[] values = { detail.getString("client_moniker"), "AUD", grossAmount, totalCharge, clearingAmount, detail.getString("bsb_no"),
|
|
|
|
|
detail.getString("account_no"), detail.getString("account_name"), settlementDate };
|
|
|
|
|
csv.printRecord((Object[]) values);
|
|
|
|
|
}
|
|
|
|
|
csv.flush();
|
|
|
|
@ -463,9 +488,9 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
BigDecimal.ROUND_HALF_DOWN);
|
|
|
|
|
BigDecimal clearingAmount = transaction.getBigDecimal("clearing_amount").multiply(BigDecimal.valueOf(multiply)).setScale(2,
|
|
|
|
|
BigDecimal.ROUND_HALF_DOWN);
|
|
|
|
|
String[] values = {transaction.getString("system_transaction_id"), transaction.getString("order_id"), transaction.getString("client_id"),
|
|
|
|
|
String[] values = { transaction.getString("system_transaction_id"), transaction.getString("order_id"), transaction.getString("client_id"),
|
|
|
|
|
transaction.getString("device_id"), transaction.getString("transaction_currency"), transactionAmount.toPlainString(),
|
|
|
|
|
transaction.getString("clearing_currency"), clearingAmount.toPlainString(), transaction.getString("channel"), transactionTime, "0"};
|
|
|
|
|
transaction.getString("clearing_currency"), clearingAmount.toPlainString(), transaction.getString("channel"), transactionTime, "0" };
|
|
|
|
|
csv.printRecord((Object[]) values);
|
|
|
|
|
}
|
|
|
|
|
csv.flush();
|
|
|
|
@ -610,6 +635,13 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
}
|
|
|
|
|
List<JSONObject> transactions = transactionMapper.listTransactionsOfClearingOrder(clearClient.getIntValue("clear_detail_id"),
|
|
|
|
|
new PageBounds(Order.formString("order_id.asc")));
|
|
|
|
|
String timezone_client = client.getString("timezone");
|
|
|
|
|
if (timezone_client != null) {
|
|
|
|
|
transactions.parallelStream().forEach(p -> {
|
|
|
|
|
TimeZoneUtils.switchTimeZone(p, timezone_client, "transaction_time");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearClient.put("report", transactions);
|
|
|
|
|
List<JSONObject> channels = clearingDetailAnalysisMapper.listReportChannels(clearClient.getString("clear_detail_id"));
|
|
|
|
|
JSONObject channelsObj = new JSONObject();
|
|
|
|
@ -628,7 +660,8 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
JSONObject clearTransation = listClearingTransactions(client_id, clearingDetailId, partner);
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
Date reportDate = clearTransation.getDate("report_date");
|
|
|
|
|
resp.addHeader("Content-Disposition", "attachment; filename=" + "Merchant_Settlement_Info_" + DateFormatUtils.format(reportDate, "yyyy-MM-dd") + ".xlsx");
|
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
|
"attachment; filename=" + "Merchant_Settlement_Info_" + DateFormatUtils.format(reportDate, "yyyy-MM-dd") + ".xlsx");
|
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
Cell cell = null;
|
|
|
|
@ -640,9 +673,9 @@ public class CleanServiceImpl implements CleanService, ManagerTodoNoticeProvider
|
|
|
|
|
Sheet sheet = wb.createSheet("Merchant_Settlement_Info_" + DateFormatUtils.format(reportDate, "yyyyMMdd"));
|
|
|
|
|
int rowNum = 0;
|
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
|
String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
|
|
|
|
|
"Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark"};
|
|
|
|
|
String[] analysis = {"Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount"};
|
|
|
|
|
String[] title = { "order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
|
|
|
|
|
"Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Remark" };
|
|
|
|
|
String[] analysis = { "Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount" };
|
|
|
|
|
for (int i = 0; i < title.length; i++) {
|
|
|
|
|
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
|
|
|
|
|
}
|
|
|
|
|