<?php
 namespace TechSoft\Laravel\Shop\Command; use Carbon\Carbon; use TechOnline\Laravel\Dao\ModelUtil; use TechSoft\Laravel\Shop\Jobs\OrderExpireCheckJob; use TechSoft\Laravel\Shop\Types\OrderStatus; use Illuminate\Console\Command; use Illuminate\Foundation\Bus\DispatchesJobs; class ShopOrderExpireCheck extends Command { use DispatchesJobs; protected $signature = 'ShopOrderExpireCheck'; protected $description = 'ShopOrderExpireCheck'; public function handle() { $expiredOrders = ModelUtil::model('order') ->where(['status' => OrderStatus::WAIT_PAY]) ->where('created_at', '<', Carbon::now()->subMinutes(30)) ->limit(10) ->get()->toArray(); foreach ($expiredOrders as $expiredOrder) { OrderExpireCheckJob::create($expiredOrder['id']); } } }