|
@@ -5,16 +5,15 @@
|
|
|
|
|
|
SELECT
|
|
|
<!-- r.id,-->
|
|
|
- cu.province name,
|
|
|
+ rd.province name,
|
|
|
count(DISTINCT c.id ) count
|
|
|
FROM
|
|
|
t_b_crm c
|
|
|
LEFT JOIN sys_custom cu ON cu.id = c.custom_id
|
|
|
LEFT JOIN t_b_service s ON c.service_id = s.id
|
|
|
- left join t_b_service_region r on r.service_id=s.id
|
|
|
- left join t_b_service_region_detail rd on rd.service_region_id=r.id
|
|
|
+ left join t_b_service_region_detail rd on rd.id=c.region_detail_id
|
|
|
<where>
|
|
|
- and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.status!='FINISH'
|
|
|
+ and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.status!='FINISH' AND c.region_detail_id IS NOT NULL
|
|
|
<if test="type != null and type != ''">
|
|
|
and cu.type = #{type}
|
|
|
</if>
|
|
@@ -35,7 +34,7 @@
|
|
|
</where>
|
|
|
GROUP BY
|
|
|
<!-- r.id,-->
|
|
|
- cu.province
|
|
|
+ rd.province
|
|
|
order by count(DISTINCT c.id ) desc
|
|
|
</select>
|
|
|
<select id="project" resultType="java.util.Map">
|
|
@@ -83,7 +82,7 @@
|
|
|
FROM
|
|
|
t_b_crm c
|
|
|
LEFT JOIN t_b_service s ON c.service_id = s.id
|
|
|
- left join t_b_service_region r on r.service_id=s.id
|
|
|
+ left join t_b_service_region r on r.id=c.region_id
|
|
|
LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
|
|
|
LEFT JOIN t_b_user_archives ua ON u.mobile_number = ua.mobile_number
|
|
|
LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id
|
|
@@ -200,8 +199,8 @@
|
|
|
su.name supplier
|
|
|
from t_b_crm a
|
|
|
LEFT JOIN t_b_service tbs ON a.service_id = tbs.id
|
|
|
- left join t_b_service_region r on r.service_id=tbs.id
|
|
|
- left join t_b_service_region_detail rd on rd.service_region_id=r.id
|
|
|
+ left join t_b_service_region r on r.id=a.region_id
|
|
|
+ left join t_b_service_region_detail rd on rd.id=a.region_detail_id
|
|
|
LEFT JOIN t_b_product p ON p.id = a.product_id
|
|
|
LEFT JOIN sys_custom sc ON sc.id = a.custom_id
|
|
|
LEFT JOIN sys_user u ON u.id = a.region_coordinator_id
|
|
@@ -223,7 +222,7 @@
|
|
|
<if test="province != null and province != ''">
|
|
|
<!-- and r.id is not null-->
|
|
|
and a.status!='FINISH'
|
|
|
- and sc.province = #{province}
|
|
|
+ and rd.province = #{province}
|
|
|
</if>
|
|
|
<if test="type != null and type != ''">
|
|
|
and sc.type = #{type}
|