ActivitySingerSubmitWorkRejectNotification.php 2.04 KB
<?php

namespace App\Notifications;

use App\Models\User;
use App\Models\Views\ActivityWork;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;

class ActivitySingerSubmitWorkRejectNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public ActivityWork $work;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(ActivityWork $work)
    {
        $this->work = $work;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param mixed $notifiable
     * @return array
     */
    public function via(): array
    {
        return ['wechat', 'jPush'];
    }

    /**
     * @param \App\Models\User $notifiable
     * @return array
     */
    public function toJPush(User $notifiable): array
    {
        return [
            'user'    => $notifiable->getKey(),
            'title'   => '您的歌手试唱未选中',
            'content' => sprintf("您的歌手%s参与试唱活动《%s》未达成合作", $this->work->getAttribute('user_nick_name'), $this->work->getAttribute('activity_name')),
            'data'    => ['type' => 'ToComplete', 'value' => $this->work->getAttribute('user_id')]
        ];
    }

    /**
     * @param \App\Models\User $notifiable
     * @return array
     */
    public function toWechat(User $notifiable): array
    {
        return [
            'openId'   => $notifiable->getWechatNotificationKey(),
            'template' => '-qM3dii-zb8nnvPunYDFyPmNptnKzdkgiWRH4-nK8vA',
            'page'     => 'packageMy/pages/myMember/detail?id=' . $this->work->getAttribute('activity_id'),
            'data'     => [
                'first'    => '您的歌手提交的试唱未被采纳',
                'keyword1' => $this->work->getUserFullName(),
                'keyword2' => '参与试唱《' . $this->work->getAttribute('activity_name') . '》未达成合作',
                'remark'   => '感谢参与,期待下次合作'
            ]
        ];
    }
}