瀏覽代碼

答题人数,红包信息统计

yfh 1 周之前
父節點
當前提交
58c35efc70
共有 1 個文件被更改,包括 24 次插入10 次删除
  1. 24 10
      fs-service-system/src/main/resources/mapper/store/FsUserMapper.xml

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

@@ -806,10 +806,12 @@
         SELECT
         (
                 SELECT
-                ifnull(count( DISTINCT log_id ), 0) AS answerTime
+                ifnull(count( DISTINCT fs_course_answer_logs.log_id ), 0) AS answerTime
                 FROM
                     fs_course_answer_logs
                         LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
+        left join fs_course_watch_log fcwl on fs_course_answer_logs.watch_log_id =fcwl.log_id
+        left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
                 <where>
 
                     <if test="dateTag != null and dateTag !='' ">
@@ -828,17 +830,19 @@
                             </when>
                         </choose>
                     </if>
-                and fs_user.user_id = #{fsUserId}
+                and fs_user.user_id = #{fsUserId} and fucu.company_user_id =#{userId}
                 </where>
                 GROUP BY
                     fs_user.user_id
             ) AS answerTime,
             (
                 SELECT
-                ifnull(count( DISTINCT log_id ), 0) AS answerRightTime
+                ifnull(count( DISTINCT fs_course_answer_logs.log_id ), 0) AS answerRightTime
                 FROM
                     fs_course_answer_logs
                         LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
+        left join fs_course_watch_log fcwl on fs_course_answer_logs.watch_log_id =fcwl.log_id
+        left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
             <where>
                 fs_course_answer_logs.is_right = 1
                 <if test="dateTag != null and dateTag !='' ">
@@ -857,7 +861,7 @@
                         </when>
                     </choose>
                 </if>
-                and fs_user.user_id = #{fsUserId}
+                and fs_user.user_id = #{fsUserId} and fucu.company_user_id =#{userId}
             </where>
                 GROUP BY
                     fs_user.user_id
@@ -866,12 +870,14 @@
 
     <select id="getCountRedPacket" resultType="com.fs.store.vo.h5.UserDetailsVO">
         SELECT
-        ifnull( count( DISTINCT log_id ), 0 ) AS answerRedPacketTime,
+        ifnull( count( DISTINCT fs_course_red_packet_log.log_id ), 0 ) AS answerRedPacketTime,
         ifnull( sum( amount ), 0 ) AS answerRedPacketAmount,
         fs_user.user_id
         FROM
             fs_course_red_packet_log
                 LEFT JOIN fs_user ON fs_user.user_id = fs_course_red_packet_log.user_id
+        left join fs_course_watch_log fcwl on fs_course_red_packet_log.watch_log_id =fcwl.log_id
+        left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
         <where>
         fs_course_red_packet_log.status = 1
         <if test="dateTag != null and dateTag !='' ">
@@ -890,7 +896,7 @@
                     </when>
                 </choose>
             </if>
-            and  fs_user.user_id = #{fsUserId}
+            and  fs_user.user_id = #{fsUserId} and fucu.company_user_id =#{userId}
         </where>
         GROUP BY
         fs_user.user_id
@@ -1046,9 +1052,11 @@
         fs_course_answer_logs
         LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
         LEFT JOIN company_user ON company_user.user_id = fs_course_answer_logs.company_user_id
+        left join fs_course_watch_log fcwl on fs_course_answer_logs.watch_log_id=fcwl.log_id
+        left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
         <where>
         <if test="userId != null and userId != 0 ">
-            and (fs_course_answer_logs.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
+            and (fucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
         </if>
         <if test="userId != null and userId == 0 ">
             and fs_course_answer_logs.company_id = #{companyId}
@@ -1078,9 +1086,11 @@
         fs_course_answer_logs
         LEFT JOIN fs_user ON fs_user.user_id = fs_course_answer_logs.user_id
         LEFT JOIN company_user ON company_user.user_id = fs_course_answer_logs.company_user_id
+        left join fs_course_watch_log fcwl on fs_course_answer_logs.watch_log_id=fcwl.log_id
+        left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
         <where>
         <if test="userId != null and userId != 0 ">
-            and (fs_course_answer_logs.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
+            and (fucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
         </if>
         <if test="userId != null and userId == 0 ">
             and fs_course_answer_logs.company_id = #{companyId}
@@ -1115,9 +1125,11 @@
                 fs_course_red_packet_log flog
                     LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
                     LEFT JOIN company_user ON company_user.user_id = flog.company_user_id
+        left join fs_course_watch_log fcwl on flog.watch_log_id =fcwl.log_id
+        left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
                 <where>
                 <if test="userId != null and userId != 0 ">
-                    and (flog.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
+                    and (fucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
                 </if>
                 <if test="userId != null and userId == 0 ">
                     and flog.company_id = #{companyId}
@@ -1147,9 +1159,11 @@
                 fs_course_red_packet_log flog
                     LEFT JOIN fs_user ON fs_user.user_id = flog.user_id
                     LEFT JOIN company_user ON company_user.user_id = flog.company_user_id
+        left join fs_course_watch_log fcwl on flog.watch_log_id =fcwl.log_id
+        left join fs_user_company_user fucu on fucu.user_id =fs_user.user_id and fcwl.project = fucu.project_id
                 <where>
                 <if test="userId != null and userId != 0 ">
-                    and (flog.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
+                    and (fucu.company_user_id = #{userId} OR company_user.parent_id = #{userId} )
                 </if>
                 <if test="userId != null and userId == 0 ">
                     and flog.company_id = #{companyId}