浏览代码

重粉逻辑bug以及sql查询优化

xw 1 天之前
父节点
当前提交
9b99d7f940
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      fs-service/src/main/resources/mapper/course/FsUserCompanyBindMapper.xml

+ 19 - 0
fs-service/src/main/resources/mapper/course/FsUserCompanyBindMapper.xml

@@ -128,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </foreach>
     </delete>
 
+    <!-- 重粉看课:仅展示同一粉丝在同一项目下、由至少两个不同企微员工产生过绑定/看课记录的数据 -->
     <select id="getWatchLogList" resultType="com.fs.course.vo.UserWatchLogListVo">
         select
         a.*,
@@ -139,6 +140,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         qc.corp_name
         from
         fs_user_company_bind a
+        inner join (
+            select fs_user_id, project_id
+            from fs_user_company_bind
+            where project_id is not null
+              and qw_user_id is not null
+            <if test="fsUserId != null">
+              and fs_user_id = #{fsUserId}
+            </if>
+            <if test="fsUserId == null and externalUserId != null">
+              and fs_user_id in (
+                select u.fs_user_id from fs_user_company_bind u
+                where u.qw_external_contact_id = #{externalUserId}
+                  and u.fs_user_id is not null
+              )
+            </if>
+            group by fs_user_id, project_id
+            having count(distinct qw_user_id) &gt;= 2
+        ) dup_proj on dup_proj.fs_user_id = a.fs_user_id and dup_proj.project_id = a.project_id
         left join fs_user b on a.fs_user_id = b.user_id
         left join sys_dict_data c on c.dict_type = 'sys_course_project' and dict_value = a.project_id
         left join fs_user_course e on a.course_id = e.course_id