LiuJ 1 dag sedan
förälder
incheckning
72261edcb7
1 ändrade filer med 30 tillägg och 14 borttagningar
  1. 30 14
      app/JsonRpc/NewsService.php

+ 30 - 14
app/JsonRpc/NewsService.php

@@ -6428,20 +6428,7 @@ class NewsService implements NewsServiceInterface
         ->orderBy('updated_at', 'desc')
         // ->limit(5)
         ->get();
-      //获取5条单聊未读聊天消息
-      $chat = ChatRecords::where('is_read', 0)
-        ->where('user_id', $user_id)
-        ->where('talk_type', 1)
-        ->orderBy('created_at', 'desc')
-        // ->limit(5)
-        ->get();
-      //获取5条未读群聊信息
-      $chat_group = ChatRecords::where('is_read', 0)
-        ->where('user_id', $user_id)
-        ->where('talk_type', 2)
-        ->orderBy('created_at', 'desc')
-        // ->limit(5)
-        ->get();
+
       //获取5条用户的已审核商品
       $good = Good::where('status', 2)
         ->where('user_id', $user_id)
@@ -6522,6 +6509,28 @@ class NewsService implements NewsServiceInterface
         // ->limit(5)
         ->get();
 
+
+      //获取5条单聊未读聊天消息
+      $chat = ChatRecords::where('is_read', 0)
+        ->where('user_id', $user_id)
+        ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
+
+        ->select('chat_records.*', 'user.nickname as nickname', 'user.user_name as user_name')
+        ->where('action', 'recieved')
+        ->where('talk_type', 1)
+        ->orderBy('created_at', 'desc')
+        // ->limit(5)
+        ->get();
+      //获取5条未读群聊信息
+      $chat_group = ChatRecords::where('is_read', 0)
+        ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
+        ->select('chat_records.*', 'chat_groups.group_name as user_name')
+        ->where('user_id', $user_id)
+        ->where('talk_type', 2)
+        ->orderBy('created_at', 'desc')
+        // ->limit(5)
+        ->get();
+
       //获取5条用户的待审核项目 
       $project = Project::where('status', 1)
         ->where('user_id', $user_id)
@@ -6652,14 +6661,21 @@ class NewsService implements NewsServiceInterface
         // ->limit(5)
         ->get();
       //获取5条单聊未读聊天消息
+      //获取5条单聊未读聊天消息
       $chat = ChatRecords::where('is_read', 0)
         ->where('user_id', $user_id)
+        ->leftJoin('user', 'chat_records.receiver_id', '=', 'user.id')
+
+        ->select('chat_records.*', 'user.nickname as nickname', 'user.user_name as user_name')
+        ->where('action', 'recieved')
         ->where('talk_type', 1)
         ->orderBy('created_at', 'desc')
         // ->limit(5)
         ->get();
       //获取5条未读群聊信息
       $chat_group = ChatRecords::where('is_read', 0)
+        ->leftJoin('chat_groups', 'chat_records.receiver_id', '=', 'chat_groups.id')
+        ->select('chat_records.*', 'chat_groups.group_name as user_name')
         ->where('user_id', $user_id)
         ->where('talk_type', 2)
         ->orderBy('created_at', 'desc')