master
yixian 6 years ago
parent 6529413836
commit 3008520c0a

@ -139,16 +139,66 @@
</update>
<select id="listOrders" resultType="com.alibaba.fastjson.JSONObject">
<if test="bd_user != null">
SELECT temp.* FROM (
</if>
<if test="gateway">
<include refid="gateway_keys"/>
</if>
<if test="!gateway">
<include refid="tradelog_list_keys"/>
</if>
FROM pmt_orders o
FROM (
select oo.order_id,oo.client_id,oo.total_amount,oo.display_amount,
oo.customer_payment_amount,oo.coupon_payment_amount,oo.currency,
oo.create_time,oo.confirm_time,oo.status,oo.order_description,oo.order_detail,
oo.client_order_id,oo.gateway,oo.channel,oo.pre_authorization,oo.refund_amount,oo.customer_id
from pmt_orders oo
<where>
<if test="search_text != null">
<bind name="name_pattern" value="'%' + search_text + '%'"/>
<if test="text_type == 'remark'">
AND oo.order_detail LIKE #{name_pattern}
</if>
<if test="text_type == 'channel'">
AND oo.channel = #{search_text}
</if>
<if test="text_type == 'order_id'">
AND oo.order_id = #{search_text}
</if>
</if>
<if test="order_id != null">
AND oo.order_id = #{order_id}
</if>
<if test="trade_type != null">
AND oo.gateway IN
<foreach collection="trade_type" item="gateway" open="(" close=")" separator=",">
#{gateway}
</foreach>
</if>
<if test="from != null">
AND oo.create_time &gt;= #{from}
</if>
<if test="to != null">
AND oo.create_time &lt; #{to}
</if>
<if test="date != null">
AND oo.transaction_date = DATE(#{date})
</if>
<if test="dev_id != null">
AND oo.dev_id = #{dev_id}
</if>
<if test="status != null">
AND
<foreach collection="status" item="std" open="(" close=")" separator=" or ">
oo.status = #{std}
</foreach>
</if>
<if test="channel != null">
AND
<foreach collection="channel" item="chan" open="(" close=")" separator=" or ">
oo.channel = #{chan}
</foreach>
</if>
</where>
) o
INNER JOIN sys_clients p
ON p.client_id = o.client_id
AND p.is_valid = 1
@ -175,7 +225,7 @@
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}
OR o.order_id = #{search_text}
)
</if>
<if test="text_type == 'client_moniker'">
@ -184,27 +234,9 @@
<if test="text_type == 'client_name'">
AND p.short_name LIKE #{name_pattern}
</if>
<if test="text_type == 'remark'">
AND o.order_detail LIKE #{name_pattern}
</if>
<if test="text_type == 'channel'">
AND o.channel = #{search_text}
</if>
<if test="text_type == 'sys_trans_id'">
AND t.system_transaction_id = #{search_text}
</if>
<if test="text_type == 'order_id'">
AND o.order_id = #{search_text}
</if>
</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>
</if>
<if test="org_id != null and org_ids == null">
AND p.org_id = #{org_id}
@ -215,33 +247,10 @@
#{org_id}
</foreach>
</if>
<if test="from != null">
AND o.create_time &gt;= #{from}
</if>
<if test="to != null">
AND o.create_time &lt; #{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>
</if>
<if test="channel != null">
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
SELECT distinct b.client_id
FROM sys_client_bd b
INNER JOIN financial_bd_config c
ON c.manager_id = b.bd_id
@ -254,19 +263,19 @@
</if>
)
</if>
<if test="bd_user != null">
AND p.client_id in(select distinct d.client_id
from sys_client_bd d
where d.bd_id = #{bd_user}
AND d.is_valid = 1
AND DATE(d.start_date) &lt;= curdate()
AND (d.end_date IS NULL OR DATE(d.end_date) &gt;= curdate()))
</if>
</where>
GROUP BY o.order_id, t.refund_id
<if test="bd_user != null">
) temp
INNER JOIN sys_client_bd d
ON temp.client_id = d.client_id
AND d.bd_id = #{bd_user}
AND d.is_valid = 1
AND DATE(d.start_date) &lt;= DATE(now())
AND (d.end_date IS NULL OR DATE(d.end_date) &gt;= DATE(now()))
</if>
GROUP BY o.order_id
</select>
<select id="listOrdersNoPage" resultType="com.alibaba.fastjson.JSONObject">
<if test="gateway">
<include refid="gateway_keys"/>
@ -293,7 +302,7 @@
<if test="from!=null">and o.create_time &gt;= #{from}</if>
<if test="to!=null">and o.create_time &lt; #{to}</if>
</where>
GROUP BY o.order_id,t.refund_id
GROUP BY o.order_id
order by o.create_time
</select>
@ -371,7 +380,7 @@
</foreach>
</if>
</where>
GROUP BY o.order_id,t.refund_id
GROUP BY o.order_id
</select>

Loading…
Cancel
Save