From 7e9dec8bd3971088dc1d8a9ede7dba6ede6aa869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Sat, 14 Feb 2026 11:11:32 +0900 Subject: [PATCH] =?UTF-8?q?feat:=EC=98=81=EC=97=85=ED=8C=8C=ED=8A=B8?= =?UTF-8?q?=EB=84=88=20=EB=93=B1=EB=A1=9D/=EC=88=98=EC=A0=95=EC=97=90=20?= =?UTF-8?q?=EC=82=AC=EC=97=85=EC=9E=90=20=EC=A0=95=EB=B3=B4(=EC=83=81?= =?UTF-8?q?=ED=98=B8,=20=EC=82=AC=EC=97=85=EC=9E=90=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=EB=B2=88=ED=98=B8,=20=EC=A3=BC=EC=86=8C)=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 컨트롤러 store/update 유효성 검사에 3개 필드 추가 - 서비스 create/update에서 SalesPartner 레코드 생성/업데이트 - 등록 폼(create.blade.php)에 사업자 정보 섹션 추가 - 수정 모달(edit-modal.blade.php)에 사업자 정보 섹션 추가 - 테스트 데이터 자동입력에 사업자 정보 포함 Co-Authored-By: Claude Opus 4.6 --- .../Sales/SalesManagerController.php | 8 ++++- app/Services/Sales/SalesManagerService.php | 30 ++++++++++++++++ .../views/sales/managers/create.blade.php | 35 +++++++++++++++++++ .../managers/partials/edit-modal.blade.php | 26 ++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) 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 + +
+

사업자 정보

+

전자서명 계약 시 자동으로 채워집니다 (선택사항)

+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+

역할 및 조직

@@ -544,6 +571,14 @@ function fillRandomData() { document.querySelector('input[name="password"]').value = password; document.querySelector('input[name="password_confirmation"]').value = password; + // 사업자 정보 + const companyInput = document.querySelector('input[name="company_name"]'); + const bizNoInput = document.querySelector('input[name="biz_no"]'); + const addressInput = document.querySelector('input[name="address"]'); + if (companyInput) companyInput.value = name + ' 개인사업자'; + if (bizNoInput) bizNoInput.value = randomNum(100, 999) + '-' + randomNum(10, 99) + '-' + randomNum(10000, 99999); + if (addressInput) addressInput.value = '서울특별시 강남구 테헤란로 ' + randomNum(1, 500) + '번길 ' + randomNum(1, 30); + // 역할 체크박스 모두 체크 document.querySelectorAll('input[name="role_ids[]"]').forEach(cb => { cb.checked = true; diff --git a/resources/views/sales/managers/partials/edit-modal.blade.php b/resources/views/sales/managers/partials/edit-modal.blade.php index 3484d410..e9186a9f 100644 --- a/resources/views/sales/managers/partials/edit-modal.blade.php +++ b/resources/views/sales/managers/partials/edit-modal.blade.php @@ -55,6 +55,32 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none foc
+ +
+

사업자 정보

+

전자서명 계약 시 자동으로 채워집니다 (선택사항)

+
+
+ + +
+
+ + +
+
+ + +
+
+
+

역할 *