ActivityStatusRecordCommand.php
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace App\Console\Commands;
use App\Enums\ActivityAuditStatusEnum;
use App\Enums\ActivityStatusEnum;
use App\Models\Activity;
use DB;
use Illuminate\Console\Command;
class ActivityStatusRecordCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'activity:status-record';
/**
* The console command description.
*
* @var string
*/
protected $description = '记录活动状态节点';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
DB::table('activity_status_records')->updateOrInsert(
['time' => today()->toDateString()],
[
'up' => Activity::query()->where('activitys.audit_status', ActivityAuditStatusEnum::SUCCESS)->where('activitys.status', ActivityStatusEnum::UP)->count(),
'down' => Activity::query()->where('activitys.audit_status', ActivityAuditStatusEnum::SUCCESS)->where('activitys.status', ActivityStatusEnum::DOWN)->count(),
'match' => Activity::query()->where('activitys.audit_status', ActivityAuditStatusEnum::SUCCESS)->where('activitys.status', ActivityStatusEnum::MATCH)->count(),
'send' => Activity::query()->where('activitys.audit_status', ActivityAuditStatusEnum::SUCCESS)->where('activitys.status', ActivityStatusEnum::SEND)->count(),
]
);
return self::SUCCESS;
}
}