51 lines
1.1 KiB
PHP
Executable File
51 lines
1.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Console\Commands\Order;
|
|
|
|
use App\Enums\LottState;
|
|
use App\Enums\PayState;
|
|
use App\Model\Order;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class DeleteUnpay extends Command
|
|
{
|
|
/**
|
|
* 这个就是命令名称
|
|
*/
|
|
protected $signature = 'order:delete_unpay';
|
|
|
|
/**
|
|
* 命令的说明描述
|
|
* @var string
|
|
*/
|
|
protected $description = '';
|
|
|
|
/**
|
|
* 创建命令的构造方法。
|
|
* @param string $words 传入的字符参数
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
Log::info('DeleteUnpay删除未支付的订单');
|
|
|
|
$closeDate = date('Y-m-d H:i:s', strtotime('-2 day'));
|
|
|
|
Order::where('pay_state', PayState::UNPAID)
|
|
->where('odds_early_close_time', '<', $closeDate)
|
|
->chunkById(200, function($orders) {
|
|
foreach ($orders as $order) {
|
|
$order->lottery_state = LottState::DELETE;
|
|
$order->delete();
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|