feat:영업/매니저 시나리오 100% 완료 시 계약완료 자동 전환

- SalesScenarioChecklist에 checkAndConvertProspectStatus() 메서드 추가
- toggleByProspect()에서 체크 완료 시 자동 전환 로직 호출
- AdminProspectController에서 목록 조회 시 기존 100% 데이터 자동 전환
- API 응답에 상태 변경 정보 포함

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-02 12:46:53 +09:00
parent 2f02390262
commit 3bd5550bb1
3 changed files with 46 additions and 1 deletions

View File

@@ -77,12 +77,19 @@ public function index(Request $request): View|Response
$prospects = $query->orderByDesc('created_at')->paginate(20);
// 각 가망고객의 진행률 계산
// 각 가망고객의 진행률 계산 및 상태 자동 전환
foreach ($prospects as $prospect) {
$progress = SalesScenarioChecklist::getProspectProgress($prospect->id);
$prospect->sales_progress = $progress['sales']['percentage'];
$prospect->manager_progress = $progress['manager']['percentage'];
// 진행률 100% 시 상태 자동 전환 체크
if ($progress['sales']['percentage'] === 100 && $progress['manager']['percentage'] === 100) {
SalesScenarioChecklist::checkAndConvertProspectStatus($prospect->id);
// 상태가 변경되었을 수 있으므로 다시 로드
$prospect->refresh();
}
// management 정보
$management = SalesTenantManagement::where('tenant_prospect_id', $prospect->id)->first();
$prospect->hq_status = $management?->hq_status ?? 'pending';