|
|
|
@ -70,6 +70,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -674,20 +675,19 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
@Override
|
|
|
|
|
public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
|
|
|
|
|
logger.debug("excel The method======= exportExcel() start.......................");
|
|
|
|
|
JSONObject transFlow = listPartnerTransFlow(query, partner);
|
|
|
|
|
// JSONObject analysis = transFlow.getJSONObject("analysis");
|
|
|
|
|
if (transFlow.getJSONArray("data").size() > 0) {
|
|
|
|
|
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.listTransFlowDetail(params);
|
|
|
|
|
|
|
|
|
|
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Arrays.asList("transaction_time"));
|
|
|
|
|
if (logs.size() > 0) {
|
|
|
|
|
OutputStream ous = null;
|
|
|
|
|
try {
|
|
|
|
|
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
|
|
|
|
|
String transType;
|
|
|
|
|
JSONObject device;
|
|
|
|
|
int status;
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
|
"attachment; filename=" + "Merchant_Settlement_Info_" + query.getDatefrom() + "_" + query.getDateto() + ".xlsx");
|
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
Workbook wb = new XSSFWorkbook();
|
|
|
|
|
HSSFWorkbook wb = new HSSFWorkbook();
|
|
|
|
|
Font font = wb.createFont();
|
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
|
font.setFontHeightInPoints((short) 10);
|
|
|
|
@ -699,14 +699,15 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
if (clientIds.length >= 2) {
|
|
|
|
|
clientIdList.addAll(Arrays.asList(clientIds));
|
|
|
|
|
}
|
|
|
|
|
Sheet sheet = null;
|
|
|
|
|
HSSFSheet sheet = null;
|
|
|
|
|
JSONObject client = null;
|
|
|
|
|
for (int i = 0;i < clientIdList.size();i++) {
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
sheet = wb.createSheet("ALL");
|
|
|
|
|
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
|
|
|
|
|
for (String clientId : clientIdList) {
|
|
|
|
|
if ("ALL".equals(clientId)) {
|
|
|
|
|
sheet = wb.createSheet(clientId);
|
|
|
|
|
} else {
|
|
|
|
|
client = clientManager.getClientInfo(Integer.parseInt(clientIdList.get(i)));
|
|
|
|
|
sheet = wb.createSheet(client == null ? clientIdList.get(i) : client.getString("client_moniker"));
|
|
|
|
|
client = clientManager.getClientInfo(Integer.parseInt(clientId));
|
|
|
|
|
sheet = wb.createSheet(client == null ? clientId : client.getString("client_moniker"));
|
|
|
|
|
}
|
|
|
|
|
int rowNum = 0;
|
|
|
|
|
Row row = sheet.createRow(rowNum);
|
|
|
|
@ -715,30 +716,52 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
for (int j = 0; j < title.length; j++) {
|
|
|
|
|
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
|
|
|
|
|
}
|
|
|
|
|
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
|
|
|
|
|
for (JSONObject data : dataList) {
|
|
|
|
|
if (!clientIdList.get(i).equals(data.getString("client_id")) && i != 0) {
|
|
|
|
|
continue;
|
|
|
|
|
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")));
|
|
|
|
|
}
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
transType = data.getString("trans_type");
|
|
|
|
|
transType = log.getString("trans_type");
|
|
|
|
|
if (!"refund".equals(transType)) {
|
|
|
|
|
status = data.getIntValue("status");
|
|
|
|
|
status = log.getIntValue("status");
|
|
|
|
|
if (status == 6)
|
|
|
|
|
transType = "Partly " + transType;
|
|
|
|
|
else if (status == 7) {
|
|
|
|
|
transType = "Fully " + transType;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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"));
|
|
|
|
|
scaleDecimalVal(data, "display_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(data, "transaction_amount", platformCurrency);
|
|
|
|
|
scaleDecimalVal(data, "clearing_amount", platformCurrency);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
resp.setContentType("application/octet-stream;");
|
|
|
|
|
resp.addHeader("Content-Disposition",
|
|
|
|
|
"attachment; filename=" + "Merchant_Settlement_Info_" + query.getDatefrom() + "_" + query.getDateto() + ".xls");
|
|
|
|
|
ous = resp.getOutputStream();
|
|
|
|
|
try {
|
|
|
|
|
wb.write(ous);
|
|
|
|
|
ous.close();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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"));
|
|
|
|
@ -757,16 +780,6 @@ public class TradeLogServiceImpl implements TradeLogService {
|
|
|
|
|
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail"));
|
|
|
|
|
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("dev_id"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wb.write(ous);
|
|
|
|
|
ous.flush();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} finally {
|
|
|
|
|
IOUtils.closeQuietly(ous);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
|
|
|
|
|