|
|
|
@ -65,14 +65,12 @@ import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
@ -467,29 +465,29 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject listPartnerTransFlow(TradeLogQuery query, JSONObject partner) throws Exception {
|
|
|
|
|
int client_id = partner.getIntValue("client_id");
|
|
|
|
|
int clientId = partner.getIntValue("client_id");
|
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
clientManager.validateClients(client_id, params);
|
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
|
clientManager.validateClients(clientId, params);
|
|
|
|
|
params.put("client_id", clientId);
|
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlow(params);
|
|
|
|
|
if (client_id!=1563){
|
|
|
|
|
logs.stream().forEach(p -> {
|
|
|
|
|
String login_id = p.getString("login_id");
|
|
|
|
|
if (StringUtils.isNotEmpty(login_id)) {
|
|
|
|
|
p.put("order_detail", (StringUtils.isEmpty(p.getString("order_detail")) ? "" : login_id+":"+p.getString("order_detail")));
|
|
|
|
|
}else{
|
|
|
|
|
if (clientId != 1563) {
|
|
|
|
|
logs.forEach(p -> {
|
|
|
|
|
String loginId = p.getString("login_id");
|
|
|
|
|
if (StringUtils.isNotEmpty(loginId)) {
|
|
|
|
|
p.put("order_detail", (StringUtils.isEmpty(p.getString("order_detail")) ? "" : loginId + ":" + p.getString("order_detail")));
|
|
|
|
|
} else {
|
|
|
|
|
p.put("order_detail", (StringUtils.isEmpty(p.getString("order_detail")) ? "" : p.getString("order_detail")));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Collections.singletonList("transaction_time"));
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy", Collections.singletonList("clearing_time"));
|
|
|
|
|
|
|
|
|
|
final JSONObject analysis = analysisTransLogs(logs);
|
|
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
|
result.put("data", logs);
|
|
|
|
|
// JSONObject analysis = transactionMapper.analysisTransFlow(params);
|
|
|
|
|
analysis.put("balance", transactionMapper.analysisBalance(params));
|
|
|
|
|
if (analysis.containsKey("paid_fee") && analysis.containsKey("refund_fee")) {
|
|
|
|
|
analysis.put("actual_fee", analysis.getBigDecimal("paid_fee").add(analysis.getBigDecimal("refund_fee")));
|
|
|
|
@ -590,13 +588,12 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void exportTransFlow(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
|
|
|
|
|
// File jasperFile = trans_flow.getFile();
|
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
|
JSONObject analysis = transFlow.getJSONObject("analysis");
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
|
try {
|
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
|
List<JSONObject> dataList = transFlow.getJSONArray("data").toJavaList(JSONObject.class);
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom())
|
|
|
|
|
? DateFormatUtils.format(DateUtils.parseDate(query.getDatefrom(), "yyyyMMdd"), "dd/MM/yyyy") : "");
|
|
|
|
@ -662,10 +659,9 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
|
// JSONObject analysis = transFlow.getJSONObject("analysis");
|
|
|
|
|
if (transFlow.getJSONArray("data").size() > 0) {
|
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
|
try {
|
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
|
List<JSONObject> dataList = transFlow.getJSONArray("data").toJavaList(JSONObject.class);
|
|
|
|
|
String transType;
|
|
|
|
|
JSONObject device;
|
|
|
|
|
int status;
|
|
|
|
@ -689,16 +685,13 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
|
|
|
|
parmerters.put("partnerCode", client.getString("client_moniker"));
|
|
|
|
|
// parmerters.put("actual_fee", analysis.containsKey("actual_fee") ?
|
|
|
|
|
// analysis.getBigDecimal("actual_fee") : 0);
|
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList);
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
|
|
|
|
|
: (parmerters.getString("dateFrom") + "~" + parmerters.getString("dateTo"));
|
|
|
|
|
// String fileName = new String(URLEncoder.encode(defaultname,"utf8"));
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
|
JasperPrint jasperPrint = JasperFillManager.fillReport(trans_excel.getInputStream(), parmerters, jrDataSource);
|
|
|
|
|
// JRXlsExporter exporter = new JRXlsExporter();
|
|
|
|
|
JRXlsxExporter exporter = new JRXlsxExporter();
|
|
|
|
|
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
|
|
|
|
|
exporter.setExporterInput(exporterInput);
|
|
|
|
@ -721,23 +714,27 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void excelTrans(Row row, JSONObject data) {
|
|
|
|
|
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_time"));
|
|
|
|
|
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(data.getString("client_order_id"));
|
|
|
|
|
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(data.getString("system_transaction_id"));
|
|
|
|
|
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(data.getString("client_moniker"));
|
|
|
|
|
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(data.getString("short_name"));
|
|
|
|
|
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_id"));
|
|
|
|
|
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(data.getString("channel"));
|
|
|
|
|
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(data.getString("display_amount"));
|
|
|
|
|
row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_amount"));
|
|
|
|
|
row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(data.getString("currency"));
|
|
|
|
|
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_amount"));
|
|
|
|
|
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type").equals("clearing")?"-":data.getBigDecimal("exchange_rate").toString());
|
|
|
|
|
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type"));
|
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clear_status"));
|
|
|
|
|
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(data.getString("gateway"));
|
|
|
|
|
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail"));
|
|
|
|
|
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("dev_id"));
|
|
|
|
|
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_time"));
|
|
|
|
|
row.createCell(1, Cell.CELL_TYPE_STRING).setCellValue(data.getString("client_order_id"));
|
|
|
|
|
row.createCell(2, Cell.CELL_TYPE_STRING).setCellValue(data.getString("system_transaction_id"));
|
|
|
|
|
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(data.getString("client_moniker"));
|
|
|
|
|
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(data.getString("short_name"));
|
|
|
|
|
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_id"));
|
|
|
|
|
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(data.getString("channel"));
|
|
|
|
|
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(data.getString("display_amount"));
|
|
|
|
|
row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_amount"));
|
|
|
|
|
row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(data.getString("currency"));
|
|
|
|
|
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_amount"));
|
|
|
|
|
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(data.getString("settle_amount"));
|
|
|
|
|
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(data.getString("total_surcharge"));
|
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(data.getString("tax_amount"));
|
|
|
|
|
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_time"));
|
|
|
|
|
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type").equals("clearing") ? "-" : data.getBigDecimal("exchange_rate").toString());
|
|
|
|
|
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type"));
|
|
|
|
|
row.createCell(17, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clear_status"));
|
|
|
|
|
row.createCell(18, Cell.CELL_TYPE_STRING).setCellValue(data.getString("gateway"));
|
|
|
|
|
row.createCell(19, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail"));
|
|
|
|
|
row.createCell(20, Cell.CELL_TYPE_STRING).setCellValue(data.getString("dev_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -745,110 +742,112 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
logger.debug("excel The method======= exportExcelNew() start.......................");
|
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
|
if (transFlow.getJSONArray("data").size() > 0) {
|
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
|
// 声明一个工作薄
|
|
|
|
|
// 生成一个表格
|
|
|
|
|
HSSFSheet sheet = workbook.createSheet("trans_excel");
|
|
|
|
|
// 设置表格默认列宽度为15个字节
|
|
|
|
|
sheet.setDefaultColumnWidth((short) 40);
|
|
|
|
|
// 生成一个样式
|
|
|
|
|
HSSFCellStyle style = workbook.createCellStyle();
|
|
|
|
|
// 设置这些样式
|
|
|
|
|
style.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
|
|
|
|
|
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font = workbook.createFont();
|
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
|
font.setFontHeightInPoints((short) 16);
|
|
|
|
|
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
|
style.setFont(font);
|
|
|
|
|
|
|
|
|
|
HSSFCellStyle style2 = workbook.createCellStyle();
|
|
|
|
|
// 设置这些样式
|
|
|
|
|
style2.setFillForegroundColor(HSSFColor.WHITE.index);
|
|
|
|
|
style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
|
|
style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font2 = workbook.createFont();
|
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
|
font2.setFontHeightInPoints((short) 12);
|
|
|
|
|
font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
|
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
|
style2.setFont(font2);
|
|
|
|
|
HSSFRow row0 = sheet.createRow(0);
|
|
|
|
|
HSSFCell cell00 = row0.createCell(0);
|
|
|
|
|
HSSFCell cell01 = row0.createCell(1);
|
|
|
|
|
HSSFCell cell02 = row0.createCell(2);
|
|
|
|
|
HSSFCell cell03 = row0.createCell(3);
|
|
|
|
|
HSSFCell cell04 = row0.createCell(4);
|
|
|
|
|
cell00.setCellStyle(style);
|
|
|
|
|
cell01.setCellStyle(style);
|
|
|
|
|
cell02.setCellStyle(style);
|
|
|
|
|
cell03.setCellStyle(style);
|
|
|
|
|
cell04.setCellStyle(style);
|
|
|
|
|
HSSFRichTextString text00 = new HSSFRichTextString("Data/Time");
|
|
|
|
|
HSSFRichTextString text01 = new HSSFRichTextString("Description");
|
|
|
|
|
HSSFRichTextString text02 = new HSSFRichTextString("Debit");
|
|
|
|
|
HSSFRichTextString text03 = new HSSFRichTextString("Credit");
|
|
|
|
|
HSSFRichTextString text04 = new HSSFRichTextString("Remark");
|
|
|
|
|
cell00.setCellValue(text00);
|
|
|
|
|
cell01.setCellValue(text01);
|
|
|
|
|
cell02.setCellValue(text02);
|
|
|
|
|
cell03.setCellValue(text03);
|
|
|
|
|
cell04.setCellValue(text04);
|
|
|
|
|
for (int i = 0; i < dataList.size(); i++) {
|
|
|
|
|
HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
|
HSSFCell cell0 = row.createCell(0);
|
|
|
|
|
HSSFCell cell1 = row.createCell(1);
|
|
|
|
|
HSSFCell cell2 = row.createCell(2);
|
|
|
|
|
HSSFCell cell3 = row.createCell(3);
|
|
|
|
|
HSSFCell cell4 = row.createCell(4);
|
|
|
|
|
cell0.setCellStyle(style2);
|
|
|
|
|
cell1.setCellStyle(style2);
|
|
|
|
|
cell2.setCellStyle(style2);
|
|
|
|
|
cell3.setCellStyle(style2);
|
|
|
|
|
cell4.setCellStyle(style2);
|
|
|
|
|
HSSFRichTextString text0 = new HSSFRichTextString(dataList.get(i).getString("transaction_time"));
|
|
|
|
|
HSSFRichTextString text1 = new HSSFRichTextString(dataList.get(i).getString("order_id2"));
|
|
|
|
|
String debit = dataList.get(i).getString("transaction_type").equals("Debit") ? dataList.get(i).getBigDecimal("clearing_amount").toString()
|
|
|
|
|
: "-";
|
|
|
|
|
HSSFRichTextString text2 = new HSSFRichTextString(debit);
|
|
|
|
|
String credit = dataList.get(i).getString("transaction_type").equals("Credit") ? dataList.get(i).getBigDecimal("clearing_amount").toString()
|
|
|
|
|
: "-";
|
|
|
|
|
HSSFRichTextString text3 = new HSSFRichTextString(credit);
|
|
|
|
|
HSSFRichTextString text4 = new HSSFRichTextString(dataList.get(i).getString("order_detail"));
|
|
|
|
|
cell0.setCellValue(text0);
|
|
|
|
|
cell1.setCellValue(text1);
|
|
|
|
|
cell2.setCellValue(text2);
|
|
|
|
|
cell3.setCellValue(text3);
|
|
|
|
|
cell4.setCellValue(text4);
|
|
|
|
|
}
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : "");
|
|
|
|
|
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
|
|
|
|
parmerters.put("partnerCode", client.getString("client_moniker"));
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
|
|
|
|
|
: (parmerters.getString("dateFrom") + "~" + parmerters.getString("dateTo"));
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
|
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
|
List<JSONObject> dataList = transFlow.getJSONArray("data").toJavaList(JSONObject.class);
|
|
|
|
|
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
|
|
|
|
// 声明一个工作薄
|
|
|
|
|
// 生成一个表格
|
|
|
|
|
HSSFSheet sheet = workbook.createSheet("trans_excel");
|
|
|
|
|
// 设置表格默认列宽度为15个字节
|
|
|
|
|
sheet.setDefaultColumnWidth((short) 40);
|
|
|
|
|
// 生成一个样式
|
|
|
|
|
HSSFCellStyle style = workbook.createCellStyle();
|
|
|
|
|
// 设置这些样式
|
|
|
|
|
style.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
|
|
|
|
|
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style.setBorderBottom(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderLeft(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderRight(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderTop(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font = workbook.createFont();
|
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
|
font.setFontHeightInPoints((short) 16);
|
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
|
style.setFont(font);
|
|
|
|
|
|
|
|
|
|
HSSFCellStyle style2 = workbook.createCellStyle();
|
|
|
|
|
// 设置这些样式
|
|
|
|
|
style2.setFillForegroundColor(HSSFColor.WHITE.index);
|
|
|
|
|
style2.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style2.setBorderBottom(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderLeft(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderRight(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderTop(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font2 = workbook.createFont();
|
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
|
font2.setFontHeightInPoints((short) 12);
|
|
|
|
|
font2.setBoldweight(Font.BOLDWEIGHT_NORMAL);
|
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
|
style2.setFont(font2);
|
|
|
|
|
HSSFRow row0 = sheet.createRow(0);
|
|
|
|
|
HSSFCell cell00 = row0.createCell(0);
|
|
|
|
|
HSSFCell cell01 = row0.createCell(1);
|
|
|
|
|
HSSFCell cell02 = row0.createCell(2);
|
|
|
|
|
HSSFCell cell03 = row0.createCell(3);
|
|
|
|
|
HSSFCell cell04 = row0.createCell(4);
|
|
|
|
|
cell00.setCellStyle(style);
|
|
|
|
|
cell01.setCellStyle(style);
|
|
|
|
|
cell02.setCellStyle(style);
|
|
|
|
|
cell03.setCellStyle(style);
|
|
|
|
|
cell04.setCellStyle(style);
|
|
|
|
|
HSSFRichTextString text00 = new HSSFRichTextString("Data/Time");
|
|
|
|
|
HSSFRichTextString text01 = new HSSFRichTextString("Description");
|
|
|
|
|
HSSFRichTextString text02 = new HSSFRichTextString("Debit");
|
|
|
|
|
HSSFRichTextString text03 = new HSSFRichTextString("Credit");
|
|
|
|
|
HSSFRichTextString text04 = new HSSFRichTextString("Remark");
|
|
|
|
|
cell00.setCellValue(text00);
|
|
|
|
|
cell01.setCellValue(text01);
|
|
|
|
|
cell02.setCellValue(text02);
|
|
|
|
|
cell03.setCellValue(text03);
|
|
|
|
|
cell04.setCellValue(text04);
|
|
|
|
|
for (int i = 0; i < dataList.size(); i++) {
|
|
|
|
|
HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
|
HSSFCell cell0 = row.createCell(0);
|
|
|
|
|
HSSFCell cell1 = row.createCell(1);
|
|
|
|
|
HSSFCell cell2 = row.createCell(2);
|
|
|
|
|
HSSFCell cell3 = row.createCell(3);
|
|
|
|
|
HSSFCell cell4 = row.createCell(4);
|
|
|
|
|
cell0.setCellStyle(style2);
|
|
|
|
|
cell1.setCellStyle(style2);
|
|
|
|
|
cell2.setCellStyle(style2);
|
|
|
|
|
cell3.setCellStyle(style2);
|
|
|
|
|
cell4.setCellStyle(style2);
|
|
|
|
|
JSONObject dataItem = dataList.get(i);
|
|
|
|
|
HSSFRichTextString text0 = new HSSFRichTextString(dataItem.getString("transaction_time"));
|
|
|
|
|
HSSFRichTextString text1 = new HSSFRichTextString(dataItem.getString("order_id2"));
|
|
|
|
|
String debit = dataItem.getString("transaction_type").equals("Debit") ? dataItem.getBigDecimal("clearing_amount").toString()
|
|
|
|
|
: "-";
|
|
|
|
|
HSSFRichTextString text2 = new HSSFRichTextString(debit);
|
|
|
|
|
String credit = dataItem.getString("transaction_type").equals("Credit") ? dataItem.getBigDecimal("clearing_amount").toString()
|
|
|
|
|
: "-";
|
|
|
|
|
HSSFRichTextString text3 = new HSSFRichTextString(credit);
|
|
|
|
|
HSSFRichTextString text4 = new HSSFRichTextString(dataItem.getString("order_detail"));
|
|
|
|
|
cell0.setCellValue(text0);
|
|
|
|
|
cell1.setCellValue(text1);
|
|
|
|
|
cell2.setCellValue(text2);
|
|
|
|
|
cell3.setCellValue(text3);
|
|
|
|
|
cell4.setCellValue(text4);
|
|
|
|
|
}
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : "");
|
|
|
|
|
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
|
|
|
|
parmerters.put("partnerCode", client.getString("client_moniker"));
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
|
|
|
|
|
: (parmerters.getString("dateFrom") + "~" + parmerters.getString("dateTo"));
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
|
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
outputStream.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
try {
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
outputStream.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -862,10 +861,10 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject listSettlementLog(TradeLogQuery query, JSONObject partner) {
|
|
|
|
|
int client_id = partner.getIntValue("client_id");
|
|
|
|
|
int clientId = partner.getIntValue("client_id");
|
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
|
params.put("client_id", clientId);
|
|
|
|
|
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
|
|
|
|
|
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
|
|
|
|
|
JSONObject result = PageListUtils.buildPageListResult(logs);
|
|
|
|
@ -873,13 +872,13 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
if (query.getPage() == 1) {
|
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
|
JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id"));
|
|
|
|
|
if (clearingDetail!=null){
|
|
|
|
|
if (clearingDetail != null) {
|
|
|
|
|
JSONObject clearingLog = clearingLogMapper.findById(clearingDetail.getIntValue("clearing_id"));
|
|
|
|
|
|
|
|
|
|
if(clearingLog.getBooleanValue("editable")){
|
|
|
|
|
if (clearingLog.getBooleanValue("editable")) {
|
|
|
|
|
result.put("padding", true);
|
|
|
|
|
logs.get(0).put("padding",true);
|
|
|
|
|
logger.info("##editable"+clearingLog.getBooleanValue("editable"));
|
|
|
|
|
logs.get(0).put("padding", true);
|
|
|
|
|
logger.info("##editable{}", clearingLog.getBooleanValue("editable"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -889,8 +888,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Double getClientUnClearedAmount(JSONObject partner) {
|
|
|
|
|
Double unCleared = transactionMapper.getClientUnClearedAmount(partner.getIntValue("client_id"));
|
|
|
|
|
return unCleared;
|
|
|
|
|
return transactionMapper.getClientUnClearedAmount(partner.getIntValue("client_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static JSONObject tunnel() {
|
|
|
|
@ -1104,11 +1102,11 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
clearings.addAll(mpPaymentApi.settlementLogs(from, to, mch.getMerchantId()));
|
|
|
|
|
}
|
|
|
|
|
for (SettlementLog clear : clearings) {
|
|
|
|
|
JSONObject date_params = new JSONObject();
|
|
|
|
|
date_params.put("from", clear.getStart());
|
|
|
|
|
date_params.put("to", clear.getEnd());
|
|
|
|
|
date_params.put("clearing_date", clear.getSettlementDate());
|
|
|
|
|
List<JSONObject> oneClear = transactionMapper.getMerchantAmount(date_params);
|
|
|
|
|
JSONObject dateParams = new JSONObject();
|
|
|
|
|
dateParams.put("from", clear.getStart());
|
|
|
|
|
dateParams.put("to", clear.getEnd());
|
|
|
|
|
dateParams.put("clearing_date", clear.getSettlementDate());
|
|
|
|
|
List<JSONObject> oneClear = transactionMapper.getMerchantAmount(dateParams);
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
for (JSONObject clientClear : oneClear) {
|
|
|
|
|
// JSONObject params = new JSONObject();
|
|
|
|
@ -1121,7 +1119,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
austracDataMapper.delete(clientClear.getIntValue("client_id"), clientClear.getDate("clearing_time"));
|
|
|
|
|
BigDecimal lastTransTotal = austracDataMapper.getClientLastTransactionTotal(clientClear.getIntValue("client_id"),
|
|
|
|
|
clientClear.getDate("clearing_time"));
|
|
|
|
|
clientClear.put("clearing_amount", clientClear.getBigDecimal("clearing_amount").setScale(0, BigDecimal.ROUND_DOWN));
|
|
|
|
|
clientClear.put("clearing_amount", clientClear.getBigDecimal("clearing_amount").setScale(0, RoundingMode.DOWN));
|
|
|
|
|
if (lastTransTotal != null && lastTransTotal.compareTo(new BigDecimal(0)) < 0) {
|
|
|
|
|
clientClear.put("clearing_amount", clientClear.getBigDecimal("clearing_amount").add(lastTransTotal));
|
|
|
|
|
}
|
|
|
|
@ -1132,8 +1130,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
clientClear.put("bank_settlement_data", clear.getBankSettlementDate());
|
|
|
|
|
austracDataMapper.save(clientClear);
|
|
|
|
|
}
|
|
|
|
|
JSONObject fee = transactionMapper.getSumMerchantAmount(date_params);
|
|
|
|
|
fee.put("clearing_amount", clear.getSettlementFee().subtract(fee.getBigDecimal("clearing_amount")).setScale(0, BigDecimal.ROUND_DOWN));
|
|
|
|
|
JSONObject fee = transactionMapper.getSumMerchantAmount(dateParams);
|
|
|
|
|
fee.put("clearing_amount", clear.getSettlementFee().subtract(fee.getBigDecimal("clearing_amount")).setScale(0, RoundingMode.DOWN));
|
|
|
|
|
fee.put("clearing_time", clear.getSettlementDate());
|
|
|
|
|
fee.put("order_time", clear.getSettlementDate());
|
|
|
|
|
fee.put("create_time", now);
|
|
|
|
@ -1164,7 +1162,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
params.put("client_id", client.getIntValue("client_id"));
|
|
|
|
|
List<JSONObject> logs = orderMapper.listOrdersByClientsNoPages(params);
|
|
|
|
|
|
|
|
|
|
if (null != logs && logs.size() > 0) {
|
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
|
int count = 0;
|
|
|
|
|
for (JSONObject object : logs) {
|
|
|
|
|
if (object.getIntValue("clearing_status") == 2 && object.getIntValue("client_id") == client.getIntValue("client_id")) {
|
|
|
|
@ -1198,27 +1196,23 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) {
|
|
|
|
|
String begin = query.getDatefrom() == null ?"":query.getDatefrom();
|
|
|
|
|
String end = query.getDateto() == null ?"":query.getDateto();
|
|
|
|
|
String begin = query.getDatefrom() == null ? "" : query.getDatefrom();
|
|
|
|
|
String end = query.getDateto() == null ? "" : query.getDateto();
|
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
if (params.get("client_ids") == null) {
|
|
|
|
|
params.put("client_id",partner.getJSONObject("client").getString("client_id"));
|
|
|
|
|
params.put("client_id", partner.getJSONObject("client").getString("client_id"));
|
|
|
|
|
}
|
|
|
|
|
List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
|
|
|
|
|
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
|
|
|
|
|
clientOrderList.parallelStream().forEach(p->{
|
|
|
|
|
clientOrders.add(p.getInteger("clearing_order"));
|
|
|
|
|
});
|
|
|
|
|
clientOrderList.parallelStream().forEach(p -> clientOrders.add(p.getInteger("clearing_order")));
|
|
|
|
|
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders);
|
|
|
|
|
OutputStream ous = null;
|
|
|
|
|
try {
|
|
|
|
|
try (OutputStream ous = resp.getOutputStream();
|
|
|
|
|
Workbook wb = new XSSFWorkbook()) {
|
|
|
|
|
JSONObject clearDetailTotal = transactionMapper.getClearDetailTotal(params);
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
|
"attachment; filename=" + "Merchant_Settlement_Info_" + begin + "_" + end + ".xlsx");
|
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
Cell cell = null;
|
|
|
|
|
Font font = wb.createFont();
|
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
@ -1229,7 +1223,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
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", "Dev No","Company Name","Short Name","Settment Date"};
|
|
|
|
|
"Input Amount", "Total Amount", "Clearing Amount", "Sruchange Rate", "Settle Amount", "Surcharge", "GST", "Remark", "Dev No", "Company Name", "Short Name", "Settlement Date"};
|
|
|
|
|
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]);
|
|
|
|
@ -1251,26 +1245,30 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
} else {
|
|
|
|
|
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue("-");
|
|
|
|
|
}
|
|
|
|
|
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, BigDecimal.ROUND_DOWN).toPlainString());
|
|
|
|
|
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, RoundingMode.DOWN).toPlainString());
|
|
|
|
|
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_type"));
|
|
|
|
|
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_currency"));
|
|
|
|
|
row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("display_amount") == null ? ""
|
|
|
|
|
: settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
|
|
|
|
: settle.getBigDecimal("display_amount").setScale(2, RoundingMode.DOWN).toPlainString());
|
|
|
|
|
row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("transaction_amount") == null ? ""
|
|
|
|
|
: settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
|
|
|
|
: settle.getBigDecimal("transaction_amount").setScale(2, RoundingMode.DOWN).toPlainString());
|
|
|
|
|
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("clearing_amount") == null ? ""
|
|
|
|
|
: settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
|
|
|
|
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("rate") == null? "": settle.getBigDecimal("rate").toPlainString() + "%");
|
|
|
|
|
: settle.getBigDecimal("clearing_amount").setScale(2, RoundingMode.DOWN).toPlainString());
|
|
|
|
|
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("rate") == null ? "" : settle.getBigDecimal("rate").toPlainString() + "%");
|
|
|
|
|
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("settle_amount") == null ? ""
|
|
|
|
|
: settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("remark"));
|
|
|
|
|
: settle.getBigDecimal("settle_amount").setScale(2, RoundingMode.DOWN).toPlainString());
|
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("total_surcharge") == null ? ""
|
|
|
|
|
: settle.getBigDecimal("total_surcharge").setScale(2, RoundingMode.DOWN).toPlainString());
|
|
|
|
|
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("tax_amount") == null ? ""
|
|
|
|
|
: settle.getBigDecimal("tax_amount").setScale(2, RoundingMode.DOWN).toPlainString());
|
|
|
|
|
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("remark"));
|
|
|
|
|
device = clientDeviceMapper.find(settle.getString("dev_id"));
|
|
|
|
|
if (device != null)
|
|
|
|
|
clientDevId = device.getString("client_dev_id");
|
|
|
|
|
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(clientDevId);
|
|
|
|
|
row.createCell(15,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("company_name"));
|
|
|
|
|
row.createCell(16,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("short_name"));
|
|
|
|
|
row.createCell(17,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("settle_date"));
|
|
|
|
|
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(clientDevId);
|
|
|
|
|
row.createCell(17, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("company_name"));
|
|
|
|
|
row.createCell(18, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("short_name"));
|
|
|
|
|
row.createCell(19, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("settle_date"));
|
|
|
|
|
}
|
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
|
for (int i = 0; i < analysis.length; i++) {
|
|
|
|
@ -1289,26 +1287,23 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
ous.flush();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
IOUtils.closeQuietly(ous);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void exportPDFSettlement(TradeLogQuery query, JSONObject partner, HttpServletResponse response) {
|
|
|
|
|
String begin = query.getDatefrom() == null ?"":query.getDatefrom();
|
|
|
|
|
String end = query.getDateto() == null ?"":query.getDateto();
|
|
|
|
|
String begin = query.getDatefrom() == null ? "" : query.getDatefrom();
|
|
|
|
|
String end = query.getDateto() == null ? "" : query.getDateto();
|
|
|
|
|
JSONObject client = partner.getJSONObject("client");
|
|
|
|
|
String timezone = client.getString("timezone");
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
if (params.get("client_ids") == null) {
|
|
|
|
|
params.put("client_id",client.getString("client_id"));
|
|
|
|
|
params.put("client_id", client.getString("client_id"));
|
|
|
|
|
}
|
|
|
|
|
List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
|
|
|
|
|
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
|
|
|
|
|
clientOrderList.parallelStream().forEach(p->{
|
|
|
|
|
clientOrders.add(p.getInteger("clearing_order"));
|
|
|
|
|
});
|
|
|
|
|
clientOrderList.parallelStream().forEach(p -> clientOrders.add(p.getInteger("clearing_order")));
|
|
|
|
|
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders);
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(settlementLogDetailList, timezone, "yyyy-MM-dd HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
|
try {
|
|
|
|
@ -1327,13 +1322,13 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
scaleDecimalVal(item, "settle_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(item, "total_surcharge", platformCurrency);
|
|
|
|
|
scaleDecimalVal(item, "transaction_amount", platformCurrency);
|
|
|
|
|
item.put("exchange_rate", item.getBigDecimal("exchange_rate").setScale(5, BigDecimal.ROUND_DOWN));
|
|
|
|
|
item.put("gateway" , item.getInteger("gateway") == null ? "-" : TradeType.fromGatewayNumber(item.getIntValue("gateway")).getTradeType());
|
|
|
|
|
item.put("rate", item.getBigDecimal("rate") == null? "-": item.getBigDecimal("rate").toPlainString() + "%");
|
|
|
|
|
item.put("exchange_rate", item.getBigDecimal("exchange_rate").setScale(5, RoundingMode.DOWN));
|
|
|
|
|
item.put("gateway", item.getInteger("gateway") == null ? "-" : TradeType.fromGatewayNumber(item.getIntValue("gateway")).getTradeType());
|
|
|
|
|
item.put("rate", item.getBigDecimal("rate") == null ? "-" : item.getBigDecimal("rate").toPlainString() + "%");
|
|
|
|
|
});
|
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(settlementLogDetailList);
|
|
|
|
|
response.setContentType("application/pdf");
|
|
|
|
|
String fileName = partner.getString("client_moniker") + "_" + parmerters.getString("dateRange").replaceAll("/", "");
|
|
|
|
|
String fileName = partner.getString("client_moniker") + "_" + parmerters.getString("dateRange").replace("/", "");
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf");
|
|
|
|
|
OutputStream outs = response.getOutputStream();
|
|
|
|
|
byte[] bytes = JasperRunManager.runReportToPdf(partner_settlement_flow.getInputStream(), parmerters, jrDataSource);
|
|
|
|
@ -1348,92 +1343,105 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
@Override
|
|
|
|
|
public void exportExcelAllPartner(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
|
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
|
int client_id = partner.getIntValue("client_id");
|
|
|
|
|
int clientId1 = partner.getIntValue("client_id");
|
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
clientManager.validateClients(client_id, params);
|
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
|
clientManager.validateClients(clientId1, params);
|
|
|
|
|
params.put("client_id", clientId1);
|
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlow(params);
|
|
|
|
|
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
|
if (logs.size() > 0) {
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Collections.singletonList("transaction_time"));
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, TimeZone.getDefault().getID(), "dd/MM/yyyy", Collections.singletonList("clearing_time"));
|
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
|
OutputStream ous = null;
|
|
|
|
|
String transType;
|
|
|
|
|
int status;
|
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
|
Font font = wb.createFont();
|
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
|
font.setFontHeightInPoints((short) 10);
|
|
|
|
|
CellStyle analysisStyle = wb.createCellStyle();
|
|
|
|
|
analysisStyle.setFont(font);
|
|
|
|
|
String[] clientIds = query.getClient_ids();
|
|
|
|
|
List<String> clientIdList = new ArrayList<>();
|
|
|
|
|
clientIdList.add("ALL");
|
|
|
|
|
if (clientIds.length >= 2) {
|
|
|
|
|
clientIdList.addAll(Arrays.asList(clientIds));
|
|
|
|
|
}
|
|
|
|
|
HSSFSheet sheet = null;
|
|
|
|
|
JSONObject client = null;
|
|
|
|
|
JSONObject device = null;
|
|
|
|
|
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
|
|
|
|
|
for (String clientId : clientIdList) {
|
|
|
|
|
if ("ALL".equals(clientId)) {
|
|
|
|
|
sheet = wb.createSheet(clientId);
|
|
|
|
|
} else {
|
|
|
|
|
client = clientManager.getClientInfo(Integer.parseInt(clientId));
|
|
|
|
|
sheet = wb.createSheet(client == null ? clientId : client.getString("client_moniker"));
|
|
|
|
|
}
|
|
|
|
|
int rowNum = 0;
|
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
|
String[] title = {"Transaction Time", "Client Order ID", "System Order ID", "Client Moniker", "Short Name", "Order ID", "Channel", "Input Amount", "Transaction Amount", "Transaction Currency", "Clearing Amount", "Exchange Rate",
|
|
|
|
|
"Transaction Type", "Clearing Status", "Gateway", "Remark", "Dev No"};
|
|
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
|
|
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
|
|
|
|
|
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
|
|
|
|
Font font = wb.createFont();
|
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
|
font.setFontHeightInPoints((short) 10);
|
|
|
|
|
CellStyle analysisStyle = wb.createCellStyle();
|
|
|
|
|
analysisStyle.setFont(font);
|
|
|
|
|
String[] clientIds = query.getClient_ids();
|
|
|
|
|
List<String> clientIdList = new ArrayList<>();
|
|
|
|
|
clientIdList.add("ALL");
|
|
|
|
|
if (clientIds.length >= 2) {
|
|
|
|
|
clientIdList.addAll(Arrays.asList(clientIds));
|
|
|
|
|
}
|
|
|
|
|
if ("ALL".equals(clientId)) {
|
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
|
String login_id = log.getString("login_id");
|
|
|
|
|
if (StringUtils.isNotEmpty(login_id)) {
|
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : login_id+":"+log.getString("order_detail")));
|
|
|
|
|
}else{
|
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : log.getString("order_detail")));
|
|
|
|
|
}
|
|
|
|
|
transType = log.getString("trans_type");
|
|
|
|
|
if ("refund".equals(transType)) {
|
|
|
|
|
status = log.getIntValue("status");
|
|
|
|
|
if (status == 6)
|
|
|
|
|
transType = "Partly " + transType;
|
|
|
|
|
else if (status == 7) {
|
|
|
|
|
transType = "Fully " + transType;
|
|
|
|
|
HSSFSheet sheet = null;
|
|
|
|
|
JSONObject client = null;
|
|
|
|
|
JSONObject device = null;
|
|
|
|
|
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
|
|
|
|
|
for (String clientId : clientIdList) {
|
|
|
|
|
if ("ALL".equals(clientId)) {
|
|
|
|
|
sheet = wb.createSheet(clientId);
|
|
|
|
|
} else {
|
|
|
|
|
client = clientManager.getClientInfo(Integer.parseInt(clientId));
|
|
|
|
|
sheet = wb.createSheet(client == null ? clientId : client.getString("client_moniker"));
|
|
|
|
|
}
|
|
|
|
|
int rowNum = 0;
|
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
|
String[] title = {"Transaction Time", "Client Order ID", "System Order ID", "Client Moniker", "Short Name",
|
|
|
|
|
"Order ID", "Channel", "Input Amount", "Transaction Amount", "Transaction Currency", "Clearing Amount",
|
|
|
|
|
"Settle Amount", "Surcharge", "GST", "Settle Date", "Exchange Rate",
|
|
|
|
|
"Transaction Type", "Clearing Status", "Gateway", "Remark", "Dev No"};
|
|
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
|
|
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
|
|
|
|
|
}
|
|
|
|
|
if ("ALL".equals(clientId)) {
|
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
|
String login_id = log.getString("login_id");
|
|
|
|
|
if (StringUtils.isNotEmpty(login_id)) {
|
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : login_id + ":" + log.getString("order_detail")));
|
|
|
|
|
} else {
|
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : log.getString("order_detail")));
|
|
|
|
|
}
|
|
|
|
|
transType = log.getString("trans_type");
|
|
|
|
|
if ("refund".equals(transType)) {
|
|
|
|
|
status = log.getIntValue("status");
|
|
|
|
|
if (status == 6)
|
|
|
|
|
transType = "Partly " + transType;
|
|
|
|
|
else if (status == 7) {
|
|
|
|
|
transType = "Fully " + transType;
|
|
|
|
|
}
|
|
|
|
|
log.put("trans_type", transType);
|
|
|
|
|
device = clientDeviceMapper.find(log.getString("order_dev_id"));
|
|
|
|
|
if (device != null)
|
|
|
|
|
log.put("dev_id", device.getString("client_dev_id"));
|
|
|
|
|
}
|
|
|
|
|
log.put("trans_type", transType);
|
|
|
|
|
device = clientDeviceMapper.find(log.getString("order_dev_id"));
|
|
|
|
|
if (device != null)
|
|
|
|
|
log.put("dev_id", device.getString("client_dev_id"));
|
|
|
|
|
scaleDecimalVal(log, "display_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "transaction_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "clearing_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "settle_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "total_surcharge", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "tax_amount", platformCurrency);
|
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
|
excelTrans(row, log);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
List<JSONObject> logsByClientId = logs.stream().filter(log -> log.getString("client_id").equals(clientId)).collect(Collectors.toList());
|
|
|
|
|
for (JSONObject log : logsByClientId) {
|
|
|
|
|
scaleDecimalVal(log, "display_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "transaction_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "clearing_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "settle_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "total_surcharge", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "tax_amount", platformCurrency);
|
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
|
excelTrans(row, log);
|
|
|
|
|
}
|
|
|
|
|
scaleDecimalVal(log, "display_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "transaction_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(log, "clearing_amount", platformCurrency);
|
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
|
excelTrans(row, log);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
List<JSONObject> logsByClientId = logs.stream().filter(log -> log.getString("client_id").equals(clientId)).collect(Collectors.toList());
|
|
|
|
|
for (JSONObject log : logsByClientId) {
|
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
|
excelTrans(row, log);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
|
"attachment; filename=" + query.getDatefrom() + "_" + query.getDateto() + ".xls");
|
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
try {
|
|
|
|
|
wb.write(ous);
|
|
|
|
|
ous.close();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
|
"attachment; filename=" + query.getDatefrom() + "_" + query.getDateto() + ".xls");
|
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
try {
|
|
|
|
|
wb.write(ous);
|
|
|
|
|
ous.close();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|