|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+<?php
|
|
|
2
|
+
|
|
|
3
|
+namespace app\command;
|
|
|
4
|
+
|
|
|
5
|
+use app\common\model\shared\SharedProsperityPartnerConsumeUpdateLog;
|
|
|
6
|
+use app\common\repositories\shared\SharedProsperityRecommendConfigRepository;
|
|
|
7
|
+use think\console\Command;
|
|
|
8
|
+use think\console\Input;
|
|
|
9
|
+use think\console\Output;
|
|
|
10
|
+use think\facade\Db;
|
|
|
11
|
+
|
|
|
12
|
+class DeleteApiLog extends Command
|
|
|
13
|
+{
|
|
|
14
|
+ // 上级
|
|
|
15
|
+ const DAY = 10;
|
|
|
16
|
+
|
|
|
17
|
+ protected function configure()
|
|
|
18
|
+ {
|
|
|
19
|
+ // 指令配置
|
|
|
20
|
+ $this->setName('deleteApiLog')
|
|
|
21
|
+ ->setDescription('定时删除api日志');
|
|
|
22
|
+ }
|
|
|
23
|
+
|
|
|
24
|
+ protected function execute(Input $input, Output $output)
|
|
|
25
|
+ {
|
|
|
26
|
+ $output->writeln('定时任务执行中...');
|
|
|
27
|
+
|
|
|
28
|
+ $this->delete();
|
|
|
29
|
+
|
|
|
30
|
+ $output->writeln('定时任务执行完成');
|
|
|
31
|
+ }
|
|
|
32
|
+
|
|
|
33
|
+ private function delete()
|
|
|
34
|
+ {
|
|
|
35
|
+ $time = time() - self::DAY * 24 * 60 * 60;
|
|
|
36
|
+ $time = date('Y-m-d H:i:s', $time);
|
|
|
37
|
+ Db::name('api_request_log')->where('create_time', '<', $time)->limit(1000)->delete();
|
|
|
38
|
+ }
|
|
|
39
|
+
|
|
|
40
|
+}
|