optimise settle log sql

master
Yixian 4 years ago
parent e67ba7c00d
commit 9497cf2559

@ -682,15 +682,17 @@
<select id="listSettlementLogTotal" resultType="com.alibaba.fastjson.JSONObject"> <select id="listSettlementLogTotal" resultType="com.alibaba.fastjson.JSONObject">
<![CDATA[ <![CDATA[
SELECT DATE(t.transaction_time) clearing_time,date_format(t.transaction_time, '%Y-%m-%d') clear_time,SUM(t.clearing_amount) total, SELECT cd.report_date clearing_time,
sum(if(LOCATE('MERCHANT',t.system_transaction_id),t.clearing_amount,0)) income, date_format(cd.report_date, '%Y-%m-%d') clear_time,
sum(if(LOCATE('SURCHARGE',t.system_transaction_id),t.clearing_amount,0)) fee SUM(cd.gross_amount) total,
FROM pmt_transactions t sum(cd.clearing_amount) income,
LEFT JOIN sys_clients c on c.client_id = t.client_id sum(cd.total_charge+cd.tax_amount) fee
WHERE t.channel='Settlement' from log_clearing_detail cd
inner JOIN sys_clients c on c.client_id = cd.client_id
]]> ]]>
<where>
<if test="client_ids!=null"> <if test="client_ids!=null">
AND t.client_id IN AND cd.client_id IN
<foreach collection="client_ids" open="(" close=")" separator="," item="client_id"> <foreach collection="client_ids" open="(" close=")" separator="," item="client_id">
#{client_id} #{client_id}
</foreach> </foreach>
@ -698,14 +700,15 @@
<if test="client_ids==null and client_id !=null"> <if test="client_ids==null and client_id !=null">
and (c.client_id=#{client_id} or c.parent_client_id=#{client_id}) and (c.client_id=#{client_id} or c.parent_client_id=#{client_id})
</if> </if>
<if test="from!=null">and t.transaction_time &gt;= #{from}</if> <if test="from!=null">and cd.report_date &gt;= #{from}</if>
<if test="to!=null">and t.transaction_time &lt; #{to}</if> <if test="to!=null">and cd.report_date &lt; #{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> <foreach collection="org_ids" item="org_id" open="(" close=")" separator=",">#{org_id}</foreach>
</if> </if>
GROUP BY DATE(t.transaction_time) GROUP BY cd.report_date
order by t.clearing_time desc order by cd.clearing_id desc
</where>
</select> </select>
<select id="listSettlementLogInClients" resultType="com.alibaba.fastjson.JSONObject"> <select id="listSettlementLogInClients" resultType="com.alibaba.fastjson.JSONObject">

Loading…
Cancel
Save