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 @@
{{ $prospect->company_name }}
-{{ $prospect->business_number ?? '-' }}
+{{ $companyName }}
+{{ $businessNumber ?? '-' }}
등록자
-{{ $registeredBy?->name ?? '-' }}
+ @if($itemType === 'tenant') + + 계약 고객 + + @else + + 매니저 담당 + + @endif등록자
+{{ $registeredBy->name }}
+