<?php

namespace App\Console;

use App\Console\Commands\ChkOrderServer;
use App\Console\Commands\ChkPriceearly;
use App\Console\Commands\ChkReplenish;
use App\Console\Commands\ChkShelflife;
use App\Console\Commands\DailySalesReport;
use App\Console\Commands\GoodsSkuDailyReport;
use App\Console\Commands\Inventory;
use App\Models\StockNotice;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Console\Commands\KttOrderQuery;
use App\Console\Commands\DeleteKttQuery;
use Illuminate\Support\Facades\Log;
use function RingCentral\Psr7\str;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
        \App\Console\Commands\ChkReplenish::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {

        // 服务器/etc/crontab添加cron入口
        // * * * * * cd /home/wwwroot/erp.chutang66.com && php artisan schedule:run >> /dev/null 2>&1
//        $schedule->command(KttOrderQuery::class)->everyMinute();
//
//        $schedule->command(GoodsSkuDailyReport::class)->dailyAt('06:00');
//        $schedule->command(Inventory::class)->dailyAt('07:00');
//
//        $schedule->command(DailySalesReport::class, ['S1'])->dailyAt('12:00');
//        $schedule->command(DailySalesReport::class, ['S2'])->dailyAt('13:30');
//        $schedule->command(DailySalesReport::class, ['S3'])->dailyAt('15:00');
//        $schedule->command(DailySalesReport::class, ['S4'])->dailyAt('16:00');
//        $schedule->command(DailySalesReport::class, ['S5'])->dailyAt('17:30');
//        $schedule->command(DailySalesReport::class, ['S6'])->dailyAt('20:00');
//        $schedule->command(DailySalesReport::class, ['S7'])->dailyAt('09:30');
//
//        $schedule->command(DeleteKttQuery::class)->daily();

//        $schedule->command('check:replenish')->everyMinute();
//        $active_time=StockNotice::pluck('active_time');
        $schedule->command(ChkReplenish::class);
        $schedule->command(ChkOrderServer::class)->everyFifteenMinutes();
        $schedule->command(ChkPriceearly::class)->everyFifteenMinutes();
        $schedule->command(ChkShelflife::class)->everyFifteenMinutes();
//        $schedule->command('check:priceearly')->dailyAt((string)$active_time[1]);
//        $schedule->command('check:shelflife')->dailyAt((string)$active_time[2]);
//        $schedule->command('check:orderServer')->everyFifteenMinutes();

    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

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