fix:매니저 참여 건 조회에 tenant 기반도 포함

- getManagerOnlyProspects에서 tenant_id만 있는 경우도 조회
- prospect 기반과 tenant 기반 구분하여 UI 표시
- tenant 기반은 "계약 고객" 배지와 계약 완료 상태 표시

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-02 15:09:28 +09:00
parent d472d10439
commit 0dd50d6b36
2 changed files with 124 additions and 65 deletions

View File

@@ -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;
}
/**