Add:清算增加导出信息,父商户包含子商户时,导出多张sheet

master
duLingLing 5 years ago
parent 9a5ce125a2
commit df176bff3d

@ -354,6 +354,14 @@ public interface ClientManager {
JSONObject getSettlementLog(JSONObject manager, String clientMoniker, TradeLogQuery query);
/**
*
* @param manager
* @param clientMoniker
* @param query
*/
void excelSettlementLog(JSONObject manager, String clientMoniker, TradeLogQuery query,HttpServletResponse response);
void updateRefundPwd(JSONObject account, String pwd);
void validRefundPwd(JSONObject account, String pwd);
@ -506,4 +514,5 @@ public interface ClientManager {
* @return
*/
JSONObject partnerIncrementalServiceInfo(String clientMoniker, String incrementalId);
}

@ -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();

@ -619,6 +619,12 @@ public class PartnerManageController {
return clientManager.getSettlementLog(manager, clientMoniker, query);
}
@GetMapping(value = "/{clientMoniker}/lists_settlements/excel")
@ReadOnlyConnection
public void excelSettlements(@PathVariable String clientMoniker, TradeLogQuery query, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,HttpServletResponse response){
clientManager.excelSettlementLog(manager, clientMoniker, query,response);
}
@ManagerMapping(value = "/{clientMoniker}/requireCustinfo", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
public void switchRequireCustinfoPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchPermission(manager, clientMoniker, "require_custinfo", pass.getBooleanValue("allow"));

@ -42,6 +42,8 @@ public interface TradeLogService {
JSONObject listSettlementLog(TradeLogQuery query, JSONObject partner);
void listSettlementLogExcel(TradeLogQuery query, JSONObject partner,HttpServletResponse response);
Double getClientUnClearedAmount(JSONObject partner);
void exportTransLog(TradeLogQuery query, JSONObject manager, HttpServletResponse httpResponse);

@ -13,10 +13,7 @@ import au.com.royalpay.payment.manage.mappers.client.ClientCustomersMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingDetailMapper;
import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper;
import au.com.royalpay.payment.manage.mappers.payment.*;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper;
import au.com.royalpay.payment.manage.mappers.system.CustomerMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper;
import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.organizations.core.OrgManager;
import au.com.royalpay.payment.manage.tradelog.beans.PreRefundQueryBean;
@ -121,6 +118,8 @@ public class TradeLogServiceImpl implements TradeLogService {
private StringRedisTemplate stringRedisTemplate;
@Resource
private OrgManager orgManager;
@Resource
private ClientMapper clientMapper;
@Resource
private ClientDeviceMapper clientDeviceMapper;
@ -953,6 +952,127 @@ public class TradeLogServiceImpl implements TradeLogService {
return result;
}
@Override
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");
JSONObject params = query.toParams(timezone);
params.put("client_id", clientId);
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
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);
}
}
@Override
public Double getClientUnClearedAmount(JSONObject partner) {
return transactionMapper.getClientUnClearedAmount(partner.getIntValue("client_id"));

@ -57,6 +57,13 @@ public class TradeFlowController {
return tradeLogService.listSettlementLog(query,partner);
}
@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);
}
@PartnerMapping(value = "/settlement/unclear",method = RequestMethod.GET)
@ReadOnlyConnection
@ResponseBody

@ -4112,6 +4112,16 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
size: 'lg'
});
};
$scope.excelSettlementLogs = function(){
var params = angular.copy($scope.params);
if (params.datefrom) {
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
}
if (params.dateto) {
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
}
return '/sys/partners/'+clientMoniker+'/lists_settlements/excel?datefrom='+params.datefrom+'&dateto='+params.dateto
}
$scope.chooseLast7Days();
}]);
app.controller('partnerSurchargeAccountCtrl', ['$scope', '$uibModal', '$http', 'clientMoniker', '$filter', function ($scope, $uibModal, $http, clientMoniker, $filter) {

@ -61,7 +61,7 @@
<div class="box box-warning">
<div class="box-header">
<h3 class="box-title">Clearing Logs</h3>
<a ng-if="settlementLogs.length>0" target="_blank" style="float: right" ng-href="{{excelSettlementLogs()}}"> <i class="fa fa-download"></i>EXCEL</a>
</div>
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped">

@ -98,8 +98,20 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
$scope.analysis = resp.data.analysis;
});
};
$scope.excelSettlementLogs = function(){
var params = angular.copy($scope.params);
if (params.datefrom) {
params.datefrom = $filter('date')(params.datefrom, 'yyyyMMdd');
}
if (params.dateto) {
params.dateto = $filter('date')(params.dateto, 'yyyyMMdd');
}
return '/client/trans_flow/settlement/log/excelAll?datefrom='+params.datefrom+'&dateto='+params.dateto
}
$scope.loadSettlementLogs(1);
$scope.chooseLast7Days();
$scope.exportSettlementLogs = function(pattern) {
var params = angular.copy($scope.params);
var url = '/client/trans_flow/settlement/log/excel';

@ -127,6 +127,7 @@
</span><i style="cursor:pointer;" class="glyphicon glyphicon-warning-sign text-yellow small"
uib-tooltip-html="htmlTooltip"></i>
</h3>
<a ng-if="settlementLogs.length>0" target="_blank" style="float: right" ng-href="{{excelSettlementLogs()}}"> <i class="fa fa-download"></i>EXCEL</a>
</div>
<div class="box-body table-responsive">
<table class="table table-bordered table-hover table-striped alignCen">

Loading…
Cancel
Save