From cea3a140930b58eb43df96b1dc245f33489dd130 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 19 Jun 2025 14:47:24 +0800 Subject: [PATCH] update --- app/Console/Commands/CheckBirthday.php | 55 +++++++++++++++++++ app/Console/Commands/SendNotification.php | 7 +++ app/Console/Kernel.php | 5 +- .../Controllers/Mobile/UserController.php | 7 ++- app/Notifications/BirthdayNotify.php | 48 ++++++++++++++++ 5 files changed, 119 insertions(+), 3 deletions(-) create mode 100755 app/Console/Commands/CheckBirthday.php create mode 100755 app/Notifications/BirthdayNotify.php diff --git a/app/Console/Commands/CheckBirthday.php b/app/Console/Commands/CheckBirthday.php new file mode 100755 index 0000000..0553373 --- /dev/null +++ b/app/Console/Commands/CheckBirthday.php @@ -0,0 +1,55 @@ +get(); + foreach ($users as $user) { + Notification::send($user, new BirthdayNotify(['user_id' => $user->id])); + } + return $this->info('更新完成'); + } + + +} diff --git a/app/Console/Commands/SendNotification.php b/app/Console/Commands/SendNotification.php index 9b2bef6..c9c1a71 100755 --- a/app/Console/Commands/SendNotification.php +++ b/app/Console/Commands/SendNotification.php @@ -9,6 +9,7 @@ use App\Models\Config; use App\Models\Course; use App\Models\CourseSign; use App\Models\Notifications; +use App\Models\User; use EasyWeChat\Factory; use Illuminate\Console\Command; use Illuminate\Support\Facades\DB; @@ -237,6 +238,12 @@ class SendNotification extends Command $content = "{$smsSign}亲爱的同学:最新课表已发布,您可在STBC小程序“我的”-“我的课程”-“本班课表”中查看。"; $this->smsNotice($vo, $content); break; + case "App\Notifications\BirthdayNotify": + // 排课通知 + $user = User::find($data['user_id']); + $content = "{$smsSign}亲爱的同学:祝您生日快乐!"; + $this->smsNotice($vo, $content); + break; } return $this->info('发送完成'); } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index e1ee408..8c11076 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -18,9 +18,10 @@ class Kernel extends ConsoleKernel $schedule->command("sms:notification")->everyMinute(); $schedule->command('update_sign_status')->everyMinute(); $schedule->command('update_letter')->everyMinute(); - // $schedule->command('update_appointment')->everyMinute(); + // $schedule->command('update_appointment')->everyMinute(); $schedule->command('update_appointment_total')->dailyAt('1:00'); - + // 生日检测 + $schedule->command('check_birthday')->dailyAt('09:00'); } /** diff --git a/app/Http/Controllers/Mobile/UserController.php b/app/Http/Controllers/Mobile/UserController.php index 56d89da..0efb971 100755 --- a/app/Http/Controllers/Mobile/UserController.php +++ b/app/Http/Controllers/Mobile/UserController.php @@ -246,7 +246,12 @@ class UserController extends CommonController $enter_schoolmate = User::whereHas('courseSigns', function ($query) { $query->where('fee_status', 1)->where('status', 1); })->where('id', $this->getUserId())->count(); - return $this->success(compact('user', 'door_appointments', 'course_signs', 'enter_schoolmate')); + // 是否生日 + $is_birthday = 0; + if ($user->birthday == date('Y-m-d')) { + $is_birthday = 1; + } + return $this->success(compact('user', 'door_appointments', 'course_signs', 'enter_schoolmate', 'is_birthday')); } /** diff --git a/app/Notifications/BirthdayNotify.php b/app/Notifications/BirthdayNotify.php new file mode 100755 index 0000000..7dba6e7 --- /dev/null +++ b/app/Notifications/BirthdayNotify.php @@ -0,0 +1,48 @@ +data = $data; + } + + /** + * Get the notification's delivery channels. + * + * @param mixed $notifiable + * @return array + */ + public function via($notifiable) + { + return ['database']; + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return $this->data; + } +}