|
|
@ -673,91 +673,64 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
|
|
|
|
public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
int client_id = partner.getIntValue("client_id");
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
// JSONObject analysis = transFlow.getJSONObject("analysis");
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
if (transFlow.getJSONArray("data").size() > 0) {
|
|
|
|
clientManager.validateClients(client_id, params);
|
|
|
|
try {
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlowDetail(params);
|
|
|
|
String transType;
|
|
|
|
|
|
|
|
JSONObject device;
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
int status;
|
|
|
|
if (logs.size() > 0) {
|
|
|
|
for (JSONObject data : dataList) {
|
|
|
|
OutputStream ous = null;
|
|
|
|
transType = data.getString("trans_type");
|
|
|
|
String transType;
|
|
|
|
if (!"refund".equals(transType))
|
|
|
|
int status;
|
|
|
|
continue;
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
status = data.getIntValue("status");
|
|
|
|
Font font = wb.createFont();
|
|
|
|
if (status == 6)
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
transType = "Partly " + transType;
|
|
|
|
font.setFontHeightInPoints((short) 10);
|
|
|
|
else if (status == 7) {
|
|
|
|
CellStyle analysisStyle = wb.createCellStyle();
|
|
|
|
transType = "Fully " + transType;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data.put("trans_type", transType);
|
|
|
|
|
|
|
|
device = clientDeviceMapper.find(data.getString("order_dev_id"));
|
|
|
|
|
|
|
|
if (device != null)
|
|
|
|
|
|
|
|
data.put("dev_id", device.getString("client_dev_id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : "");
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
|
|
|
"attachment; filename=" + "Merchant_Settlement_Info_" + query.getDatefrom() + "_" + query.getDateto() + ".xls");
|
|
|
|
parmerters.put("partnerCode", partner.getString("client_moniker"));
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
// parmerters.put("actual_fee", analysis.containsKey("actual_fee") ?
|
|
|
|
try {
|
|
|
|
// analysis.getBigDecimal("actual_fee") : 0);
|
|
|
|
wb.write(ous);
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList);
|
|
|
|
ous.close();
|
|
|
|
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);
|
|
|
|
|
|
|
|
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(outputStream);
|
|
|
|
|
|
|
|
exporter.setExporterOutput(exporterOutput);
|
|
|
|
|
|
|
|
// 设置导出时参数
|
|
|
|
|
|
|
|
SimpleXlsxReportConfiguration xlsReportConfiguration = new SimpleXlsxReportConfiguration();
|
|
|
|
|
|
|
|
xlsReportConfiguration.setOnePagePerSheet(false);
|
|
|
|
|
|
|
|
xlsReportConfiguration.setRemoveEmptySpaceBetweenRows(true);
|
|
|
|
|
|
|
|
xlsReportConfiguration.setDetectCellType(true);
|
|
|
|
|
|
|
|
xlsReportConfiguration.setWhitePageBackground(false);
|
|
|
|
|
|
|
|
exporter.setConfiguration(xlsReportConfiguration);
|
|
|
|
|
|
|
|
exporter.exportReport();
|
|
|
|
|
|
|
|
outputStream.close();
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1373,4 +1346,97 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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");
|
|
|
|
|
|
|
|
String timezone = partner.getJSONObject("client").getString("timezone");
|
|
|
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
|
|
|
clientManager.validateClients(client_id, params);
|
|
|
|
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
|
|
|
|
List<JSONObject> logs = transactionMapper.listTransFlow(params);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
|
|
|
|
if (logs.size() > 0) {
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|