!79 增加删除日志命令

Merge pull request !79 from 赵世界/develop
This commit is contained in:
赵世界 2022-08-30 15:37:24 +00:00 committed by Gitee
commit 9e161cb83c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 65 additions and 2 deletions

View File

@ -0,0 +1,61 @@
<?php
namespace App\Console\Commands;
use App\Models\Log;
use Illuminate\Console\Command;
class DeleteKttQuery extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'delete:ktt_query';
/**
* 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()
{
$count = Log::where('target_field', 'pdd.ktt.goods.query.list')
->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-1 day')))
->delete();
$this->info('删除商品列表查询: ' . $count);
$count = Log::where('target_field', 'pdd.ktt.order.list')
->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-2 day')))
->delete();
$this->info('删除根据成交时间拉取订单列表: ' . $count);
$count = Log::where('target_field', 'pdd.ktt.increment.order.query')
->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-2 day')))
->delete();
$this->info('删除增量查订单: ' . $count);
$count = Log::where('target_field', '更新库存')
->where('created_at', '<', date('Y-m-d H:i:s', strtotime('-2 day')))
->delete();
$this->info('删除妙选更新库存: ' . $count);
}
}

View File

@ -6,6 +6,7 @@ use App\Console\Commands\Inventory;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Console\Commands\KttOrderQuery; use App\Console\Commands\KttOrderQuery;
use App\Console\Commands\DeleteKttQuery;
class Kernel extends ConsoleKernel class Kernel extends ConsoleKernel
{ {
@ -30,6 +31,7 @@ class Kernel extends ConsoleKernel
// * * * * * cd /home/wwwroot/erp.staging.chutang66.com && php artisan schedule:run >> /dev/null 2>&1 // * * * * * cd /home/wwwroot/erp.staging.chutang66.com && php artisan schedule:run >> /dev/null 2>&1
$schedule->command(Inventory::class)->dailyAt('07:00'); $schedule->command(Inventory::class)->dailyAt('07:00');
$schedule->command(KttOrderQuery::class)->everyMinute(); $schedule->command(KttOrderQuery::class)->everyMinute();
$schedule->command(DeleteKttQuery::class)->daily();
} }
/** /**
@ -39,7 +41,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function commands() protected function commands()
{ {
$this->load(__DIR__.'/Commands'); $this->load(__DIR__ . '/Commands');
require base_path('routes/console.php'); require base_path('routes/console.php');
} }