fix dashboard

master
yuan 6 years ago
parent 440cacb194
commit 6c5680f78e

@ -131,8 +131,8 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT
private JSONObject getYesOrLasMonth(JSONObject params){
JSONObject res = new JSONObject();
res.put("traded_partners", customerAndOrdersStatisticsMapper.countTradedClients(params));
res.put("total_customers", clientCustomersMapper.countTotalCustomers(params));
res.put("old_customers", clientCustomersMapper.countTotalOldCustomers(params));
res.put("total_customers", customerAndOrdersStatisticsMapper.countTotalCustomers(params));
res.put("old_customers", customerAndOrdersStatisticsMapper.countTotalOldCustomers(params));
return res;
}

@ -57,4 +57,8 @@ public interface CustomerAndOrdersStatisticsMapper {
List<JSONObject> getAreaMerchantTradeByLastCycle(JSONObject parasm);
int countTradedClients(JSONObject params);
int countTotalCustomers(JSONObject params);
int countTotalOldCustomers(JSONObject params);
}

@ -30,10 +30,5 @@ public interface ClientCustomersMapper {
PageList<JSONObject> listCustomerInfo(JSONObject params, PageBounds pageBounds);
int countTradedClients(JSONObject params);
int countTotalCustomers(JSONObject params);
int countTotalOldCustomers(JSONObject params);
}

@ -458,7 +458,7 @@
</select>
<select id="countTradedClients" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT s.client_id) traded_partners
SELECT ifnull(COUNT(DISTINCT s.client_id),0) traded_partners
FROM statistics_customer_order s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
<where>
@ -488,4 +488,68 @@
</if>
</where>
</select>
<select id="countTotalCustomers" resultType="java.lang.Integer">
SELECT ifnull(SUM(s.customers),0) total_customers
FROM statistics_customer_order s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
<where>
s.client_id != 0
<if test="begin!=null">and s.date &gt;= DATE_FORMAT(DATE_ADD(#{end},INTERVAL -1 DAY),'%Y-%m-%d')</if>
<if test="end!=null">and s.date &lt; #{end}</if>
<if test="client_ids!=null">
AND s.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 s.client_id=#{client_id}
</if>
<if test="channel!=null">and s.channel = #{channel}</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>
<if test="bd_group!=null">and c.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND (c.bd_group=#{bd_group} or c.manager_id=#{bd_group})
<if test="bd_group_bd">and c.manager_id=#{bd_group_bd}</if>
)
</if>
</where>
</select>
<select id="countTotalOldCustomers" resultType="java.lang.Integer">
SELECT ifnull(sum(s.old_customers),0) old_customers
FROM statistics_customer_order s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
<where>
s.client_id != 0
<if test="begin!=null">and s.date &gt;= DATE_FORMAT(DATE_ADD(#{end},INTERVAL -1 DAY),'%Y-%m-%d')</if>
<if test="end!=null">and s.date &lt; #{end}</if>
<if test="client_ids!=null">
AND s.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 s.client_id=#{client_id}
</if>
<if test="channel!=null">and s.channel = #{channel}</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>
<if test="bd_group!=null">and c.client_id in
(SELECT b.client_id FROM sys_client_bd b
INNER JOIN financial_bd_config c ON c.manager_id=b.bd_id
where b.is_valid=1 and b.start_date&lt;=now() and (b.end_date is null or b.end_date &gt;= now())
AND (c.bd_group=#{bd_group} or c.manager_id=#{bd_group})
<if test="bd_group_bd">and c.manager_id=#{bd_group_bd}</if>
)
</if>
</where>
</select>
</mapper>

@ -44,42 +44,4 @@
</update>
<select id="countTradedClients" resultType="java.lang.Integer">
select COUNT(DISTINCT s.client_id) traded_clients
FROM sys_clients_customers s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
<where>
<if test="begin!=null">and s.last_payment_time &gt;= #{begin}</if>
<if test="end!=null">and s.last_payment_time &lt;= #{end}</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>
</where>
</select>
<select id="countTotalCustomers" resultType="java.lang.Integer">
select COUNT(DISTINCT s.customer_id) total_customers
FROM sys_clients_customers s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
<where>
<if test="begin!=null">and s.last_payment_time &gt;= #{begin}</if>
<if test="end!=null">and s.last_payment_time &lt;= #{end}</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>
</where>
</select>
<select id="countTotalOldCustomers" resultType="java.lang.Integer">
select COUNT(DISTINCT s.customer_id) total_old_customers
FROM sys_clients_customers s
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
<where>
<if test="begin!=null">and s.update_time &lt; #{begin} AND s.last_payment_time &gt; #{begin}</if>
<if test="end!=null">and s.last_payment_time &lt; #{end}</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>
</where>
</select>
</mapper>
Loading…
Cancel
Save