|
|
|
@ -89,6 +89,11 @@ import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
|
|
import org.apache.poi.hssf.util.HSSFColor;
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Font;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.dom4j.Element;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -127,6 +132,7 @@ import java.security.InvalidParameterException;
|
|
|
|
|
import java.security.KeyPair;
|
|
|
|
|
import java.security.interfaces.RSAPrivateKey;
|
|
|
|
|
import java.security.interfaces.RSAPublicKey;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
@ -3685,6 +3691,139 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void excelSettlementLog(JSONObject manager, String clientMoniker, TradeLogQuery query,HttpServletResponse response) {
|
|
|
|
|
JSONObject client = getClientInfoByMoniker(clientMoniker);
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new InvalidShortIdException();
|
|
|
|
|
}
|
|
|
|
|
checkOrgPermission(manager, client);
|
|
|
|
|
int client_id = client.getIntValue("client_id");
|
|
|
|
|
String timezone = client.getString("timezone");
|
|
|
|
|
if (query.getDatefrom() == null) {
|
|
|
|
|
JSONObject earlistOrder = transactionAnalysisMapper.getEarliestOrder(client_id);
|
|
|
|
|
if (earlistOrder != null) {
|
|
|
|
|
query.setDatefrom(DateFormatUtils.format(earlistOrder.getDate("transaction_time"), "yyyyMMdd"));
|
|
|
|
|
query.setDateto(DateFormatUtils.format(new Date(), "yyyyMMdd"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
JSONObject params = query.toParams(timezone);
|
|
|
|
|
params.put("client_id", client_id);
|
|
|
|
|
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, new PageBounds(query.getPage(), 10000, Order.formString("clearing_time.desc")));
|
|
|
|
|
//Excel 多sheet导出
|
|
|
|
|
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
|
|
|
|
addSheet(0,workbook,client,logs);
|
|
|
|
|
List<JSONObject> childs = clientMapper.listChildClients(client.getIntValue("client_id"));
|
|
|
|
|
if(childs.size()>0){
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String fileName = "Settlement Log - "+ (query.getDatefrom() + "~" + query.getDateto() );
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls");
|
|
|
|
|
OutputStream outputStream = response.getOutputStream();
|
|
|
|
|
try {
|
|
|
|
|
workbook.write(outputStream);
|
|
|
|
|
outputStream.close();
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addSheet(int sheetNum,HSSFWorkbook workbook,JSONObject client,List<JSONObject> logs){
|
|
|
|
|
HSSFSheet sheet = workbook.createSheet();
|
|
|
|
|
workbook.setSheetName(sheetNum,client.getString("client_moniker")+"_excel");
|
|
|
|
|
sheet.setDefaultColumnWidth((short) 40);
|
|
|
|
|
HSSFCellStyle style = workbook.createCellStyle();
|
|
|
|
|
style.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
|
|
|
|
|
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style.setBorderBottom(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderLeft(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderRight(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setBorderTop(CellStyle.BORDER_THIN);
|
|
|
|
|
style.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font = workbook.createFont();
|
|
|
|
|
font.setFontHeightInPoints((short) 16);
|
|
|
|
|
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
|
|
|
|
|
style.setFont(font);
|
|
|
|
|
|
|
|
|
|
HSSFCellStyle style2 = workbook.createCellStyle();
|
|
|
|
|
style2.setFillForegroundColor(HSSFColor.WHITE.index);
|
|
|
|
|
style2.setFillPattern(CellStyle.SOLID_FOREGROUND);
|
|
|
|
|
style2.setBorderBottom(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderLeft(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderRight(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setBorderTop(CellStyle.BORDER_THIN);
|
|
|
|
|
style2.setAlignment(CellStyle.ALIGN_CENTER);
|
|
|
|
|
HSSFFont font2 = workbook.createFont();
|
|
|
|
|
// font.setColor(HSSFColor.VIOLET.index);
|
|
|
|
|
font2.setFontHeightInPoints((short) 12);
|
|
|
|
|
font2.setBoldweight(Font.BOLDWEIGHT_NORMAL);
|
|
|
|
|
// 把字体应用到当前的样式
|
|
|
|
|
style2.setFont(font2);
|
|
|
|
|
HSSFRow row0 = sheet.createRow(0);
|
|
|
|
|
HSSFCell cell00 = row0.createCell(0);
|
|
|
|
|
HSSFCell cell01 = row0.createCell(1);
|
|
|
|
|
HSSFCell cell02 = row0.createCell(2);
|
|
|
|
|
HSSFCell cell03 = row0.createCell(3);
|
|
|
|
|
HSSFCell cell04 = row0.createCell(4);
|
|
|
|
|
HSSFCell cell05 = row0.createCell(5);
|
|
|
|
|
cell00.setCellStyle(style);
|
|
|
|
|
cell01.setCellStyle(style);
|
|
|
|
|
cell02.setCellStyle(style);
|
|
|
|
|
cell03.setCellStyle(style);
|
|
|
|
|
cell04.setCellStyle(style);
|
|
|
|
|
cell05.setCellStyle(style);
|
|
|
|
|
HSSFRichTextString text00 = new HSSFRichTextString("Short Name");
|
|
|
|
|
HSSFRichTextString text01 = new HSSFRichTextString("Client Moniker");
|
|
|
|
|
HSSFRichTextString text02 = new HSSFRichTextString("Settle Time");
|
|
|
|
|
HSSFRichTextString text03 = new HSSFRichTextString("Transaction Amount");
|
|
|
|
|
HSSFRichTextString text04 = new HSSFRichTextString("to Merchant");
|
|
|
|
|
HSSFRichTextString text05 = new HSSFRichTextString("Service Fee");
|
|
|
|
|
cell00.setCellValue(text00);
|
|
|
|
|
cell01.setCellValue(text01);
|
|
|
|
|
cell02.setCellValue(text02);
|
|
|
|
|
cell03.setCellValue(text03);
|
|
|
|
|
cell04.setCellValue(text04);
|
|
|
|
|
cell05.setCellValue(text05);
|
|
|
|
|
for (int i = 0; i < logs.size(); i++) {
|
|
|
|
|
HSSFRow row = sheet.createRow(i + 1);
|
|
|
|
|
HSSFCell cell0 = row.createCell(0);
|
|
|
|
|
HSSFCell cell1 = row.createCell(1);
|
|
|
|
|
HSSFCell cell2 = row.createCell(2);
|
|
|
|
|
HSSFCell cell3 = row.createCell(3);
|
|
|
|
|
HSSFCell cell4 = row.createCell(4);
|
|
|
|
|
HSSFCell cell5 = row.createCell(5);
|
|
|
|
|
cell0.setCellStyle(style2);
|
|
|
|
|
cell1.setCellStyle(style2);
|
|
|
|
|
cell2.setCellStyle(style2);
|
|
|
|
|
cell3.setCellStyle(style2);
|
|
|
|
|
cell4.setCellStyle(style2);
|
|
|
|
|
cell5.setCellStyle(style2);
|
|
|
|
|
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 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());
|
|
|
|
|
cell0.setCellValue(text0);
|
|
|
|
|
cell1.setCellValue(text1);
|
|
|
|
|
cell2.setCellValue(text2);
|
|
|
|
|
cell3.setCellValue(text3);
|
|
|
|
|
cell4.setCellValue(text4);
|
|
|
|
|
cell5.setCellValue(text5);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateSysClientFiles(JSONObject manager, int clientId, String fileType, String fileValue) {
|
|
|
|
|
if (fileValue != null) {
|
|
|
|
|
JSONObject fileJson = new JSONObject();
|
|
|
|
|