feat:고객 서비스이용 계약서 - 고객 불러오기/계약번호 자동채번/기본값

- 테넌트(고객) 검색 API 추가 (searchTenants)
- 계약번호 자동 채번 API 추가 (CONTRACT-YYYYMMDD-N 형식)
- 고객 서비스이용 계약서 선택 시 "고객 불러오기" 버튼 표시
- 고객 선택 시 상호/사업자등록번호/주소/전화번호 자동 채움
- 총개발비 기본값 20,000,000 / 월구독료 기본값 500,000 자동 세팅
- TenantSearchModal 컴포넌트 추가

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-19 23:23:06 +09:00
parent abf424d10e
commit bcc95ffafa
3 changed files with 236 additions and 9 deletions

View File

@@ -13,6 +13,7 @@
use App\Models\ESign\EsignSigner;
use App\Models\ESign\EsignSignField;
use App\Models\ESign\EsignAuditLog;
use App\Models\Tenants\Tenant;
use App\Models\Tenants\TenantSetting;
use App\Services\Barobill\BarobillService;
use App\Services\GoogleCloudStorageService;
@@ -73,6 +74,65 @@ public function searchPartners(Request $request): JsonResponse
return response()->json(['success' => true, 'data' => $data]);
}
/**
* 고객(테넌트) 검색
*/
public function searchTenants(Request $request): JsonResponse
{
$q = trim($request->input('q', ''));
$query = Tenant::whereNull('deleted_at');
if ($q !== '') {
$query->where(function ($w) use ($q) {
$w->where('company_name', 'like', "%{$q}%")
->orWhere('business_num', 'like', "%{$q}%")
->orWhere('phone', 'like', "%{$q}%")
->orWhere('ceo_name', 'like', "%{$q}%");
});
}
$tenants = $query->orderBy('company_name')->limit(20)->get();
$data = $tenants->map(fn($t) => [
'id' => $t->id,
'company_name' => $t->company_name,
'business_num' => $t->business_num,
'ceo_name' => $t->ceo_name,
'address' => $t->address,
'phone' => $t->phone,
'email' => $t->email,
]);
return response()->json(['success' => true, 'data' => $data]);
}
/**
* 계약번호 자동 채번 (CONTRACT-YYYY-MMDD-N)
*/
public function generateContractNumber(): JsonResponse
{
$tenantId = session('selected_tenant_id', 1);
$today = now()->format('Ymd');
$prefix = "CONTRACT-{$today}-";
$lastContract = EsignContract::where('tenant_id', $tenantId)
->where('contract_code', 'like', "{$prefix}%")
->orderByRaw("CAST(SUBSTRING(contract_code, ?) AS UNSIGNED) DESC", [strlen($prefix) + 1])
->first();
$seq = 1;
if ($lastContract) {
$lastSeq = (int) str_replace($prefix, '', $lastContract->contract_code);
$seq = $lastSeq + 1;
}
return response()->json([
'success' => true,
'data' => ['contract_number' => $prefix . $seq],
]);
}
/**
* 법인도장 조회
*/