|
|
|
@ -9,6 +9,7 @@
|
|
|
|
|
ifnull(SUM(if(temp.refund_id IS NOT NULL, if(temp.transaction_type='Debit', temp.clearing_amount, -temp.clearing_amount) * clinetBD.proportion, 0)), 0) refund_fee
|
|
|
|
|
FROM(
|
|
|
|
|
SELECT
|
|
|
|
|
trans.org_id,
|
|
|
|
|
trans.client_id,
|
|
|
|
|
trans.clearing_amount,
|
|
|
|
|
trans.refund_id,
|
|
|
|
@ -18,25 +19,28 @@
|
|
|
|
|
WHERE (trans.transaction_type = 'Credit' OR trans.refund_id IS NOT NULL)
|
|
|
|
|
AND trans.system_generate = 0
|
|
|
|
|
AND trans.channel !='Settlement'
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
AND trans.channel != 'System'
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
AND trans.create_time >= #{begin}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="end != null">
|
|
|
|
|
AND trans.create_time < #{end}
|
|
|
|
|
</if>
|
|
|
|
|
) AS temp
|
|
|
|
|
|
|
|
|
|
INNER JOIN sys_org AS org
|
|
|
|
|
ON org.org_id = temp.org_id
|
|
|
|
|
AND org.is_valid = 1
|
|
|
|
|
<if test="org_id != null">
|
|
|
|
|
AND org.org_id = #{org_id}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
INNER JOIN sys_client_bd AS clinetBD
|
|
|
|
|
ON temp.client_id = clinetBD.client_id
|
|
|
|
|
AND clinetBD.start_date <= temp.create_time
|
|
|
|
|
AND clinetBD.is_valid = '1'
|
|
|
|
|
AND (clinetBD.end_date IS NULL OR clinetBD.end_date > temp.create_time)
|
|
|
|
|
|
|
|
|
|
INNER JOIN sys_managers AS manage
|
|
|
|
|
ON manage.manager_id = clinetBD.bd_id
|
|
|
|
|
<if test="org_id != null">
|
|
|
|
|
AND manage.org_id = #{org_id}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
GROUP BY clinetBD.bd_id
|
|
|
|
|
ORDER BY total DESC
|
|
|
|
|
</select>
|
|
|
|
@ -199,49 +203,50 @@
|
|
|
|
|
SELECT
|
|
|
|
|
clinetBD.bd_name,
|
|
|
|
|
clinetBD.bd_id,
|
|
|
|
|
manage.org_id,
|
|
|
|
|
org.org_id,
|
|
|
|
|
org.type AS org_type,
|
|
|
|
|
org.name AS org_name,
|
|
|
|
|
if(org.org_id=1,1,0) AS isOrg,
|
|
|
|
|
SUM( IF ( temp.transaction_type = 'Credit', temp.clearing_amount, 0 )) clearing_amount,
|
|
|
|
|
0 AS isOrg,
|
|
|
|
|
0 AS clearing_amount,
|
|
|
|
|
SUM(if(temp.transaction_type = 'Credit',temp.clearing_amount * clinetBD.proportion, -temp.clearing_amount * clinetBD.proportion)) pay_amount,
|
|
|
|
|
ifnull(SUM(if(temp.refund_id IS NOT NULL, if(temp.transaction_type='Debit', temp.clearing_amount, -temp.clearing_amount) * clinetBD.proportion, 0)), 0) refund_amount,
|
|
|
|
|
(SUM(if(temp.transaction_type = 'Credit', temp.clearing_amount * clinetBD.proportion, -temp.clearing_amount * clinetBD.proportion))) - (ifnull(SUM(if(temp.refund_id IS NOT NULL, if(temp.transaction_type='Debit', temp.clearing_amount, -temp.clearing_amount) * clinetBD.proportion, 0)), 0)) AS net_amount
|
|
|
|
|
FROM(
|
|
|
|
|
SELECT
|
|
|
|
|
trans.client_id,
|
|
|
|
|
trans.clearing_amount,
|
|
|
|
|
trans.refund_id,
|
|
|
|
|
trans.transaction_type,
|
|
|
|
|
trans.create_time
|
|
|
|
|
FROM pmt_transactions AS trans
|
|
|
|
|
WHERE (trans.transaction_type = 'Credit' OR trans.refund_id IS NOT NULL)
|
|
|
|
|
AND trans.system_generate = 0
|
|
|
|
|
AND trans.channel !='Settlement'
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
AND trans.create_time >= #{begin}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="end != null">
|
|
|
|
|
AND trans.create_time < #{end}
|
|
|
|
|
</if>
|
|
|
|
|
)
|
|
|
|
|
SELECT
|
|
|
|
|
trans.org_id,
|
|
|
|
|
trans.client_id,
|
|
|
|
|
trans.clearing_amount,
|
|
|
|
|
trans.refund_id,
|
|
|
|
|
trans.transaction_type,
|
|
|
|
|
trans.create_time
|
|
|
|
|
FROM pmt_transactions AS trans
|
|
|
|
|
WHERE (trans.transaction_type = 'Credit' OR trans.refund_id IS NOT NULL)
|
|
|
|
|
AND trans.system_generate = 0
|
|
|
|
|
AND trans.channel !='Settlement'
|
|
|
|
|
AND trans.channel != 'System'
|
|
|
|
|
<if test="begin != null">
|
|
|
|
|
AND trans.create_time >= #{begin}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="end != null">
|
|
|
|
|
AND trans.create_time < #{end}
|
|
|
|
|
</if>
|
|
|
|
|
)
|
|
|
|
|
AS temp
|
|
|
|
|
INNER JOIN sys_client_bd AS clinetBD
|
|
|
|
|
ON temp.client_id = clinetBD.client_id
|
|
|
|
|
AND clinetBD.start_date <= temp.create_time
|
|
|
|
|
AND clinetBD.is_valid = '1'
|
|
|
|
|
AND (clinetBD.end_date IS NULL OR clinetBD.end_date > temp.create_time)
|
|
|
|
|
INNER JOIN sys_managers AS manage
|
|
|
|
|
ON manage.manager_id = clinetBD.bd_id
|
|
|
|
|
AND manage.org_id IS NOT NULL
|
|
|
|
|
|
|
|
|
|
INNER JOIN sys_org AS org
|
|
|
|
|
ON org.org_id = manage.org_id
|
|
|
|
|
ON org.org_id = temp.org_id
|
|
|
|
|
AND org.is_valid = 1
|
|
|
|
|
<if test="org_id != null">
|
|
|
|
|
AND manage.org_id = #{org_id}
|
|
|
|
|
</if>
|
|
|
|
|
INNER JOIN sys_client_bd AS clinetBD
|
|
|
|
|
ON temp.client_id = clinetBD.client_id
|
|
|
|
|
AND clinetBD.start_date <= temp.create_time
|
|
|
|
|
AND clinetBD.is_valid = '1'
|
|
|
|
|
AND (clinetBD.end_date IS NULL OR clinetBD.end_date > temp.create_time)
|
|
|
|
|
|
|
|
|
|
GROUP BY clinetBD.bd_id
|
|
|
|
|
ORDER BY pay_amount DESC
|
|
|
|
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</mapper>
|
|
|
|
|