fix:서명 완료 후 다음 서명자 자동 알림 발송 추가
- submitSignature: 첫 번째 서명자 완료 시 다음 서명자에게 자동 이메일 발송 - send: sign_order_type이 parallel이면 모든 서명자에게 동시 발송 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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' => '서명이 완료되었습니다.']);
|
||||
|
||||
Reference in New Issue
Block a user