AI 3 달 전
부모
커밋
b2af3472d3
1개의 변경된 파일25개의 추가작업 그리고 1개의 파일을 삭제
  1. 25 1
      app/JsonRpc/ChatService.php

+ 25 - 1
app/JsonRpc/ChatService.php

@@ -182,8 +182,32 @@ class ChatService implements ChatServiceInterface
                             'status' => $status,
                         ]
                     );
-                Db::commit();
 
+                // 给对方发送通知
+                $friendId = $fr['user_id'];
+                $userId = $fr['friend_id'];
+                $content = "你们已经成为好友了" . date("Y-m-d H:i:s");
+                $chatRecordsData = [[
+                    'user_id' => $userId,
+                    'receiver_id' => $friendId,
+                    'content' => $content,
+                    'msg_type' => 1,
+                    'is_read' => 1,
+                    'talk_type' => 1,
+                    'action' => 'said',
+
+                ], [
+                    'user_id' => $friendId,
+                    'receiver_id' => $userId,
+                    'content' => $content,
+                    'msg_type' => 1,
+                    'is_read' => 1,
+                    'talk_type' => 1,
+                    'action' => 'recieved',
+
+                ]];
+                ChatRecords::insert($chatRecordsData);
+                Db::commit();
             } catch (\Throwable $ex) {
                 Db::rollBack();
                 var_dump($ex->getMessage());