@ -95,6 +95,8 @@
<update id= "updateRefundAmount" >
< ![CDATA[
UPDATE pmt_orders o
LEFT JOIN (
SELECT
@ -113,14 +115,20 @@
THEN 7
END
WHERE o.order_id = #{order_id}
]]>
</update>
<update id= "updateOrderCreationError" >
< ![CDATA[
UPDATE pmt_orders
SET status = #{status}, error_code = #{error_code}, error_message = #{error_message}
WHERE order_id = #{order_id} AND status < = #{status}
]]>
</update>
<select id= "listOrders" resultType= "com.alibaba.fastjson.JSONObject" >
@ -150,7 +158,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id =#{search_text} or o.channel = #{search_text} or t.order_id =#{search_text})
#{name_pattern} or t.system_transaction_id =#{search_text} or o.channel = #{search_text} or
t.order_id =#{search_text})
</if>
<if test= "text_type=='client_moniker'" >
and p.client_moniker=#{search_text}
@ -177,16 +186,20 @@
</if>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</if>
<if test= "org_ids!=null" > and p.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= "from!=null" > and o.create_time > = #{from}</if>
<if test= "to!=null" > and o.create_time < #{to}</if>
<if test= "date!=null" > and date(o.create_time)=date(#{date})</if>
<if test= "dev_id!=null" > and o.dev_id=#{dev_id}</if>
<if test= "status!=null" >
and <foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
and
<foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
</if>
<if test= "channel!=null" >
and <foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}</foreach>
and
<foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}
</foreach>
</if>
<if test= "bd_group!=null" > and p.client_id in
(SELECT b.client_id FROM sys_client_bd b
@ -263,7 +276,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text}
or o.client_order_id = #{search_text})
</if>
<if test= "text_type=='client_moniker'" >
@ -294,15 +308,19 @@
</if>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</if>
<if test= "org_ids!=null" > and p.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= "from!=null" > and o.create_time > = #{from}</if>
<if test= "to!=null" > and o.create_time < #{to}</if>
<if test= "date!=null" > and date(o.create_time)=date(#{date})</if>
<if test= "status!=null" >
and <foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
and
<foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
</if>
<if test= "channel!=null" >
and <foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}</foreach>
and
<foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}
</foreach>
</if>
</where>
GROUP BY o.order_id,t.refund_id
@ -317,10 +335,14 @@
ifnull(sum(if(l.refund_id is not null AND l.pre_authorization=1,l.clearing_amount,0)),0)
pre_refund_fee,
count(DISTINCT l.customer_id) customers,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY',l.display_amount,0)),0) display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY' and l.pre_authorization=1,l.display_amount,0)),0) pre_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY',l.display_amount,0)),0) cny_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY' and l.pre_authorization=1,l.display_amount,0)),0) pre_cny_display_amount
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY',l.display_amount,0)),0)
display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency!='CNY' and
l.pre_authorization=1,l.display_amount,0)),0) pre_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY',l.display_amount,0)),0)
cny_display_amount,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null and l.currency='CNY' and
l.pre_authorization=1,l.display_amount,0)),0) pre_cny_display_amount
from (
<if test= "bd_user!=null" >
SELECT temp.* FROM (
@ -344,7 +366,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text}
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text}
or o.client_order_id = #{search_text})
</if>
<if test= "text_type=='client_moniker'" >
@ -373,7 +396,8 @@
</if>
</if>
<if test= "org_ids!=null" > and p.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= "order_id!=null" > and o.order_id=#{order_id}</if>
<if test= "trade_type!=null" > and o.gateway in
<foreach collection= "trade_type" item= "gateway" open= "(" close= ")" separator= "," > #{gateway}</foreach>
@ -384,10 +408,13 @@
<if test= "date!=null" > and date(o.create_time)=date(#{date})</if>
<if test= "dev_id!=null" > and o.dev_id=#{dev_id}</if>
<if test= "status!=null" >
and <foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
and
<foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
</if>
<if test= "channel!=null" >
and <foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}</foreach>
and
<foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}
</foreach>
</if>
<if test= "bd_group!=null" > and p.client_id in
(SELECT b.client_id FROM sys_client_bd b
@ -449,6 +476,8 @@
</select>
<select id= "listOrdersWithNoTransactions" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
SELECT
o.order_id,
o.channel
@ -457,6 +486,8 @@
SELECT DISTINCT order_id
FROM pmt_transactions
WHERE transaction_type = 'Credit') AND o.status >= 5 AND o.customer_payment_amount > 0
]]>
</select>
@ -483,7 +514,8 @@
<if test= "to!=null" > and o.create_time < #{to}</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>
</where>
</select>
@ -514,7 +546,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or t.order_id = #{search_text})
#{name_pattern} or t.system_transaction_id=#{search_text} or o.channel = #{search_text} or
t.order_id = #{search_text})
</if>
<if test= "text_type=='client_moniker'" >
and p.client_moniker=#{search_text}
@ -541,15 +574,19 @@
</if>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</if>
<if test= "org_ids!=null" > and p.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= "from!=null" > and o.create_time > = #{from}</if>
<if test= "to!=null" > and o.create_time < #{to}</if>
<if test= "date!=null" > and date(o.create_time)=date(#{date})</if>
<if test= "status!=null" >
and <foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
and
<foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
</if>
<if test= "channel!=null" >
and <foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}</foreach>
and
<foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}
</foreach>
</if>
</where>
GROUP BY o.order_id,t.refund_id
@ -558,24 +595,24 @@
<select id= "listAnalysisClientCustomer" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT
count(*) payment_times ,
sum(customer_payment_amount) total_amount,
o.client_id client_id,
o.customer_id customer_id,
o.channel channel,
max( o.confirm_time) confirm_time
SELECT
count(*) payment_times ,
sum(customer_payment_amount) total_amount,
o.client_id client_id,
o.customer_id customer_id,
o.channel channel,
max( o.confirm_time) confirm_time
from pmt_orders o
where o.customer_id is not null and o.channel is not null
and client_id = #{client_id}
<if test= "confirm_time" >
and o.confirm_time > #{confirm_time}
</if>
<if test= "include_success_status!=null" >
and o.status >#{include_success_status}
</if>
group by o.customer_id
from pmt_orders o
where o.customer_id is not null and o.channel is not null
and client_id = #{client_id}
<if test= "confirm_time" >
and o.confirm_time > #{confirm_time}
</if>
<if test= "include_success_status!=null" >
and o.status >#{include_success_status}
</if>
group by o.customer_id
</select>
<select id= "listPaid" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT * FROM pmt_orders
@ -585,7 +622,63 @@
and client_id = #{client_id}
</if>
<if test= "channels != null" >
and channel IN <foreach collection= "channels" item= "channel" open= "(" close= ")" separator= "," > #{channel}</foreach>
and channel IN
<foreach collection= "channels" item= "channel" open= "(" close= ")" separator= "," > #{channel}</foreach>
</if>
</where>
</select>
<select id= "listTransactionsForApp" resultType= "com.alibaba.fastjson.JSONObject" >
select
o.order_id,
o.client_id,
o.display_amount,
o.customer_payment_amount,
o.coupon_payment_amount,
o.currency,
o.create_time,
o.confirm_time,
o.status,
o.gateway,
o.channel,
o.pre_authorization,
o.refund_amount refund_fee,
o.customer_id,
t.clearing_amount,
t.refund_id,
t.transaction_time,
t.transaction_type,
t.transaction_id,
t.exchange_rate,
t.clearing_status,
t.settle_amount
from pmt_orders o
left join pmt_transactions t on t.order_id=o.order_id and t.channel!='Settlement' and t.system_generate=0
<where >
<if test= "client_ids!=null" >
AND o.client_id IN
<foreach collection= "client_ids" open= "(" close= ")" separator= "," item= "client_id" >
#{client_id}
</foreach>
</if>
<if test= "client_ids==null and client_id !=null" >
and o.client_id=#{client_id}
</if>
<if test= "from!=null" > and o.create_time > = #{from}</if>
<if test= "to!=null" > and o.create_time < #{to}</if>
<if test= "date!=null" > and date(o.create_time)=date(#{date})
</if>
<if test= "trade_type!=null" > and o.gateway in
<foreach collection= "trade_type" item= "gateway" open= "(" close= ")" separator= "," > #{gateway}</foreach>
</if>
<if test= "status!=null" >
and
<foreach collection= "status" item= "std" open= "(" close= ")" separator= " or " > o.status=#{std}</foreach>
</if>
<if test= "channel!=null" >
and
<foreach collection= "channel" item= "chan" open= "(" close= ")" separator= " or " > o.channel=#{chan}
</foreach>
</if>
</where>
</select>