secure upload

master
yixian 6 years ago
parent 3ac82ce0e3
commit e43b4b0f42

@ -8,8 +8,6 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import java.math.BigDecimal;
import java.util.Date;
@ -102,6 +100,7 @@ public interface TransactionMapper {
BigDecimal TotalAmountForBDPrize(@Param("year") int year, @Param("month") int month, @Param("bd_id") String bd_id);
BigDecimal TotalAmountForBDLeaderPrize(@Param("year") int year, @Param("month") int month, @Param("bd_group") String bd_group);
BigDecimal TotalAmountForSydneyGMPrize(@Param("year") int year, @Param("month") int month);
List<JSONObject> listTransactionForCityPartnerCommissionByDate(@Param("year") int year, @Param("month") int month);
@ -120,9 +119,9 @@ public interface TransactionMapper {
@AdvanceSelect(addonWhereClause = "transaction_type='Credit'")
int countOrders(@Param("client_id") int client_id);
List<JSONObject> listDailyTransactions(@Param("from") Date from, @Param("to") Date to, @Param("dev_id") String devId, @Param("client_id") int clientId,@Param("client_ids")String [] client_ids);
List<JSONObject> listDailyTransactions(@Param("from") Date from, @Param("to") Date to, @Param("dev_id") String devId, @Param("client_id") int clientId, @Param("client_ids") String[] client_ids);
JSONObject analysisRetailDailyReport(@Param("from") Date from, @Param("to") Date to, @Param("dev_id") String devId, @Param("client_id") int clientId,@Param("client_ids")String [] client_ids);
JSONObject analysisRetailDailyReport(@Param("from") Date from, @Param("to") Date to, @Param("dev_id") String devId, @Param("client_id") int clientId, @Param("client_ids") String[] client_ids);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "system_generate=1")
@ -156,6 +155,7 @@ public interface TransactionMapper {
/**
* 退退
*
* @param clientId
* @param systemTransactionId
* @return
@ -164,4 +164,8 @@ public interface TransactionMapper {
PageList<JSONObject> findByClientIdAndSystemTransactionId(@Param("client_id") int clientId,
@Param("system_transaction_id") String systemTransactionId,
PageBounds pageBounds);
List<JSONObject> listCreditTransactionsForSecure(Date from, Date to);
List<JSONObject> listDebitTransactionsForSecure(Date from, Date to);
}

@ -0,0 +1,17 @@
package au.com.royalpay.payment.manage.system.core;
import au.com.royalpay.payment.manage.system.core.beans.TradeSecureFile;
import java.util.Date;
/**
* Create by yixian at 2019-01-08 3:17
*/
public interface TradeSecureService {
void uploadSecureReportYesterday();
void uploadSecureReport(Date date);
TradeSecureFile getSecureReportFile(Date date);
}

@ -0,0 +1,149 @@
package au.com.royalpay.payment.manage.system.core.beans;
import au.com.royalpay.payment.tools.defines.TradeType;
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
import com.alibaba.fastjson.JSONObject;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import java.util.stream.Collectors;
/**
* Create by yixian at 2019-01-08 3:27
*/
public class TradeSecureFile {
private static final DateTimeZone zone = DateTimeZone.forTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
private final String pid;
private final DateTime transDate;
private final DateTime createTime;
private List<TradeItem> tradeItems;
private byte[] content;
public TradeSecureFile(String pid, Date transDate) {
this.pid = pid;
this.transDate = new DateTime(transDate).withZoneRetainFields(zone).withMillisOfDay(0);
this.tradeItems = new ArrayList<>();
this.createTime = DateTime.now(zone);
}
public DateTime getTransDate() {
return transDate;
}
public Date getFromTime() {
return transDate.withZone(DateTimeZone.forTimeZone(TimeZone.getDefault())).toDate();
}
public Date getToTime() {
return transDate.plusDays(1).withZone(DateTimeZone.forTimeZone(TimeZone.getDefault())).toDate();
}
public TradeSecureFile addTransactions(List<JSONObject> transactions) {
tradeItems.addAll(transactions.stream().map(TradeItem::new).collect(Collectors.toList()));
return this;
}
public void writeToHttp(HttpServletResponse response) {
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + filename());
try (OutputStream ous = response.getOutputStream()) {
ous.write(content());
ous.flush();
} catch (IOException e) {
throw new ServerErrorException(e);
}
}
public String filename() {
return String.join("_", transDate.toString("yyMMdd"), pid, createTime.toString("yyMMddHHmmss"));
}
public byte[] content() {
return content == null ? build() : content;
}
private byte[] build() {
try (ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(new OutputStreamWriter(bos, StandardCharsets.UTF_8))) {
writer.println(headerLine());
for (TradeItem item : tradeItems) {
writer.println(item.line());
}
content = bos.toByteArray();
return content;
} catch (IOException e) {
throw new ServerErrorException(e);
}
}
private String headerLine() {
int totalCount = tradeItems.size();
BigDecimal totalCredit = tradeItems.stream().filter(TradeItem::isCredit).map(TradeItem::getClearingAmount)
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
BigDecimal totalDebit = tradeItems.stream().filter(TradeItem::isDebit).map(TradeItem::getClearingAmount)
.reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
String date = transDate.toString("yyyy-MM-dd");
String[] columns = {String.valueOf(totalCount), totalCredit.toPlainString(), totalDebit.toPlainString(), date, pid};
return String.join("|", columns);
}
class TradeItem {
private String clientMoniker;
private String orderId;
private String channel;
private TradeType gateway;
private BigDecimal price;
private BigDecimal clearingAmount;
private String currency;
private BigDecimal exchangeRate;
private String transactionType;
private Date transactionTime;
public TradeItem(JSONObject item) {
clientMoniker = item.getString("client_moniker");
transactionType = item.getString("transaction_type");
orderId = isCredit() ? item.getString("order_id") : item.getString("out_refund_id");
channel = item.getString("order_channel");
gateway = TradeType.fromGatewayNumber(item.getIntValue("gateway"));
currency = item.getString("transaction_currency");
price = CurrencyAmountUtils.scale(item.getBigDecimal("transaction_amount"), currency);
clearingAmount = CurrencyAmountUtils.scale(item.getBigDecimal("clearing_amount"), PlatformEnvironment.getEnv().getForeignCurrency());
exchangeRate = item.getBigDecimal("exchange_rate");
transactionTime = item.getDate("transaction_time");
}
public String line() {
String[] columns = {clientMoniker, orderId, channel, gateway.toString(), price.toPlainString(), clearingAmount.toPlainString(), currency,
exchangeRate.toPlainString(), filterStatus(), new DateTime(transactionTime).withZone(zone).toString()};
return String.join("|", columns);
}
private String filterStatus() {
return isCredit() ? "SUCCESS" : "REFUND";
}
public boolean isCredit() {
return "Credit".equals(transactionType);
}
public boolean isDebit() {
return "Debit".equals(transactionType);
}
public BigDecimal getClearingAmount() {
return clearingAmount;
}
}
}

@ -0,0 +1,94 @@
package au.com.royalpay.payment.manage.system.core.impl;
import au.com.royalpay.payment.core.exceptions.ChannelNetworkException;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.system.core.TradeSecureService;
import au.com.royalpay.payment.manage.system.core.beans.TradeSecureFile;
import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.*;
import org.apache.commons.vfs2.FileSystemOptions;
import org.apache.commons.vfs2.provider.sftp.SftpClientFactory;
import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.List;
/**
* Create by yixian at 2019-01-08 3:26
*/
@Service
public class TradeSecureServiceHanyinImpl implements TradeSecureService {
@Value("${app.hanyin-secure.pid:ROYALPAY}")
private String pid;
@Value("${app.hanyin-secure.sftp-host}")
private String sftpHost;
@Value("${app.hanyin-secure.sftp-port}")
private int sftpPort;
@Value("${app.hanyin-secure.sftp-username}")
private String sftpUsername;
@Value("${app.hanyin-secure.sftp-pwd}")
private String sftpPwd;
@Resource
private TransactionMapper transactionMapper;
@Override
public void uploadSecureReportYesterday() {
uploadSecureReport(DateTime.now().plusDays(-1).withMillisOfDay(0).toDate());
}
@Override
public void uploadSecureReport(Date date) {
TradeSecureFile file = getSecureReportFile(date);
sftpUpload(file);
}
private void sftpUpload(TradeSecureFile file) {
Session session = null;
ChannelSftp command = null;
try {
session = initSFTPConnection();
Channel channel = session.openChannel("sftp");
channel.connect();
command = (ChannelSftp) channel;
command.ls("/royalpay");
String dir = "/royalpay/" + file.getTransDate().toString("yyyyMMdd");
command.rmdir(dir);
command.mkdir(dir);
String dest = dir + file.filename();
command.put(new ByteArrayInputStream(file.content()), dest);
} catch (IOException | JSchException | SftpException e) {
throw new ChannelNetworkException("Upload Secure file failed", e);
} finally {
if (command != null && command.isConnected()) {
command.exit();
session.disconnect();
}
}
}
private Session initSFTPConnection() throws IOException {
FileSystemOptions fso = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(fso, "no");
return SftpClientFactory.createConnection(sftpHost, sftpPort,
sftpUsername.toCharArray(), sftpPwd.toCharArray(), fso);
}
@Override
public TradeSecureFile getSecureReportFile(Date date) {
TradeSecureFile file = new TradeSecureFile(pid, date);
Date from = file.getFromTime();
Date to = file.getToTime();
List<JSONObject> credits = transactionMapper.listCreditTransactionsForSecure(from, to);
file.addTransactions(credits);
List<JSONObject> debits = transactionMapper.listDebitTransactionsForSecure(from, to);
file.addTransactions(debits);
return file;
}
}

@ -0,0 +1,26 @@
package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.system.core.TradeSecureService;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* Create by yixian at 2019-01-08 3:13
*/
@Component
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class SecureTask {
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Resource
private TradeSecureService tradeSecureService;
@Scheduled(cron = "0 0 3 * * *")
public void pushSecureFile(){
synchronizedScheduler.executeProcess("task:secure_file_uploading",600_000,()->tradeSecureService.uploadSecureReportYesterday());
}
}

@ -133,3 +133,11 @@ settle.abafile.bank.ANZ.apca=514624
settle.abafile.bank.ANZ.bsb=013006
settle.abafile.bank.ANZ.account-no=837022519
settle.abafile.bank.ANZ.account-name=Tunnel Show Pty Ltd
# 瀚银Secure
app.hanyin-secure.pid=ROYALPAY
app.hanyin-secure.sftp-host=180.168.61.86
app.hanyin-secure.sftp-port=28480
app.hanyin-secure.sftp-username=royalpay
app.hanyin-secure.sftp-pwd=royalpay

@ -4,13 +4,19 @@
<update id="removeSettleRemark">
UPDATE pmt_transactions AS t
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
SET clearing_status = 0, clearing_order = NULL, clearing_time = NULL
SET clearing_status = 0,
clearing_order = NULL,
clearing_time = NULL
WHERE d.clearing_id = #{clearing_id}
</update>
<delete id="deleteSettlementTransaction">
DELETE t FROM pmt_transactions t
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
WHERE d.clearing_id = #{clearing_id} AND t.transaction_type = 'Debit' AND t.refund_id IS NULL and t.channel='Settlement'
DELETE t
FROM pmt_transactions t
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
WHERE d.clearing_id = #{clearing_id}
AND t.transaction_type = 'Debit'
AND t.refund_id IS NULL
and t.channel = 'Settlement'
</delete>
<select id="listTransFlowPage" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*,if(t.refund_id is not null,'refund',if(t.transaction_type='Debit' AND
@ -95,7 +101,7 @@
THEN 'Native QR Code'
WHEN 14
THEN 'Share Link'
END AS gateway,
END AS gateway,
CASE o.channel
WHEN 'Alipay' THEN ra.login_id
WHEN 'AlipayOnline' THEN ra.login_email
@ -217,14 +223,16 @@
<select id="findLastIncome" resultType="com.alibaba.fastjson.JSONObject">
SELECT *
FROM pmt_transactions
WHERE channel = 'Wechat' AND transaction_type = 'Credit'
WHERE channel = 'Wechat'
AND transaction_type = 'Credit'
ORDER BY transaction_time DESC
LIMIT 1
</select>
<select id="getClientUnClearedAmount" resultType="java.lang.Double">
SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0)
FROM pmt_transactions
WHERE clearing_status = 0 AND client_id = #{client_id}
WHERE clearing_status = 0
AND client_id = #{client_id}
</select>
<select id="getClientsUnClearedAmount" resultType="com.alibaba.fastjson.JSONObject">
@ -252,14 +260,13 @@
</select>
<select id="listPreRefundClients" resultType="com.alibaba.fastjson.JSONObject">
SELECT *
FROM (SELECT
ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) amount,
c.client_id client_id,
max(t.transaction_time) transation_time,
c.client_moniker client_moniker
FROM (SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) amount,
c.client_id client_id,
max(t.transaction_time) transation_time,
c.client_moniker client_moniker
FROM pmt_transactions t
INNER JOIN sys_clients c ON t.client_id = c.client_id
INNER JOIN sys_client_config cc on cc.client_id = c.client_id AND cc.enable_refund_auth = 1
INNER JOIN sys_clients c ON t.client_id = c.client_id
INNER JOIN sys_client_config cc on cc.client_id = c.client_id AND cc.enable_refund_auth = 1
GROUP BY c.client_id) a
WHERE a.amount &lt; 0
</select>
@ -281,41 +288,38 @@
</select>
<select id="listUnclearedTransactionsOfClient" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
c.client_id,
c.client_moniker,
c.parent_client_id,
c.org_id,
cc.clean_days,
t.transaction_id,
t.transaction_type,
t.transaction_time,
t.clearing_amount,
t.channel,
t.system_generate,
t.order_id,
t.refund_id,
t.cny_amount,
t.exchange_rate,
o.display_amount,
o.total_amount
SELECT c.client_id,
c.client_moniker,
c.parent_client_id,
c.org_id,
cc.clean_days,
t.transaction_id,
t.transaction_type,
t.transaction_time,
t.clearing_amount,
t.channel,
t.system_generate,
t.order_id,
t.refund_id,
t.cny_amount,
t.exchange_rate,
o.display_amount,
o.total_amount
FROM pmt_transactions t
INNER JOIN sys_clients c ON c.client_id = t.client_id
inner join sys_client_config cc on cc.client_id = c.client_id
LEFT JOIN pmt_orders o ON o.order_id = t.order_id
WHERE t.clearing_order IS NULL AND t.clearing_status = 0 AND t.channel != 'Settlement' AND
t.client_id = #{client_id} AND
((t.transaction_type = 'Credit' AND t.transaction_time < #{end} AND t.channel != 'System')
OR (t.transaction_type = 'Credit' AND date(t.transaction_time) < date(#{settleDate}) AND
t.channel = 'System')
OR (t.transaction_type = 'Debit' AND t.transaction_time < now())
)
INNER JOIN sys_clients c ON c.client_id = t.client_id
inner join sys_client_config cc on cc.client_id = c.client_id
LEFT JOIN pmt_orders o ON o.order_id = t.order_id
WHERE t.clearing_order IS NULL
AND t.clearing_status = 0
AND t.channel != 'Settlement'
AND t.client_id = #{client_id}
AND ((t.transaction_type = 'Credit' AND t.transaction_time < #{end} AND t.channel != 'System')
OR (t.transaction_type = 'Credit' AND date(t.transaction_time) < date(#{settleDate}) AND
t.channel = 'System')
OR (t.transaction_type = 'Debit' AND t.transaction_time < now())
)
GROUP BY t.transaction_id
ORDER BY t.transaction_type, t.transaction_time
]]>
</select>
@ -461,77 +465,66 @@
<select id="getMerchantAmount" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT temp.*
FROM (
SELECT
#{clearing_date} AS order_time,
#{clearing_date} AS clearing_time,
t.client_id,
round(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) *
(100 - ifnull(min(r.rate_value), 1.4))) / 100 clearing_amount,
t.transaction_currency currency,
t.order_id
SELECT #{clearing_date} AS order_time,
#{clearing_date} AS clearing_time,
t.client_id,
round(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) *
(100 - ifnull(min(r.rate_value), 1.4))) / 100 clearing_amount,
t.transaction_currency currency,
t.order_id
FROM pmt_transactions t
INNER JOIN sys_client_config c ON t.client_id = c.client_id AND c.skip_clearing = 0
LEFT JOIN sys_client_rates r ON r.client_id = t.client_id
AND date(r.expiry_time) >= DATE(t.transaction_time)
AND date(r.active_time) <= DATE(t.transaction_time)
INNER JOIN sys_bank_accounts a ON a.client_id = t.client_id
WHERE
t.transaction_time >= #{from} AND t.transaction_time < #{to} AND t.channel != 'Settlement'
INNER JOIN sys_client_config c ON t.client_id = c.client_id AND c.skip_clearing = 0
LEFT JOIN sys_client_rates r ON r.client_id = t.client_id
AND date(r.expiry_time) >= DATE(t.transaction_time)
AND date(r.active_time) <= DATE(t.transaction_time)
INNER JOIN sys_bank_accounts a ON a.client_id = t.client_id
WHERE t.transaction_time >= #{from}
AND t.transaction_time < #{to}
AND t.channel != 'Settlement'
GROUP BY t.client_id) temp
WHERE clearing_amount != 0
]]>
</select>
<select id="getSumMerchantAmount" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT SUM(temp.clearing_amount) clearing_amount
FROM
(SELECT round(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) *
(100 - ifnull(min(r.rate_value), 1.6))) / 100 clearing_amount
FROM pmt_transactions t
INNER JOIN sys_client_config c ON t.client_id = c.client_id AND c.skip_clearing = 0
LEFT JOIN sys_client_rates r ON r.client_id = t.client_id
AND date(r.expiry_time) >= DATE(t.transaction_time)
AND date(r.active_time) <= DATE(t.transaction_time)
INNER JOIN sys_bank_accounts a ON a.client_id = t.client_id
WHERE
t.transaction_time >= #{from} AND t.transaction_time < #{to} AND t.channel != 'Settlement'
GROUP BY t.client_id) temp
FROM (SELECT round(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) *
(100 - ifnull(min(r.rate_value), 1.6))) / 100 clearing_amount
FROM pmt_transactions t
INNER JOIN sys_client_config c ON t.client_id = c.client_id AND c.skip_clearing = 0
LEFT JOIN sys_client_rates r ON r.client_id = t.client_id
AND date(r.expiry_time) >= DATE(t.transaction_time)
AND date(r.active_time) <= DATE(t.transaction_time)
INNER JOIN sys_bank_accounts a ON a.client_id = t.client_id
WHERE t.transaction_time >= #{from}
AND t.transaction_time < #{to}
AND t.channel != 'Settlement'
GROUP BY t.client_id) temp
WHERE temp.clearing_amount != 0
]]>
</select>
<select id="analysisTotalTransactions" resultType="java.lang.Double">
<![CDATA[
SELECT ifnull(sum(clearing_amount), 0) total
FROM pmt_transactions
WHERE client_id = #{client_id} AND date(transaction_time) >= date(#{begin}) AND
date(transaction_time) <= date(#{end})
WHERE client_id = #{client_id}
AND date(transaction_time) >= date(#{begin})
AND date(transaction_time) <= date(#{end})
]]>
</select>
<select id="listTransactionsOfClearingTask" resultType="com.alibaba.fastjson.JSONObject">
SELECT
t.*,
cl.client_moniker
SELECT t.*,
cl.client_moniker
FROM pmt_transactions t
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
INNER JOIN log_clearing c ON c.clearing_id = d.clearing_id AND c.clearing_id = #{clear_id}
INNER JOIN sys_clients cl ON cl.client_id = t.client_id
inner join sys_client_config cc on cc.clear_id = cl.client_id and cc.is_valid = 1
WHERE t.transaction_type = 'Credit' OR t.refund_id IS NOT NULL
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
INNER JOIN log_clearing c ON c.clearing_id = d.clearing_id AND c.clearing_id = #{clear_id}
INNER JOIN sys_clients cl ON cl.client_id = t.client_id
inner join sys_client_config cc on cc.clear_id = cl.client_id and cc.is_valid = 1
WHERE t.transaction_type = 'Credit'
OR t.refund_id IS NOT NULL
ORDER BY t.order_id ASC
</select>
@ -560,259 +553,267 @@
<select id="TotalAmountForBDPrize" resultType="java.math.BigDecimal">
<![CDATA[
select sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,-temp.clearing_amount*d.proportion))
total FROM
(SELECT l.client_id,l.clearing_amount,l.refund_id,l.transaction_type,o.create_time FROM pmt_transactions l
INNER JOIN pmt_orders o
ON o.order_id = l.order_id
and year(o.create_time) = #{year} AND month(o.create_time) = #{month}
where (l.transaction_type='Credit' or l.refund_id is not null)
) temp
INNER JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time and
d.is_valid = '1'
AND (d.end_date is null or d.end_date > temp.create_time)
and d.bd_id=#{bd_id}
select sum(if(temp.transaction_type = 'Credit', temp.clearing_amount * d.proportion,
-temp.clearing_amount * d.proportion))
total
FROM (SELECT l.client_id,l.clearing_amount,l.refund_id,l.transaction_type,o.create_time
FROM pmt_transactions l
INNER JOIN pmt_orders o
ON o.order_id = l.order_id
and year(o.create_time) = #{year} AND month(o.create_time) = #{month}
where (l.transaction_type = 'Credit' or l.refund_id is not null)
) temp
INNER JOIN sys_client_bd d ON temp.client_id = d.client_id AND d.start_date <= temp.create_time and
d.is_valid = '1'
AND (d.end_date is null or d.end_date > temp.create_time)
and d.bd_id = #{bd_id}
]]>
</select>
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t.total),0)
total
SELECT ifnull(sum(t.total), 0)
total
FROM statistics_customer_order t
INNER JOIN sys_clients c ON c.client_id = t.client_id AND c.org_id = 1
WHERE year(t.date) = #{year} AND month(t.date) = #{month}
and t.client_id!=0
and t.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND c.bd_group=#{bd_group} or c.manager_id=#{bd_group})
INNER JOIN sys_clients c ON c.client_id = t.client_id AND c.org_id = 1
WHERE year(t.date) = #{year}
AND month(t.date) = #{month}
and t.client_id != 0
and t.client_id in
(SELECT b.client_id
FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id = b.bd_id
where b.is_valid = 1 and b.start_date &lt;= now() and (b.end_date is null or b.end_date &gt;= now())
AND c.bd_group = #{bd_group}
or c.manager_id = #{bd_group})
</select>
<select id="TotalAmountForSydneyGMPrize" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(t.total),0)
total
SELECT ifnull(sum(t.total), 0)
total
FROM statistics_customer_order t
INNER JOIN sys_clients c ON c.client_id = t.client_id AND c.org_id = 1
WHERE year(t.date) = #{year} AND month(t.date) = #{month}
and t.client_id!=0
and t.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND c.city='Sydney')
INNER JOIN sys_clients c ON c.client_id = t.client_id AND c.org_id = 1
WHERE year(t.date) = #{year}
AND month(t.date) = #{month}
and t.client_id != 0
and t.client_id in
(SELECT b.client_id
FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id = b.bd_id
where b.is_valid = 1
and b.start_date &lt;= now()
and (b.end_date is null or b.end_date &gt;= now())
AND c.city = 'Sydney')
</select>
<select id="listTransactionsForCityPartnerCommission" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) * b.proportion
total,
t.client_id,
m.org_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Wechat'), 1) wechat_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Alipay'), 1) alipay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'jd'), 1) jd_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'AlipayOnline'), 2.0) AlipayOnline_rate_value
SELECT sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)) * b.proportion
total,
t.client_id,
m.org_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'Wechat'), 1) wechat_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'Alipay'), 1) alipay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'jd'), 1) jd_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'AlipayOnline'), 2.0) AlipayOnline_rate_value
FROM pmt_transactions t
INNER JOIN sys_clients c ON c.client_id = t.client_id
INNER JOIN sys_client_bd b ON b.client_id = c.client_id AND b.start_date <= t.transaction_time
AND (b.end_date IS NULL OR b.end_date >= t.transaction_time) AND
b.is_valid = 1
INNER JOIN sys_managers m ON m.manager_id = b.bd_id
INNER JOIN sys_org so
ON m.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.citypartner = 1 AND so.commission = 1
WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement'
INNER JOIN sys_clients c ON c.client_id = t.client_id
INNER JOIN sys_client_bd b ON b.client_id = c.client_id AND b.start_date <= t.transaction_time
AND (b.end_date IS NULL OR b.end_date >= t.transaction_time) AND
b.is_valid = 1
INNER JOIN sys_managers m ON m.manager_id = b.bd_id
INNER JOIN sys_org so
ON m.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.citypartner = 1 AND
so.commission = 1
WHERE year(t.transaction_time) = #{year}
AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement'
GROUP BY t.client_id, trade_date, channel
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
]]>
</select>
<select id="listTransactionForCityPartnerCommissionByDate" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select t.org_id,t.clearing_currency,t.client_id,t.channel,t.surcharge_rate,t.transaction_time,if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
t.order_id
from pmt_transactions t INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type=0
AND so.citypartner = 1 AND so.commission = 1
AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement' AND t.channel!='System'
select t.org_id,
t.clearing_currency,
t.client_id,
t.channel,
t.surcharge_rate,
t.transaction_time,
if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
t.order_id
from pmt_transactions t
INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type = 0
AND so.citypartner = 1 AND so.commission = 1
AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement' AND t.channel != 'System'
ORDER BY t.client_id asc
]]>
]]>
</select>
<select id="listTransactionForCityPartnerAgentCommissionByDate" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
select t.org_id,t.client_id,t.channel,t.surcharge_rate,t.transaction_time,if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
t.order_id
from pmt_transactions t INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type=0
AND so.parent_org_id !=''
AND so.citypartner = 1 AND so.commission = 1
AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement' AND t.channel!='System'
select t.org_id,
t.client_id,
t.channel,
t.surcharge_rate,
t.transaction_time,
if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount) clearing_amount,
if(t.transaction_type = 'Credit', t.total_surcharge, -t.total_surcharge) total_surcharge,
if(t.transaction_type = 'Credit', t.channel_surcharge, -t.channel_surcharge) channel_surcharge,
t.order_id
from pmt_transactions t
INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
AND so.type = 0
AND so.parent_org_id != ''
AND so.citypartner = 1 AND so.commission = 1
AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement' AND t.channel != 'System'
ORDER BY t.client_id asc
]]>
]]>
</select>
<select id="listTransactionsForReferrerCommission" resultType="com.alibaba.fastjson.JSONObject">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total,
t.client_id client_id,
so.org_id org_id,
c.source client_source,
date(t.transaction_time) trade_date,
ifnull(so.rate_value, 1) rate_value
SELECT sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total,
t.client_id client_id,
so.org_id org_id,
c.source client_source,
date(t.transaction_time) trade_date,
ifnull(so.rate_value, 1) rate_value
FROM pmt_transactions t
INNER JOIN sys_clients c ON c.client_id = t.client_id
inner join sys_client_config cc on cc.client_id = c.client_id
INNER JOIN sys_org so
ON c.referrer_id = so.org_id AND so.is_valid = 1 AND so.type = 1 AND so.commission = 1
WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement'
INNER JOIN sys_clients c ON c.client_id = t.client_id
inner join sys_client_config cc on cc.client_id = c.client_id
INNER JOIN sys_org so
ON c.referrer_id = so.org_id AND so.is_valid = 1 AND so.type = 1 AND so.commission = 1
WHERE year(t.transaction_time) = #{year}
AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement'
GROUP BY so.org_id, trade_date, t.client_id
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
</select>
<select id="listTransactionsForAgentCommission" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total,
t.client_id client_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull(so.rate_value, 1) rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Wechat'), 1) wechat_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Alipay'), 1) alipay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'jd'), 1) jd_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND
r.expiry_time >= t.transaction_time AND
r.rate_name = 'AlipayOnline'), 2.0) AlipayOnline_rate_value
SELECT sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
total,
t.client_id client_id,
c.approve_time client_create_time,
c.source client_source,
date(t.transaction_time) trade_date,
t.channel channel,
ifnull(so.rate_value, 1) rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'Wechat'), 1) wechat_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'Alipay'), 1) alipay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'Bestpay'), 1) bestpay_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'jd'), 1) jd_rate_value,
ifnull((SELECT min(r.rate_value)
FROM sys_client_rates r
WHERE r.client_id = t.client_id
AND r.active_time <= t.transaction_time
AND r.expiry_time >= t.transaction_time
AND r.rate_name = 'AlipayOnline'), 2.0) AlipayOnline_rate_value
FROM pmt_transactions t
INNER JOIN sys_clients c ON c.client_id = t.client_id
INNER JOIN sys_org so
ON c.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.parent_org_id = #{parent_org_id}
WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement'
INNER JOIN sys_clients c ON c.client_id = t.client_id
INNER JOIN sys_org so
ON c.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.parent_org_id = #{parent_org_id}
WHERE year(t.transaction_time) = #{year}
AND month(t.transaction_time) = #{month}
AND t.channel != 'Settlement'
GROUP BY t.client_id, trade_date, channel
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
]]>
</select>
<select id="checkBalance" resultType="java.math.BigDecimal">
<![CDATA[
SELECT sum(subval)
FROM (SELECT
c.client_moniker,
a.client_id,
a.total_credit,
a.total_debit,
a.total_debit - a.total_credit subval
FROM
(
SELECT
sum(
IF(
t.transaction_type = 'Credit',
t.clearing_amount,
0
)
) total_credit,
sum(
IF(
t.transaction_type = 'Debit',
t.clearing_amount,
0
)
) total_debit,
t.client_id
FROM
pmt_transactions t
WHERE
t.clearing_status = 1
AND (date(t.clearing_time) <= date(#{end}) OR t.clearing_time IS NULL)
GROUP BY
t.client_id
) a
INNER JOIN sys_clients c ON c.client_id = a.client_id
AND c.client_id != 9
AND (
c.parent_client_id != 9
OR c.parent_client_id IS NULL
)
WHERE
abs(total_credit - total_debit) > 1
ORDER BY
subval DESC) t
FROM (SELECT c.client_moniker,
a.client_id,
a.total_credit,
a.total_debit,
a.total_debit - a.total_credit subval
FROM (
SELECT sum(
IF(
t.transaction_type = 'Credit',
t.clearing_amount,
0
)
) total_credit,
sum(
IF(
t.transaction_type = 'Debit',
t.clearing_amount,
0
)
) total_debit,
t.client_id
FROM pmt_transactions t
WHERE t.clearing_status = 1
AND (date(t.clearing_time) <= date(#{end}) OR t.clearing_time IS NULL)
GROUP BY t.client_id
) a
INNER JOIN sys_clients c ON c.client_id = a.client_id
AND c.client_id != 9
AND (
c.parent_client_id != 9
OR c.parent_client_id IS NULL
)
WHERE abs(total_credit - total_debit) > 1
ORDER BY subval DESC) t
]]>
</select>
<select id="listDailyTransactions" resultType="com.alibaba.fastjson.JSONObject">
@ -866,37 +867,35 @@ select sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,
</select>
<select id="listTransactionsOfClearingOrder" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[
SELECT
t.*,
o.display_amount,
o.client_order_id,
o.gateway,
r.out_refund_id,
r.client_refund_id,
o.order_detail,
o.dev_id
SELECT t.*,
o.display_amount,
o.client_order_id,
o.gateway,
r.out_refund_id,
r.client_refund_id,
o.order_detail,
o.dev_id
FROM pmt_transactions t
LEFT JOIN pmt_orders o ON o.order_id = t.order_id
LEFT JOIN pmt_refunds r ON r.refund_id = t.refund_id
WHERE t.channel != 'Settlement' AND t.clearing_order = #{clearing_order}
LEFT JOIN pmt_orders o ON o.order_id = t.order_id
LEFT JOIN pmt_refunds r ON r.refund_id = t.refund_id
WHERE t.channel != 'Settlement'
AND t.clearing_order = #{clearing_order}
]]>
</select>
<select id="listSettlementTransactions" resultType="com.alibaba.fastjson.JSONObject">
SELECT t.*
FROM pmt_transactions t
WHERE t.channel = 'Settlement' AND t.clearing_order = #{clearing_order}
WHERE t.channel = 'Settlement'
AND t.clearing_order = #{clearing_order}
</select>
<select id="analysisCustomerPaid" resultType="java.math.BigDecimal">
SELECT ifnull(sum(t.clearing_amount), 0)
FROM pmt_transactions t
INNER JOIN pmt_orders o
ON o.order_id = t.order_id AND o.transaction_date BETWEEN #{startDate} AND #{endDate} AND
o.customer_id = #{customer_id}
WHERE t.system_generate = 0 AND t.transaction_type = 'Credit'
INNER JOIN pmt_orders o
ON o.order_id = t.order_id AND o.transaction_date BETWEEN #{startDate} AND #{endDate} AND
o.customer_id = #{customer_id}
WHERE t.system_generate = 0
AND t.transaction_type = 'Credit'
</select>
<select id="getSettleDelayAnalysis" resultType="com.alibaba.fastjson.JSONObject">
@ -951,41 +950,86 @@ select sum(if(temp.transaction_type='Credit',temp.clearing_amount*d.proportion,
group by client_id
</select>
<select id="listClientUnsettleDataByDate" resultType="com.alibaba.fastjson.JSONObject">
SELECT
date(transaction_time) trans_date,
sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)) clearing_amount,
sum(if(transaction_type = 'Credit', settle_amount, -settle_amount)) settle_amount
SELECT date(transaction_time) trans_date,
sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)) clearing_amount,
sum(if(transaction_type = 'Credit', settle_amount, -settle_amount)) settle_amount
FROM pmt_transactions t
WHERE t.client_id = #{client_id} AND t.clearing_status = 0 AND date(t.transaction_time)&lt;=date(#{max_settle_to})
WHERE t.client_id = #{client_id}
AND t.clearing_status = 0
AND date(t.transaction_time) &lt;= date(#{max_settle_to})
GROUP BY trans_date
ORDER BY trans_date DESC
</select>
<select id="getHfClearAmount" resultType="com.alibaba.fastjson.JSONObject">
SELECT sum(clearing_amount) clear_amount,
sum(channel_surcharge) charge_amount ,
SELECT sum(clearing_amount) clear_amount,
sum(channel_surcharge) charge_amount,
transaction_type
FROM pmt_transactions where channel='hf'
AND transaction_time >= #{datefrom}
AND transaction_time &lt;= #{dateto}
GROUP BY transaction_type
FROM pmt_transactions
where channel = 'hf'
AND transaction_time >= #{datefrom}
AND transaction_time &lt;= #{dateto}
GROUP BY transaction_type
</select>
<select id="analysisForATOReport" resultType="com.alibaba.fastjson.JSONObject">
select sum(if(transaction_type='Credit',t.clearing_amount,0)) gross_payment,
sum(if(transaction_type='Credit',1,0)) pay_count,
sum(if(transaction_type='Debit',t.clearing_amount,0)) total_refund,
sum(if(transaction_type='Debit',1,0)) refund_count,
min(t.transaction_time) period_start,
max(t.transaction_time) period_end,
cd.bsb_no,
cd.account_no,
cd.account_name
select sum(if(transaction_type = 'Credit', t.clearing_amount, 0)) gross_payment,
sum(if(transaction_type = 'Credit', 1, 0)) pay_count,
sum(if(transaction_type = 'Debit', t.clearing_amount, 0)) total_refund,
sum(if(transaction_type = 'Debit', 1, 0)) refund_count,
min(t.transaction_time) period_start,
max(t.transaction_time) period_end,
cd.bsb_no,
cd.account_no,
cd.account_name
from pmt_transactions t
inner join log_clearing_detail cd on cd.clear_detail_id=t.clearing_order
where t.client_id=#{clientId} and t.system_generate=0 and t.clearing_status=1 and t.transaction_time between #{from} and #{to}
and t.channel!='Settlement'
inner join log_clearing_detail cd on cd.clear_detail_id = t.clearing_order
where t.client_id = #{clientId}
and t.system_generate = 0
and t.clearing_status = 1
and t.transaction_time between #{from} and #{to}
and t.channel != 'Settlement'
group by cd.bsb_no,cd.account_no
order by period_start
</select>
<select id="listCreditTransactionsForSecure" resultType="com.alibaba.fastjson.JSONObject">
select c.client_moniker,
o.order_id,
o.gateway,
t.transaction_amount,
t.transaction_currency,
t.order_channel,
t.clearing_amount,
t.exchange_rate,
t.transaction_time,
t.transaction_type
from pmt_transactions t
inner join pmt_orders o on o.order_id = t.order_id
inner join sys_clients c on c.client_id = t.client_id
where t.transaction_time between #{from} and #{to}
and t.channel not in ('Settlement', 'System')
and t.system_generate = 0
and t.transaction_type = 'Credit'
</select>
<select id="listDebitTransactionsForSecure" resultType="com.alibaba.fastjson.JSONObject">
select c.client_moniker,
o.order_id,
o.gateway,
r.out_refund_id,
t.transaction_amount,
t.transaction_currency,
t.order_channel,
t.clearing_amount,
t.exchange_rate,
t.transaction_time,
t.transaction_type
from pmt_transactions t
inner join pmt_orders o on o.order_id = t.order_id
inner join sys_clients c on c.client_id = t.client_id
inner join pmt_refunds r on r.refund_id = t.refund_id
where t.transaction_time between #{from} and #{to}
and t.channel not in ('Settlement', 'System')
and t.system_generate = 0
and t.transaction_type = 'Debit'
</select>
</mapper>

Loading…
Cancel
Save