Merge remote-tracking branch 'origin/develop' into develop

master
liuxinxin 5 years ago
commit 1fac5ac08c

@ -58,6 +58,8 @@ public interface TradeLogService {
void exportSettlementLog(TradeLogQuery query, JSONObject partner, HttpServletResponse response);
void exportSettlementLogCSV(TradeLogQuery query, JSONObject partner, HttpServletResponse response);
void exportPDFSettlement(TradeLogQuery query, JSONObject partner, HttpServletResponse response);
void exportExcelAllPartner(TradeLogQuery query, JSONObject partner, HttpServletResponse httpResponse) throws Exception;

@ -22,6 +22,7 @@ import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.permission.enums.ManagerRole;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
@ -40,6 +41,9 @@ import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter;
import net.sf.jasperreports.export.*;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.csv.QuoteMode;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
@ -58,9 +62,7 @@ import org.springframework.ui.Model;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DateFormat;
@ -150,8 +152,10 @@ public class TradeLogServiceImpl implements TradeLogService {
if (manager != null && manager.getInteger("org_id") != null) {
params.put("org_id", manager.getIntValue("org_id"));
}
if(query.getGatewayChild()!=null){
params.put("trade_type",new ArrayList<Integer>(){{add(query.getGatewayChild());}});
if (query.getGatewayChild() != null) {
params.put("trade_type", new ArrayList<Integer>() {{
add(query.getGatewayChild());
}});
}
PageList<JSONObject> logs = orderMapper.listOrdersByClients(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
@ -185,8 +189,10 @@ public class TradeLogServiceImpl implements TradeLogService {
if (manager != null && manager.getInteger("org_id") != null) {
params.put("org_id", manager.getIntValue("org_id"));
}
if(query.getGatewayChild()!=null){
params.put("trade_type",new ArrayList<Integer>(){{add(query.getGatewayChild());}});
if (query.getGatewayChild() != null) {
params.put("trade_type", new ArrayList<Integer>() {{
add(query.getGatewayChild());
}});
}
PageList<JSONObject> logs = orderMapper.listIncrementalOrdersByClients(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
@ -222,8 +228,10 @@ public class TradeLogServiceImpl implements TradeLogService {
}
}
orgManager.checkOrgIds(manager, params);
if(query.getGatewayChild()!=null){
params.put("trade_type",new ArrayList<Integer>(){{add(query.getGatewayChild());}});
if (query.getGatewayChild() != null) {
params.put("trade_type", new ArrayList<Integer>() {{
add(query.getGatewayChild());
}});
}
PageList<JSONObject> logs = orderMapper.listOrders(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
JSONObject result = PageListUtils.buildPageListResult(logs);
@ -246,12 +254,14 @@ public class TradeLogServiceImpl implements TradeLogService {
}
}
orgManager.checkOrgIds(manager, params);
if(query.getGatewayChild()!=null){
params.put("trade_type",new ArrayList<Integer>(){{add(query.getGatewayChild());}});
if (query.getGatewayChild() != null) {
params.put("trade_type", new ArrayList<Integer>() {{
add(query.getGatewayChild());
}});
}
PageList<JSONObject> logs = orderMapper.listIncrementalOrders(params, new PageBounds(query.getPage(), query.getLimit(), Order.formString("create_time.desc")));
for (JSONObject log : logs) {
log.put("rate_value",clientIncrementalMapper.findByChannelAndClientId(log.getIntValue("client_id"),log.getString("source")));
log.put("rate_value", clientIncrementalMapper.findByChannelAndClientId(log.getIntValue("client_id"), log.getString("source")));
}
JSONObject result = PageListUtils.buildPageListResult(logs);
JSONObject analysis = orderMapper.analysisOrders(params);
@ -791,7 +801,7 @@ public class TradeLogServiceImpl implements TradeLogService {
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_amount"));
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(data.getString("settle_amount"));
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(data.getString("total_surcharge"));
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(StringUtils.defaultString(data.getString("incremental_surcharge"),"0.0000"));
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(StringUtils.defaultString(data.getString("incremental_surcharge"), "0.0000"));
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(data.getString("tax_amount"));
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_time"));
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type").equals("clearing") ? "-" : data.getBigDecimal("exchange_rate").toString());
@ -907,9 +917,9 @@ public class TradeLogServiceImpl implements TradeLogService {
cell0.setCellValue(text0);
cell1.setCellValue(text1);
cell2.setCellValue(text2);
if(dataItem.getString("transaction_type").equals("Debit") ){
if (dataItem.getString("transaction_type").equals("Debit")) {
cell2.setCellStyle(style3);
}else{
} else {
cell2.setCellStyle(style2);
}
cell3.setCellValue(text3);
@ -971,12 +981,12 @@ public class TradeLogServiceImpl implements TradeLogService {
}
@Override
public void listSettlementLogExcel(TradeLogQuery query, JSONObject partner,HttpServletResponse response) {
public void listSettlementLogExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse response) {
JSONObject client = clientManager.getClientInfoByMoniker(partner.getString("client_moniker"));
int clientId = partner.getIntValue("client_id");
String timezone = partner.getJSONObject("client").getString("timezone");
if(query.getClient_ids()!=null){
if(query.getClient_ids().length>1){
if (query.getClient_ids() != null) {
if (query.getClient_ids().length > 1) {
query.setClient_ids(null);
}
}
@ -985,21 +995,21 @@ public class TradeLogServiceImpl implements TradeLogService {
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
if(query.getClient_ids() ==null){
addSheet(0,workbook,client,logs);
if (query.getClient_ids() == null) {
addSheet(0, workbook, client, logs);
List<JSONObject> childs = clientMapper.listChildClients(client.getIntValue("client_id"));
for (int i=0;i<childs.size();i++){
for (int i = 0; i < childs.size(); i++) {
params.put("client_id", childs.get(i).getInteger("client_id"));
PageList<JSONObject> childLogs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc")));
if(childLogs.size()>0){
addSheet(i+1,workbook, childs.get(i),childLogs);
if (childLogs.size() > 0) {
addSheet(i + 1, workbook, childs.get(i), childLogs);
}
}
}else{
} else {
JSONObject chlidClient = clientMapper.findClient(Integer.parseInt(query.getClient_ids()[0]));
addSheet(0,workbook,chlidClient,logs);
addSheet(0, workbook, chlidClient, logs);
}
String fileName = "Settlement Log - "+ (query.getDatefrom() + "~" + query.getDateto() );
String fileName = "Settlement Log - " + (query.getDatefrom() + "~" + query.getDateto());
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
OutputStream outputStream = response.getOutputStream();
try {
@ -1013,9 +1023,9 @@ public class TradeLogServiceImpl implements TradeLogService {
}
}
private void addSheet(int sheetNum,HSSFWorkbook workbook,JSONObject client,List<JSONObject> logs){
private void addSheet(int sheetNum, HSSFWorkbook workbook, JSONObject client, List<JSONObject> logs) {
HSSFSheet sheet = workbook.createSheet();
workbook.setSheetName(sheetNum,client.getString("client_moniker")+"_excel");
workbook.setSheetName(sheetNum, client.getString("client_moniker") + "_excel");
sheet.setDefaultColumnWidth((short) 40);
HSSFCellStyle style = workbook.createCellStyle();
style.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
@ -1086,7 +1096,7 @@ public class TradeLogServiceImpl implements TradeLogService {
JSONObject dataItem = logs.get(i);
HSSFRichTextString text0 = new HSSFRichTextString(client.getString("short_name"));
HSSFRichTextString text1 = new HSSFRichTextString(client.getString("client_moniker"));
HSSFRichTextString text2 = new HSSFRichTextString(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format( dataItem.getDate("report_date")));
HSSFRichTextString text2 = new HSSFRichTextString(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(dataItem.getDate("report_date")));
HSSFRichTextString text3 = new HSSFRichTextString(dataItem.getBigDecimal("total").setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
HSSFRichTextString text4 = new HSSFRichTextString(dataItem.getBigDecimal("income").setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
HSSFRichTextString text5 = new HSSFRichTextString(dataItem.getBigDecimal("fee").setScale(2, BigDecimal.ROUND_HALF_DOWN).toString());
@ -1468,33 +1478,21 @@ public class TradeLogServiceImpl implements TradeLogService {
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("exchange_rate").setScale(5, RoundingMode.DOWN).toPlainString());
cell = row.createCell(6, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getString("transaction_type"));
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(settle.getString("transaction_currency"));
cell = row.createCell(8, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("display_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type"))?
settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString():
"-"+settle.getBigDecimal("display_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
cell.setCellValue(convertMarkedAmountString(settle, "display_amount"));
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
cell = row.createCell(9, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("transaction_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type"))?
settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString():
"-"+settle.getBigDecimal("transaction_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
cell.setCellValue(convertMarkedAmountString(settle, "transaction_amount"));
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
cell = row.createCell(10, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("clearing_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type"))?
settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString():
"-"+settle.getBigDecimal("clearing_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
cell.setCellValue(convertMarkedAmountString(settle, "clearing_amount"));
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(settle.getBigDecimal("rate") == null ? "" : settle.getBigDecimal("rate").toPlainString() + "%");
cell = row.createCell(12, Cell.CELL_TYPE_STRING);
cell.setCellValue(settle.getBigDecimal("settle_amount") == null ? ""
: "Credit".equals(settle.getString("transaction_type"))?
settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString():
"-"+settle.getBigDecimal("settle_amount").setScale(2, BigDecimal.ROUND_DOWN).toPlainString());
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type"))?analysisStyle2:null);
cell.setCellValue(convertMarkedAmountString(settle, "settle_amount"));
cell.setCellStyle(!"Credit".equals(settle.getString("transaction_type")) ? analysisStyle2 : null);
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 ? ""
@ -1524,9 +1522,99 @@ public class TradeLogServiceImpl implements TradeLogService {
wb.write(ous);
ous.flush();
} catch (IOException e) {
e.printStackTrace();
throw new ServerErrorException(e);
}
}
@Override
public void exportSettlementLogCSV(TradeLogQuery query, JSONObject partner, HttpServletResponse response) {
String begin = query.getDatefrom() == null ? "" : query.getDatefrom();
String end = query.getDateto() == null ? "" : query.getDateto();
String timezone = partner.getJSONObject("client").getString("timezone");
JSONObject params = query.toParams(timezone);
if (params.get("client_ids") == null) {
params.put("client_id", partner.getJSONObject("client").getString("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);
String[] title = {"order Id", "Client Order Id", "Transaction Time", "Channel", "Gateway", "Exchange Rate", "Transaction Type", "Currency",
"Input Amount", "Total Amount", "Clearing Amount", "Surcharge Rate", "Settle Amount", "Surcharge", "GST", "Remark", "Dev No", "Company Name", "Short Name", "Settlement Date"};
CSVFormat format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withHeader(title);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/octet-stream;");
response.addHeader("Content-Disposition",
"attachment; filename=" + "Merchant_Settlement_Info_" + begin + "_" + end + ".csv");
try (PrintWriter writer = response.getWriter();
CSVPrinter printer = new CSVPrinter(writer, format)) {
printer.printRecord((Object[]) title);
JSONObject clearDetailTotal = transactionMapper.getClearDetailTotal(params);
for (JSONObject settle : settlementLogDetailList) {
if (settle.getBigDecimal("clearing_amount").compareTo(BigDecimal.ZERO) == 0) {
continue;
}
String gateway = settle.getInteger("gateway") != null ? TradeType.fromGatewayNumber(settle.getIntValue("gateway")).getTradeType() : "-";
String displayAmount = convertMarkedAmountString(settle, "display_amount");
String transAmt = convertMarkedAmountString(settle, "transaction_amount");
String clearAmt = convertMarkedAmountString(settle, "clearing_amount");
String settleAmt = convertMarkedAmountString(settle, "settle_amount");
JSONObject device = clientDeviceMapper.find(settle.getString("dev_id"));
String clientDevId = device == null ? "" : device.getString("client_dev_id");
//print row
printer.printRecord(
settle.getString("order_id"),
settle.getString("client_order_id"),
settle.getString("transaction_time"),
settle.getString("channel"),
gateway,
settle.getBigDecimal("exchange_rate").setScale(5, RoundingMode.DOWN).toPlainString(),
settle.getString("transaction_type"),
settle.getString("transaction_currency"),
displayAmount,
transAmt,
clearAmt,
settle.getBigDecimal("rate") == null ? "" : settle.getBigDecimal("rate").toPlainString() + "%",
settleAmt,
settle.getBigDecimal("total_surcharge") == null ? ""
: settle.getBigDecimal("total_surcharge").setScale(2, RoundingMode.DOWN).toPlainString(),
settle.getBigDecimal("tax_amount") == null ? ""
: settle.getBigDecimal("tax_amount").setScale(2, RoundingMode.DOWN).toPlainString(),
settle.getString("remark"),
clientDevId, settle.getString("company_name"),
settle.getString("short_name"),
settle.getString("settle_date"));
}
String[] analysisRow = {"Total Credit",
clearDetailTotal.getString("total_payment"),
"Total Debit",
clearDetailTotal.getString("total_refund"),
"Gross Amount",
clearDetailTotal.getString("gross_amount"),
"Total Charge",
clearDetailTotal.getBigDecimal("total_charge").add(clearDetailTotal.getBigDecimal("tax_amount")).toPlainString(),
"Net Amount",
clearDetailTotal.getString("clearing_amount")};
printer.printRecord((Object[]) analysisRow);
writer.flush();
} catch (IOException e) {
throw new ServerErrorException(e);
}
}
public String convertMarkedAmountString(JSONObject settle, String key) {
if (settle.getBigDecimal(key) == null) {
return "";
} else {
return "Credit".equals(settle.getString("transaction_type")) ?
settle.getBigDecimal(key).setScale(2, RoundingMode.DOWN).toPlainString() :
"-" + settle.getBigDecimal(key).setScale(2, RoundingMode.DOWN).toPlainString();
}
}
@Override
@ -1574,7 +1662,7 @@ public class TradeLogServiceImpl implements TradeLogService {
outs.flush();
outs.close();
} catch (Exception e) {
e.printStackTrace();
throw new ServerErrorException(e);
}
}

@ -36,51 +36,59 @@ public class TradeFlowController {
@PartnerMapping(value = "/report/pdf", method = RequestMethod.GET)
@ReadOnlyConnection
public void exportPDF(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse httpResponse) throws Exception {
tradeLogService.exportTransFlow(query,partner,httpResponse);
tradeLogService.exportTransFlow(query, partner, httpResponse);
}
@PartnerMapping(value = "/report/excel", method = RequestMethod.GET)
@ReadOnlyConnection
public void exportExcel(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse httpResponse) throws Exception {
tradeLogService.exportExcelNew(query,partner,httpResponse);
tradeLogService.exportExcelNew(query, partner, httpResponse);
}
@PartnerMapping(value = "/report/excel_detail", method = RequestMethod.GET)
@ReadOnlyConnection
public void exportExcelDetail(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse httpResponse) throws Exception {
tradeLogService.exportExcel(query,partner,httpResponse);
tradeLogService.exportExcel(query, partner, httpResponse);
}
@PartnerMapping(value = "/settlement/log",method = RequestMethod.GET)
@PartnerMapping(value = "/settlement/log", method = RequestMethod.GET)
@ReadOnlyConnection
@ResponseBody
public JSONObject listSettlementLog(TradeLogQuery query,@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner){
return tradeLogService.listSettlementLog(query,partner);
public JSONObject listSettlementLog(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) {
return tradeLogService.listSettlementLog(query, partner);
}
@PartnerMapping(value = "/settlement/log/excelAll",method = RequestMethod.GET)
@PartnerMapping(value = "/settlement/log/excelAll", method = RequestMethod.GET)
@ReadOnlyConnection
@ResponseBody
public void listSettlementLogExcel(TradeLogQuery query,@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner,HttpServletResponse response){
tradeLogService.listSettlementLogExcel(query,partner,response);
public void listSettlementLogExcel(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse response) {
tradeLogService.listSettlementLogExcel(query, partner, response);
}
@PartnerMapping(value = "/settlement/unclear",method = RequestMethod.GET)
@PartnerMapping(value = "/settlement/unclear", method = RequestMethod.GET)
@ReadOnlyConnection
@ResponseBody
public String getClientUnClearedAmount(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner){
public String getClientUnClearedAmount(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner) {
// JSONObject res = new JSONObject();
// res.put("unCleared",tradeLogService.getClientUnClearedAmount(partner));
return tradeLogService.getClientUnClearedAmount(partner).toString();
}
@PartnerMapping(value = "/settlement/log/excel",method = RequestMethod.GET)
@PartnerMapping(value = "/settlement/log/excel", method = RequestMethod.GET)
@ReadOnlyConnection
@ResponseBody
public void exportSettlementLog(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse response) {
tradeLogService.exportSettlementLog(query, partner, response);
}
@PartnerMapping(value = "/settlement/log/pdf",method = RequestMethod.GET)
@PartnerMapping(value = "/settlement/log/csv", method = RequestMethod.GET)
@ReadOnlyConnection
@ResponseBody
public void exportSettlementLogCSV(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse response) {
tradeLogService.exportSettlementLogCSV(query, partner, response);
}
@PartnerMapping(value = "/settlement/log/pdf", method = RequestMethod.GET)
@ReadOnlyConnection
@ResponseBody
public void exportLogPDF(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse response) {
@ -90,6 +98,6 @@ public class TradeFlowController {
@PartnerMapping(value = "/report/excel_detail_all", method = RequestMethod.GET)
@ReadOnlyConnection
public void exportExcelDetailAllPartner(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse httpResponse) throws Exception {
tradeLogService.exportExcelAllPartner(query,partner,httpResponse);
tradeLogService.exportExcelAllPartner(query, partner, httpResponse);
}
}

@ -97,7 +97,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
$scope.analysis = resp.data.analysis;
});
};
$scope.excelSettlementAllLogs = function(){
$scope.excelSettlementAllLogs = function () {
var params = angular.copy($scope.params);
var url = '/client/trans_flow/settlement/log/excelAll';
var connectSymbol = '?';
@ -110,7 +110,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
url += connectSymbol + 'dateto=' + params.dateto;
}
if (params.client_ids){
if (params.client_ids) {
params.client_ids.forEach(function (i) {
url += connectSymbol + 'client_ids=' + i;
connectSymbol = '&';
@ -120,13 +120,15 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
};
$scope.chooseLast7Days();
$scope.exportSettlementLogs = function(pattern) {
var params = angular.copy($scope.params);
var url = '/client/trans_flow/settlement/log/excel';
$scope.exportSettlementLogs = function (pattern) {
let params = angular.copy($scope.params);
let url = '/client/trans_flow/settlement/log/excel';
if (pattern === 'pdf') {
url = '/client/trans_flow/settlement/log/pdf';
} else if (pattern === 'csv') {
url = '/client/trans_flow/settlement/log/csv';
}
var connectSymbol = '?';
let connectSymbol = '?';
if (params.datefrom) {
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
url += connectSymbol + 'datefrom=' + params.datefrom;
@ -136,7 +138,7 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
url += connectSymbol + 'dateto=' + params.dateto;
}
if (params.client_ids){
if (params.client_ids) {
params.client_ids.forEach(function (i) {
url += connectSymbol + 'client_ids=' + i;
connectSymbol = '&';

@ -107,6 +107,7 @@
</button>
<ul class="dropdown-menu" uib-dropdown-menu aria-labelledby="single-button" style="min-width: 80px">
<li><a target="_blank" ng-href="{{exportSettlementLogs('pdf')}}">PDF</a></li>
<li><a target="_blank" ng-href="{{exportSettlementLogs('csv')}}">CSV</a></li>
<li><a target="_blank" ng-href="{{exportSettlementLogs('excel')}}">EXCEL</a></li>
</ul>
</div>

@ -0,0 +1,29 @@
package au.com.royalpay.payment.manage.valid;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.csv.QuoteMode;
import org.junit.Test;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
/**
* Create by davep at 2019-12-24 15:15
*/
public class CSVTest {
@Test
public void test() throws IOException {
File file = File.createTempFile("csvtest",".csv");
FileWriter writer = new FileWriter(file);
CSVFormat format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withHeader("title", "标题1", "abc");//.withQuoteMode(QuoteMode.ALL_NON_NULL);
CSVPrinter printer = new CSVPrinter(writer, format);
printer.printRecord("test", "订单1234", "hello");
writer.flush();
System.out.println(file.getAbsolutePath());
}
}
Loading…
Cancel
Save