69 lines
2.0 KiB
PHP
69 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use RuLong\Order\Models\Order;
|
|
|
|
class OrderPaied 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 && $this->order->item_type == 'GIFT') {
|
|
$type_text = '';
|
|
$url = route('orders.show', $this->order->orderid);
|
|
switch ($this->order->type) {
|
|
case 'lottery':
|
|
$type_text = '奖品';
|
|
$url = route('lottery.logs');
|
|
break;
|
|
case 'lesson':
|
|
$type_text = '赠品';
|
|
$url = route('gifts.index');
|
|
|
|
break;
|
|
default:
|
|
$type_text = ($this->order->payment) ? $this->order->payment->type_text : '';
|
|
break;
|
|
}
|
|
|
|
if (in_array($this->order->type, ['lottery', 'lesson'])) {
|
|
$str = '您获得一份礼品,请设置收货地址,我们将尽快为您安排发货' . "\r\n\r\n";
|
|
} else {
|
|
$str = '您的订单已经支付成功,我们将尽快为您安排发货!!' . "\r\n\r\n";
|
|
}
|
|
|
|
$str .= '订单号:' . $this->order->orderid . "\r\n";
|
|
$str .= '下单时间:' . $this->order->created_at->format('Y-m-d H:i:s') . "\r\n";
|
|
$str .= '订单金额:' . number_format($this->order->amount, 2) . "\r\n";
|
|
$str .= '支付途径:' . $type_text . "\r\n\r\n";
|
|
$str .= "<a href='" . $url . "'>点击查看详情</a>";
|
|
|
|
$app->customer_service->message($str)->to($notifiable->openid)->send();
|
|
}
|
|
}
|
|
|
|
public function toArray($notifiable)
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
}
|