You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
aquaculture/app/Console/Kernel.php

72 lines
2.3 KiB

<?php
namespace App\Console; // 定义命名空间
// 引入需要的控制台命令类
use App\Console\Commands\CountSite; // 引入 CountSite 命令
use App\Console\Commands\DelExpireScoreData; // 引入 DelExpireScoreData 命令
use App\Console\Commands\DelExpireSecKill; // 引入 DelExpireSecKill 命令
use App\Console\Commands\SendSubscribeEmail; // 引入 SendSubscribeEmail 命令
use App\Console\Commands\SyncProducViewCommand; // 引入 SyncProducViewCommand 命令
use App\Console\Commands\UpdateCacheHomeData; // 引入 UpdateCacheHomeData 命令
use Illuminate\Console\Scheduling\Schedule; // 引入 Schedule 类
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; // 引入 ConsoleKernel 基类
/**
* 控制台命令调度内核
*
* 该类负责注册和调度应用程序的 Artisan 命令。
*/
class Kernel extends ConsoleKernel
{
/**
* 应用程序提供的 Artisan 命令
*
* @var array
*/
protected $commands = [
// 注册的命令列表
];
/**
* 定义应用程序的命令调度
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// 每周六早上 8 点发送订阅邮件
$schedule->command(SendSubscribeEmail::class)->saturdays()->at('8:00');
// 每天凌晨 1 点统计注册人数和销售数量
$schedule->command(CountSite::class)->dailyAt('01:00');
// 每小时执行一次,回滚秒杀过期的数据
$schedule->command(DelExpireSecKill::class)->hourly();
// 每天午夜 12 点删除昨天过期的积分数据
$schedule->command(DelExpireScoreData::class)->dailyAt('00:00');
// 每天午夜 12 点 10 分同步商品浏览量
$schedule->command(SyncProducViewCommand::class)->dailyAt('00:10');
// 每分钟更新一次首页数据
$schedule->command(UpdateCacheHomeData::class)->everyMinute();
}
/**
* 注册应用程序的命令
*
* @return void
*/
protected function commands()
{
// 加载命令目录下的所有命令
$this->load(__DIR__.'/Commands');
// 引入控制台路由文件
require base_path('routes/console.php');
}
}