12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace App\Console\Commands;
- use App\Services\OrderService;
- use Illuminate\Console\Command;
- use App\Models\Order;
- use App\Models\User;
- use App\Models\Plan;
- use Illuminate\Support\Facades\DB;
- class CheckOrder extends Command
- {
-
- protected $signature = 'check:order';
-
- protected $description = '订单检查任务';
-
- public function __construct()
- {
- parent::__construct();
- }
-
- public function handle()
- {
- ini_set('memory_limit', -1);
- $orders = Order::whereIn('status', [0, 1])
- ->get();
- foreach ($orders as $item) {
- $orderService = new OrderService($item);
- switch ($item->status) {
-
- case 0:
- if ($item->created_at <= (time() - 1800)) {
- $orderService->cancel();
- }
- break;
- case 1:
- $orderService->open();
- break;
- }
- }
- }
- }
|