|
|
@@ -533,54 +533,39 @@ select a.id,a.name,d.name as departmentName,role_name as roleName,ifnull(e.telNo
|
|
|
order by a.name
|
|
|
</select>
|
|
|
<select id="sometimeMarketingDepStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
|
|
|
- select
|
|
|
- a.department_id as departmentId,
|
|
|
- d.name as departmentName,
|
|
|
- f.name as departmentManagerName,
|
|
|
- d.manager_id,
|
|
|
- ifnull(e.telNo,0) as countTelNo,
|
|
|
- ifnull(e.visitNo,0) as countVisitNo,
|
|
|
- ifnull(e.followNo,0) as countFollowNo
|
|
|
- <if test="startTime !=null and endTime !=null">
|
|
|
- ,e.followNo/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as AVG
|
|
|
- </if>
|
|
|
- from admin a left join user_role b on
|
|
|
- a.id = b.uid left join role c on
|
|
|
- b.rid = c.id left join department_management d on
|
|
|
- a.department_id = d.id left join admin f on
|
|
|
- d.manager_id=f.id left join (select
|
|
|
- b.department_id,
|
|
|
+ select z.id,z.name as departmentName,y.name as departmentManagerName,
|
|
|
+ x.followNo as countFollowNo,x.visitNo as countVisitNo,x.telNo as countTelNo
|
|
|
+ <if test="startTime !=null and endTime !=null">
|
|
|
+ ,x.followNo/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as dayAVG
|
|
|
+ </if>
|
|
|
+ from (select b.department_id as departmentId,sum(a.followNo) as followNo,sum(a.visitNo)as visitNo,sum(a.telNo)as telNo
|
|
|
+ from (select
|
|
|
+ aid,
|
|
|
count( 0 ) as followNo,
|
|
|
ifnull(
|
|
|
- sum( case when a.contact_type = 0 then 1 else 0 end ),
|
|
|
+ sum( case when contact_type = 0 then 1 else 0 end ),
|
|
|
0
|
|
|
) as visitNo,
|
|
|
ifnull(
|
|
|
- sum( case when a.contact_type = 1 then 1 else 0 end ),
|
|
|
+ sum( case when contact_type = 1 then 1 else 0 end ),
|
|
|
0
|
|
|
) as telNo
|
|
|
- from user_follow a left join admin b on a.aid=b.id
|
|
|
- left join department_management c on b.department_id=c.id
|
|
|
- where
|
|
|
- 1 = 1
|
|
|
+ from user_follow a where 1 = 1
|
|
|
<if test="startTime !=null">
|
|
|
and a.create_time > #{startTime,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
<if test="endTime !=null">
|
|
|
and a.create_time < #{endTime,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
- GROUP BY b.department_id)e on a.department_id=e.department_id
|
|
|
- where
|
|
|
- 1 = 1
|
|
|
- and(
|
|
|
- c.role_name = '营销员'
|
|
|
- or c.role_name = '营销经理'
|
|
|
- or c.role_name = '营销管理员'
|
|
|
- )
|
|
|
+ GROUP BY aid)a left join admin b on a.aid=b.id
|
|
|
+ left join department_management c on b.department_id=c.id
|
|
|
+ where b.department_id is not null and b.department_id !=''
|
|
|
<if test="depId != null">
|
|
|
- and a.department_id= #{depId,jdbcType=VARCHAR}
|
|
|
+ and b.department_id=#{depId,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
- group by a.department_id
|
|
|
+ GROUP by b.department_id
|
|
|
+) x left join department_management z on x.departmentId=z.id
|
|
|
+ left join admin y on z.manager_id=y.id
|
|
|
</select>
|
|
|
<select id="countsometimeMarketingStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
|
|
|
select
|
|
|
@@ -608,4 +593,31 @@ select a.id,a.name,d.name as departmentName,role_name as roleName,ifnull(e.telNo
|
|
|
and a.department_id= #{depId,jdbcType=VARCHAR}
|
|
|
</if>
|
|
|
</select>
|
|
|
+
|
|
|
+ <select id="countsometimeMarketingDepStatistics" parameterType="String" resultType="com.goafanti.report.bo.SomeTimeMarketingBo">
|
|
|
+ select
|
|
|
+ count( 0 ) as countFollowNo,
|
|
|
+ ifnull(
|
|
|
+ sum( case when a.contact_type = 0 then 1 else 0 end ),
|
|
|
+ 0
|
|
|
+ ) as countVisitNo,
|
|
|
+ ifnull(
|
|
|
+ sum( case when a.contact_type = 1 then 1 else 0 end ),
|
|
|
+ 0
|
|
|
+ ) as countTelNo
|
|
|
+ <if test="startTime !=null and endTime !=null">
|
|
|
+ ,count( 0 )/datediff(#{endTime,jdbcType=VARCHAR},#{startTime,jdbcType=VARCHAR}) as A
|
|
|
+ </if>
|
|
|
+ from
|
|
|
+ user_follow a left join admin b on
|
|
|
+ a.aid = b.id left join department_management c on
|
|
|
+ b.department_id = c.id left join user_role d on
|
|
|
+ b.id = d.uid left join role e on
|
|
|
+ d.rid = e.id
|
|
|
+ where 1 = 1
|
|
|
+ and( e.role_name = '营销员' or e.role_name = '营销经理' or e.role_name = '营销管理员')
|
|
|
+ <if test="depId != null">
|
|
|
+ and a.department_id= #{depId,jdbcType=VARCHAR}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
</mapper>
|