|
|
|
@ -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 >= DATE_FORMAT(DATE_ADD(#{end},INTERVAL -1 DAY),'%Y-%m-%d')</if>
|
|
|
|
|
<if test="end!=null">and s.date < #{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<=now() and (b.end_date is null or b.end_date >= 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 >= DATE_FORMAT(DATE_ADD(#{end},INTERVAL -1 DAY),'%Y-%m-%d')</if>
|
|
|
|
|
<if test="end!=null">and s.date < #{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<=now() and (b.end_date is null or b.end_date >= 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>
|