Forráskód Böngészése

总后台app会员统计修改

wangxy 4 hete
szülő
commit
50946f88e7

+ 1 - 1
fs-service/src/main/java/com/fs/his/mapper/FsPackageOrderMapper.java

@@ -98,7 +98,7 @@ public interface FsPackageOrderMapper
             "            <if test=\"maps.userPhone != null and maps.userPhone != '' \"> and fso.user_phone = #{maps.userPhone}</if>\n" +
             "            <if test=\"maps.status != null \"> and o.status = #{maps.status}</if>\n" +
             "            <if test=\"maps.source != null \"> and o.source = #{maps.source}</if>\n" +
-            "            <if test=\"maps.sTime != null \">  and DATE(o.start_time) &gt;= DATE(#maps.sTime})</if>\n" +
+            "            <if test=\"maps.sTime != null \">  and DATE(o.start_time) &gt;= DATE(#{maps.sTime})</if>\n" +
             "            <if test=\"maps.eTime != null \">  and DATE(o.start_time) &lt;= DATE(#{maps.eTime})</if>\n" +
             "            <if test=\"maps.stTime != null \">  and DATE(o.create_time) &gt;= DATE(#{maps.stTime})</if>\n" +
             "            <if test=\"maps.endTime != null \">  and DATE(o.create_time) &lt;= DATE(#{maps.endTime})</if>\n" +

+ 14 - 10
fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java

@@ -90,15 +90,15 @@ public interface FsUserMapper
     List<FsUser> findDuplicatePhonesWithCount();
 
     /**
-     * 查询 APP 总用户数(app_create_time 不为空的用户)
+     * 查询 APP 总用户数(source、login_device、app_create_time 任一不为空的用户)
      * @return APP 总用户数
      */
-    @Select("SELECT COUNT(DISTINCT c.company_id, ucu.user_id, ucu.company_user_id) " +
+    @Select("SELECT COUNT(DISTINCT u.user_id) " +
             "FROM fs_user_company_user ucu " +
             "INNER JOIN fs_user u ON ucu.user_id = u.user_id " +
             "INNER JOIN company c ON ucu.company_id = c.company_id " +
-            "WHERE u.app_create_time IS NOT NULL " +
-            "  AND u.status = 1 " +
+            "WHERE ((u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL) " +
+            "  AND u.status = 1 " +"AND u.is_del=0 "+
             "  AND ucu.status IN (0, 1)")
     Long selectAppUserCount();
 
@@ -106,12 +106,13 @@ public interface FsUserMapper
      * 查询今日新增 APP 用户数
      * @return 今日新增 APP 用户数
      */
-    @Select("SELECT COUNT(DISTINCT c.company_id, ucu.user_id, ucu.company_user_id) " +
+    @Select("SELECT COUNT(DISTINCT u.user_id) " +
             "FROM fs_user_company_user ucu " +
             "INNER JOIN fs_user u ON ucu.user_id = u.user_id " +
             "INNER JOIN company c ON ucu.company_id = c.company_id " +
-            "WHERE u.app_create_time IS NOT NULL " +
+            "WHERE ((u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL) " +
             "  AND u.status = 1 " +
+            "  AND u.is_del=0"+
             "  AND ucu.status IN (0, 1) " +
             "  AND u.app_create_time >= CURDATE() " +
             "  AND u.app_create_time < DATE_ADD(CURDATE(), INTERVAL 1 DAY)")
@@ -574,16 +575,18 @@ public interface FsUserMapper
      * @return APP 会员列表
      */
     @Select({"<script> " +
-            "SELECT DISTINCT " +
+            "SELECT " +
             "    c.company_id, " +
             "    c.company_name, " +
-            "    ucu.user_id, " +
-            "    ucu.company_user_id " +
+            "    ucu.user_id " +
             "FROM fs_user_company_user ucu " +
             "INNER JOIN fs_user u ON ucu.user_id = u.user_id " +
             "INNER JOIN company c ON ucu.company_id = c.company_id " +
-            "WHERE u.app_create_time IS NOT NULL " +
+            "WHERE ((u.source IS NOT NULL AND u.source != '') " +
+            "       OR (u.login_device IS NOT NULL AND u.login_device != '') " +
+            "       OR u.app_create_time IS NOT NULL) " +
             "  AND u.status = 1 " +
+            "  AND u.is_del = 0 " +
             "  AND ucu.status IN (0, 1) " +
             "<if test=\"param.companyId != null\"> " +
             "  AND c.company_id = #{param.companyId} " +
@@ -591,6 +594,7 @@ public interface FsUserMapper
             "<if test=\"param.startDate != null and param.startDate != '' and param.endDate != null and param.endDate != ''\"> " +
             "  AND u.app_create_time &gt;= #{param.startDate} AND u.app_create_time &lt; CONCAT(#{param.endDate}, ' 23:59:59') " +
             "</if> " +
+            "GROUP BY ucu.user_id " +
             "</script>"})
     List<AppUserCompanyDTO> selectAppUserListForActiveCount(@Param("param")FsCourseWatchLogStatisticsListParam param);
 

+ 27 - 24
fs-service/src/main/resources/mapper/course/FsCourseWatchLogMapper.xml

@@ -1280,7 +1280,7 @@ FROM
         COUNT(DISTINCT log.log_id)-COUNT(DISTINCT log.user_id) AS notWatchedCount,
         COUNT(DISTINCT log.log_id) - COUNT(DISTINCT a.watch_log_id) AS notAnsweredCount,
         COALESCE(SUM(rp.amount), 0) AS redPacketAmount,
-        COUNT(DISTINCT rp.log_id) AS redPacketCount
+        COUNT(rp.log_id) AS redPacketCount
         FROM
         fs_course_watch_log log
         <if test="orderSTime != null and orderETime != null">
@@ -1837,7 +1837,7 @@ FROM
             COUNT(DISTINCT log.user_id) - COUNT(DISTINCT CASE WHEN log.log_type = '2' THEN log.user_id END) AS notWatchedCount,
             COUNT(DISTINCT log.log_id) - COUNT(DISTINCT a.watch_log_id) AS notAnsweredCount,
             COALESCE(SUM(rp.amount), 0) AS redPacketAmount,
-            COUNT(DISTINCT rp.log_id) AS redPacketCount
+            COUNT(rp.log_id) AS redPacketCount
         FROM fs_course_watch_log log
         LEFT JOIN company_user cu ON log.company_user_id = cu.user_id
         LEFT JOIN fs_user u ON log.user_id = u.user_id
@@ -2193,21 +2193,22 @@ FROM
     <select id="selectAppSalesUserStats" resultType="com.fs.his.vo.AppSalesWatchLogReportVO">
         SELECT
             cu.user_id AS salesId,
-            COUNT(DISTINCT CASE WHEN u.app_create_time IS NOT NULL THEN u.user_id END) AS appUserCount,
-            <choose>
-                <when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
-                    COUNT(DISTINCT CASE WHEN u.app_create_time IS NOT NULL AND u.app_create_time &gt;= #{startDate} AND u.app_create_time &lt; CONCAT(#{endDate}, ' 23:59:59') THEN u.user_id END)
-                </when>
-                <otherwise>
-                    COUNT(DISTINCT CASE WHEN u.app_create_time IS NOT NULL THEN u.user_id END)
-                </otherwise>
-            </choose> AS newAppUserCount
+        COUNT(DISTINCT CASE WHEN (u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL THEN u.user_id END) AS appUserCount,
+        <choose>
+            <when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
+                COUNT(DISTINCT CASE WHEN ((u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL) AND u.app_create_time &gt;= #{startDate} AND u.app_create_time &lt; CONCAT(#{endDate}, ' 23:59:59') THEN u.user_id END)
+            </when>
+            <otherwise>
+                COUNT(DISTINCT CASE WHEN (u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL THEN u.user_id END)
+            </otherwise>
+        </choose> AS newAppUserCount
         FROM fs_user u
         INNER JOIN fs_user_company_user cuu ON cuu.user_id = u.user_id
         INNER JOIN company_user cu ON cuu.company_user_id = cu.user_id
         INNER JOIN company c ON cuu.company_id = c.company_id
-        WHERE u.app_create_time IS NOT NULL
+        WHERE ((u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL)
           AND u.status = 1
+          AND u.is_del=0
           AND cuu.status IN (0, 1)
         <if test="companyId != null and companyId != ''">
             AND cuu.company_id = #{companyId}
@@ -2289,23 +2290,25 @@ FROM
     <!-- 销售部门维度APP会员数统计 -->
     <select id="selectAppDeptUserStats" resultType="com.fs.his.vo.AppSalesWatchLogReportVO">
         SELECT
-            cd.dept_id AS deptId,
-            COUNT(DISTINCT CASE WHEN u.app_create_time IS NOT NULL THEN u.user_id END) AS appUserCount,
-            <choose>
-                <when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
-                    COUNT(DISTINCT CASE WHEN u.app_create_time IS NOT NULL AND u.app_create_time &gt;= #{startDate} AND u.app_create_time &lt; CONCAT(#{endDate}, ' 23:59:59') THEN u.user_id END)
-                </when>
-                <otherwise>
-                    COUNT(DISTINCT CASE WHEN u.app_create_time IS NOT NULL THEN u.user_id END)
-                </otherwise>
-            </choose> AS newAppUserCount,
-            COUNT(DISTINCT cu.user_id) AS salesCount
+        cd.dept_id AS deptId,
+        COUNT(DISTINCT CASE WHEN (u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL THEN u.user_id END) AS appUserCount,
+        <choose>
+            <when test="startDate != null and startDate != '' and endDate != null and endDate != ''">
+                COUNT(DISTINCT CASE WHEN ((u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL) AND u.app_create_time &gt;= #{startDate} AND u.app_create_time &lt; CONCAT(#{endDate}, ' 23:59:59') THEN u.user_id END)
+            </when>
+            <otherwise>
+                COUNT(DISTINCT CASE WHEN (u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL THEN u.user_id END)
+            </otherwise>
+        </choose> AS newAppUserCount,
+        COUNT(DISTINCT cu.user_id) AS salesCount
         FROM fs_user u
         INNER JOIN fs_user_company_user cuu ON cuu.user_id = u.user_id
         INNER JOIN company_user cu ON cuu.company_user_id = cu.user_id
         INNER JOIN company c ON cuu.company_id = c.company_id
         INNER JOIN company_dept cd ON cu.dept_id = cd.dept_id
-        WHERE u.app_create_time IS NOT NULL
+        WHERE ((u.source IS NOT NULL AND u.source != '') OR (u.login_device IS NOT NULL AND u.login_device != '') OR u.app_create_time IS NOT NULL)
+        AND u.status = 1
+        and u.is_del=0
           AND u.status = 1
           AND cuu.status IN (0, 1)
         <if test="companyId != null and companyId != ''">