优化 BD提成查询

master
eason 6 years ago
parent 5e0fa354b2
commit c8657980cf

@ -504,21 +504,12 @@
<select id="TotalAmountForBDLeaderPrize" resultType="java.math.BigDecimal">
SELECT
ifnull(sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount)),0)
ifnull(sum(t.total),0)
total
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 = o.client_id AND c.org_id = 1
WHERE year(o.create_time) = #{year} AND month(o.create_time) = #{month}
AND(
t.transaction_type = 'Credit'
OR t.refund_id IS NOT NULL
)
AND(
o. STATUS =5
OR o. STATUS =6
OR o. STATUS =7
)
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
@ -528,21 +519,12 @@
<select id="TotalAmountForSydneyGMPrize" resultType="java.math.BigDecimal">
SELECT
sum(if(t.transaction_type = 'Credit', t.clearing_amount, -t.clearing_amount))
ifnull(sum(t.total),0)
total
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 = o.client_id AND c.org_id = 1
WHERE year(o.create_time) = #{year} AND month(o.create_time) = #{month}
AND(
t.transaction_type = 'Credit'
OR t.refund_id IS NOT NULL
)
AND(
o. STATUS =5
OR o. STATUS =6
OR o. STATUS =7
)
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

Loading…
Cancel
Save