AI 3 months ago
parent
commit
ab6b20b773
1 changed files with 6 additions and 6 deletions
  1. 6 6
      app/JsonRpc/ChatService.php

+ 6 - 6
app/JsonRpc/ChatService.php

@@ -313,7 +313,7 @@ class ChatService implements ChatServiceInterface
         $userId = $data['user_id'];
         $unreadMessages = ChatRecords::where('user_id', $userId)
             ->where('is_read', 0)
-            ->where('action', 'recieved')
+        // ->where('action', 'recieved')
             ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
             ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
             ->select(
@@ -332,7 +332,7 @@ class ChatService implements ChatServiceInterface
         // 查询已读消息,并将 num 字段设置为 0
         $readMessages = ChatRecords::where('user_id', $userId)
             ->where('is_read', 1)
-            ->where('action', 'recieved')
+        // ->where('action', 'recieved')
             ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
             ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
             ->select(
@@ -358,13 +358,13 @@ class ChatService implements ChatServiceInterface
 
         foreach ($readMessages as $message) {
             if (strlen($message['receiver_id']) === 18) {
-                if (!isset($allMessages[$message['receiver_id']])) {
-                    $allMessages[$message['receiver_id']] = $message->toArray();
-                }
+
             } else {
+                // $allMessages[$message['receiver_id']] = $message->toArray();
+            }
+            if (!isset($allMessages[$message['receiver_id']])) {
                 $allMessages[$message['receiver_id']] = $message->toArray();
             }
-
         }
 
         // var_dump($allMessages);