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']; +}