yangkai 6 years ago
parent 3ad1a84834
commit b5287202ae

@ -175,5 +175,4 @@ public interface TransactionMapper {
List<JSONObject> getClientOrderByTransactionTime(JSONObject params);
List<JSONObject> listTransFlowDetail(JSONObject params);
}

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

@ -673,91 +673,64 @@ public class TradeLogServiceImpl implements TradeLogService {
}
@Override
public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
logger.debug("excel The method======= exportExcel() start.......................");
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;
JSONObject transFlow = listPartnerTransFlow(query, partner);
// JSONObject analysis = transFlow.getJSONObject("analysis");
if (transFlow.getJSONArray("data").size() > 0) {
try {
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
String transType;
JSONObject device;
int status;
HSSFWorkbook wb = new HSSFWorkbook();
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font);
String[] clientIds = query.getClient_ids();
List<String> clientIdList = new ArrayList<>();
clientIdList.add("ALL");
if (clientIds.length >= 2) {
clientIdList.addAll(Arrays.asList(clientIds));
}
HSSFSheet sheet = null;
JSONObject client = null;
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
for (String clientId : clientIdList) {
if ("ALL".equals(clientId)) {
sheet = wb.createSheet(clientId);
} else {
client = clientManager.getClientInfo(Integer.parseInt(clientId));
sheet = wb.createSheet(client == null ? clientId : client.getString("client_moniker"));
}
int rowNum = 0;
Row row = sheet.createRow(rowNum);
String[] title = {"Transaction Time", "Client Order ID", "System Order ID", "Client Moniker", "Short Name", "Order ID", "Channel", "Input Amount", "Transaction Amount", "Transaction Currency", "Clearing Amount", "Exchange Rate",
"Transaction Type", "Clearing Status", "Gateway", "Remark", "Dev No"};
for (int j = 0; j < title.length; j++) {
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
}
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")));
}
transType = log.getString("trans_type");
if (!"refund".equals(transType)) {
status = log.getIntValue("status");
for (JSONObject data : dataList) {
transType = data.getString("trans_type");
if (!"refund".equals(transType))
continue;
status = data.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"));
}
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();
JSONObject parmerters = new JSONObject();
parmerters.put("dateFrom", StringUtils.isNotBlank(query.getDatefrom()) ? query.getDatefrom() : "");
parmerters.put("dateTo", StringUtils.isNotBlank(query.getDateto()) ? query.getDateto() : DateFormatUtils.format(new Date(), "yyyyMMdd"));
parmerters.put("partnerCode", partner.getString("client_moniker"));
// parmerters.put("actual_fee", analysis.containsKey("actual_fee") ?
// analysis.getBigDecimal("actual_fee") : 0);
JRDataSource jrDataSource = new JRBeanCollectionDataSource(dataList);
response.setContentType("application/vnd.ms-excel");
String fileName = StringUtils.isEmpty(parmerters.getString("dateFrom")) ? parmerters.getString("dateTo")
: (parmerters.getString("dateFrom") + "~" + parmerters.getString("dateTo"));
// String fileName = new String(URLEncoder.encode(defaultname,"utf8"));
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
OutputStream outputStream = response.getOutputStream();
JasperPrint jasperPrint = JasperFillManager.fillReport(trans_excel.getInputStream(), parmerters, jrDataSource);
// JRXlsExporter exporter = new JRXlsExporter();
JRXlsxExporter exporter = new JRXlsxExporter();
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
exporter.setExporterInput(exporterInput);
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(outputStream);
exporter.setExporterOutput(exporterOutput);
// 设置导出时参数
SimpleXlsxReportConfiguration xlsReportConfiguration = new SimpleXlsxReportConfiguration();
xlsReportConfiguration.setOnePagePerSheet(false);
xlsReportConfiguration.setRemoveEmptySpaceBetweenRows(true);
xlsReportConfiguration.setDetectCellType(true);
xlsReportConfiguration.setWhitePageBackground(false);
exporter.setConfiguration(xlsReportConfiguration);
exporter.exportReport();
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@ -1373,4 +1346,97 @@ public class TradeLogServiceImpl implements TradeLogService {
e.printStackTrace();
}
}
@Override
public void exportExcelAllPartner(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
logger.debug("excel The method======= exportExcel() start.......................");
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.listTransFlow(params);
TimeZoneUtils.switchTimeZoneToString(logs, timezone, "dd/MM/yyyy HH:mm:ss", Arrays.asList("transaction_time"));
if (logs.size() > 0) {
OutputStream ous = null;
String transType;
int status;
HSSFWorkbook wb = new HSSFWorkbook();
Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10);
CellStyle analysisStyle = wb.createCellStyle();
analysisStyle.setFont(font);
String[] clientIds = query.getClient_ids();
List<String> clientIdList = new ArrayList<>();
clientIdList.add("ALL");
if (clientIds.length >= 2) {
clientIdList.addAll(Arrays.asList(clientIds));
}
HSSFSheet sheet = null;
JSONObject client = null;
JSONObject device = null;
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
for (String clientId : clientIdList) {
if ("ALL".equals(clientId)) {
sheet = wb.createSheet(clientId);
} else {
client = clientManager.getClientInfo(Integer.parseInt(clientId));
sheet = wb.createSheet(client == null ? clientId : client.getString("client_moniker"));
}
int rowNum = 0;
Row row = sheet.createRow(rowNum);
String[] title = {"Transaction Time", "Client Order ID", "System Order ID", "Client Moniker", "Short Name", "Order ID", "Channel", "Input Amount", "Transaction Amount", "Transaction Currency", "Clearing Amount", "Exchange Rate",
"Transaction Type", "Clearing Status", "Gateway", "Remark", "Dev No"};
for (int j = 0; j < title.length; j++) {
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
}
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")));
}
transType = log.getString("trans_type");
if ("refund".equals(transType)) {
status = log.getIntValue("status");
if (status == 6)
transType = "Partly " + transType;
else if (status == 7) {
transType = "Fully " + transType;
}
log.put("trans_type", transType);
device = clientDeviceMapper.find(log.getString("order_dev_id"));
if (device != null)
log.put("dev_id", device.getString("client_dev_id"));
}
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=" + query.getDatefrom() + "_" + query.getDateto() + ".xls");
ous = resp.getOutputStream();
try {
wb.write(ous);
ous.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

@ -71,4 +71,8 @@ public class TradeFlowController {
tradeLogService.exportPDFSettlement(query, partner, response);
}
@PartnerMapping(value = "/report/excel_detail_all", method = RequestMethod.GET)
public void exportExcelDetailAllPartner(TradeLogQuery query, @ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, HttpServletResponse httpResponse) throws Exception {
tradeLogService.exportExcelAllPartner(query,partner,httpResponse);
}
}

@ -58,6 +58,8 @@
<select id="listTransFlow" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*,
o.status,
c.client_moniker,
c.short_name,
o.dev_id order_dev_id,
ifnull(o.client_order_id,'--') client_order_id,
if(t.channel='Settlement','clearing',
@ -109,6 +111,7 @@
FROM pmt_transactions t
LEFT JOIN pmt_orders o ON o.order_id=t.order_id
left join sys_customer_relation_alipay ra on ra.alipay_uid = o.customer_id
LEFT JOIN sys_clients c on c.client_id = t.client_id
<where>
<if test="client_ids!=null">
AND t.client_id IN
@ -1099,90 +1102,4 @@
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
</select>
<select id="listTransFlowDetail" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*,
o.status,
c.client_moniker,
c.short_name,
d.client_dev_id,
o.dev_id order_dev_id,
ifnull(o.client_order_id,'--') client_order_id,
if(t.channel='Settlement','clearing',
if(t.transaction_type='Credit','payment','refund')) trans_type,
t.system_transaction_id,
if(t.channel='Settlement',
if(locate('MERCHANT',t.system_transaction_id)>0, 'Transfer to Merchant','Merchant Service Fee'),
if(t.system_generate=0,t.order_id,t.remark)) order_id2,
if(t.channel='Settlement','-',CASE t.clearing_status
WHEN 0 THEN 'ReadyToClear'
WHEN 1 THEN 'Cleared'
WHEN 2 THEN 'Preauthorised'
END) clear_status,
o.order_detail,o.display_amount,o.channel,o.currency,o.pre_authorization,
CASE o.gateway
WHEN 0
THEN 'Retail In-Store'
WHEN 1
THEN 'Retail In-Store'
WHEN 2
THEN 'QR Code'
WHEN 3
THEN 'Online API'
WHEN 4
THEN 'WeChat HTML5'
WHEN 5
THEN 'Retail API'
WHEN 6
THEN 'Retail API'
WHEN 7
THEN 'QR Code'
WHEN 8
THEN 'Mobile H5'
WHEN 9
THEN 'Third Party Gateway'
WHEN 10
THEN 'APP'
WHEN 12
THEN 'MICROAPP'
WHEN 13
THEN 'Native QR Code'
WHEN 14
THEN 'Share Link'
END AS gateway,
CASE o.channel
WHEN 'Alipay' THEN ra.login_id
WHEN 'AlipayOnline' THEN ra.login_email
END login_id
FROM pmt_transactions t
LEFT JOIN pmt_orders o ON o.order_id=t.order_id
left join sys_customer_relation_alipay ra on ra.alipay_uid = o.customer_id
LEFT JOIN sys_clients c on c.client_id = t.client_id
LEFT JOIN sys_clients_devices d on d.dev_id = o.dev_id
<where>
<if test="client_ids!=null">
AND t.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id}
</foreach>
</if>
<if test="client_ids==null">
and t.client_id=#{client_id}
</if>
<if test="from!=null">and t.transaction_time &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if>
<if test="transaction_type!=null">and t.transaction_type=#{transaction_type}</if>
<if test="date!=null">and date(t.transaction_time)=date(#{date})</if>
<if test="clearing_status!=null">and t.clearing_status=#{clearing_status}</if>
<if test="trans_type==1">and t.transaction_type = 'Credit'</if>
<if test="trans_type==2">and t.refund_id is NOT NULL</if>
<if test="trans_type==3">and t.transaction_type='Debit' and t.refund_id is NULL</if>
<if test="channel!=null">
and
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">o.channel=#{chan}
</foreach>
</if>
</where>
order by t.transaction_time desc
</select>
</mapper>

@ -175,6 +175,7 @@
<li><a target="_blank" ng-href="{{export('pdf')}}">PDF</a></li>
<li><a target="_blank" ng-href="{{export('excel')}}">EXCEL</a></li>
<li><a target="_blank" ng-href="{{export('excel_detail')}}">EXCEL(Detail)</a></li>
<li><a target="_blank" ng-href="{{export('excel_detail_all')}}">EXCEL(All Partner Detail)</a></li>
</ul>
</div>

@ -110,6 +110,9 @@ define(['angular', 'uiBootstrap', 'uiRouter'], function (angular) {
if (type=='excel_detail'){
url='/client/trans_flow/report/excel_detail';
}
if (type=='excel_detail_all'){
url='/client/trans_flow/report/excel_detail_all';
}
var connectSymbol = '?';
var params = angular.copy($scope.params);
if (params.clearing_status) {

Loading…
Cancel
Save