- 영업(Sales), 재무(Finance), 생산(Production) 3개 도메인 구현 - 일간/월간 통계 테이블 6개 마이그레이션 생성 - 도메인별 StatService (SalesStatService, FinanceStatService, ProductionStatService) - Daily/Monthly 6개 Eloquent 모델 생성 - StatAggregatorService에 도메인 서비스 매핑 활성화 - StatJobLog duration_ms abs() 처리 - 스케줄러 등록 (일간 02:00, 월간 1일 03:00) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Stats;
|
|
|
|
class StatJobLog extends BaseStatModel
|
|
{
|
|
protected $table = 'stat_job_logs';
|
|
|
|
public $timestamps = false;
|
|
|
|
protected $casts = [
|
|
'target_date' => 'date',
|
|
'started_at' => 'datetime',
|
|
'completed_at' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
];
|
|
|
|
public function markRunning(): void
|
|
{
|
|
$this->update([
|
|
'status' => 'running',
|
|
'started_at' => now(),
|
|
]);
|
|
}
|
|
|
|
public function markCompleted(int $recordsProcessed = 0): void
|
|
{
|
|
$durationMs = $this->started_at
|
|
? abs((int) now()->diffInMilliseconds($this->started_at))
|
|
: null;
|
|
|
|
$this->update([
|
|
'status' => 'completed',
|
|
'records_processed' => $recordsProcessed,
|
|
'completed_at' => now(),
|
|
'duration_ms' => $durationMs,
|
|
]);
|
|
}
|
|
|
|
public function markFailed(string $errorMessage): void
|
|
{
|
|
$durationMs = $this->started_at
|
|
? abs((int) now()->diffInMilliseconds($this->started_at))
|
|
: null;
|
|
|
|
$this->update([
|
|
'status' => 'failed',
|
|
'error_message' => $errorMessage,
|
|
'completed_at' => now(),
|
|
'duration_ms' => $durationMs,
|
|
]);
|
|
}
|
|
}
|