fix:파트너 타입 판별 로직 개선 (management→registered_by 순 조회)
management.sales_partner_id가 미설정된 경우 registered_by(User ID)로 SalesPartner를 조회하여 partner_type 결정 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Sales\SalesCommission;
|
||||
use App\Models\Sales\SalesPartner;
|
||||
use App\Models\Sales\SalesScenarioChecklist;
|
||||
use App\Models\Sales\SalesTenantManagement;
|
||||
use App\Models\Sales\TenantProspect;
|
||||
@@ -149,11 +150,16 @@ private function getIndexData(Request $request): array
|
||||
if ($management) {
|
||||
$commission = SalesCommission::where('management_id', $management->id)->first();
|
||||
$prospect->commission = $commission;
|
||||
$prospect->partner_type = $management->salesPartner?->partner_type ?? 'individual';
|
||||
} else {
|
||||
$prospect->commission = null;
|
||||
$prospect->partner_type = 'individual';
|
||||
}
|
||||
|
||||
// 파트너 타입: management → registered_by 순으로 조회
|
||||
$partnerType = $management?->salesPartner?->partner_type;
|
||||
if (!$partnerType && $prospect->registered_by) {
|
||||
$partnerType = SalesPartner::where('user_id', $prospect->registered_by)->value('partner_type');
|
||||
}
|
||||
$prospect->partner_type = $partnerType ?? 'individual';
|
||||
}
|
||||
|
||||
// 두 시나리오 모두 100%인 것만 필터링
|
||||
@@ -196,11 +202,16 @@ private function getIndexData(Request $request): array
|
||||
if ($management) {
|
||||
$commission = SalesCommission::where('management_id', $management->id)->first();
|
||||
$prospect->commission = $commission;
|
||||
$prospect->partner_type = $management->salesPartner?->partner_type ?? 'individual';
|
||||
} else {
|
||||
$prospect->commission = null;
|
||||
$prospect->partner_type = 'individual';
|
||||
}
|
||||
|
||||
// 파트너 타입: management → registered_by 순으로 조회
|
||||
$partnerType = $management?->salesPartner?->partner_type;
|
||||
if (!$partnerType && $prospect->registered_by) {
|
||||
$partnerType = SalesPartner::where('user_id', $prospect->registered_by)->value('partner_type');
|
||||
}
|
||||
$prospect->partner_type = $partnerType ?? 'individual';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user