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,20 +675,19 @@ 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 {
List<JSONObject> dataList = (List<JSONObject>) transFlow.get("data");
String transType; String transType;
JSONObject device;
int status; int status;
resp.setContentType("application/octet-stream;"); HSSFWorkbook wb = new HSSFWorkbook();
resp.addHeader("Content-Disposition",
"attachment; filename=" + "Merchant_Settlement_Info_" + query.getDatefrom() + "_" + query.getDateto() + ".xlsx");
ous = resp.getOutputStream();
Workbook wb = new XSSFWorkbook();
Font font = wb.createFont(); Font font = wb.createFont();
font.setBoldweight(Font.BOLDWEIGHT_BOLD); font.setBoldweight(Font.BOLDWEIGHT_BOLD);
font.setFontHeightInPoints((short) 10); font.setFontHeightInPoints((short) 10);
@ -699,14 +699,15 @@ public class TradeLogServiceImpl implements TradeLogService {
if (clientIds.length >= 2) { if (clientIds.length >= 2) {
clientIdList.addAll(Arrays.asList(clientIds)); clientIdList.addAll(Arrays.asList(clientIds));
} }
Sheet sheet = null; HSSFSheet sheet = null;
JSONObject client = null; JSONObject client = null;
for (int i = 0;i < clientIdList.size();i++) { String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency();
if (i == 0) { for (String clientId : clientIdList) {
sheet = wb.createSheet("ALL"); if ("ALL".equals(clientId)) {
sheet = wb.createSheet(clientId);
} else { } else {
client = clientManager.getClientInfo(Integer.parseInt(clientIdList.get(i))); client = clientManager.getClientInfo(Integer.parseInt(clientId));
sheet = wb.createSheet(client == null ? clientIdList.get(i) : client.getString("client_moniker")); sheet = wb.createSheet(client == null ? clientId : client.getString("client_moniker"));
} }
int rowNum = 0; int rowNum = 0;
Row row = sheet.createRow(rowNum); Row row = sheet.createRow(rowNum);
@ -715,30 +716,52 @@ public class TradeLogServiceImpl implements TradeLogService {
for (int j = 0; j < title.length; j++) { for (int j = 0; j < title.length; j++) {
row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]); row.createCell(j, Cell.CELL_TYPE_STRING).setCellValue(title[j]);
} }
String platformCurrency = PlatformEnvironment.getEnv().getForeignCurrency(); if ("ALL".equals(clientId)) {
for (JSONObject data : dataList) { for (JSONObject log : logs) {
if (!clientIdList.get(i).equals(data.getString("client_id")) && i != 0) { String login_id = log.getString("login_id");
continue; 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")));
} }
if (i == 0) { transType = log.getString("trans_type");
transType = data.getString("trans_type");
if (!"refund".equals(transType)) { if (!"refund".equals(transType)) {
status = data.getIntValue("status"); status = log.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); log.put("trans_type", transType);
device = clientDeviceMapper.find(data.getString("order_dev_id")); scaleDecimalVal(log, "display_amount", platformCurrency);
if (device != null) scaleDecimalVal(log, "transaction_amount", platformCurrency);
data.put("dev_id", device.getString("client_dev_id")); scaleDecimalVal(log, "clearing_amount", platformCurrency);
scaleDecimalVal(data, "display_amount", platformCurrency); row = sheet.createRow(++rowNum);
scaleDecimalVal(data, "transaction_amount", platformCurrency); excelTrans(row, log);
scaleDecimalVal(data, "clearing_amount", platformCurrency);
} }
} 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); 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();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void excelTrans(Row row, JSONObject data) {
row.createCell(0, Cell.CELL_TYPE_STRING).setCellValue(data.getString("transaction_time")); 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(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(2, Cell.CELL_TYPE_STRING).setCellValue(data.getString("system_transaction_id"));
@ -757,16 +780,6 @@ public class TradeLogServiceImpl implements TradeLogService {
row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail")); row.createCell(15, Cell.CELL_TYPE_STRING).setCellValue(data.getString("order_detail"));
row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("dev_id")); row.createCell(16, Cell.CELL_TYPE_STRING).setCellValue(data.getString("dev_id"));
} }
}
wb.write(ous);
ous.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(ous);
}
}
}
@Override @Override
public void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception { public void exportExcelNew(TradeLogQuery query, JSONObject partner, HttpServletResponse response) throws Exception {

@ -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