| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Console\Commands;
- use App\Models\OrderModel;
- use Illuminate\Console\Command;
- class OrderStatusExpired extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'order:status-expired';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '支付订单过期处理';
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * Execute the console command.
- *
- * @return mixed
- */
- public function handle()
- {
- $this->comment("开始处理过期订单");
- $expiredTime = date('Y-m-d H:i:s', time() - 400);
- $orderData = OrderModel::query()->where('created_at', '<', $expiredTime)->where('status', 1)->get(['id']);
- if ($orderData->isNotEmpty()) {
- foreach ($orderData as $var) {
- OrderModel::query()->where('id', $var->id)->update(['status' => 3]);
- }
- }
- $this->comment("过期订单处理完成");
- }
- }
|