<?php
// +----------------------------------------------------------------------
// | onezan-admin 快速开发的管理平台
// +----------------------------------------------------------------------
// | 官方网址：https://www.onezan.cn
// +----------------------------------------------------------------------
// | onezan团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: 543885307@qq.com
// +----------------------------------------------------------------------
namespace app\listener\user;

use app\event\user\UserVerified;
use Core\service\queue\QueueDispatcher;


/**
 * 用户认证完成事件监听器
 * 认证完成后分发审核任务到队列
 * @package app\listener\user
 */
class UserVerifiedListener
{
    /**
     * 处理用户认证完成事件
     * @param UserVerified $event
     * @return void
     */
    public function handle(UserVerified $event): void
    {
        $this->queue()->dispatch('user.verified.audit', [
            'user_id' => $event->userId,
            'remark' => $event->remark,
        ], [
            'biz_key' => 'user.verified.audit:' . $event->userId,
        ]);
    }

    /**
     * 获取队列分发器
     * @return QueueDispatcher
     */
    private function queue(): QueueDispatcher
    {
        return app()->make(QueueDispatcher::class);
    }
}