|
|
<?php
|
|
|
|
|
|
namespace App\Console;
|
|
|
|
|
|
use App\Models\Notifications;
|
|
|
use App\Models\OrderItems;
|
|
|
use App\Models\Orders;
|
|
|
use App\Models\Refund;
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
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('order-items:create-daily')->everyMinute();
|
|
|
$schedule->command('sync-recharge-pay-state:weixin')->everyMinute();
|
|
|
$schedule->command('sync-recharge-pay-state:alipay')->everyMinute();
|
|
|
|
|
|
//自动扣款,下午两点开始扣款,每小时可处理3000个子订单,每天可以处理30000个子订单
|
|
|
$schedule->call(function () {
|
|
|
(new OrderItems())->autoCheckout();
|
|
|
})->everyMinute()->timezone('Asia/Shanghai')->between('14:00', '23:59');
|
|
|
|
|
|
//自动退款
|
|
|
$schedule->call(function () {
|
|
|
(new Refund())->autoRefund();
|
|
|
})->everyMinute();
|
|
|
|
|
|
//自动生成日志文件,配合系统层面定时更新文件权限,避免临时生成后的权限问题
|
|
|
$schedule->call(function () {
|
|
|
Log::info('auto generate log file');
|
|
|
})->daily();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Register the commands for the application.
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
protected function commands()
|
|
|
{
|
|
|
$this->load(__DIR__ . '/Commands');
|
|
|
|
|
|
require base_path('routes/console.php');
|
|
|
}
|
|
|
}
|