From 4f25e0e4a1729ab4aed9e97714884640fe2cd4e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=B3=B4=EA=B3=A4?= Date: Thu, 12 Feb 2026 16:46:57 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EC=84=9C=EB=AA=85=20=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?=ED=9B=84=20=EB=8B=A4=EC=9D=8C=20=EC=84=9C=EB=AA=85=EC=9E=90=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=20=EC=95=8C=EB=A6=BC=20=EB=B0=9C=EC=86=A1=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - submitSignature: 첫 번째 서명자 완료 시 다음 서명자에게 자동 이메일 발송 - send: sign_order_type이 parallel이면 모든 서명자에게 동시 발송 Co-Authored-By: Claude Opus 4.6 --- .../Controllers/ESign/EsignApiController.php | 19 ++++++++++---- .../ESign/EsignPublicController.php | 25 +++++++++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ESign/EsignApiController.php b/app/Http/Controllers/ESign/EsignApiController.php index 32347c8c..38afa2fa 100644 --- a/app/Http/Controllers/ESign/EsignApiController.php +++ b/app/Http/Controllers/ESign/EsignApiController.php @@ -258,11 +258,20 @@ public function send(Request $request, int $id): JsonResponse 'updated_by' => auth()->id(), ]); - // 첫 번째 서명자 상태 변경 + 메일 발송 - $nextSigner = $contract->signers()->orderBy('sign_order')->first(); - if ($nextSigner) { - $nextSigner->update(['status' => 'notified']); - Mail::to($nextSigner->email)->send(new EsignRequestMail($contract, $nextSigner)); + // 서명 순서 유형에 따라 알림 발송 + if ($contract->sign_order_type === 'parallel') { + // 동시 서명: 모든 서명자에게 발송 + foreach ($contract->signers as $s) { + $s->update(['status' => 'notified']); + Mail::to($s->email)->send(new EsignRequestMail($contract, $s)); + } + } else { + // 순차 서명: 첫 번째 서명자에게만 발송 + $nextSigner = $contract->signers()->orderBy('sign_order')->first(); + if ($nextSigner) { + $nextSigner->update(['status' => 'notified']); + Mail::to($nextSigner->email)->send(new EsignRequestMail($contract, $nextSigner)); + } } EsignAuditLog::create([ diff --git a/app/Http/Controllers/ESign/EsignPublicController.php b/app/Http/Controllers/ESign/EsignPublicController.php index 5552485e..fc772f99 100644 --- a/app/Http/Controllers/ESign/EsignPublicController.php +++ b/app/Http/Controllers/ESign/EsignPublicController.php @@ -8,6 +8,8 @@ use App\Models\ESign\EsignSigner; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; +use App\Mail\EsignRequestMail; +use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; use Illuminate\Support\Str; use Illuminate\View\View; @@ -243,6 +245,29 @@ public function submitSignature(Request $request, string $token): JsonResponse ]); } else { $contract->update(['status' => 'partially_signed']); + + // 다음 서명자에게 자동 알림 발송 (순차 서명) + $nextSigner = EsignSigner::withoutGlobalScopes() + ->where('contract_id', $contract->id) + ->whereIn('status', ['waiting', 'pending']) + ->orderBy('sign_order') + ->first(); + + if ($nextSigner) { + $nextSigner->update(['status' => 'notified']); + Mail::to($nextSigner->email)->send(new EsignRequestMail($contract, $nextSigner)); + + EsignAuditLog::create([ + 'tenant_id' => $contract->tenant_id, + 'contract_id' => $contract->id, + 'signer_id' => $nextSigner->id, + 'action' => 'sign_request_sent', + 'ip_address' => $request->ip(), + 'user_agent' => $request->userAgent(), + 'metadata' => ['triggered_by' => 'auto_after_sign'], + 'created_at' => now(), + ]); + } } return response()->json(['success' => true, 'message' => '서명이 완료되었습니다.']);