From c7142efa99773afda10417e2ff8ba13d5c5d72cf Mon Sep 17 00:00:00 2001 From: lkddi Date: Thu, 2 Apr 2026 16:46:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E5=A5=BD=E5=8F=8B=E4=B8=8A=E7=BA=BF=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=94=B1=E4=BA=8E=E5=A5=BD=E5=8F=8B=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E5=AF=BC=E8=87=B4=E7=9A=84=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WechatBot/WechatNotificationService.php | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/Services/WechatBot/WechatNotificationService.php b/app/Services/WechatBot/WechatNotificationService.php index 9d5cf8a..644708a 100644 --- a/app/Services/WechatBot/WechatNotificationService.php +++ b/app/Services/WechatBot/WechatNotificationService.php @@ -227,17 +227,23 @@ class WechatNotificationService protected function getUserFriends(int $userId) { - // 假定有好友表 - if (\Illuminate\Support\Facades\Schema::hasTable('friends')) { - return \Illuminate\Support\Facades\DB::table('friends') - ->join('users', 'users.id', '=', 'friends.friend_id') - ->where('friends.user_id', $userId) - ->whereNotNull('users.wxid') - ->select('users.*') - ->get(); + $user = User::find($userId); + if (! $user) { + return collect([]); } - return collect([]); + // 谁把当前用户加为了好友(当前用户是 towho),谁就应该收到上线通知 + $watcherNames = \App\Models\FriendRequest::where('towho', $user->username) + ->pluck('who'); + + if ($watcherNames->isEmpty()) { + return collect([]); + } + + return User::whereIn('username', $watcherNames) + ->whereNotNull('wxid') + ->where('wxid', '!=', '') + ->get(); } protected function getUserSpouse(User $user)