|
|
|
@ -4,7 +4,9 @@
|
|
|
|
|
<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,
|
|
|
|
|
SET clearing_status = if(
|
|
|
|
|
(select count(task_id) from log_presettle_task p where p.clear_detail_id = d.clear_detail_id) >
|
|
|
|
|
0, 4, 0),
|
|
|
|
|
clearing_order = NULL,
|
|
|
|
|
clearing_time = NULL
|
|
|
|
|
WHERE d.clearing_id = #{clearing_id}
|
|
|
|
@ -61,15 +63,17 @@
|
|
|
|
|
SELECT count(1)
|
|
|
|
|
FROM pmt_transactions t
|
|
|
|
|
<if test="dev_id!=null or ">
|
|
|
|
|
INNER JOIN (select o.order_id from pmt_orders o<where>
|
|
|
|
|
<if test="dev_id!=null">and o.dev_id = #{dev_id}</if>
|
|
|
|
|
<if test="
|
|
|
|
|
INNER JOIN (select o.order_id from pmt_orders o
|
|
|
|
|
<where>
|
|
|
|
|
<if test="dev_id!=null">and o.dev_id = #{dev_id}</if>
|
|
|
|
|
<if test="
|
|
|
|
|
channel!=null">and
|
|
|
|
|
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
|
|
|
|
|
o.channel=#{chan}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>)oo ON oo.order_id=t.order_id
|
|
|
|
|
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
|
|
|
|
|
o.channel=#{chan}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
)oo ON oo.order_id=t.order_id
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
<where>
|
|
|
|
@ -170,7 +174,7 @@
|
|
|
|
|
<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="dev_id!=null">
|
|
|
|
|
and binary o.dev_id = #{dev_id}
|
|
|
|
|
and binary o.dev_id = #{dev_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="channel!=null">
|
|
|
|
|
and
|
|
|
|
@ -241,7 +245,7 @@
|
|
|
|
|
<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="dev_id!=null">
|
|
|
|
|
and binary o.dev_id = #{dev_id}
|
|
|
|
|
and binary o.dev_id = #{dev_id}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="channel!=null">
|
|
|
|
|
and
|
|
|
|
@ -310,12 +314,12 @@
|
|
|
|
|
SELECT sc.client_id,
|
|
|
|
|
sc.client_moniker,
|
|
|
|
|
IFNULL(SUM(IF(pt.transaction_type = 'Credit', pt.clearing_amount, -pt.clearing_amount)), 0) amount,
|
|
|
|
|
IFNULL(MAX(pt.create_time), sc.approve_time) transation_time
|
|
|
|
|
FROM pmt_transactions pt,
|
|
|
|
|
sys_clients sc
|
|
|
|
|
WHERE clearing_status = 0
|
|
|
|
|
AND pt.client_id = sc.client_id
|
|
|
|
|
GROUP BY client_id
|
|
|
|
|
IFNULL(MAX(pt.create_time), sc.approve_time) transation_time
|
|
|
|
|
FROM pmt_transactions pt,
|
|
|
|
|
sys_clients sc
|
|
|
|
|
WHERE clearing_status = 0
|
|
|
|
|
AND pt.client_id = sc.client_id
|
|
|
|
|
GROUP BY client_id
|
|
|
|
|
HAVING amount < 0
|
|
|
|
|
</select>
|
|
|
|
|
<select id="validAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
@ -439,17 +443,17 @@
|
|
|
|
|
FROM sys_clients c
|
|
|
|
|
]]>
|
|
|
|
|
INNER JOIN (select system_transaction_id,clearing_amount,client_id
|
|
|
|
|
from pmt_transactions
|
|
|
|
|
where channel='Settlement'
|
|
|
|
|
<if test="from!=null">and transaction_time >= #{from}</if>
|
|
|
|
|
<if test="to!=null">and transaction_time < #{to}</if>
|
|
|
|
|
) t ON t.client_id = c.client_id
|
|
|
|
|
from pmt_transactions
|
|
|
|
|
where channel='Settlement'
|
|
|
|
|
<if test="from!=null">and transaction_time >= #{from}</if>
|
|
|
|
|
<if test="to!=null">and transaction_time < #{to}</if>
|
|
|
|
|
) t ON t.client_id = c.client_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and c.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and c.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY c.client_id
|
|
|
|
|
</select>
|
|
|
|
@ -628,7 +632,7 @@
|
|
|
|
|
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 (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
|
|
|
|
@ -744,13 +748,13 @@
|
|
|
|
|
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,
|
|
|
|
|
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
|
|
|
|
|
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
|
|
|
|
|
t.order_id,
|
|
|
|
|
t.org_rate,
|
|
|
|
|
t.surcharge_cashback,
|
|
|
|
|
o.customer_surcharge
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
@ -763,7 +767,7 @@
|
|
|
|
|
<select id="listTransactionForCityPartnerAgentCommissionByDate" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
select t.org_id,
|
|
|
|
|
t.clearing_currency,
|
|
|
|
|
t.clearing_currency,
|
|
|
|
|
t.client_id,
|
|
|
|
|
t.channel,
|
|
|
|
|
t.surcharge_rate,
|
|
|
|
@ -771,13 +775,13 @@
|
|
|
|
|
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,
|
|
|
|
|
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
|
|
|
|
|
if(t.transaction_type = 'Credit', t.settle_amount, -t.settle_amount) settle_amount,
|
|
|
|
|
t.order_id,
|
|
|
|
|
t.org_rate,
|
|
|
|
|
t.surcharge_cashback,
|
|
|
|
|
o.customer_surcharge
|
|
|
|
|
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
|
|
|
|
|
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 != ''
|
|
|
|
@ -951,7 +955,7 @@
|
|
|
|
|
<select id="listTransactionsOfClearingOrder" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
SELECT t.*,
|
|
|
|
|
IFNULL(t.incremental_surcharge, 0.00) incremental_surcharge_settle,
|
|
|
|
|
IFNULL(t.incremental_surcharge, 0.00) incremental_surcharge_settle,
|
|
|
|
|
o.display_amount,
|
|
|
|
|
o.client_order_id,
|
|
|
|
|
o.gateway,
|
|
|
|
@ -1073,7 +1077,7 @@
|
|
|
|
|
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
|
|
|
|
|
group by cd.bsb_no, cd.account_no
|
|
|
|
|
order by period_start
|
|
|
|
|
</select>
|
|
|
|
|
<select id="listCreditTransactionsForSecure" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
@ -1145,10 +1149,10 @@
|
|
|
|
|
t.channel = 'Settlement'
|
|
|
|
|
]]>
|
|
|
|
|
<if test="client_ids!=null">
|
|
|
|
|
AND t.client_id IN
|
|
|
|
|
<foreach collection="client_ids" open="(" close=")" separator="," item="clientId">
|
|
|
|
|
#{clientId}
|
|
|
|
|
</foreach>
|
|
|
|
|
AND t.client_id IN
|
|
|
|
|
<foreach collection="client_ids" open="(" close=")" separator="," item="clientId">
|
|
|
|
|
#{clientId}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="client_ids==null">
|
|
|
|
|
and t.client_id=#{client_id}
|
|
|
|
@ -1208,42 +1212,42 @@
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getLastDaytransAmount" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT ifnull(SUM(IF(transaction_type='Credit',clearing_amount,-clearing_amount)),0) clearing_amount,
|
|
|
|
|
ifnull(SUM(IF(transaction_type='Credit',total_surcharge,-total_surcharge)),0) total_surcharge,
|
|
|
|
|
ifnull(SUM(IF(transaction_type='Credit',channel_surcharge,-channel_surcharge)),0) channel_surcharge,
|
|
|
|
|
channel
|
|
|
|
|
FROM pmt_transactions
|
|
|
|
|
WHERE channel!='Settlement'
|
|
|
|
|
AND channel!='System'
|
|
|
|
|
AND system_generate = 0
|
|
|
|
|
AND transaction_time >= #{datefrom}
|
|
|
|
|
AND transaction_time < #{dateto}
|
|
|
|
|
GROUP BY channel
|
|
|
|
|
SELECT ifnull(SUM(IF(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0) clearing_amount,
|
|
|
|
|
ifnull(SUM(IF(transaction_type = 'Credit', total_surcharge, -total_surcharge)), 0) total_surcharge,
|
|
|
|
|
ifnull(SUM(IF(transaction_type = 'Credit', channel_surcharge, -channel_surcharge)), 0) channel_surcharge,
|
|
|
|
|
channel
|
|
|
|
|
FROM pmt_transactions
|
|
|
|
|
WHERE channel != 'Settlement'
|
|
|
|
|
AND channel != 'System'
|
|
|
|
|
AND system_generate = 0
|
|
|
|
|
AND transaction_time >= #{datefrom}
|
|
|
|
|
AND transaction_time < #{dateto}
|
|
|
|
|
GROUP BY channel
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="useAlipayOnlineClients" resultType="java.lang.Integer">
|
|
|
|
|
SELECT DISTINCT client_id FROM pmt_transactions
|
|
|
|
|
WHERE order_channel='AlipayOnline'
|
|
|
|
|
and create_time>='2019-01-01 00:00:00'
|
|
|
|
|
SELECT DISTINCT client_id
|
|
|
|
|
FROM pmt_transactions
|
|
|
|
|
WHERE order_channel = 'AlipayOnline'
|
|
|
|
|
and create_time >= '2019-01-01 00:00:00'
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getSettleDataDailyReport" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT
|
|
|
|
|
channel,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', settle_amount, -settle_amount)) AS settle_amount,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', clearing_amount, 0)) AS credit_amount,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', 0, -clearing_amount)) AS debit_amount,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', clearing_amount, -clearing_amount)) AS net_trading,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', total_surcharge, -total_surcharge)) AS total_surcharge,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', royal_surcharge, -royal_surcharge)) AS royal_surcharge,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', channel_surcharge, -channel_surcharge)) AS channel_surcharge,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', tax_amount, -tax_amount)) AS tax_amount,
|
|
|
|
|
cashback_send_flag,
|
|
|
|
|
surcharge_cashback
|
|
|
|
|
SELECT channel,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', settle_amount, -settle_amount)) AS settle_amount,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', clearing_amount, 0)) AS credit_amount,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', 0, -clearing_amount)) AS debit_amount,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', clearing_amount, -clearing_amount)) AS net_trading,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', total_surcharge, -total_surcharge)) AS total_surcharge,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', royal_surcharge, -royal_surcharge)) AS royal_surcharge,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', channel_surcharge, -channel_surcharge)) AS channel_surcharge,
|
|
|
|
|
SUM(IF(transaction_type = 'Credit', tax_amount, -tax_amount)) AS tax_amount,
|
|
|
|
|
cashback_send_flag,
|
|
|
|
|
surcharge_cashback
|
|
|
|
|
FROM pmt_transactions
|
|
|
|
|
WHERE create_time >= #{beginTime}
|
|
|
|
|
AND create_time < #{endTime}
|
|
|
|
|
AND channel != 'Settlement'
|
|
|
|
|
AND create_time < #{endTime}
|
|
|
|
|
AND channel != 'Settlement'
|
|
|
|
|
GROUP BY channel
|
|
|
|
|
</select>
|
|
|
|
|
</mapper>
|
|
|
|
|