From 2b59b0ec7e4c0ae7617dd5a1bcc8faf8a14fe456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E6=9C=9D=E4=BC=9F?= Date: Thu, 14 Nov 2024 10:33:57 +0800 Subject: [PATCH] init --- .../bydauto/src/Jobs/TestdrivePushJob.php | 11 ++++++++- packages/bydauto/src/Models/Activity.php | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 packages/bydauto/src/Models/Activity.php diff --git a/packages/bydauto/src/Jobs/TestdrivePushJob.php b/packages/bydauto/src/Jobs/TestdrivePushJob.php index 1de46b1..38f4ee6 100644 --- a/packages/bydauto/src/Jobs/TestdrivePushJob.php +++ b/packages/bydauto/src/Jobs/TestdrivePushJob.php @@ -2,6 +2,7 @@ namespace BYDAuto\Jobs; +use BYDAuto\Models\Activity; use BYDAuto\Models\Contact; use BYDAuto\Models\Testdrive; use BYDAuto\Notifications\TestdirveNotification; @@ -32,6 +33,14 @@ public function sendNotification() { $message = new TestdirveNotification($this->model); $contacts = Contact::query()->where('status', Contact::STATUS_PUBLISHED)->get(); - $contacts->each(fn(Contact $contact) => $contact->notify($message)); + // $contacts->each(fn(Contact $contact) => $contact->notify($message)); + $contact = $contacts->random(); + $contact->notify($message); + Activity::create([ + 'name' => '试驾通知', + 'content' => ['testdrive' => $this->model->id, 'contact' => $contact->id], + 'related_id' => $this->model->id, + 'related_type' => Testdrive::class, + ]); } } diff --git a/packages/bydauto/src/Models/Activity.php b/packages/bydauto/src/Models/Activity.php new file mode 100644 index 0000000..0a1459d --- /dev/null +++ b/packages/bydauto/src/Models/Activity.php @@ -0,0 +1,23 @@ + 'json']; +}