feat:유치 파트너 현황 1차/2차 수당 지급 현황 테이블 추가
- 컨트롤러에 매니저 수당 1차/2차 분할 데이터 추가 - 요약 카드를 5개 카드 + 1차/2차 테이블로 개선 - 내 활동 탭과 동일한 UI 패턴 적용 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -658,11 +658,49 @@ private function calculatePartnerSummaryStats(array $partnerIds, int $currentUse
|
||||
// 최종 예상 수당 (확정 + 예상 중 큰 값)
|
||||
$expectedCommission = max($confirmedCommission, $expectedFromFee);
|
||||
|
||||
// 지급 완료된 매니저 수당
|
||||
$paidManagerCommission = SalesCommission::where('manager_user_id', $currentUserId)
|
||||
->whereHas('partner', function ($query) use ($partnerIds) {
|
||||
$query->whereIn('user_id', $partnerIds);
|
||||
})
|
||||
->where('status', SalesCommission::STATUS_PAID)
|
||||
->sum('manager_commission');
|
||||
|
||||
// 지급예정 (승인됨)
|
||||
$scheduledManagerCommission = SalesCommission::where('manager_user_id', $currentUserId)
|
||||
->whereHas('partner', function ($query) use ($partnerIds) {
|
||||
$query->whereIn('user_id', $partnerIds);
|
||||
})
|
||||
->where('status', SalesCommission::STATUS_APPROVED)
|
||||
->sum('manager_commission');
|
||||
|
||||
// 납입대기 = 총 예상 - 지급완료 - 지급예정
|
||||
$pendingManagerCommission = max(0, $expectedCommission - $paidManagerCommission - $scheduledManagerCommission);
|
||||
|
||||
// 1차/2차 분할 (각 50%)
|
||||
$halfExpected = $expectedCommission / 2;
|
||||
$halfPending = $pendingManagerCommission / 2;
|
||||
$halfScheduled = $scheduledManagerCommission / 2;
|
||||
$halfPaid = $paidManagerCommission / 2;
|
||||
|
||||
return [
|
||||
'partner_count' => $partnerCount,
|
||||
'total_prospects' => $totalProspects,
|
||||
'total_conversions' => $totalConversions,
|
||||
'expected_commission' => $expectedCommission,
|
||||
'paid_commission' => $paidManagerCommission,
|
||||
'first_commission' => [
|
||||
'total' => (int)$halfExpected,
|
||||
'pending' => (int)$halfPending,
|
||||
'scheduled' => (int)$halfScheduled,
|
||||
'paid' => (int)$halfPaid,
|
||||
],
|
||||
'second_commission' => [
|
||||
'total' => (int)$halfExpected,
|
||||
'pending' => (int)$halfPending,
|
||||
'scheduled' => (int)$halfScheduled,
|
||||
'paid' => (int)$halfPaid,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user