|
|
@ -3,13 +3,15 @@
|
|
|
|
<mapper namespace="au.com.royalpay.payment.manage.mappers.payment.TransactionMapper">
|
|
|
|
<mapper namespace="au.com.royalpay.payment.manage.mappers.payment.TransactionMapper">
|
|
|
|
<update id="removeSettleRemark">
|
|
|
|
<update id="removeSettleRemark">
|
|
|
|
UPDATE pmt_transactions AS t
|
|
|
|
UPDATE pmt_transactions AS t
|
|
|
|
INNER JOIN log_clearing_detail d ON d.clear_detail_id = t.clearing_order
|
|
|
|
INNER JOIN (
|
|
|
|
SET clearing_status = if(
|
|
|
|
select d.clear_detail_id,count(p.task_id) pre_settle_flag from log_clearing_detail d
|
|
|
|
(select count(task_id) from log_presettle_task p where p.clear_detail_id = d.clear_detail_id) >
|
|
|
|
left join log_presettle_task p on p.clear_detail_id = d.clear_detail_id
|
|
|
|
0, 4, 0),
|
|
|
|
where d.clearing_id=#{clearing_id}
|
|
|
|
|
|
|
|
group by d.clear_detail_id) dd
|
|
|
|
|
|
|
|
ON dd.clear_detail_id = t.clearing_order
|
|
|
|
|
|
|
|
SET clearing_status = if(pre_settle_flag > 0, 4, 0),
|
|
|
|
clearing_order = NULL,
|
|
|
|
clearing_order = NULL,
|
|
|
|
clearing_time = NULL
|
|
|
|
clearing_time = NULL
|
|
|
|
WHERE d.clearing_id = #{clearing_id}
|
|
|
|
|
|
|
|
</update>
|
|
|
|
</update>
|
|
|
|
<delete id="deleteSettlementTransaction">
|
|
|
|
<delete id="deleteSettlementTransaction">
|
|
|
|
DELETE t
|
|
|
|
DELETE t
|
|
|
@ -559,6 +561,46 @@
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="listSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
<select id="listSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
|
|
|
select cd.client_id, cd.report_date clearing_time, cd.report_date,
|
|
|
|
|
|
|
|
lc.editable, lc.balance_group,
|
|
|
|
|
|
|
|
<if test="merge_settle!=null">
|
|
|
|
|
|
|
|
SUM(cd.tax_amount) as tax_amount,
|
|
|
|
|
|
|
|
SUM(cd.total_charge) as total_charge,
|
|
|
|
|
|
|
|
1 as merge_settle,
|
|
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<if test="merge_settle==null">
|
|
|
|
|
|
|
|
cd.tax_amount,
|
|
|
|
|
|
|
|
cd.total_charge,
|
|
|
|
|
|
|
|
cd.clear_detail_id,
|
|
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
sum(cd.gross_amount) total,
|
|
|
|
|
|
|
|
sum(cd.clearing_amount) income,
|
|
|
|
|
|
|
|
sum(cd.total_charge+cd.tax_amount) fee,
|
|
|
|
|
|
|
|
(SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = cd.client_id
|
|
|
|
|
|
|
|
AND r.expiry_time > cd.report_date
|
|
|
|
|
|
|
|
AND r.active_time <= cd.report_date) rate
|
|
|
|
|
|
|
|
from log_clearing_detail cd
|
|
|
|
|
|
|
|
inner join sys_clients sc on sc.client_id=cd.client_id
|
|
|
|
|
|
|
|
inner join log_clearing lc on lc.clearing_id=cd.clearing_id
|
|
|
|
|
|
|
|
<where>
|
|
|
|
|
|
|
|
<if test="client_ids!=null">
|
|
|
|
|
|
|
|
AND cd.client_id IN
|
|
|
|
|
|
|
|
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
|
|
|
|
|
|
|
#{client_id}
|
|
|
|
|
|
|
|
</foreach>
|
|
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<if test="client_ids==null and client_id !=null">
|
|
|
|
|
|
|
|
and (sc.client_id=#{client_id} or sc.parent_client_id =#{client_id})
|
|
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
<if test="from!=null">and cd.report_date >= #{from}</if>
|
|
|
|
|
|
|
|
<if test="to!=null">and cd.report_date < #{to}</if>
|
|
|
|
|
|
|
|
<if test="merge_settle!=null">GROUP BY cd.report_date</if>
|
|
|
|
|
|
|
|
<if test="merge_settle==null">GROUP BY cd.clear_detail_id</if>
|
|
|
|
|
|
|
|
order by lc.clearing_id desc
|
|
|
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="listSettlementLogOrigin" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
SELECT t.client_id,DATE(t.transaction_time) clearing_time,
|
|
|
|
SELECT t.client_id,DATE(t.transaction_time) clearing_time,
|
|
|
|
ifnull(cd.report_date,date(t.transaction_time)) report_date,
|
|
|
|
ifnull(cd.report_date,date(t.transaction_time)) report_date,
|
|
|
|
<if test="merge_settle!=null">
|
|
|
|
<if test="merge_settle!=null">
|
|
|
@ -646,15 +688,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
<select id="listSettlementLogTotal" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
<select id="listSettlementLogTotal" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
<![CDATA[
|
|
|
|
<![CDATA[
|
|
|
|
SELECT DATE(t.transaction_time) clearing_time,date_format(t.transaction_time, '%Y-%m-%d') clear_time,SUM(t.clearing_amount) total,
|
|
|
|
SELECT cd.report_date clearing_time,
|
|
|
|
sum(if(LOCATE('MERCHANT',t.system_transaction_id),t.clearing_amount,0)) income,
|
|
|
|
date_format(cd.report_date, '%Y-%m-%d') clear_time,
|
|
|
|
sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee
|
|
|
|
SUM(cd.gross_amount) total,
|
|
|
|
FROM pmt_transactions t
|
|
|
|
sum(cd.clearing_amount) income,
|
|
|
|
LEFT JOIN sys_clients c on c.client_id = t.client_id
|
|
|
|
sum(cd.total_charge+cd.tax_amount) fee
|
|
|
|
WHERE t.channel='Settlement'
|
|
|
|
from log_clearing_detail cd
|
|
|
|
|
|
|
|
inner JOIN sys_clients c on c.client_id = cd.client_id
|
|
|
|
]]>
|
|
|
|
]]>
|
|
|
|
|
|
|
|
<where>
|
|
|
|
<if test="client_ids!=null">
|
|
|
|
<if test="client_ids!=null">
|
|
|
|
AND t.client_id IN
|
|
|
|
AND cd.client_id IN
|
|
|
|
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
|
|
|
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
|
|
|
#{client_id}
|
|
|
|
#{client_id}
|
|
|
|
</foreach>
|
|
|
|
</foreach>
|
|
|
@ -662,29 +706,27 @@
|
|
|
|
<if test="client_ids==null and client_id !=null">
|
|
|
|
<if test="client_ids==null and client_id !=null">
|
|
|
|
and (c.client_id=#{client_id} or c.parent_client_id=#{client_id})
|
|
|
|
and (c.client_id=#{client_id} or c.parent_client_id=#{client_id})
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
<if test="from!=null">and t.transaction_time >= #{from}</if>
|
|
|
|
<if test="from!=null">and cd.report_date >= #{from}</if>
|
|
|
|
<if test="to!=null">and t.transaction_time < #{to}</if>
|
|
|
|
<if test="to!=null">and cd.report_date < #{to}</if>
|
|
|
|
<if test="org_id!=null and org_ids==null">and c.org_id = #{org_id}</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
|
|
|
|
<if test="org_ids!=null">and c.org_id in
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
GROUP BY DATE(t.transaction_time)
|
|
|
|
GROUP BY cd.report_date
|
|
|
|
order by t.clearing_time desc
|
|
|
|
order by cd.clearing_id desc
|
|
|
|
|
|
|
|
</where>
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="listSettlementLogInClients" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
<select id="listSettlementLogInClients" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
<![CDATA[
|
|
|
|
<![CDATA[
|
|
|
|
SELECT c.short_name,SUM(t.clearing_amount) total,
|
|
|
|
SELECT c.short_name,SUM(cd.gross_amount) total,
|
|
|
|
sum(if(LOCATE('MERCHANT',t.system_transaction_id),t.clearing_amount,0)) income,
|
|
|
|
sum(cd.clearing_amount) income,
|
|
|
|
sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee
|
|
|
|
sum(cd.total_charge+cd.tax_amount) fee
|
|
|
|
FROM sys_clients c
|
|
|
|
FROM sys_clients c
|
|
|
|
]]>
|
|
|
|
]]>
|
|
|
|
INNER JOIN (select system_transaction_id,clearing_amount,client_id
|
|
|
|
INNER JOIN log_clearing_detail cd on c.client_id=cd.client_id
|
|
|
|
from pmt_transactions
|
|
|
|
<if test="from!=null">and cd.report_date >= #{from}</if>
|
|
|
|
where channel='Settlement'
|
|
|
|
<if test="to!=null">and cd.report_date < #{to}</if>
|
|
|
|
<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>
|
|
|
|
<where>
|
|
|
|
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</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_id!=null and org_ids==null">and c.org_id = #{org_id}</if>
|
|
|
@ -696,8 +738,9 @@
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
<select id="countSettlementLogInClients" resultType="int">
|
|
|
|
<select id="countSettlementLogInClients" resultType="int">
|
|
|
|
<![CDATA[
|
|
|
|
<![CDATA[
|
|
|
|
SELECT count(1)
|
|
|
|
SELECT count(cd.clear_detail_id)
|
|
|
|
FROM sys_clients c
|
|
|
|
from log_clearing_detail
|
|
|
|
|
|
|
|
inner join sys_clients c on c.client_id=cd.client_id
|
|
|
|
]]>
|
|
|
|
]]>
|
|
|
|
<where>
|
|
|
|
<where>
|
|
|
|
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
|
|
|
|
<if test="client_moniker!=null">and c.client_moniker=#{client_moniker}</if>
|
|
|
@ -705,13 +748,9 @@
|
|
|
|
<if test="org_ids!=null">and c.org_id in
|
|
|
|
<if test="org_ids!=null">and c.org_id in
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
</if>
|
|
|
|
</if>
|
|
|
|
and exists (select client_id from pmt_transactions t where channel='Settlement'
|
|
|
|
<if test="from!=null">and cd.report_date >= #{from}</if>
|
|
|
|
<if test="from!=null">and transaction_time >= #{from}</if>
|
|
|
|
<if test="to!=null">and cd.report_date < #{to}</if>
|
|
|
|
<if test="to!=null">and transaction_time < #{to}</if>
|
|
|
|
|
|
|
|
and client_id=c.client_id
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
</where>
|
|
|
|
</where>
|
|
|
|
exists
|
|
|
|
|
|
|
|
</select>
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
<select id="analysisSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
<select id="analysisSettlementLog" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
@ -967,8 +1006,8 @@
|
|
|
|
INNER JOIN sys_org so
|
|
|
|
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
|
|
|
|
ON m.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.citypartner = 1 AND
|
|
|
|
so.commission = 1
|
|
|
|
so.commission = 1
|
|
|
|
WHERE year(t.transaction_time) = #{year}
|
|
|
|
WHERE t.transaction_time >= #{begin}
|
|
|
|
AND month(t.transaction_time) = #{month}
|
|
|
|
AND t.transaction_time < #{end}
|
|
|
|
AND t.channel != 'Settlement'
|
|
|
|
AND t.channel != 'Settlement'
|
|
|
|
GROUP BY t.client_id, trade_date, channel
|
|
|
|
GROUP BY t.client_id, trade_date, channel
|
|
|
|
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
|
|
|
|
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
|
|
|
@ -997,7 +1036,7 @@
|
|
|
|
INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
|
|
|
|
INNER JOIN sys_org so ON t.org_id = so.org_id AND so.is_valid = 1
|
|
|
|
AND so.type = 0
|
|
|
|
AND so.type = 0
|
|
|
|
AND so.citypartner = 1 AND so.commission = 1
|
|
|
|
AND so.citypartner = 1 AND so.commission = 1
|
|
|
|
AND year(t.create_time) = #{year} AND month(t.create_time) = #{month}
|
|
|
|
AND t.create_time >= #{begin} AND t.create_time < #{end}
|
|
|
|
AND t.channel != 'Settlement' AND t.channel != 'System' AND t.system_generate = 0
|
|
|
|
AND t.channel != 'Settlement' AND t.channel != 'System' AND t.system_generate = 0
|
|
|
|
ORDER BY t.client_id asc
|
|
|
|
ORDER BY t.client_id asc
|
|
|
|
]]>
|
|
|
|
]]>
|
|
|
@ -1027,7 +1066,7 @@
|
|
|
|
AND so.type = 0
|
|
|
|
AND so.type = 0
|
|
|
|
AND so.parent_org_id != ''
|
|
|
|
AND so.parent_org_id != ''
|
|
|
|
AND so.citypartner = 1 AND so.commission = 1
|
|
|
|
AND so.citypartner = 1 AND so.commission = 1
|
|
|
|
AND year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month}
|
|
|
|
AND t.transaction_time >= #{begin} AND t.transaction_time < #{end}
|
|
|
|
AND t.channel != 'Settlement' AND t.channel != 'System'
|
|
|
|
AND t.channel != 'Settlement' AND t.channel != 'System'
|
|
|
|
ORDER BY t.client_id asc
|
|
|
|
ORDER BY t.client_id asc
|
|
|
|
]]>
|
|
|
|
]]>
|
|
|
@ -1045,8 +1084,8 @@
|
|
|
|
inner join sys_client_config cc on cc.client_id = c.client_id
|
|
|
|
inner join sys_client_config cc on cc.client_id = c.client_id
|
|
|
|
INNER JOIN sys_org so
|
|
|
|
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
|
|
|
|
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}
|
|
|
|
WHERE t.transaction_time >= #{begin}
|
|
|
|
AND month(t.transaction_time) = #{month}
|
|
|
|
AND t.transaction_time < #{end}
|
|
|
|
AND t.channel != 'Settlement'
|
|
|
|
AND t.channel != 'Settlement'
|
|
|
|
GROUP BY so.org_id, trade_date, t.client_id
|
|
|
|
GROUP BY so.org_id, trade_date, t.client_id
|
|
|
|
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
|
|
|
|
ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC
|
|
|
|