diff --git a/app/Http/Controllers/Sales/SalesDashboardController.php b/app/Http/Controllers/Sales/SalesDashboardController.php index b65d35d7..49ef808a 100644 --- a/app/Http/Controllers/Sales/SalesDashboardController.php +++ b/app/Http/Controllers/Sales/SalesDashboardController.php @@ -484,20 +484,20 @@ private function getPartnerActivityData(): array } /** - * 내가 매니저로만 참여하는 가망고객 조회 + * 내가 매니저로만 참여하는 건 조회 * (다른 사람이 등록했지만 내가 매니저로 지정된 건) */ private function getManagerOnlyProspects(int $currentUserId): array { - // 내가 매니저로 지정된 management 조회 - $managements = SalesTenantManagement::where('manager_user_id', $currentUserId) + $results = []; + + // 1. prospect 기반 매니저 지정 (가망고객 단계) + $prospectManagements = SalesTenantManagement::where('manager_user_id', $currentUserId) ->whereNotNull('tenant_prospect_id') ->with(['tenantProspect.registeredBy']) ->get(); - $prospects = []; - - foreach ($managements as $management) { + foreach ($prospectManagements as $management) { $prospect = $management->tenantProspect; // 내가 등록한 건은 제외 (순수하게 매니저로만 참여한 건만) @@ -513,17 +513,54 @@ private function getManagerOnlyProspects(int $currentUserId): array ->selectRaw('SUM(registration_fee) as total_registration_fee, SUM(subscription_fee) as total_subscription_fee') ->first(); - $prospects[] = [ + $results[] = [ + 'type' => 'prospect', 'prospect' => $prospect, 'management' => $management, 'registeredBy' => $prospect->registeredBy, 'progress' => $progress, + 'company_name' => $prospect->company_name, + 'business_number' => $prospect->business_number, 'total_registration_fee' => $contractTotals->total_registration_fee ?? 0, 'total_subscription_fee' => $contractTotals->total_subscription_fee ?? 0, ]; } - return $prospects; + // 2. tenant 기반 매니저 지정 (이미 계약된 고객) + $tenantManagements = SalesTenantManagement::where('manager_user_id', $currentUserId) + ->whereNull('tenant_prospect_id') + ->whereNotNull('tenant_id') + ->with(['tenant']) + ->get(); + + foreach ($tenantManagements as $management) { + $tenant = $management->tenant; + if (!$tenant) { + continue; + } + + // 계약 금액 정보 + $contractTotals = SalesContractProduct::where('management_id', $management->id) + ->selectRaw('SUM(registration_fee) as total_registration_fee, SUM(subscription_fee) as total_subscription_fee') + ->first(); + + $results[] = [ + 'type' => 'tenant', + 'tenant' => $tenant, + 'management' => $management, + 'registeredBy' => null, + 'progress' => [ + 'sales' => ['percentage' => 100, 'completed' => 0, 'total' => 0], + 'manager' => ['percentage' => 100, 'completed' => 0, 'total' => 0], + ], + 'company_name' => $tenant->company_name, + 'business_number' => $tenant->business_number, + 'total_registration_fee' => $contractTotals->total_registration_fee ?? 0, + 'total_subscription_fee' => $contractTotals->total_subscription_fee ?? 0, + ]; + } + + return $results; } /** diff --git a/resources/views/sales/dashboard/partials/manager-prospects.blade.php b/resources/views/sales/dashboard/partials/manager-prospects.blade.php index 2bad97b5..86f2cd18 100644 --- a/resources/views/sales/dashboard/partials/manager-prospects.blade.php +++ b/resources/views/sales/dashboard/partials/manager-prospects.blade.php @@ -32,10 +32,12 @@
@foreach($managerOnlyProspects as $item) @php - $prospect = $item['prospect']; + $itemType = $item['type'] ?? 'prospect'; $management = $item['management']; $registeredBy = $item['registeredBy']; $progress = $item['progress']; + $companyName = $item['company_name']; + $businessNumber = $item['business_number']; $hqStatuses = \App\Models\Sales\SalesTenantManagement::$hqStatusLabels; $hqStatusOrder = \App\Models\Sales\SalesTenantManagement::$hqStatusOrder; $currentHqStep = $hqStatusOrder[$management->hq_status ?? 'pending'] ?? 0; @@ -45,71 +47,91 @@
-

{{ $prospect->company_name }}

-

{{ $prospect->business_number ?? '-' }}

+

{{ $companyName }}

+

{{ $businessNumber ?? '-' }}

- - 매니저 담당 - -
-
-

등록자

-

{{ $registeredBy?->name ?? '-' }}

+ @if($itemType === 'tenant') + + 계약 고객 + + @else + + 매니저 담당 + + @endif
+ @if($registeredBy) +
+

등록자

+

{{ $registeredBy->name }}

+
+ @endif
- {{-- 시나리오 버튼들 --}} -
- {{-- 영업 시나리오 (읽기 전용) --}} - + @if($itemType === 'prospect') + {{-- prospect 기반: 시나리오 버튼들 --}} +
+ {{-- 영업 시나리오 (읽기 전용) --}} + - {{-- 매니저 시나리오 (체크 가능) --}} - -
+ {{-- 매니저 시나리오 (체크 가능) --}} + +
+ @else + {{-- tenant 기반: 계약 완료 상태 표시 --}} +
+ + + + 계약 완료 고객 - 매니저로 관리 중 +
+ @endif - {{-- 진행률 바 --}} -
-
-
- 영업 - ({{ $progress['sales']['percentage'] }}%) + @if($itemType === 'prospect') + {{-- 진행률 바 (prospect 기반만) --}} +
+
+
+ 영업 + ({{ $progress['sales']['percentage'] }}%) +
+
+
+
-
-
+
+
+ 매니저 + {{ $progress['manager']['percentage'] }}% +
+
+
+
-
-
- 매니저 - {{ $progress['manager']['percentage'] }}% -
-
-
-
-
-
+ @endif {{-- 개발 진행 상태 (100% 완료 시) --}} @if($isHqEnabled)