feat:E-Sign 리마인더 발송 라우트 및 컨트롤러 추가
detail.blade.php에서 호출하는 remind 엔드포인트가 누락되어 있었음.
POST /esign/contracts/{id}/remind 라우트 추가,
EsignApiController::remind() 메서드 구현 (상태 변경 + 감사 로그).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -275,6 +275,49 @@ public function send(Request $request, int $id): JsonResponse
|
||||
return response()->json(['success' => true, 'message' => '서명 요청이 발송되었습니다.']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 리마인더 발송
|
||||
*/
|
||||
public function remind(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$tenantId = session('selected_tenant_id', 1);
|
||||
$contract = EsignContract::forTenant($tenantId)->with('signers')->findOrFail($id);
|
||||
|
||||
if (! in_array($contract->status, ['pending', 'partially_signed'])) {
|
||||
return response()->json(['success' => false, 'message' => '리마인더를 발송할 수 없는 상태입니다.'], 422);
|
||||
}
|
||||
|
||||
// 다음 서명 대상자 찾기
|
||||
$nextSigner = $contract->signers()
|
||||
->whereIn('status', ['waiting', 'notified'])
|
||||
->orderBy('sign_order')
|
||||
->first();
|
||||
|
||||
if ($nextSigner) {
|
||||
$nextSigner->update(['status' => 'notified']);
|
||||
}
|
||||
|
||||
EsignAuditLog::create([
|
||||
'tenant_id' => $tenantId,
|
||||
'contract_id' => $contract->id,
|
||||
'action' => 'reminded',
|
||||
'ip_address' => $request->ip(),
|
||||
'user_agent' => $request->userAgent(),
|
||||
'metadata' => [
|
||||
'reminded_by' => auth()->id(),
|
||||
'target_signer_id' => $nextSigner?->id,
|
||||
],
|
||||
'created_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => $nextSigner
|
||||
? "{$nextSigner->name}에게 리마인더가 발송되었습니다."
|
||||
: '리마인더가 기록되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* PDF 다운로드
|
||||
*/
|
||||
|
||||
@@ -1411,6 +1411,7 @@
|
||||
Route::post('/{id}/cancel', [EsignApiController::class, 'cancel'])->whereNumber('id')->name('cancel');
|
||||
Route::post('/{id}/fields', [EsignApiController::class, 'configureFields'])->whereNumber('id')->name('fields');
|
||||
Route::post('/{id}/send', [EsignApiController::class, 'send'])->whereNumber('id')->name('send');
|
||||
Route::post('/{id}/remind', [EsignApiController::class, 'remind'])->whereNumber('id')->name('remind');
|
||||
Route::get('/{id}/download', [EsignApiController::class, 'download'])->whereNumber('id')->name('download');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user