<?php

namespace App\Console;

use App\Console\Commands\MakeApacheConfCommand;
use App\Console\Commands\MakeBlogUvCommand;
use App\Console\Commands\MakeNginxConfCommand;
use App\Form\Services\FormRecordService;
use App\Web\Services\WebUtmService;
use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        MakeBlogUvCommand::class,
        MakeNginxConfCommand::class,
        MakeApacheConfCommand::class
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        //* * * * * cd /mp_website && php artisan schedule:run >> /dev/null 2>&1
        //发送邮件
        $schedule->call(function () {
            $service = app()->make(FormRecordService::class);
            $service->processRecordEmailSend();
        })->everyMinute()
            ->name('SendFormRecordEmail')
            ->withoutOverlapping(6000);

        //统计utm
        // */5 * * * * curl -k https://mp-website-test-munich.matchexpo.cn/cron/web-utm/persistence
//        $schedule->call(function () {
//            $service = app()->make(WebUtmService::class);
//            $service->persistenceUtmPvUv();
//        })->everyFiveMinutes()
//            ->name('persistenceUtmPvUv')
//            ->withoutOverlapping(6000);
    }
}
