<?php

namespace App\Providers;

use App\Events\AdminUserCreatedEvent;
use App\Events\AdminUserResetPwdEvent;
use App\Events\CommissionGotEvent;
use App\Events\CommissionUnfreezeComplete;
use App\Events\OperationLoggedEvent;
use App\Events\OrderCommissionSetedEvent;
use App\Events\OrderServeFinishedEvent;
use App\Events\OrderServeStartedEvent;
use App\Events\WithdrawalsApplyEvent;
use App\Events\WithdrawalsCompleteEvent;
use App\Listeners\OperationLogListener;
use App\Listeners\SendApplyOfWithdrawalsNotifyToFinanceListener;
use App\Listeners\SendApplyOfWithdrawalsNotifyToUserListener;
use App\Listeners\SendCommissionToPartnerListener;
use App\Listeners\SendCommissionNoticeToPartnerListener;
use App\Listeners\SendCommissionToServeUserListener;
use App\Listeners\SendPwdToAdminUserListener;
use App\Listeners\SendResultOfWithdrawalsNotifyListener;
use App\Listeners\UnfreezeCommissionListener;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event to listener mappings for the application.
     *
     * @var array<class-string, array<int, class-string>>
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],

        //订单佣金分配方案设置完成
        OrderCommissionSetedEvent::class => [
            SendCommissionNoticeToPartnerListener::class, //发送佣金通知
        ],

        //订单开始服务
        OrderServeStartedEvent::class => [
            SendCommissionToServeUserListener::class,//发佣金给服务人员(包括推荐人)
        ],

        //订单完成服务
        OrderServeFinishedEvent::class => [
            SendCommissionToServeUserListener::class,//发佣金给服务人员(包括推荐人)
        ],

        //佣金入账
        CommissionGotEvent::class => [
            UnfreezeCommissionListener::class,            //佣金解锁任务入队
        ],
        //佣金解冻完成
        CommissionUnfreezeComplete::class => [
            SendCommissionNoticeToPartnerListener::class, //发送佣金通知
        ],
        //发起提现申请
        WithdrawalsApplyEvent::class => [
            SendApplyOfWithdrawalsNotifyToFinanceListener::class, //发送申请通知给财务
//            SendApplyOfWithdrawalsNotifyToUserListener::class, //发送申请通知给用户
        ],

        //提现申请完成
        WithdrawalsCompleteEvent::class => [
            SendResultOfWithdrawalsNotifyListener::class, //发送申请结果
        ],

        //记录后台操作记录
        OperationLoggedEvent::class => [
            OperationLogListener::class,//记录后台操作记录
        ],
        //后台创建管理员
        AdminUserCreatedEvent::class => [
            SendPwdToAdminUserListener::class,//发送密码给对应管理员
        ],
        //重置管理员密码
        AdminUserResetPwdEvent::class => [
            SendPwdToAdminUserListener::class,//发送密码给对应管理员
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {


    }

    /**
     * Determine if events and listeners should be automatically discovered.
     *
     * @return bool
     */
    public function shouldDiscoverEvents()
    {
        return false;
    }
}
