@ -17,10 +17,11 @@
ORDER BY transaction_time
LIMIT 1;
</select>
<!-- 1.partner card 标题 -->
<!-- 已修改 -->
<select id= "getTransactionCommonAnalysis" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT ifnull(sum(if(t.transaction_type = 'Credit',t.clearing_amount,-t.clearing_amount )), 0) total_amount,
SELECT ifnull(sum(if(t.transaction_type = 'Credit' ,t.clearing_amount,0 )), 0) total_amount,
ifnull(sum(if(t.transaction_type = 'Credit' and t.refund_id is null,1,0)), 0) total_count,
ifnull(sum(if(t.refund_id is not null,if(t.transaction_type = 'Debit',t.clearing_amount,-t.clearing_amount),0)), 0) refund_amount,
ifnull(sum(if(t.clearing_status != 1,if(t.transaction_type = 'Credit',t.clearing_amount,-t.clearing_amount),0)), 0) notsettle_amount,
@ -34,7 +35,11 @@
</if>
</where>
</select>
<!-- 1.Dashboard标题交易额( 移动至getClientTransaction)
2 商户端 Dashboard 标题 交易额 ( 移动至getClientTransaction) )
3.BD analysis bd提成
4./api/v1.0/retail/app 移动至getClientTransaction) -->
<!-- 不修改 -->
<select id= "analysisTotalAmount" resultType= "java.math.BigDecimal" >
< ![CDATA[
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount)), 0)
@ -56,7 +61,10 @@
<if test= "org_ids!=null" > and l.org_id in
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
</select>
<!-- 1.Dashboard交易笔数 ( 移动至getClientTransaction)
2./api/v1.0/retail/app 移动至getClientTransaction)
2.商户端 dashboard 交易笔数( 移动至getClientTransaction) -->
<!-- 不修改 -->
<select id= "analysisTotalCount" resultType= "java.lang.Double" >
< ![CDATA[
SELECT ifnull(count(DISTINCT l.order_id), 0)
@ -80,6 +88,7 @@
</if>
</select>
<!-- 1.商户端 dashboard退款金额 ( 移动至getClientTransaction) -->
<select id= "analysisRefundAmount" resultType= "java.lang.Double" >
< ![CDATA[
SELECT ifnull(sum(if(l.transaction_type='Debit',l.clearing_amount,-l.clearing_amount)), 0)
@ -99,7 +108,8 @@
</if>
</select>
<!-- 商户端 dashboard 未清算金额 -->
<!-- 不修改 -->
<select id= "analysisNotSettled" resultType= "java.lang.Double" >
< ![CDATA[
SELECT ifnull(sum(if(transaction_type = 'Credit', clearing_amount, -clearing_amount)), 0)
@ -117,6 +127,8 @@
</if>
</select>
<!-- 商户端 dashboard 预授权金额 -->
<!-- 不修改 -->
<select id= "analysisPreAmount" resultType= "java.lang.Double" >
< ![CDATA[
SELECT ifnull(sum(l.clearing_amount), 0)
@ -136,7 +148,9 @@
</if>
</select>
<!-- 1.Dashboard最大交易额订单(aud_fee)
2.商户端 Dashboard最大交易额订单-->
<!-- 不修改 -->
<select id= "getTopOrders" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT
@ -169,6 +183,9 @@
]]>
</select>
<!-- 1.Dashboard交易类型分布 - 交易量
2.partner card 交易类型分布-交易量-->
<!-- 已修改 -->
<select id= "getTradeAmountInTypes" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT
@ -198,7 +215,7 @@
WHEN 11
THEN 'Share Code'
END AS gateway_label,
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,-l.clearing_amount )), 0) aud_fee
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0 )), 0) aud_fee
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id
WHERE (l.transaction_type = 'Credit' or l.refund_id is not null)
@ -211,11 +228,15 @@
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
GROUP BY gateway_label
</select>
<!-- 1.交易数据(日统计)交易时间分布
2.商户端 Dashboard Trading distribution chart
3.partner card Transaction Time Analysis-->
<!-- 已修改 -->
<select id= "tradeAnalysisInHours" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT h, round(sum(count)/datediff(#{end},#{begin}),1) count, round(sum(aud_fee)/datediff(#{end},#{begin}),2) aud_fee
FROM(
SELECT HOUR(o.create_time) h, DATE(o.create_time) dt, sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)) count, ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,-l.clearing_amount )), 0) aud_fee
SELECT HOUR(o.create_time) h, DATE(o.create_time) dt, sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)) count, ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0 )), 0) aud_fee
FROM pmt_transactions l
inner join pmt_orders o on o.order_id = l.order_id
WHERE (l.transaction_type='Credit' or l.refund_id is not null)
@ -252,11 +273,14 @@
order by h
]]>
</select>
<!-- 1.Dashboard交易额趋势(aud_fee)(已不用)
2.generateReport( 方法名) -->
<!-- 已修改 -->
<select id= "tradeAnalysisInDays" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT
date_format(o.create_time, '%Y-%m-%d') date_str,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, -l.clearing_amount )), 0) aud_fee,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, 0 )), 0) aud_fee,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time < = #{end}
@ -279,11 +303,13 @@
ORDER BY date(o.create_time)
]]>
</select>
<!-- 1.商户端 Dashboard Trading trends -->
<!-- 已修改 -->
<select id= "tradeAnalysisInDay" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT
date_format(#{end}, '%Y-%m-%d') date_str,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount, -l.clearing_amount )), 0) aud_fee,
ifnull(sum(if(l.transaction_type = 'Credit', l.clearing_amount,0 )), 0) aud_fee,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null,1,0)),0) order_count
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND o.create_time < = #{end}
@ -416,7 +442,9 @@
o.create_time < #{date} and o.status>=5
]]>
</select>
<!-- 1.Dashboard 交易类型分布 - 商户数量
2.gataway统计 各交易类型商家数量分布(家)-->
<!-- 不修改 -->
<select id= "getTradePartnersInTypes" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT
@ -466,9 +494,11 @@
GROUP BY gateway_label
</select>
<!-- 1.getaWay统计 交易方式商户排名 -->
<!-- 已修改 -->
<select id= "getPartnersByTradeType" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT c.short_name ,ifnull(SUM(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount )), 0) total
SELECT c.short_name ,ifnull(SUM(if(l.transaction_type = 'Credit',l.clearing_amount,0 )), 0) total
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id
left JOIN sys_clients c on c.client_id=o.client_id AND c.is_valid=1
@ -542,6 +572,8 @@
<!-- </if> -->
<!-- <if test="org_id!=null">and l.org_id=#{org_id}</if> -->
<!-- </select> -->
<!-- 1.Dashboard交易时间分布(order_total) -->
<!-- 不修改 -->
<select id= "getOrdersByGateway" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT po.create_time,
@ -631,9 +663,12 @@
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
GROUP BY date , channel ORDER BY date DESC
</select>
<!-- 1.合伙人 合伙人销量 各组织机构交易量分布
2.generateReport( WeekReporter) -->
<!-- 已修改 -->
<select id= "getOrgTransactionAnalysis" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount)) amount
SELECT o.org_id, o.name org_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0 )) amount
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
@ -647,9 +682,11 @@
<foreach collection= "org_ids" item= "org_id" open= "(" close= ")" separator= "," > #{org_id}</foreach> </if>
GROUP BY o.org_id order by amount desc
</select>
<!-- 1.合伙人 合伙人销量 合伙人商户交易量排名 -->
<!-- 已修改 -->
<select id= "getPartnersAmountByOrg" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT c.client_moniker,c.short_name,sum(if(t.transaction_type='Credit',t.clearing_amount,-t.clearing_amount )) amount
SELECT c.client_moniker,c.short_name,sum(if(t.transaction_type='Credit',t.clearing_amount,0 )) amount
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 AND c.org_id = #{org_id}
@ -660,9 +697,11 @@
GROUP BY c.client_id order by amount desc
</select>
<!-- (1)Dashboard支付通道交易额, 订单数 -->
<!-- 已修改 -->
<select id= "getPlatformAmount" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,-l.clearing_amount )), 0) amount,
SELECT ifnull(sum(if(l.transaction_type = 'Credit',l.clearing_amount,0 )), 0) amount,
ifnull(count(DISTINCT l.order_id), 0) order_count
FROM pmt_transactions l
INNER JOIN pmt_orders o ON o.order_id = l.order_id AND o.create_time >= #{begin} AND
@ -696,7 +735,8 @@
<if test= "amount_to!=null" > and t.clearing_amount < #{amount_to}</if>
</select>
<!-- 1.交易金额分析 交易订单列表 -->
<!-- 不更改 -->
<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
FROM pmt_transactions t
@ -711,6 +751,8 @@
<if test= "amount_to!=null" > and t.clearing_amount < #{amount_to}</if>
</select>
<!-- 交易金额分析 饼图 -->
<!-- 不更改 -->
<select id= "getAmountRangeAnalysis" resultType= "com.alibaba.fastjson.JSONObject" >
select
sum(if(t.clearing_amount > = 0 and t.clearing_amount < 20,1,0)) amount0_20,
@ -732,14 +774,19 @@
<if test= "channel!=null" > and t.channel=#{channel}</if>
</select>
<!-- 1.Dashboard标题交易额
2.Dashboard 交易笔数
3.商户端 交易额,交易笔数 退款金额
4./api/v1.0/retail/app-->
<!-- 新增接口 -->
<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.refund_id>0,l.clearing_amount,0)),0) refund_amount,
sum(if(l.transaction_type='Credit',1,0)) trade_count,
sum(if(l.refund_id>0,1,0)) refund_orders,
sum(if(l.refund_id>0,1,0)) refund_orders
FROM pmt_transactions l
where l.channel!='Settlement' and t .system_generate=0
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" >
@ -749,8 +796,8 @@
<if test= "client_ids==null and client_id != null" >
and l.client_id=#{client_id}
</if>
<if test= "begin!=null" > and l.transaction > = #{begin}</if>
<if test= "end!=null" > and l.transaction < #{end}</if>
<if test= "begin!=null" > and l.transaction_time > = #{begin}</if>
<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>