Merge branch 'develop'

master
yangkai 6 years ago
commit 6bf22dabe7

@ -174,4 +174,6 @@ public interface TransactionMapper {
List<JSONObject> getSettlementLogDetailList(@Param("clientOrders") List<Integer> clientOrders, @Param("client_id") int clientId); List<JSONObject> getSettlementLogDetailList(@Param("clientOrders") List<Integer> clientOrders, @Param("client_id") int clientId);
List<JSONObject> getClientOrderByTransactionTime(JSONObject params); List<JSONObject> getClientOrderByTransactionTime(JSONObject params);
List<JSONObject> listTransFlowDetail(JSONObject params);
} }

@ -70,6 +70,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -674,100 +675,112 @@ public class TradeLogServiceImpl implements TradeLogService {
@Override @Override
public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception { public void exportExcel(TradeLogQuery query, JSONObject partner, HttpServletResponse resp) throws Exception {
logger.debug("excel The method======= exportExcel() start......................."); logger.debug("excel The method======= exportExcel() start.......................");
JSONObject transFlow = listPartnerTransFlow(query, partner); int client_id = partner.getIntValue("client_id");
// JSONObject analysis = transFlow.getJSONObject("analysis"); String timezone = partner.getJSONObject("client").getString("timezone");
if (transFlow.getJSONArray("data").size() > 0) { 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; OutputStream ous = null;
try { String transType;
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data"); int status;
String transType; HSSFWorkbook wb = new HSSFWorkbook();
JSONObject device; Font font = wb.createFont();
int status; font.setBoldweight(Font.BOLDWEIGHT_BOLD);
resp.setContentType("application/octet-stream;"); font.setFontHeightInPoints((short) 10);
resp.addHeader("Content-Disposition", CellStyle analysisStyle = wb.createCellStyle();
"attachment; filename=" + "Merchant_Settlement_Info_" + query.getDatefrom() + "_" + query.getDateto() + ".xlsx"); analysisStyle.setFont(font);
ous = resp.getOutputStream(); String[] clientIds = query.getClient_ids();
Workbook wb = new XSSFWorkbook(); List<String> clientIdList = new ArrayList<>();
Font font = wb.createFont(); clientIdList.add("ALL");
font.setBoldweight(Font.BOLDWEIGHT_BOLD); if (clientIds.length >= 2) {
font.setFontHeightInPoints((short) 10); clientIdList.addAll(Arrays.asList(clientIds));
CellStyle analysisStyle = wb.createCellStyle(); }
analysisStyle.setFont(font); HSSFSheet sheet = null;
String[] clientIds = query.getClient_ids(); JSONObject client = null;
List<String> clientIdList = new ArrayList<>(); String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
clientIdList.add("ALL"); for (String clientId : clientIdList) {
if (clientIds.length >= 2) { if ("ALL".equals(clientId)) {
clientIdList.addAll(Arrays.asList(clientIds)); sheet = wb.createSheet(clientId);
} else {
client = clientManager.getClientInfo(Integer.parseInt(clientId));
sheet = wb.createSheet(client == null ? clientId : client.getString("client_moniker"));
} }
Sheet sheet = null; int rowNum = 0;
JSONObject client = null; Row row = sheet.createRow(rowNum);
for (int i = 0;i < clientIdList.size();i++) { 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",
if (i == 0) { "Transaction Type", "Clearing Status", "Gateway", "Remark", "Dev No"};
sheet = wb.createSheet("ALL"); for (int j = 0; j < title.length; j++) {
} else { row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
client = clientManager.getClientInfo(Integer.parseInt(clientIdList.get(i))); }
sheet = wb.createSheet(client == null ? clientIdList.get(i) : client.getString("client_moniker")); if ("ALL".equals(clientId)) {
} for (JSONObject log : logs) {
int rowNum = 0; String login_id = log.getString("login_id");
Row row = sheet.createRow(rowNum); if (StringUtils.isNotEmpty(login_id)) {
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", log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : login_id+":"+log.getString("order_detail")));
"Transaction Type", "Clearing Status", "Gateway", "Remark", "Dev No"}; }else{
for (int j = 0; j < title.length; j++) { log.put("order_detail", (StringUtils.isEmpty(log.getString("order_detail")) ? "" : log.getString("order_detail")));
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 (i == 0) { transType = log.getString("trans_type");
transType = data.getString("trans_type"); if (!"refund".equals(transType)) {
if (!"refund".equals(transType)) { status = log.getIntValue("status");
status = data.getIntValue("status"); if (status == 6)
if (status == 6) transType = "Partly " + transType;
transType = "Partly " + transType; else if (status == 7) {
else if (status == 7) { transType = "Fully " + transType;
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); row = sheet.createRow(++rowNum);
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_time")); excelTrans(row, log);
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")); } else {
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(data.getString("client_moniker")); List<JSONObject> logsByClientId = logs.stream().filter(log -> log.getString("client_id").equals(clientId)).collect(Collectors.toList());
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(data.getString("short_name")); for (JSONObject log : logsByClientId) {
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_id")); row = sheet.createRow(++rowNum);
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(data.getString("channel")); excelTrans(row, log);
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(data.getString("display_amount"));
row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_amount"));
row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(data.getString("currency"));
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_amount"));
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type").equals("clearing")?"-":data.getBigDecimal("exchange_rate").toString());
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type"));
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clear_status"));
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(data.getString("gateway"));
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail"));
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("dev_id"));
} }
} }
}
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); wb.write(ous);
ous.flush(); ous.close();
} catch (IOException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} finally {
IOUtils.closeQuietly(ous);
} }
} }
} }
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"));
row.createCell(3, Cell.CELL_TYPE_STRING).setCellValue(data.getString("client_moniker"));
row.createCell(4, Cell.CELL_TYPE_STRING).setCellValue(data.getString("short_name"));
row.createCell(5, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_id"));
row.createCell(6, Cell.CELL_TYPE_STRING).setCellValue(data.getString("channel"));
row.createCell(7, Cell.CELL_TYPE_STRING).setCellValue(data.getString("display_amount"));
row.createCell(8, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_amount"));
row.createCell(9, Cell.CELL_TYPE_STRING).setCellValue(data.getString("currency"));
row.createCell(10, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clearing_amount"));
row.createCell(11, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type").equals("clearing")?"-":data.getBigDecimal("exchange_rate").toString());
row.createCell(12, Cell.CELL_TYPE_STRING).setCellValue(data.getString("trans_type"));
row.createCell(13, Cell.CELL_TYPE_STRING).setCellValue(data.getString("clear_status"));
row.createCell(14, Cell.CELL_TYPE_STRING).setCellValue(data.getString("gateway"));
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail"));
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("dev_id"));
}
@Override @Override
public void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception { public void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {
logger.debug("excel The method======= exportExcelNew() start......................."); logger.debug("excel The method======= exportExcelNew() start.......................");

@ -58,8 +58,6 @@
<select id="listTransFlow" resultType="com.alibaba.fastjson.JSONObject"> <select id="listTransFlow" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*, SELECT t.*,
o.status, o.status,
c.client_moniker,
c.short_name,
o.dev_id order_dev_id, o.dev_id order_dev_id,
ifnull(o.client_order_id,'--') client_order_id, ifnull(o.client_order_id,'--') client_order_id,
if(t.channel='Settlement','clearing', if(t.channel='Settlement','clearing',
@ -111,7 +109,6 @@
FROM pmt_transactions t FROM pmt_transactions t
LEFT JOIN pmt_orders o ON o.order_id=t.order_id 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_customer_relation_alipay ra on ra.alipay_uid = o.customer_id
LEFT JOIN sys_clients c on c.client_id = t.client_id
<where> <where>
<if test="client_ids!=null"> <if test="client_ids!=null">
AND t.client_id IN AND t.client_id IN
@ -1102,4 +1099,90 @@
<if test="from!=null">and t.transaction_time &gt;= #{from}</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="to!=null">and t.transaction_time &lt; #{to}</if>
</select> </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> </mapper>

Loading…
Cancel
Save