|
|
|
@ -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 < 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<=now() and (b.end_date is null or b.end_date >= 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 <= now() and (b.end_date is null or b.end_date >= 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<=now() and (b.end_date is null or b.end_date >= 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 <= now()
|
|
|
|
|
and (b.end_date is null or b.end_date >= 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)<=date(#{max_settle_to})
|
|
|
|
|
WHERE t.client_id = #{client_id}
|
|
|
|
|
AND t.clearing_status = 0
|
|
|
|
|
AND date(t.transaction_time) <= 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 <= #{dateto}
|
|
|
|
|
GROUP BY transaction_type
|
|
|
|
|
FROM pmt_transactions
|
|
|
|
|
where channel = 'hf'
|
|
|
|
|
AND transaction_time >= #{datefrom}
|
|
|
|
|
AND transaction_time <= #{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>
|
|
|
|
|