|
|
@ -156,6 +156,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
private org.springframework.core.io.Resource trans_excel;
|
|
|
|
private org.springframework.core.io.Resource trans_excel;
|
|
|
|
@Value("classpath:/jasper/austrac_report.jasper")
|
|
|
|
@Value("classpath:/jasper/austrac_report.jasper")
|
|
|
|
private org.springframework.core.io.Resource austrac_report;
|
|
|
|
private org.springframework.core.io.Resource austrac_report;
|
|
|
|
|
|
|
|
@Value("classpath:/jasper/partner_settlement_detail.jasper")
|
|
|
|
|
|
|
|
private org.springframework.core.io.Resource partner_settlement_flow;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public JSONObject listPartnerTradeLogs(JSONObject manager, JSONObject account, String shortId, TradeLogQuery query, String timezone) throws Exception {
|
|
|
|
public JSONObject listPartnerTradeLogs(JSONObject manager, JSONObject account, String shortId, TradeLogQuery query, String timezone) throws Exception {
|
|
|
@ -1246,7 +1248,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
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, BigDecimal.ROUND_DOWN).toPlainString());
|
|
|
|
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("order_detail"));
|
|
|
|
row.createCell(13, 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");
|
|
|
@ -1273,4 +1275,54 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
IOUtils.closeQuietly(ous);
|
|
|
|
IOUtils.closeQuietly(ous);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void exportPDFSettlement(TradeLogQuery query, JSONObject partner, HttpServletResponse response) {
|
|
|
|
|
|
|
|
int client_id = partner.getIntValue("client_id");
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
params.put("client_id", 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"));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
List<JSONObject> settlementLogDetailList = transactionMapper.getSettlementLogDetailList(clientOrders, client_id);
|
|
|
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(settlementLogDetailList, timezone, "yyyy-MM-dd HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
|
|
|
parmerters.put("dateRange", "(Statement Period " + begin + "~"
|
|
|
|
|
|
|
|
+ end + ")");
|
|
|
|
|
|
|
|
parmerters.put("clientName", client.getString("company_name"));
|
|
|
|
|
|
|
|
parmerters.put("clientAddress", client.getString("address"));
|
|
|
|
|
|
|
|
parmerters.put("clientLocation", client.getString("suburb") + "," + client.getString("state") + "," + client.getString("postcode"));
|
|
|
|
|
|
|
|
parmerters.put("logo", logo.getInputStream());
|
|
|
|
|
|
|
|
settlementLogDetailList.parallelStream().forEach(item -> {
|
|
|
|
|
|
|
|
scaleDecimalVal(item, "display_amount", item.getString("transaction_currency"));
|
|
|
|
|
|
|
|
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
|
|
|
|
|
|
|
|
scaleDecimalVal(item, "clearing_amount", platformCurrency);
|
|
|
|
|
|
|
|
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() + "%");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
JRDataSource jrDataSource = new JRBeanCollectionDataSource(settlementLogDetailList);
|
|
|
|
|
|
|
|
response.setContentType("application/pdf");
|
|
|
|
|
|
|
|
String fileName = partner.getString("client_moniker") + "_" + parmerters.getString("dateRange").replaceAll("/", "");
|
|
|
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName + ".pdf");
|
|
|
|
|
|
|
|
OutputStream outs = response.getOutputStream();
|
|
|
|
|
|
|
|
byte[] bytes = JasperRunManager.runReportToPdf(partner_settlement_flow.getInputStream(), parmerters, jrDataSource);
|
|
|
|
|
|
|
|
outs.write(bytes, 0, bytes.length);
|
|
|
|
|
|
|
|
outs.flush();
|
|
|
|
|
|
|
|
outs.close();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|