From 29b40ad2bc375d2763a74e86b307bb2dff569270 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:56:40 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EC=82=AC=EC=97=85=EC=9E=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EB=AF=B8=EC=9E=85=EB=A0=A5=20=EC=8B=9C=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20SalesPartner=20=EB=A0=88=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=83=9D=EC=84=B1=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기존 레코드가 있거나 실제 값이 입력된 경우에만 저장 - SoftDelete 스코프 충돌 방지를 위해 where 쿼리로 변경 Co-Authored-By: Claude Opus 4.6 --- app/Services/Sales/SalesManagerService.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Services/Sales/SalesManagerService.php b/app/Services/Sales/SalesManagerService.php index a629451d..80a90e3a 100644 --- a/app/Services/Sales/SalesManagerService.php +++ b/app/Services/Sales/SalesManagerService.php @@ -110,16 +110,19 @@ public function updateSalesPartner(User $user, array $data, array $documents = [ } // 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]); + $hasBizInfo = !empty($data['company_name']) || !empty($data['biz_no']) || !empty($data['address']); + $existingSp = SalesPartner::where('user_id', $user->id)->first(); + + if ($hasBizInfo || $existingSp) { + $sp = $existingSp ?? new SalesPartner(['user_id' => $user->id]); if (!$sp->exists) { $sp->partner_code = SalesPartner::generatePartnerCode(); $sp->partner_type = 'individual'; $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->company_name = $data['company_name'] ?? null; + $sp->biz_no = $data['biz_no'] ?? null; + $sp->address = $data['address'] ?? null; $sp->save(); }