jingcai-php/app/Console/Commands/Order/AutoDelete45.php

50 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Console\Commands\Order;
use App\Enums\LottState;
use App\Enums\PayState;
use App\Exceptions\JingCaiException;
use App\Model\Order;
use App\Model\Seller\Seller;
use App\Service\CustomerWalletService;
use App\Utils\Helps;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use PhpMyAdmin\Logging;
class AutoDelete45 extends Command
{
/**
* 这个就是命令名称
*/
protected $signature = 'order:auto_delete45';
/**
* 命令的说明描述
* @var string
*/
protected $description = '系统自动删除45天之前的订单数据';
/**
* 创建命令的构造方法。
* @param string $words 传入的字符参数
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle()
{
$dayPoint = date('Y-m-d H:i:s', strtotime('-45 day'));
$effect = Order::where('created_at', '<=', $dayPoint)
->delete();
Log::info('AutoDelete45 删除' . $dayPoint . '之前的订单数据, 影响行数:' . $effect);
}
}