diff --git a/app/Http/Controllers/Credit/CreditController.php b/app/Http/Controllers/Credit/CreditController.php index 469c0427..e7aeb8cc 100644 --- a/app/Http/Controllers/Credit/CreditController.php +++ b/app/Http/Controllers/Credit/CreditController.php @@ -6,6 +6,7 @@ use App\Models\Coocon\CooconConfig; use App\Models\Credit\CreditInquiry; use App\Services\Coocon\CooconService; +use App\Services\Nts\NtsBusinessService; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -78,31 +79,47 @@ public function search(Request $request): JsonResponse $companyKey = preg_replace('/[^0-9]/', '', $request->input('company_key')); - $service = new CooconService(); + $cooconService = new CooconService(); - if (!$service->hasConfig()) { + if (!$cooconService->hasConfig()) { return response()->json([ 'success' => false, 'error' => '쿠콘 API 설정이 없습니다. 설정을 먼저 등록해주세요.', ], 400); } - // 전체 신용정보 조회 - $apiResult = $service->getAllCreditInfo($companyKey); + // 전체 신용정보 조회 (쿠콘 API) + $apiResult = $cooconService->getAllCreditInfo($companyKey); + + // 국세청 사업자등록 상태 조회 + $ntsService = new NtsBusinessService(); + $ntsResult = $ntsService->getBusinessStatus($companyKey); // DB에 저장 $inquiry = CreditInquiry::createFromApiResponse( $companyKey, $apiResult, + $ntsResult, auth()->id() ); return response()->json([ 'success' => true, 'data' => $apiResult, + 'nts' => $ntsResult, 'inquiry_key' => $inquiry->inquiry_key, 'inquiry_id' => $inquiry->id, 'company_key' => $companyKey, + 'company_info' => [ + 'company_name' => $inquiry->company_name, + 'ceo_name' => $inquiry->ceo_name, + 'company_address' => $inquiry->company_address, + 'business_type' => $inquiry->business_type, + 'business_item' => $inquiry->business_item, + 'nts_status' => $inquiry->nts_status, + 'nts_status_label' => $inquiry->nts_status_label, + 'nts_tax_type' => $inquiry->nts_tax_type, + ], ]); } @@ -122,6 +139,13 @@ public function getRawData(string $inquiryKey): JsonResponse 'company_key' => $inquiry->company_key, 'formatted_company_key' => $inquiry->formatted_company_key, 'company_name' => $inquiry->company_name, + 'ceo_name' => $inquiry->ceo_name, + 'company_address' => $inquiry->company_address, + 'business_type' => $inquiry->business_type, + 'business_item' => $inquiry->business_item, + 'nts_status' => $inquiry->nts_status, + 'nts_status_label' => $inquiry->nts_status_label, + 'nts_tax_type' => $inquiry->nts_tax_type, 'inquired_at' => $inquiry->inquired_at->format('Y-m-d H:i:s'), 'status' => $inquiry->status, 'total_issue_count' => $inquiry->total_issue_count, @@ -164,8 +188,20 @@ private function transformToReportFormat(CreditInquiry $inquiry): array 'company_info' => [ 'company_key' => $inquiry->formatted_company_key, 'company_name' => $inquiry->company_name ?? '-', + 'ceo_name' => $inquiry->ceo_name ?? '-', + 'company_address' => $inquiry->company_address ?? '-', + 'business_type' => $inquiry->business_type ?? '-', + 'business_item' => $inquiry->business_item ?? '-', + 'establishment_date' => $inquiry->establishment_date?->format('Y-m-d') ?? '-', 'inquired_at' => $inquiry->inquired_at->format('Y년 m월 d일 H:i'), ], + 'nts_info' => [ + 'status' => $inquiry->nts_status ?? '-', + 'status_label' => $inquiry->nts_status_label, + 'tax_type' => $inquiry->nts_tax_type ?? '-', + 'closure_date' => $inquiry->nts_closure_date?->format('Y-m-d') ?? null, + 'is_active' => $inquiry->isNtsActive(), + ], 'summary' => [ 'total_issue_count' => $inquiry->total_issue_count, 'has_issue' => $inquiry->has_issue, diff --git a/app/Models/Credit/CreditInquiry.php b/app/Models/Credit/CreditInquiry.php index 222172d3..97edc1c6 100644 --- a/app/Models/Credit/CreditInquiry.php +++ b/app/Models/Credit/CreditInquiry.php @@ -15,6 +15,15 @@ class CreditInquiry extends Model 'inquiry_key', 'company_key', 'company_name', + 'ceo_name', + 'company_address', + 'business_type', + 'business_item', + 'establishment_date', + 'nts_status', + 'nts_status_code', + 'nts_tax_type', + 'nts_closure_date', 'user_id', 'inquired_at', 'short_term_overdue_cnt', @@ -29,18 +38,24 @@ class CreditInquiry extends Model 'raw_negative_info_cb', 'raw_suspension_info', 'raw_workout_info', + 'raw_company_info', + 'raw_nts_status', 'status', 'error_message', ]; protected $casts = [ 'inquired_at' => 'datetime', + 'establishment_date' => 'date', + 'nts_closure_date' => 'date', 'raw_summary' => 'array', 'raw_short_term_overdue' => 'array', 'raw_negative_info_kci' => 'array', 'raw_negative_info_cb' => 'array', 'raw_suspension_info' => 'array', 'raw_workout_info' => 'array', + 'raw_company_info' => 'array', + 'raw_nts_status' => 'array', 'short_term_overdue_cnt' => 'integer', 'negative_info_kci_cnt' => 'integer', 'negative_info_pb_cnt' => 'integer', @@ -121,6 +136,8 @@ public function getFormattedCompanyKeyAttribute(): string public function getAllRawData(): array { return [ + 'companyInfo' => $this->raw_company_info, + 'ntsStatus' => $this->raw_nts_status, 'summary' => $this->raw_summary, 'shortTermOverdue' => $this->raw_short_term_overdue, 'negativeInfoKCI' => $this->raw_negative_info_kci, @@ -131,22 +148,82 @@ public function getAllRawData(): array } /** - * API 응답으로부터 모델 생성 + * 국세청 상태가 정상(영업중)인지 확인 */ - public static function createFromApiResponse(string $companyKey, array $apiResult, ?int $userId = null): self + public function isNtsActive(): bool { + return $this->nts_status_code === '01'; + } + + /** + * 국세청 상태 라벨 + */ + public function getNtsStatusLabelAttribute(): string + { + return match ($this->nts_status_code) { + '01' => '계속사업자', + '02' => '휴업자', + '03' => '폐업자', + default => $this->nts_status ?: '미확인', + }; + } + + /** + * API 응답으로부터 모델 생성 + * + * @param string $companyKey 사업자번호 + * @param array $apiResult 쿠콘 API 결과 + * @param array|null $ntsResult 국세청 API 결과 + * @param int|null $userId 조회자 ID + */ + public static function createFromApiResponse( + string $companyKey, + array $apiResult, + ?array $ntsResult = null, + ?int $userId = null + ): self { // 요약 정보에서 건수 추출 $summaryData = $apiResult['summary']['data'] ?? []; $creditSummaryList = $summaryData['data']['creditSummaryList'][0] ?? $summaryData['creditSummaryList'][0] ?? []; + // 기업 기본정보 추출 (OA08) + $companyInfoData = $apiResult['companyInfo']['data']['data'] ?? $apiResult['companyInfo']['data'] ?? []; + $companyName = $companyInfoData['korentrnm'] ?? $companyInfoData['entrpNm'] ?? null; + $ceoName = $companyInfoData['korreprnm'] ?? $companyInfoData['reprNm'] ?? null; + $companyAddress = $companyInfoData['addr'] ?? $companyInfoData['address'] ?? null; + $businessType = $companyInfoData['bizcnd'] ?? $companyInfoData['indutyNm'] ?? null; + $businessItem = $companyInfoData['bizitm'] ?? $companyInfoData['indutyDetailNm'] ?? null; + $establishmentDate = null; + if (!empty($companyInfoData['estbDt']) || !empty($companyInfoData['estbDate'])) { + $estbDt = $companyInfoData['estbDt'] ?? $companyInfoData['estbDate']; + if (strlen($estbDt) === 8) { + $establishmentDate = substr($estbDt, 0, 4) . '-' . substr($estbDt, 4, 2) . '-' . substr($estbDt, 6, 2); + } + } + + // 국세청 상태 추출 + $ntsStatus = null; + $ntsStatusCode = null; + $ntsTaxType = null; + $ntsClosureDate = null; + if ($ntsResult && ($ntsResult['success'] ?? false)) { + $ntsData = $ntsResult['data'] ?? []; + $ntsStatus = $ntsData['b_stt'] ?? null; + $ntsStatusCode = $ntsData['b_stt_cd'] ?? null; + $ntsTaxType = $ntsData['tax_type'] ?? null; + if (!empty($ntsData['end_dt']) && strlen($ntsData['end_dt']) === 8) { + $ntsClosureDate = substr($ntsData['end_dt'], 0, 4) . '-' . substr($ntsData['end_dt'], 4, 2) . '-' . substr($ntsData['end_dt'], 6, 2); + } + } + // 성공/실패 상태 판단 $successCount = 0; - $totalCount = 6; + $totalCount = 7; // companyInfo 추가 $errors = []; - foreach (['summary', 'shortTermOverdue', 'negativeInfoKCI', 'negativeInfoCB', 'suspensionInfo', 'workoutInfo'] as $key) { + foreach (['companyInfo', 'summary', 'shortTermOverdue', 'negativeInfoKCI', 'negativeInfoCB', 'suspensionInfo', 'workoutInfo'] as $key) { if (isset($apiResult[$key]['success']) && $apiResult[$key]['success']) { $successCount++; } else { @@ -165,6 +242,20 @@ public static function createFromApiResponse(string $companyKey, array $apiResul 'user_id' => $userId, 'inquired_at' => now(), + // 기업 기본정보 + 'company_name' => $companyName, + 'ceo_name' => $ceoName, + 'company_address' => $companyAddress, + 'business_type' => $businessType, + 'business_item' => $businessItem, + 'establishment_date' => $establishmentDate, + + // 국세청 상태 + 'nts_status' => $ntsStatus, + 'nts_status_code' => $ntsStatusCode, + 'nts_tax_type' => $ntsTaxType, + 'nts_closure_date' => $ntsClosureDate, + // 요약 건수 'short_term_overdue_cnt' => $creditSummaryList['shorttermOverdueCnt'] ?? 0, 'negative_info_kci_cnt' => $creditSummaryList['negativeInfoBbCnt'] ?? 0, @@ -174,6 +265,8 @@ public static function createFromApiResponse(string $companyKey, array $apiResul 'workout_cnt' => $creditSummaryList['workoutCnt'] ?? 0, // 원본 데이터 + 'raw_company_info' => $apiResult['companyInfo'] ?? null, + 'raw_nts_status' => $ntsResult, 'raw_summary' => $apiResult['summary'] ?? null, 'raw_short_term_overdue' => $apiResult['shortTermOverdue'] ?? null, 'raw_negative_info_kci' => $apiResult['negativeInfoKCI'] ?? null, diff --git a/app/Services/Coocon/CooconService.php b/app/Services/Coocon/CooconService.php index bfea0bd3..476ddcd9 100644 --- a/app/Services/Coocon/CooconService.php +++ b/app/Services/Coocon/CooconService.php @@ -18,6 +18,7 @@ class CooconService /** * API ID 상수 */ + public const API_COMPANY_INFO = 'OA08'; // 기업 기본정보 public const API_CREDIT_SUMMARY = 'OA12'; // 신용요약정보 public const API_SHORT_TERM_OVERDUE = 'OA13'; // 단기연체정보 (한국신용정보원) public const API_NEGATIVE_INFO_KCI = 'OA14'; // 신용도판단정보 (한국신용정보원) @@ -29,6 +30,7 @@ class CooconService * API 이름 목록 */ public const API_NAMES = [ + self::API_COMPANY_INFO => '기업 기본정보', self::API_CREDIT_SUMMARY => '신용요약정보', self::API_SHORT_TERM_OVERDUE => '단기연체정보 (한국신용정보원)', self::API_NEGATIVE_INFO_KCI => '신용도판단정보 (한국신용정보원)', @@ -198,6 +200,20 @@ private function generateTransactionSequence(): string return date('YmdHis') . substr(microtime(), 2, 6); } + /** + * 기업 기본정보 조회 (OA08) + * + * @param string $companyKey 사업자번호, 법인번호, 업체코드 중 하나 + * @param string $idscdcg 식별자구분코드 (기본값: 09-사업자등록번호) + */ + public function getCompanyInfo(string $companyKey, string $idscdcg = '09'): array + { + return $this->callApi(self::API_COMPANY_INFO, [ + 'Companykey' => $companyKey, + 'idscdcg' => $idscdcg, + ]); + } + /** * 신용요약정보 조회 (OA12) * @@ -288,6 +304,9 @@ public function getAllCreditInfo(string $companyKey): array { $results = []; + // 기업 기본정보 + $results['companyInfo'] = $this->getCompanyInfo($companyKey); + // 신용요약정보 $results['summary'] = $this->getCreditSummary($companyKey); diff --git a/app/Services/Nts/NtsBusinessService.php b/app/Services/Nts/NtsBusinessService.php new file mode 100644 index 00000000..c64e3416 --- /dev/null +++ b/app/Services/Nts/NtsBusinessService.php @@ -0,0 +1,208 @@ +serviceKey = config('services.nts.service_key', 'EFI7Fchltxh8LNyMu%2BUE9GSklj4ZsJqpL1UAYP6S0ci9D7fqJA98RRdxJos8KxwwEr6L9GAuAEB6E9IA1v1j2Q%3D%3D'); + } + + /** + * 사업자등록 상태 조회 + * + * @param string $businessNumber 사업자등록번호 (10자리, 하이픈 없이) + * @return array + */ + public function getBusinessStatus(string $businessNumber): array + { + // 사업자번호에서 숫자만 추출 + $bizNo = preg_replace('/[^0-9]/', '', $businessNumber); + + if (strlen($bizNo) !== 10) { + return [ + 'success' => false, + 'error' => '사업자등록번호는 10자리여야 합니다.', + 'code' => 'INVALID_FORMAT', + ]; + } + + $url = self::API_URL . '?serviceKey=' . $this->serviceKey; + + Log::info('국세청 사업자등록 상태 조회', [ + 'biz_no' => $bizNo, + ]); + + try { + $response = Http::timeout(30) + ->withHeaders([ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]) + ->post($url, [ + 'b_no' => [$bizNo], + ]); + + $result = $response->json(); + + Log::info('국세청 API 응답', [ + 'biz_no' => $bizNo, + 'match_cnt' => $result['match_cnt'] ?? 0, + 'status_code' => $response->status(), + ]); + + if (!$response->successful()) { + return [ + 'success' => false, + 'error' => 'HTTP 오류: ' . $response->status(), + 'code' => 'HTTP_ERROR', + 'http_status' => $response->status(), + ]; + } + + $matchCnt = $result['match_cnt'] ?? 0; + + if ($matchCnt >= 1 && isset($result['data'][0])) { + $data = $result['data'][0]; + + return [ + 'success' => true, + 'data' => [ + 'b_no' => $data['b_no'] ?? $bizNo, + 'b_stt' => $data['b_stt'] ?? '', // 상태 (영업, 휴업, 폐업) + 'b_stt_cd' => $data['b_stt_cd'] ?? '', // 상태코드 (01: 계속사업자, 02: 휴업자, 03: 폐업자) + 'tax_type' => $data['tax_type'] ?? '', // 과세유형 + 'tax_type_cd' => $data['tax_type_cd'] ?? '', // 과세유형코드 + 'end_dt' => $data['end_dt'] ?? '', // 폐업일 + 'utcc_yn' => $data['utcc_yn'] ?? '', // 단위과세전환여부 + 'tax_type_change_dt' => $data['tax_type_change_dt'] ?? '', // 과세유형전환일 + 'invoice_apply_dt' => $data['invoice_apply_dt'] ?? '', // 세금계산서적용일 + 'rbf_tax_type' => $data['rbf_tax_type'] ?? '', // 직전과세유형 + 'rbf_tax_type_cd' => $data['rbf_tax_type_cd'] ?? '', // 직전과세유형코드 + ], + 'raw' => $result, + ]; + } + + // 조회 실패 (국세청에 등록되지 않은 사업자번호) + $errorMsg = $result['data'][0]['tax_type'] ?? '조회된 결과가 없습니다.'; + + return [ + 'success' => false, + 'error' => $errorMsg, + 'code' => 'NOT_FOUND', + 'raw' => $result, + ]; + } catch (\Exception $e) { + Log::error('국세청 API 호출 실패', [ + 'biz_no' => $bizNo, + 'error' => $e->getMessage(), + ]); + + return [ + 'success' => false, + 'error' => '국세청 API 호출 중 오류가 발생했습니다: ' . $e->getMessage(), + 'code' => 'EXCEPTION', + ]; + } + } + + /** + * 여러 사업자번호 일괄 상태 조회 + * + * @param array $businessNumbers 사업자등록번호 배열 + * @return array + */ + public function getBusinessStatusBulk(array $businessNumbers): array + { + $bizNos = array_map(function ($num) { + return preg_replace('/[^0-9]/', '', $num); + }, $businessNumbers); + + // 유효하지 않은 번호 필터링 + $validBizNos = array_filter($bizNos, fn($num) => strlen($num) === 10); + + if (empty($validBizNos)) { + return [ + 'success' => false, + 'error' => '유효한 사업자등록번호가 없습니다.', + 'code' => 'INVALID_FORMAT', + ]; + } + + $url = self::API_URL . '?serviceKey=' . $this->serviceKey; + + try { + $response = Http::timeout(30) + ->withHeaders([ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + ]) + ->post($url, [ + 'b_no' => array_values($validBizNos), + ]); + + $result = $response->json(); + + if (!$response->successful()) { + return [ + 'success' => false, + 'error' => 'HTTP 오류: ' . $response->status(), + 'code' => 'HTTP_ERROR', + ]; + } + + return [ + 'success' => true, + 'data' => $result['data'] ?? [], + 'match_cnt' => $result['match_cnt'] ?? 0, + 'raw' => $result, + ]; + } catch (\Exception $e) { + return [ + 'success' => false, + 'error' => '국세청 API 호출 중 오류가 발생했습니다: ' . $e->getMessage(), + 'code' => 'EXCEPTION', + ]; + } + } + + /** + * 사업자 상태 코드를 한글로 변환 + */ + public static function getStatusLabel(string $statusCode): string + { + return match ($statusCode) { + '01' => '계속사업자', + '02' => '휴업자', + '03' => '폐업자', + default => '알 수 없음', + }; + } + + /** + * 사업자 상태가 정상(영업중)인지 확인 + */ + public static function isActiveStatus(string $statusCode): bool + { + return $statusCode === '01'; + } +} diff --git a/database/migrations/2026_01_22_203001_add_company_info_to_credit_inquiries_table.php b/database/migrations/2026_01_22_203001_add_company_info_to_credit_inquiries_table.php new file mode 100644 index 00000000..2844e114 --- /dev/null +++ b/database/migrations/2026_01_22_203001_add_company_info_to_credit_inquiries_table.php @@ -0,0 +1,55 @@ +string('ceo_name')->nullable()->after('company_name')->comment('대표자명'); + $table->string('company_address')->nullable()->after('ceo_name')->comment('회사 주소'); + $table->string('business_type')->nullable()->after('company_address')->comment('업종'); + $table->string('business_item')->nullable()->after('business_type')->comment('업태'); + $table->date('establishment_date')->nullable()->after('business_item')->comment('설립일'); + + // 국세청 사업자등록 상태 + $table->string('nts_status', 20)->nullable()->after('establishment_date')->comment('국세청 상태 (영업/휴업/폐업)'); + $table->string('nts_status_code', 2)->nullable()->after('nts_status')->comment('국세청 상태코드 (01/02/03)'); + $table->string('nts_tax_type', 50)->nullable()->after('nts_status_code')->comment('과세유형'); + $table->date('nts_closure_date')->nullable()->after('nts_tax_type')->comment('폐업일'); + + // API 원본 데이터 + $table->json('raw_company_info')->nullable()->after('raw_workout_info')->comment('OA08 기업기본정보 원본'); + $table->json('raw_nts_status')->nullable()->after('raw_company_info')->comment('국세청 상태조회 원본'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('credit_inquiries', function (Blueprint $table) { + $table->dropColumn([ + 'ceo_name', + 'company_address', + 'business_type', + 'business_item', + 'establishment_date', + 'nts_status', + 'nts_status_code', + 'nts_tax_type', + 'nts_closure_date', + 'raw_company_info', + 'raw_nts_status', + ]); + }); + } +}; diff --git a/resources/views/credit/inquiry/index.blade.php b/resources/views/credit/inquiry/index.blade.php index ab3ab536..1e51f996 100644 --- a/resources/views/credit/inquiry/index.blade.php +++ b/resources/views/credit/inquiry/index.blade.php @@ -98,11 +98,11 @@ class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
| 조회키 | 사업자번호 | -업체명 | +업체정보 | +국세청 | 조회일시 | -상태 | +API상태 | 이슈 | 조회자 | 액션 | @@ -111,9 +111,24 @@ class="w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500">
|---|---|---|---|---|---|---|---|---|---|---|
| {{ substr($inquiry->inquiry_key, 0, 16) }}... | {{ $inquiry->formatted_company_key }} | -{{ $inquiry->company_name ?? '-' }} | +
+ {{ $inquiry->company_name ?? '-' }}
+ @if($inquiry->ceo_name)
+ 대표: {{ $inquiry->ceo_name }}
+ @endif
+ |
+ + @if($inquiry->nts_status_code === '01') + {{ $inquiry->nts_status_label }} + @elseif($inquiry->nts_status_code === '02') + {{ $inquiry->nts_status_label }} + @elseif($inquiry->nts_status_code === '03') + {{ $inquiry->nts_status_label }} + @else + {{ $inquiry->nts_status_label }} + @endif + | {{ $inquiry->inquired_at->format('Y-m-d H:i') }} |
@if($inquiry->status === 'success')
@@ -478,8 +493,8 @@ class="flex-1 bg-blue-600 text-white py-2 rounded-lg hover:bg-blue-700 transitio
// 원본 데이터 패널 렌더링 (기존 종합 패널과 동일)
function renderRawDataPanel(data, inquiry) {
- // 이전에 구현한 종합 패널 렌더링 로직을 그대로 사용
- return renderComprehensivePanel(data, inquiry.company_key);
+ // inquiry 객체에서 회사 정보 포함해서 렌더링
+ return renderComprehensivePanel(data, inquiry);
}
// 종합 패널 렌더링 함수들 (기존 코드와 동일)
@@ -496,20 +511,63 @@ function renderRawDataPanel(data, inquiry) {
'3': '법인등록번호',
};
- function renderComprehensivePanel(data, companyKey) {
+ function renderComprehensivePanel(data, inquiry) {
let html = '';
+ const companyKey = inquiry.company_key || inquiry;
- // 헤더
+ // 회사 정보 헤더
html += `
-
`;
// 신용요약
html += renderSummaryCard(data.summary);
+ // 기업기본정보 섹션 (OA08)
+ if (data.companyInfo) {
+ html += renderSection('기업 기본정보', 'NICE', 'OA08', data.companyInfo, renderCompanyInfoDetail);
+ }
+
+ // 국세청 상태 섹션
+ if (data.ntsStatus) {
+ html += renderSection('사업자등록 상태', '국세청', 'NTS', { success: data.ntsStatus?.success, data: data.ntsStatus }, renderNtsStatusDetail);
+ }
+
// 각 섹션
html += renderSection('단기연체정보', '한국신용정보원', 'OA13', data.shortTermOverdue, renderShortTermOverdue);
html += renderSection('신용도판단정보', '한국신용정보원', 'OA14', data.negativeInfoKCI, renderNegativeInfoKCI);
@@ -520,6 +578,54 @@ function renderComprehensivePanel(data, companyKey) {
return html;
}
+ function renderNtsStatusBadge(statusCode, statusLabel) {
+ const colors = {
+ '01': 'bg-green-100 text-green-700',
+ '02': 'bg-yellow-100 text-yellow-700',
+ '03': 'bg-red-100 text-red-700',
+ };
+ const colorClass = colors[statusCode] || 'bg-gray-100 text-gray-600';
+ return `${statusLabel}`;
+ }
+
+ function renderCompanyInfoDetail(data) {
+ const info = data?.data || data || {};
+ if (!info || Object.keys(info).length === 0) {
+ return renderNoData('기업 기본정보가 없습니다.');
+ }
+
+ let html = '신용도판단 종합 조회 결과-사업자/법인번호: ${formatBusinessNumber(companyKey)} +
+
+
+ + ${inquiry.company_name || '업체명 미확인'} + ${inquiry.nts_status_label ? renderNtsStatusBadge(inquiry.nts_status_code, inquiry.nts_status_label) : ''} ++
+
+
+ 사업자번호
+ ${formatBusinessNumber(companyKey)}
+
+ ${inquiry.ceo_name ? `
+
+ 대표자
+ ${inquiry.ceo_name}
+ ` : ''}
+ ${inquiry.company_address ? `
+
+ 주소
+ ${inquiry.company_address}
+ ` : ''}
+ ${inquiry.business_type || inquiry.business_item ? `
+
+ 업종/업태
+ ${[inquiry.business_type, inquiry.business_item].filter(Boolean).join(' / ')}
+ ` : ''}
+ ${inquiry.nts_tax_type ? `
+
+ 과세유형
+ ${inquiry.nts_tax_type}
+ ` : ''}
+ ';
+ const fields = [
+ ['korentrnm', '업체명'], ['korreprnm', '대표자명'], ['bizno', '사업자번호'],
+ ['crpno', '법인번호'], ['addr', '주소'], ['bizcnd', '업종'], ['bizitm', '업태'],
+ ['estbDt', '설립일'], ['empCnt', '종업원수'], ['salesAmt', '매출액']
+ ];
+ fields.forEach(([key, label]) => {
+ if (info[key]) {
+ html += ` ';
+ return html;
+ }
+
+ function renderNtsStatusDetail(data) {
+ const nts = data?.data || {};
+ if (!nts || Object.keys(nts).length === 0) {
+ return renderNoData('국세청 사업자등록 상태 정보가 없습니다.');
+ }
+
+ let html = '${label}: ${info[key]} `;
+ }
+ });
+ html += '';
+ html += ` ';
+ return html;
+ }
+
function renderSummaryCard(result) {
if (!result || !result.success) {
return `사업자번호: ${nts.b_no || '-'} `;
+ html += `상태: ${nts.b_stt || '-'} `;
+ html += `과세유형: ${nts.tax_type || '-'} `;
+ if (nts.end_dt) {
+ html += `폐업일: ${nts.end_dt} `;
+ }
+ html += '신용요약정보 조회 실패
- 리포트 형식은 추후 구현 예정입니다. -sales.sam.kr/creditreport/index.php 형태의 코드가 필요합니다. -
- 조회 요약-
- 총 이슈 건수: ${data.summary?.total_issue_count || 0}건
- 단기연체: ${data.summary?.short_term_overdue_cnt || 0}건
- 신용도판단(KCI): ${data.summary?.negative_info_kci_cnt || 0}건
- 공공정보: ${data.summary?.negative_info_pb_cnt || 0}건
- 신용도판단(CB): ${data.summary?.negative_info_cb_cnt || 0}건
- 당좌정지: ${data.summary?.suspension_info_cnt || 0}건
- 법정관리: ${data.summary?.workout_cnt || 0}건
+
+
+
+ `;
+ }
+
+ function renderNtsStatusBadgeLarge(statusLabel, isActive) {
+ if (!statusLabel) return '';
+ const colorClass = isActive ? 'bg-green-100 text-green-800 border-green-300' : 'bg-red-100 text-red-800 border-red-300';
+ return `${statusLabel}`;
+ }
+
+ function renderReportSummaryItem(label, count) {
+ const hasIssue = count > 0;
+ const bgColor = hasIssue ? 'bg-red-50 border-red-200' : 'bg-green-50 border-green-200';
+ const textColor = hasIssue ? 'text-red-700' : 'text-green-700';
+ return `
+
+
+
+
+
+
+
+
+ + ${company.company_name || '업체명 미확인'} ++${company.company_key || '-'} +
+ ${renderNtsStatusBadgeLarge(nts.status_label, nts.is_active)}
+
+
+ ${company.ceo_name ? `
+ 대표자: ${company.ceo_name} ` : ''}
+ ${company.company_address && company.company_address !== '-' ? `주소: ${company.company_address} ` : ''}
+ ${company.business_type && company.business_type !== '-' ? `업종: ${company.business_type} ` : ''}
+ ${company.business_item && company.business_item !== '-' ? `업태: ${company.business_item} ` : ''}
+ ${company.establishment_date && company.establishment_date !== '-' ? `설립일: ${company.establishment_date} ` : ''}
+ ${nts.tax_type && nts.tax_type !== '-' ? `과세유형: ${nts.tax_type} ` : ''}
+
+ 조회일시: ${company.inquired_at || '-'}
+
+
+
+ ${nts.closure_date ? `
+ 신용 정보 요약+
+
+
+
+ ${hasIssue
+ ? ''
+ : ''
+ }
+
+
+
+ + ${hasIssue ? `총 ${summary.total_issue_count}건의 신용 이슈가 발견되었습니다.` : '신용 이슈가 없습니다.'} + ++ ${hasIssue ? '상세 내용을 확인하시기 바랍니다.' : '깨끗한 신용 상태입니다.'} + +
+ ${renderReportSummaryItem('단기연체', summary.short_term_overdue_cnt)}
+ ${renderReportSummaryItem('신용도판단(KCI)', summary.negative_info_kci_cnt)}
+ ${renderReportSummaryItem('공공정보', summary.negative_info_pb_cnt)}
+ ${renderReportSummaryItem('신용도판단(CB)', summary.negative_info_cb_cnt)}
+ ${renderReportSummaryItem('당좌정지', summary.suspension_info_cnt)}
+ ${renderReportSummaryItem('법정관리', summary.workout_cnt)}
+
+
+
+ ` : ''}
+
+
+
+
+
+ 폐업 사업자입니다 +폐업일: ${nts.closure_date} +
+
`;
}
${label} +${count || 0} +건 |