<?php

namespace App\Console;

use App\Console\Commands\CheckPrice;
use App\Console\Commands\CheckSkuQualityPeriod;
use App\Console\Commands\DailySalesReport;
use App\Console\Commands\DailyStockRecordReport;
use App\Console\Commands\GoodsSkuDailyReport;
use App\Console\Commands\Inventory;
use App\Console\Commands\KttOrderAfterSaleQuery;
use App\Console\Commands\KttOrderSyncStatus;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Console\Commands\KttOrderQuery;
use App\Console\Commands\DeleteKttQuery;

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)
    {
        // 服务器/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(CheckPrice::class)->everyFifteenMinutes();
        //保质期
        $schedule->command(CheckSkuQualityPeriod::class)->dailyAt('11:00');
        //快团团售后单拉取
        $schedule->command(KttOrderAfterSaleQuery::class)->everyFifteenMinutes();
        //同步售卖信息和报损相关数据
        $schedule->command(DailyStockRecordReport::class)->dailyAt('03:30');

        //新增快团团订单状态同步
        $schedule->command(KttOrderSyncStatus::class)->everyTenMinutes();

    }

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

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