From 7e47f086e9cc385c91ebe48fb48cb1425879e866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Mon, 2 Feb 2026 14:46:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:tenant=20=EA=B8=B0=EB=B0=98=20=EB=A7=A4?= =?UTF-8?q?=EB=8B=88=EC=A0=80=20=EC=A7=80=EC=A0=95=EB=8F=84=20=EC=9C=A0?= =?UTF-8?q?=EC=B9=98=20=ED=8C=8C=ED=8A=B8=EB=84=88=20=ED=98=84=ED=99=A9?= =?UTF-8?q?=EC=97=90=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - prospect_id가 NULL이고 tenant_id만 있는 매니저 지정도 조회 - type 필드로 prospect/tenant 기반 구분 - tenant 기반은 "계약 고객" 배지로 표시 - 진행률 대신 계약 완료 상태 표시 Co-Authored-By: Claude Opus 4.5 --- .../Sales/SalesDashboardController.php | 32 ++++++- .../partials/partner-activity.blade.php | 91 ++++++++++++------- 2 files changed, 89 insertions(+), 34 deletions(-) diff --git a/app/Http/Controllers/Sales/SalesDashboardController.php b/app/Http/Controllers/Sales/SalesDashboardController.php index a35a6ece..cf111b16 100644 --- a/app/Http/Controllers/Sales/SalesDashboardController.php +++ b/app/Http/Controllers/Sales/SalesDashboardController.php @@ -623,21 +623,47 @@ private function getPartnerActivitiesDetail($recruitedPartners, int $currentUser ->orderBy('created_at', 'desc') ->get(); - // 파트너가 매니저로 참여하는 가망고객 (다른 사람이 등록, 이 파트너가 매니저) + // 파트너가 매니저로 참여하는 건 (다른 사람이 등록, 이 파트너가 매니저) $managerProspects = collect(); - $managerManagements = SalesTenantManagement::where('manager_user_id', $partner->id) + + // 1. prospect 기반 매니저 지정 (가망고객 단계) + $prospectManagements = SalesTenantManagement::where('manager_user_id', $partner->id) ->whereNotNull('tenant_prospect_id') ->with(['tenantProspect.registeredBy']) ->get(); - foreach ($managerManagements as $mgmt) { + foreach ($prospectManagements as $mgmt) { $prospect = $mgmt->tenantProspect; // 본인이 등록한 건은 제외 (이미 allProspects에 포함됨) if ($prospect && $prospect->registered_by !== $partner->id) { $managerProspects->push([ + 'type' => 'prospect', 'prospect' => $prospect, 'management' => $mgmt, 'registeredBy' => $prospect->registeredBy, + 'company_name' => $prospect->company_name, + 'business_number' => $prospect->business_number, + ]); + } + } + + // 2. tenant 기반 매니저 지정 (이미 계약된 테넌트) + $tenantManagements = SalesTenantManagement::where('manager_user_id', $partner->id) + ->whereNull('tenant_prospect_id') + ->whereNotNull('tenant_id') + ->with(['tenant']) + ->get(); + + foreach ($tenantManagements as $mgmt) { + $tenant = $mgmt->tenant; + if ($tenant) { + $managerProspects->push([ + 'type' => 'tenant', + 'tenant' => $tenant, + 'management' => $mgmt, + 'registeredBy' => null, // 테넌트는 등록자 정보 없음 + 'company_name' => $tenant->company_name, + 'business_number' => $tenant->business_number, ]); } } diff --git a/resources/views/sales/dashboard/partials/partner-activity.blade.php b/resources/views/sales/dashboard/partials/partner-activity.blade.php index a3da4a02..ee64b85d 100644 --- a/resources/views/sales/dashboard/partials/partner-activity.blade.php +++ b/resources/views/sales/dashboard/partials/partner-activity.blade.php @@ -279,54 +279,83 @@
@foreach($activity['manager_prospects'] as $item) @php - $mProspect = $item['prospect']; $mManagement = $item['management']; $mRegisteredBy = $item['registeredBy']; - $mProgress = \App\Models\Sales\SalesScenarioChecklist::getProspectProgress($mProspect->id); + $mCompanyName = $item['company_name']; + $mBusinessNumber = $item['business_number']; + $mType = $item['type'] ?? 'prospect'; $mHqStatuses = \App\Models\Sales\SalesTenantManagement::$hqStatusLabels; $mHqStatusOrder = \App\Models\Sales\SalesTenantManagement::$hqStatusOrder; $mCurrentHqStep = $mHqStatusOrder[$mManagement->hq_status ?? 'pending'] ?? 0; - $isMHqEnabled = $mProgress['sales']['percentage'] >= 100 && $mProgress['manager']['percentage'] >= 100; + + // prospect 기반인 경우 진행률 조회 + $mProgress = null; + $isMHqEnabled = false; + if ($mType === 'prospect' && isset($item['prospect'])) { + $mProgress = \App\Models\Sales\SalesScenarioChecklist::getProspectProgress($item['prospect']->id); + $isMHqEnabled = $mProgress['sales']['percentage'] >= 100 && $mProgress['manager']['percentage'] >= 100; + } elseif ($mType === 'tenant') { + // tenant 기반은 이미 계약 완료 + $isMHqEnabled = true; + } @endphp
-

{{ $mProspect->company_name }}

-

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

+

{{ $mCompanyName }}

+

{{ $mBusinessNumber ?? '-' }}

- - 매니저만 진행 - + @if($mType === 'tenant') + + 계약 고객 + + @else + + 매니저만 진행 + + @endif
- {{-- 등록자 정보 --}} -
- 등록자: - {{ $mRegisteredBy?->name ?? '-' }} -
- {{-- 영업/매니저 진행률 --}} -
-
-
- 영업 - ({{ $mProgress['sales']['percentage'] }}%) + @if($mRegisteredBy) + {{-- 등록자 정보 (prospect 기반인 경우) --}} +
+ 등록자: + {{ $mRegisteredBy->name }} +
+ @endif + @if($mType === 'prospect' && $mProgress) + {{-- 영업/매니저 진행률 (prospect 기반) --}} +
+
+
+ 영업 + ({{ $mProgress['sales']['percentage'] }}%) +
+
+
+
-
-
+
+
+ 매니저 + {{ $mProgress['manager']['percentage'] }}% +
+
+
+
-
-
- 매니저 - {{ $mProgress['manager']['percentage'] }}% -
-
-
-
+ @elseif($mType === 'tenant') + {{-- 계약 고객 상태 표시 --}} +
+ + + + 계약 완료 고객
-
- {{-- 개발 진행 상태 (100% 완료 시) --}} + @endif + {{-- 개발 진행 상태 --}} @if($isMHqEnabled)