更新代码
This commit is contained in:
48
app/Notifications/AccountChanged.php
Normal file
48
app/Notifications/AccountChanged.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
class AccountChanged extends BaseNotification
|
||||
{
|
||||
|
||||
protected static $title = '账户变动提醒';
|
||||
|
||||
protected $log;
|
||||
|
||||
public static function title()
|
||||
{
|
||||
return self::$title;
|
||||
}
|
||||
|
||||
public function __construct($log)
|
||||
{
|
||||
$this->log = $log;
|
||||
}
|
||||
|
||||
public function toWechat($notifiable)
|
||||
{
|
||||
$app = app('wechat.official_account');
|
||||
$variable = number_format($this->log->variable ?? '', 2);
|
||||
if ($variable > 0) {
|
||||
$variable = '+' . $variable;
|
||||
}
|
||||
if ($notifiable->openid) {
|
||||
$data = ['cash' => '现金账户', 'score' => '可提现账户'];
|
||||
$str = '亲爱的' . $notifiable->info->nickname . ',您的余额发生变动,内容如下:' . "\r\n\r\n";
|
||||
$str .= '变动账户:' . $data[$this->log->type] . "\r\n";
|
||||
$str .= '变动金额:' . $variable . "\r\n";
|
||||
$str .= '变动内容:' . $this->log->rule->title . "\r\n";
|
||||
$str .= '变动时间:' . $this->log->created_at->format('Y-m-d H:i:s') . "\r\n\r\n";
|
||||
|
||||
$app->customer_service->message($str)->to($notifiable->openid)->send();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user