Selaa lähdekoodia

销售端app课程统计数据为空

luolinsong 2 viikkoa sitten
vanhempi
commit
25913cd586

+ 1 - 6
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -931,12 +931,7 @@ public class FsUserServiceImpl implements IFsUserService {
     @Override
     public FsUserStatisticsVO userStatisticsDetails(UserStatisticsCommonParam param) {
         FsUserStatisticsVO userStatisticsVO = getUserStatistics(param);
-
-        // 判断是否是管理员
-        CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getUserId());
-        if (companyUser != null && companyUser.isAdmin()) {
-            param.setUserId(0L);
-        }
+        
         //统计课程数据详情,在查询统计详情的时候需要显示
         Map<String, Long> courseDetailsMap = fsUserMapper.countCourseDetailsNew(param);
         if (courseDetailsMap != null && courseDetailsMap.get("courseNum") != null && courseDetailsMap.get("videoNum") != null && courseDetailsMap.get("courseUserNum") != null) {

+ 100 - 1
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -1818,7 +1818,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="userId != null and userId != 0 ">
             AND l.company_user_id = #{userId}
         </if>
-        <if test="userId != null and userId == 0 ">
+        <if test="companyId != null and companyId == 0 ">
             and l.company_id = #{companyId}
         </if>
         <if test="periodId != null and periodId != ''">
@@ -2200,5 +2200,104 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND log.create_time &lt;= #{endTime}
         </if>
     </select>
+   <!-- 查询观看和完成人数 -->
+    <select id="countUserWatchStats" resultType="Map">
+        SELECT
+        COUNT(DISTINCT CASE WHEN l.log_type != 3 AND l.send_type = 1 THEN l.user_id END) AS courseWatchNum,
+        COUNT(DISTINCT CASE WHEN l.log_type = 2 AND l.send_type = 1 THEN l.user_id END) AS courseCompleteNum
+        FROM  fs_course_watch_log l
+        LEFT JOIN fs_user u  ON u.user_id = l.user_id
+        LEFT JOIN company_user cu_l ON l.company_user_id = cu_l.user_id
+        <where>
+            <if test="userId != null and userId != 0">
+                AND (cu_l.user_id = #{userId} OR cu_l.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>
+            <if test="companyUserId != null and companyUserId != ''">
+                AND l.company_user_id = #{companyUserId}
+            </if>
+        </where>
+    </select>
+
+    <!-- 查询答题人数和答对人数 -->
+    <select id="countUserAnswerStats" resultType="Map">
+        SELECT
+        COUNT(DISTINCT CASE WHEN a.user_id THEN a.user_id END) AS answerNum,
+        COUNT(DISTINCT CASE WHEN a.is_right = 1 THEN a.user_id END) AS answerRightNum
+        FROM  fs_course_answer_logs a
+        LEFT JOIN fs_user u  ON u.user_id = a.user_id
+        LEFT JOIN company_user cu_a ON a.company_user_id = cu_a.user_id
+        <where>
+            <if test="userId != null and userId != 0">
+                AND (cu_a.user_id = #{userId} OR cu_a.parent_id = #{userId})
+            </if>
+            <if test="userId != null and userId == 0">
+                AND a.company_id = #{companyId}
+            </if>
+            <if test="periodId != null and periodId != ''">
+                AND a.period_id = #{periodId}
+            </if>
+            <if test="videoId != null and videoId != ''">
+                AND a.video_id = #{videoId}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                AND a.create_time &gt;= #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                AND a.create_time &lt;= #{endTime}
+            </if>
+            <if test="companyUserId != null and companyUserId != ''">
+                AND a.company_user_id = #{companyUserId}
+            </if>
+        </where>
+    </select>
+
+    <!-- 查询红包数量和红包金额 -->
+    <select id="countUserRedPacketStats" resultType="Map">
+        SELECT
+        COUNT(CASE WHEN flog.status = 1 THEN flog.log_id END) AS redPacketNum,
+        IFNULL(SUM(CASE WHEN flog.status = 1 THEN flog.amount END), 0) AS redPacketAmount
+        FROM  fs_course_red_packet_log flog
+        LEFT JOIN fs_user u  ON u.user_id = flog.user_id
+        LEFT JOIN company_user cu_flog ON flog.company_user_id = cu_flog.user_id
+        <where>
+            <if test="userId != null and userId != 0">
+                AND (cu_flog.user_id = #{userId} OR cu_flog.parent_id = #{userId})
+            </if>
+            <if test="userId != null and userId == 0">
+                AND flog.company_id = #{companyId}
+            </if>
+            <if test="periodId != null and periodId != ''">
+                AND flog.period_id = #{periodId}
+            </if>
+            <if test="videoId != null and videoId != ''">
+                AND flog.video_id = #{videoId}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                AND flog.create_time &gt;= #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                AND flog.create_time &lt;= #{endTime}
+            </if>
+            <if test="companyUserId != null and companyUserId != ''">
+                AND flog.company_user_id = #{companyUserId}
+            </if>
+        </where>
+    </select>
+
 
 </mapper>