|
|
|
@ -593,6 +593,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
result.put("analysis", analysis);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private JSONObject listPartnerTransFlowByExportPdfSecurePay(TradeLogQuery query, JSONObject client, String[] channels) throws Exception {
|
|
|
|
|
int clientId = client.getIntValue("client_id");
|
|
|
|
|
String timezone = client.getString("timezone");
|
|
|
|
@ -802,8 +803,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
JSONObject client = clientManager.getClientInfo(partner.getIntValue("client_id"));
|
|
|
|
|
Context ctx = new Context();
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
int recordsSize=transFlow.getJSONArray("data").isEmpty()?0:transFlow.getJSONArray("data").size();
|
|
|
|
|
parmerters.put("records",recordsSize);
|
|
|
|
|
int recordsSize = transFlow.getJSONArray("data").isEmpty() ? 0 : transFlow.getJSONArray("data").size();
|
|
|
|
|
parmerters.put("records", recordsSize);
|
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom())
|
|
|
|
|
? DateFormatUtils.format(DateUtils.parseDate(query.getDatefrom(), "yyyyMMdd"), "dd/MM/yyyy") : "");
|
|
|
|
|
parmerters.put("dateTo",
|
|
|
|
@ -838,7 +839,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
try {
|
|
|
|
|
OutputStream outs = response.getOutputStream();
|
|
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
|
List<JSONObject> dataList= transTransform(transFlow);
|
|
|
|
|
List<JSONObject> dataList = transTransform(transFlow);
|
|
|
|
|
ctx.setVariable("dataList", dataList);
|
|
|
|
|
final String html = thymeleaf.process("app/invoice.html", ctx);
|
|
|
|
|
response.setContentType("application/pdf");
|
|
|
|
@ -853,15 +854,13 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
outs.write(bytes, 0, bytes.length);
|
|
|
|
|
outs.flush();
|
|
|
|
|
renderer.finishPDF();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public byte[] exportTransFlowForSecurePay(TradeLogQuery query, JSONObject client) throws Exception {
|
|
|
|
|
JSONObject transFlow = listPartnerTransFlowByExportPdfSecurePay(query, client, new String[]{"Wechat", "Alipay", "AlipayOnline"});
|
|
|
|
@ -869,8 +868,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
// JSONObject client = clientManager.getClientInfo(partner.getIntValue("client_id"));
|
|
|
|
|
Context ctx = new Context();
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
int recordsSize=transFlow.getJSONArray("data").isEmpty()?0:transFlow.getJSONArray("data").size();
|
|
|
|
|
parmerters.put("records",recordsSize);
|
|
|
|
|
int recordsSize = transFlow.getJSONArray("data").isEmpty() ? 0 : transFlow.getJSONArray("data").size();
|
|
|
|
|
parmerters.put("records", recordsSize);
|
|
|
|
|
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom())
|
|
|
|
|
? DateFormatUtils.format(DateUtils.parseDate(query.getDatefrom(), "yyyyMMdd"), "dd/MM/yyyy") : "");
|
|
|
|
|
parmerters.put("dateTo",
|
|
|
|
@ -904,7 +903,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
ctx.setVariable("orgInfo", orgInfo);
|
|
|
|
|
try {
|
|
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
|
List<JSONObject> dataList= transTransform(transFlow);
|
|
|
|
|
List<JSONObject> dataList = transTransform(transFlow);
|
|
|
|
|
ctx.setVariable("dataList", dataList);
|
|
|
|
|
|
|
|
|
|
final String html = thymeleaf.process("app/invoice.html", ctx);
|
|
|
|
@ -917,17 +916,15 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
renderer.finishPDF();
|
|
|
|
|
os.close();
|
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return bytes;
|
|
|
|
|
|
|
|
|
|
catch (Exception e) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<JSONObject> transTransform( JSONObject transFlow ){
|
|
|
|
|
private List<JSONObject> transTransform(JSONObject transFlow) {
|
|
|
|
|
List<JSONObject> dataList;
|
|
|
|
|
if (!transFlow.getJSONArray("data").isEmpty()) {
|
|
|
|
|
dataList = transFlow.getJSONArray("data").toJavaList(JSONObject.class);
|
|
|
|
@ -958,20 +955,20 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
item.put("credit", credit);
|
|
|
|
|
item.putIfAbsent("settle_amount", "-");
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
dataList=new ArrayList<>();
|
|
|
|
|
JSONObject jsonObject=new JSONObject();
|
|
|
|
|
jsonObject.put("transaction_time","-");
|
|
|
|
|
jsonObject.put("client_order_id","-");
|
|
|
|
|
jsonObject.put("order_id","-");
|
|
|
|
|
jsonObject.put("debit","-");
|
|
|
|
|
jsonObject.put("credit","-");
|
|
|
|
|
jsonObject.put("real_royalpay_surcharge","-");
|
|
|
|
|
jsonObject.put("incremental_surcharge","-");
|
|
|
|
|
jsonObject.put("settle_amount","-");
|
|
|
|
|
} else {
|
|
|
|
|
dataList = new ArrayList<>();
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("transaction_time", "-");
|
|
|
|
|
jsonObject.put("client_order_id", "-");
|
|
|
|
|
jsonObject.put("order_id", "-");
|
|
|
|
|
jsonObject.put("debit", "-");
|
|
|
|
|
jsonObject.put("credit", "-");
|
|
|
|
|
jsonObject.put("real_royalpay_surcharge", "-");
|
|
|
|
|
jsonObject.put("incremental_surcharge", "-");
|
|
|
|
|
jsonObject.put("settle_amount", "-");
|
|
|
|
|
dataList.add(jsonObject);
|
|
|
|
|
}
|
|
|
|
|
return dataList;
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -2088,8 +2085,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public byte[] exportPDFSettlement(TradeLogQuery query, JSONObject client) {
|
|
|
|
|
logger.info("exporting settlement pdf for {}", client.getString("client_moniker"));
|
|
|
|
|
String begin = query.getDatefrom() == null ? "" : query.getDatefrom();
|
|
|
|
|
String end = query.getDateto() == null ? "" : query.getDateto();
|
|
|
|
|
String timezone = client.getString("timezone");
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
if (params.get("client_ids") == null) {
|
|
|
|
@ -2099,8 +2096,8 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
List<JSONObject> clientOrderList = transactionMapper.getClientOrderByTransactionTime(params);
|
|
|
|
|
JSONObject parmerters = new JSONObject();
|
|
|
|
|
try {
|
|
|
|
|
String beginParse= DateFormatUtils.format(DateUtils.parseDate(begin,"yyyyMMdd"),"dd.MM.yyyy");
|
|
|
|
|
parmerters.put("dateRange", "Your Statement For:"+beginParse+"");
|
|
|
|
|
String beginParse = DateFormatUtils.format(DateUtils.parseDate(begin, "yyyyMMdd"), "dd.MM.yyyy");
|
|
|
|
|
parmerters.put("dateRange", "Your Statement For:" + beginParse + "");
|
|
|
|
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
@ -2127,8 +2124,7 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
item.put("gateway", item.getInteger("gateway") == null ? "-" : TradeType.fromGatewayNumber(item.getIntValue("gateway")).getTradeType());
|
|
|
|
|
item.put("rate", item.getBigDecimal("rate") == null ? "-" : item.getBigDecimal("rate").stripTrailingZeros().toPlainString() + "%");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (clientOrderList.size() <= 0) {
|
|
|
|
|
} else {
|
|
|
|
|
JSONObject mockJson = new JSONObject();
|
|
|
|
|
mockJson.put("order_id", "-");
|
|
|
|
|
mockJson.put("client_order_id", "-");
|
|
|
|
@ -2154,9 +2150,9 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
orgInfo.put("logo", "none");
|
|
|
|
|
}
|
|
|
|
|
ctx.setVariable("orgInfo", orgInfo);
|
|
|
|
|
ctx.setVariable("parmerters",parmerters);
|
|
|
|
|
ctx.setVariable("settlementLogDetailList",settlementLogDetailList);
|
|
|
|
|
System.out.println("=====>reports/securepay_settlement.html:");
|
|
|
|
|
ctx.setVariable("parmerters", parmerters);
|
|
|
|
|
ctx.setVariable("settlementLogDetailList", settlementLogDetailList);
|
|
|
|
|
logger.info("=====>reports/securepay_settlement.html:");
|
|
|
|
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
|
|
|
|
final String html = thymeleaf.process("reports/securepay_settlement.html", ctx);
|
|
|
|
|
|
|
|
|
@ -2172,9 +2168,9 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
|
|
|
|
|
// JRDataSource jrDataSource = new JRBeanCollectionDataSource(settlementLogDetailList);
|
|
|
|
|
// return JasperRunManager.runReportToPdf(securepay_settlement_flow.getInputStream(), parmerters, jrDataSource);
|
|
|
|
|
return bytes;
|
|
|
|
|
return bytes;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServerErrorException(e);
|
|
|
|
|
throw new ServerErrorException("Failed to export settlement report pdf for " + client.getString("client_moniker"), e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|