fix: [settlement] 구독료 수당(매니저/파트너) 로직 3가지 버그 수정
- 매니저 미지정 시 구독료가 소실되던 버그 → 파트너 수당으로 편입 - deposit/balance 양쪽에서 구독료 이중 계상 → deposit에서만 1회 기록 - 파트너별 결산 탭에 +구독 배지 추가, select에 manager_user_id 포함
This commit is contained in:
@@ -611,7 +611,7 @@ private function getPartnerSettlement(\Closure $baseQuery): \Illuminate\Support\
|
||||
->select([
|
||||
'id', 'partner_id', 'management_id', 'payment_type',
|
||||
'partner_commission', 'manager_commission', 'referrer_commission',
|
||||
'status', 'scheduled_payment_date',
|
||||
'status', 'scheduled_payment_date', 'manager_user_id',
|
||||
])
|
||||
->orderBy('partner_id')
|
||||
->orderBy('scheduled_payment_date')
|
||||
|
||||
@@ -182,9 +182,19 @@ public function createCommission(int $managementId, string $paymentType, float $
|
||||
// 수당 계산
|
||||
$partnerCommission = $baseAmount * ($partnerRate / 100);
|
||||
|
||||
// 매니저 수당 = 구독료 1개월 (비율 아님)
|
||||
// 구독료 수당 (deposit에서만 1회 설정, balance에서는 0)
|
||||
$subscriptionFee = $contractProducts->sum('subscription_fee') ?? 0;
|
||||
$managerCommission = $management->manager_user_id ? $subscriptionFee : 0;
|
||||
$managerCommission = 0;
|
||||
|
||||
if ($paymentType === SalesCommission::PAYMENT_DEPOSIT && $subscriptionFee > 0) {
|
||||
if ($management->manager_user_id) {
|
||||
// 매니저 지정 → 매니저 수당
|
||||
$managerCommission = $subscriptionFee;
|
||||
} else {
|
||||
// 매니저 미지정 → 파트너 수당으로 편입
|
||||
$partnerCommission += $subscriptionFee;
|
||||
}
|
||||
}
|
||||
$managerRate = 0; // 매니저는 비율 기반이 아님
|
||||
|
||||
$referrerCommission = ($referrerId && $referrerRate > 0)
|
||||
@@ -654,9 +664,17 @@ private function recalculateCommission(SalesCommission $commission): void
|
||||
|
||||
$partnerCommission = $baseAmount * ($partnerRate / 100);
|
||||
|
||||
// 매니저 수당 = 구독료 1개월
|
||||
// 구독료 수당 (deposit에서만 1회 설정, balance에서는 0)
|
||||
$subscriptionFee = $contractProducts->sum('subscription_fee') ?? 0;
|
||||
$managerCommission = $management->manager_user_id ? $subscriptionFee : 0;
|
||||
$managerCommission = 0;
|
||||
|
||||
if ($commission->payment_type === SalesCommission::PAYMENT_DEPOSIT && $subscriptionFee > 0) {
|
||||
if ($management->manager_user_id) {
|
||||
$managerCommission = $subscriptionFee;
|
||||
} else {
|
||||
$partnerCommission += $subscriptionFee;
|
||||
}
|
||||
}
|
||||
|
||||
// 유치수당
|
||||
$referrerCommission = ($referrerId && $referrerRate > 0)
|
||||
|
||||
@@ -439,9 +439,14 @@ class="px-6 py-3 border-b-2 text-sm font-medium transition-colors">
|
||||
<tr class="hover:bg-gray-50">
|
||||
<td class="px-4 py-2 text-sm text-gray-400 pl-8">└</td>
|
||||
<td class="px-4 py-2 text-sm text-center">
|
||||
<span class="inline-flex px-2 py-0.5 text-xs rounded-full {{ $item->payment_type === 'deposit' ? 'bg-indigo-100 text-indigo-700' : 'bg-emerald-100 text-emerald-700' }}">
|
||||
{{ $item->payment_type === 'deposit' ? '계약금' : '잔금' }}
|
||||
</span>
|
||||
@if ($item->payment_type === 'deposit')
|
||||
<span class="inline-flex px-2 py-0.5 text-xs rounded-full bg-indigo-100 text-indigo-700">계약금</span>
|
||||
@if ($item->manager_commission > 0 || (!$item->manager_user_id && $item->partner_commission > 0))
|
||||
<span class="inline-flex px-1.5 py-0.5 text-[10px] rounded-full bg-orange-100 text-orange-700 ml-0.5">+구독</span>
|
||||
@endif
|
||||
@else
|
||||
<span class="inline-flex px-2 py-0.5 text-xs rounded-full bg-emerald-100 text-emerald-700">잔금</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-2 text-sm text-gray-700">{{ $item->management?->tenant?->company_name ?? '-' }}</td>
|
||||
<td class="px-4 py-2 text-sm text-right text-gray-900">{{ number_format($item->partner_commission) }}원</td>
|
||||
|
||||
Reference in New Issue
Block a user