|
|
|
@ -13,7 +13,8 @@
|
|
|
|
|
<select id="getEarliestOrder" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT *
|
|
|
|
|
FROM pmt_transactions
|
|
|
|
|
WHERE client_id = #{client_id} AND clearing_amount > 1
|
|
|
|
|
WHERE client_id = #{client_id}
|
|
|
|
|
AND clearing_amount > 1
|
|
|
|
|
ORDER BY transaction_time
|
|
|
|
|
LIMIT 1;
|
|
|
|
|
</select>
|
|
|
|
@ -55,7 +56,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="analysisTotalAmount" resultType="java.math.BigDecimal">
|
|
|
|
@ -77,7 +79,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="analysisTotalCount" resultType="java.lang.Double">
|
|
|
|
@ -184,7 +187,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
GROUP BY o.order_id ORDER BY aud_fee DESC limit 1
|
|
|
|
|
]]>
|
|
|
|
@ -244,7 +248,8 @@
|
|
|
|
|
<if test="end!=null">and o.create_time <= #{end}</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY gateway_label
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@ -274,7 +279,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bd_group!=null">and l.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
|
|
|
|
@ -311,7 +317,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
GROUP BY date(o.create_time)
|
|
|
|
|
ORDER BY date(o.create_time)
|
|
|
|
@ -339,7 +346,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="countCustomers" resultType="java.lang.Integer">
|
|
|
|
|
<![CDATA[
|
|
|
|
@ -360,7 +368,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
GROUP BY o.customer_id) p
|
|
|
|
|
]]>
|
|
|
|
@ -385,8 +394,9 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and t.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<if test="channel !=null"> and o.channel = #{channel}</if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="channel !=null">and o.channel = #{channel}</if>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
GROUP BY o.customer_id) p
|
|
|
|
|
where p.customer_id NOT IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
|
|
|
@ -426,8 +436,9 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and t.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and t.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<if test="channel !=null"> and o.channel = #{channel}</if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="channel !=null">and o.channel = #{channel}</if>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
GROUP BY o.customer_id) p
|
|
|
|
|
where p.customer_id IN (SELECT o.customer_id FROM pmt_transactions t INNER JOIN pmt_orders o ON o.order_id = t.order_id
|
|
|
|
@ -451,9 +462,11 @@
|
|
|
|
|
|
|
|
|
|
<select id="getCountCustomers" resultType="java.lang.Integer">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
SELECT count(DISTINCT o.customer_id) FROM pmt_orders o where
|
|
|
|
|
o.create_time < #{date} and o.status>=5
|
|
|
|
|
]]>
|
|
|
|
|
SELECT count(DISTINCT o.customer_id)
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
where o.create_time < #{date}
|
|
|
|
|
and o.status >= 5
|
|
|
|
|
]]>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getTradePartnersInTypes" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
@ -499,7 +512,8 @@
|
|
|
|
|
]]>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bd_group!=null">and l.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
|
|
|
|
@ -558,7 +572,8 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="bd_group!=null">and l.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
|
|
|
|
@ -650,18 +665,19 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and ptran.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and ptran.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="listExchangeRates" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
SELECT max(t.transaction_time) mx,t.exchange_rate,date(t.transaction_time) `date`
|
|
|
|
|
FROM
|
|
|
|
|
pmt_transactions t
|
|
|
|
|
WHERE date(t.transaction_time) >= #{begin} And date(t.transaction_time) <= #{end} AND
|
|
|
|
|
t.transaction_type ='Credit' AND t.channel =#{channel}
|
|
|
|
|
GROUP BY
|
|
|
|
|
date(t.transaction_time)
|
|
|
|
|
order by `date` asc
|
|
|
|
|
SELECT max(t.transaction_time) mx, t.exchange_rate, date(t.transaction_time) `date`
|
|
|
|
|
FROM pmt_transactions t
|
|
|
|
|
WHERE date(t.transaction_time) >= #{begin}
|
|
|
|
|
And date(t.transaction_time) <= #{end}
|
|
|
|
|
AND t.transaction_type = 'Credit'
|
|
|
|
|
AND t.channel = #{channel}
|
|
|
|
|
GROUP BY date(t.transaction_time)
|
|
|
|
|
order by `date` asc
|
|
|
|
|
]]>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@ -693,8 +709,9 @@
|
|
|
|
|
</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
GROUP BY date , channel ORDER BY date DESC
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY date , channel ORDER BY date DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getOrgTransactionAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
@ -710,7 +727,8 @@
|
|
|
|
|
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and o.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and o.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
GROUP BY o.org_id order by amount desc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@ -749,7 +767,8 @@
|
|
|
|
|
<if test="channel!=null">and o.channel=#{channel}</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="countAmountRangeAnalysis" resultType="java.lang.Integer">
|
|
|
|
@ -766,7 +785,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="listAmountRangeOrders" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
select c.client_moniker,c.short_name,t.order_id,t.clearing_amount,t.transaction_time,t.channel,o.customer_id,o.customer_ip,o.gateway
|
|
|
|
|
select
|
|
|
|
|
c.client_moniker,c.short_name,t.order_id,t.clearing_amount,t.transaction_time,t.channel,o.customer_id,o.customer_ip,o.gateway
|
|
|
|
|
FROM pmt_transactions t
|
|
|
|
|
LEFT JOIN pmt_orders o on o.order_id=t.order_id
|
|
|
|
|
INNER JOIN sys_clients c on c.client_id = t.client_id
|
|
|
|
@ -778,6 +798,19 @@
|
|
|
|
|
<if test="amount_from!=null">and t.clearing_amount >= #{amount_from}</if>
|
|
|
|
|
<if test="amount_to!=null">and t.clearing_amount < #{amount_to}</if>
|
|
|
|
|
</select>
|
|
|
|
|
<select id="countAmountRangeOrders" resultType="int">
|
|
|
|
|
select count(1)
|
|
|
|
|
FROM pmt_transactions t
|
|
|
|
|
<if test="client_moniker!=null">
|
|
|
|
|
inner join sys_clients c on c.client_id=t.client_id and c.client_moniker=#{client_moniker}
|
|
|
|
|
</if>
|
|
|
|
|
where t.transaction_type = 'Credit' and t.refund_id is null and t.channel != 'Settlement'
|
|
|
|
|
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
|
|
|
|
<if test="channel!=null">and t.channel=#{channel}</if>
|
|
|
|
|
<if test="amount_from!=null">and t.clearing_amount >= #{amount_from}</if>
|
|
|
|
|
<if test="amount_to!=null">and t.clearing_amount < #{amount_to}</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<!--交易金额分析 饼图 -->
|
|
|
|
|
<!--不更改-->
|
|
|
|
@ -804,13 +837,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getClientTransaction" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Credit',l.clearing_amount,0)),0) trade_amount,
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Debit',l.clearing_amount,0)),0) refund_amount,
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Credit',1,0)),0) trade_count,
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Debit',1,0)),0) refund_orders
|
|
|
|
|
FROM pmt_transactions l
|
|
|
|
|
where l.channel!='Settlement' and l.system_generate=0
|
|
|
|
|
SELECT
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Credit',l.clearing_amount,0)),0) trade_amount,
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Debit',l.clearing_amount,0)),0) refund_amount,
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Credit',1,0)),0) trade_count,
|
|
|
|
|
IFNULL(sum(if(l.transaction_type='Debit',1,0)),0) refund_orders
|
|
|
|
|
FROM pmt_transactions l
|
|
|
|
|
where l.channel!='Settlement' and l.system_generate=0
|
|
|
|
|
<if test="client_ids!=null">
|
|
|
|
|
AND l.client_id IN
|
|
|
|
|
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
|
|
|
|
@ -824,31 +857,39 @@
|
|
|
|
|
<if test="end!=null">and l.transaction_time < #{end}</if>
|
|
|
|
|
<if test="org_id!=null and org_ids==null">and l.org_id=#{org_id}</if>
|
|
|
|
|
<if test="org_ids!=null">and l.org_id in
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach></if>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getAreaMerchantAmountAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT c.client_moniker,c.short_name,c.bd_user_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) total,
|
|
|
|
|
SELECT c.client_moniker,c.short_name,c.bd_user_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0))
|
|
|
|
|
total,
|
|
|
|
|
COUNT(DISTINCT t.order_id) orders,
|
|
|
|
|
c.suburb,c.state,c.royalpayindustry,sum(if(t.channel='Alipay' OR t.channel='AlipayOnline',t.clearing_amount,0)) alipay_total,
|
|
|
|
|
sum(if(t.channel='Alipay'OR t.channel='AlipayOnline',1,0)) alipay_order,sum(if(t.channel='Wechat',t.clearing_amount,0)) wechat_toatl,
|
|
|
|
|
c.suburb,c.state,c.royalpayindustry,sum(if(t.channel='Alipay' OR t.channel='AlipayOnline',t.clearing_amount,0))
|
|
|
|
|
alipay_total,
|
|
|
|
|
sum(if(t.channel='Alipay'OR t.channel='AlipayOnline',1,0))
|
|
|
|
|
alipay_order,sum(if(t.channel='Wechat',t.clearing_amount,0)) wechat_toatl,
|
|
|
|
|
sum(if(t.channel='Wechat',1,0)) wechat_order
|
|
|
|
|
FROM pmt_transactions t
|
|
|
|
|
INNER JOIN pmt_orders ord on ord.order_id = t.order_id
|
|
|
|
|
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1
|
|
|
|
|
FROM sys_clients c
|
|
|
|
|
LEFT JOIN (select
|
|
|
|
|
tt.client_id,tt.order_id,tt.transaction_type,tt.clearing_amount, tt.channel
|
|
|
|
|
from pmt_transactions tt where tt.transaction_type = 'Credit'
|
|
|
|
|
and tt.system_generate=0
|
|
|
|
|
<if test="begin!=null">and tt.transaction_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and tt.transaction_time <= #{end}</if>
|
|
|
|
|
)t on t.client_id = c.client_id
|
|
|
|
|
<if test="bd_user!=null">
|
|
|
|
|
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
|
|
|
|
|
date(d.start_date)<= #{begin} and (d.end_date is null or date(d.end_date)>= #{end}) and
|
|
|
|
|
d.is_valid=1
|
|
|
|
|
</if>
|
|
|
|
|
where (t.transaction_type = 'Credit')
|
|
|
|
|
<if test="begin!=null">and t.transaction_time >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and t.transaction_time <= #{end}</if>
|
|
|
|
|
where (c.is_valid = 1 )
|
|
|
|
|
<if test="state!=null">and c.state <= #{state}</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>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="client_monikers!=null">
|
|
|
|
|
AND c.client_moniker IN
|
|
|
|
|
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
|
|
|
|
@ -858,6 +899,29 @@
|
|
|
|
|
GROUP BY c.client_id order by total desc
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="countAreaMerchantAmountAnalysis" resultType="int">
|
|
|
|
|
SELECT count(distinct c.client_id) clients
|
|
|
|
|
FROM sys_clients c
|
|
|
|
|
<if test="bd_user!=null">
|
|
|
|
|
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
|
|
|
|
|
date(d.start_date)<= #{begin} and (d.end_date is null or date(d.end_date)>= #{end}) and
|
|
|
|
|
d.is_valid=1
|
|
|
|
|
</if>
|
|
|
|
|
where (c.is_valid = 1)
|
|
|
|
|
|
|
|
|
|
<if test="state!=null">and c.state <= #{state}</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_monikers!=null">
|
|
|
|
|
AND c.client_moniker IN
|
|
|
|
|
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
|
|
|
|
|
#{client_moniker}
|
|
|
|
|
</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getAreaMerchantAmountByCycle" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT c.client_moniker,sum(if(t.transaction_type='Credit',t.clearing_amount,0)) old_total,
|
|
|
|
@ -868,16 +932,20 @@
|
|
|
|
|
RIGHT JOIN sys_clients c on t.client_id = c.client_id and c.is_valid = 1
|
|
|
|
|
<if test="bd_user!=null">
|
|
|
|
|
INNER JOIN sys_client_bd d ON c.client_id = d.client_id AND d.bd_id = #{bd_user} and
|
|
|
|
|
date(d.start_date)<= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY) and (d.end_date is null or date(d.end_date)>= #{begin}) and
|
|
|
|
|
date(d.start_date)<= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY) and (d.end_date is null
|
|
|
|
|
or date(d.end_date)>= #{begin}) and
|
|
|
|
|
d.is_valid=1
|
|
|
|
|
</if>
|
|
|
|
|
where (t.transaction_type = 'Credit')
|
|
|
|
|
<if test="begin!=null">and t.transaction_time >= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin}) DAY)</if>
|
|
|
|
|
<if test="begin!=null">and t.transaction_time >= DATE_ADD(#{begin},INTERVAL -datediff( #{end},#{begin})
|
|
|
|
|
DAY)
|
|
|
|
|
</if>
|
|
|
|
|
<if test="end!=null">and t.transaction_time <= #{begin}</if>
|
|
|
|
|
<if test="state!=null">and c.state <= #{state}</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>
|
|
|
|
|
<foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
|
|
|
|
|
</if>
|
|
|
|
|
<if test="client_monikers!=null">
|
|
|
|
|
AND c.client_moniker IN
|
|
|
|
|
<foreach collection="client_monikers" open="(" close=")" separator="," item="client_moniker">
|
|
|
|
@ -888,9 +956,9 @@
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getOrderClearAmount" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
SELECT clearing_amount,o.client_id
|
|
|
|
|
SELECT clearing_amount, o.client_id
|
|
|
|
|
FROM pmt_orders o
|
|
|
|
|
INNER JOIN pmt_transactions pt ON o.order_id = pt.order_id
|
|
|
|
|
INNER JOIN pmt_transactions pt ON o.order_id = pt.order_id
|
|
|
|
|
WHERE o.order_id = #{order_id}
|
|
|
|
|
LIMIT 1;
|
|
|
|
|
</select>
|
|
|
|
|