67 lines
1.9 KiB
PHP
67 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Console;
|
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
use Nwidart\Modules\Facades\Module as ModuleManager;
|
|
|
|
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)
|
|
{
|
|
// $schedule->command('inspire')->hourly();
|
|
$schedule->command('Bonus:MonthPerf 1')->monthlyOn(1, '00:01');
|
|
$schedule->command('Bonus:StartMonth 1 1')->monthlyOn(1, '00:10');
|
|
$schedule->command('Bonus:StartMonth 2 1')->monthlyOn(1, '00:15');
|
|
$schedule->command('Bonus:StartMonth 3 1')->monthlyOn(1, '00:20');
|
|
$schedule->command('Bonus:StartMonth 4 1')->monthlyOn(1, '00:25');
|
|
$schedule->command('Bonus:StartMonth 5 1')->monthlyOn(1, '00:30');
|
|
$this->modules($schedule);
|
|
}
|
|
|
|
/**
|
|
* 要执行任务的位置增加Console\Kernel类
|
|
* 类中 runCommand(Schedule $schedule)
|
|
* 模型中的command在模型的ServiceProvider自行注册
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
|
*/
|
|
protected function modules(Schedule $schedule)
|
|
{
|
|
$data = ModuleManager::toCollection();
|
|
foreach ($data as $name => $module) {
|
|
$nameSpace = "\\Modules\\$name\\Console\\Kernel";
|
|
if (class_exists($nameSpace)) {
|
|
$runKernel = resolve($nameSpace);
|
|
$runKernel->runCommand($schedule);
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Register the commands for the application.
|
|
* @return void
|
|
*/
|
|
protected function commands()
|
|
{
|
|
$this->load(__DIR__.'/Commands');
|
|
|
|
// require base_path('routes/console.php');
|
|
}
|
|
|
|
}
|