|
|
@ -65,14 +65,12 @@ import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.io.OutputStream;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.DateFormat;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
@ -461,29 +459,29 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private JSONObject listPartnerTransFlow(TradeLogQuery query, JSONObject partner) throws Exception {
|
|
|
|
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");
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
clientManager.validateClients(client_id, params);
|
|
|
|
clientManager.validateClients(clientId, params);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
params.put("client_id", clientId);
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlow(params);
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlow(params);
|
|
|
|
if (client_id!=1563){
|
|
|
|
if (clientId != 1563) {
|
|
|
|
logs.stream().forEach(p -> {
|
|
|
|
logs.forEach(p -> {
|
|
|
|
String login_id = p.getString("login_id");
|
|
|
|
String loginId = p.getString("login_id");
|
|
|
|
if (StringUtils.isNotEmpty(login_id)) {
|
|
|
|
if (StringUtils.isNotEmpty(loginId)) {
|
|
|
|
p.put("order_detail", (StringUtils.isEmpty(p.getString("order_detail")) ? "" : login_id+":"+p.getString("order_detail")));
|
|
|
|
p.put("order_detail", (StringUtils.isEmpty(p.getString("order_detail")) ? "" : loginId + ":" + p.getString("order_detail")));
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
p.put("order_detail", (StringUtils.isEmpty(p.getString("order_detail")) ? "" : p.getString("order_detail")));
|
|
|
|
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);
|
|
|
|
final JSONObject analysis = analysisTransLogs(logs);
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
result.put("data", logs);
|
|
|
|
result.put("data", logs);
|
|
|
|
// JSONObject analysis = transactionMapper.analysisTransFlow(params);
|
|
|
|
|
|
|
|
analysis.put("balance", transactionMapper.analysisBalance(params));
|
|
|
|
analysis.put("balance", transactionMapper.analysisBalance(params));
|
|
|
|
if (analysis.containsKey("paid_fee") && analysis.containsKey("refund_fee")) {
|
|
|
|
if (analysis.containsKey("paid_fee") && analysis.containsKey("refund_fee")) {
|
|
|
|
analysis.put("actual_fee", analysis.getBigDecimal("paid_fee").add(analysis.getBigDecimal("refund_fee")));
|
|
|
|
analysis.put("actual_fee", analysis.getBigDecimal("paid_fee").add(analysis.getBigDecimal("refund_fee")));
|
|
|
@ -584,13 +582,12 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void exportTransFlow(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
|
|
|
|
public void exportTransFlow(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
|
|
|
|
// File jasperFile = trans_flow.getFile();
|
|
|
|
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
JSONObject analysis = transFlow.getJSONObject("analysis");
|
|
|
|
JSONObject analysis = transFlow.getJSONObject("analysis");
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
List<JSONObject> dataList = transFlow.getJSONArray("data").toJavaList(JSONObject.class);
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom())
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom())
|
|
|
|
? DateFormatUtils.format(DateUtils.parseDate(query.getDatefrom(), "yyyyMMdd"), "dd/MM/yyyy") : "");
|
|
|
|
? DateFormatUtils.format(DateUtils.parseDate(query.getDatefrom(), "yyyyMMdd"), "dd/MM/yyyy") : "");
|
|
|
@ -656,10 +653,9 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
// JSONObject analysis = transFlow.getJSONObject("analysis");
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
if (transFlow.getJSONArray("data").size() > 0) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
List<JSONObject> dataList = transFlow.getJSONArray("data").toJavaList(JSONObject.class);
|
|
|
|
String transType;
|
|
|
|
String transType;
|
|
|
|
JSONObject device;
|
|
|
|
JSONObject device;
|
|
|
|
int status;
|
|
|
|
int status;
|
|
|
@ -683,16 +679,13 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
|
|
|
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
|
|
|
parmerters.put("partnerCode", client.getString("client_moniker"));
|
|
|
|
parmerters.put("partnerCode", client.getString("client_moniker"));
|
|
|
|
// parmerters.put("actual_fee", analysis.containsKey("actual_fee") ?
|
|
|
|
// parmerters.put("actual_fee", analysis.containsKey("actual_fee") ?
|
|
|
|
// analysis.getBigDecimal("actual_fee") : 0);
|
|
|
|
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList);
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList);
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
|
|
|
|
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
|
|
|
|
: (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");
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
JasperPrint jasperPrint = JasperFillManager.fillReport(trans_excel.getInputStream(), parmerters, jrDataSource);
|
|
|
|
JasperPrint jasperPrint = JasperFillManager.fillReport(trans_excel.getInputStream(), parmerters, jrDataSource);
|
|
|
|
// JRXlsExporter exporter = new JRXlsExporter();
|
|
|
|
|
|
|
|
JRXlsxExporter exporter = new JRXlsxExporter();
|
|
|
|
JRXlsxExporter exporter = new JRXlsxExporter();
|
|
|
|
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
|
|
|
|
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
|
|
|
|
exporter.setExporterInput(exporterInput);
|
|
|
|
exporter.setExporterInput(exporterInput);
|
|
|
@ -726,12 +719,16 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_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(9, Cell.CELL_TYPE_STRING).setCellValue(data.getString("currency"));
|
|
|
|
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_amount"));
|
|
|
|
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(11, Cell.CELL_TYPE_STRING).setCellValue(data.getString("settle_amount"));
|
|
|
|
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type"));
|
|
|
|
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(data.getString("total_surcharge"));
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clear_status"));
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(data.getString("tax_amount"));
|
|
|
|
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(data.getString("gateway"));
|
|
|
|
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_time"));
|
|
|
|
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail"));
|
|
|
|
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("dev_id"));
|
|
|
|
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
|
|
|
|
@Override
|
|
|
@ -739,9 +736,9 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
logger.debug("excel The method======= exportExcelNew() start.......................");
|
|
|
|
logger.debug("excel The method======= exportExcelNew() start.......................");
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
JSONObject client = clientManager.getClientInfo(Integer.parseInt(query.getClient_ids()[0]));
|
|
|
|
if (transFlow.getJSONArray("data").size() > 0) {
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
List<JSONObject> dataList = transFlow.getJSONArray("data").toJavaList(JSONObject.class);
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
|
|
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
|
|
|
// 声明一个工作薄
|
|
|
|
// 声明一个工作薄
|
|
|
|
// 生成一个表格
|
|
|
|
// 生成一个表格
|
|
|
|
HSSFSheet sheet = workbook.createSheet("trans_excel");
|
|
|
|
HSSFSheet sheet = workbook.createSheet("trans_excel");
|
|
|
@ -751,32 +748,32 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
HSSFCellStyle style = workbook.createCellStyle();
|
|
|
|
HSSFCellStyle style = workbook.createCellStyle();
|
|
|
|
// 设置这些样式
|
|
|
|
// 设置这些样式
|
|
|
|
style.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
|
|
|
|
style.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
|
|
|
|
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
|
|
|
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style.setBorderBottom(CellStyle.BORDER_THIN);
|
|
|
|
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style.setBorderLeft(CellStyle.BORDER_THIN);
|
|
|
|
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style.setBorderRight(CellStyle.BORDER_THIN);
|
|
|
|
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style.setBorderTop(CellStyle.BORDER_THIN);
|
|
|
|
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
style.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
HSSFFont font = workbook.createFont();
|
|
|
|
HSSFFont font = workbook.createFont();
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
font.setFontHeightInPoints((short) 16);
|
|
|
|
font.setFontHeightInPoints((short) 16);
|
|
|
|
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
style.setFont(font);
|
|
|
|
style.setFont(font);
|
|
|
|
|
|
|
|
|
|
|
|
HSSFCellStyle style2 = workbook.createCellStyle();
|
|
|
|
HSSFCellStyle style2 = workbook.createCellStyle();
|
|
|
|
// 设置这些样式
|
|
|
|
// 设置这些样式
|
|
|
|
style2.setFillForegroundColor(HSSFColor.WHITE.index);
|
|
|
|
style2.setFillForegroundColor(HSSFColor.WHITE.index);
|
|
|
|
style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
|
|
|
|
style2.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style2.setBorderBottom(CellStyle.BORDER_THIN);
|
|
|
|
style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style2.setBorderLeft(CellStyle.BORDER_THIN);
|
|
|
|
style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style2.setBorderRight(CellStyle.BORDER_THIN);
|
|
|
|
style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
|
|
|
|
style2.setBorderTop(CellStyle.BORDER_THIN);
|
|
|
|
style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
|
|
|
|
style2.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
HSSFFont font2 = workbook.createFont();
|
|
|
|
HSSFFont font2 = workbook.createFont();
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
font2.setFontHeightInPoints((short) 12);
|
|
|
|
font2.setFontHeightInPoints((short) 12);
|
|
|
|
font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);
|
|
|
|
font2.setBoldweight(Font.BOLDWEIGHT_NORMAL);
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
style2.setFont(font2);
|
|
|
|
style2.setFont(font2);
|
|
|
|
HSSFRow row0 = sheet.createRow(0);
|
|
|
|
HSSFRow row0 = sheet.createRow(0);
|
|
|
@ -812,15 +809,16 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
cell2.setCellStyle(style2);
|
|
|
|
cell2.setCellStyle(style2);
|
|
|
|
cell3.setCellStyle(style2);
|
|
|
|
cell3.setCellStyle(style2);
|
|
|
|
cell4.setCellStyle(style2);
|
|
|
|
cell4.setCellStyle(style2);
|
|
|
|
HSSFRichTextString text0 = new HSSFRichTextString(dataList.get(i).getString("transaction_time"));
|
|
|
|
JSONObject dataItem = dataList.get(i);
|
|
|
|
HSSFRichTextString text1 = new HSSFRichTextString(dataList.get(i).getString("order_id2"));
|
|
|
|
HSSFRichTextString text0 = new HSSFRichTextString(dataItem.getString("transaction_time"));
|
|
|
|
String debit = dataList.get(i).getString("transaction_type").equals("Debit") ? dataList.get(i).getBigDecimal("clearing_amount").toString()
|
|
|
|
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);
|
|
|
|
HSSFRichTextString text2 = new HSSFRichTextString(debit);
|
|
|
|
String credit = dataList.get(i).getString("transaction_type").equals("Credit") ? dataList.get(i).getBigDecimal("clearing_amount").toString()
|
|
|
|
String credit = dataItem.getString("transaction_type").equals("Credit") ? dataItem.getBigDecimal("clearing_amount").toString()
|
|
|
|
: "-";
|
|
|
|
: "-";
|
|
|
|
HSSFRichTextString text3 = new HSSFRichTextString(credit);
|
|
|
|
HSSFRichTextString text3 = new HSSFRichTextString(credit);
|
|
|
|
HSSFRichTextString text4 = new HSSFRichTextString(dataList.get(i).getString("order_detail"));
|
|
|
|
HSSFRichTextString text4 = new HSSFRichTextString(dataItem.getString("order_detail"));
|
|
|
|
cell0.setCellValue(text0);
|
|
|
|
cell0.setCellValue(text0);
|
|
|
|
cell1.setCellValue(text1);
|
|
|
|
cell1.setCellValue(text1);
|
|
|
|
cell2.setCellValue(text2);
|
|
|
|
cell2.setCellValue(text2);
|
|
|
@ -845,6 +843,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -856,10 +855,10 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject listSettlementLog(TradeLogQuery query, JSONObject partner) {
|
|
|
|
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");
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
params.put("client_id", clientId);
|
|
|
|
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
|
|
|
|
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
|
|
|
|
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
|
|
|
|
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
|
|
|
|
JSONObject result = PageListUtils.buildPageListResult(logs);
|
|
|
|
JSONObject result = PageListUtils.buildPageListResult(logs);
|
|
|
@ -867,13 +866,13 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
if (query.getPage() == 1) {
|
|
|
|
if (query.getPage() == 1) {
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
JSONObject clearingDetail = clearingDetailMapper.findByDetailId(logs.get(0).getIntValue("clear_detail_id"));
|
|
|
|
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"));
|
|
|
|
JSONObject clearingLog = clearingLogMapper.findById(clearingDetail.getIntValue("clearing_id"));
|
|
|
|
|
|
|
|
|
|
|
|
if(clearingLog.getBooleanValue("editable")){
|
|
|
|
if (clearingLog.getBooleanValue("editable")) {
|
|
|
|
result.put("padding", true);
|
|
|
|
result.put("padding", true);
|
|
|
|
logs.get(0).put("padding",true);
|
|
|
|
logs.get(0).put("padding", true);
|
|
|
|
logger.info("##editable"+clearingLog.getBooleanValue("editable"));
|
|
|
|
logger.info("##editable{}", clearingLog.getBooleanValue("editable"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -883,8 +882,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Double getClientUnClearedAmount(JSONObject partner) {
|
|
|
|
public Double getClientUnClearedAmount(JSONObject partner) {
|
|
|
|
Double unCleared = transactionMapper.getClientUnClearedAmount(partner.getIntValue("client_id"));
|
|
|
|
return transactionMapper.getClientUnClearedAmount(partner.getIntValue("client_id"));
|
|
|
|
return unCleared;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static JSONObject tunnel() {
|
|
|
|
public static JSONObject tunnel() {
|
|
|
@ -1098,11 +1096,11 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
clearings.addAll(mpPaymentApi.settlementLogs(from, to, mch.getMerchantId()));
|
|
|
|
clearings.addAll(mpPaymentApi.settlementLogs(from, to, mch.getMerchantId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (SettlementLog clear : clearings) {
|
|
|
|
for (SettlementLog clear : clearings) {
|
|
|
|
JSONObject date_params = new JSONObject();
|
|
|
|
JSONObject dateParams = new JSONObject();
|
|
|
|
date_params.put("from", clear.getStart());
|
|
|
|
dateParams.put("from", clear.getStart());
|
|
|
|
date_params.put("to", clear.getEnd());
|
|
|
|
dateParams.put("to", clear.getEnd());
|
|
|
|
date_params.put("clearing_date", clear.getSettlementDate());
|
|
|
|
dateParams.put("clearing_date", clear.getSettlementDate());
|
|
|
|
List<JSONObject> oneClear = transactionMapper.getMerchantAmount(date_params);
|
|
|
|
List<JSONObject> oneClear = transactionMapper.getMerchantAmount(dateParams);
|
|
|
|
Date now = new Date();
|
|
|
|
Date now = new Date();
|
|
|
|
for (JSONObject clientClear : oneClear) {
|
|
|
|
for (JSONObject clientClear : oneClear) {
|
|
|
|
// JSONObject params = new JSONObject();
|
|
|
|
// JSONObject params = new JSONObject();
|
|
|
@ -1115,7 +1113,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
austracDataMapper.delete(clientClear.getIntValue("client_id"), clientClear.getDate("clearing_time"));
|
|
|
|
austracDataMapper.delete(clientClear.getIntValue("client_id"), clientClear.getDate("clearing_time"));
|
|
|
|
BigDecimal lastTransTotal = austracDataMapper.getClientLastTransactionTotal(clientClear.getIntValue("client_id"),
|
|
|
|
BigDecimal lastTransTotal = austracDataMapper.getClientLastTransactionTotal(clientClear.getIntValue("client_id"),
|
|
|
|
clientClear.getDate("clearing_time"));
|
|
|
|
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) {
|
|
|
|
if (lastTransTotal != null && lastTransTotal.compareTo(new BigDecimal(0)) < 0) {
|
|
|
|
clientClear.put("clearing_amount", clientClear.getBigDecimal("clearing_amount").add(lastTransTotal));
|
|
|
|
clientClear.put("clearing_amount", clientClear.getBigDecimal("clearing_amount").add(lastTransTotal));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1126,8 +1124,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
clientClear.put("bank_settlement_data", clear.getBankSettlementDate());
|
|
|
|
clientClear.put("bank_settlement_data", clear.getBankSettlementDate());
|
|
|
|
austracDataMapper.save(clientClear);
|
|
|
|
austracDataMapper.save(clientClear);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject fee = transactionMapper.getSumMerchantAmount(date_params);
|
|
|
|
JSONObject fee = transactionMapper.getSumMerchantAmount(dateParams);
|
|
|
|
fee.put("clearing_amount", clear.getSettlementFee().subtract(fee.getBigDecimal("clearing_amount")).setScale(0, BigDecimal.ROUND_DOWN));
|
|
|
|
fee.put("clearing_amount", clear.getSettlementFee().subtract(fee.getBigDecimal("clearing_amount")).setScale(0, RoundingMode.DOWN));
|
|
|
|
fee.put("clearing_time", clear.getSettlementDate());
|
|
|
|
fee.put("clearing_time", clear.getSettlementDate());
|
|
|
|
fee.put("order_time", clear.getSettlementDate());
|
|
|
|
fee.put("order_time", clear.getSettlementDate());
|
|
|
|
fee.put("create_time", now);
|
|
|
|
fee.put("create_time", now);
|
|
|
@ -1158,7 +1156,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
params.put("client_id", client.getIntValue("client_id"));
|
|
|
|
params.put("client_id", client.getIntValue("client_id"));
|
|
|
|
List<JSONObject> logs = orderMapper.listOrdersByClientsNoPages(params);
|
|
|
|
List<JSONObject> logs = orderMapper.listOrdersByClientsNoPages(params);
|
|
|
|
|
|
|
|
|
|
|
|
if (null != logs && logs.size() > 0) {
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
for (JSONObject object : logs) {
|
|
|
|
for (JSONObject object : logs) {
|
|
|
|
if (object.getIntValue("clearing_status") == 2 && object.getIntValue("client_id") == client.getIntValue("client_id")) {
|
|
|
|
if (object.getIntValue("clearing_status") == 2 && object.getIntValue("client_id") == client.getIntValue("client_id")) {
|
|
|
@ -1192,27 +1190,23 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) {
|
|
|
|
public void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) {
|
|
|
|
String begin = query.getDatefrom() == null ?"":query.getDatefrom();
|
|
|
|
String begin = query.getDatefrom() == null ? "" : query.getDatefrom();
|
|
|
|
String end = query.getDateto() == null ?"":query.getDateto();
|
|
|
|
String end = query.getDateto() == null ? "" : query.getDateto();
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
if (params.get("client_ids") == null) {
|
|
|
|
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<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
|
|
|
|
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
|
|
|
|
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
|
|
|
|
clientOrderList.parallelStream().forEach(p->{
|
|
|
|
clientOrderList.parallelStream().forEach(p -> clientOrders.add(p.getInteger("clearing_order")));
|
|
|
|
clientOrders.add(p.getInteger("clearing_order"));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders);
|
|
|
|
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders);
|
|
|
|
OutputStream ous = null;
|
|
|
|
try (OutputStream ous = resp.getOutputStream();
|
|
|
|
try {
|
|
|
|
Workbook wb = new XSSFWorkbook()) {
|
|
|
|
JSONObject clearDetailTotal = transactionMapper.getClearDetailTotal(params);
|
|
|
|
JSONObject clearDetailTotal = transactionMapper.getClearDetailTotal(params);
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
"attachment; filename=" + "Merchant_Settlement_Info_" + begin + "_" + end + ".xlsx");
|
|
|
|
"attachment; filename=" + "Merchant_Settlement_Info_" + begin + "_" + end + ".xlsx");
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
|
|
|
Cell cell = null;
|
|
|
|
Cell cell = null;
|
|
|
|
Font font = wb.createFont();
|
|
|
|
Font font = wb.createFont();
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
@ -1223,7 +1217,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
int rowNum = 0;
|
|
|
|
int rowNum = 0;
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
|
|
|
|
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"};
|
|
|
|
String[] analysis = {"Total Credit", "Total Debit", "Gross Amount", "Total Charge", "Net Amount"};
|
|
|
|
for (int i = 0; i < title.length; i++) {
|
|
|
|
for (int i = 0; i < title.length; i++) {
|
|
|
|
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
|
|
|
|
row.createCell(i, Cell.CELL_TYPE_STRING).setCellValue(title[i]);
|
|
|
@ -1245,26 +1239,30 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue("-");
|
|
|
|
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(6, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_type"));
|
|
|
|
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_currency"));
|
|
|
|
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 ? ""
|
|
|
|
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 ? ""
|
|
|
|
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 ? ""
|
|
|
|
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("clearing_amount") == null ? ""
|
|
|
|
: settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).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(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 ? ""
|
|
|
|
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("settle_amount") == null ? ""
|
|
|
|
: settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
|
|
|
|
: settle.getBigDecimal("settle_amount").setScale(2, RoundingMode.DOWN).toPlainString());
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("remark"));
|
|
|
|
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"));
|
|
|
|
device = clientDeviceMapper.find(settle.getString("dev_id"));
|
|
|
|
if (device != null)
|
|
|
|
if (device != null)
|
|
|
|
clientDevId = device.getString("client_dev_id");
|
|
|
|
clientDevId = device.getString("client_dev_id");
|
|
|
|
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(clientDevId);
|
|
|
|
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(clientDevId);
|
|
|
|
row.createCell(15,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("company_name"));
|
|
|
|
row.createCell(17, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("company_name"));
|
|
|
|
row.createCell(16,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("short_name"));
|
|
|
|
row.createCell(18, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("short_name"));
|
|
|
|
row.createCell(17,Cell.CELL_TYPE_STRING).setCellValue(settle.getString("settle_date"));
|
|
|
|
row.createCell(19, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("settle_date"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
for (int i = 0; i < analysis.length; i++) {
|
|
|
|
for (int i = 0; i < analysis.length; i++) {
|
|
|
@ -1283,26 +1281,23 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
ous.flush();
|
|
|
|
ous.flush();
|
|
|
|
} catch (IOException e) {
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
IOUtils.closeQuietly(ous);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void exportPDFSettlement(TradeLogQuery query, JSONObject partner, HttpServletResponse response) {
|
|
|
|
public void exportPDFSettlement(TradeLogQuery query, JSONObject partner, HttpServletResponse response) {
|
|
|
|
String begin = query.getDatefrom() == null ?"":query.getDatefrom();
|
|
|
|
String begin = query.getDatefrom() == null ? "" : query.getDatefrom();
|
|
|
|
String end = query.getDateto() == null ?"":query.getDateto();
|
|
|
|
String end = query.getDateto() == null ? "" : query.getDateto();
|
|
|
|
JSONObject client = partner.getJSONObject("client");
|
|
|
|
JSONObject client = partner.getJSONObject("client");
|
|
|
|
String timezone = client.getString("timezone");
|
|
|
|
String timezone = client.getString("timezone");
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
if (params.get("client_ids") == null) {
|
|
|
|
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<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
|
|
|
|
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
|
|
|
|
List<Integer> clientOrders = new ArrayList<>(clientOrderList.size());
|
|
|
|
clientOrderList.parallelStream().forEach(p->{
|
|
|
|
clientOrderList.parallelStream().forEach(p -> clientOrders.add(p.getInteger("clearing_order")));
|
|
|
|
clientOrders.add(p.getInteger("clearing_order"));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders);
|
|
|
|
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders);
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(settlementLogDetailList, timezone, "yyyy-MM-dd HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(settlementLogDetailList, timezone, "yyyy-MM-dd HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1321,13 +1316,13 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
scaleDecimalVal(item, "settle_amount", platformCurrency);
|
|
|
|
scaleDecimalVal(item, "settle_amount", platformCurrency);
|
|
|
|
scaleDecimalVal(item, "total_surcharge", platformCurrency);
|
|
|
|
scaleDecimalVal(item, "total_surcharge", platformCurrency);
|
|
|
|
scaleDecimalVal(item, "transaction_amount", platformCurrency);
|
|
|
|
scaleDecimalVal(item, "transaction_amount", platformCurrency);
|
|
|
|
item.put("exchange_rate", item.getBigDecimal("exchange_rate").setScale(5, BigDecimal.ROUND_DOWN));
|
|
|
|
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("gateway", item.getInteger("gateway") == null ? "-" : TradeType.fromGatewayNumber(item.getIntValue("gateway")).getTradeType());
|
|
|
|
item.put("rate", item.getBigDecimal("rate") == null? "-": item.getBigDecimal("rate").toPlainString() + "%");
|
|
|
|
item.put("rate", item.getBigDecimal("rate") == null ? "-" : item.getBigDecimal("rate").toPlainString() + "%");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(settlementLogDetailList);
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(settlementLogDetailList);
|
|
|
|
response.setContentType("application/pdf");
|
|
|
|
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");
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf");
|
|
|
|
OutputStream outs = response.getOutputStream();
|
|
|
|
OutputStream outs = response.getOutputStream();
|
|
|
|
byte[] bytes = JasperRunManager.runReportToPdf(partner_settlement_flow.getInputStream(), parmerters, jrDataSource);
|
|
|
|
byte[] bytes = JasperRunManager.runReportToPdf(partner_settlement_flow.getInputStream(), parmerters, jrDataSource);
|
|
|
@ -1342,19 +1337,20 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void exportExcelAllPartner(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
|
|
|
|
public void exportExcelAllPartner(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
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");
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
clientManager.validateClients(client_id, params);
|
|
|
|
clientManager.validateClients(clientId1, params);
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
params.put("client_id", clientId1);
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlow(params);
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlow(params);
|
|
|
|
|
|
|
|
|
|
|
|
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"));
|
|
|
|
if (logs.size() > 0) {
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, TimeZone.getDefault().getID(), "dd/MM/yyyy", Collections.singletonList("clearing_time"));
|
|
|
|
|
|
|
|
if (!logs.isEmpty()) {
|
|
|
|
OutputStream ous = null;
|
|
|
|
OutputStream ous = null;
|
|
|
|
String transType;
|
|
|
|
String transType;
|
|
|
|
int status;
|
|
|
|
int status;
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
|
|
|
Font font = wb.createFont();
|
|
|
|
Font font = wb.createFont();
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
font.setFontHeightInPoints((short) 10);
|
|
|
|
font.setFontHeightInPoints((short) 10);
|
|
|
@ -1379,7 +1375,9 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int rowNum = 0;
|
|
|
|
int rowNum = 0;
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
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",
|
|
|
|
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"};
|
|
|
|
"Transaction Type", "Clearing Status", "Gateway", "Remark", "Dev No"};
|
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
|
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
|
|
|
|
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
|
|
|
@ -1388,8 +1386,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
for (JSONObject log : logs) {
|
|
|
|
String login_id = log.getString("login_id");
|
|
|
|
String login_id = log.getString("login_id");
|
|
|
|
if (StringUtils.isNotEmpty(login_id)) {
|
|
|
|
if (StringUtils.isNotEmpty(login_id)) {
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : login_id+":"+log.getString("order_detail")));
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : login_id + ":" + log.getString("order_detail")));
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : log.getString("order_detail")));
|
|
|
|
log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : log.getString("order_detail")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
transType = log.getString("trans_type");
|
|
|
|
transType = log.getString("trans_type");
|
|
|
@ -1408,12 +1406,21 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
scaleDecimalVal(log, "display_amount", platformCurrency);
|
|
|
|
scaleDecimalVal(log, "display_amount", platformCurrency);
|
|
|
|
scaleDecimalVal(log, "transaction_amount", platformCurrency);
|
|
|
|
scaleDecimalVal(log, "transaction_amount", platformCurrency);
|
|
|
|
scaleDecimalVal(log, "clearing_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);
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
excelTrans(row, log);
|
|
|
|
excelTrans(row, log);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
List<JSONObject> logsByClientId = logs.stream().filter(log -> log.getString("client_id").equals(clientId)).collect(Collectors.toList());
|
|
|
|
List<JSONObject> logsByClientId = logs.stream().filter(log -> log.getString("client_id").equals(clientId)).collect(Collectors.toList());
|
|
|
|
for (JSONObject log : logsByClientId) {
|
|
|
|
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);
|
|
|
|
row = sheet.createRow(++rowNum);
|
|
|
|
excelTrans(row, log);
|
|
|
|
excelTrans(row, log);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1431,4 +1438,5 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|