Files
confirms/app/Controllers/V2/M701.php
yangsh 2c96bd12de
Some checks failed
Close Pull Request / main (pull_request_target) Has been cancelled
상세수정
2026-02-04 10:48:51 +09:00

1705 lines
87 KiB
PHP

<?php
namespace App\Controllers\V2;
use App\Controllers\BaseController;
use App\Libraries\FormValidation;
use App\Libraries\MyUpload;
use App\Libraries\NaverApiClient;
use App\Models\common\CodeModel;
use App\Models\results\M415Model;
use App\Models\v2\M701Model;
use App\Models\v2\M710Model;
use Exception;
use function PHPUnit\Framework\throwException;
class M701 extends BaseController
{
private $model, $codeModel;
public function __construct()
{
$this->model = new M701Model();
$this->codeModel = new CodeModel();
}
public function lists(): string
{
$codes = $this->codeModel->getCodeLists(['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'ARTICLE_TYPE']); // 코드조회
$sido = $this->model->getAreaList(); // 지역조회
$bonbu = $this->model->getBonbuList();
$team = $this->model->getTeamList();
$user = $this->model->getUserList();
$this->data['sido'] = $sido;
$this->data['bonbu'] = $bonbu;
$this->data['team'] = $team;
$this->data['user'] = $user;
$this->data['codes'] = $codes;
return view("pages/v2/m701/lists", $this->data);
}
public function getResultList()
{
$start = (int) $this->request->getGet('start') ?: 0;
$end = (int) $this->request->getGet('length') ?: 10;
$data = [
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
'srcSido' => $this->request->getGet('srcSido'), // 시도
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
'bonbu' => $this->request->getGet('bonbu'), // 본부
'team' => $this->request->getGet('team'), // 팀
'damdang' => $this->request->getGet('damdang'), // 담당
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
'corp_own' => $this->request->getGet('corp_own'), // 법인
];
$totalCount = $this->model->getTotalCount($data);
$datas = $this->model->getResultList($start, $end, $data);
return $this->response->setJSON(body: [
'recordsTotal' => $totalCount,
'recordsFiltered' => $totalCount,
'data' => $datas,
]);
}
// 엑셀 다운로드
public function excel()
{
try {
$data = [
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
'srcSido' => $this->request->getGet('srcSido'), // 시도
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
'bonbu' => $this->request->getGet('bonbu'), // 본부
'team' => $this->request->getGet('team'), // 팀
'damdang' => $this->request->getGet('damdang'), // 담당
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
'corp_own' => $this->request->getGet('corp_own'), // 법인
];
$datas = $this->model->getExcelList($data);
return $this->response->setJSON(body: [
'data' => $datas,
]);
} catch (\Exception $e) {
$e->getPrevious()->getTraceAsString();
}
}
// 상세화면
public function detail($id = null)
{
$id = (int) $id;
$naver = new NaverApiClient();
if ($id <= 0) {
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
}
$codes = $this->codeModel->getCodeLists(['VRFCREQ_WAY', 'CONFIRM_RESULT_D11', 'CONFIRM_RESULT_T11', 'CONSULTANT_COMMENT', 'STEP_VERIFICATION', 'TEL_FAIL_CAUSE']); // 코드조회
$record = $this->model->getRecordInfo($id, '1'); // 홍보확인서
$regist = $this->model->getRecordInfo($id, '2'); // 등기부등본
$tel = $this->model->getRecordInfo($id, '3'); // 녹취파일
$memo = $this->model->getMemo($id); // 메모
$data = $this->model->getDetail($id);
$history = $this->model->getHistory($id);
$complexList = [];
$ptpList = [];
// 아파트단지목록
$complexList = $naver->complexList($data['address_code']);
// 평형목록
$ptpList = $naver->ptpList($data['hscp_no']);
$hscp_info = [];
if (!empty($data['hscp_no'])) {
$apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
$villa_rlet_type_cd = ['A05', 'A06'];
if (in_array($data['rlet_type_cd'], $apt_rlet_type_cd)) { // apt 단지
$detail_hscp = $naver->aptDetail($data['hscp_no']);
}
if (in_array($data['rlet_type_cd'], $villa_rlet_type_cd)) { // villa 단지
$detail_hscp = $naver->villaDetail($data['hscp_no']);
}
$hscp_info = $detail_hscp['result'];
}
$this->data['codes'] = $codes;
$this->data['record'] = $record;
$this->data['regist'] = $regist;
$this->data['tel'] = $tel;
$this->data['memo'] = $memo;
$this->data['data'] = $data;
$this->data['history'] = $history;
$this->data['complexList'] = $complexList;
$this->data['ptpList'] = $ptpList;
$this->data['detail_hscp'] = $hscp_info;
// print_r($data);
// print ('===================');
// print_r($complexList);
// print ('===================');
// print_r($ptpList);
// exit;
return view("pages/v2/m701/detail", $this->data);
}
// 가격수정
public function changePrice()
{
$naver = new NaverApiClient();
try {
$data = [
'rcpt_key' => $this->request->getPost('rcpt_key'),
'trade_type' => $this->request->getPost('trade_type_cd'),
'atcl_amt1' => $this->request->getPost('atcl_amt1'),
'atcl_amt2' => $this->request->getPost('atcl_amt2'),
'atcl_amt3' => $this->request->getPost('atcl_amt3'),
'atcl_amt4' => $this->request->getPost('atcl_amt4'),
'isale_amt' => $this->request->getPost('isale_amt'),
'prem_amt' => $this->request->getPost('prem_amt'),
];
// UPDATE v2_vrfc_req
$this->model->changePrice($data);
// API 호출
$detail = $this->model->getDetail($data['rcpt_key']);
$priceInfo = $naver->priceChange($detail['atcl_no'], $detail['deal_amt'], $detail['wrrnt_amt'], $detail['lease_amt'], $detail['isale_amt'], $detail['prem_amt'], $detail['charger']);
// print_r($priceInfo['error']);
// exit;
$priceInfo = $priceInfo['error'];
if ($priceInfo['code'] !== 'success') {
$return = $priceInfo['error'] ?? null;
if (is_array($return) && isset($return['code'], $return['message'])) {
$err_time = date("Y-m-d H:i:s");
$this->model->saveApiErr($data['rcpt_key'], $return['code'], $return['message'], $err_time, $detail['atcl_no']);
throw new \Exception("가격수정 오류: " . $return['message']);
}
throw new \Exception($priceInfo['message']);
}
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
// 정보수정
public function modifyInfo()
{
$naver = new NaverApiClient();
try {
$atcl_vr_sq = $this->request->getPost('rcpt_key'); // 순번(vr_sq)
$atcl_hscp_nm = $this->request->getPost('atcl_hscp_nm'); // 화면에서 선택한 단지명
$atcl_ptp_nm = $this->request->getPost('atcl_ptp_nm'); // 화면에서 선택한 평형명
$atcl_vrfc_type = $this->request->getPost('atcl_vrtc_way'); // 검증구분
$trade_type = $this->request->getPost('trade_type_cd'); // 거래구분
$atcl_addr1 = $this->request->getPost('atcl_addr1'); // 상세주소1 폐기 예정
$atcl_addr1a = $this->request->getPost('atcl_addr1a'); // 리 주소
$atcl_addr1b = $this->request->getPost('atcl_addr1b'); // 공동 : 동 주소, 비공동 : 지번주소
$atcl_addr2 = $this->request->getPost('atcl_addr2'); // 상세주소2
$atcl_hscp_no = $this->request->getPost('atcl_hscp_no'); // 단지번호
$atcl_ptp_no = $this->request->getPost('atcl_ptp_no'); // 평형번호
$atcl_amt1 = $this->request->getPost('atcl_amt1'); // 매매 가격
$atcl_amt2 = $this->request->getPost('atcl_amt2'); // 전세 가격
$atcl_amt3 = $this->request->getPost('atcl_amt3'); // 월세 가격
$atcl_amt4 = $this->request->getPost('atcl_amt4'); // 분양권매매 가격 2
$isale_amt = $this->request->getPost('isale_amt'); // 분양가
$prem_amt = $this->request->getPost('prem_amt'); // 프리미엄가
$atcl_floor = $this->request->getPost('atcl_floor'); // 층
$atcl_floor2 = $this->request->getPost('atcl_floor2'); // 총층
$price_ignore = $this->request->getPost('price_ignore'); // 가격무시 체크여부
$return = "";
if ($price_ignore != '1') {
if ($trade_type == 'A1') {
$return = limitHscpMarketPriceInfo($this, $trade_type, $atcl_hscp_no, $atcl_ptp_no, $atcl_amt1);
} else if ($trade_type == 'B1') {
$return = limitHscpMarketPriceInfo($this, $trade_type, $atcl_hscp_no, $atcl_ptp_no, $atcl_amt2);
}
}
if (empty($return)) {
$this->model->modifyInfo($atcl_vr_sq, $atcl_hscp_nm, $atcl_ptp_nm, $atcl_vrfc_type, $trade_type, $atcl_addr1b, $atcl_addr1a, $atcl_addr1b, $atcl_addr2, $atcl_hscp_no, $atcl_ptp_no, $atcl_amt1, $atcl_amt2, $atcl_amt3, $atcl_floor, $atcl_floor2, $atcl_amt4, $isale_amt, $prem_amt);
$this->model->saveModifyVrfc($atcl_vr_sq, $atcl_vrfc_type);
// API 호출
$detail = $this->model->getDetail($atcl_vr_sq);
$result = $naver->modifyInfo(
$detail['atcl_no'],
$detail['hscp_no'],
$detail['ptp_no'],
$detail['bild_nm'],
$detail['rm_no'],
$detail['trade_type_cd'],
$detail['deal_amt'],
$detail['wrrnt_amt'],
$detail['lease_amt'],
$detail['isale_amt'],
$detail['prem_amt'],
$detail['floor'],
$detail['floor2'],
$detail['charger'],
$detail['address_code'],
$detail['address2'],
$detail['address2a'],
$detail['address2b'],
$detail['address3'],
$detail['sply_spc'],
$detail['excls_spc'],
$detail['tot_spc'],
$detail['grnd_spc'],
$detail['bldg_spc']
);
if ($result['code'] !== 'success') {
$return = $priceInfo['error'] ?? null;
if (is_array($return) && isset($return['code'], $return['message'])) {
$err_time = date("Y-m-d H:i:s");
$this->model->saveApiErr($atcl_vr_sq, $return['code'], $return['message'], $err_time, $detail['atcl_no']);
throw new \Exception("가격수정 오류: " . $return['message']);
}
throw new \Exception($result['message']);
}
}
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
// 상태변경
public function chgArticleStatus()
{
try {
$usrLvl = session('usr_level');
if (in_array($usrLvl, ['1', '60', '70', '80'])) {
$data = [
'vr_sq' => $this->request->getPost('vr_sq'),
'stat_cd' => $this->request->getPost('stat_cd'),
];
// update v2_chg_stat, v2_modify_info, v2_vrfc_req
$this->model->chgArticleStatus($data);
} else {
return $this->response->setJSON([
'code' => '6',
'msg' => '권한이 없습니다.'
]);
}
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
// 전화정보>메모저장
public function saveMemo()
{
try {
$data = [
'vr_sq' => $this->request->getPost('vr_sq'),
'memo' => $this->request->getPost('memo'),
];
// UPDATE v2_vrfc_req
$this->model->saveMemo($data);
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
/**
* 홍보확인서 확인
* 1.0.1 POST 데이터 받기.
* 1.1.1 1차 검증인지 2차검증인지 확인.
* 1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
* 1.2.1 v2_confirms에 데이터가 있는지 확인.
* 1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
* 1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
* 1.4.2 상태변경 하기 : 전화(서류)확인중 상태로 변경. (수정변경이력 저장)
* 1.5.1 이미지파일 서버에 UPLOAD (수정변경이력 저장)
* 1.6.1 기존파일 탐색.
* 1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
* 1.8.1 기존파일 없음 : v2_files INSERT.
* 1.9.1 확인여부 + 홍보확인서 미확인여부 상세, 매물주소, 가격거래구분, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
* 1.10.1 API 전송.
* 1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 전화(서류)확인완료 상태. (수정변경이력 저장)
*/
public function saveDocu()
{
$lib = new MyUpload();
$naver = new NaverApiClient();
$model415 = new M415Model();
try {
$usr_id = session('usr_id');
$toDay = date('Y-m-d H:i:s'); //오늘날짜
$atcl_vrtc_way = $this->request->getPost('atcl_vrtc_way'); //검증구분
$atcl_vr_sq = $this->request->getPost('rcpt_key');
$comment = $this->request->getPost('comment'); //홍보확인서 미확인여부 상세
$fax_conf_res_d11 = $this->request->getPost('fax_conf_res_d11'); //확인여부
$fax_conf_yn_1 = $this->request->getPost('fax_conf_yn_1'); //확인내용
$fax_conf_yn_2 = $this->request->getPost('fax_conf_yn_2'); //매물주소
$fax_conf_yn_3 = $this->request->getPost('fax_conf_yn_3'); //가격 거래구분
$fax_conf_yn_4 = $this->request->getPost('fax_conf_yn_4'); //의뢰인정보
$fax_conf_yn_info_2 = $this->request->getPost('fax_conf_yn_info_2'); //매물주소
$fax_conf_yn_info_3 = $this->request->getPost('fax_conf_yn_info_3'); //가격 거래구분
$fax_conf_yn_info_4 = $this->request->getPost('fax_conf_yn_info_4'); //의뢰인정보
$reg_chk_val = $this->request->getPost('reg_chk_val'); //등기부등본 확인여부
$memo = $this->request->getPost('memo_fax'); //메모
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
$resStat = $this->model->chkStat($atcl_vr_sq);
if ($resStat['stat_cd'] >= '40' || $resStat['stat_cd'] == '19') {
throw new \Exception('이미 저장된 데이터입니다.');
} else {
$v2DailyModel = new V2StDailyModel();
$v2_vrfc_req = $v2DailyModel->get_v2_vrfc_req($atcl_vr_sq);
$resultCnt = $this->model->chkTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
$try_cnt = '0';
if ($resultCnt['try_cnt'] == 0) { //1차 검증일 때
$try_cnt = '1';
} else if ($resultCnt['try_cnt'] == 1) { //2차 검증일 때
$try_cnt = '2';
} else {
$try_cnt = intval($try_cnt) + 1;
}
$result = $this->model->chkConfirm($atcl_vr_sq, '');
if ($result == 0) { //v2_confirm 존재하지 않는다면
if ($fax_conf_yn_2 == '10000' && $fax_conf_yn_3 == '10000' && $fax_conf_yn_4 == '10000') { //success 여부 판단
$chk_type = '1'; //성공여부
//$chk_delay = '0'; //지연여부
//$chk_zombie = '0'; //좀비매물
} else {
$chk_type = '0';
//$chk_delay = '1'; //지연여부
//$chk_zombie = '0'; //좀비매물
}
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
} else {
if ($fax_conf_yn_2 == '10000' && $fax_conf_yn_3 == '10000' && $fax_conf_yn_4 == '10000') { //success 여부 판단
$chk_type = '1';
//$chk_delay = '0'; //지연여부
//$chk_zombie = '0'; //좀비매물
} else {
$chk_type = '0';
//$chk_delay = '1'; //지연여부
//$chk_zombie = '0'; //좀비매물
}
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
}
//상태변경 TABLE INSERT : 전화(서류)확인중 상태로 변경
$this->model->chgStat($atcl_vr_sq, '30', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
$file = $this->request->getFile('docu_file');
if ($file && $file->isValid() && !$file->hasMoved()) {
$uploadPath = './upload/v2_file/' . $atcl_vr_sq;
$arrUploadfile = [];
if ($file->isValid() && !$file->hasMoved()) {
$uploadData = $lib->do_upload2($file, $uploadPath);
if ($uploadData !== false) {
$arrUploadfile[] = $uploadData;
}
}
if (!empty($arrUploadfile)) {
foreach ($arrUploadfile as $key => $uploadFile) {
$data['file'] = [
'vr_sq' => $atcl_vr_sq,
'orig_name' => $uploadFile['origin_name'],
'new_name' => $uploadFile['file_name'],
'file_path' => $uploadPath, // 필요에 따라 상대경로로만 저장
'ext' => '.' . $uploadFile['ext'],
'size' => $file->getSize(),
'img_yn' => null,
// 높이/폭은 나중에 getimagesize 등으로 구해도 됨
'img_height' => null,
'img_width' => null,
];
}
$this->model->saveFileInfo($data['file']);
}
}
//v2_check_list 확인여부 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D11', $fax_conf_res_d11, $comment);
//v2_check_list 매물주소 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D12', $fax_conf_yn_2, $fax_conf_yn_info_2);
//v2_check_list 가격거래구분 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D13', $fax_conf_yn_3, $fax_conf_yn_info_3);
//v2_check_list 의뢰인정보 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D14', $fax_conf_yn_4, $fax_conf_yn_info_4);
//memo 저장
if (!empty($memo)) {
$this->model->saveMemo(['vr_sq' => $atcl_vr_sq, 'memo' => $memo]);
}
//API 호출
$sendData = $this->model->getDataConfirmAPI($atcl_vr_sq);
$model710 = new M710Model();
$h_yn = $model710->getDataConfirmAPI($atcl_vr_sq);
if ($h_yn['stop_yn'] == 'N') { //전송금지
//1.해당매물정보를v2_stop_api_save_info에다 넣음
$model710->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'H', '');
//2.아무렇지않게 행동한다
$send_result['result'] = 'success';
} else {
$send_result = $naver->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
}
if ($send_result['result'] == 'success') {
/* 상태변경 */
if ($fax_conf_res_d11 == '10000' && $chk_type == '1') {
//상태변경 TABLE INSERT : 전화(서류)확인 완료 상태로 변경
$this->model->chgStat($atcl_vr_sq, '35', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '35'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '35'); //fax_imgs
if ($reg_chk_val == '1') {
//등기부등본 확인 대상은 전화(서류)확인 완료 후 -> 등기부등본 확인중 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '40', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '40'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '40'); //fax_imgs
//★등기 로 넘어갈때
//1.서류전화 들어온시간
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
//2.서류/전화 확인일자
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$sf = 'T';
$model415->insert_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $sf);
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0201', '1', 'add'); // 일치로 저장
} else {
//등기부등본 확인 대상이 아닌 경우 전화(서류)확인 완료 후 -> 검증 완료 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '60', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '60'); //fax_imgs
//★검증완료일때
//0.불일치 이력이 있는지 확인
$cnt = $model415->getFaxFailTimeForHistory($atcl_vr_sq);
if (empty($cnt)) { //검증완료일땐 불일치가없어야 통계포함된다
//1.서류전화 들어온시간
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
//2.서류/전화 확인일자
$tel_doc_conf_dt = $model415->getConfTimeForHistory($atcl_vr_sq);
//3.검증시간
$finishTime = $model415->get_60_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $finishTime['insert_tm']);
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0205', '1', 'add'); // 홍보확인서완료 등기부등본확인 안함 저장
}
} else {
//상태변경 TABLE INSERT : 전화(서류)확인 불일치
$this->model->chgStat($atcl_vr_sq, '39', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '39'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '39'); //fax_imgs
if ($try_cnt == '1') {
if ($fax_conf_yn_4 = !'10000') { //의뢰인정보 불일치일경우
$this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 39 => 30'); //검증결과 변동사항 HISTORY
$this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
// $this->session->set_userdata('alert', "의뢰인정보 불일치로 저장되었습니다..");
throw new Exception('의뢰인정보 불일치로 저장되었습니다.');
}
//v2_vrfc_req try_cnt 값을 1로 update
$this->model->chgTryCnt($atcl_vr_sq, '1');
//★ 1차실패니까 검증실패시간 업데이트하고 검증소요시간 산출
//1.서류전화 들어온시간
$insert_tm = $model415->getFaxSaveTime($atcl_vr_sq);
//2.서류/전화 불일치 시간
$tel_doc_conf_dt = $model415->getFaxFailTimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$sf = 'F';
$model415->insert_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['recv_time'], $tel_doc_conf_dt['insert_tm'], $sf);
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0301', '1', 'add'); // 1차실패로 저장
} else if ($try_cnt == '2') {
//v2_vrfc_req try_cnt 값을 2로 update
$this->model->chgTryCnt($atcl_vr_sq, '2');
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
//★ 검증실패면 검증실패시간 업데이트하고 검증소요시간, 전체소요시간 산출
//1.서류전화 들어온시간
$insert_tm = $model415->getFaxSaveTime($atcl_vr_sq);
//2.서류/전화 불일치 시간
$tel_doc_conf_dt = $model415->getFaxFailTimeForHistory($atcl_vr_sq);
//3.검증실패시간
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['recv_time'], $tel_doc_conf_dt['insert_tm'], $finishTime['insert_tm']);
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0302', '1', 'add'); // 2차실패로 저장
}
///////////////////////////////////////////
// 불일치로 저장
///////////////////////////////////////////
if ($fax_conf_res_d11 == '20013') {
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0203', '1', 'add'); // 기타로 저장
} else {
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0202', '1', 'add'); // 불일치로 저장
}
}
} else {
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
$err_time = date("Y-m-d H:i:s");
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
}
}
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
// 전화정보저장
public function saveTel()
{
/*
1.0.1 POST 데이터 받기.
1.1.1 1차 검증인지 2차검증인지 확인.
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
1.2.1 v2_confirms에 데이터가 있는지 확인.
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
1.4.2 상태변경 하기 : 전화(서류)확인중 상태로 변경. (수정변경이력 저장)
1.5.1 녹취파일 서버에 UPLOAD (수정변경이력 저장)
1.6.1 기존파일 탐색.
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
1.8.1 기존파일 없음 : v2_files INSERT.
1.9.1 개인정보 제공동의, 매물주소, 가격거래구분, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
1.10.1 API 전송.
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 전화(서류)확인완료 상태. (수정변경이력 저장)
*/
$lib = new MyUpload();
$naver = new NaverApiClient();
$model710 = new M710Model();
$model415 = new M415Model();
$v2DailyModel = new V2StDailyModel();
try {
$usr_id = session('usr_id');
$toDay = date('Y-m-d H:i:s');
$atcl_vrtc_way = $this->request->getPost('atcl_vrtc_way');
$atcl_vr_sq = $this->request->getPost('rcpt_key');
$tel_agree = $this->request->getPost('tel_agree');
// 개인정보 제공 동의가 승인일 경우 필수 필드 검증
if ($tel_agree == '10000') {
$validation = \Config\Services::validation();
$validation->setRules([
'tel_conf_yn_2' => [
'label' => '매물주소',
'rules' => 'required',
'errors' => ['required' => '{field} 정보확인 결과를 선택해주세요.']
],
'tel_conf_yn_3' => [
'label' => '가격 거래구분',
'rules' => 'required',
'errors' => ['required' => '{field} 정보확인 결과를 선택해주세요.']
],
'tel_conf_yn_4' => [
'label' => '의뢰인정보',
'rules' => 'required',
'errors' => ['required' => '{field} 정보확인 결과를 선택해주세요.']
],
]);
if (!$validation->withRequest($this->request)->run()) {
$errors = $validation->getErrors();
throw new \Exception(implode(', ', $errors));
}
}
// POST 데이터 받기
$tel_suc = $this->request->getPost('tel_suc');
$tel_conf_yn_2 = $this->request->getPost('tel_conf_yn_2');
$tel_conf_yn_3 = $this->request->getPost('tel_conf_yn_3');
$tel_conf_yn_4 = $this->request->getPost('tel_conf_yn_4');
$tel_conf_yn_5 = $this->request->getPost('tel_conf_yn_5');
$tel_conf_yn_info_2 = $this->request->getPost('tel_conf_yn_info_2');
$tel_conf_yn_info_3 = $this->request->getPost('tel_conf_yn_info_3');
$tel_conf_yn_info_4 = $this->request->getPost('tel_conf_yn_info_4');
$address_code = $this->request->getPost('address_code');
$reg_chk_val = $this->request->getPost('reg_chk_val');
$tel_file_yn = $this->request->getPost('tel_file_yn');
$memo = $this->request->getPost('memo_tel');
$tel_fail_cause = $this->request->getPost('tel_fail_cause');
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
$resStat = $this->model->chkStat($atcl_vr_sq);
if ($resStat['stat_cd'] >= '40' || $resStat['stat_cd'] == '19') {
throw new \Exception('이미 저장된 데이터입니다.');
} else {
$v2_vrfc_req = $this->model->get_v2_vrfc_req($atcl_vr_sq);
$this->model->InsCharger($atcl_vr_sq); //담당자가 없을 경우 강제로 session 정보로 넣어준다
$try_cnt = '0';
$resultCnt = $this->model->chkTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
if ($resultCnt['try_cnt'] == 0) { //1차 검증일 때
$try_cnt = '1';
} else if ($resultCnt['try_cnt'] == 1) { //2차 검증일 때
$try_cnt = '2';
} else {
$try_cnt = intval($try_cnt) + 1;
}
$result = $this->model->chkConfirm($atcl_vr_sq, '');
if ($result == 0) { //v2_confirm 존재하지 않는다면
if ($tel_conf_yn_2 == '10000' && $tel_conf_yn_3 == '10000' && $tel_conf_yn_4 == '10000') { //success 여부 판단
$chk_type = '1'; //성공여부
//$chk_delay = '0'; //지연여부
//$chk_zombie = '0'; //좀비매물
} else {
// 2015.06.29 추가
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
$chk_type = '0';
//$chk_delay = '1'; //지연여부
//$chk_zombie = '0'; //좀비매물
$result_tm = $this->model->getUpdateFailTime1($atcl_vr_sq);
$update_tm = $result_tm['insert_tm'];
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
if ($update_tm > $ten_ago) {
throw new \Exception('이미 불일치 처리 된 매물입니다.');
}
}
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
} else {
//v2_confirm 기존데이터에 success 컬럼만 변경 가능하도록
//v2_confirm delay, zombie 컬럼추가 (2020.03.05)
if ($tel_conf_yn_2 == '10000' && $tel_conf_yn_3 == '10000' && $tel_conf_yn_4 == '10000') { //success 여부 판단
$chk_type = '1';
$chk_delay = '0'; //지연여부
$chk_zombie = '0'; //좀비매물
} else {
// 2015.06.29 추가
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.\
$chk_type = '0';
$chk_delay = '1'; //지연여부
$chk_zombie = '0'; //좀비매물
$result_tm = $this->model->getUpdateFailTime1($atcl_vr_sq);
$update_tm = $result_tm['insert_tm'];
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
if ($update_tm > $ten_ago) {
throw new Exception('이미 불일치 처리 된 매물입니다.');
}
}
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $chk_delay, $chk_zombie);
}
$file = $this->request->getFile('rec_file');
if ($file && $file->isValid() && !$file->hasMoved()) {
$uploadPath = './upload/v2_file/' . $atcl_vr_sq . '/';
$arrUploadfile = [];
if ($file->isValid() && !$file->hasMoved()) {
$uploadData = $lib->do_upload2($file, $uploadPath);
if ($uploadData !== false) {
$arrUploadfile[] = $uploadData;
}
}
if (!empty($arrUploadfile)) {
foreach ($arrUploadfile as $key => $uploadFile) {
$data['file'] = [
'vr_sq' => $atcl_vr_sq,
'orig_name' => $uploadFile['origin_name'],
'new_name' => $uploadFile['file_name'],
'file_path' => $uploadPath, // 필요에 따라 상대경로로만 저장
'ext' => '.' . $uploadFile['ext'],
'size' => $file->getSize(),
'img_yn' => null,
// 높이/폭은 나중에 getimagesize 등으로 구해도 됨
'img_height' => null,
'img_width' => null,
];
}
$this->model->saveFileInfo($data['file']);
}
}
//v2_check_list 확인여부 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T11', $tel_agree, '');
if ($tel_agree == '10000') {
//v2_check_list 매물주소 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T12', $tel_conf_yn_2, $tel_conf_yn_info_2);
//v2_check_list 가격거래구분 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T13', $tel_conf_yn_3, $tel_conf_yn_info_3);
//v2_check_list 의뢰인정보 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T14', $tel_conf_yn_4, $tel_conf_yn_info_4);
} else {
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T12');
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T13');
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T14');
}
if (!empty($tel_conf_yn_5)) {
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T15', $tel_conf_yn_5, $tel_conf_yn_5);
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T11');
} else {
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T15');
}
//memo 저장
if (!empty($memo)) {
$this->model->saveMemo(['vr_sq' => $atcl_vr_sq, 'memo' => $memo]);
}
//전화실패 사유 저장
if (!empty($tel_fail_cause)) {
$this->model->up_tel_fail_cause($atcl_vr_sq, $tel_fail_cause);
}
$sendData = $this->model->getDataConfirmAPI($atcl_vr_sq);
$t_yn = $model710->get_send_yn('T');
if ($t_yn['stop_yn'] == 'N') { //전송금지
//1.해당매물정보를v2_stop_api_save_info에다 넣음
$this->model->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'T1', '');
//2.아무렇지않게 행동한다
$send_result['result'] = 'success';
} else {
//API 호출
$send_result = $naver->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
}
//v2_vrfc_req INSERT//상태변경 TABLE INSERT : 전화(서류)확인중 상태로 변경
$this->model->chgStat($atcl_vr_sq, '30', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '30');
if ($send_result['result'] == 'success') {
if ($tel_agree == '10000' && $chk_type == '1') {
//상태변경 TABLE INSERT : 전화(서류)확인 완료 상태로 변경
$this->model->chgStat($atcl_vr_sq, '35', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '35'); //v2_vrfc_req INSERT
if ($reg_chk_val == '1') {
//등기부등본 확인 대상은 전화(서류)확인 완료 후 -> 등기부등본 확인중 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '40', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '40'); //v2_vrfc_req INSERT
//★등기 로 넘어갈때
//0.통화실패 여부를 확인한다
$cnt = $model415->getCallfailForHistory($atcl_vr_sq);
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
//1.서류전화 들어온시간
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
//2.서류/전화 확인일자
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$sf = 'T';
$model415->insert_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $sf);
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0201', '1', 'add'); // 일치로 저장
} else {
//등기부등본 확인 대상이 아닌 경우 전화(서류)확인 완료 후 -> 검증 완료 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '60', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
//★검증완료일때
//0.통화실패 여부를 확인한다
$cnt = $model415->getCallfailForHistory($atcl_vr_sq);
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
//1.서류전화 들어온시간
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
//2.서류/전화 확인일자
$tel_doc_conf_dt = $model415->getConfTimeForHistory($atcl_vr_sq);
//3.검증완료시간
$finishTime = $model415->get_60_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $finishTime['insert_tm']);
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0206', '1', 'add'); // 전화확인완료 등기부등본확인 안함 저장
}
} else {
//상태변경 TABLE INSERT : 전화(서류)확인 불일치 상태로 변경
$this->model->chgStat($atcl_vr_sq, '39', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '39'); //v2_vrfc_req INSERT
if ($try_cnt == '1') {
//v2_vrfc_req try_cnt 값을 1로 update
$this->model->chgTryCnt($atcl_vr_sq, '1');
//★불일치
//0.통화실패 여부를 확인한다
$cnt = $model415->getCallfailForHistory($atcl_vr_sq);
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
//1.서류전화 들어온시간
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
//2.서류/전화 불일치 시간
$tel_doc_conf_dt = $model415->getFaxFailTimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$sf = 'F';
$model415->insert_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $sf);
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0301', '1', 'add'); // 1차실패로 저장
} else if ($try_cnt == '2') {
//v2_vrfc_req try_cnt 값을 2로 update
$res_try = $this->m701_model->chgTryCnt($atcl_vr_sq, '2');
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
$result_query9 = $this->m701_model->chgStat($atcl_vr_sq, '69', $toDay);
$chgVrfc69 = $this->m701_model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
//★ 검증실패
//0.통화실패 여부를 확인한다
$cnt = $model415->getCallfailForHistory($atcl_vr_sq);
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
//1.서류전화 들어온시간
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
//2.서류/전화 불일치 시간
$tel_doc_conf_dt = $model415->getFaxFailTimeForHistory($atcl_vr_sq);
//3.검증실패시간
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $finishTime['insert_tm']);
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0302', '1', 'add'); // 최종실패로 저장
}
if (in_array($tel_agree, array('20001', '20002'))) {
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0203', '1', 'add'); // 거부로 저장
} elseif (in_array($tel_agree, array('20003', '20004', '20005'))) {
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0204', '1', 'add'); // 무응답 외
} else {
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0202', '1', 'add'); // 불일치
}
}
} else {
if (isset($send_result['error'])) {
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
$err_time = date("Y-m-d H:i:s");
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
throw new \Exception($error_message);
} else {
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
}
}
}
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
//$file = $this->request->getFile('rec_file');
// print_r($file);
// exit;
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
// 파일업로드
public function uploadFile()
{
$lib = new MyUpload();
try {
$usr_id = session('usr_id');
$vr_sq = $this->request->getPost(index: 'vr_sq');
$files = $this->request->getFiles();
$uploadPath = "/upload/v2_file/" . $vr_sq . "/";
$file = $files['files'];
$arrUploadfile = [];
$uploadData = $lib->do_upload2($file, $uploadPath);
if ($uploadData !== false) {
$arrUploadfile[] = $uploadData;
}
// print_r($arrUploadfile);
// exit;
if (!empty($arrUploadfile)) {
foreach ($arrUploadfile as $key => $uploadFile) {
$data = [
'vr_sq' => $vr_sq,
// 'file_sq' => $this->request->getPost('file_sq'),
'orig_name' => $uploadFile['origin_name'],
'new_name' => $uploadFile['file_name'],
'file_path' => $uploadPath, // 필요에 따라 상대경로로만 저장
'ext' => '.' . $uploadFile['ext'],
'size' => $file->getSize(),
'img_yn' => null,
'img_height' => null,
'img_width' => null,
'usr_id' => $usr_id,
'file_type' => '2',
];
}
if (!empty($data)) {
$detail = $this->model->getDetail($vr_sq);
$this->model->saveHistory($vr_sq, $detail['stat_cd'], 'C28', $usr_id, '이미지파일 업로드');
// 파일업로드 정보 저장
$this->model->saveFileInfo($data);
}
}
// return $this->response->setJSON([
// 'code' => '0',
// 'msg' => 'success'
// ]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
// 등기부등본 저장
public function saveRegi()
{
/*
1.0.1 POST 데이터 받기.
1.1.1 1차 검증인지 2차검증인지 확인.
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
1.2.1 v2_confirms에 데이터가 있는지 확인.
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
1.4.2 상태변경 하기 : 등기부등본 확인중 상태로 변경. (수정변경이력 저장)
1.5.1 이미지파일 서버에 UPLOAD (수정변경이력 저장)
1.6.1 기존파일 탐색.
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
1.8.1 기존파일 없음 : v2_files INSERT.
1.9.1 매물주소, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
1.10.1 API 전송 certification.
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 등기부등본 확인완료 상태. (수정변경이력 저장)
*/
$model415 = new M415Model();
$model710 = new M710Model();
$v2DailyModel = new V2StDailyModel();
$naver = new NaverApiClient();
try {
$atcl_vrtc_type = $this->request->getGet('atcl_vrtc_type', TRUE); // 검증방식
if ($atcl_vrtc_type == "N") {
$ownerVerifiable = $this->request->getPost('ownerVerifiable', TRUE); //소유자명 확인
}
$usr_id = session('usr_id');
$toDay = date('Y-m-d H:i:s');
$atcl_vrtc_way = 'R'; //검증구분
$atcl_vr_sq = $this->request->getPost('rcpt_key', TRUE);
$reg_conf_yn_1 = $this->request->getPost('reg_conf_yn_1', TRUE); //확인내용
$reg_conf_yn_2 = $this->request->getPost('reg_conf_yn_2', TRUE); //매물주소
$reg_conf_yn_3 = $this->request->getPost('reg_conf_yn_3', TRUE); //의뢰인정보
$reg_conf_yn_info_2 = $this->request->getPost('reg_conf_yn_info_2', TRUE); //매물주소
$reg_conf_yn_info_3 = $this->request->getPost('reg_conf_yn_info_3', TRUE); //의뢰인정보
$memo = $this->request->getPost('memo_reg', TRUE); //메모
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
$this->model->chkStat($atcl_vr_sq);
$v2_vrfc_req = $this->model->get_v2_vrfc_req($atcl_vr_sq);
$rlet_type_cd = $this->model->get_rlet_type_cd($atcl_vr_sq);
$resultCnt = $this->model->chkRegiTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
$try_cnt = '0';
if ($resultCnt['reg_try_cnt'] == 0) { //1차 검증일 때
$try_cnt = '1';
} else if ($resultCnt['reg_try_cnt'] == 1) { //2차 검증일 때
$try_cnt = '2';
} else {
$try_cnt = intval($try_cnt) + 1;
}
$result = $this->model->chkConfirm($atcl_vr_sq, $atcl_vrtc_way);
if ($result == 0) {
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
$chk_type = '1';
//$chk_delay = '0'; //지연여부
//$chk_zombie = '0'; //좀비매물
} else {
// 2015.06.29 추가
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
$chk_type = '0';
//$chk_delay = '1'; //지연여부
//$chk_zombie = '0'; //좀비매물
$result_tm = $this->model->getUpdateFailTime2($atcl_vr_sq);
$update_tm = $result_tm['insert_tm'];
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
if ($update_tm > $ten_ago) {
throw new \Exception('이미 불일치 처리 된 매물입니다.');
}
}
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
} else {
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
$chk_type = '1';
//$chk_delay = '0'; //지연여부
//$chk_zombie = '0'; //좀비매물
} else {
// 2015.06.29 추가
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
$chk_type = '0';
//$chk_delay = '1'; //지연여부
//$chk_zombie = '0'; //좀비매물
$result_tm = $this->model->getUpdateFailTime2($atcl_vr_sq);
$update_tm = $result_tm['insert_tm'];
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
if ($update_tm > $ten_ago) {
throw new \Exception('이미 불일치 처리 된 매물입니다.');
}
}
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
}
//상태변경 TABLE INSERT : 등기부등본 확인중 상태로 변경
$this->model->chgStat($atcl_vr_sq, '40', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '40'); //v2_vrfc_req INSERT
//v2_check_list 확인여부 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '21', $reg_conf_yn_2, $reg_conf_yn_info_2);
//v2_check_list 매물주소 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '22', $reg_conf_yn_3, $reg_conf_yn_info_3);
//memo 저장
if (!empty($memo)) {
$this->model->saveMemo(['vr_sq' => $atcl_vr_sq, 'memo' => $memo]);
}
$sendData = $this->model->getDatacertAPI($atcl_vr_sq, 'R');
$d_yn = $model710->get_send_yn('D');
if ($d_yn['stop_yn'] == 'N') { //전송금지
//1.해당매물정보를v2_stop_api_save_info에다 넣음
$model710->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'D', '');
//2.아무렇지않게 행동한다
$send_result['result'] = 'success';
} else {
if ($atcl_vrtc_type == "N") {
if ($ownerVerifiable == '1') {
$ownerVerifiable = true;
} else {
$ownerVerfiable = false;
}
} else {
$ownerVerifiable = $sendData['ownerVerifiable'];
}
// 소유주 확인 여부 업데이트
$result_verifiable = $this->model->updateOwnerVerifiable($atcl_vr_sq, $ownerVerifiable);
$send_result = $naver->certification($sendData['atclNo'], $try_cnt, $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['date'], $sendData['modifyInfo'], $ownerVerifiable);
}
if ($send_result['result'] == 'success') {
if ($chk_type == '1') {
//상태변경 TABLE INSERT : 등기부등본 확인완료 상태로 변경
$this->model->chgStat($atcl_vr_sq, '45', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '45'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '45'); //fax_imgs
//상태변경 TABLE INSERT : 검증완료 상태로 변경
$this->model->chgStat($atcl_vr_sq, '60', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '60'); //fax_imgs
//★검증완료일때
//0.불일치 이력이 있는지 확인
$cnt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
if (empty($cnt)) { //검증완료일땐 불일치가없어야 통계포함된다
if ($atcl_vrtc_type == 'M' || $atcl_vrtc_type == 'O') { //모바일은 등기가 첨 시작이니까 insert해줘야함
if (!($atcl_vrtc_type == 'M' && in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03')))) {//만약 분양권들이면 넘어가고 아니면 체크
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
//2.등기부등본 확인완료 시간
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
//3.검증완료시간
$finishTime = $model415->get_60_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
}
} else {
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
//2.등기부등본 확인완료 시간
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
}
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
} else {
if ($atcl_vrtc_type == 'M') {
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
//v2_vrfc_req try_cnt 값을 1로 update
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
// ★모바일이고 검증실패
if (!in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03'))) {//만약 분양권들이면 넘어가고 아니면 체크
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.검증실패시간
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
} else {
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '49'); //fax_img
//등기부등본 확인중 상태로 변경.
$this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 49 => 30'); //검증결과 변동사항 HISTORY
$this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
if ($try_cnt == '1') {
//v2_vrfc_req try_cnt 값을 1로 update
$this->model->chgRegiTryCnt($atcl_vr_sq, '1');
// ★1차실패
if ($atcl_vrtc_type == 'O') {
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.검증실패시간
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
} else {
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$sf = 'F';
$model415->update_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $sf);
}
} else if ($try_cnt == '2') {
//v2_vrfc_req try_cnt 값을 2로 update
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
// ★모바일 이외 검증실패
if ($atcl_vrtc_type == 'O') {
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.검증실패시간
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
} else {
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
}
}
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
}
}
} else {
if (isset($send_result['error'])) {
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
$err_time = date("Y-m-d H:i:s");
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
throw new \Exception($error_message);
} else {
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
}
}
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
// 검증 최종실패처리
public function saveFinalRegi()
{
$naver = new NaverApiClient();
$model710 = new M710Model();
$model415 = new M415Model();
$v2DailyModel = new V2StDailyModel();
try {
$atcl_vrtc_type = $this->request->getGet('atcl_vrtc_type', TRUE); // 검증방식
if ($atcl_vrtc_type == "N") {
$ownerVerifiable = $this->request->getPost('ownerVerifiable', TRUE); //소유자명 확인
}
$usr_id = session('usr_id');
$toDay = date('Y-m-d H:i:s');
$atcl_vrtc_way = 'R'; //검증구분
$atcl_vr_sq = $this->request->getPost('rcpt_key', TRUE);
// $atcl_no = $this->input->post('atcl_no', TRUE);
$reg_conf_yn_1 = $this->request->getPost('reg_conf_yn_1', TRUE); //확인내용
$reg_conf_yn_2 = '20000'; //매물주소 불일치 처리
$reg_conf_yn_3 = '20000'; //의뢰인정보 불일치 처리
$reg_conf_yn_info_2 = $this->request->getPost('reg_conf_yn_info_2', TRUE); //매물주소
$reg_conf_yn_info_3 = $this->request->getPost('reg_conf_yn_info_3', TRUE); //의뢰인정보
$memo = $this->request->getPost('memo_reg', TRUE); //메모
$try_cnt = '2';
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
$resStat = $this->model->chkStat($atcl_vr_sq);
$v2_vrfc_req = $v2DailyModel->get_v2_vrfc_req($atcl_vr_sq);
$rlet_type_cd = $model415->get_rlet_type_cd($atcl_vr_sq);
if ($resStat['stat_cd'] >= '60' || $resStat['stat_cd'] == '19') {
throw new \Exception('이미 최종처리된 매물입니다.');
} else {
$this->model->InsResChar($atcl_vr_sq); //담당자가 없을 경우 강제로 session 정보로 넣어준다
$result = $this->model->chkConfirm($atcl_vr_sq, $atcl_vrtc_way);
//v2_confirm 존재하지 않는다면
if ($result == 0) {
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') {
$chk_type = '1';
} else {
$chk_type = '0';
$result_tm = $this->model->getUpdateFailTime2($atcl_vr_sq);
$update_tm = $result_tm['insert_tm'];
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
if ($update_tm > $ten_ago) {
throw new \Exception('이미 불일치 처리 된 매물입니다.');
}
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
}
} else {
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
$chk_type = '1';
//$chk_delay = '0'; //지연여부
//$chk_zombie = '0'; //좀비매물
} else {
// 2015.06.29 추가
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
$chk_type = '0';
//$chk_delay = '1'; //지연여부
//$chk_zombie = '0'; //좀비매물
$result_tm = $this->model->getUpdateFailTime2($atcl_vr_sq);
$update_tm = $result_tm['insert_tm'];
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
if ($update_tm > $ten_ago) {
throw new \Exception('이미 불일치 처리 된 매물입니다.');
}
}
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
}
//v2_check_list 확인여부 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '21', $reg_conf_yn_2, $reg_conf_yn_info_2);
//v2_check_list 매물주소 INSERT
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '22', $reg_conf_yn_3, $reg_conf_yn_info_3);
//memo 저장
if (!empty($memo)) {
$this->model->saveMemo(['vr_sq' => $atcl_vr_sq, 'memo' => $memo]);
}
$sendData = $this->model->getDatacertAPI($atcl_vr_sq, 'R');
$d_yn = $this->model->get_send_yn('D');
if ($d_yn['stop_yn'] == 'N') { //전송금지
//1.해당매물정보를v2_stop_api_save_info에다 넣음
$this->model->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'D', '');
//2.아무렇지않게 행동한다
$send_result['result'] = 'success';
} else {
if ($atcl_vrtc_type == "N") {
if ($ownerVerifiable == '1') {
$ownerVerifiable = true;
} else {
$ownerVerifiable = false;
}
} else {
$ownerVerifiable = $sendData['ownerVerifiable'];
}
// 소유주 확인 여부 업데이트
$result_verifiable = $this->model->updateOwnerVerifiable($atcl_vr_sq, $ownerVerifiable);
$send_result = $naver->certification($sendData['atclNo'], $try_cnt, $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['date'], $sendData['modifyInfo'], $ownerVerifiable);
}
if ($send_result['result'] == 'success') {
if ($atcl_vrtc_type == 'M') {
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
//v2_vrfc_req try_cnt 값을 1로 update
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
// ★모바일이고 검증실패
if (!in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03'))) {//만약 분양권들이면 넘어가고 아니면 체크
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.검증실패시간
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
}
} else {
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
//등기부등본 확인중 상태로 변경.
$this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 49 => 30'); //검증결과 변동사항 HISTORY
$this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
if ($try_cnt == '2') {
//v2_vrfc_req try_cnt 값을 2로 update
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
// ★모바일 이외 검증실패
if ($atcl_vrtc_type == 'O') {
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.검증실패시간
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
//4.해당 정보를 테이블에 넣는다
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
} else {
//1.등기부등본 확인중 시간
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
//2.등기부등본 확인실패 시간
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
//3.해당 정보를 테이블에 넣는다
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
}
}
}
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
} else {
if (isset($send_result['error'])) {
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
$err_time = date("Y-m-d H:i:s");
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
throw new \Exception($error_message);
} else {
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
}
}
//상태변경 TABLE INSERT : 최종실패 상태로 변경
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
}
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
} catch (\Exception $e) {
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
}