Ver código fonte

修改客户总量分析查询语句

ysm 1 ano atrás
pai
commit
d818d7db4f

+ 20 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/DepartmentMapper.xml

@@ -118,7 +118,7 @@
         GROUP BY b.project_id, a.department_id
         having IFNULL(SUM(b.custom_data),0) > 0
     </select>
-    <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.DepartmentVO">
+<!--    <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.DepartmentVO">
         select count(*) as customertotal ,
         sum(case when c.close_deal=1 then 1 else 0 end) as customerDeal ,
         u.department_id as id,d.department_name as departmentName
@@ -136,6 +136,25 @@
             </if>
         </where>
         group by u.department_id
+    </select>-->
+    <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.DepartmentVO">
+        select count(*) as customertotal ,
+               sum(case when b.stage_id=15 then 1 else 0 end) as customerDeal,
+               u.department_id as id,d.department_name as departmentName
+        from business_opportunity b
+                 left join user u on b.incharger_id=u.id
+                 left join department d on d.department_id=u.department_id
+        <where>
+            1=1 AND u.department_id IS NOT NULL and b.company_id=#{companyId}
+
+            <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
+                AND  b.create_time BETWEEN #{startDate} AND #{endDate}
+            </if>
+            <if test="departmentId !=null ">
+                AND  u.department_id=#{departmentId}
+            </if>
+        </where>
+        group by u.department_id
     </select>
     <select id="getCustomerTransferRate" resultType="com.management.platform.entity.vo.DepartmentVO">
         select count(distinct c.id) as num, count(distinct s.custom_id) as saleNum,

+ 20 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/resources/mapper/UserMapper.xml

@@ -277,7 +277,7 @@
         AND (induction_date &lt;= #{startDate} OR induction_date is NULL)
         AND id not IN (SELECT * from user_exclude)
     </select>
-    <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.UserVO">
+   <!-- <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.UserVO">
 
         select count(*) as customertotal ,
                sum(case when c.close_deal=1 then 1 else 0 end) as customerDeal ,
@@ -297,7 +297,26 @@
         </where>
             group by c.incharger_id
 
+    </select>-->
+    <select id="getCustomerTotalCount" resultType="com.management.platform.entity.vo.UserVO">
+        SELECT count(*) customertotal ,
+        sum(case when b.stage_id=15 then 1 else 0 end) as customerDeal,
+        b.incharger_id id,u.name
+        from business_opportunity b
+        left join user u on b.incharger_id=u.id
+        <where>
+            1=1 and b.incharger_id is not null and b.company_id=#{companyId}
+
+            <if test="startDate !=null and startDate !='' and endDate !=null and endDate !=''">
+                AND  b.create_time BETWEEN #{startDate} AND #{endDate}
+            </if>
+            <if test="userId !=null and userId!=''">
+                AND  b.incharger_id=#{userId}
+            </if>
+        </where>
+        GROUP BY b.incharger_id
     </select>
+
     <select id="getCustomerTransferRate" resultType="com.management.platform.entity.vo.UserVO">
         select count(distinct c.id) as num, count(distinct s.custom_id) as saleNum, c.incharger_id as id  ,u.name
         from  custom c