Browse Source

企微聊天-聊天会话根据待处理数量排序(倒叙)

Long 3 weeks ago
parent
commit
01d949dd69
1 changed files with 5 additions and 2 deletions
  1. 5 2
      fs-service/src/main/resources/mapper/qw/QwSessionMapper.xml

+ 5 - 2
fs-service/src/main/resources/mapper/qw/QwSessionMapper.xml

@@ -75,10 +75,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             s.last_msg_type                                         as type,
             s.last_content                                          as lastContent,
             s.last_send_time                                        as lastSendTime,
-            0                                                       as unread
+            0                                                       as unread,
+            count(qwt.id)                                           as pendcount
         from qw_session s
         left join qw_external_contact ec on s.qw_ext_id = ec.id
         left join fs_user u on ec.fs_user_id = u.user_id
+        left join qw_work_task qwt on qwt.ext_id = ec.id and qwt.qw_user_id = s.qw_user_id and qwt.status = 0
         where s.qw_user_id = #{params.qwUserId}
         <if test="params.removeBlack != null and params.removeBlack">
             and ec.comment_status = 0
@@ -86,7 +88,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="params.removeRepeat != null and params.removeRepeat">
             and u.qw_repeat != 1 and u.user_repeat != 1
         </if>
-        order by s.update_time desc
+        group by s.session_id
+        order by pendcount desc, s.update_time desc
     </select>
 
     <insert id="insertQwSession" parameterType="QwSession" useGeneratedKeys="true" keyProperty="sessionId">