diff --git a/packages/bydauto/src/Commands/BYDAutoCommand.php b/packages/bydauto/src/Commands/BYDAutoCommand.php
index 4e7b7dd..2b725bd 100644
--- a/packages/bydauto/src/Commands/BYDAutoCommand.php
+++ b/packages/bydauto/src/Commands/BYDAutoCommand.php
@@ -96,8 +96,9 @@ public function action_push2contact()
// 开始发送
foreach ($sendList as $contactId => $items) {
- $contact = $contacts->find($contactId);
+ $contact = $contacts->firstWhere('id', $contactId);
$this->info("发送试驾数据给联系人 {$contact->id} 总数 " . count($items));
+ $contact->notify(new TestdirveNotification($items));
}
return Command::SUCCESS;
}
diff --git a/packages/bydauto/src/Notifications/TestdirveNotification.php b/packages/bydauto/src/Notifications/TestdirveNotification.php
index 95610e2..c3b1d61 100644
--- a/packages/bydauto/src/Notifications/TestdirveNotification.php
+++ b/packages/bydauto/src/Notifications/TestdirveNotification.php
@@ -2,7 +2,6 @@
namespace BYDAuto\Notifications;
-use BYDAuto\Models\Testdrive;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
@@ -12,7 +11,7 @@ class TestdirveNotification extends Notification
{
use Queueable;
- public function __construct(protected Testdrive $model) {}
+ public function __construct(protected $items) {}
public function via(object $notifiable): array
{
@@ -21,19 +20,26 @@ public function via(object $notifiable): array
public function toMail(object $notifiable): MailMessage
{
- $text = sprintf("姓名:%s
电话:%s", $this->model->name, $this->model->mobile, $this->model->mobile);
- $text = new HtmlString($text);
+ $table = new HtmlString(view('bydauto::mail.testdrive', ['items' => $this->items])->render());
return (new MailMessage())
->subject("预约试驾线索通知")
- ->line("收到一条新的试驾预约信息")
- ->line($text)
+ ->line("收到新的试驾预约信息:")
+ ->line($table)
->line("=====")
->salutation("祝,工作愉快!");
+
+ // $text = sprintf("姓名:%s
电话:%s", $this->model->name, $this->model->mobile, $this->model->mobile);
+ // $text = new HtmlString($text);
+ // return (new MailMessage())
+ // ->subject("预约试驾线索通知")
+ // ->line("收到一条新的试驾预约信息")
+ // ->line($text)
+ // ->line("=====")
+ // ->salutation("祝,工作愉快!");
}
public function toArray(object $notifiable): array
{
- return [
- ];
+ return [];
}
}
diff --git a/packages/bydauto/views/notice/salesleads-day.blade.php b/packages/bydauto/views/mail/salesleads-day.blade.php
similarity index 100%
rename from packages/bydauto/views/notice/salesleads-day.blade.php
rename to packages/bydauto/views/mail/salesleads-day.blade.php
diff --git a/packages/bydauto/views/notice/salesleads.blade.php b/packages/bydauto/views/mail/salesleads.blade.php
similarity index 100%
rename from packages/bydauto/views/notice/salesleads.blade.php
rename to packages/bydauto/views/mail/salesleads.blade.php
diff --git a/packages/bydauto/views/mail/testdrive.blade.php b/packages/bydauto/views/mail/testdrive.blade.php
new file mode 100644
index 0000000..b3585d4
--- /dev/null
+++ b/packages/bydauto/views/mail/testdrive.blade.php
@@ -0,0 +1,12 @@
+
姓名 | +电话 | +
---|---|
{{ $item->name }} | +{{ $item->mobile }} | +