1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace App\Console;
- use App\Models\Notification;
- use App\Models\Order;
- use App\Models\OrderDevice;
- use Carbon\Carbon;
- use Illuminate\Console\Scheduling\Schedule;
- use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
- class Kernel extends ConsoleKernel
- {
- /**
- * The Artisan commands provided by your application.
- *
- * @var array
- */
- protected $commands = [
- //
- // Commands\UpdateRentDevice::class,
- Commands\UpdateApplyDevice::class,
- Commands\GetOrdersOverview::class,
- ];
- /**
- * Define the application's command schedule.
- *
- * @param \Illuminate\Console\Scheduling\Schedule $schedule
- * @return void
- */
- protected function schedule(Schedule $schedule)
- {
- $schedule->call(function () {
- // 租赁订单过期提醒|调用设备过期提醒-为一天后或三天后过期的订单发送
- $tomorrow = Carbon::tomorrow()->toDateString();
- $three_day = Carbon::today()->addDays(3)->toDateString();
- $order_ids = OrderDevice::whereIn('end_date', [$tomorrow, $three_day])->pluck('order_id')->unique();
- foreach($order_ids as $order_id) {
- Notification::send($order_id, true);
- }
- })->dailyAt('12:00');
- /*每分钟执行一次更新租赁设备的时间*/
- $schedule->command('updateApplyDevice')->everyMinute();
- }
- /**
- * Register the Closure based commands for the application.
- *
- * @return void
- */
- protected function commands()
- {
- require base_path('routes/console.php');
- }
- }
|