|
|
|
@ -456,4 +456,36 @@
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY datelist ORDER BY datelist
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="countTradedClients" resultType="java.lang.Integer">
|
|
|
|
|
SELECT COUNT(DISTINCT s.client_id) 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>
|
|
|
|
|
s.client_id != 0
|
|
|
|
|
<if test="begin!=null">and s.date >= #{begin}</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>
|