@ -95,6 +95,8 @@
<update id= "updateRefundAmount" >
<update id= "updateRefundAmount" >
< ![CDATA[
< ![CDATA[
UPDATE pmt_orders o
UPDATE pmt_orders o
LEFT JOIN (
LEFT JOIN (
SELECT
SELECT
@ -113,16 +115,23 @@
THEN 7
THEN 7
END
END
WHERE o.order_id = #{order_id}
WHERE o.order_id = #{order_id}
]]>
]]>
</update>
</update>
<update id= "updateOrderCreationError" >
<update id= "updateOrderCreationError" >
< ![CDATA[
< ![CDATA[
UPDATE pmt_orders
UPDATE pmt_orders
SET status = #{status}, error_code = #{error_code}, error_message = #{error_message}
SET status = #{status}, error_code = #{error_code}, error_message = #{error_message}
WHERE order_id = #{order_id} AND status < = #{status}
WHERE order_id = #{order_id} AND status < = #{status}
]]>
]]>
</update>
</update>
<select id= "listOrders" resultType= "com.alibaba.fastjson.JSONObject" >
<select id= "listOrders" resultType= "com.alibaba.fastjson.JSONObject" >
<if test= "bd_user!=null" >
<if test= "bd_user!=null" >
SELECT temp.* FROM (
SELECT temp.* FROM (
@ -150,7 +159,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
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>
<if test= "text_type=='client_moniker'" >
<if test= "text_type=='client_moniker'" >
and p.client_moniker=#{search_text}
and p.client_moniker=#{search_text}
@ -177,16 +187,20 @@
</if>
</if>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</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
<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= "from!=null" > and o.create_time > = #{from}</if>
<if test= "to!=null" > and o.create_time < #{to}</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= "date!=null" > and date(o.create_time)=date(#{date})</if>
<if test= "dev_id!=null" > and o.dev_id=#{dev_id}</if>
<if test= "dev_id!=null" > and o.dev_id=#{dev_id}</if>
<if test= "status!=null" >
<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>
<if test= "channel!=null" >
<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>
<if test= "bd_group!=null" > and p.client_id in
<if test= "bd_group!=null" > and p.client_id in
(SELECT b.client_id FROM sys_client_bd b
(SELECT b.client_id FROM sys_client_bd b
@ -263,7 +277,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
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})
or o.client_order_id = #{search_text})
</if>
</if>
<if test= "text_type=='client_moniker'" >
<if test= "text_type=='client_moniker'" >
@ -294,33 +309,42 @@
</if>
</if>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</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
<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= "from!=null" > and o.create_time > = #{from}</if>
<if test= "to!=null" > and o.create_time < #{to}</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= "date!=null" > and date(o.create_time)=date(#{date})</if>
<if test= "status!=null" >
<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>
<if test= "channel!=null" >
<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>
</where>
</where>
GROUP BY o.order_id,t.refund_id
GROUP BY o.order_id,t.refund_id
</select>
</select>
<select id= "analysisOrders" resultType= "com.alibaba.fastjson.JSONObject" >
<select id= "analysisOrders" resultType= "com.alibaba.fastjson.JSONObject" >
select
select
count(DISTINCT l.order_id) order_count,
count(DISTINCT l.order_id) order_count,
ifnull(sum(if(l.transaction_type='Credit' and l.refund_id is null ,l.clearing_amount,0)),0) paid_fee,
ifnull(sum(if(l.transaction_type='Credit',l.clearing_amount,0)),0) paid_fee,
ifnull(sum(if(l.refund_id is not null,if(l.transaction_type='Debit',-l.clearing_amount,l.clearing_amount),0)),0)
ifnull(sum(if(l.refund_id is not null,if(l.transaction_type='Debit',-l.clearing_amount,l.clearing_amount),0)),0)
refund_fee,
refund_fee,
ifnull(sum(if(l.refund_id is not null AND l.pre_authorization=1,l.clearing_amount,0)),0)
ifnull(sum(if(l.refund_id is not null AND l.pre_authorization=1,l.clearing_amount,0)),0)
pre_refund_fee,
pre_refund_fee,
count(DISTINCT l.customer_id) customers,
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',l.display_amount,0)),0)
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,
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
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
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 (
from (
<if test= "bd_user!=null" >
<if test= "bd_user!=null" >
SELECT temp.* FROM (
SELECT temp.* FROM (
@ -344,7 +368,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
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})
or o.client_order_id = #{search_text})
</if>
</if>
<if test= "text_type=='client_moniker'" >
<if test= "text_type=='client_moniker'" >
@ -373,7 +398,8 @@
</if>
</if>
</if>
</if>
<if test= "org_ids!=null" > and p.org_id in
<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= "order_id!=null" > and o.order_id=#{order_id}</if>
<if test= "trade_type!=null" > and o.gateway in
<if test= "trade_type!=null" > and o.gateway in
<foreach collection= "trade_type" item= "gateway" open= "(" close= ")" separator= "," > #{gateway}</foreach>
<foreach collection= "trade_type" item= "gateway" open= "(" close= ")" separator= "," > #{gateway}</foreach>
@ -384,10 +410,13 @@
<if test= "date!=null" > and date(o.create_time)=date(#{date})</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= "dev_id!=null" > and o.dev_id=#{dev_id}</if>
<if test= "status!=null" >
<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>
<if test= "channel!=null" >
<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>
<if test= "bd_group!=null" > and p.client_id in
<if test= "bd_group!=null" > and p.client_id in
(SELECT b.client_id FROM sys_client_bd b
(SELECT b.client_id FROM sys_client_bd b
@ -449,6 +478,8 @@
</select>
</select>
<select id= "listOrdersWithNoTransactions" resultType= "com.alibaba.fastjson.JSONObject" >
<select id= "listOrdersWithNoTransactions" resultType= "com.alibaba.fastjson.JSONObject" >
< ![CDATA[
< ![CDATA[
SELECT
SELECT
o.order_id,
o.order_id,
o.channel
o.channel
@ -457,6 +488,8 @@
SELECT DISTINCT order_id
SELECT DISTINCT order_id
FROM pmt_transactions
FROM pmt_transactions
WHERE transaction_type = 'Credit') AND o.status >= 5 AND o.customer_payment_amount > 0
WHERE transaction_type = 'Credit') AND o.status >= 5 AND o.customer_payment_amount > 0
]]>
]]>
</select>
</select>
@ -468,6 +501,7 @@
WHERE o.customer_id = #{customer_id} and t.transaction_time > = '2017-11-07'
WHERE o.customer_id = #{customer_id} and t.transaction_time > = '2017-11-07'
</select>
</select>
<select id= "listOrderByCustomer" resultType= "com.alibaba.fastjson.JSONObject" >
<select id= "listOrderByCustomer" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT o.*,c.short_name,c.client_moniker FROM pmt_orders o
SELECT o.*,c.short_name,c.client_moniker FROM pmt_orders o
LEFT JOIN sys_clients c on c.client_id = o.client_id
LEFT JOIN sys_clients c on c.client_id = o.client_id
@ -483,7 +517,8 @@
<if test= "to!=null" > and o.create_time < #{to}</if>
<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_id!=null and org_ids==null" > and c.org_id=#{org_id}</if>
<if test= "org_ids!=null" > and c.org_id in
<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>
</where>
</select>
</select>
@ -514,7 +549,8 @@
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<bind name= "name_pattern" value= "'%'+search_text+'%'" />
<if test= "text_type=='all'" >
<if test= "text_type=='all'" >
and (p.client_moniker=#{search_text} or p.short_name like #{name_pattern} or o.order_detail like
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>
<if test= "text_type=='client_moniker'" >
<if test= "text_type=='client_moniker'" >
and p.client_moniker=#{search_text}
and p.client_moniker=#{search_text}
@ -541,15 +577,19 @@
</if>
</if>
<if test= "org_id!=null and org_ids==null" > and p.org_id=#{org_id}</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
<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= "from!=null" > and o.create_time > = #{from}</if>
<if test= "to!=null" > and o.create_time < #{to}</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= "date!=null" > and date(o.create_time)=date(#{date})</if>
<if test= "status!=null" >
<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>
<if test= "channel!=null" >
<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>
</where>
</where>
GROUP BY o.order_id,t.refund_id
GROUP BY o.order_id,t.refund_id
@ -558,24 +598,24 @@
<select id= "listAnalysisClientCustomer" resultType= "com.alibaba.fastjson.JSONObject" >
<select id= "listAnalysisClientCustomer" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT
SELECT
count(*) payment_times ,
count(*) payment_times ,
sum(customer_payment_amount) total_amount,
sum(customer_payment_amount) total_amount,
o.client_id client_id,
o.client_id client_id,
o.customer_id customer_id,
o.customer_id customer_id,
o.channel channel,
o.channel channel,
max( o.confirm_time) confirm_time
max( o.confirm_time) confirm_time
from pmt_orders o
from pmt_orders o
where o.customer_id is not null and o.channel is not null
where o.customer_id is not null and o.channel is not null
and client_id = #{client_id}
and client_id = #{client_id}
<if test= "confirm_time" >
<if test= "confirm_time" >
and o.confirm_time > #{confirm_time}
and o.confirm_time > #{confirm_time}
</if>
</if>
<if test= "include_success_status!=null" >
<if test= "include_success_status!=null" >
and o.status >#{include_success_status}
and o.status >#{include_success_status}
</if>
</if>
group by o.customer_id
group by o.customer_id
</select>
</select>
<select id= "listPaid" resultType= "com.alibaba.fastjson.JSONObject" >
<select id= "listPaid" resultType= "com.alibaba.fastjson.JSONObject" >
SELECT * FROM pmt_orders
SELECT * FROM pmt_orders
@ -585,7 +625,63 @@
and client_id = #{client_id}
and client_id = #{client_id}
</if>
</if>
<if test= "channels != null" >
<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>
</if>
</where>
</where>
</select>
</select>