jingcai-php/app/Console/Commands/Table/OptimizeReport.php

49 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands\Table;
use App\Model\Config;
use App\Model\Customer\CustomerRanking;
use App\Model\Report\ReportDaySeller;
use App\Model\Report\ReportDayShop;
use App\Model\Report\ReportDayWin;
use Illuminate\Console\Command;
class OptimizeReport extends Command
{
/**
* 这个就是命令名称
*/
protected $signature = 'optimize:report';
/**
* 命令的说明描述
* @var string
*/
protected $description = '优化统计相关的表,物理删除数据';
/**
* 创建命令的构造方法。
* @param string $words 传入的字符参数
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle()
{
$currentDate = Config::keepDataDate();
CustomerRanking::where('created_at', '<', $currentDate)
->forceDelete();
ReportDaySeller::where('created_at', '<', $currentDate)
->forceDelete();
ReportDayShop::where('created_at', '<', $currentDate)
->forceDelete();
ReportDayWin::where('created_at', '<', $currentDate)
->forceDelete();
}
}