feat:영업파트너 수정 모달에 개인/단체 유형 변경 기능 추가
- 승인 전(pending): 라디오 버튼으로 개인/단체 변경 가능 - 승인 후(approved): 읽기 전용 뱃지로 표시 - 유형 변경 시 수당률 자동 설정 (단체 30%, 개인 초기화) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -196,6 +196,7 @@ public function update(Request $request, int $id)
|
||||
'password' => 'nullable|string|min:4|confirmed',
|
||||
'role_ids' => 'required|array|min:1',
|
||||
'role_ids.*' => 'exists:roles,id',
|
||||
'partner_type' => 'nullable|in:individual,corporate',
|
||||
'company_name' => 'nullable|string|max:100',
|
||||
'biz_no' => 'nullable|string|max:20',
|
||||
'address' => 'nullable|string|max:255',
|
||||
|
||||
@@ -123,13 +123,27 @@ public function updateSalesPartner(User $user, array $data, array $documents = [
|
||||
$hasBizInfo = !empty($data['company_name']) || !empty($data['biz_no']) || !empty($data['address']);
|
||||
$existingSp = SalesPartner::where('user_id', $user->id)->first();
|
||||
|
||||
if ($hasBizInfo || $existingSp) {
|
||||
$hasPartnerType = !empty($data['partner_type']);
|
||||
if ($hasBizInfo || $existingSp || $hasPartnerType) {
|
||||
$sp = $existingSp ?? new SalesPartner(['user_id' => $user->id]);
|
||||
if (!$sp->exists) {
|
||||
$sp->partner_code = SalesPartner::generatePartnerCode();
|
||||
$sp->partner_type = 'individual';
|
||||
$sp->partner_type = $data['partner_type'] ?? 'individual';
|
||||
$sp->status = 'active';
|
||||
}
|
||||
// 승인 전에만 파트너 유형 변경 허용
|
||||
if ($hasPartnerType && $user->approval_status === 'pending') {
|
||||
$newType = $data['partner_type'];
|
||||
$sp->partner_type = $newType;
|
||||
// 단체 → 수당률 설정, 개인 → 수당률 초기화
|
||||
if ($newType === 'corporate') {
|
||||
$sp->commission_rate = 30.00;
|
||||
$sp->manager_commission_rate = 0;
|
||||
} else {
|
||||
$sp->commission_rate = $sp->getOriginal('commission_rate') ?? null;
|
||||
$sp->manager_commission_rate = $sp->getOriginal('manager_commission_rate') ?? null;
|
||||
}
|
||||
}
|
||||
$sp->company_name = $data['company_name'] ?? null;
|
||||
$sp->biz_no = $data['biz_no'] ?? null;
|
||||
$sp->address = $data['address'] ?? null;
|
||||
|
||||
@@ -92,6 +92,36 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none foc
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 파트너 유형 -->
|
||||
<div class="bg-gray-50 rounded-lg p-4 mb-4">
|
||||
<h3 class="text-sm font-semibold text-gray-800 mb-3">파트너 유형</h3>
|
||||
@if($partner->approval_status === 'pending')
|
||||
<div class="flex gap-4">
|
||||
<label class="flex items-center">
|
||||
<input type="radio" name="partner_type" value="individual"
|
||||
{{ ($partner->salesPartner?->partner_type ?? 'individual') === 'individual' ? 'checked' : '' }}
|
||||
class="w-4 h-4 text-blue-600 border-gray-300 focus:ring-blue-500">
|
||||
<span class="ml-2 text-sm text-gray-700">개인 (영업파트너)</span>
|
||||
</label>
|
||||
<label class="flex items-center">
|
||||
<input type="radio" name="partner_type" value="corporate"
|
||||
{{ ($partner->salesPartner?->partner_type ?? 'individual') === 'corporate' ? 'checked' : '' }}
|
||||
class="w-4 h-4 text-blue-600 border-gray-300 focus:ring-blue-500">
|
||||
<span class="ml-2 text-sm text-gray-700">단체 (그룹)</span>
|
||||
</label>
|
||||
</div>
|
||||
@else
|
||||
<div class="flex items-center gap-2">
|
||||
@if(($partner->salesPartner?->partner_type ?? 'individual') === 'corporate')
|
||||
<span class="px-2 py-1 text-xs font-medium rounded-full bg-amber-100 text-amber-800">단체</span>
|
||||
@else
|
||||
<span class="px-2 py-1 text-xs font-medium rounded-full bg-sky-100 text-sky-800">개인</span>
|
||||
@endif
|
||||
<span class="text-xs text-gray-400">승인 후에는 변경할 수 없습니다</span>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<!-- 역할 -->
|
||||
<div class="bg-gray-50 rounded-lg p-4 mb-4">
|
||||
<h3 class="text-sm font-semibold text-gray-800 mb-3">역할 <span class="text-red-500">*</span></h3>
|
||||
|
||||
Reference in New Issue
Block a user