0
0
Files
Babyclass/app/Notifications/OrderDelivered.php
2020-08-04 10:09:42 +08:00

50 lines
1.3 KiB
PHP

<?php
namespace App\Notifications;
use RuLong\Order\Models\Order;
class OrderDelivered extends BaseNotification
{
protected static $title = '订单发货提醒';
protected $user;
protected $order;
public static function title()
{
return self::$title;
}
public function __construct(Order $order)
{
$this->order = $order;
}
public function toWechat($notifiable)
{
$app = app('wechat.official_account');
if ($notifiable->openid) {
$str = '您的订单已经成功发货!!' . "\r\n\r\n";
$str .= '订单号:' . $this->order->orderid . "\r\n";
$str .= '商品名称:' . $this->order->detail->item->goods->title . "\r\n";
$str .= '商品数量:' . $this->order->details()->sum('number') . "\r\n";
$str .= '快递公司:' . $this->order->express->company ?? '' . "\r\n";
$str .= '快递单号:' . $this->order->express->number ?? '' . "\r\n";
$str .= "<a href='" . route('orders.show', $this->order->orderid) . "'>点击查看详情</a>";
$app->customer_service->message($str)->to($notifiable->openid)->send();
}
}
public function toArray($notifiable)
{
return [
//
];
}
}