워커 수정

This commit is contained in:
2026-04-27 15:03:36 +09:00
parent b0ec75ae56
commit f8c26acea8
30 changed files with 1317 additions and 1142 deletions

View File

@@ -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([

View File

@@ -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(),
]);
}
}
}

View File

@@ -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();