Browse Source

feat:分别同步代码-看课统计

caoliqin 1 week ago
parent
commit
b988631623

+ 5 - 2
fs-service-system/src/main/java/com/fs/store/mapper/FsUserMapper.java

@@ -243,8 +243,6 @@ public interface FsUserMapper
 
     Map<String, Long> countUserCourse(UserStatisticsCommonParam param);
 
-    Map<String, Long> countUserCourseNew(UserStatisticsCommonParam param);
-
     Map<String, Long> countUserAnswer(UserStatisticsCommonParam param);
 
     Map<String, Object> countUserRedPacket(UserStatisticsCommonParam param);
@@ -311,4 +309,9 @@ public interface FsUserMapper
     List<FsUserWatchCourseStatistics> selectFsUserDetail();
 
     List<FsUser> selectFsUserListByJointUserNameKey(String userNameKey);
+
+    Map<String, Long> countUserCourse2(UserStatisticsCommonParam param);
+
+    Map<String, Long> countCourseDetailsNew(UserStatisticsCommonParam param);
+
 }

+ 2 - 2
fs-service-system/src/main/java/com/fs/store/service/impl/FsUserServiceImpl.java

@@ -735,7 +735,7 @@ public class FsUserServiceImpl implements IFsUserService
             param.setCompanyId(companyUser.getCompanyId());
         }
         // 获取课程统计
-        Map<String, Long> couserMap = fsUserMapper.countUserCourse(param);
+        Map<String, Long> couserMap = fsUserMapper.countUserCourse2(param);
         if (couserMap != null) {
             fsUserStatisticsVO.setCourseWatchNum(couserMap.get("courseWatchNum").intValue()).setCourseCompleteNum(couserMap.get("courseCompleteNum").intValue());
 
@@ -781,7 +781,7 @@ public class FsUserServiceImpl implements IFsUserService
             param.setUserId(0L);
         }
         //统计课程数据详情,在查询统计详情的时候需要显示
-        Map<String, Long> courseDetailsMap = fsUserMapper.countCourseDetails(param);
+        Map<String, Long> courseDetailsMap = fsUserMapper.countCourseDetailsNew(param);
         if(courseDetailsMap != null && courseDetailsMap.get("courseNum") != null && courseDetailsMap.get("videoNum") != null && courseDetailsMap.get("courseUserNum") != null){
             userStatisticsVO.setCourseNum(Integer.parseInt(courseDetailsMap.get("courseNum").toString()))
                     .setVideoNum(Integer.parseInt(courseDetailsMap.get("videoNum").toString()))

+ 0 - 1
fs-service-system/src/main/resources/mapper/store/FsUserCourseCountMapper.xml

@@ -61,7 +61,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             ifnull ( sum( fs_user_course_count.miss_course_count ), 0 ) AS miss_course_count,
             ifnull ( sum( fs_user_course_count.part_course_count ), 0 ) AS part_course_count,
             Max( fs_user_course_count.last_watch_date ) AS last_watch_date,
-            ifnull ( sum( fs_user_course_count.stop_watch_days ), 0 ) AS stop_watch_days,
             Max( fs_user_course_count.complete_watch_date) AS complete_watch_date
             from fs_user_course_count where user_id = ${userId}
     </select>

+ 67 - 24
fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml

@@ -935,10 +935,6 @@
             ) as courseCompleteNum
     </select>
 
-    <select id="countUserCourseNew" resultType="Map">
-
-    </select>
-
     <select id="countUserAnswer" resultType="Map">
         SELECT
         (
@@ -1764,40 +1760,50 @@
             and company_user_id = #{companyUserId}
         </if>
     </select>
+
     <select id="countUserCourse2" resultType="java.util.Map">
         SELECT
         (
         SELECT
-        count(1)
+        count(DISTINCT l.user_id)
         FROM
         fs_course_watch_log l
+        LEFT JOIN fs_user on fs_user.user_id = l.user_id
         LEFT JOIN company_user ON l.company_user_id = company_user.user_id
         where
-            l.log_type != 3 and send_type = 1
-            <if test="userId != null and userId != 0 ">
-                and (l.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
-            </if>
-            <if test="userId != null and userId == 0 ">
-                and l.company_id = #{companyId}
-            </if>
-            <if test="periodId != null and periodId != ''">
-                AND l.period_id = #{periodId}
-            </if>
-            <if test="videoId != null and videoId != ''">
-                AND l.video_id = #{videoId}
-            </if>
-            <if test="companyUserId != null and companyUserId != ''">
-                AND l.user_id = #{companyUserId}
-            </if>
+        l.log_type != 3 and send_type = 1 AND fs_user.is_del = 0 AND fs_user.`status` = 1
+        <if test="userId != null and userId != 0 ">
+            and (l.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
+        </if>
+        <if test="userId != null and userId == 0 ">
+            and l.company_id = #{companyId}
+        </if>
+        <if test="periodId != null and periodId != ''">
+            AND l.period_id = #{periodId}
+        </if>
+        <if test="videoId != null and videoId != ''">
+            AND l.video_id = #{videoId}
+        </if>
+        <if test="startTime != null and startTime !='' ">
+            and l.create_time &gt;= #{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            and l.create_time &lt;= #{endTime}
+        </if>
+        -- 单独通过销售id查询
+        <if test="companyUserId != null and companyUserId != ''">
+            AND l.company_user_id = #{companyUserId}
+        </if>
         ) as courseWatchNum,
         (
         SELECT
-        count(1)
+        count(DISTINCT l.user_id)
         FROM
         fs_course_watch_log l
+        LEFT JOIN fs_user on fs_user.user_id = l.user_id
         LEFT JOIN company_user ON l.company_user_id = company_user.user_id
         where
-        l.log_type = 2 and send_type = 1
+        l.log_type = 2 and send_type = 1 AND fs_user.is_del = 0 AND fs_user.`status` = 1
         <if test="userId != null and userId != 0 ">
             and (l.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
         </if>
@@ -1810,11 +1816,48 @@
         <if test="videoId != null and videoId != ''">
             AND l.video_id = #{videoId}
         </if>
+        <if test="startTime != null and startTime !='' ">
+            and l.create_time &gt;= #{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            and l.create_time &lt;= #{endTime}
+        </if>
         -- 单独通过销售id查询
         <if test="companyUserId != null and companyUserId != ''">
-            AND l.user_id = #{companyUserId}
+            AND l.company_user_id = #{companyUserId}
         </if>
         ) as courseCompleteNum
     </select>
 
+    <select id="countCourseDetailsNew" resultType="Map">
+        SELECT
+        count( DISTINCT l.period_id ) as courseNum,
+        count( DISTINCT l.video_id ) as videoNum,
+        count( DISTINCT l.user_id ) as courseUserNum
+        FROM
+        fs_course_watch_log l
+        left join fs_user on fs_user.user_id = l.user_id
+        LEFT JOIN company_user ON l.company_user_id = company_user.user_id
+        WHERE
+        l.log_type != 3
+        AND send_type = 1
+        AND fs_user.is_del = 0 AND fs_user.`status` = 1
+        <if test="userId != null and userId != 0 ">
+            AND l.company_user_id = #{userId}
+        </if>
+        <if test="userId != null and userId == 0 ">
+            and l.company_id = #{companyId}
+        </if>
+        <if test="periodId != null and periodId != ''">
+            AND l.period_id =  #{periodId}
+        </if>
+        <if test="videoId != null and videoId != ''">
+            AND l.video_id = #{videoId}
+        </if>
+        -- 单独通过销售id查询
+        <if test="companyUserId != null and companyUserId != ''">
+            AND l.company_user_id = #{companyUserId}
+        </if>
+    </select>
+
 </mapper>