diff --git a/app/Commands/NaverWorker.php b/app/Commands/NaverWorker.php
index 8e6866a..ef17c5e 100644
--- a/app/Commands/NaverWorker.php
+++ b/app/Commands/NaverWorker.php
@@ -26,6 +26,14 @@ class NaverWorker extends BaseCommand
helper(['log', 'redis']); // redis helper 추가
$this->db = \Config\Database::connect();
+
+ // 워커 시작 시점에 선제적으로 연결 상태를 보정
+ try {
+ $this->db->initialize();
+ } catch (\Throwable $e) {
+ CLI::error('Database connection init failed: ' . $e->getMessage());
+ }
+
$logModel = model(NaverWorkerLogModel::class);
$naverService = new \App\Services\NaverService(); // 서비스 생성
@@ -107,12 +115,13 @@ class NaverWorker extends BaseCommand
'raw_payload' => $rawData,
'status' => 'INIT'
]);
- } catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
- // MySQL gone away 에러 시 재연결 후 재시도
- if (strpos($e->getMessage(), 'MySQL server has gone away') !== false) {
+ } catch (\Throwable $e) {
+ // MySQL 연결 계열 에러 시 재연결 후 재시도
+ if ($this->isMySqlConnectionError($e)) {
CLI::write(CLI::color('⚠️ MySQL gone away, reconnecting...', 'yellow'));
$this->db->close();
$this->db = \Config\Database::connect();
+ $this->db->initialize();
$logModel = model(NaverWorkerLogModel::class);
// 재시도
@@ -188,17 +197,18 @@ class NaverWorker extends BaseCommand
}
/**
- * MySQL gone away 에러 발생 시 재연결 후 재시도하는 안전한 update
+ * MySQL 연결 계열 에러 발생 시 재연결 후 재시도하는 안전한 update
*/
protected function safeUpdateLog($logModel, $logId, $data)
{
try {
return $logModel->update($logId, $data);
- } catch (\CodeIgniter\Database\Exceptions\DatabaseException $e) {
- if (strpos($e->getMessage(), 'MySQL server has gone away') !== false) {
+ } catch (\Throwable $e) {
+ if ($this->isMySqlConnectionError($e)) {
CLI::write(CLI::color('⚠️ MySQL gone away on update, reconnecting...', 'yellow'));
$this->db->close();
$this->db = \Config\Database::connect();
+ $this->db->initialize();
$logModel = model(\App\Models\Entities\NaverWorkerLogModel::class);
// 재시도
@@ -209,6 +219,18 @@ class NaverWorker extends BaseCommand
}
}
+ /**
+ * MySQL 연결 끊김 계열 에러 여부 판별
+ */
+ protected function isMySqlConnectionError(\Throwable $e): bool
+ {
+ $message = strtolower($e->getMessage());
+
+ return str_contains($message, 'mysql server has gone away')
+ || str_contains($message, 'lost connection to mysql server')
+ || str_contains($message, 'server has gone away');
+ }
+
/**
* 폴백 파일에서 데이터 읽기 (Redis 장애 시 파일에서 직접 처리)
*
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index bd28076..1ff75bd 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -28,6 +28,8 @@ $routes->group('common', ['namespace' => 'App\Controllers\Common'], function ($r
$routes->post('common/changeUserPass', 'Common::changeUserPass'); // 비밀번호변경
+ $routes->get('getComplexList', 'Common::getComplexList'); // 단지목록조회
+ $routes->get('getPyeongInfo', 'Common::getPyeongInfo'); // 평형정보조회
});
@@ -84,6 +86,8 @@ $routes->group('', ['namespace' => 'App\Controllers\Article'], static function (
$routes->post('updateImageOrder', 'Receipt::updateImageOrder'); // 이미지 순서 업데이트
$routes->get('downloadAllImages', 'Receipt::downloadAllImages'); // 이미지 일괄 다운로드
$routes->post('saveImgLocation', 'Receipt::saveImgLocation'); // 촬영위치 저장
+
+ $routes->post('modifyPriceInfo', 'Receipt::modifyPriceInfo'); // 가격정보 수정
});
/**
diff --git a/app/Controllers/Article/Receipt.php b/app/Controllers/Article/Receipt.php
index 9008a65..17371d8 100644
--- a/app/Controllers/Article/Receipt.php
+++ b/app/Controllers/Article/Receipt.php
@@ -9,27 +9,64 @@ use App\Libraries\NaverApiClient;
use App\Models\article\DeptModel;
use App\Models\article\ReceiptModel;
use App\Models\common\CodeModel;
+use App\Models\Entities\ReceiptModel as ReceiptEntity;
+use App\Models\Entities\ChangedHistoryModel as ChangedHistoryEntity;
use Exception;
class Receipt extends BaseController
{
- private $model, $codeModel;
+ private $model, $entityModel, $codeModel, $changedHistoryEntity;
+ private $naverApiClient;
+
+ private const SEARCH_FILTER_KEYS = [
+ 'rcpt_atclno',
+ 'schDateGb',
+ 'sdate',
+ 'edate',
+ 'bonbu',
+ 'team',
+ 'user',
+ 'sido',
+ 'gugun',
+ 'dong',
+ 'rcpt_stat1',
+ 'rcpt_stat2',
+ 'rcpt_stat3',
+ 'rcpt_product_info1',
+ 'exp_movie_yn',
+ 'conf_img_yn',
+ 'parcel_out_yn',
+ 'rcpt_cpid',
+ 'rcpt_product',
+ 'exp_spc_yn',
+ 'check_list_img_yn',
+ 'ground_plan_yn',
+ 'ground_plan',
+ 'direct_trad_yn',
+ 'image_360_yn',
+ 'srchType',
+ 'srchTxt',
+ ];
public function __construct()
{
$this->model = new ReceiptModel();
+ $this->entityModel = new ReceiptEntity();
$this->codeModel = new CodeModel();
+ $this->changedHistoryEntity = new ChangedHistoryEntity();
+ $this->naverApiClient = new NaverApiClient();
}
public function lists(): string
{
- log_message('error', '========== Receipt::lists() CALLED ==========');
+ log_message('info', '========== Receipt::lists() CALLED ==========');
$usr_id = $this->request->getGet('usr_id') ?: '';
$sBonbu = $this->request->getGet('bonbu') ?: '';
- $sTeanm = $this->request->getGet('dept_sq') ?: '';
+ $sTeam = $this->request->getGet('dept_sq') ?: '';
$codes = $this->codeModel->getCodeLists(['NHN_DEAL_TYPE', 'CP_ID', 'ARTICLE_TYPE', 'VRFCREQ_WAY', 'STEP_VERIFICATION']); // 코드조회
+
$sido = $this->model->getAreaList(); // 지역조회
$bonbu = $this->model->getBonbuList();
$team = $this->model->getTeamList();
@@ -48,7 +85,8 @@ class Receipt extends BaseController
}
$this->data['sBonbu'] = $sBonbu;
- $this->data['sTeanm'] = $sTeanm;
+ $this->data['sTeam'] = $sTeam;
+ $this->data['sTeanm'] = $sTeam;
return view("pages/article/receipt/lists", $this->data);
@@ -61,40 +99,7 @@ class Receipt extends BaseController
$start = (int) $this->request->getGet('start') ?: 0;
$end = (int) $this->request->getGet('length') ?: 10;
- $data = [
- 'rcpt_atclno' => $this->request->getGet('rcpt_atclno'), // 매물ID
- 'schDateGb' => $this->request->getGet('schDateGb'), // 일자유형
- 'sdate' => $this->request->getGet('sdate'), // 시작일
- 'edate' => $this->request->getGet('edate'), // 종료일
-
- 'bonbu' => $this->request->getGet('bonbu'), // 본부
- 'team' => $this->request->getGet('team'), // 팀
- 'user' => $this->request->getGet('user'), // 담당자
-
- 'sido' => $this->request->getGet('sido'), // 시도
- 'gugun' => $this->request->getGet('gugun'), // 시군구
- 'dong' => $this->request->getGet('dong'), // 읍면동
-
- 'rcpt_stat1' => $this->request->getGet('rcpt_stat1'), // 상태1
- 'rcpt_stat2' => $this->request->getGet('rcpt_stat2'), // 상태2
- 'rcpt_stat3' => $this->request->getGet('rcpt_stat3'), // 상태3
-
- 'rcpt_product_info1' => $this->request->getGet('rcpt_product_info1'), // 거래구분
- 'exp_movie_yn' => $this->request->getGet('exp_movie_yn'), // 동영상촬영여부
- 'conf_img_yn' => $this->request->getGet('conf_img_yn'), // 홍보확인서여부
- 'parcel_out_yn' => $this->request->getGet('parcel_out_yn'), // 분양권
- 'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // CPID
- 'rcpt_product' => $this->request->getGet('rcpt_product'), // 매물종류
- 'exp_spc_yn' => $this->request->getGet('exp_spc_yn'), // 면적확인
- 'check_list_img_yn' => $this->request->getGet('check_list_img_yn'), // 체크리스트
- 'ground_plan_yn' => $this->request->getGet('ground_plan_yn'), // 평면도유무
- 'ground_plan' => $this->request->getGet('ground_plan'), // 평면도요청
-
- 'direct_trad_yn' => $this->request->getGet('direct_trad_yn'), // 직거래
- 'image_360_yn' => $this->request->getGet('image_360_yn'), // 360촬영여부
- 'srchType' => $this->request->getGet('srchType'), // 검색유형
- 'srchTxt' => $this->request->getGet('srchTxt'), // 검색어
- ];
+ $data = $this->getSearchFilterData();
log_message('info', '[Receipt::getResultList] START - start=' . $start . ' length=' . $end);
@@ -103,7 +108,7 @@ class Receipt extends BaseController
$datas = $this->model->getResultList($start, $end, $data);
log_message('info', '[Receipt::getResultList] END - returned ' . count($datas) . ' rows');
-
+ // echo db_connect()->getLastQuery();
return $this->response->setJSON(body: [
'recordsTotal' => $totalCount,
'recordsFiltered' => $totalCount,
@@ -116,41 +121,7 @@ class Receipt extends BaseController
public function excel()
{
try {
-
- $data = [
- 'rcpt_atclno' => $this->request->getGet('rcpt_atclno'), // 매물ID
- 'schDateGb' => $this->request->getGet('schDateGb'), // 일자유형
- 'sdate' => $this->request->getGet('sdate'), // 시작일
- 'edate' => $this->request->getGet('edate'), // 종료일
-
- 'bonbu' => $this->request->getGet('bonbu'), // 본부
- 'team' => $this->request->getGet('team'), // 팀
- 'user' => $this->request->getGet('user'), // 담당자
-
- 'sido' => $this->request->getGet('sido'), // 시도
- 'gugun' => $this->request->getGet('gugun'), // 시군구
- 'dong' => $this->request->getGet('dong'), // 읍면동
-
- 'rcpt_stat1' => $this->request->getGet('rcpt_stat1'), // 상태1
- 'rcpt_stat2' => $this->request->getGet('rcpt_stat2'), // 상태2
- 'rcpt_stat3' => $this->request->getGet('rcpt_stat3'), // 상태3
-
- 'rcpt_product_info1' => $this->request->getGet('rcpt_product_info1'), // 거래구분
- 'exp_movie_yn' => $this->request->getGet('exp_movie_yn'), // 동영상촬영여부
- 'conf_img_yn' => $this->request->getGet('conf_img_yn'), // 홍보확인서여부
- 'parcel_out_yn' => $this->request->getGet('parcel_out_yn'), // 분양권
- 'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // CPID
- 'rcpt_product' => $this->request->getGet('rcpt_product'), // 매물종류
- 'exp_spc_yn' => $this->request->getGet('exp_spc_yn'), // 면적확인
- 'check_list_img_yn' => $this->request->getGet('check_list_img_yn'), // 체크리스트
- 'ground_plan_yn' => $this->request->getGet('ground_plan_yn'), // 평면도유무
- 'ground_plan' => $this->request->getGet('ground_plan'), // 평면도요청
-
- 'direct_trad_yn' => $this->request->getGet('direct_trad_yn'), // 직거래
- 'image_360_yn' => $this->request->getGet('image_360_yn'), // 360촬영여부
- 'srchType' => $this->request->getGet('srchType'), // 검색유형
- 'srchTxt' => $this->request->getGet('srchTxt'), // 검색어
- ];
+ $data = $this->getSearchFilterData();
$datas = $this->model->getExcelList($data);
@@ -159,15 +130,28 @@ class Receipt extends BaseController
]);
} catch (\Exception $e) {
- $e->getPrevious()->getTraceAsString();
+ log_message('error', '[Receipt::excel] Error: ' . $e->getMessage());
+ return $this->response->setJSON([
+ 'code' => '9',
+ 'msg' => $e->getMessage(),
+ ]);
}
}
+ private function getSearchFilterData(): array
+ {
+ $data = [];
+ foreach (self::SEARCH_FILTER_KEYS as $key) {
+ $data[$key] = $this->request->getGet($key);
+ }
+
+ return $data;
+ }
+
// 상세화면
public function detail($id)
{
- $naver = new NaverApiClient();
$id = (string) $id;
if ($id === '') {
@@ -188,13 +172,16 @@ class Receipt extends BaseController
$damdang = $this->model->getUserList();
-
+ $complexList = $this->naverApiClient->complexList($id);
// sms 코드
$sms = [];
- foreach ($codes as $c) {
- if ($c['category'] === "SMS_MSG_TYPE2")
- array_push($sms, $c);
+ foreach (($codes['SMS_MSG_TYPE2']['items'] ?? []) as $cd => $cdNm) {
+ $sms[] = [
+ 'category' => 'SMS_MSG_TYPE2',
+ 'cd' => $cd,
+ 'cd_nm' => $cdNm,
+ ];
}
$t3 = microtime(true);
@@ -265,10 +252,10 @@ class Receipt extends BaseController
if ($data['comp_sq'] == '2') {
// 아파트단지목록
- $complexList = $naver->complexList($data['rcpt_dong']);
+ $complexList = $this->naverApiClient->complexList($data['rcpt_dong']);
// 평형목록
- $ptpList = $naver->ptpList($data['rcpt_hscp_no']);
+ $ptpList = $this->naverApiClient->ptpList($data['rcpt_hscp_no']);
}
// print_r($ptpList);
@@ -313,10 +300,13 @@ class Receipt extends BaseController
public function saveTel()
{
try {
-
- $tel = $this->request->getPost('agent_tel');
-
- $this->model->saveTel($tel);
+
+ $tel = (string) $this->request->getPost('agent_tel');
+ $rcpt_sq = (string) $this->request->getPost('rcpt_sq');
+ if (empty($tel)) {
+ throw new Exception("전화번호가 입력되지 않았습니다.");
+ }
+ $this->model->saveTel($rcpt_sq , $tel);
return $this->response->setJSON([
@@ -335,8 +325,6 @@ class Receipt extends BaseController
// 거주여부 저장
public function resDbYn()
{
- $naver = new NaverApiClient();
-
try {
$rcpt_key = $this->request->getPost('rcpt_key');
@@ -362,7 +350,7 @@ class Receipt extends BaseController
log_message('info', '[resDbYn] 네이버 API 호출 시작 - rcpt_key: ' . $rcpt_key . ', charger: ' . $charger . ', updateData: ' . json_encode($updateData, JSON_UNESCAPED_UNICODE));
- $api_result = $naver->updateArticleInfo($rcpt_key, $updateData, $charger);
+ $api_result = $this->naverApiClient->updateArticleInfo($rcpt_key, $updateData, $charger);
log_message('info', '[resDbYn] 네이버 API 응답 - result: ' . json_encode($api_result, JSON_UNESCAPED_UNICODE) . ' (type: ' . gettype($api_result) . ')');
@@ -429,7 +417,6 @@ class Receipt extends BaseController
// 예약확정 저장
public function assignRegist()
{
- $naver = new NaverApiClient();
$deptModel = new DeptModel();
try {
@@ -451,7 +438,7 @@ class Receipt extends BaseController
$receipt = $this->model->getDetail($rcpt_key);
/*** 네이버 연동[s] ***/
- $na_result = $naver->reserveSuccess($rcpt_key, 'Y', $bonbuInfo['dept_nm'], $deptInfo['dept_nm'], $userInfo['usr_nm'], $userInfo['usr_tel1'], $rsrv_date, $rsrv_tm_ap);
+ $na_result = $this->naverApiClient->reserveSuccess($rcpt_key, 'Y', $bonbuInfo['dept_nm'], $deptInfo['dept_nm'], $userInfo['usr_nm'], $userInfo['usr_tel1'], $rsrv_date, $rsrv_tm_ap);
/*** 네이버 연동[e] ***/
if (isset($na_result['code']) && $na_result['code'] === 'success') { //네이버연동 상태변경 완료
@@ -527,8 +514,6 @@ class Receipt extends BaseController
// 예약취소
public function rsrvcancel()
{
- $naver = new NaverApiClient();
-
try {
//전달받은 값
$rcpt_sq = $this->request->getPost('rcpt_sq');
@@ -543,19 +528,19 @@ class Receipt extends BaseController
/*** 네이버 연동[s] ***/
if ($result_cd2 == '9010' || $result_cd2 == '9020') { //예약취소
- $na_result = $naver->reserveFail($rcpt_key, "E11", $result_msg);
+ $na_result = $this->naverApiClient->reserveFail($rcpt_key, "E11", $result_msg);
} else if ($result_cd2 == '9030') {
if ($rcpt_stat1 == '70') {
throw new \Exception('방문전 취소 할 수 없습니다.');
} else {
- $na_result = $naver->shootFail($rcpt_key, "E21", $result_msg);
+ $na_result = $this->naverApiClient->shootFail($rcpt_key, "E21", $result_msg);
}
} else if ($result_cd2 == '9040') {
- $na_result = $naver->shootFail($rcpt_key, "E22", $result_msg);
+ $na_result = $this->naverApiClient->shootFail($rcpt_key, "E22", $result_msg);
} else if ($result_cd2 == '9045') {
- $na_result = $naver->shootFail($rcpt_key, "E23", $result_msg);
+ $na_result = $this->naverApiClient->shootFail($rcpt_key, "E23", $result_msg);
} else if ($result_cd2 == '9050') {
- $na_result = $naver->inspectFail($rcpt_key, 'E31', $result_msg);
+ $na_result = $this->naverApiClient->inspectFail($rcpt_key, 'E31', $result_msg);
}
/*** 네이버 연동[e] ***/
@@ -599,7 +584,7 @@ class Receipt extends BaseController
$rletTypeCd = $this->request->getGet('rletTypeCd');
- // 파라미터 디버그 로깅
+ // 파라미터 로깅
$p = [
'rcpt_sq' => $rcpt_sq,
'rcpt_key' => $rcpt_key,
@@ -615,9 +600,10 @@ class Receipt extends BaseController
'rletTypeCd' => $rletTypeCd,
];
+ log_message('info', '[Receipt::chgStatus] params: ' . json_encode($p, JSON_UNESCAPED_UNICODE));
- print_r($p);
- exit;
+ // TODO: 기존 비즈니스 로직 복원 필요
+ throw new \Exception('상태변경 로직 점검 중입니다. 잠시 후 다시 시도해주세요.');
} catch (\Exception $e) {
@@ -1339,59 +1325,129 @@ class Receipt extends BaseController
}
}
- public function modifyPriceInfo(){
+ public function modifyPriceInfo()
+ {
try {
- $rcpt_sq = $this->request->getPost('rcpt_sq'); // 필수
- $rcpt_key = $this->request->getPost('rcpt_key'); // 필수
- $rcpt_no = $this->request->getPost('rcpt_no'); // 선택
- $trade_type = $this->request->getPost('trade_type'); // 거래구분
- $rcpt_product_info2 = $this->request->getPost('rcpt_product_info2'); // 보증금
- $rcpt_product_info3 = $this->request->getPost('rcpt_product_info3'); // 월세
- $rcpt_product_info4 = $this->request->getPost('rcpt_product_info4'); // 분양가
- $rcpt_product_info5 = $this->request->getPost('rcpt_product_info5'); // 프리미엄
- $rcpt_ptp_no = $this->request->getPost('rcpt_ptp_no'); // 단지정보
- $rcpt_hscp_no = $this->request->getPost('rcpt_hscp_no'); // 평형정보
+ $rcpt_sq = $this->request->getPost('rcpt_sq');
+ $rcpt_key = $this->request->getPost('rcpt_key');
+ $trade_type = $this->request->getPost('trade_type');
+ $rcpt_product_info2 = $this->request->getPost('rcpt_product_info2');
+ $rcpt_product_info3 = $this->request->getPost('rcpt_product_info3');
+ $rcpt_product_info4 = $this->request->getPost('rcpt_product_info4');
+ $rcpt_product_info5 = $this->request->getPost('rcpt_product_info5');
+ $rcpt_product_info6 = $this->request->getPost('rcpt_product_info6');
- // 거래유형에 따른 가격 정보 제한
- $return = limitHscpMarketPriceInfo($trade_type, $rcpt_hscp_no, $rcpt_ptp_no, $rcpt_product_info2);
- if (empty($return)){
-
- }
-
- if (empty($rcpt_sq) || empty($trade_type)) {
+ $rcpt_ptp_no = $this->request->getPost('rcpt_ptp_no');
+ $rcpt_hscp_no = $this->request->getPost('rcpt_hscp_no');
+
+ $dealAmount = $this->request->getPost('dealAmount') ?: 0;
+ $warrantyAmount = $this->request->getPost('warrantyAmount') ?: 0;
+ $leaseAmount = $this->request->getPost('leaseAmount') ?: 0;
+ $preSaleAmount = $this->request->getPost('preSaleAmount') ?: 0;
+ $premiumAmount = $this->request->getPost('premiumAmount') ?: 0;
+ $preSaleOptionAmount = $this->request->getPost('preSaleOptionAmount') ?: 0;
+
+ if (empty($rcpt_sq) || empty($rcpt_key) || empty($trade_type)) {
return $this->response->setJSON([
'code' => '1',
'msg' => '필수 파라미터가 누락되었습니다.'
]);
}
- $params = [
- 'rcpt_sq' => $rcpt_sq,
- 'rcpt_key' => $rcpt_key,
- 'rcpt_no' => $rcpt_no,
+ $receipt = $this->model->getDetail($rcpt_key);
+ if (empty($receipt)) {
+ return $this->response->setJSON([
+ 'code' => '1',
+ 'msg' => '매물 정보를 찾을 수 없습니다.'
+ ]);
+ }
+
+ // 거래유형에 따른 가격 정보 제한
+ $limitCheck = limitHscpMarketPriceInfo($trade_type, $rcpt_hscp_no, $rcpt_ptp_no, $rcpt_product_info2);
+ if (!empty($limitCheck)) {
+ return $this->response->setJSON([
+ 'code' => '1',
+ 'msg' => $limitCheck['message'] ?? '가격 범위를 벗어났습니다.'
+ ]);
+ }
+
+ $data = [
'trade_type' => $trade_type,
'rcpt_product_info2' => $rcpt_product_info2,
'rcpt_product_info3' => $rcpt_product_info3,
'rcpt_product_info4' => $rcpt_product_info4,
'rcpt_product_info5' => $rcpt_product_info5,
+ 'rcpt_product_info6' => $rcpt_product_info6,
'rcpt_ptp_no' => $rcpt_ptp_no,
'rcpt_hscp_no' => $rcpt_hscp_no,
+ 'dealAmount' => $dealAmount,
+ 'warrantyAmount' => $warrantyAmount,
+ 'leaseAmount' => $leaseAmount,
+ 'preSaleAmount' => $preSaleAmount,
+ 'premiumAmount' => $premiumAmount,
+ 'preSaleOptionAmount' => $preSaleOptionAmount,
];
- $result = $this->model->modifyPriceInfo($params);
-
- if (!$result['success']) {
+ $updated = $this->entityModel->update($rcpt_sq, $data);
+ if (!$updated) {
+ $errors = $this->entityModel->errors();
+ log_message('error', 'Failed to update modifyPriceInfo info for rcpt_sq: ' . $rcpt_sq . '. Errors: ' . json_encode($errors));
return $this->response->setJSON([
'code' => '1',
- 'msg' => $result['msg'] ?? '가격 정보 수정 실패'
+ 'msg' => !empty($errors) ? implode(', ', $errors) : '가격 정보 수정 실패'
]);
}
+ $affectedRows = $this->entityModel->db->affectedRows();
+ $isChanged = ($affectedRows > 0);
+
+ if (!$isChanged) {
+ return $this->response->setJSON([
+ 'code' => '0',
+ 'changed' => false,
+ 'msg' => '변경사항이 없습니다.'
+ ]);
+ }
+
+ log_message('info', 'Price info updated for rcpt_sq: ' . $rcpt_sq . '. Affected rows: ' . $affectedRows);
+
+ $changed = what_is_changed($receipt, $data);
+ log_message('info', 'what_is_changed result for rcpt_sq: ' . $rcpt_sq . '. Changes: ' . $changed);
+ if (!empty($changed)) {
+ $this->changedHistoryEntity->addHistory(
+ $rcpt_sq,
+ $receipt['result_cd3'] ?? '',
+ 'C25',
+ session('usr_id'),
+ $changed
+ );
+ }
+
+ $usr_id = session('usr_id');
+ $atcl_no = $receipt['rcpt_atclno'] ?? null;
+
+ if (!empty($atcl_no)) {
+ $params = [
+ 'dealAmount' => $dealAmount,
+ 'warrantyAmount' => $warrantyAmount,
+ 'leaseAmount' => $leaseAmount,
+ ];
+
+ if (in_array($receipt['rcpt_product'] ?? '', ['B01', 'B02', 'B03'], true)) {
+ $params['preSaleAmount'] = $preSaleAmount;
+ $params['premiumAmount'] = $premiumAmount;
+ $params['preSaleOptionAmount'] = $preSaleOptionAmount;
+ }
+
+ $priceInfo = $this->naverApiClient->postArticlePriceUpdate($atcl_no, $params, $usr_id);
+ log_message('info', 'postArticlePriceUpdate response for atcl_no: ' . $atcl_no . '. Response: ' . json_encode($priceInfo));
+ }
+
return $this->response->setJSON([
'code' => '0',
+ 'changed' => true,
'msg' => '가격 정보가 수정되었습니다.'
]);
-
} catch (\Exception $e) {
log_message('error', 'modifyPriceInfo error: ' . $e->getMessage());
return $this->response->setJSON([
diff --git a/app/Controllers/Common/Common.php b/app/Controllers/Common/Common.php
index 315211a..6817597 100644
--- a/app/Controllers/Common/Common.php
+++ b/app/Controllers/Common/Common.php
@@ -4,16 +4,19 @@ namespace App\Controllers\Common;
use App\Controllers\BaseController;
use App\Models\common\CommonModel;
use App\Models\manage\UserModel;
+use App\Libraries\NaverApiClient;
class Common extends BaseController
{
private $model;
private $userModel;
+ private $naverApiClient;
public function __construct()
{
$this->model = new CommonModel();
$this->userModel = new UserModel();
+ $this->naverApiClient = new NaverApiClient();
}
public function getVrfcCode()
@@ -118,4 +121,54 @@ class Common extends BaseController
]);
}
}
+
+ // 단지 조회
+ public function getComplexList()
+ {
+ $legalDivisionNumber = $this->request->getGet("legalDivisionNumber");
+ $realEstateType = $this->request->getGet("realEstateType") ?? null;
+
+ try {
+ $complexList = $this->naverApiClient->getComplexList($legalDivisionNumber , $realEstateType);
+
+ return $this->response->setJSON($complexList);
+ } catch (\Exception $e) {
+ return $this->response->setJSON([
+ 'code' => '9',
+ 'msg' => $e->getMessage(),
+ ]);
+ }
+ }
+
+ /**
+ * 평형 조회
+ *
+ * complexNumber : 단지 번호
+ * realEstateType : 매물 종류 (APT, OFFICETEL, VILLA 등)
+ */
+ public function getPyeongInfo()
+ {
+ $complexNumber = $this->request->getGet("complexNumber");
+ $realEstateType = $this->request->getGet("realEstateType");
+ try {
+
+ if ( $realEstateType == 'A01' || $realEstateType == 'A02' || $realEstateType == 'A03' ) {
+ $pyeongInfo = $this->naverApiClient->getPyeongTypeList($complexNumber);
+ } else if ( $realEstateType == 'A05' || $realEstateType == 'A06' ) {
+ $pyeongInfo = $this->naverApiClient->getVillaPyeongTypeList($complexNumber);
+ } else {
+ return $this->response->setJSON([
+ 'code' => '9',
+ 'msg' => '지원하지 않는 매물 종류입니다.',
+ ]);
+ }
+
+ return $this->response->setJSON($pyeongInfo);
+ } catch (\Exception $e) {
+ return $this->response->setJSON([
+ 'code' => '9',
+ 'msg' => $e->getMessage(),
+ ]);
+ }
+ }
}
\ No newline at end of file
diff --git a/app/Controllers/V2/M710.php b/app/Controllers/V2/M710.php
index 7429419..d9b5c05 100644
--- a/app/Controllers/V2/M710.php
+++ b/app/Controllers/V2/M710.php
@@ -18,6 +18,7 @@ class M710 extends BaseController
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();
diff --git a/app/Helpers/function_helper.php b/app/Helpers/function_helper.php
index 3d33269..cea8a01 100644
--- a/app/Helpers/function_helper.php
+++ b/app/Helpers/function_helper.php
@@ -14,34 +14,26 @@ if (!function_exists('limitHscpMarketPriceInfo')) {
if (!empty($hscp_no) && !empty($ptp_no)) {
$naver = new \App\Libraries\NaverApiClient();
- $hscpMarketPriceInfo = $naver->hscpMarketPriceInfo($hscp_no, $ptp_no);
+ $hscpMarketPriceInfo = $naver->getComplexPriceByUnitType((int)$hscp_no, (int)$ptp_no);
- if (isset($hscpMarketPriceInfo['error'])) { //결과값 확인
- if ($hscpMarketPriceInfo['error']['code'] == 'VC027') {
- $return = array();
- } else {
- $return = $hscpMarketPriceInfo['error'];
- }
+ if (isset($hscpMarketPriceInfo['error']) && $hscpMarketPriceInfo['error']) { //결과값 확인
+ log_message('error', '네이버 시세 API 호출 실패: ' . json_encode($hscpMarketPriceInfo));
+ return array();
} else {
$limitH = 0;
$limitL = 0;
+ $sise = array();
+ $sise = $hscpMarketPriceInfo['data'];
// 상한가, 하한가 체크 ( 상한가 * 2, 하한가 * 0.7) 이내의 범위에 가격이 있어야 함.
if ($trade_type == 'A1') {
// 매매
- if (isset($hscpMarketPriceInfo['result']['deal_uplmt_prc'])) {
- $limitH = $hscpMarketPriceInfo['result']['deal_uplmt_prc'];
- }
- if (isset($hscpMarketPriceInfo['result']['deal_lwlmt_prc'])) {
- $limitL = $hscpMarketPriceInfo['result']['deal_lwlmt_prc'];
- }
+ $limitH = $sise['dealCeilingPrice'] ?? 0;
+ $limitL = $sise['dealFloorPrice'] ?? 0;
+
} elseif ($trade_type == 'B1') {
// 전세
- if (isset($hscpMarketPriceInfo['result']['lease_uplmt_prc'])) {
- $limitH = $hscpMarketPriceInfo['result']['lease_uplmt_prc'];
- }
- if (isset($hscpMarketPriceInfo['result']['lease_lwlmt_prc'])) {
- $limitL = $hscpMarketPriceInfo['result']['lease_lwlmt_prc'];
- }
+ $limitH = $sise['leaseCeilingPrice'] ?? 0;
+ $limitL = $sise['leaseFloorPrice'] ?? 0;
}
if (!empty($limitH)) {
@@ -317,3 +309,146 @@ function getOwnerTypeCodeNo($code)
break;
}
}
+
+
+/**
+ * 무엇이 변경되었는지 확인한다.
+ * $table(DB의 원래 데이터), data (변경된 내용) ==> array
+ */
+function what_is_changed($table, $data){
+ $return = '';
+ if (empty($table) || empty($data)){
+ log_message('warning', 'what_is_changed 함수에 빈 데이터 전달 | table: ' . json_encode($table) . ', data: ' . json_encode($data));
+ return $return;
+ }
+
+ foreach ( $data as $key => $value ) {
+ if (!array_key_exists($key, $table)) {
+ $table[$key] = '';
+ }
+
+ if (strcmp(trim((string) $table[$key]), trim((string) $value)) != 0){
+ switch ( $key ) {
+ case 'trade_type': // 거래구분
+ $return .= ', 거래구분 : ';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_product_info2': // 매매, 전세, 월세보증금
+ $return .= ', 거래가 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_product_info3': // 월세
+ $return .= ', 월세 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_dtl_addr': // 상세주소
+ $return .= ', 상세주소 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_li_addr': //리 주소
+ $return .= ', 리 주소 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_jibun_addr': //지번 주소
+ $return .= ', 지번 주소 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_etc_addr': //기타 주소
+ $return .= ', 기타 주소 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_ref_addr': // 상세주소
+ $return .= ', 기타주소2 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_ho': // 기타주소
+ $return .= ', 기타주소 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_hscp_no': // 단지
+ $return .= ', 단지번호 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_ptp_no': // 평형
+ $return .= ', 평형 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'rcpt_floor': // 층
+ $return .= ', 층 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'exp_spc_yn': // 층
+ $return .= ', 면적확인여부 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'excls_spc1': // 층
+ $return .= ', 전용면적 첫번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'excls_spc2': // 층
+ $return .= ', 전용면적 두번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'room_cnt': // 층
+ $return .= ', 방개수 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'sply_spc': // 층
+ $return .= ', 공급면적 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'share_spc': // 층
+ $return .= ', 공용면적 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'tot_spc': // 층
+ $return .= ', 연면적 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'tot_spc1': // 층
+ $return .= ', 연면적 첫번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'tot_spc2': // 층
+ $return .= ', 연면적 두번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'grnd_spc1': // 층
+ $return .= ', 대지면적 첫번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'grnd_spc2': // 층
+ $return .= ', 대지면적 두번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'grnd_spc3': // 층
+ $return .= ', 대지면적 세번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'grnd_spc4': // 층
+ $return .= ', 대지면적 네번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'grnd_spc5': // 층
+ $return .= ', 대지면적 다섯번째 값 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'spc_stat': // 층
+ $return .= ', 면적구분 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+ case 'request_msg': // 층
+ $return .= ', 메모변경 :';
+ $return .= $table[$key] . ' => ' . $value . "\n";
+ break;
+// case 'rcpt_x': // 좌표 x 12x.xxxxx (경도: longitude)
+// $return .= '거래구분 :';
+// break;
+// case 'rcpt_y': // 좌표 y 3x.xxxx (위도: latitude)
+// $return .= '거래구분 :';
+// break;
+ }
+ }
+ }
+ return trim(substr($return, 1));
+}
\ No newline at end of file
diff --git a/app/Libraries/NaverApiClient.php b/app/Libraries/NaverApiClient.php
index a658fa0..17b499b 100644
--- a/app/Libraries/NaverApiClient.php
+++ b/app/Libraries/NaverApiClient.php
@@ -131,7 +131,7 @@ class NaverApiClient
$this->charger = $charger;
$url = "{$this->baseUrl}/kiso/center/verification-article/price/{$articleNumber}?charger={$this->charger}";
- return $this->request('POST', $url, $priceData);
+ return $this->request('PATCH', $url, $priceData);
}
/**
@@ -176,21 +176,85 @@ class NaverApiClient
/**
* 특정 단지/평형 시세조회()
- * @param string hscpNo 단지번호
- * @param string ptpNo 평형번호
+ * @param Long hscpNo 단지번호
+ * @param int ptpNo 평형번호
* API: GET /confirms/hscpMarketPriceInfo.nhn?hscpNo={단지번호}&ptpNo={평형번호}
*/
- public function hscpMarketPriceInfo($hscpNo, $ptpNo){
- $url = '/confirms/hscpMarketPriceInfo.nhn';
- $url = $this->commonModel->getCompanyInfo(3);
- $url = $url['api_server'] . $url;
- $data = [
- 'hscpNo' => $hscpNo,
- 'ptpNo' => $ptpNo
- ];
+ // public function hscpMarketPriceInfo($hscpNo, $ptpNo){
+ // $url = '/confirms/hscpMarketPriceInfo.nhn';
+ // $url = $this->commonModel->getCompanyInfo(3);
+ // $url = $url['api_server'] . $url;
+ // $data = [
+ // 'hscpNo' => $hscpNo,
+ // 'ptpNo' => $ptpNo
+ // ];
- return $this->request('GET', $url, $data);
- }
+ // return $this->request('GET', $url, $data);
+ // }
+ public function getComplexPriceByUnitType(int $hscpNo, int $ptpNo): ?array
+ {
+ $url = $this->baseUrl . "/kiso/marketprice/complex/{$hscpNo}/pyeong-type/{$ptpNo}";
+ return $this->request('GET', $url);
+ }
+
+ /**
+ * 법정동 기준 단지 목록 조회
+ * API: GET /kiso/complex/legal-division/{법정동코드}
+ * legalDivisionNumber : 법정동 코드
+ */
+ public function getComplexList($legalDivisionNumber, $realEstateType = null)
+ {
+ $url = $this->baseUrl . "/kiso/complex/legal-division/{$legalDivisionNumber}";
+ if ($realEstateType !== null) {
+ $url .= "?realEstateType={$realEstateType}";
+ }
+ return $this->request('GET', $url);
+ }
+
+ /**
+ * 단지평형목록 조회(아파트/오피스텔)
+ */
+ public function getPyeongTypeList($complexNumber){
+ $url = $this->baseUrl . "/kiso/complex/{$complexNumber}/pyeongs";
+ return $this->request('GET', $url);
+ }
+ /**
+ * 빌라 단지 평형 목록 조회
+ */
+ public function getVillaPyeongTypeList($complexNumber){
+ $url = $this->baseUrl . "/kiso/complex/villa/{$complexNumber}/pyeongs";
+ return $this->request('GET', $url);
+ }
+
+ /**
+ * 단지 상세 조회
+ */
+ public function getComplexDetail($complexNumber){
+ $url = $this->baseUrl . "/kiso/complex/{$complexNumber}";
+ return $this->request('GET', $url);
+ }
+
+ /**
+ * 빌라 단지 상세 조회
+ */
+ public function getVillaComplexDetail($complexNumber){
+ $url = $this->baseUrl . "/kiso/complex/villa/{$complexNumber}";
+ return $this->request('GET', $url);
+ }
+ /**
+ * 빌라 단지 동호수 조회
+ */
+ public function getVillaBuildingList($complexNumber){
+ $url = $this->baseUrl . "/kiso/complex/villa/{$complexNumber}/buildings";
+ return $this->request('GET', $url);
+ }
+
+
+ /**
+ * 현장확인 동기화 결과 전송
+ * API: GET /site/submitSyncResult.nhn?reserveNoList={예약번호리스트}
+ * @param string reserveNoList 예약번호 리스트 (쉼표로 구분된 문자열, 예: "12345,67890,54321")
+ */
public function submitSyncResult(string $reserveNoList): ?array
diff --git a/app/Models/Entities/ChangedHistoryModel.php b/app/Models/Entities/ChangedHistoryModel.php
new file mode 100644
index 0000000..0d59f27
--- /dev/null
+++ b/app/Models/Entities/ChangedHistoryModel.php
@@ -0,0 +1,47 @@
+ $rcptSq,
+ 'rcpt_stat' => $rcptStat,
+ 'changed_type' => $changedType,
+ 'changed_id' => $changedId,
+ 'changed_tm' => $changedTm ?? date('Y-m-d H:i:s'),
+ 'remark' => $remark,
+ ];
+
+ return $this->insert($data) !== false;
+ }
+}
+
diff --git a/app/Models/Entities/ReceiptModel.php b/app/Models/Entities/ReceiptModel.php
index e9aa285..6db9dad 100644
--- a/app/Models/Entities/ReceiptModel.php
+++ b/app/Models/Entities/ReceiptModel.php
@@ -13,7 +13,10 @@ class ReceiptModel extends Model
protected $allowedFields = [
'comp_sq', 'rcpt_rating', 'rcpt_key', 'rcpt_atclno', 'rcpt_type',
'rcpt_product', 'rcpt_product_nm', 'rcpt_product_info1', 'rcpt_product_info2',
- 'rcpt_product_info3', 'rcpt_office', 'rcpt_agent', 'rcpt_sido', 'rcpt_hscp_nm',
+ 'rcpt_product_info3', 'rcpt_product_info4', 'rcpt_product_info5', 'rcpt_product_info6',
+ 'trade_type', 'rcpt_ptp_no', 'rcpt_hscp_no',
+ 'dealAmount', 'warrantyAmount', 'leaseAmount', 'preSaleAmount', 'premiumAmount', 'preSaleOptionAmount',
+ 'rcpt_office', 'rcpt_agent', 'rcpt_sido', 'rcpt_hscp_nm',
'rcpt_dtl_addr', 'rcpt_etc_addr', 'rcpt_floor', 'rcpt_floor2', 'rcpt_tm',
'rcpt_stat', 'rcpt_x', 'rcpt_y', 'agent_nm', 'agent_head_tel', 'rsrv_date',
'insert_tm', 'rcpt_cpid', 'room_cnt', 'isSiteVRVerification'
@@ -104,4 +107,5 @@ class ReceiptModel extends Model
'total' => $totalCount
];
}
+
}
\ No newline at end of file
diff --git a/app/Models/article/ReceiptModel.php b/app/Models/article/ReceiptModel.php
index 48a8ad8..6b07f04 100644
--- a/app/Models/article/ReceiptModel.php
+++ b/app/Models/article/ReceiptModel.php
@@ -2,6 +2,7 @@
namespace App\Models\article;
use App\Models\common\CodeModel;
+use App\Models\Entities\ChangedHistoryModel;
use CodeIgniter\Model;
class ReceiptModel extends Model
@@ -205,209 +206,8 @@ class ReceiptModel extends Model
$builder->join('receipt_transimage_log l', 'a.rcpt_key = l.rcpt_key', 'left');
- $login_dept_info = $this->getDeptDetail($dept_sq); // 로그인 사용자 소속부서정보
- $child_dept = []; // 하위조직 목록
- if (strcmp($usr_level, '40') == 0) {
- $child = $this->getChildDept($login_dept_info);
- if (!empty($child)) {
- foreach ($child as $child) {
- $child_dept[] = $child['dept_sq'];
- }
- }
- }
-
- if ((int) $usr_level >= 4 && $usr_level != '45') {
- if (!empty($child_dept)) {
- $builder->whereIn('b.dept_sq', $child_dept);
- } else {
- $builder->where('b.usr_sq', $usr_sq);
- }
- }
-
- $builder->where('a.rcpt_tm >= DATE_ADD(CURDATE(), INTERVAL -3 MONTH)', null, false);
- $builder->where('b.use_yn', 'Y');
-
- if (!empty($data['rcpt_atclno'])) {
- $builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
- } else {
- if ($data['schDateGb'] == '2') {
- $builder->where('a.rcpt_tm >=', $data['sdate'] . ' 00:00:00');
- $builder->where('a.rcpt_tm <=', $data['edate'] . ' 23:59:59');
- } else {
- $builder->where('b.rsrv_date >=', $data['sdate'] . ' 00:00:00');
- $builder->where('b.rsrv_date <=', $data['edate'] . ' 23:59:59');
- }
-
- // 지역
- if (!empty($data['dong'])) {
- $builder->where('a.rcpt_dong', $data['dong']);
- } else {
- if (!empty($data['gugun'])) {
- $builder->like('a.rcpt_gugun', substr($data['gugun'], 0, 5), 'after');
- } else {
- if (!empty($data['sido'])) {
- $builder->like('a.rcpt_gugun', substr($data['sido'], 0, 2), 'after');
- }
- }
- }
-
- // 관할조직
- if (!empty($data['bonbu'])) {
- $builder->where('d.pdept_sq', $data['bonbu']);
- }
-
- if (!empty($data['team'])) {
- $builder->where('d.dept_sq', $data['team']);
- }
-
- if (!empty($data['user'])) {
- $builder->where('d.usr_sq', $data['user']);
- }
-
- // 거래구분
- if (!empty($data['rcpt_product_info1'])) {
- $builder->where('a.rcpt_product_info1', $data['rcpt_product_info1']);
- }
-
- // 현재상태
- if (!empty($data['rcpt_stat1'])) {
- $builder->like('a.rcpt_stat', $data['rcpt_stat1'], 'after');
- }
-
- if (!empty($data['rcpt_stat2'])) {
- $builder->like('a.rcpt_stat', $data['rcpt_stat2'], 'after');
- }
-
- if (!empty($data['rcpt_stat3'])) {
- $builder->where('a.rcpt_stat', $data['rcpt_stat3']);
- }
-
- // 중개사명
- if (!empty($data['agent_nm'])) {
- $builder->like('a.agent_nm', $data['agent_nm'], 'both');
- }
-
- // 동영상촬영여부
- if (!empty($data['exp_movie_yn'])) {
- $builder->where('a.exp_movie_yn', $data['exp_movie_yn']);
- }
-
- // 홍보확인서여부
- if ($data['conf_img_yn'] == 'Y') {
- $builder->where('e.rsrv_sq IS NOT NULL', null, false);
- } else if ($data['conf_img_yn'] == 'N') {
- $builder->where('e.rsrv_sq IS NULL', null, false);
- }
-
- // 분양권
- if ($data['parcel_out_yn'] == 'Y') {
- $builder->where('a.parcel_out_yn', 'Y');
- } else if ($data['parcel_out_yn'] == 'N') {
- $builder->where('a.parcel_out_yn', 'N');
- }
-
- // CP ID
- if (!empty($data['rcpt_cpid'])) {
- if (strcmp($data['rcpt_cpid'], 'naver') == 0) {
- $builder->where('a.rcpt_cpid =', '');
- } else if (strcmp($data['rcpt_cpid'], 'cleancente') == 0) {
- $builder->where("a.rcpt_cpid !=", "");
- } else {
- $builder->where('a.rcpt_cpid', $data['rcpt_cpid']);
- }
- }
-
- // 매물종류
- if (!empty($data['rcpt_product'])) {
- $builder->where('a.parcel_out_yn', $data['rcpt_product']);
- }
-
- // 면적확인
- if ($data['exp_spc_yn'] == 'Y') {
- $builder->where('a.parcel_out_yn', 'Y');
- } else if ($data['exp_spc_yn'] == 'N') {
- $builder->where('a.parcel_out_yn', 'N');
- }
-
- // 체크리스트
- if ($data['check_list_img_yn'] == 'Y') {
- $builder->where('a.check_list_img_yn', 'Y');
- } else if ($data['check_list_img_yn'] == 'N') {
- $builder->where('a.check_list_img_yn', 'N');
- }
-
- // 평면도유무
- if ($data['ground_plan_yn'] == 'Y') {
- $builder->where('exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', NULL, FALSE);
- } else if ($data['ground_plan_yn'] == 'N') {
- $builder->where('not exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', NULL, FALSE);
- }
-
- // 평면도요청
- if (!empty($data['ground_plan'])) {
- $builder->where('a.ground_plan', $data['ground_plan']);
- }
-
- // 직거래
- if ($data['direct_trad_yn'] == "Y") {
- $builder->where('a.direct_trad_yn', 'Y');
- } else if ($data['direct_trad_yn'] == "N") {
- $builder->where('a.direct_trad_yn', 'N');
- }
-
- // 360촬영여부
- if ($data['image_360_yn'] == "Y") {
- $builder->where('a.image_360_yn', 'Y');
- } else if ($data['image_360_yn'] == "N") {
- $builder->where('a.image_360_yn', 'N');
- }
-
- // 검증방식
- if (!empty($data['isSiteVRVerification'])) {
- $builder->where('a.isSiteVRVerification', $data['isSiteVRVerification']);
- }
-
- // 프로모션
- if (!empty($data['isPromotionApply'])) {
- $builder->where('a.isPromotionApply', $data['isPromotionApply']);
- }
-
- if (!empty($data['srchTxt'])) {
- // 중개사
- if ($data['srchType'] == '1') {
- $builder->groupStart()
- ->like('a.agent_nm', $data['srchTxt'])
- ->orLike('a.sellr_nm', $data['srchTxt'])
- ->groupEnd();
-
- // 주소
- } else if ($data['srchType'] == '2') {
- $builder->groupStart()
- ->like('a.rcpt_dtl_addr', $data['srchTxt'])
- ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
- ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
- ->groupEnd();
-
- // 사업자번호
- } else if ($data['srchType'] == '3') {
- $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
- } else {
- $builder->groupStart()
- ->like('a.agent_nm', $data['srchTxt'])
- ->orLike('a.sellr_nm', $data['srchTxt'])
- ->groupEnd();
-
- $builder->groupStart()
- ->like('a.rcpt_dtl_addr', $data['srchTxt'])
- ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
- ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
- ->groupEnd();
-
- $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
- }
- }
-
- }
+ $this->applyListUserScope($builder, $usr_level, $usr_sq, $dept_sq);
+ $this->applyListSearchFilters($builder, $data);
$row = $builder->get()->getRowArray();
// log_message('debug', '[getTotalCount] SQL = ' . $this->db->getLastQuery());
@@ -542,9 +342,28 @@ class ReceiptModel extends Model
$builder->join('result_imgs e', "e.rsrv_sq = b.rsrv_sq AND e.img_type = 'I1' AND e.use_yn = 'Y'", 'left outer');
$builder->join('receipt_transimage_log l', 'a.rcpt_key = l.rcpt_key', 'left outer');
+ $this->applyListUserScope($builder, $usr_level, $usr_sq, $dept_sq);
+ $this->applyListSearchFilters($builder, $data);
+
+
+ $builder->orderBy('a.rcpt_atclno', 'DESC');
+
+ $builder->limit($end, $start);
+
+ $result = $builder->get()->getResultArray();
+
+ // log_message('debug', '[getResultList] SQL = ' . $this->db->getLastQuery());
+ // log_message('info', '[getResultList] Result count = ' . count($result));
+
+ return $result;
+
+ }
+
+ private function applyListUserScope($builder, $usr_level, $usr_sq, $dept_sq): void
+ {
+ $login_dept_info = $this->getDeptDetail($dept_sq);
+ $child_dept = [];
- $login_dept_info = $this->getDeptDetail($dept_sq); // 로그인 사용자 소속부서정보
- $child_dept = []; // 하위조직 목록
if (strcmp($usr_level, '40') == 0) {
$child = $this->getChildDept($login_dept_info);
if (!empty($child)) {
@@ -561,204 +380,167 @@ class ReceiptModel extends Model
$builder->where('b.usr_sq', $usr_sq);
}
}
+ }
+ private function applyListSearchFilters($builder, $data): void
+ {
$builder->where('a.rcpt_tm >= DATE_ADD(CURDATE(), INTERVAL -3 MONTH)', null, false);
$builder->where('b.use_yn', 'Y');
if (!empty($data['rcpt_atclno'])) {
$builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
- } else {
- if ($data['schDateGb'] == '2') {
- $builder->where('a.rcpt_tm >=', $data['sdate'] . ' 00:00:00');
- $builder->where('a.rcpt_tm <=', $data['edate'] . ' 23:59:59');
- } else {
- $builder->where('b.rsrv_date >=', $data['sdate'] );
- $builder->where('b.rsrv_date <=', $data['edate'] );
- }
-
- // 지역
- if (!empty($data['dong'])) {
- $builder->where('a.rcpt_dong', $data['dong']);
- } else {
- if (!empty($data['gugun'])) {
- $builder->like('a.rcpt_gugun', substr($data['gugun'], 0, 5), 'after');
- } else {
- if (!empty($data['sido'])) {
- $builder->like('a.rcpt_gugun', substr($data['sido'], 0, 2), 'after');
- }
- }
- }
-
- // 관할조직
- if (!empty($data['bonbu'])) {
- $builder->where('d.pdept_sq', $data['bonbu']);
- }
-
- if (!empty($data['team'])) {
- $builder->where('d.dept_sq', $data['team']);
- }
-
- if (!empty($data['user'])) {
- $builder->where('d.usr_sq', $data['user']);
- }
-
- // 거래구분
- if (!empty($data['rcpt_product_info1'])) {
- $builder->where('a.rcpt_product_info1', $data['rcpt_product_info1']);
- }
-
- // 현재상태
- if (!empty($data['rcpt_stat1'])) {
- $builder->like('a.rcpt_stat', $data['rcpt_stat1'], 'after');
- }
-
- if (!empty($data['rcpt_stat2'])) {
- $builder->like('a.rcpt_stat', $data['rcpt_stat2'], 'after');
- }
-
- if (!empty($data['rcpt_stat3'])) {
- $builder->where('a.rcpt_stat', $data['rcpt_stat3']);
- }
-
- // 중개사명
- if (!empty($data['agent_nm'])) {
- $builder->like('a.agent_nm', $data['agent_nm'], 'both');
- }
-
- // 동영상촬영여부
- if (!empty($data['exp_movie_yn'])) {
- $builder->where('a.exp_movie_yn', $data['exp_movie_yn']);
- }
-
- // 홍보확인서여부
- if ($data['conf_img_yn'] == 'Y') {
- $builder->where('e.rsrv_sq IS NOT NULL', null, false);
- } else if ($data['conf_img_yn'] == 'N') {
- $builder->where('e.rsrv_sq IS NULL', null, false);
- }
-
- // 분양권
- if ($data['parcel_out_yn'] == 'Y') {
- $builder->where('a.parcel_out_yn', 'Y');
- } else if ($data['parcel_out_yn'] == 'N') {
- $builder->where('a.parcel_out_yn', 'N');
- }
-
- // CP ID
- if (!empty($data['rcpt_cpid'])) {
- if (strcmp($data['rcpt_cpid'], 'naver') == 0) {
- $builder->where('a.rcpt_cpid =', '');
- } else if (strcmp($data['rcpt_cpid'], 'cleancente') == 0) {
- $builder->where("a.rcpt_cpid !=", "");
- } else {
- $builder->where('a.rcpt_cpid', $data['rcpt_cpid']);
- }
- }
-
- // 매물종류
- if (!empty($data['rcpt_product'])) {
- $builder->where('a.parcel_out_yn', $data['rcpt_product']);
- }
-
- // 면적확인
- if ($data['exp_spc_yn'] == 'Y') {
- $builder->where('a.parcel_out_yn', 'Y');
- } else if ($data['exp_spc_yn'] == 'N') {
- $builder->where('a.parcel_out_yn', 'N');
- }
-
- // 체크리스트
- if ($data['check_list_img_yn'] == 'Y') {
- $builder->where('a.check_list_img_yn', 'Y');
- } else if ($data['check_list_img_yn'] == 'N') {
- $builder->where('a.check_list_img_yn', 'N');
- }
-
- // 평면도유무
- if ($data['ground_plan_yn'] == 'Y') {
- $builder->where('exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', NULL, FALSE);
- } else if ($data['ground_plan_yn'] == 'N') {
- $builder->where('not exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', NULL, FALSE);
- }
-
- // 평면도요청
- if (!empty($data['ground_plan'])) {
- $builder->where('a.ground_plan', $data['ground_plan']);
- }
-
- // 직거래
- if ($data['direct_trad_yn'] == "Y") {
- $builder->where('a.direct_trad_yn', 'Y');
- } else if ($data['direct_trad_yn'] == "N") {
- $builder->where('a.direct_trad_yn', 'N');
- }
-
- // 360촬영여부
- if ($data['image_360_yn'] == "Y") {
- $builder->where('a.image_360_yn', 'Y');
- } else if ($data['image_360_yn'] == "N") {
- $builder->where('a.image_360_yn', 'N');
- }
-
- // 검증방식
- if (!empty($data['isSiteVRVerification'])) {
- $builder->where('a.isSiteVRVerification', $data['isSiteVRVerification']);
- }
-
- // 프로모션
- if (!empty($data['isPromotionApply'])) {
- $builder->where('a.isPromotionApply', $data['isPromotionApply']);
- }
-
- if (!empty($data['srchTxt'])) {
- // 중개사
- if ($data['srchType'] == '1') {
- $builder->groupStart()
- ->like('a.agent_nm', $data['srchTxt'])
- ->orLike('a.sellr_nm', $data['srchTxt'])
- ->groupEnd();
-
- // 주소
- } else if ($data['srchType'] == '2') {
- $builder->groupStart()
- ->like('a.rcpt_dtl_addr', $data['srchTxt'])
- ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
- ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
- ->groupEnd();
-
- // 사업자번호
- } else if ($data['srchType'] == '3') {
- $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
- } else {
- $builder->groupStart()
- ->like('a.agent_nm', $data['srchTxt'])
- ->orLike('a.sellr_nm', $data['srchTxt'])
- ->groupEnd();
-
- $builder->groupStart()
- ->like('a.rcpt_dtl_addr', $data['srchTxt'])
- ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
- ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
- ->groupEnd();
-
- $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
- }
- }
-
+ return;
}
+ if ($data['schDateGb'] == '2') {
+ $builder->where('a.rcpt_tm >=', $data['sdate'] . ' 00:00:00');
+ $builder->where('a.rcpt_tm <=', $data['edate'] . ' 23:59:59');
+ } else {
+ $builder->where('b.rsrv_date >=', $data['sdate']);
+ $builder->where('b.rsrv_date <=', $data['edate']);
+ }
- $builder->orderBy('a.rcpt_atclno', 'DESC');
+ if (!empty($data['dong'])) {
+ $builder->where('a.rcpt_dong', $data['dong']);
+ } else if (!empty($data['gugun'])) {
+ $builder->like('a.rcpt_gugun', substr($data['gugun'], 0, 5), 'after');
+ } else if (!empty($data['sido'])) {
+ $builder->like('a.rcpt_gugun', substr($data['sido'], 0, 2), 'after');
+ }
- $builder->limit($end, $start);
+ if (!empty($data['bonbu'])) {
+ $builder->where('d.pdept_sq', $data['bonbu']);
+ }
- $result = $builder->get()->getResultArray();
-
- // log_message('debug', '[getResultList] SQL = ' . $this->db->getLastQuery());
- // log_message('info', '[getResultList] Result count = ' . count($result));
+ if (!empty($data['team'])) {
+ $builder->where('d.dept_sq', $data['team']);
+ }
- return $result;
+ if (!empty($data['user'])) {
+ $builder->where('d.usr_sq', $data['user']);
+ }
+ if (!empty($data['rcpt_product_info1'])) {
+ $builder->where('a.rcpt_product_info1', $data['rcpt_product_info1']);
+ }
+
+ if (!empty($data['rcpt_stat1'])) {
+ $builder->like('a.rcpt_stat', $data['rcpt_stat1'], 'after');
+ }
+
+ if (!empty($data['rcpt_stat2'])) {
+ $builder->like('a.rcpt_stat', $data['rcpt_stat2'], 'after');
+ }
+
+ if (!empty($data['rcpt_stat3'])) {
+ $builder->where('a.rcpt_stat', $data['rcpt_stat3']);
+ }
+
+ if (!empty($data['agent_nm'])) {
+ $builder->like('a.agent_nm', $data['agent_nm'], 'both');
+ }
+
+ if (!empty($data['exp_movie_yn'])) {
+ $builder->where('a.exp_movie_yn', $data['exp_movie_yn']);
+ }
+
+ if ($data['conf_img_yn'] == 'Y') {
+ $builder->where('e.rsrv_sq IS NOT NULL', null, false);
+ } else if ($data['conf_img_yn'] == 'N') {
+ $builder->where('e.rsrv_sq IS NULL', null, false);
+ }
+
+ if ($data['parcel_out_yn'] == 'Y') {
+ $builder->where('a.parcel_out_yn', 'Y');
+ } else if ($data['parcel_out_yn'] == 'N') {
+ $builder->where('a.parcel_out_yn', 'N');
+ }
+
+ if (!empty($data['rcpt_cpid'])) {
+ if (strcmp($data['rcpt_cpid'], 'naver') == 0) {
+ $builder->where('a.rcpt_cpid =', '');
+ } else if (strcmp($data['rcpt_cpid'], 'cleancente') == 0) {
+ $builder->where('a.rcpt_cpid !=', '');
+ } else {
+ $builder->where('a.rcpt_cpid', $data['rcpt_cpid']);
+ }
+ }
+
+ if (!empty($data['rcpt_product'])) {
+ $builder->where('a.rcpt_product', $data['rcpt_product']);
+ }
+
+ if ($data['exp_spc_yn'] == 'Y') {
+ $builder->where('a.exp_spc_yn', 'Y');
+ } else if ($data['exp_spc_yn'] == 'N') {
+ $builder->where('a.exp_spc_yn', 'N');
+ }
+
+ if ($data['check_list_img_yn'] == 'Y') {
+ $builder->where('a.check_list_img_yn', 'Y');
+ } else if ($data['check_list_img_yn'] == 'N') {
+ $builder->where('a.check_list_img_yn', 'N');
+ }
+
+ if ($data['ground_plan_yn'] == 'Y') {
+ $builder->where('exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', null, false);
+ } else if ($data['ground_plan_yn'] == 'N') {
+ $builder->where('not exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', null, false);
+ }
+
+ if (!empty($data['ground_plan'])) {
+ $builder->where('a.ground_plan', $data['ground_plan']);
+ }
+
+ if ($data['direct_trad_yn'] == 'Y') {
+ $builder->where('a.direct_trad_yn', 'Y');
+ } else if ($data['direct_trad_yn'] == 'N') {
+ $builder->where('a.direct_trad_yn', 'N');
+ }
+
+ if ($data['image_360_yn'] == 'Y') {
+ $builder->where('a.image_360_yn', 'Y');
+ } else if ($data['image_360_yn'] == 'N') {
+ $builder->where('a.image_360_yn', 'N');
+ }
+
+ if (!empty($data['isSiteVRVerification'])) {
+ $builder->where('a.isSiteVRVerification', $data['isSiteVRVerification']);
+ }
+
+ if (!empty($data['isPromotionApply'])) {
+ $builder->where('a.isPromotionApply', $data['isPromotionApply']);
+ }
+
+ if (!empty($data['srchTxt'])) {
+ if ($data['srchType'] == '1') {
+ $builder->groupStart()
+ ->like('a.agent_nm', $data['srchTxt'])
+ ->orLike('a.sellr_nm', $data['srchTxt'])
+ ->groupEnd();
+ } else if ($data['srchType'] == '2') {
+ $builder->groupStart()
+ ->like('a.rcpt_dtl_addr', $data['srchTxt'])
+ ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
+ ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
+ ->groupEnd();
+ } else if ($data['srchType'] == '3') {
+ $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
+ } else {
+ $builder->groupStart()
+ ->like('a.agent_nm', $data['srchTxt'])
+ ->orLike('a.sellr_nm', $data['srchTxt'])
+ ->groupEnd();
+
+ $builder->groupStart()
+ ->like('a.rcpt_dtl_addr', $data['srchTxt'])
+ ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
+ ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
+ ->groupEnd();
+
+ $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
+ }
+ }
}
@@ -833,209 +615,8 @@ class ReceiptModel extends Model
$builder->join('receipt_transimage_log l', 'a.rcpt_key = l.rcpt_key', 'left');
- $login_dept_info = $this->getDeptDetail($dept_sq); // 로그인 사용자 소속부서정보
- $child_dept = []; // 하위조직 목록
- if (strcmp($usr_level, '40') == 0) {
- $child = $this->getChildDept($login_dept_info);
- if (!empty($child)) {
- foreach ($child as $child) {
- $child_dept[] = $child['dept_sq'];
- }
- }
- }
-
- if ((int) $usr_level >= 4 && $usr_level != '45') {
- if (!empty($child_dept)) {
- $builder->whereIn('b.dept_sq', $child_dept);
- } else {
- $builder->where('b.usr_sq', $usr_sq);
- }
- }
-
- $builder->where('a.rcpt_tm >= DATE_ADD(CURDATE(), INTERVAL -3 MONTH)', null, false);
- $builder->where('b.use_yn', 'Y');
-
- if (!empty($data['rcpt_atclno'])) {
- $builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
- } else {
- if ($data['schDateGb'] == '2') {
- $builder->where('a.rcpt_tm >=', $data['sdate'] . ' 00:00:00');
- $builder->where('a.rcpt_tm <=', $data['edate'] . ' 23:59:59');
- } else {
- $builder->where('b.rsrv_date >=', $data['sdate'] . ' 00:00:00');
- $builder->where('b.rsrv_date <=', $data['edate'] . ' 23:59:59');
- }
-
- // 지역
- if (!empty($data['dong'])) {
- $builder->where('a.rcpt_dong', $data['dong']);
- } else {
- if (!empty($data['gugun'])) {
- $builder->like('a.rcpt_gugun', substr($data['gugun'], 0, 5), 'after');
- } else {
- if (!empty($data['sido'])) {
- $builder->like('a.rcpt_gugun', substr($data['sido'], 0, 2), 'after');
- }
- }
- }
-
- // 관할조직
- if (!empty($data['bonbu'])) {
- $builder->where('d.pdept_sq', $data['bonbu']);
- }
-
- if (!empty($data['team'])) {
- $builder->where('d.dept_sq', $data['team']);
- }
-
- if (!empty($data['user'])) {
- $builder->where('d.usr_sq', $data['user']);
- }
-
- // 거래구분
- if (!empty($data['rcpt_product_info1'])) {
- $builder->where('a.rcpt_product_info1', $data['rcpt_product_info1']);
- }
-
- // 현재상태
- if (!empty($data['rcpt_stat1'])) {
- $builder->like('a.rcpt_stat', $data['rcpt_stat1'], 'after');
- }
-
- if (!empty($data['rcpt_stat2'])) {
- $builder->like('a.rcpt_stat', $data['rcpt_stat2'], 'after');
- }
-
- if (!empty($data['rcpt_stat3'])) {
- $builder->where('a.rcpt_stat', $data['rcpt_stat3']);
- }
-
- // 중개사명
- if (!empty($data['agent_nm'])) {
- $builder->like('a.agent_nm', $data['agent_nm'], 'both');
- }
-
- // 동영상촬영여부
- if (!empty($data['exp_movie_yn'])) {
- $builder->where('a.exp_movie_yn', $data['exp_movie_yn']);
- }
-
- // 홍보확인서여부
- if ($data['conf_img_yn'] == 'Y') {
- $builder->where('e.rsrv_sq IS NOT NULL', null, false);
- } else if ($data['conf_img_yn'] == 'N') {
- $builder->where('e.rsrv_sq IS NULL', null, false);
- }
-
- // 분양권
- if ($data['parcel_out_yn'] == 'Y') {
- $builder->where('a.parcel_out_yn', 'Y');
- } else if ($data['parcel_out_yn'] == 'N') {
- $builder->where('a.parcel_out_yn', 'N');
- }
-
- // CP ID
- if (!empty($data['rcpt_cpid'])) {
- if (strcmp($data['rcpt_cpid'], 'naver') == 0) {
- $builder->where('a.rcpt_cpid =', '');
- } else if (strcmp($data['rcpt_cpid'], 'cleancente') == 0) {
- $builder->where("a.rcpt_cpid !=", "");
- } else {
- $builder->where('a.rcpt_cpid', $data['rcpt_cpid']);
- }
- }
-
- // 매물종류
- if (!empty($data['rcpt_product'])) {
- $builder->where('a.parcel_out_yn', $data['rcpt_product']);
- }
-
- // 면적확인
- if ($data['exp_spc_yn'] == 'Y') {
- $builder->where('a.parcel_out_yn', 'Y');
- } else if ($data['exp_spc_yn'] == 'N') {
- $builder->where('a.parcel_out_yn', 'N');
- }
-
- // 체크리스트
- if ($data['check_list_img_yn'] == 'Y') {
- $builder->where('a.check_list_img_yn', 'Y');
- } else if ($data['check_list_img_yn'] == 'N') {
- $builder->where('a.check_list_img_yn', 'N');
- }
-
- // 평면도유무
- if ($data['ground_plan_yn'] == 'Y') {
- $builder->where('exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', NULL, FALSE);
- } else if ($data['ground_plan_yn'] == 'N') {
- $builder->where('not exists (select \'x\' from result_imgs imgs where imgs.rsrv_sq = b.rsrv_sq and imgs.img_type = \'I5\' and imgs.use_yn=\'Y\')', NULL, FALSE);
- }
-
- // 평면도요청
- if (!empty($data['ground_plan'])) {
- $builder->where('a.ground_plan', $data['ground_plan']);
- }
-
- // 직거래
- if ($data['direct_trad_yn'] == "Y") {
- $builder->where('a.direct_trad_yn', 'Y');
- } else if ($data['direct_trad_yn'] == "N") {
- $builder->where('a.direct_trad_yn', 'N');
- }
-
- // 360촬영여부
- if ($data['image_360_yn'] == "Y") {
- $builder->where('a.image_360_yn', 'Y');
- } else if ($data['image_360_yn'] == "N") {
- $builder->where('a.image_360_yn', 'N');
- }
-
- // 검증방식
- if (!empty($data['isSiteVRVerification'])) {
- $builder->where('a.isSiteVRVerification', $data['isSiteVRVerification']);
- }
-
- // 프로모션
- if (!empty($data['isPromotionApply'])) {
- $builder->where('a.isPromotionApply', $data['isPromotionApply']);
- }
-
- if (!empty($data['srchTxt'])) {
- // 중개사
- if ($data['srchType'] == '1') {
- $builder->groupStart()
- ->like('a.agent_nm', $data['srchTxt'])
- ->orLike('a.sellr_nm', $data['srchTxt'])
- ->groupEnd();
-
- // 주소
- } else if ($data['srchType'] == '2') {
- $builder->groupStart()
- ->like('a.rcpt_dtl_addr', $data['srchTxt'])
- ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
- ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
- ->groupEnd();
-
- // 사업자번호
- } else if ($data['srchType'] == '3') {
- $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
- } else {
- $builder->groupStart()
- ->like('a.agent_nm', $data['srchTxt'])
- ->orLike('a.sellr_nm', $data['srchTxt'])
- ->groupEnd();
-
- $builder->groupStart()
- ->like('a.rcpt_dtl_addr', $data['srchTxt'])
- ->orLike('a.rcpt_hscp_nm', $data['srchTxt'])
- ->orLike('a.rcpt_jibun_addr', $data['srchTxt'])
- ->groupEnd();
-
- $builder->like('a.image_360_yn', $data['srchTxt'], 'both');
- }
- }
-
- }
+ $this->applyListUserScope($builder, $usr_level, $usr_sq, $dept_sq);
+ $this->applyListSearchFilters($builder, $data);
$builder->orderBy('a.rcpt_atclno', 'DESC');
@@ -1070,6 +651,7 @@ class ReceiptModel extends Model
,a.rcpt_product_info3
,a.rcpt_product_info4
,a.rcpt_product_info5
+ ,a.rcpt_product_info6
,a.rcpt_office
,(CASE WHEN a.rcpt_agent IS NULL THEN 'N' ELSE 'Y' END) as rcpt_agent
,a.rcpt_sido
@@ -1210,13 +792,19 @@ class ReceiptModel extends Model
,a.isPromotionApply
,DATE_FORMAT(b.vr_check_cplt_dt, '%Y-%m-%d') as vr_check_cplt_dt_dt
,DATE_FORMAT(b.vr_check_cplt_dt, '%H:%i:%s') as vr_check_cplt_dt_dm
+ ,a.dealAmount
+ ,a.warrantyAmount
+ ,a.leaseAmount
+ ,a.preSaleAmount
+ ,a.premiumAmount
+ ,a.preSaleOptionAmount
", false);
$builder->join('result b', 'b.rcpt_sq = a.rcpt_sq', 'inner');
$builder->join('region_codes c', 'a.rcpt_dong = c.region_cd', 'left');
$builder->join('departments d', 'b.dept_sq = d.dept_sq', 'left');
$builder->where('a.rcpt_key', $id);
-
+
return $builder->get()->getRowArray();
}
@@ -1733,18 +1321,14 @@ class ReceiptModel extends Model
public function saveChangedHistory($rcpt_sq, $rcpt_stat, $changed_type, $usr_id, $remark)
{
- $sql = "INSERT INTO changed_history" .
- " (rcpt_sq, rcpt_stat, changed_type, changed_id, changed_tm, remark)" .
- " VALUES" .
- " (?, ?, ?, ?, now(), ?)";
- $data = [
- $rcpt_sq,
+ $changedHistoryModel = new ChangedHistoryModel();
+ return $changedHistoryModel->addHistory(
+ (int) $rcpt_sq,
$rcpt_stat,
$changed_type,
$usr_id,
$remark
- ];
- $res = $this->db->query($sql, $data);
+ );
}
diff --git a/app/Models/common/CodeModel.php b/app/Models/common/CodeModel.php
index 2afda47..d7f22e3 100644
--- a/app/Models/common/CodeModel.php
+++ b/app/Models/common/CodeModel.php
@@ -8,64 +8,85 @@ class CodeModel extends Model
/**
* 코드목록 읽어오기(Y만)
*/
- public function getCodeList($category)
- {
- $sql = "SELECT category, category_nm, cd, cd_nm FROM codes" .
- " WHERE category = ?" .
- " AND use_yn = 'Y'" .
- " ORDER BY view_odr";
- $data = [$category];
- $query = $this->db->query($sql, $data);
-
- return $query->getResultArray();
- }
-
-
- public function getCodeLists($data): array
+ public function getCodeList(string $category): array
{
return $this->db->table('codes')
->select('category, category_nm, cd, cd_nm')
- ->whereIn('category', $data)
+ ->where('category', $category)
->where('use_yn', 'Y')
- ->orderBy('view_odr')
+ ->orderBy('view_odr', 'asc')
->get()
->getResultArray();
}
- public function getCategoryCodeList($category = [], $useYn = '')
+
+ public function getCodeLists(array $categories): array
{
- $this->db->select('category, cd, cd_nm, use_yn');
- $this->db->from('codes');
- $this->db->where_in('category', $category);
- if (!empty($useYn)) {
- $this->db->where('use_yn', $useYn);
+ if (empty($categories)) {
+ return [];
}
- $this->db->order_by('category', 'asc');
- $this->db->order_by('view_odr', 'asc');
- $query = $this->db->get();
+ $result = $this->db->table('codes')
+ ->select('category, category_nm, cd, cd_nm')
+ ->whereIn('category', $categories)
+ ->where('use_yn', 'Y')
+ ->orderBy('category', 'asc')
+ ->orderBy('view_odr', 'asc')
+ ->get()
+ ->getResultArray();
- //echo $this->db->last_query()."
";
+ $groupedData = [];
+ foreach ($result as $item) {
+ $category = $item['category'];
+
+ if (!isset($groupedData[$category])) {
+ $groupedData[$category] = [
+ 'name' => $item['category_nm'],
+ 'items' => []
+ ];
+ }
+
+ $groupedData[$category]['items'][$item['cd']] = $item['cd_nm'];
+ }
+
+ return $groupedData;
+ }
+
+ public function getCategoryCodeList(array $category = [], string $useYn = ''): array
+ {
+ if (empty($category)) {
+ return [];
+ }
+
+ $builder = $this->db->table('codes');
+ $builder->select('category, cd, cd_nm, use_yn');
+ $builder->whereIn('category', $category);
+ if (!empty($useYn)) {
+ $builder->where('use_yn', $useYn);
+ }
+ $builder->orderBy('category', 'asc');
+ $builder->orderBy('view_odr', 'asc');
+
+ $query = $builder->get();
- //여기 아래부분을 해줘야 배열을 카테고리로 뽑아쓸수있다 위에는 배열에 배열이담김
$codes = [];
foreach ($query->getResultArray() as $row) {
$codes[$row['category']][] = ['cd' => $row['cd'], 'cd_nm' => $row['cd_nm']];
}
+
return $codes;
}
/**
* 코드 상세
*/
- public function getCodeDetail($category, $code)
+ public function getCodeDetail(string $category, string $code): array
{
- $sql = "SELECT category, category_nm, cd, cd_nm FROM codes" .
- " WHERE category = ? and cd = ?";
- $data = [$category, $code];
- $query = $this->db->query($sql, $data);
- $row = $query->getResultArray();
-
- return $row;
+ return $this->db->table('codes')
+ ->select('category, category_nm, cd, cd_nm')
+ ->where('category', $category)
+ ->where('cd', $code)
+ ->get()
+ ->getResultArray();
}
}
\ No newline at end of file
diff --git a/app/Services/ParameterMapper/TypeSParameterMapper.php b/app/Services/ParameterMapper/TypeSParameterMapper.php
index 61037db..9e8e501 100644
--- a/app/Services/ParameterMapper/TypeSParameterMapper.php
+++ b/app/Services/ParameterMapper/TypeSParameterMapper.php
@@ -46,6 +46,7 @@ class TypeSParameterMapper extends BaseParameterMapper
'rcpt_product_info2' => $price['dealAmount'] ?? '0',
'rcpt_product_info4' => $price['preSaleAmount'] ?? '0',
'rcpt_product_info5' => $price['premiumAmount'] ?? '0',
+ 'rcpt_product_info6' => $price['preSaleOptionAmount'] ?? '0',
'rcpt_living_yn' => ($rawData['site']['isRegistration'] ?? false) ? 'Y' : 'N',
'rcpt_agent' => $realtor['realtorName'] ?? null,
'rcpt_sido' => $address['legalDivision']['cityNumber'] ?? null,
@@ -95,6 +96,11 @@ class TypeSParameterMapper extends BaseParameterMapper
'rcpt_cpid' => $rawData['cpId'] ?? 'naver',
'isSiteVRVerification' => ($rawData['site']['isVrVerification'] ?? false) ? 'Y' : 'N',
'isPromotionApply' => ($rawData['site']['isVrRepresentativeApply'] ?? false) ? 'Y' : 'N',
+ 'dealAmount' => $price['dealAmount'] ?? null,
+ 'warrantyAmount' => $price['warrantyAmount'] ?? null,
+ 'leaseAmount' => $price['leaseAmount'] ?? null,
+ 'preSaleAmount' => $price['preSaleAmount'] ?? null,
+ 'premiumAmount' => $price['premiumAmount'] ?? null
];
}
diff --git a/app/Services/ParameterMapper/TypeV2ParameterMapper.php b/app/Services/ParameterMapper/TypeV2ParameterMapper.php
index fabc0fb..b06d7e7 100644
--- a/app/Services/ParameterMapper/TypeV2ParameterMapper.php
+++ b/app/Services/ParameterMapper/TypeV2ParameterMapper.php
@@ -90,6 +90,7 @@ class TypeV2ParameterMapper extends BaseParameterMapper
'lease_amt' => $price['leaseAmount'] ?? 0,
'isale_amt' => $price['preSaleAmount'] ?? 0,
'prem_amt' => $price['premiumAmount'] ?? 0,
+ 'preopt_amt' => $price['preSaleOptionAmount'] ?? 0,
'sise' => null,
'floor' => $floor['correspondenceFloorCount'] ?? null,
'floor2' => $floor['totalFloorCount'] ?? null,
diff --git a/app/Views/pages/article/receipt/detail.php b/app/Views/pages/article/receipt/detail.php
index 8a3a02e..e768f16 100644
--- a/app/Views/pages/article/receipt/detail.php
+++ b/app/Views/pages/article/receipt/detail.php
@@ -96,6 +96,12 @@ $isV2 = (($data['isSiteVRVerification'] ?? '') === 'Y');
+
+
+
+
+
+