<?php

namespace App\Console;

use App\Services\Notice\OldUserRetainedService;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

/**
 * Class Kernel
 * @package App\Console
 */
class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [

    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        ## 微信公众号
        // 定时刷新token
        $schedule->command('wechat:access-token')->everyFiveMinutes()->withoutOverlapping();

        // 时遇记公众号每日推送
        $schedule->command('daily:syj')->dailyAt('22:02')->withoutOverlapping();

        ## 福利中心
        // 福利抽奖定时
        $schedule->command('welfare:lottery')->dailyAt('19:55');
        // 福利发奖定时
        $schedule->command('welfare:prize')->dailyAt('20:00');
        // 福利通知定时
        $schedule->command('welfare:notice')->dailyAt('20:05');

        ## 契约
        // 卡片:心动通知延迟发送
        $schedule->command('partner:thumbme:notice:dely')->dailyAt('09:30');
        // 心动邀请通知:夜间通知延迟发送
        $schedule->command('invitation:notice:dely')->dailyAt('09:30');

        // 好友列表:未读消息通知:加载通知用户
        // $schedule->command("friendslist:unreadnotice:load")->dailyAt("02:20");
        // 好友列表:未读消息通知:发送通知
        // $schedule->command("friendslist:unreadnotice:send")->between("8:00", "23:00")->everyFiveMinutes();

        ## 晚安
        // 榜单
        $schedule->command("goodnight:rank total")->everyMinute()->withoutOverlapping();
        $schedule->command("goodnight:rank daily")->everyMinute()->withoutOverlapping();
        // 创建活动
        $schedule->command('goodnight:activity')->dailyAt('02:00');
        // 晚安伴侣:订阅推送
        $schedule->command('goodnight:push')->dailyAt('22:00');
        // 晚安伴侣:匹配伴侣
        $schedule->command('goodnight:match')->dailyAt('19:30');

        ## 客服号

        /**
         * 客服号
         */
        // 清理脚本:微信客服管理:每日发码和加好友数量
        $schedule->command('clean:wxkf:daycnt')->dailyAt('00:30');
        // 微信客服管理:添加每小时二维码数量
        $schedule->command('wxkf:hourqueue:add')->hourly();

        // 超级会员:过期通知
        $schedule->command('supervip:remindexpire')->twiceDaily(10, 20)->hourly();
        // 人气值:好友助力和小fa:过期通知
        $schedule->command('popularity:share:flower:expire')->everyTenMinutes();
        // 人气值:存储用户今日人气值
        $schedule->command('popularity:todaylog:save')->at('23:00');
        // 人气值:加载人气值日报推送用户
        $schedule->command('popularity:daiyuser:load')->at('01:30');
        // 人气值:发送日报
        $schedule->command('popularity:daiyuser:push')->between("8:01", "23:01")->everyFiveMinutes();

        // 未登录用户模拟点赞
        $schedule->command('mockthumb:timing')->between("09:00", "23:59")->everyMinute()->withoutOverlapping();

        // 完善卡片提醒-被提醒者
//        $schedule->command('operate:remindComplteInfo')
//            ->between("08:00", "20:00")->everyMinute()->withoutOverlapping();

        // 通知:老用户召回
//        $schedule->command('notice:old_user visitor')->hourlyAt(1)->between('8:00', '22:00')->withoutOverlapping();
//        $schedule->command('notice:old_user vip')->hourlyAt(2)->between('8:00', '22:00')->withoutOverlapping();
//        $schedule->command('notice:old_user once_pair')->hourlyAt(3)->between('8:00', '22:00')->withoutOverlapping();
//        $schedule->command('notice:old_user phone_not_card')
//            ->hourlyAt(4)->between('8:00', '22:00')->withoutOverlapping();
//        $schedule->command('notice:old_user partner')->hourlyAt(5)->between('8:00', '22:00')->withoutOverlapping();
//        $schedule->command('notice:old_user cardRecommendCancel')
//            ->hourlyAt(6)->between('8:00', '22:00')->withoutOverlapping();


        // QQ小程序营销通知
//        $schedule->command('notice:qq first')->hourlyAt(31)->between('8:00', '22:00')->withoutOverlapping();
//        $schedule->command('notice:qq second')->hourlyAt(32)->between('8:00', '22:00')->withoutOverlapping();
//        $schedule->command('notice:qq third')->hourlyAt(33)->between('8:00', '22:00')->withoutOverlapping();
        $schedule->call(function () {
            $ors = new OldUserRetainedService();
            $ors->send();
        })->dailyAt("08:25");


        // 时遇记公众号营销通知
//        $schedule->command('notice:syj a')->between('8:00', '22:00')->everyMinute();
//        $schedule->command('notice:syj b')->between('8:00', '22:00')->everyMinute();
//        $schedule->command('notice:syj c')->between('8:00', '22:00')->everyMinute();
//        $schedule->command('notice:syj d')->between('8:00', '22:00')->everyMinute();
//        $schedule->command('notice:syj e')->between('8:00', '22:00')->everyMinute();

        // 分配对象公众号营销通知
//        $schedule->command('notice:fpdx a')->between('8:00', '22:00')->everyMinute();
//        $schedule->command('notice:fpdx b')->between('8:00', '22:00')->everyMinute();
//        $schedule->command('notice:fpdx c')->between('8:00', '22:00')->everyMinute();

        ## 72小时活动
        // 分配对象预匹配
        $schedule->command('pair:prepipei')->wednesdays()->at('12:30');

        // 每周创建活动
        $schedule->command('pair:activity')->thursdays()->at('12:00');
        // 对象匹配
        $schedule->command('pair:pipei')->thursdays()->at('12:10');
        // 匹配通知
        $schedule->command('pair:notice:pair')->thursdays()->at('12:20');

        // 匹配修改状态
        $schedule->command('pair:publish')->thursdays()->at('17:01');
        // 送入群聊
        $schedule->command('pair:into:group')->thursdays()->at('17:02');
        // 情报局送入房间
        $schedule->command('qbj:into:room')->thursdays()->at("17:03");


        // 分配对象:重新匹配
        $schedule->command('pair:rematch')->fridays()->at('10:10');
        // 重匹通知
        $schedule->command('pair:notice:rematch')->fridays()->at('10:20');
        // 创群创房间
        $schedule->command('pair:into:room')->fridays()->at("11:01");
        $schedule->command('pair:into:group')->fridays()->at("11:02");

        // 活动结束分销
        $schedule->command('pair:account')->mondays()->at('00:10');
        // 反馈通知
        $schedule->command('pair:notice:feedback')->mondays()->at('00:20');
    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');
        $this->load(__DIR__ . '/Commands/Pair');
        $this->load(__DIR__ . '/Commands/Partner');
        $this->load(__DIR__ . '/Commands/Cache');
        $this->load(__DIR__ . '/Commands/Welfare');
        $this->load(__DIR__ . '/Commands/Wechat');
        $this->load(__DIR__ . '/Commands/Goodnight');
        $this->load(__DIR__ . '/Commands/Upgrade');
        $this->load(__DIR__ . '/Commands/User');
        $this->load(__DIR__ . '/Commands/Notices');
        $this->load(__DIR__ . '/Commands/Exports');
        $this->load(__DIR__ . '/Commands/MeiTu');

        require base_path('routes/console.php');
    }
}
