|
|
|
@ -93,36 +93,52 @@
|
|
|
|
|
|
|
|
|
|
<select id="getSumCustomersAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
SELECT sum(s.customers) customers,sum(s.orders) orders,sum(s.new_customers) new_customers,
|
|
|
|
|
sum(s.old_customers) old_customers,sum(s.total) total, sum(s.total)/sum(s.customers) single_amount,
|
|
|
|
|
date_format(s.date,'%d/%m/%Y') trade_date
|
|
|
|
|
FROM statistics_customer_order s
|
|
|
|
|
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
|
|
|
|
]]>
|
|
|
|
|
select date_format(calendar.datelist,'%d/%m/%Y') AS trade_date,
|
|
|
|
|
IFNULL(customerStatic.customers,0) AS customers,
|
|
|
|
|
IFNULL(customerStatic.orders,0) AS orders,
|
|
|
|
|
IFNULL(customerStatic.new_customers,0) AS new_customers,
|
|
|
|
|
IFNULL(customerStatic.old_customers,0) AS old_customers,
|
|
|
|
|
IFNULL(customerStatic.total,0) AS total,
|
|
|
|
|
IFNULL(customerStatic.single_amount,0) AS single_amount
|
|
|
|
|
FROM calendar
|
|
|
|
|
LEFT JOIN
|
|
|
|
|
(SELECT sum(s.customers) customers,sum(s.orders) orders,sum(s.new_customers) new_customers,
|
|
|
|
|
sum(s.old_customers) old_customers,sum(s.total) total, sum(s.total)/sum(s.customers) single_amount,
|
|
|
|
|
date_format(s.date,'%Y-%m-%d') trade_date
|
|
|
|
|
FROM statistics_customer_order s
|
|
|
|
|
LEFT JOIN sys_clients c ON c.client_id = s.client_id and c.is_valid=1
|
|
|
|
|
]]>
|
|
|
|
|
<where>
|
|
|
|
|
<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="begin!=null">and s.date >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and s.date < #{end}</if>
|
|
|
|
|
<if test="org_id!=null">and c.org_id = #{org_id}</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>
|
|
|
|
|
GROUP BY s.date
|
|
|
|
|
) AS customerStatic
|
|
|
|
|
ON calendar.datelist = customerStatic.trade_date
|
|
|
|
|
<where>
|
|
|
|
|
<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="begin!=null">and s.date >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and s.date < #{end}</if>
|
|
|
|
|
<if test="org_id!=null">and c.org_id = #{org_id}</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>
|
|
|
|
|
<if test="begin!=null">and calendar.datelist >= #{begin}</if>
|
|
|
|
|
<if test="end!=null">and calendar.datelist < #{end}</if>
|
|
|
|
|
</where>
|
|
|
|
|
GROUP BY s.date ORDER BY date DESC
|
|
|
|
|
ORDER BY calendar.datelist DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getSumChannelAnalysis" resultType="com.alibaba.fastjson.JSONObject">
|
|
|
|
|