feat : Main Request 모델 추가, Enum 클래스 추가
- Main Request가 모든 공정을 관리하는 형태
This commit is contained in:
59
app/Services/EstimateService.php
Normal file
59
app/Services/EstimateService.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Enums\EstimateStatus;
|
||||
use App\Repositories\MainRequestRepository;
|
||||
use App\Models\MainRequestEstimate;
|
||||
|
||||
class EstimateService
|
||||
{
|
||||
protected $mainRequestRepo;
|
||||
|
||||
public function __construct(MainRequestRepository $mainRequestRepo)
|
||||
{
|
||||
$this->mainRequestRepo = $mainRequestRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적 신규 등록
|
||||
*/
|
||||
public function createEstimate($mainRequestId, array $data, $actorId): MainRequestEstimate
|
||||
{
|
||||
$estimate = $this->mainRequestRepo->createEstimate($mainRequestId, $data);
|
||||
|
||||
// 상태 이력 기록 (draft)
|
||||
$this->mainRequestRepo->addFlow(
|
||||
$mainRequestId,
|
||||
get_class($estimate),
|
||||
$estimate->id,
|
||||
EstimateStatus::Draft->value,
|
||||
'등록',
|
||||
$actorId,
|
||||
'견적서 임시 등록'
|
||||
);
|
||||
|
||||
return $estimate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 견적 상태 변경
|
||||
*/
|
||||
public function changeEstimateStatus(MainRequestEstimate $estimate, EstimateStatus $newStatus, $actorId, $memo = null)
|
||||
{
|
||||
$estimate->status_code = $newStatus;
|
||||
$estimate->save();
|
||||
|
||||
// 이력 기록
|
||||
$this->mainRequestRepo->addFlow(
|
||||
$estimate->main_request_id,
|
||||
get_class($estimate),
|
||||
$estimate->id,
|
||||
$newStatus->value,
|
||||
'상태변경',
|
||||
$actorId,
|
||||
$memo
|
||||
);
|
||||
}
|
||||
|
||||
// ... 기타 견적 비즈니스 로직도 여기에!
|
||||
}
|
||||
Reference in New Issue
Block a user