상세수정

Reviewed-on: http://192.168.10.243:3000/owrainfo/confirms/pulls/47
This commit was merged in pull request #47.
This commit is contained in:
2026-02-04 13:33:28 +09:00
7 changed files with 3030 additions and 994 deletions

View File

@@ -510,6 +510,24 @@ class M415Model extends Model
return $res;
}
// 등기부등본 확인완료 시간
public function get_cert_confTimeForHistory($vr_sq)
{
$sql = "select insert_tm from v2_chg_history" .
" where vr_sq = ?" .
" and stat_cd = '45'" .
" and chg_type= 'C9'" .
" order by seq desc" .
" limit 1";
$data = array(
$vr_sq
);
$query = $this->db->query($sql, $data);
$res = $query->getRowArray();
return $res;
}
// 검증실패 시간
public function get_69_ForHistory($vr_sq)
{

View File

@@ -311,7 +311,7 @@ class M701Model extends Model
b.vrfc_type,
IFNULL(c.rm_no, '') as rm_no,
c.floor,
c.address_code,
IFNULL(c.address_code, '') as address_code,
IFNULL(c.address2, '') as address2,
IFNULL(m.address2a, '') as address2a,
IFNULL(m.address2b, '') as address2b,
@@ -332,7 +332,7 @@ class M701Model extends Model
d.insert_tm as update_res_tm,
greatest(ifnull(d45.insert_tm, ''), ifnull(d49.insert_tm, '')) as rgbk_check_tm,
e.insert_tm as result_tm,
f.region_nm,
IFNULL(f.region_nm, '') as region_nm,
g.cd_nm as pre_stat,
h.cd_nm as vrfc_type,
i.usr_nm,

View File

@@ -1,6 +1,7 @@
<?php
namespace App\Models\v2;
use App\Models\webfax\FaxModel;
use CodeIgniter\Model;
class M702Model extends Model
@@ -740,6 +741,78 @@ class M702Model extends Model
];
}
public function chgStat($vr_sq, $stat_cd, $insert_tm)
{ //상태변경 TABLE INSERT
$usr_sq = session('usr_sq');
$usr_id = session('usr_id');
$list = $this->getDetail($vr_sq);
$sql = "INSERT INTO v2_chg_stat (vr_sq, stat_cd, insert_user, insert_tm)" .
"VALUES (?, ?, ?, ?)" .
"ON DUPLICATE KEY " .
"UPDATE vr_sq=VALUES(vr_sq), stat_cd=VALUES(stat_cd), insert_user=VALUES(insert_user), insert_tm=VALUES(insert_tm)";
$data = array(
'vr_sq' => $vr_sq
,
'stat_cd' => $stat_cd
,
'usr_sq' => $usr_sq
,
'insert_tm' => $insert_tm
);
$this->db->transStart();
$res = $this->db->query($sql, $data);
// echo $this->db->last_query();
$return['error_number'] = $this->db->_error_number();
$return['error_message'] = $this->db->_error_message();
if (empty($return['error_number'])) {
//로그를 남긴다.
if ($this->db->affected_rows() > 0) {
if (!empty($changed)) {
$this->saveHistory($list['data']['vr_sq'], $stat_cd, 'C9', $usr_id, "등기부등본확인 정보 수정"); //검증결과 변동사항 HISTORY
}
}
}
$this->db->transComplete();
}
public function chgStatVrfc($vr_sq, $stat_cd)
{
$data = ['stat_cd' => $stat_cd];
$builder = $this->db->table('v2_vrfc_req');
$builder->where('vr_sq', $vr_sq);
$builder->update($data);
$error = $this->db->error();
$return['error_number'] = $error['code'] ?? null;
$return['error_message'] = $error['message'] ?? null;
return $return;
}
public function chgStatFax($vr_sq, $stat_cd)
{
$data = ['stat_cd' => $stat_cd];
$builder = $this->db->table('fax_imgs');
$builder->where('vr_sq', $vr_sq);
$builder->update($data);
$error = $this->db->error();
$return['error_number'] = $error['code'] ?? null;
$return['error_message'] = $error['message'] ?? null;
return $return;
}
// 상태변경 시각 기록
public function saveV2ChgStat($vr_sq, $stat_cd, $insert_user)
{
@@ -752,6 +825,45 @@ class M702Model extends Model
$this->db->query($sql, [$vr_sq, $stat_cd, $insert_user]);
}
// 파일정보 저장
public function saveFileInfo($file)
{
$this->db->transStart();
$fileType = $file['file_type'] ?? '1';
// 기존 파일 확인
$sql = "SELECT seq FROM v2_files WHERE vr_sq = ? AND use_yn = 'Y' AND file_type = ?";
$query = $this->db->query($sql, [$file['vr_sq'], $fileType]);
$result = $query->getRow();
if (!empty($result)) {
// 기존 파일을 비활성화
$sql = "UPDATE v2_files SET use_yn = 'N' WHERE vr_sq = ? AND file_type = ?";
$this->db->query($sql, [$file['vr_sq'], $fileType]);
}
// 새 파일 정보 INSERT
$data = [
'vr_sq' => $file['vr_sq'],
'use_yn' => 'Y',
'file_type' => $fileType,
'view_odr' => $file['view_odr'] ?? 0,
'file_path' => $file['file_path'],
'file_name' => $file['new_name'],
'file_ext' => $file['ext'],
'file_size' => $file['size'],
'insert_user' => session('usr_sq'),
'insert_tm' => date('Y-m-d H:i:s'),
'cloud_upload_yn' => 'Y',
];
$builder = $this->db->table('v2_files');
$builder->insert($data);
$this->db->transComplete();
}
// 변경이력 저장
public function saveHistory($vr_sq, $stat_cd, $chg_type, $usr_id, $memo)
@@ -925,6 +1037,476 @@ class M702Model extends Model
}
/* 매물정보를 수정 */
//public function saveModifyInfo($atcl_vr_sq, $atcl_hscp_nm, $atcl_ptp_nm, $atcl_vrfc_type, $trade_type, $atcl_addr1, $atcl_addr1a, $atcl_addr1b, $atcl_addr2, $atcl_hscp_no, $atcl_ptp_no, $atcl_amt1, $atcl_amt2, $atcl_amt3, $atcl_floor, $atcl_floor2){
public function saveModifyInfo($atcl_vr_sq, $atcl_hscp_nm, $atcl_ptp_nm, $atcl_vrfc_type, $trade_type, $atcl_addr1, $atcl_addr1a, $atcl_addr1b, $atcl_addr2, $atcl_hscp_no, $atcl_ptp_no, $atcl_amt1, $atcl_amt2, $atcl_amt3, $atcl_floor, $atcl_floor2)
{
$usr_id = session('usr_id');
$list = $this->getDetail($atcl_vr_sq);
if ($trade_type !== 'B2') {
$atcl_amt3 = '0';
$data['lease_amt'] = $atcl_amt3;
}
if (!empty($trade_type)) {
$data['trade_type'] = $trade_type;
}
if (!empty($atcl_hscp_nm)) {
$data['hscp_nm'] = $atcl_hscp_nm;
}
if (!empty($atcl_ptp_nm)) {
$data['ptp_nm'] = $atcl_ptp_nm;
}
if (!empty($atcl_addr1)) {
$data['address2'] = $atcl_addr1;
}
if (!empty($atcl_addr1a)) {
$data['address2a'] = $atcl_addr1a;
}
if (!empty($atcl_addr1b)) {
$data['address2b'] = $atcl_addr1b;
}
if (!empty($atcl_addr2)) {
$data['address3'] = $atcl_addr2;
}
if (!empty($atcl_hscp_no)) {
$data['hscp_no'] = $atcl_hscp_no;
}
if (!empty($atcl_ptp_no)) {
$data['ptp_no'] = $atcl_ptp_no;
}
if (!empty($atcl_amt1)) {
$data['deal_amt'] = $atcl_amt1;
}
if (!empty($atcl_amt2)) {
$data['wrrnt_amt'] = $atcl_amt2;
}
if (!empty($atcl_amt3)) {
$data['lease_amt'] = $atcl_amt3;
}
if (!empty($atcl_floor)) {
$data['floor'] = $atcl_floor;
}
if (!empty($atcl_floor2)) {
$data['floor2'] = $atcl_floor2;
}
$data['modify_yn'] = 'Y';
$this->db->transStart();
$builder = $this->db->table('v2_modify_info');
$builder->where('vr_sq', $atcl_vr_sq);
$builder->update($data);
$lastQuery = (string) $this->db->getLastQuery();
$currentUrl = current_url();
log_message('debug', "{$currentUrl} :: {$lastQuery}");
$data['trade_type_cd'] = $trade_type;
$error = $this->db->error();
$return['error_number'] = $error['code'] ?? null;
$return['error_message'] = $error['message'] ?? null;
if (empty($return['error_number'])) {
if ($this->db->affectedRows() > 0) {
if (!empty($changed)) {
$this->saveHistory($list['data']['vr_sq'], $list['data']['pre_stat_cd'], 'C25', $usr_id, '매물정보 수정');
}
}
}
$this->db->transComplete();
$faxModel = new FaxModel();
$faxModel->updateAddress($atcl_vr_sq, $list['data']['address_code'], $data['address2'], $data['address3'], $data['hscp_no'], $data['hscp_nm']);
return $return;
}
public function saveModifyVrfc($atcl_vr_sq, $atcl_vrfc_type)
{
$usr_id = session('usr_id');
$list = $this->getDetail($atcl_vr_sq);
$data = [
'vrfc_type' => $atcl_vrfc_type,
];
$this->db->transStart();
$builder = $this->db->table('v2_vrfc_req');
$builder->where('vr_sq', $atcl_vr_sq);
$builder->update($data);
$data['vrfc_type_cd'] = $atcl_vrfc_type;
$error = $this->db->error();
$return['error_number'] = $error['code'] ?? null;
$return['error_message'] = $error['message'] ?? null;
if (empty($return['error_number'])) {
if ($this->db->affectedRows() > 0) {
if (!empty($changed)) {
$this->saveHistory($list['data']['vr_sq'], $list['data']['pre_stat_cd'], 'C25', $usr_id, '매물정보 저장');
}
}
}
$this->db->transComplete();
return $return;
}
// 현재상태확인
public function chkStat($vr_sq)
{
$sql = "SELECT stat_cd FROM v2_vrfc_req WHERE vr_sq = ?";
$data = [
$vr_sq
];
$query = $this->db->query($sql, $data);
return $query->getRowArray();
}
public function InsResChar($atcl_vr_sq)
{
$usr_id = session('usr_id');
$sql = "UPDATE v2_article_info" .
" SET reg_charger = ?" .
" WHERE vr_sq = ?";
$data = array(
$usr_id,
$atcl_vr_sq
);
$res = $this->db->query($sql, $data);
$log_v = $this->db->getLastQuery();
log_message('debug', $log_v);
}
public function chkRegiTryCnt($atcl_vr_sq)
{
$builder = $this->db->table('v2_vrfc_req a');
$builder->select('a.reg_try_cnt');
$builder->where('vr_sq', $atcl_vr_sq);
$query = $builder->get();
return $query->getRowArray();
}
public function chkConfirm($atcl_vr_sq, $reg_yn)
{ //검증결과 table에 있는지 확인.
$builder = $this->db->table('v2_confirm a');
$builder->select('a.vr_sq');
$builder->where('a.vr_sq', $atcl_vr_sq);
if (!empty($reg_yn)) {
$builder->where('a.vrfc_type', $reg_yn); // 등기부등본 정보 확인시
}
return $builder->get()->getNumRows();
}
public function insertConfirm($vr_sq, $vrfc_type, $success, $type)
{ //v2_confirm INSERT
$usr_sq = session('usr_sq');
$usr_id = session('usr_id');
$sql = "INSERT INTO v2_confirm" .
"(vr_sq, vrfc_type, success, type, charger, date, insert_user, insert_tm, update_user, update_tm)" .
"VALUES" .
"(?, ?, ?, ?, ?, '" . date('YmdHis') . "', ?, NOW(), ?, NOW())";
$data = array(
$vr_sq,
$vrfc_type,
$success,
$type,
$usr_id,
$usr_sq,
$usr_sq
);
$this->db->query($sql, $data);
}
public function updateConfirm($vr_sq, $vrfc_type, $success)
{
$data = [
'success' => $success,
'update_user' => session('usr_sq'),
'update_tm' => date('Y-m-d H:i:s')
];
$builder = $this->db->table('v2_confirm');
$builder->where('vr_sq', $vr_sq);
$builder->where('vrfc_type', $vrfc_type);
$builder->update($data);
$error = $this->db->error();
$return['error_number'] = $error['code'] ?? null;
$return['error_message'] = $error['message'] ?? null;
return $return;
}
public function saveApiErr($err_sq, $err_code, $err_nm, $err_time, $err_no, $err_server = '')
{
$sql = "INSERT INTO err_api (err_sq, err_code, err_nm, err_time, err_no, err_server)" .
" VALUES (?, ?, ?, ?, ?, ?);";
$data = array(
$err_sq,
$err_code,
$err_nm,
$err_time,
$err_no,
$err_server
);
$res = $this->db->query($sql, $data);
}
public function insertChkList($vr_sq, $vrfc_type, $type, $code, $comment)
{ //v2_check_list INSERT
$usr_sq = session('usr_sq');
$sql = "INSERT INTO v2_check_list" .
"(vr_sq, vrfc_type, type, code, comment, insert_user, insert_tm)" .
"VALUES" .
"(?, ?, ?, ?, ?, ?, NOW())" .
" ON DUPLICATE KEY UPDATE" .
" vr_sq=values(vr_sq), vrfc_type=values(vrfc_type), type=values(type), code=values(code), comment=values(comment), insert_user=values(insert_user), insert_tm=values(insert_tm)";
$data = array(
$vr_sq,
$vrfc_type,
$type,
$code,
$comment,
$usr_sq
);
$res = $this->db->query($sql, $data);
}
/* 등기부등본 API 호출*/
public function getDatacertAPI($vr_sq, $vrfc_type = '')
{
// 요청정보
$sql = "SELECT vr_sq, atcl_no, step, cpid, cp_atcl_id, trade_type, realtor_nm, realtor_tel_no, seller_tel_no, vrfc_type, rgbk_confirm, req_type, rdate, stat_cd, try_cnt, insert_user, insert_tm, owner_verifiable" .
" FROM v2_vrfc_req where vr_sq = ?";
$data = array($vr_sq);
$query = $this->db->query($sql, $data);
$row_vrfc_req = $query->getRowArray();
if (!empty($vrfc_type)) {
$row_vrfc_req['vrfc_type'] = $vrfc_type;
}
log_message('debug', $this->db->getLastQuery());
// 매물정보
$sql = "SELECT vr_sq, atcl_no, cpid, cp_atcl_id, rlet_type_cd, trade_type, address_code, address1, address2, address3, sply_spc, excls_spc, tot_spc, grnd_spc, bldg_spc, deal_amt, wrrnt_amt, lease_amt, isale_amt, prem_amt, sise, floor, rdate, seller_tel_no, seller_nm, realtor_nm, realtor_tel_no, hscp_no, hscp_nm, ptp_no, ptp_nm, charger, req_price_yn, reg_charger, dept1_sq, dept2_sq, reg_dept1_sq, reg_dept2_sq, floor2" .
" FROM v2_article_info where vr_sq = ?";
$data = array($vr_sq);
$query = $this->db->query($sql, $data);
$row_article_info = $query->getRowArray();
log_message('debug', $this->db->getLastQuery());
// 수정정보
$sql = "SELECT vr_sq, bild_nm, rm_no, floor, address_code, address2, address3, trade_type, deal_amt, wrrnt_amt, lease_amt, isale_amt, prem_amt, sply_spc, excls_spc, tot_spc, grnd_spc, bldg_spc, hscp_no, hscp_nm, ptp_no, ptp_nm, modify_yn, floor2" .
" FROM v2_modify_info where vr_sq = ?";
$data = array($vr_sq);
$query = $this->db->query($sql, $data);
$row_modify_info = $query->getRowArray();
log_message('debug', $this->db->getLastQuery());
// 검증결과
$sql = "SELECT vr_sq, vrfc_type, success, type, charger, date, insert_user, insert_tm, update_user, update_tm, work_type" .
" FROM v2_confirm where vr_sq = ? and vrfc_type = ?";
$data = array($vr_sq, $row_vrfc_req['vrfc_type']);
$query = $this->db->query($sql, $data);
$row_confirm = $query->getRowArray();
log_message('debug', $this->db->getLastQuery());
// 확인정보
$sql = "SELECT a.type, a.code, a.comment, b.ownerNm, b.owner_birth" .
" FROM v2_check_list a " .
" INNER JOIN v2_article_info b on a.vr_sq = b.vr_sq" .
" WHERE a.vr_sq = ? and a.vrfc_type = ?";
// " FROM v2_check_list where vr_sq = ? and vrfc_type = ? and type like concat(vrfc_type, '%')";
$data = array($vr_sq, $row_vrfc_req['vrfc_type']);
$query = $this->db->query($sql, $data);
$res_check_list = $query->getResultArray();
log_message('debug', $this->db->getLastQuery());
log_message('debug', implode(', ', $row_confirm));
$atclNo = $row_vrfc_req['atcl_no'];
$type = $row_vrfc_req['try_cnt'];
$success = empty($row_confirm['success']) ? FALSE : TRUE;
$charger = $row_confirm['charger'];
$date = $row_confirm['date'];
if ($row_vrfc_req['owner_verifiable'] == 'false') {
$ownerVerifiable = FALSE;
} else {
$ownerVerifiable = TRUE;
}
$checkList = array();
foreach ($res_check_list as $row) {
$checkList[] = array(
'type' => $row['type'],
'code' => $row['code'],
'comment' => $row['comment'],
'ownerNm' => $row['ownerNm'],
'ownerBirth' => $row['owner_birth'],
);
}
$modifyInfo = array();
if ($row_modify_info['modify_yn'] == 'Y') {
if (!empty($row_modify_info['hscp_no'])) {
// 공동주택
$modifyInfo = array(
'hscpNo' => $row_modify_info['hscp_no'],
'ptpNo' => $row_modify_info['ptp_no'],
'bildNm' => $row_modify_info['address2'],
'rmNo' => $row_modify_info['address3'],
'tradeType' => $row_modify_info['trade_type'],
'dealAmt' => $row_modify_info['deal_amt'],
'wrrntAmt' => $row_modify_info['wrrnt_amt'],
'leaseAmt' => $row_modify_info['lease_amt'],
'isaleAmt' => $row_modify_info['isale_amt'],
'premAmt' => $row_modify_info['prem_amt'],
'floor' => $row_modify_info['floor'],
);
} else {
// 비공동주택
$modifyInfo = array(
'addressCode' => $row_modify_info['address_code'],
'address2' => $row_modify_info['address2'],
'address3' => $row_modify_info['address3'],
'tradeType' => $row_modify_info['trade_type'],
'dealAmt' => $row_modify_info['deal_amt'],
'wrrntAmt' => $row_modify_info['wrrnt_amt'],
'leaseAmt' => $row_modify_info['lease_amt'],
'splySpc' => $row_modify_info['sply_spc'],
'exclsSpc' => $row_modify_info['excls_spc'],
'totSpc' => $row_modify_info['tot_spc'],
'grndSpc' => $row_modify_info['grnd_spc'],
'bldgSpc' => $row_modify_info['bldg_spc'],
'floor' => $row_modify_info['floor'],
'floor2' => $row_modify_info['floor2'],
);
}
return array(
'atclNo' => $atclNo,
'type' => $type,
'success' => $success,
'checkList' => $checkList,
'charger' => $charger,
'modifyInfo' => $modifyInfo,
'date' => $date,
'ownerVerifiable' => $ownerVerifiable,
);
} else {
return array(
'atclNo' => $atclNo,
'type' => $type,
'success' => $success,
'checkList' => $checkList,
'charger' => $charger,
'date' => $date,
'ownerVerifiable' => $ownerVerifiable,
);
}
}
public function chgRegiTryCnt($vr_sq, $try_cnt)
{ //v2_vrfc_req try_cnt 값 변경.
$sql = "UPDATE v2_vrfc_req" .
" SET reg_try_cnt = ?" .
" WHERE vr_sq = ?";
$data = array(
$try_cnt,
$vr_sq
);
$res = $this->db->query($sql, $data);
}
public function InsCharger($atcl_vr_sq)
{
$usr_id = session('usr_id');
$sql = "UPDATE v2_article_info" .
" SET charger = ?" .
" WHERE vr_sq = ?";
$data = array(
$usr_id,
$atcl_vr_sq
);
$res = $this->db->query($sql, $data);
$log_v = $this->db->getLastQuery();
log_message('debug', $log_v);
}
public function chkTryCnt($atcl_vr_sq)
{
$builder = $this->db->table('v2_vrfc_req a');
$builder->select('a.try_cnt');
$builder->where('a.vr_sq', $atcl_vr_sq);
$query = $builder->get();
return $query->getRowArray();
}
public function saveMemo($data)
{
$usr_id = session('usr_id');
$sql = "UPDATE v2_vrfc_req SET
memo = ?
WHERE vr_sq = ?
";
if ($this->db->query($sql, [$data['memo'], $data['vr_sq']]) === false) {
return [
'success' => false,
'msg' => '저장 실패',
];
}
$detail = $this->getDetail($data['vr_sq']);
$memo = "메모변경 : " . $detail['memo'] . " => " . $data['memo'];
$this->saveHistory($data['vr_sq'], $data['pre_stat_cd'], 'C19', $usr_id, $memo);
return [
'success' => true,
];
}
// 변경이력 조회
public function getHistory($vr_sq)
{