partner_dashboard 页面清算查询优化

master
dalong306 3 years ago
parent 7046841c74
commit 7f3644467e

@ -60,6 +60,8 @@ public interface TransactionMapper {
PageList<JSONObject> listSettlementLog(JSONObject params, PageBounds pagination); PageList<JSONObject> listSettlementLog(JSONObject params, PageBounds pagination);
PageList<JSONObject> listSettlementLogForDashbord(JSONObject params, PageBounds pagination);
@CountRef(".countSettlementLogInClients") @CountRef(".countSettlementLogInClients")
PageList<JSONObject> listSettlementLogInClients(JSONObject params, PageBounds pagination); PageList<JSONObject> listSettlementLogInClients(JSONObject params, PageBounds pagination);

@ -1423,7 +1423,7 @@ public class TradeLogServiceImpl implements TradeLogService {
params.remove("client_ids"); params.remove("client_ids");
params.put("merge_settle", true); params.put("merge_settle", true);
} }
PageList<JSONObject> logs = transactionMapper.listSettlementLog(params, PageList<JSONObject> logs = transactionMapper.listSettlementLogForDashbord(params,
new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc"))); new PageBounds(query.getPage(), query.getLimit(), Order.formString("clearing_time.desc")));
logs.forEach(log -> log.put("padding", log.getBooleanValue("editable"))); logs.forEach(log -> log.put("padding", log.getBooleanValue("editable")));
result.putAll(PageListUtils.buildPageListResult(logs)); result.putAll(PageListUtils.buildPageListResult(logs));

@ -600,6 +600,50 @@
order by t.clearing_time desc order by t.clearing_time desc
</select> </select>
<select id="listSettlementLogForDashbord" resultType="com.alibaba.fastjson.JSONObject">
SELECT cd.client_id,cd.report_date clearing_time,
cd.report_date,
<if test="merge_settle!=null">
SUM(cd.tax_amount) as tax_amount,
SUM(cd.total_charge) as total_charge,
1 as merge_settle,
SUM(cd.gross_amount) total,
SUM(cd.clearing_amount) income,
SUM(cd.gross_amount-cd.clearing_amount) fee,
</if>
<if test="merge_settle==null">
cd.tax_amount,
cd.total_charge,
cd.gross_amount total,
cd.clearing_amount income,
cd.gross_amount-cd.clearing_amount fee,
</if>
(SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = cd.client_id
AND date(r.expiry_time) >= DATE(cd.report_date)
AND date(r.active_time) &lt;= DATE(cd.report_date)) rate,
cd.clear_detail_id,
lc.balance_group, lc.editable
FROM log_clearing_detail cd
left join log_clearing lc on cd.clearing_id = lc.clearing_id
left join sys_clients sc on cd.client_id = sc.client_id
WHERE
<if test="client_ids!=null">
cd.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">
(sc.client_id=#{client_id} or sc.parent_client_id =#{client_id})
</if>
<if test="from!=null">and cd.report_date &gt;= #{from}</if>
<if test="to!=null">and cd.report_date &lt; #{to}</if>
<if test="merge_settle!=null">GROUP BY report_date</if>
order by cd.report_date desc
</select>
<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 DATE(t.transaction_time) clearing_time,date_format(t.transaction_time, '%Y-%m-%d') clear_time,SUM(t.clearing_amount) total,

Loading…
Cancel
Save