diff --git a/app/Http/Controllers/Sales/SalesManagerController.php b/app/Http/Controllers/Sales/SalesManagerController.php index c78ec003..fd8e5179 100644 --- a/app/Http/Controllers/Sales/SalesManagerController.php +++ b/app/Http/Controllers/Sales/SalesManagerController.php @@ -68,6 +68,9 @@ public function store(Request $request) 'password' => 'required|string|min:4|confirmed', 'role_ids' => 'required|array|min:1', 'role_ids.*' => 'exists:roles,id', + 'company_name' => 'nullable|string|max:100', + 'biz_no' => 'nullable|string|max:20', + 'address' => 'nullable|string|max:255', 'documents' => 'nullable|array', 'documents.*.file' => 'nullable|file|max:10240', 'documents.*.document_type' => 'nullable|string', @@ -140,7 +143,7 @@ public function modalShow(int $id): View */ public function modalEdit(int $id): View { - $partner = User::with(['userRoles.role', 'salesDocuments', 'parent'])->findOrFail($id); + $partner = User::with(['userRoles.role', 'salesDocuments', 'parent', 'salesPartner'])->findOrFail($id); $roles = $this->service->getSalesRoles(); $currentRoleIds = $partner->userRoles->pluck('role_id')->toArray(); $documentTypes = SalesManagerDocument::DOCUMENT_TYPES; @@ -185,6 +188,9 @@ public function update(Request $request, int $id) 'password' => 'nullable|string|min:4|confirmed', 'role_ids' => 'required|array|min:1', 'role_ids.*' => 'exists:roles,id', + 'company_name' => 'nullable|string|max:100', + 'biz_no' => 'nullable|string|max:20', + 'address' => 'nullable|string|max:255', 'documents' => 'nullable|array', 'documents.*.file' => 'nullable|file|max:10240', 'documents.*.document_type' => 'nullable|string', diff --git a/app/Services/Sales/SalesManagerService.php b/app/Services/Sales/SalesManagerService.php index d3d1d54d..0a2d7cee 100644 --- a/app/Services/Sales/SalesManagerService.php +++ b/app/Services/Sales/SalesManagerService.php @@ -6,6 +6,7 @@ use App\Models\DepartmentUser; use App\Models\Role; use App\Models\Sales\SalesManagerDocument; +use App\Models\Sales\SalesPartner; use App\Models\User; use App\Models\UserRole; use Illuminate\Http\UploadedFile; @@ -57,6 +58,21 @@ public function createSalesPartner(array $data, array $documents = []): User // 4. 영업팀 부서 자동 할당 $this->assignSalesDepartment($user, $tenantId); + // 4-1. 사업자 정보 저장 (선택) + if (!empty($data['company_name']) || !empty($data['biz_no']) || !empty($data['address'])) { + SalesPartner::updateOrCreate( + ['user_id' => $user->id], + [ + 'partner_code' => SalesPartner::generatePartnerCode(), + 'partner_type' => 'sales', + 'status' => 'active', + 'company_name' => $data['company_name'] ?? null, + 'biz_no' => $data['biz_no'] ?? null, + 'address' => $data['address'] ?? null, + ] + ); + } + // 5. 첨부 서류 저장 if (!empty($documents)) { $this->uploadDocuments($user, $tenantId, $documents); @@ -93,6 +109,20 @@ public function updateSalesPartner(User $user, array $data, array $documents = [ $this->syncRoles($user, $tenantId, $data['role_ids']); } + // 2-1. 사업자 정보 업데이트 + if (array_key_exists('company_name', $data) || array_key_exists('biz_no', $data) || array_key_exists('address', $data)) { + $sp = SalesPartner::firstOrNew(['user_id' => $user->id]); + if (!$sp->exists) { + $sp->partner_code = SalesPartner::generatePartnerCode(); + $sp->partner_type = 'sales'; + $sp->status = 'active'; + } + $sp->company_name = $data['company_name'] ?? $sp->company_name; + $sp->biz_no = $data['biz_no'] ?? $sp->biz_no; + $sp->address = $data['address'] ?? $sp->address; + $sp->save(); + } + // 3. 새 첨부 서류 저장 if (!empty($documents)) { $this->uploadDocuments($user, $tenantId, $documents); diff --git a/resources/views/sales/managers/create.blade.php b/resources/views/sales/managers/create.blade.php index e707d521..50916ca8 100644 --- a/resources/views/sales/managers/create.blade.php +++ b/resources/views/sales/managers/create.blade.php @@ -171,6 +171,33 @@ class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none foc + +
전자서명 계약 시 자동으로 채워집니다 (선택사항)
+ +전자서명 계약 시 자동으로 채워집니다 (선택사항)
+