From dbe85efcefbf1d6e88151a4c3ce4da1b48e9ebea Mon Sep 17 00:00:00 2001 From: jjstyle Date: Fri, 23 Jan 2026 20:29:16 +0900 Subject: [PATCH] =?UTF-8?q?vrfcReqModel=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/NaverService.php | 90 +++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/app/Services/NaverService.php b/app/Services/NaverService.php index 3f202ff..92041c7 100644 --- a/app/Services/NaverService.php +++ b/app/Services/NaverService.php @@ -6,6 +6,7 @@ use CodeIgniter\CLI\CLI; use App\Libraries\NaverApiClient; use App\Models\Entities\VrfcReqModel; use App\Models\Entities\V2articleInfoModel; +use App\Models\Entities\V2articleInfoetcModel; use App\Models\Entities\V2stdailyModel; use App\Models\Entities\NaverRawStagingModel; use App\Models\Entities\ReceiptModel; @@ -24,6 +25,7 @@ class NaverService protected $receiptModel; protected $resultModel; protected $articleModel; + protected $articleEtcModel; public function __construct() { @@ -32,6 +34,7 @@ class NaverService $this->naverClient = new NaverApiClient(); $this->VrfcReqModel = new VrfcReqModel(); $this->articleModel = new V2ArticleInfoModel(); + $this->articleEtcModel = new V2articleInfoetcModel(); $this->V2stdailyModel = new V2stdailyModel(); $this->rawStagingModel = new NaverRawStagingModel(); $this->receiptModel = new ReceiptModel(); @@ -282,6 +285,7 @@ class NaverService $vrfcParam = $this->v2Parameter($articleNumber, $rawData, $payload); $articleInfoParam = $this->articleInfoParameter($articleNumber, $rawData, $payload); + $articleInfoEtcParam = $this->articleInfoEtcParameter($articleNumber, $rawData, $payload); try { switch ($payload['requestType']){ @@ -295,6 +299,26 @@ class NaverService if ($this->articleModel->insert($articleInfoParam)) { // 성공 로그 write_custom_log("articleInfo Insert Success :: vr_sq: $vr_sq", "INFO", "SERVICE"); + // article_info_etc 저장 + $articleInfoEtcParam['vr_sq'] = $vr_sq; + if ( $this->articleEtcModel->insert($articleInfoEtcParam)) { + write_custom_log("articleInfoEtc Insert Success :: vr_sq: $vr_sq", "INFO", "SERVICE"); + } else { + // 1. 모델에서 발생한 에러 정보 가져오기 + $dbError = $this->db->error(); + $lastQuery = (string)$this->articleEtcModel->getLastQuery(); + + // 2. 로그 기록 (에러 메시지 + 실패한 쿼리) + write_custom_log( + "DB_ERROR | Code: {$dbError['code']} | Message: {$dbError['message']} | Query: {$lastQuery}", + "ERROR", + "SERVICE" + ); + + // 필요하다면 예외를 던져서 상위(Worker)의 try-catch에서 처리하게 함 + throw new \Exception("ArticleInfoEtc Insert Failed: " . $dbError['message']); + } + } else { // 1. 모델에서 발생한 에러 정보 가져오기 $dbError = $this->db->error(); @@ -533,6 +557,72 @@ class NaverService ]; } + private function articleInfoEtcParameter($articleNumber, $rawData , $payload){ + // JSON 객체 안전하게 로드 + $address = $rawData['address'] ?? []; + $space = $rawData['space'] ?? []; + $price = $rawData['price'] ?? []; + $floor = $rawData['floor'] ?? []; + $seller = $rawData['seller'] ?? []; + $realtor = $rawData['realtor'] ?? []; + $files = $rawData['realtor']['file'] ?? []; + + // 공동 : 동 정보, 비공동 : 지번주소 + if ( $rawData['realEstateTypeCode'] == "A01"){ + $address2b = $address['buildingName']; + } else { + $address2b = $address['jibunAddress']; + } + + $ownerTypeCode = null; + $ownerTypeCodeResponse = isset($rawData['ownerTypeCode']) ?? null; + + if ($ownerTypeCodeResponse !== null ){ + switch ($ownerTypeCodeResponse) { + case "INDIV": + $ownerTypeCode = 0; + break; + case "CORP": + $ownerTypeCode = 1; + break; + case "FRGNR": + $ownerTypeCode = 2; + break; + case "DELEG": + $ownerTypeCode = 3; + break; + } + } + + return [ + 'atcl_no' => $articleNumber, + 'vir_addr_yn' => ($address['isVirtualAddress'] === true) ? 'Y' : (($address['isVirtualAddress'] === false) ? 'N' : null), + 'bild_no' => null, + 'vrfcMthdTpcd' => null, + 'cert_uncnfrm_status' => null, + 'expsStartYmdt' => $rawData['exposureStartDateTime'] ?? null, + 'vrfcAutoPassYn' => ($rawData['isAutoVerificationRequested'] ?? false) === true ? "Y" : "N", + 'address2a' => $address['liAddress'] ?? null, + 'address2b' => $address2b, + 'registerBookUniqueNo' => null, + 'ownerTypeCode' => $ownerTypeCode, + 'orgRepCphNo' => null, + 'orgRepTelNo' => null, + 'orgRltrNm' => null, + 'orgRepNm' => null, + 'smsSendTime' => null, + 'document_cert_method' => null, + 'noRgbkVrfcReqYn' => ($address['isUnregisteredVerificationRequested'] === true) ? 'Y' : (($address['isUnregisteredVerificationRequested'] === false) ? 'N' : null), + 'areaByBdbkVrfcReqYn' => ($address['isBuildingRegisterAreaCheckRequested'] === true) ? 'Y' : (($address['isBuildingRegisterAreaCheckRequested'] === false) ? 'N' : null), + 'orgAtclNo' => null, + 'atclStatCd' => null, + 'repNm' => $realtor['realtorName'] ?? null, + 'cpName' => $rawData['cpId'], + 'document_not_received' => null, + 'final_failure' => null, + ]; + } + /** * [REG] 신규 등록 */