Browse Source

部门客户统计修改及新增字段

anderx 1 year ago
parent
commit
29ad01285d
1 changed files with 8 additions and 18 deletions
  1. 8 18
      src/main/java/com/goafanti/common/mapper/AdminMapper.xml

+ 8 - 18
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -904,29 +904,19 @@
 
 
     <select id="selectAdminCustomerList"  resultType="com.goafanti.admin.bo.AdminCustomerBo">
-        select a.id as aid,a.name as aName,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(c.timeCount,0) as inputCount,
-        ifnull(d.timeCount,0) as receiveCount,ifnull(g.timeCount,0) as signCount from admin a
-        left join (select aid,count(aid) as userCount from user where aid is not null
-        and  share_type=0 and source in(1,2,3) and type=1 and new_channel=0
+        select a.id as aid,a.name as aName,d.name as depName,ifnull(b.userCount,0) as userCount,ifnull(c.inputCount,0) as newCount,
+        ifnull(c.receiveCount,0) as receiveCount,ifnull(b.signCount,0) as signCount,ifnull(c.transferCount,0) as transferCount
+        from admin a
+        left join (select aid, sum(if(share_type=0 and source in (1,2,3),1,0))userCount,
+        sum(if(share_type=2,1,0))signCount from `user` where   type=1  and new_channel=0
         group by aid) b on a.id=b.aid
-        left join (select aid,count(aid) as timeCount from `user` where aid is not null
-        and  share_type in (0,2) and source =1 and type=1 and new_channel=0
+        left join (select aid, sum(if(share_type=0 and source in (1),1,0))inputCount,
+        sum(if(share_type=0 and source in (2),1,0))transferCount, sum(if(share_type=0 and source in (3),1,0))receiveCount
+        from `user` where   type=1  and new_channel=0
         <if test="startTime != null and endTime != null">
             and  transfer_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
         </if>
         group by aid) c on a.id=c.aid
-        left join (select aid,count(aid) as timeCount from `user` where aid is not null
-        and  share_type in (0,2) and source =2 and type=1 and new_channel=0
-        <if test="startTime != null and endTime != null">
-            and  transfer_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-        </if>
-        group by aid) d on a.id=d.aid
-        left join (select aid,count(aid) as timeCount from `user` where aid is not null
-        and share_type =2 and type=1  and new_channel=0
-        <if test="startTime != null and endTime != null">
-            and  transfer_time  between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
-        </if>
-        group by aid) g on a.id=g.aid
         left join department d on a.department_id=d.id
         left join user_role e on a.id=e.uid
         left join `role` f on e.rid=f.id