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