Files
ProxyPanel/app/Notifications/PaymentConfirm.php
兔姬桑 12d4365fe4 Bark & 企业微信 等显示调整优化
Apply fixes from StyleCI
2022-01-16 22:57:48 +08:00

78 lines
2.4 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Notifications;
use App\Models\Order;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\Telegram\TelegramMessage;
class PaymentConfirm extends Notification
{
use Queueable;
private $order;
private $sign;
public function __construct(Order $order)
{
$this->order = $order;
$this->sign = string_encrypt($order->payment->id);
}
public function via($notifiable)
{
return sysConfig('payment_confirm_notification');
}
public function toTelegram($notifiable)
{
$order = $this->order;
$goods = $this->order->goods;
$message = sprintf("🛒 人工支付\n———————————————\n\t\t 账号:%s\n\t\t💰 金额:%1.2f\n\t\t📦 商品:%s\n\t\t", $order->user->username, $order->amount, $goods->name ?? '余额充值');
foreach (User::role('Super Admin')->get() as $admin) {
if (! $admin->telegram_user_id) {
continue;
}
return TelegramMessage::create()
->to($admin->telegram_user_id)
->token(sysConfig('telegram_token'))
->content($message)
->button('否 決', route('payment.notify', ['method' => 'manual', 'sign' => $this->sign, 'status' => 0]))
->button('确 认', route('payment.notify', ['method' => 'manual', 'sign' => $this->sign, 'status' => 1]));
}
return false;
}
public function toCustom($notifiable)
{
$order = $this->order;
$goods = $this->order->goods;
return [
'title' => '🛒 人工支付',
'body' => [
[
'keyname' => ' 账号',
'value' => $order->user->username,
],
[
'keyname' => '💰 金额',
'value' => sprintf('%1.2f', $order->amount),
],
[
'keyname' => '📦 商品',
'value' => $goods->name ?? '余额充值',
],
],
'button' => [
route('payment.notify', ['method' => 'manual', 'sign' => $this->sign, 'status' => 0]),
route('payment.notify', ['method' => 'manual', 'sign' => $this->sign, 'status' => 1]),
],
];
}
}