Compare commits
144 Commits
32b869f05b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f8c26acea8 | |||
| b0ec75ae56 | |||
| a87fed538b | |||
| cbf7e85cf8 | |||
| 6a72ccebd5 | |||
| cba387de9d | |||
| 930e690126 | |||
| 0ef2ba77c6 | |||
| c22b023310 | |||
| 0b6ed3df73 | |||
| a170fdc774 | |||
| e5a80aff33 | |||
| 7139e0c095 | |||
| 129e2b4e69 | |||
| fd187bb84a | |||
| 3fbc57bedc | |||
| 81b85ae25d | |||
| e2f49ba77e | |||
| 728b394063 | |||
| 1f445512f7 | |||
| b553310dc1 | |||
| bb07396abf | |||
| 80cb9451d2 | |||
| 9138fa9c16 | |||
| a6ae1bd377 | |||
| 6bb9dceec9 | |||
| 32efe755e6 | |||
| 141f526f91 | |||
| 9650707caf | |||
| 13dfb3e112 | |||
| 9d9df394c5 | |||
| 353df045d8 | |||
| f02f8c0457 | |||
| 243ca0c45e | |||
| e54b5bbbb8 | |||
| 69e6aa5fe6 | |||
| af7846ea7c | |||
| b237c4b934 | |||
| d91738c667 | |||
| c129362724 | |||
| 49d33b55b8 | |||
| c3b4e0e712 | |||
| f988ecabd2 | |||
| 99a072f732 | |||
| b0e7cf0df0 | |||
| ed80e90bb3 | |||
| c17110087c | |||
| 3cd6b238d2 | |||
| 906f208734 | |||
| 54e8c50a11 | |||
| 5504ca154a | |||
| d666315497 | |||
| 424b0e9411 | |||
| 85fdb38281 | |||
| 4f78d5493c | |||
| 56a7fe94d5 | |||
| 23286f6890 | |||
| 38ea1c1129 | |||
| c6da9c12be | |||
|
|
6d87a209e0 | ||
| f6857ae959 | |||
|
|
a7dca8c5fa | ||
| 98d74658e9 | |||
|
|
9a27018922 | ||
| 922c85962c | |||
|
|
8b621a065e | ||
| 53695a1dc3 | |||
|
|
d92bbfef1a | ||
|
|
4a8178b185 | ||
| b9b3f43956 | |||
|
|
790216404c | ||
| fc4ce793e3 | |||
|
|
36355f75f3 | ||
| ae5677a635 | |||
| 1311dc529a | |||
| 54f0a2a4d2 | |||
| 9f20f4347a | |||
| f9b6336eab | |||
| 6bed688be0 | |||
| fef656243c | |||
| c93a2035dd | |||
| db70b28eb9 | |||
| 918e27da67 | |||
| f7bda06ddf | |||
| 2781638f58 | |||
| c21a137dbb | |||
|
|
8b77448128 | ||
| 9a2d0af8d0 | |||
| 7143a6bd28 | |||
| a11d686b2a | |||
| acbf430ae7 | |||
| c33fb47508 | |||
|
|
e342d7f916 | ||
| 3bb6741e44 | |||
|
|
c7856394c0 | ||
| ecf1be8ab7 | |||
|
|
99ea553d9a | ||
| adcd5aca7d | |||
|
|
2c96bd12de | ||
| 8bb7700a00 | |||
| cbcd66d5c7 | |||
|
|
107cc395d6 | ||
| 0493cd7708 | |||
|
|
f358b44e16 | ||
| 44035795d2 | |||
|
|
04c28d79f2 | ||
| 0605948ab5 | |||
|
|
d134b27614 | ||
| 19bf534086 | |||
|
|
b51f2fddcf | ||
| 2f5b1a7da6 | |||
| 20e6398005 | |||
| 1de224627e | |||
| 9b9e752bd1 | |||
| 1cb1e6837b | |||
| b5e06188b1 | |||
| c375d84874 | |||
| 1d6dc49971 | |||
| dbe85efcef | |||
| 253a5de579 | |||
| 52213c3ad4 | |||
| 87dd69d703 | |||
| e394acd7cc | |||
| 7c48d1134f | |||
| 0d1c6855e5 | |||
| 43d45332ef | |||
| 55e1cdf82a | |||
| 3dc24d011a | |||
| 5ae247fe91 | |||
| 9a3a8ed4e3 | |||
| 1993013193 | |||
| 9f511b4dba | |||
| 522b89fb9f | |||
|
|
2030ca0836 | ||
| cac86ffc7a | |||
|
|
26db8eb602 | ||
| 112923c459 | |||
|
|
929d885b2b | ||
| 1761e31587 | |||
|
|
bfdd56ba48 | ||
| 0114faae2b | |||
|
|
6e28c750dd | ||
| f17dc88f99 | |||
|
|
abf369dcd6 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -172,3 +172,7 @@ _modules/*
|
||||
/node_modules/
|
||||
.env
|
||||
**/logs/
|
||||
|
||||
|
||||
# 6. 기타 개인 설정 파일 (선택적)
|
||||
.github/copilot-instructions.mdworker/fallback_queue/*.json
|
||||
|
||||
267
REFACTORING_REPORT.md
Normal file
267
REFACTORING_REPORT.md
Normal file
@@ -0,0 +1,267 @@
|
||||
# NaverService 리팩토링 완료 보고서
|
||||
|
||||
## 📋 개요
|
||||
NaverService를 **683줄 거대한 단일 파일**에서 **책임 분리 기반의 모듈식 구조**로 리팩토링했습니다.
|
||||
|
||||
## 🏗️ 새로운 구조
|
||||
|
||||
```
|
||||
app/Services/
|
||||
├── NaverService.php (84줄) ✨ 간결화됨
|
||||
├── ParameterMapper/
|
||||
│ ├── BaseParameterMapper.php (기본 추상 클래스)
|
||||
│ ├── TypeSParameterMapper.php (현장확인 데이터 변환)
|
||||
│ └── TypeV2ParameterMapper.php (일반/서류 데이터 변환)
|
||||
└── Handlers/
|
||||
├── TypeSHandler.php (Type S 처리 로직)
|
||||
└── TypeV2Handler.php (Type V2 처리 로직)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 개선 효과
|
||||
|
||||
| 메트릭 | 이전 | 이후 | 개선율 |
|
||||
|--------|------|------|--------|
|
||||
| **파일 크기** | 683줄 | 84줄 | **87.7% 감소** ⬇️ |
|
||||
| **메서드 수** | 12개 | 1개 | **91.7% 감소** |
|
||||
| **순환 복잡도** | 높음 | 낮음 | **상당히 개선** |
|
||||
| **테스트 용이성** | 어려움 | 쉬움 | **크게 개선** |
|
||||
| **재사용성** | 낮음 | 높음 | **크게 개선** |
|
||||
|
||||
---
|
||||
|
||||
## 🔑 핵심 개선 사항
|
||||
|
||||
### 1️⃣ **NaverService 간결화** (84줄)
|
||||
```php
|
||||
// 이전: 683줄의 로직 모두 포함
|
||||
// 이후: API 호출 + 타입별 위임만 담당
|
||||
public function processArticle(array $payload): int
|
||||
{
|
||||
// 1. 네이버 API 호출
|
||||
$response = $this->naverClient->getArticleInfo($articleNumber);
|
||||
|
||||
// 2. 원본 데이터 Staging 저장
|
||||
$this->rawStagingModel->insert([...]);
|
||||
|
||||
// 3. 타입별 처리 위임
|
||||
if ($vType === 'S') {
|
||||
return $this->typeSHandler->handle(...);
|
||||
} else {
|
||||
return $this->typeV2Handler->handle(...);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2️⃣ **ParameterMapper 분리**
|
||||
네이버 API 응답을 데이터베이스 파라미터로 변환하는 로직 전담
|
||||
|
||||
#### BaseParameterMapper (추상 기본 클래스)
|
||||
- 공통 변환 메서드: `mapOwnerTypeCode()`, `mapTradeType()`, `extractFilesByType()`
|
||||
- 모든 매퍼의 기반
|
||||
|
||||
#### TypeSParameterMapper
|
||||
```php
|
||||
// Receipt 테이블용 파라미터
|
||||
$receiptData = $mapper->mapReceipt($articleNumber, $rawData, $payload);
|
||||
|
||||
// Result 테이블용 파라미터
|
||||
$resultData = $mapper->mapResult($rcptSq, $rawData);
|
||||
```
|
||||
|
||||
#### TypeV2ParameterMapper
|
||||
```php
|
||||
// VrfcReq, ArticleInfo, ArticleInfoEtc 파라미터 생성
|
||||
$vrfcReqParam = $mapper->mapVrfcReq(...);
|
||||
$articleInfoParam = $mapper->mapArticleInfo(...);
|
||||
$articleInfoEtcParam = $mapper->mapArticleInfoEtc(...);
|
||||
```
|
||||
|
||||
### 3️⃣ **Handler 분리**
|
||||
각 타입별 비즈니스 로직과 DB 처리 전담
|
||||
|
||||
#### TypeSHandler (현장확인)
|
||||
- Receipt, Result 데이터 저장
|
||||
- 트랜잭션 관리
|
||||
- 네이버 동기화
|
||||
|
||||
#### TypeV2Handler (일반/서류)
|
||||
- REG (신규 등록)
|
||||
- MOD (수정)
|
||||
- CNC (취소)
|
||||
- VrfcReq, ArticleInfo, ArticleInfoEtc 처리
|
||||
|
||||
---
|
||||
|
||||
## 💡 사용 방법
|
||||
|
||||
### 기존 코드 (변경 없음)
|
||||
```php
|
||||
$naverService = new NaverService();
|
||||
$result = $naverService->processArticle([
|
||||
'articleNumber' => '12345',
|
||||
'requestType' => 'REG',
|
||||
'requestDatetime' => '2026-01-27 10:00:00'
|
||||
]);
|
||||
```
|
||||
|
||||
### 내부 동작 (개선됨)
|
||||
```
|
||||
1. NaverService::processArticle()
|
||||
└─ API 호출 + Staging 저장
|
||||
└─ 타입 분석
|
||||
|
||||
2. TypeSHandler::handle() 또는 TypeV2Handler::handle()
|
||||
└─ ParameterMapper로 데이터 변환
|
||||
└─ DB 저장 + 트랜잭션 관리
|
||||
└─ 상태 기록
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ 이점
|
||||
|
||||
### 1. **유지보수성 향상**
|
||||
- 각 클래스가 단일 책임 원칙 준수
|
||||
- 메서드 수가 감소하여 이해하기 쉬움
|
||||
- 로직 변경 시 영향 범위 최소화
|
||||
|
||||
### 2. **테스트 용이성**
|
||||
```php
|
||||
// 각 컴포넌트를 독립적으로 테스트 가능
|
||||
$mapper = new TypeSParameterMapper();
|
||||
$receiptData = $mapper->mapReceipt($articleNumber, $mockRawData, $mockPayload);
|
||||
$this->assertArrayHasKey('rcpt_key', $receiptData);
|
||||
|
||||
$handler = new TypeSHandler();
|
||||
// MockModel 주입 후 테스트 가능
|
||||
```
|
||||
|
||||
### 3. **재사용성**
|
||||
- ParameterMapper를 다른 서비스에서 재사용 가능
|
||||
- Handler를 확장하여 새로운 타입 추가 용이
|
||||
|
||||
### 4. **확장성**
|
||||
새로운 타입 추가 시:
|
||||
```php
|
||||
// 1. TypeCParameterMapper 생성
|
||||
class TypeCParameterMapper extends BaseParameterMapper { ... }
|
||||
|
||||
// 2. TypeCHandler 생성
|
||||
class TypeCHandler { ... }
|
||||
|
||||
// 3. NaverService에 추가
|
||||
public function processArticle(array $payload): int {
|
||||
// ...
|
||||
} else if ($vType === 'C') {
|
||||
return $this->typeCHandler->handle(...);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔍 코드 구조 비교
|
||||
|
||||
### 이전 (모놀리식)
|
||||
```
|
||||
NaverService.php
|
||||
├── processArticle() → 메인 로직
|
||||
├── processTypeS() → 현장확인 로직 (160줄)
|
||||
├── processTypeV2() → 일반/서류 로직 (30줄 + 미완성)
|
||||
├── insertVrfcReq() → DB 저장
|
||||
├── v2Parameter() → 파라미터 변환 (60줄)
|
||||
├── articleInfoParameter() → 파라미터 변환 (150줄)
|
||||
├── articleInfoEtcParameter() → 파라미터 변환 (60줄)
|
||||
├── modifyInfoParameter() → 파라미터 변환 (미완성)
|
||||
└── logAndThrowError() → 에러 처리
|
||||
```
|
||||
|
||||
### 이후 (모듈식)
|
||||
```
|
||||
NaverService.php (84줄)
|
||||
├── processArticle() → 오케스트레이션
|
||||
|
||||
ParameterMapper/BaseParameterMapper.php (추상 클래스)
|
||||
├── mapOwnerTypeCode()
|
||||
├── mapTradeType()
|
||||
└── extractFilesByType()
|
||||
|
||||
ParameterMapper/TypeSParameterMapper.php
|
||||
├── mapReceipt()
|
||||
└── mapResult()
|
||||
|
||||
ParameterMapper/TypeV2ParameterMapper.php
|
||||
├── mapVrfcReq()
|
||||
├── mapArticleInfo()
|
||||
└── mapArticleInfoEtc()
|
||||
|
||||
Handlers/TypeSHandler.php
|
||||
└── handle()
|
||||
|
||||
Handlers/TypeV2Handler.php
|
||||
├── handle()
|
||||
├── handleRegister()
|
||||
├── handleModify()
|
||||
└── handleCancel()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📝 파일 목록
|
||||
|
||||
### 생성된 파일
|
||||
1. `app/Services/ParameterMapper/BaseParameterMapper.php` (95줄)
|
||||
2. `app/Services/ParameterMapper/TypeSParameterMapper.php` (165줄)
|
||||
3. `app/Services/ParameterMapper/TypeV2ParameterMapper.php` (330줄)
|
||||
4. `app/Services/Handlers/TypeSHandler.php` (85줄)
|
||||
5. `app/Services/Handlers/TypeV2Handler.php` (200줄)
|
||||
|
||||
### 수정된 파일
|
||||
1. `app/Services/NaverService.php` (683줄 → 84줄)
|
||||
|
||||
---
|
||||
|
||||
## ⚡ 성능
|
||||
- **동작**: 100% 동일 (로직 변경 없음)
|
||||
- **성능**: 약간의 오버헤드 (메서드 호출 추가) → 무시할 수 있는 수준
|
||||
- **메모리**: 거의 동일
|
||||
|
||||
---
|
||||
|
||||
## 🎯 다음 단계
|
||||
|
||||
### 1. 단위 테스트 작성
|
||||
```php
|
||||
// tests/unit/Services/ParameterMapperTest.php
|
||||
class TypeSParameterMapperTest extends CIUnitTestCase {
|
||||
public function testMapReceiptReturnsValidArray()
|
||||
public function testMapResultCalculatesCorrectDepartment()
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 통합 테스트
|
||||
```php
|
||||
// tests/integration/NaverServiceTest.php
|
||||
public function testProcessArticleTypeSSuccess()
|
||||
public function testProcessArticleTypeV2Success()
|
||||
```
|
||||
|
||||
### 3. 추가 개선
|
||||
- [ ] 에러 처리 강화 (Custom Exception)
|
||||
- [ ] 로깅 일관성 개선
|
||||
- [ ] 캐싱 메커니즘 추가
|
||||
- [ ] 비동기 처리 (동기화, 이메일 등)
|
||||
|
||||
---
|
||||
|
||||
## ✨ 요약
|
||||
|
||||
✅ **코드 라인 수 87.7% 감소** (683 → 84줄)
|
||||
✅ **단일 책임 원칙 준수**
|
||||
✅ **테스트 용이성 극대화**
|
||||
✅ **확장성 및 유지보수성 향상**
|
||||
✅ **기존 API 호환성 100% 유지**
|
||||
|
||||
이제 프로젝트는 **더 깔끔하고, 테스트 가능하고, 확장 가능한 구조**를 가지게 되었습니다! 🚀
|
||||
360
SESSION_README.md
Normal file
360
SESSION_README.md
Normal file
@@ -0,0 +1,360 @@
|
||||
# Session 관리 가이드
|
||||
|
||||
## 개요
|
||||
|
||||
본 애플리케이션은 **Redis**를 기본 세션 저장소로 사용하며, Redis 장애 시 **Database(MariaDB)**로 자동 폴백하는 이중화 구조를 가지고 있습니다.
|
||||
|
||||
## 아키텍처
|
||||
|
||||
### 세션 저장소
|
||||
|
||||
| 우선순위 | 핸들러 | 설명 | 성능 |
|
||||
|---------|-------|------|------|
|
||||
| 1순위 | **RedisHandler** | 메모리 기반 고속 세션 | ~0.03초 |
|
||||
| 2순위 | **DatabaseHandler** | DB 기반 안정적 세션 | ~0.05초 (수동 전환 시) |
|
||||
|
||||
### 구성 요소
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────┐
|
||||
│ 사용자 로그인 요청 │
|
||||
└──────────────┬──────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────┐
|
||||
│ Session.php 생성자 │
|
||||
│ - Redis 연결 테스트 │
|
||||
│ - SESSION_FORCE_DATABASE 확인 │
|
||||
└──────────────┬──────────────────────────┘
|
||||
│
|
||||
┌──────┴──────┐
|
||||
│ │
|
||||
Redis 정상? Redis 장애?
|
||||
│ │
|
||||
▼ ▼
|
||||
RedisHandler DatabaseHandler
|
||||
(ci_sessions (ci_sessions
|
||||
테이블) 테이블)
|
||||
│ │
|
||||
└──────┬──────┘
|
||||
▼
|
||||
세션 데이터 저장/조회
|
||||
```
|
||||
|
||||
## 설정 파일
|
||||
|
||||
### 1. Session.php (`src/app/Config/Session.php`)
|
||||
|
||||
```php
|
||||
public string $driver = RedisHandler::class;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// 환경변수로 강제 Database 모드 설정 가능
|
||||
$forceDatabase = env('SESSION_FORCE_DATABASE', false);
|
||||
|
||||
if ($this->driver === RedisHandler::class && !$forceDatabase) {
|
||||
try {
|
||||
// Redis 연결 테스트 (타임아웃: 0.5초)
|
||||
$testRedis = get_redis_connection('session');
|
||||
|
||||
if (!$testRedis) {
|
||||
throw new \Exception('Redis connection failed');
|
||||
}
|
||||
|
||||
// Redis 정상 - Redis 사용
|
||||
$this->savePath = 'tcp://192.168.10.243:6379?database=0';
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Redis 실패 - DatabaseHandler로 폴백
|
||||
$this->driver = DatabaseHandler::class;
|
||||
$this->savePath = 'ci_sessions';
|
||||
}
|
||||
} else {
|
||||
// Database 모드
|
||||
$this->savePath = 'ci_sessions';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. 환경 설정 (`.env`)
|
||||
|
||||
```bash
|
||||
# Redis 세션 설정
|
||||
SESSION_REDIS_HOST = 192.168.10.243
|
||||
SESSION_REDIS_PORT = 6379
|
||||
SESSION_REDIS_DATABASE = 0
|
||||
#SESSION_REDIS_PASSWORD =
|
||||
|
||||
# 세션 강제 Database 모드 (Redis 장애 시 true로 변경)
|
||||
SESSION_FORCE_DATABASE = false
|
||||
```
|
||||
|
||||
### 3. Redis Helper (`src/app/Helpers/redis_helper.php`)
|
||||
|
||||
```php
|
||||
function get_redis_connection(string $type = 'worker')
|
||||
{
|
||||
$redis = new \Redis();
|
||||
|
||||
// 타임아웃 0.5초로 빠른 실패 감지
|
||||
$timeout = 0.5;
|
||||
$success = $redis->connect($host, $port, $timeout);
|
||||
|
||||
return $success ? $redis : false;
|
||||
}
|
||||
```
|
||||
|
||||
## 데이터베이스 테이블
|
||||
|
||||
### ci_sessions 테이블 구조
|
||||
|
||||
```sql
|
||||
CREATE TABLE `ci_sessions` (
|
||||
`session_id` VARCHAR(40) NOT NULL DEFAULT '0',
|
||||
`ip_address` VARCHAR(16) NOT NULL DEFAULT '0',
|
||||
`user_agent` VARCHAR(120) NOT NULL,
|
||||
`last_activity` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`user_data` VARCHAR(4000) NOT NULL,
|
||||
PRIMARY KEY (`session_id`)
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
CREATE INDEX `last_activity_idx`
|
||||
ON `ci_sessions` (`last_activity` ASC);
|
||||
```
|
||||
|
||||
**주요 특징:**
|
||||
- **ENGINE = MEMORY**: 메모리 기반 테이블로 매우 빠른 읽기/쓰기 성능
|
||||
- **장점**: Redis와 비슷한 속도 (디스크 I/O 없음)
|
||||
- **단점**: 서버 재시작 시 세션 데이터 소실 (일반적으로 문제없음 - 세션은 휘발성 데이터)
|
||||
- **용량**: VARCHAR(4000)으로 충분한 세션 데이터 저장 가능
|
||||
|
||||
## 운영 가이드
|
||||
|
||||
### 1. Redis 장애 발생 시
|
||||
|
||||
#### 자동 폴백 (기본 동작)
|
||||
- Redis 연결 실패 시 자동으로 DatabaseHandler로 전환
|
||||
- **단점**: 매 요청마다 Redis 연결 시도 → 타임아웃 대기 (약 0.5초 추가)
|
||||
- 사용자는 약간 느린 응답 시간을 경험
|
||||
|
||||
#### 수동 전환 (권장)
|
||||
Redis 장애 감지 즉시 다음 조치:
|
||||
|
||||
```bash
|
||||
# 1. .env 파일 수정
|
||||
vi /path/to/src/.env
|
||||
|
||||
# SESSION_FORCE_DATABASE를 true로 변경
|
||||
SESSION_FORCE_DATABASE = true
|
||||
|
||||
# 2. PHP-FPM 재시작 (선택사항, 다음 요청부터 자동 적용)
|
||||
docker exec projects-admin_confirms kill -USR2 1
|
||||
```
|
||||
|
||||
**장점**: Redis 연결 시도 없이 즉시 Database 사용 → 빠른 응답 (0.05초)
|
||||
|
||||
### 2. Redis 복구 후
|
||||
|
||||
```bash
|
||||
# 1. .env 파일 원복
|
||||
SESSION_FORCE_DATABASE = false
|
||||
|
||||
# 2. PHP-FPM 재시작
|
||||
docker exec projects-admin_confirms kill -USR2 1
|
||||
```
|
||||
|
||||
### 3. 모니터링
|
||||
|
||||
#### 로그 확인
|
||||
```bash
|
||||
# 세션 관련 로그 확인
|
||||
docker exec projects-admin_confirms tail -f /var/www/html/writable/logs/log-$(date +%Y-%m-%d).log | grep -i session
|
||||
|
||||
# Redis 폴백 경고 확인
|
||||
docker exec projects-admin_confirms grep "Redis unavailable" /var/www/html/writable/logs/log-$(date +%Y-%m-%d).log
|
||||
```
|
||||
|
||||
#### 예상 로그 메시지
|
||||
|
||||
**Redis 정상:**
|
||||
```
|
||||
DEBUG - Session: Class initialized using 'CodeIgniter\Session\Handlers\RedisHandler' driver.
|
||||
```
|
||||
|
||||
**Redis 장애 (자동 폴백):**
|
||||
```
|
||||
WARNING - Session: Redis unavailable (Redis connection failed), falling back to DatabaseHandler
|
||||
DEBUG - Session: Class initialized using 'CodeIgniter\Session\Handlers\DatabaseHandler' driver.
|
||||
```
|
||||
|
||||
**Database 강제 모드:**
|
||||
```
|
||||
INFO - Session: Forced to use DatabaseHandler (SESSION_FORCE_DATABASE=true)
|
||||
DEBUG - Session: Class initialized using 'CodeIgniter\Session\Handlers\DatabaseHandler' driver.
|
||||
```
|
||||
|
||||
### 4. 성능 모니터링
|
||||
|
||||
```bash
|
||||
# 로그인 응답 시간 측정
|
||||
for i in {1..5}; do
|
||||
curl -X POST http://localtest2-admin.confirms.co.kr/login/chkLogin \
|
||||
-H "Content-Type: application/x-www-form-urlencoded" \
|
||||
-d "user_id=test&user_pw=test" \
|
||||
-o /dev/null -s -w " Time: %{time_total}s\n"
|
||||
done
|
||||
```
|
||||
|
||||
**기대 성능:**
|
||||
- Redis 정상: 0.03 ~ 0.05초
|
||||
- Database (수동 전환): 0.05 ~ 0.08초
|
||||
- 자동 폴백 (Redis 다운): 0.5 ~ 1.0초
|
||||
|
||||
## 사용자 알림
|
||||
|
||||
### 프론트엔드 경고 표시
|
||||
|
||||
Redis 장애 시 로그인 페이지에 자동으로 경고 배너가 표시됩니다:
|
||||
|
||||
```javascript
|
||||
// login.php의 JavaScript
|
||||
function checkSystemStatus(responseData) {
|
||||
if (responseData.system && responseData.system.redis_fallback) {
|
||||
// 경고 메시지: "세션 서버(Redis) 장애로 임시 모드로 운영 중입니다."
|
||||
showRedisWarning(responseData.system.warning_message);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**API 응답 예시:**
|
||||
```json
|
||||
{
|
||||
"code": "0",
|
||||
"msg": "success",
|
||||
"system": {
|
||||
"redis_fallback": true,
|
||||
"warning_message": "세션 서버(Redis) 장애로 임시 모드로 운영 중입니다. 시스템 관리자에게 문의하세요."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 트러블슈팅
|
||||
|
||||
### 문제: 로그인이 느림 (2~3초)
|
||||
|
||||
**원인**: Redis 다운 상태에서 자동 폴백 모드 사용 중
|
||||
|
||||
**해결**:
|
||||
```bash
|
||||
# SESSION_FORCE_DATABASE=true로 수동 전환
|
||||
echo "SESSION_FORCE_DATABASE = true" >> /path/to/src/.env
|
||||
```
|
||||
|
||||
### 문제: 세션이 유지되지 않음
|
||||
|
||||
**원인**: ci_sessions 테이블이 없거나 권한 문제
|
||||
|
||||
**해결**:
|
||||
```sql
|
||||
-- 테이블 존재 확인
|
||||
SHOW TABLES LIKE 'ci_sessions';
|
||||
|
||||
-- 권한 확인
|
||||
SHOW GRANTS FOR 'confirms'@'%';
|
||||
|
||||
-- 테이블이 없는 경우 생성
|
||||
CREATE TABLE `ci_sessions` (
|
||||
`session_id` VARCHAR(40) NOT NULL DEFAULT '0',
|
||||
`ip_address` VARCHAR(16) NOT NULL DEFAULT '0',
|
||||
`user_agent` VARCHAR(120) NOT NULL,
|
||||
`last_activity` INT UNSIGNED NOT NULL DEFAULT 0,
|
||||
`user_data` VARCHAR(4000) NOT NULL,
|
||||
PRIMARY KEY (`session_id`)
|
||||
) ENGINE = MEMORY;
|
||||
|
||||
CREATE INDEX `last_activity_idx`
|
||||
ON `ci_sessions` (`last_activity` ASC);
|
||||
```
|
||||
|
||||
### 문제: 서버 재시작 후 모든 세션이 사라짐
|
||||
|
||||
**원인**: ci_sessions가 MEMORY 엔진을 사용 (정상 동작)
|
||||
|
||||
**설명**:
|
||||
- MEMORY 엔진은 서버 재시작 시 데이터가 삭제됩니다
|
||||
- 세션은 일시적 데이터이므로 일반적으로 문제가 되지 않습니다
|
||||
- 사용자는 재로그인하면 됩니다
|
||||
|
||||
**영구 저장이 필요한 경우**:
|
||||
```sql
|
||||
-- InnoDB로 변경 (성능은 약간 느려짐)
|
||||
ALTER TABLE ci_sessions ENGINE=InnoDB;
|
||||
```
|
||||
|
||||
### 문제: Redis 연결 타임아웃이 너무 김
|
||||
|
||||
**원인**: redis_helper.php의 타임아웃 설정
|
||||
|
||||
**해결**:
|
||||
```php
|
||||
// src/app/Helpers/redis_helper.php
|
||||
$timeout = 0.5; // 0.1 ~ 1.0 사이 값으로 조정
|
||||
$redis->connect($host, $port, $timeout);
|
||||
```
|
||||
|
||||
## 관련 파일
|
||||
|
||||
| 파일 | 역할 |
|
||||
|------|------|
|
||||
| `src/app/Config/Session.php` | 세션 설정 및 폴백 로직 |
|
||||
| `src/app/Helpers/redis_helper.php` | Redis 연결 헬퍼 함수 |
|
||||
| `src/app/Controllers/Login.php` | 로그인 및 시스템 상태 체크 |
|
||||
| `src/app/Views/pages/login.php` | 프론트엔드 경고 표시 |
|
||||
| `src/.env` | 환경 설정 (Redis 연결 정보, 강제 모드) |
|
||||
|
||||
## Worker 및 API (참고)
|
||||
|
||||
### Worker (NaverWorker.php)
|
||||
- Redis 큐 사용 (DB 9)
|
||||
- Redis 장애 시 파일 기반 폴백 (`worker/fallback_queue/*.json`)
|
||||
|
||||
### API (api_receiver.php, KisoController.php)
|
||||
- Redis 큐 사용 (DB 9)
|
||||
- Redis 장애 시 파일 기반 폴백 (`worker/fallback_queue/*.json`)
|
||||
|
||||
## 추가 개선 사항
|
||||
|
||||
### 고려 중인 기능
|
||||
|
||||
1. **Redis Sentinel 도입** (고가용성)
|
||||
- 자동 장애 조치
|
||||
- 마스터/슬레이브 구조
|
||||
|
||||
2. **APM 연동**
|
||||
- New Relic, DataDog 등
|
||||
- 실시간 성능 모니터링
|
||||
|
||||
3. **헬스체크 엔드포인트**
|
||||
```php
|
||||
// GET /health/session
|
||||
{
|
||||
"status": "ok",
|
||||
"driver": "RedisHandler",
|
||||
"redis_available": true,
|
||||
"response_time_ms": 12
|
||||
}
|
||||
```
|
||||
|
||||
## 문의
|
||||
|
||||
세션 관련 문제 발생 시:
|
||||
1. 로그 확인 (`/writable/logs/`)
|
||||
2. Redis 서버 상태 확인
|
||||
3. ci_sessions 테이블 상태 확인
|
||||
4. 필요 시 수동 전환 수행
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2026-03-25
|
||||
**Version**: 1.0.0
|
||||
209
app/Commands/NaverRetry.php
Normal file
209
app/Commands/NaverRetry.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Models\Entities\NaverWorkerLogModel;
|
||||
|
||||
class NaverRetry extends BaseCommand
|
||||
{
|
||||
protected $group = 'Workers';
|
||||
protected $name = 'naver:retry';
|
||||
protected $description = '실패한 Naver Worker 작업을 재처리합니다.';
|
||||
|
||||
protected $usage = 'naver:retry [log_id] [options]';
|
||||
protected $arguments = [
|
||||
'log_id' => '재처리할 특정 로그 ID (선택사항, 없으면 모든 실패 건 재처리)'
|
||||
];
|
||||
protected $options = [
|
||||
'--limit' => '재처리할 최대 개수 (기본: 10)',
|
||||
'--dry-run' => '실제 실행 없이 목록만 확인',
|
||||
'--force' => '재시도 횟수 제한 무시 (3회 이상 실패한 건도 재처리)'
|
||||
];
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
helper(['log']);
|
||||
|
||||
$logId = $params[0] ?? null;
|
||||
$limit = CLI::getOption('limit') ?? 10;
|
||||
$isDryRun = CLI::getOption('dry-run') !== null;
|
||||
$isForce = CLI::getOption('force') !== null;
|
||||
|
||||
$logModel = model(NaverWorkerLogModel::class);
|
||||
$naverService = new \App\Services\NaverService();
|
||||
|
||||
// 1. 특정 ID 재처리
|
||||
if ($logId) {
|
||||
$this->retryOne($logModel, $naverService, $logId, $isDryRun, $isForce);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 실패한 모든 작업 재처리
|
||||
$this->retryFailed($logModel, $naverService, $limit, $isDryRun, $isForce);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 로그 ID 재처리
|
||||
*/
|
||||
protected function retryOne($logModel, $naverService, $logId, $isDryRun, $isForce)
|
||||
{
|
||||
$log = $logModel->find($logId);
|
||||
|
||||
if (!$log) {
|
||||
CLI::error("❌ Log ID {$logId} not found");
|
||||
return;
|
||||
}
|
||||
|
||||
CLI::write(CLI::color("📋 Log ID: {$logId}", 'cyan'));
|
||||
CLI::write(" Status: {$log['status']}");
|
||||
CLI::write(" Retry Count: " . ($log['retry_cnt'] ?? 0));
|
||||
CLI::write(" Error: {$log['error_msg']}");
|
||||
CLI::write(" Created: {$log['created_at']}");
|
||||
|
||||
// 재시도 횟수 체크
|
||||
if (!$isForce && ($log['retry_cnt'] ?? 0) >= 3) {
|
||||
CLI::write(CLI::color('⚠️ 이미 3회 이상 재시도했습니다. --force 옵션으로 강제 실행 가능', 'yellow'));
|
||||
return;
|
||||
}
|
||||
|
||||
// 재시도 불가능한 오류 체크
|
||||
if (!$isForce && $this->isNonRetryableError($log['error_msg'])) {
|
||||
CLI::write(CLI::color('⚠️ 재시도 불가능한 오류입니다. 데이터를 먼저 수정해주세요.', 'yellow'));
|
||||
CLI::write(CLI::color(' (--force 옵션으로 강제 실행 가능)', 'yellow'));
|
||||
return;
|
||||
}
|
||||
|
||||
if ($isDryRun) {
|
||||
CLI::write(CLI::color('🔍 DRY RUN - 재처리하지 않음', 'yellow'));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->processLog($logModel, $naverService, $log);
|
||||
}
|
||||
|
||||
/**
|
||||
* 재시도 불가능한 오류인지 확인
|
||||
*/
|
||||
protected function isNonRetryableError($errorMsg)
|
||||
{
|
||||
if (!$errorMsg) return false;
|
||||
|
||||
// 데이터 수정이 필요한 오류 패턴
|
||||
$nonRetryablePatterns = [
|
||||
'foreign key constraint',
|
||||
'Duplicate entry',
|
||||
'빈 페이로드',
|
||||
'usr_sq.*users 테이블에 없음', // 이미 폴백 적용된 건은 재시도 가능
|
||||
];
|
||||
|
||||
foreach ($nonRetryablePatterns as $pattern) {
|
||||
if (stripos($errorMsg, $pattern) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 실패한 모든 작업 재처리
|
||||
*/
|
||||
protected function retryFailed($logModel, $naverService, $limit, $isDryRun, $isForce)
|
||||
{
|
||||
$query = $logModel->where('status', 'FAIL');
|
||||
|
||||
// force가 아닌 경우 재시도 횟수 3회 미만만 조회
|
||||
if (!$isForce) {
|
||||
$query->groupStart()
|
||||
->where('retry_cnt IS NULL')
|
||||
->orWhere('retry_cnt <', 3)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
$failedLogs = $query->orderBy('created_at', 'ASC')->findAll($limit);
|
||||
|
||||
if (empty($failedLogs)) {
|
||||
CLI::write(CLI::color('✅ 재처리할 실패 작업이 없습니다.', 'green'));
|
||||
return;
|
||||
}
|
||||
|
||||
CLI::write(CLI::color("📋 실패한 작업 {count}건 발견", 'cyan')
|
||||
->replace('{count}', count($failedLogs)));
|
||||
|
||||
if ($isDryRun) {
|
||||
foreach ($failedLogs as $log) {
|
||||
CLI::write(" - ID: {$log['seq']} | Atcl: {$log['atcl_no']} | Error: {$log['error_msg']}");
|
||||
}
|
||||
CLI::write(CLI::color('🔍 DRY RUN - 재처리하지 않음', 'yellow'));
|
||||
return;
|
||||
}
|
||||
|
||||
// 실제 재처리
|
||||
$successCount = 0;
|
||||
$failCount = 0;
|
||||
|
||||
foreach ($failedLogs as $log) {
|
||||
CLI::write(CLI::color("\n🔄 Retrying Log ID: {$log['seq']}", 'yellow'));
|
||||
|
||||
$result = $this->processLog($logModel, $naverService, $log);
|
||||
|
||||
if ($result) {
|
||||
$successCount++;
|
||||
} else {
|
||||
$failCount++;
|
||||
}
|
||||
|
||||
// 과부하 방지
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
CLI::write(CLI::color("\n✅ 재처리 완료: 성공 {$successCount}건, 실패 {$failCount}건", 'green'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 데이터 재처리
|
||||
*/
|
||||
protected function processLog($logModel, $naverService, $log)
|
||||
{
|
||||
try {
|
||||
// 상태를 RETRY로 변경
|
||||
$logModel->update($log['seq'], ['status' => 'RETRY']);
|
||||
|
||||
// JSON 파싱
|
||||
$responseJson = json_decode($log['raw_payload'], true);
|
||||
$payload = $responseJson['request_data'] ?? [];
|
||||
|
||||
if (empty($payload)) {
|
||||
throw new \Exception("빈 페이로드 데이터");
|
||||
}
|
||||
|
||||
CLI::write(" Article: {$payload['articleNumber']}");
|
||||
|
||||
// 재처리
|
||||
$insertId = $naverService->processArticle($payload);
|
||||
|
||||
// 성공 시 로그 업데이트
|
||||
$logModel->update($log['seq'], [
|
||||
'atcl_no' => $payload['articleNumber'] ?? null,
|
||||
'status' => 'SUCCESS',
|
||||
'target_db_id' => $insertId,
|
||||
'error_msg' => null
|
||||
]);
|
||||
|
||||
CLI::write(CLI::color(" ✅ Success! DB ID: {$insertId}", 'green'));
|
||||
return true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// 실패 시 로그 업데이트
|
||||
$logModel->update($log['seq'], [
|
||||
'status' => 'FAIL',
|
||||
'error_msg' => $e->getMessage()
|
||||
]);
|
||||
|
||||
CLI::error(" ❌ Failed: " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,44 +15,127 @@ class NaverWorker extends BaseCommand
|
||||
protected $name = 'naver:worker';
|
||||
protected $description = 'Redis에서 데이터를 꺼내 DB에 저장하고 네이버 API를 호출합니다.';
|
||||
|
||||
// DB 객체를 담을 변수 선언
|
||||
protected $db;
|
||||
protected $redisHost;
|
||||
protected $redisPort;
|
||||
protected $redisDatabase;
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
helper('log'); // 여기서 로드 완료!
|
||||
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(); // 서비스 생성
|
||||
|
||||
$redis = new \Redis();
|
||||
try {
|
||||
$redis->connect('redis', 6379);
|
||||
$redis->select(9);
|
||||
CLI::write(CLI::color('🟢 Naver Worker running...', 'green'));
|
||||
} catch (\Exception $e) {
|
||||
CLI::error("Redis 연결 불가: " . $e->getMessage());
|
||||
return;
|
||||
// Redis 연결 (실패해도 계속 진행 - 파일 모드로 동작 가능)
|
||||
$redis = get_redis_connection('worker');
|
||||
$config = get_redis_config('worker');
|
||||
|
||||
if ($redis) {
|
||||
CLI::write(CLI::color('🟢 Naver Worker running... (Redis: ' . $config['host'] . ':' . $config['port'] . ' DB:' . $config['database'] . ')', 'green'));
|
||||
} else {
|
||||
CLI::write(CLI::color('⚠️ Naver Worker running in FILE-ONLY mode (Redis unavailable)', 'yellow'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
while (true) {
|
||||
$result = $redis->brPop(['naver:raw_queue'], 30);
|
||||
|
||||
if (!$result) {
|
||||
// 데이터가 없어서 타임아웃 난 경우.
|
||||
// 굳이 sleep 안 해도 바로 다음 brPop이 다시 30초 대기를 시작함.
|
||||
// Redis 또는 폴백 파일에서 데이터 읽기
|
||||
$rawData = null;
|
||||
$source = 'redis'; // 데이터 소스 추적
|
||||
|
||||
// 1. Redis에서 데이터 읽기 시도 (Redis가 있을 경우만)
|
||||
if ($redis) {
|
||||
$maxRetries = 2;
|
||||
$retryCount = 0;
|
||||
|
||||
while ($retryCount < $maxRetries) {
|
||||
try {
|
||||
$result = $redis->brPop(['naver:raw_queue'], 5); // 5초 타임아웃
|
||||
if ($result) {
|
||||
$rawData = $result[1];
|
||||
$source = 'redis';
|
||||
}
|
||||
break; // 성공하면 루프 탈출
|
||||
} catch (\Exception $e) {
|
||||
$retryCount++;
|
||||
CLI::write(CLI::color("⚠️ Redis error (attempt {$retryCount}/{$maxRetries}): " . $e->getMessage(), 'yellow'));
|
||||
|
||||
if ($retryCount >= $maxRetries) {
|
||||
CLI::write(CLI::color("⚠️ Redis unavailable, switching to file mode", 'yellow'));
|
||||
$redis = null; // Redis를 비활성화
|
||||
break;
|
||||
}
|
||||
|
||||
// Redis 재연결 시도
|
||||
try {
|
||||
CLI::write(CLI::color('🔄 Reconnecting to Redis...', 'yellow'));
|
||||
$redis->close();
|
||||
$redis = get_redis_connection('worker');
|
||||
if ($redis) {
|
||||
CLI::write(CLI::color('✅ Redis reconnected', 'green'));
|
||||
}
|
||||
} catch (\Exception $reconnectError) {
|
||||
CLI::error("Redis reconnection error: " . $reconnectError->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Redis에서 데이터 없으면 폴백 파일 확인
|
||||
if (!$rawData) {
|
||||
$rawData = $this->readFromFallbackFile();
|
||||
if ($rawData) {
|
||||
$source = 'file';
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 데이터 없으면 다음 루프
|
||||
if (!$rawData) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
$rawData = $result[1];
|
||||
// [1] 꺼내자마자 DB에 원문 저장 (2차 임시 저장)
|
||||
// 4. 데이터 소스 로깅
|
||||
CLI::write(CLI::color("📥 Data received from: " . strtoupper($source), 'cyan'));
|
||||
|
||||
// [1] 꺼내자마자 DB에 원문 저장 (2차 임시 저장) - 실패 시 재시도
|
||||
try {
|
||||
$logId = $logModel->insert([
|
||||
'raw_payload' => $rawData,
|
||||
'status' => 'INIT'
|
||||
]);
|
||||
} 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);
|
||||
|
||||
// 재시도
|
||||
$logId = $logModel->insert([
|
||||
'raw_payload' => $rawData,
|
||||
'status' => 'INIT'
|
||||
]);
|
||||
} else {
|
||||
throw $e; // 다른 에러면 그대로 throw
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$responseJson = json_decode($result[1], true);
|
||||
$responseJson = json_decode($rawData, true);
|
||||
$payload = $responseJson['request_data'] ?? [];
|
||||
|
||||
if (empty($payload)) {
|
||||
@@ -62,27 +145,152 @@ class NaverWorker extends BaseCommand
|
||||
// 서비스의 함수 하나로 모든 처리 완료
|
||||
$insertId = $naverService->processArticle($payload);
|
||||
|
||||
// [3] 성공 시 로그 업데이트
|
||||
$logModel->update($logId, [
|
||||
// [3] 성공 시 로그 업데이트 (재연결 처리 포함)
|
||||
$this->safeUpdateLog($logModel, $logId, [
|
||||
'atcl_no' => $payload['articleNumber'] ?? null,
|
||||
'status' => 'SUCCESS',
|
||||
'target_db_id' => $insertId
|
||||
]);
|
||||
|
||||
CLI::write("✅ Success! DB ID: $insertId", 'cyan');
|
||||
CLI::write("✅ Success! DB ID: $insertId | Source: $source", 'cyan');
|
||||
|
||||
} catch (\Exception $e) {
|
||||
CLI::error("❌ Task Failed: " . $e->getMessage());
|
||||
// 실패 로그는 여기서 남김
|
||||
// 1. DB 상태를 FAIL로 업데이트 (필수)
|
||||
$logModel->update($logId, ['status' => 'FAIL', 'error_msg' => $e->getMessage()]);
|
||||
|
||||
// 2. Redis 실패 큐에 백업 (선택 - 나중에 모아서 다시 던질 때 편함)
|
||||
// payload에서 매물번호 추출 시도
|
||||
$atclNo = null;
|
||||
try {
|
||||
if (!empty($rawData)) {
|
||||
$responseJson = json_decode($rawData, true);
|
||||
$payload = $responseJson['request_data'] ?? [];
|
||||
$atclNo = $payload['articleNumber'] ?? null;
|
||||
}
|
||||
} catch (\Exception $parseEx) {
|
||||
// JSON 파싱 실패는 무시
|
||||
}
|
||||
|
||||
// 실패 로그는 여기서 남김
|
||||
// 1. DB 상태를 FAIL로 업데이트 (필수) (재연결 처리 포함)
|
||||
$this->safeUpdateLog($logModel, $logId, [
|
||||
'atcl_no' => $atclNo,
|
||||
'status' => 'FAIL',
|
||||
'error_msg' => $e->getMessage()
|
||||
]);
|
||||
|
||||
// 2. Redis 실패 큐에 백업 (선택 - Redis가 있을 경우만)
|
||||
if ($redis) {
|
||||
try {
|
||||
$redis->lPush('naver:failed_queue', $rawData);
|
||||
} catch (\Exception $redisEx) {
|
||||
// Redis 실패 시에도 에러 처리하지 않음 (이미 DB에 FAIL 로그 남김)
|
||||
CLI::write(CLI::color('⚠️ Failed to push to failed_queue: ' . $redisEx->getMessage(), 'yellow'));
|
||||
}
|
||||
}
|
||||
|
||||
helper('log');
|
||||
write_custom_log("FAILED_DATA | Error: " . $e->getMessage(), 'ERROR', 'failed');
|
||||
|
||||
// 루프 과부하 방지 (연속 에러 시)
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL 연결 계열 에러 발생 시 재연결 후 재시도하는 안전한 update
|
||||
*/
|
||||
protected function safeUpdateLog($logModel, $logId, $data)
|
||||
{
|
||||
try {
|
||||
return $logModel->update($logId, $data);
|
||||
} 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);
|
||||
|
||||
// 재시도
|
||||
return $logModel->update($logId, $data);
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 장애 시 파일에서 직접 처리)
|
||||
*
|
||||
* @return string|null JSON 데이터 또는 null
|
||||
*/
|
||||
protected function readFromFallbackFile()
|
||||
{
|
||||
$fallbackDir = ROOTPATH . 'worker/fallback_queue';
|
||||
|
||||
// 폴백 디렉토리가 없으면 null 반환
|
||||
if (!is_dir($fallbackDir)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 폴백 파일 목록 가져오기 (오래된 순서대로)
|
||||
$files = glob($fallbackDir . '/*.json');
|
||||
|
||||
if (empty($files)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
sort($files); // 파일명(타임스탬프) 기준 정렬
|
||||
|
||||
// 가장 오래된 파일 하나 처리
|
||||
$filePath = $files[0];
|
||||
|
||||
try {
|
||||
// 파일 락을 사용하여 읽기 (동시 접근 방지)
|
||||
$fp = fopen($filePath, 'r');
|
||||
if (!$fp) {
|
||||
CLI::write(CLI::color("⚠️ Failed to open fallback file: " . basename($filePath), 'yellow'));
|
||||
return null;
|
||||
}
|
||||
|
||||
// 배타적 락 획득 시도
|
||||
if (!flock($fp, LOCK_EX | LOCK_NB)) {
|
||||
// 락 획득 실패 (다른 프로세스가 처리 중)
|
||||
fclose($fp);
|
||||
return null;
|
||||
}
|
||||
|
||||
// 파일 내용 읽기
|
||||
$content = stream_get_contents($fp);
|
||||
|
||||
// 파일 삭제 (처리 완료로 간주)
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
unlink($filePath);
|
||||
|
||||
CLI::write(CLI::color("📂 Processing fallback file: " . basename($filePath), 'green'));
|
||||
|
||||
return $content;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
CLI::write(CLI::color("❌ Error reading fallback file " . basename($filePath) . ": " . $e->getMessage(), 'red'));
|
||||
if (isset($fp) && is_resource($fp)) {
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
32
app/Commands/TestLog.php
Normal file
32
app/Commands/TestLog.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
class TestLog extends BaseCommand
|
||||
{
|
||||
protected $group = 'Test';
|
||||
protected $name = 'test:log';
|
||||
protected $description = 'Test log_message function';
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('Testing log_message()...', 'yellow');
|
||||
|
||||
log_message('error', '===== TEST LOG MESSAGE FROM CLI ===== ' . date('Y-m-d H:i:s'));
|
||||
log_message('debug', 'Debug level test');
|
||||
log_message('info', 'Info level test');
|
||||
|
||||
$logFile = WRITEPATH . 'logs/log-' . date('Y-m-d') . '.log';
|
||||
|
||||
CLI::write('Log file: ' . $logFile);
|
||||
CLI::write('Exists: ' . (file_exists($logFile) ? 'YES' : 'NO'));
|
||||
|
||||
if (file_exists($logFile)) {
|
||||
CLI::write('Last 10 lines:');
|
||||
CLI::write(shell_exec('tail -10 ' . escapeshellarg($logFile)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class App extends BaseConfig
|
||||
*
|
||||
* E.g., http://example.com/
|
||||
*/
|
||||
public string $baseURL = 'http://test2-admin.confirms.co.kr';
|
||||
public string $baseURL = 'http://localtest2-admin.confirms.co.kr';
|
||||
|
||||
/**
|
||||
* Allowed Hostnames in the Site URL other than the hostname in the baseURL.
|
||||
@@ -199,4 +199,37 @@ class App extends BaseConfig
|
||||
* @see http://www.w3.org/TR/CSP/
|
||||
*/
|
||||
public bool $CSPEnabled = false;
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
* Constructor - .env 값 로드
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// .env 파일의 값으로 속성 오버라이드
|
||||
if (env('app.baseURL')) {
|
||||
$this->baseURL = env('app.baseURL');
|
||||
}
|
||||
|
||||
if (env('app.appTimezone')) {
|
||||
$this->appTimezone = env('app.appTimezone');
|
||||
}
|
||||
|
||||
if (env('app.forceGlobalSecureRequests') !== null) {
|
||||
$this->forceGlobalSecureRequests = filter_var(
|
||||
env('app.forceGlobalSecureRequests'),
|
||||
FILTER_VALIDATE_BOOLEAN
|
||||
);
|
||||
}
|
||||
|
||||
if (env('app.CSPEnabled') !== null) {
|
||||
$this->CSPEnabled = filter_var(
|
||||
env('app.CSPEnabled'),
|
||||
FILTER_VALIDATE_BOOLEAN
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,13 +159,13 @@ class Cache extends BaseConfig
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Redis 설정에 .env 값을 할당 (이전 논의된 Docker 호스트 이름 'redis' 사용)
|
||||
// Redis 설정에 환경 변수 값을 할당 (두 가지 환경 변수 형식 지원)
|
||||
$this->redis = [
|
||||
'host' => env('redis.default.host', '127.0.0.1'),
|
||||
'password' => (env('redis.default.password') === '' || env('redis.default.password') === null) ? null : env('redis.default.password'),
|
||||
'port' => (int)env('redis.default.port', 6379),
|
||||
'timeout' => (int)env('redis.default.timeout', 0),
|
||||
'database' => (int)env('redis.default.database', 0)
|
||||
'host' => env('REDIS_HOST', env('redis.default.host', '127.0.0.1')),
|
||||
'password' => env('REDIS_PASSWORD', env('redis.default.password')) ?: null,
|
||||
'port' => (int)(env('REDIS_PORT', env('redis.default.port', 6379))),
|
||||
'timeout' => (int)(env('REDIS_TIMEOUT', env('redis.default.timeout', 0))),
|
||||
'database' => (int)(env('REDIS_DATABASE', env('redis.default.database', 0)))
|
||||
];
|
||||
|
||||
// 필요하다면, 이 생성자에서 $handler나 $backupHandler 같은 다른 설정도
|
||||
|
||||
@@ -82,8 +82,18 @@ defined('EXIT__AUTO_MAX') || define('EXIT__AUTO_MAX', 125); // highest automa
|
||||
/**
|
||||
* ncloud url
|
||||
*/
|
||||
define('NCLOUD_OBJECT_STORAGE_URL', 'https://kr.object.ncloudstorage.com/confirms-object');
|
||||
define('NCLOUD_S3_KEY', 'ncp_iam_BPAMKR3l50hXJiQ6qpSP');
|
||||
define('NCLOUD_S3_SECRET', 'ncp_iam_BPKMKRW2GU59UE59I1QftVGst6NJgnmbSc');
|
||||
define('NCLOUD_S3_BUCKET', 'confirms-object');
|
||||
define('NCLOUD_S3_ENDPOINT', 'https://kr.object.ncloudstorage.com');
|
||||
// 환경별 버킷 설정
|
||||
$environment = getenv('CI_ENVIRONMENT') ?: 'production';
|
||||
|
||||
if ($environment === 'development') {
|
||||
define('NCLOUD_S3_BUCKET', 'confirms-object-test');
|
||||
define('NCLOUD_OBJECT_STORAGE_URL', 'https://kr.object.ncloudstorage.com/confirms-object-test');
|
||||
} else {
|
||||
define('NCLOUD_S3_BUCKET', 'confirms-object');
|
||||
define('NCLOUD_OBJECT_STORAGE_URL', 'https://kr.object.ncloudstorage.com/confirms-object');
|
||||
}
|
||||
|
||||
// .env 파일에서 NCLOUD 설정 읽기
|
||||
define('NCLOUD_S3_KEY', getenv('ncloud.s3.key') ?: 'ncp_iam_BPAMKR3l50hXJiQ6qpSP');
|
||||
define('NCLOUD_S3_SECRET', getenv('ncloud.s3.secret') ?: 'ncp_iam_BPKMKRW2GU59UE59I1QftVGst6NJgnmbSc');
|
||||
define('NCLOUD_S3_ENDPOINT', getenv('ncloud.s3.endpoint') ?: 'https://kr.object.ncloudstorage.com');
|
||||
|
||||
@@ -39,7 +39,7 @@ class Logger extends BaseConfig
|
||||
*
|
||||
* @var int|list<int>
|
||||
*/
|
||||
public $threshold = (ENVIRONMENT === 'production') ? 4 : 9;
|
||||
public $threshold = 9; // Always log everything for debugging
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
|
||||
@@ -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'); // 평형정보조회
|
||||
|
||||
});
|
||||
|
||||
@@ -67,7 +69,25 @@ $routes->group('', ['namespace' => 'App\Controllers\Article'], static function (
|
||||
$routes->get('excel', 'Receipt::excel');
|
||||
|
||||
$routes->post('saveTel', 'Receipt::saveTel'); // 연락가능전화 저장
|
||||
$routes->post('resDbYn', 'Receipt::resDbYn'); // 거주여부 저장
|
||||
$routes->post('resGround', 'Receipt::resGround'); // 평면도요청 저장
|
||||
$routes->post('assignRegist', 'Receipt::assignRegist'); // 예약확정 저장
|
||||
$routes->post('requestMovie', 'Receipt::requestMovie'); // 동영상 촬영여부저장
|
||||
$routes->post('requestMessage', 'Receipt::requestMessage'); // 중개사메모 저장
|
||||
$routes->post('rsrvcancel', 'Receipt::rsrvcancel'); // 예약취소
|
||||
$routes->post('chgStatus', 'Receipt::chgStatus'); // 상태변경
|
||||
$routes->post('sendSms', 'Receipt::sendSms'); // 문자발송
|
||||
$routes->post('saveRecInfo', 'Receipt::saveRecInfo'); // 거주인정보저장
|
||||
$routes->get('getRecInfo', 'Receipt::getRecInfo'); // 거주인정보조회
|
||||
$routes->get('getHistory', 'Receipt::getHistory'); // 정보변경이력조회
|
||||
$routes->get('getImages', 'Receipt::getImages'); // 이미지 목록 조회
|
||||
$routes->post('uploadFile', 'Receipt::uploadFile'); // 파일업로드
|
||||
$routes->post('removeUploadFile', 'Receipt::removeUploadFile'); // 파일삭제
|
||||
$routes->post('updateImageOrder', 'Receipt::updateImageOrder'); // 이미지 순서 업데이트
|
||||
$routes->get('downloadAllImages', 'Receipt::downloadAllImages'); // 이미지 일괄 다운로드
|
||||
$routes->post('saveImgLocation', 'Receipt::saveImgLocation'); // 촬영위치 저장
|
||||
|
||||
$routes->post('modifyPriceInfo', 'Receipt::modifyPriceInfo'); // 가격정보 수정
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -75,10 +95,11 @@ $routes->group('', ['namespace' => 'App\Controllers\Article'], static function (
|
||||
*/
|
||||
$routes->group('article/dept', static function ($routes) {
|
||||
$routes->get('lists', 'Dept::lists');
|
||||
$routes->get('detail/(:num)', 'Dept::detail/$1');
|
||||
$routes->get('detail/(:num)', 'Receipt::detail/$1');
|
||||
|
||||
$routes->get('getResultList', 'Dept::getResultList');
|
||||
$routes->get('excel', 'Dept::excel');
|
||||
$routes->get('excel2', 'Dept::excel2');
|
||||
$routes->get('print', 'Dept::print'); // 관할포인트
|
||||
$routes->get('updateAssign', 'Dept::updateAssign'); // 배정변경
|
||||
|
||||
@@ -89,7 +110,7 @@ $routes->group('', ['namespace' => 'App\Controllers\Article'], static function (
|
||||
*/
|
||||
$routes->group('article/record', static function ($routes) {
|
||||
$routes->get('lists', 'Record::lists');
|
||||
$routes->get('detail/(:num)', 'Record::detail/$1');
|
||||
$routes->get('detail/(:num)', 'Receipt::detail/$1');
|
||||
|
||||
$routes->get('getResultList', 'Record::getResultList');
|
||||
$routes->get('excel', 'Record::excel');
|
||||
@@ -165,10 +186,19 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
*/
|
||||
$routes->get('m701a/getResultList', 'M701::getResultList');
|
||||
$routes->get('m701a/excel', 'M701::excel');
|
||||
$routes->post('m701a/chgArticleStatus', 'M701::chgArticleStatus'); // 상태정보변경
|
||||
|
||||
$routes->post('m701a/changePrice', 'M701::changePrice'); // 가격수정
|
||||
$routes->post('m701a/chgArticleStatus', 'M701::chgArticleStatus'); // 상태정보변경
|
||||
$routes->post('m701a/modifyInfo', 'M701::modifyInfo'); // 정보수정
|
||||
$routes->post('m701a/saveMemo', 'M701::saveMemo'); // 메모저장
|
||||
|
||||
$routes->post('m701a/saveDocu', 'M701::saveDocu'); // 서류 저장
|
||||
$routes->post('m701a/saveTel', 'M701::saveTel'); // 전화정보 저장
|
||||
$routes->post('m701a/saveRegi', 'M701::saveRegi'); // 등기부등본 저장
|
||||
$routes->post('m701a/saveFinalRegi', 'M701::saveFinalRegi'); // 검증최종실패 처리
|
||||
|
||||
$routes->post('m701a/uploadFile', 'M701::uploadFile'); // 파일업로드
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -184,7 +214,12 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
$routes->get('m702a/getResultList', 'M702::getResultList');
|
||||
$routes->get('m702a/excel', 'M702::excel');
|
||||
$routes->post('m702a/updateAssign', 'M702::updateAssign'); // 배정변경
|
||||
// 서류누락
|
||||
$routes->post('m702a/saveTel', 'M702::saveTel'); // 전화확인 정보 저장
|
||||
$routes->post('m702a/modifyInfo', 'M702::modifyInfo'); // 매물정보저장
|
||||
$routes->post('m702a/saveDocu', 'M702::saveDocu'); // 서류정보저장
|
||||
|
||||
$routes->post('m702a/uploadFile', 'M702::uploadFile'); // 파일업로드
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -209,6 +244,7 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
$routes->post('m703a/saveRequestMessage', 'M703::saveRequestMessage'); // 중개사요청사항저장
|
||||
$routes->post('m703a/saveResult', 'M703::saveResult'); // 결과저장
|
||||
|
||||
|
||||
/**
|
||||
* 홍보확인서 확인
|
||||
*/
|
||||
@@ -227,8 +263,11 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
*/
|
||||
$routes->get('m704a/getResultList', 'M704::getResultList');
|
||||
$routes->get('m704a/excel', 'M704::excel');
|
||||
$routes->post('m704a/modifyInfo', 'M704::modifyInfo'); // 매물정보 저장
|
||||
$routes->post('m704a/uploadFile', 'M704::uploadFile'); // 파일업로드
|
||||
$routes->post('m704a/saveMemo', 'M704::saveMemo'); // 메모저장
|
||||
$routes->post('m704a/contactFail', 'M704::contactFail'); // 통화실패 저장
|
||||
$routes->post('m704a/saveTel', 'M704::saveTel'); // 전화확인정보 저장
|
||||
$routes->post('m704a/getNextFaxImgs', 'M704::getNextFaxImgs'); // 다음매물확인
|
||||
});
|
||||
|
||||
@@ -250,7 +289,8 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
$routes->post('m705a/uploadFile', 'M705::uploadFile'); // 파일업로드
|
||||
|
||||
$routes->post('m705a/getNextInfo', 'M705::getNextInfo'); // 다음매물확인
|
||||
$routes->post('m705a/nextRegi', 'M705::saveRegi'); // 매물저장
|
||||
$routes->post('m705a/saveRegi', 'M705::saveRegi'); // 매물저장
|
||||
$routes->post('m705a/getNextInfo', 'M705::getNextInfo'); // 다음매물
|
||||
|
||||
|
||||
});
|
||||
@@ -268,6 +308,10 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
$routes->get('m706a/getResultList', 'M706::getResultList');
|
||||
$routes->get('m706a/excel', 'M706::excel');
|
||||
|
||||
$routes->post('m706a/modifyInfo', 'M706::modifyInfo'); // 매물정보 저장
|
||||
$routes->post('m706a/saveDocu', 'M706::saveDocu'); // 서류정보 저장
|
||||
$routes->post('m706a/saveRegi', 'M706::saveRegi'); // 등기부등본 저장
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -290,7 +334,8 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
$routes->post('m708a/saveBunyang', 'M708::saveBunyang'); // 분양권 저장
|
||||
$routes->post('m708a/saveRequestMessage', 'M708::saveRequestMessage'); // 중개인 요청사항 저장
|
||||
$routes->post('m708a/saveResult', 'M708::saveResult'); // 결과저장
|
||||
$routes->post('m708a/saveBunyangCnt', 'M708::saveBunyangCnt'); // 분양계약서저장
|
||||
$routes->post('m708a/saveBunyangCnt', 'M708::saveBunyangCnt'); // 분양계약서조회
|
||||
$routes->post('m708a/saveResult3', 'M708::saveResult3'); // 분양계약서저장
|
||||
$routes->post('m708a/getNextFaxImgs', 'M708::getNextFaxImgs'); // 다음매물
|
||||
|
||||
});
|
||||
@@ -379,7 +424,8 @@ $routes->group('', ['namespace' => 'App\Controllers\V2'], static function ($rout
|
||||
$routes->get('m713a/excel', 'M713::excel');
|
||||
$routes->post('m713a/rotateImage', 'M713::rotateImage'); // 이미지 회전
|
||||
$routes->post('m713a/saveCorpOwn', 'M713::saveCorpOwn'); // 법인매물저장
|
||||
$routes->post('m713a/saveRegi', 'M713::saveRegi'); // 매물저장
|
||||
$routes->post('m713a/saveModify', 'M713::saveModify');
|
||||
$routes->post('m713a/saveRegi', 'M713::saveRegi'); // 등기부등본 저장
|
||||
$routes->post('m713a/nextRegi', 'M713::nextRegi'); // 다음매물
|
||||
|
||||
});
|
||||
@@ -623,6 +669,12 @@ $routes->group('manage', ['namespace' => 'App\Controllers\Manage'], function ($r
|
||||
/** API - 로그인로그관리 */
|
||||
$routes->get('loginlog/getLogList', 'LoginLog::getLogList');
|
||||
$routes->get('loginlog/excel', 'LoginLog::excel');
|
||||
|
||||
/** Worker 로그 관리 */
|
||||
$routes->get('workerlog', 'WorkerLog::index');
|
||||
$routes->get('workerlog/stream', 'WorkerLog::stream');
|
||||
$routes->get('workerlog/download', 'WorkerLog::download');
|
||||
$routes->post('workerlog/delete', 'WorkerLog::delete');
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -649,3 +701,12 @@ $routes->post('/login/chkLogin', 'Login::chkLogin');
|
||||
if (is_file($filepath = APPPATH . 'Config/Routes/Api.php')) {
|
||||
require $filepath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Worker 관리
|
||||
*/
|
||||
$routes->group('manage/worker', ['namespace' => 'App\Controllers\Manage'], function ($routes) {
|
||||
$routes->get('failed', 'WorkerLogController::failedList');
|
||||
$routes->post('retry', 'WorkerLogController::retrySelected');
|
||||
$routes->get('detail/(:num)', 'WorkerLogController::detail/$1');
|
||||
});
|
||||
@@ -6,5 +6,5 @@ use CodeIgniter\Router\RouteCollection;
|
||||
/** @var RouteCollection $routes */
|
||||
|
||||
$routes->group('kiso', function(RouteCollection $routes) {
|
||||
$routes->match(['get', 'post'], 'api/vrfcReq', 'KisoController::vrfcReq');
|
||||
$routes->match(['GET', 'POST'], 'api/vrfcReq', 'KisoController::vrfcReq');
|
||||
});
|
||||
@@ -4,7 +4,7 @@ namespace Config;
|
||||
|
||||
use CodeIgniter\Config\BaseConfig;
|
||||
use CodeIgniter\Session\Handlers\BaseHandler;
|
||||
use CodeIgniter\Session\Handlers\FileHandler;
|
||||
use CodeIgniter\Session\Handlers\DatabaseHandler;
|
||||
use CodeIgniter\Session\Handlers\RedisHandler;
|
||||
|
||||
class Session extends BaseConfig
|
||||
@@ -15,14 +15,11 @@ class Session extends BaseConfig
|
||||
* --------------------------------------------------------------------------
|
||||
*
|
||||
* The session storage driver to use:
|
||||
* - `CodeIgniter\Session\Handlers\FileHandler`
|
||||
* - `CodeIgniter\Session\Handlers\DatabaseHandler`
|
||||
* - `CodeIgniter\Session\Handlers\MemcachedHandler`
|
||||
* - `CodeIgniter\Session\Handlers\RedisHandler`
|
||||
*
|
||||
* @var class-string<BaseHandler>
|
||||
*/
|
||||
// public string $driver = FileHandler::class;
|
||||
public string $driver = RedisHandler::class;
|
||||
|
||||
/**
|
||||
@@ -51,16 +48,61 @@ class Session extends BaseConfig
|
||||
*
|
||||
* The location to save sessions to and is driver dependent.
|
||||
*
|
||||
* For the 'files' driver, it's a path to a writable directory.
|
||||
* WARNING: Only absolute paths are supported!
|
||||
*
|
||||
* For the 'database' driver, it's a table name.
|
||||
* Please read up the manual for the format with other session drivers.
|
||||
* For Redis: tcp://host:port?database=n&password=xxx
|
||||
*
|
||||
* IMPORTANT: You are REQUIRED to set a valid save path!
|
||||
*/
|
||||
// public string $savePath = WRITEPATH . 'session';
|
||||
public string $savePath = 'tcp://192.168.10.243:6379?database=0';
|
||||
public string $savePath;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// 환경변수로 강제로 Database 모드 설정 가능 (Redis 장애 시 수동 전환)
|
||||
$forceDatabase = env('SESSION_FORCE_DATABASE', false);
|
||||
|
||||
// Redis 설정: Redis 연결 실패 시 Database로 폴백
|
||||
if ($this->driver === RedisHandler::class && !$forceDatabase) {
|
||||
helper('redis');
|
||||
|
||||
try {
|
||||
// Redis 연결 테스트
|
||||
$testRedis = get_redis_connection('session');
|
||||
|
||||
if (!$testRedis) {
|
||||
throw new \Exception('Redis connection failed');
|
||||
}
|
||||
|
||||
// Redis 정상 - Redis 설정 사용
|
||||
$config = get_redis_config('session');
|
||||
|
||||
$this->savePath = sprintf(
|
||||
'tcp://%s:%s?database=%s',
|
||||
$config['host'],
|
||||
$config['port'],
|
||||
$config['database']
|
||||
);
|
||||
|
||||
if (!empty($config['password'])) {
|
||||
$this->savePath .= '&password=' . $config['password'];
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Redis 실패 - DatabaseHandler로 폴백
|
||||
log_message('warning', 'Session: Redis unavailable (' . $e->getMessage() . '), falling back to DatabaseHandler');
|
||||
$this->driver = DatabaseHandler::class;
|
||||
$this->savePath = 'ci_sessions'; // 테이블 이름
|
||||
}
|
||||
} else {
|
||||
// Database 강제 모드 또는 기본 Database 설정
|
||||
if ($forceDatabase && $this->driver === RedisHandler::class) {
|
||||
log_message('info', 'Session: Forced to use DatabaseHandler (SESSION_FORCE_DATABASE=true)');
|
||||
$this->driver = DatabaseHandler::class;
|
||||
}
|
||||
$this->savePath = 'ci_sessions';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* --------------------------------------------------------------------------
|
||||
|
||||
@@ -158,6 +158,51 @@ class Dept extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
public function excel2()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'rcpt_atclno' => $this->request->getGet('rcpt_atclno'), // 매물ID
|
||||
|
||||
'sdate' => $this->request->getGet('sdate'), // 시작일
|
||||
'edate' => $this->request->getGet('edate'), // 종료일
|
||||
|
||||
'rsrv_tm_ap' => $this->request->getGet('rsrv_tm_ap'), // 유형
|
||||
'rsrv_sdate' => $this->request->getGet('rsrv_sdate'), // 시작일
|
||||
'rsrv_edate' => $this->request->getGet('rsrv_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'), // 읍면동
|
||||
|
||||
'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'), // 직거래
|
||||
|
||||
'stat' => $this->request->getGet('stat'),
|
||||
|
||||
'srchType' => $this->request->getGet('srchType'), // 검색유형
|
||||
'srchTxt' => $this->request->getGet('srchTxt'), // 검색어
|
||||
|
||||
'type' => 'excel',
|
||||
];
|
||||
|
||||
$datas = $this->model->getResultList(null, null, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 배정변경
|
||||
public function updateAssign()
|
||||
@@ -222,9 +267,9 @@ class Dept extends BaseController
|
||||
public function detail($id): string
|
||||
{
|
||||
|
||||
$id = (int) $id;
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -136,4 +136,52 @@ class Dept2 extends BaseController
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
// 배정내역 excel
|
||||
public function excel2()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'req_rec_yn' => 'Y',
|
||||
'rcpt_atclno' => $this->request->getGet('rcpt_atclno'), // 매물ID
|
||||
|
||||
'sdate' => $this->request->getGet('sdate'), // 시작일
|
||||
'edate' => $this->request->getGet('edate'), // 종료일
|
||||
|
||||
'rsrv_tm_ap' => $this->request->getGet('rsrv_tm_ap'), // 유형
|
||||
'rsrv_sdate' => $this->request->getGet('rsrv_sdate'), // 시작일
|
||||
'rsrv_edate' => $this->request->getGet('rsrv_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'), // 읍면동
|
||||
|
||||
'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'), // 직거래
|
||||
|
||||
'isSiteVRVerification' => $this->request->getGet('isSiteVRVerification'), // 검증방식
|
||||
'conf_img_yn' => $this->request->getGet('conf_img_yn'), // 홍보확인서 여부
|
||||
|
||||
'stat' => $this->request->getGet('stat'),
|
||||
|
||||
'srchType' => $this->request->getGet('srchType'), // 검색유형
|
||||
'srchTxt' => $this->request->getGet('srchTxt'), // 검색어
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,42 +109,100 @@ class Processible extends BaseController
|
||||
// 지역별 수량 저장
|
||||
public function saveArea()
|
||||
{
|
||||
try {
|
||||
log_message('info', '[Processible::saveArea] 진입');
|
||||
|
||||
try {
|
||||
$rows = $this->request->getPost('rows');
|
||||
$rows = json_decode($rows, true);
|
||||
|
||||
// dd($rows);
|
||||
// exit;
|
||||
|
||||
if (count($rows) > 0) {
|
||||
|
||||
foreach ($rows as $row):
|
||||
$this->model->saveArea($row);
|
||||
endforeach;
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} else {
|
||||
if (empty($rows)) {
|
||||
log_message('info', '[Processible::saveArea] 저장가능한 데이터가 없습니다.');
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => '저장가능한 데이터가 없습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
// API 형식으로 변환 및 DB 저장
|
||||
$syncSlotData = [];
|
||||
foreach ($rows as $row) {
|
||||
// DB 저장 (API 실패와 무관하게 저장됨)
|
||||
$this->model->saveArea($row);
|
||||
|
||||
// API 데이터 구성
|
||||
$syncSlotData[] = [
|
||||
'baseDate' => $row['sc_date'],
|
||||
'legalDivisionNumber' => $row['region_cd'],
|
||||
'slots' => [
|
||||
'am' => [
|
||||
'max' => (int) $row['am_cnt'],
|
||||
'reserved' => 0
|
||||
],
|
||||
'pm' => [
|
||||
'max' => (int) $row['pm_cnt'],
|
||||
'reserved' => 0
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
log_message('info', '[Processible::saveArea] DB 저장 완료 | Count: ' . count($rows));
|
||||
|
||||
// 네이버 API 슬롯 동기화 시도
|
||||
log_message('info', '[Processible::saveArea] 슬롯 동기화 시작 | Count: ' . count($syncSlotData));
|
||||
$naverClient = new \App\Libraries\NaverApiClient();
|
||||
$apiResponse = $naverClient->syncSiteSlot($syncSlotData);
|
||||
|
||||
// API 응답 에러 체크
|
||||
$hasError = false;
|
||||
$errorMessage = '';
|
||||
|
||||
if ($apiResponse === null) {
|
||||
$hasError = true;
|
||||
$errorMessage = 'API 응답 없음 (null)';
|
||||
} elseif (!empty($apiResponse['error'])) {
|
||||
$hasError = true;
|
||||
$errorType = $apiResponse['error_type'] ?? 'UNKNOWN';
|
||||
$httpCode = $apiResponse['http_code'] ?? 'N/A';
|
||||
$errorMessage = "API Error: {$errorType} (HTTP {$httpCode})";
|
||||
} elseif (isset($apiResponse['http_code']) && $apiResponse['http_code'] >= 400) {
|
||||
$hasError = true;
|
||||
$errorMessage = "HTTP Error: {$apiResponse['http_code']}";
|
||||
}
|
||||
|
||||
// API 에러 발생 시 (DB는 이미 저장됨)
|
||||
if ($hasError) {
|
||||
log_message('error', "[Processible::saveArea] {$errorMessage} | Response: " . json_encode($apiResponse, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '1',
|
||||
'msg' => 'DB 저장은 완료되었으나 네이버 슬롯 동기화에 실패했습니다. 관리자에게 문의하세요.',
|
||||
'error' => $errorMessage,
|
||||
'dbSaved' => true,
|
||||
'syncData' => $syncSlotData,
|
||||
'apiResponse' => $apiResponse
|
||||
]);
|
||||
}
|
||||
|
||||
// 성공
|
||||
log_message('info', '[Processible::saveArea] Naver API 슬롯 동기화 성공 | Response: ' . json_encode($apiResponse, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success',
|
||||
'dbSaved' => true,
|
||||
'syncData' => $syncSlotData,
|
||||
'apiResponse' => $apiResponse
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', '[Processible::saveArea] 예외 발생: ' . $e->getMessage());
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
'msg' => '처리 중 오류가 발생했습니다: ' . $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 기본 수량 저장
|
||||
public function saveCount()
|
||||
{
|
||||
try {
|
||||
@@ -152,18 +210,24 @@ class Processible extends BaseController
|
||||
$rows = $this->request->getPost('rows');
|
||||
$rows = json_decode($rows, true);
|
||||
|
||||
// dd($rows);
|
||||
// exit;
|
||||
|
||||
if (count($rows) > 0) {
|
||||
|
||||
$results = [];
|
||||
$hasError = false;
|
||||
|
||||
foreach ($rows as $row):
|
||||
$this->model->saveCount($row);
|
||||
$result = $this->model->saveCount($row);
|
||||
$results[] = $result;
|
||||
|
||||
if (!$result['success']) {
|
||||
$hasError = true;
|
||||
}
|
||||
endforeach;
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
'code' => $hasError ? '9' : '0',
|
||||
'msg' => $hasError ? '일부 저장 실패' : 'success',
|
||||
'debug' => $results // 디버깅 정보 포함
|
||||
]);
|
||||
|
||||
} else {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -120,9 +120,9 @@ class Record extends BaseController
|
||||
public function detail($id): string
|
||||
{
|
||||
|
||||
$id = (int) $id;
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,23 @@ class KisoController extends BaseController
|
||||
/** @var ResponseInterface */
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* 네이버 검증 요청 API
|
||||
*
|
||||
* Required Parameters:
|
||||
* - articleNumber: 기사 번호
|
||||
* - requestType: 요청 타입 (verify, check, validate)
|
||||
* - requestDatetime: 요청 일시 (YYYY-MM-DD HH:MM:SS)
|
||||
*
|
||||
* Error Codes:
|
||||
* - E001: 필수 파라미터 누락
|
||||
* - E002: requestType 값 오류
|
||||
* - E003: requestDatetime 형식 오류
|
||||
* - E005: HTTP 메소드 오류
|
||||
* - E999: Redis 연결 오류
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function vrfcReq()
|
||||
{
|
||||
// 1. 요청 방식에 따라 데이터 파싱
|
||||
@@ -25,56 +42,79 @@ class KisoController extends BaseController
|
||||
} else {
|
||||
// 지원하지 않는 메소드 처리 (예: PUT, DELETE 등)
|
||||
return $this->response->setStatusCode(Response::HTTP_METHOD_NOT_ALLOWED)
|
||||
->setJSON(['resultCode' => 'E005', 'resultMessage' => 'Method not allowed. Use GET or POST.']);
|
||||
->setJSON(['code' => 'E005', 'message' => 'Method not allowed. Use GET or POST.']);
|
||||
}
|
||||
|
||||
// 2. 필수 항목 검증
|
||||
$requiredKeys = ['articleNumber', 'requestType', 'requestDatetime'];
|
||||
|
||||
foreach ($requiredKeys as $key) {
|
||||
// 파싱된 데이터($data) 내에 키가 없거나 값이 비어있는지 확인
|
||||
if (empty($data[$key])) {
|
||||
// isset()과 trim()을 사용하여 '0' 값도 허용
|
||||
if (!isset($data[$key]) || trim((string)$data[$key]) === '') {
|
||||
return $this->response->setStatusCode(Response::HTTP_BAD_REQUEST)
|
||||
->setJSON([
|
||||
'resultCode' => 'E001',
|
||||
'resultMessage' => "Missing required parameter: {$key}"
|
||||
'code' => 'E001',
|
||||
'message' => "Missing required parameter: {$key}"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Redis 연결 및 예외 처리
|
||||
// 3. Redis 연결 및 직접 푸시
|
||||
try {
|
||||
$redis = new \Redis();
|
||||
// Docker 환경이므로 host를 'redis'로 설정
|
||||
$success = $redis->connect('redis', 6379);
|
||||
// 3. requestType 값 검증
|
||||
$validRequestTypes = ['verify', 'check', 'validate']; // 허용되는 requestType 값
|
||||
if (!in_array($data['requestType'], $validRequestTypes, true)) {
|
||||
return $this->response->setStatusCode(Response::HTTP_BAD_REQUEST)
|
||||
->setJSON([
|
||||
'code' => 'E002',
|
||||
'message' => "Invalid requestType. Allowed values: " . implode(', ', $validRequestTypes)
|
||||
]);
|
||||
}
|
||||
|
||||
if (!$success) {
|
||||
// 4. requestDatetime 날짜 형식 검증 (Y-m-d H:i:s 형식)
|
||||
$datetime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['requestDatetime']);
|
||||
if (!$datetime || $datetime->format('Y-m-d H:i:s') !== $data['requestDatetime']) {
|
||||
return $this->response->setStatusCode(Response::HTTP_BAD_REQUEST)
|
||||
->setJSON([
|
||||
'code' => 'E003',
|
||||
'message' => "Invalid requestDatetime format. Use: YYYY-MM-DD HH:MM:SS"
|
||||
]);
|
||||
}
|
||||
|
||||
// 5. Redis 연결 및 큐 저장
|
||||
helper('redis');
|
||||
try {
|
||||
$redis = get_redis_connection('worker');
|
||||
|
||||
if (!$redis) {
|
||||
throw new \Exception('Redis connection failed');
|
||||
}
|
||||
|
||||
$redis->select(10); // 10번 DB 선택
|
||||
|
||||
// 데이터 준비
|
||||
$data['retry_count'] = 0;
|
||||
$data['received_at'] = date('Y-m-d H:i:s');
|
||||
|
||||
// 리스트에 데이터 삽입 (이 명령어가 실행되어야 monitor에 LPUSH가 뜹니다)
|
||||
$redis->lPush('naver:queue', json_encode($data));
|
||||
// 리스트에 데이터 삽입
|
||||
$pushResult = $redis->lPush('naver:queue', json_encode($data));
|
||||
|
||||
if (!$pushResult) {
|
||||
throw new \Exception('Failed to push data to Redis queue');
|
||||
}
|
||||
|
||||
// 성공 로그 기록
|
||||
log_message('info', "Request queued successfully - Article: {$data['articleNumber']}, Type: {$data['requestType']}");
|
||||
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', 'Redis Push Error: ' . $e->getMessage());
|
||||
return $this->response->setStatusCode(500)->setJSON([
|
||||
'resultCode' => 'E999',
|
||||
'resultMessage' => 'Redis Connection Error'
|
||||
'code' => 'E999',
|
||||
'message' => 'Redis Connection Error'
|
||||
]);
|
||||
}
|
||||
|
||||
// 4. 성공 응답
|
||||
return $this->response->setStatusCode(Response::HTTP_ACCEPTED) // 202 Accepted
|
||||
// 6. 성공 응답
|
||||
return $this->response->setStatusCode(Response::HTTP_OK) // 200 OK
|
||||
->setJSON([
|
||||
'resultCode' => 'S000',
|
||||
'resultMessage' => 'Request successfully queued for processing',
|
||||
'articleNumber' => $data['articleNumber']
|
||||
'code' => 'success',
|
||||
'message' => ''
|
||||
]);
|
||||
}
|
||||
}
|
||||
27
app/Controllers/LogTest.php
Normal file
27
app/Controllers/LogTest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
class LogTest extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
log_message('error', '===== WEB LOG TEST ===== ' . date('Y-m-d H:i:s'));
|
||||
log_message('info', 'Info from web');
|
||||
log_message('debug', 'Debug from web');
|
||||
|
||||
$logFile = WRITEPATH . 'logs/log-' . date('Y-m-d') . '.log';
|
||||
|
||||
echo "ENVIRONMENT: " . ENVIRONMENT . "<br>";
|
||||
echo "Log file: " . $logFile . "<br>";
|
||||
echo "Exists: " . (file_exists($logFile) ? 'YES' : 'NO') . "<br>";
|
||||
echo "Writable: " . (is_writable(dirname($logFile)) ? 'YES' : 'NO') . "<br>";
|
||||
|
||||
if (file_exists($logFile)) {
|
||||
echo "<h3>Last 20 lines:</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(shell_exec('tail -20 ' . escapeshellarg($logFile)));
|
||||
echo "</pre>";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\common\LoginModel;
|
||||
use CodeIgniter\Session\Handlers\DatabaseHandler;
|
||||
|
||||
class Login extends BaseController
|
||||
{
|
||||
@@ -13,11 +14,44 @@ class Login extends BaseController
|
||||
$this->loginModel = new LoginModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redis 폴백 상태 체크 (세션이 DatabaseHandler로 동작 중인지)
|
||||
*/
|
||||
private function getSystemStatus(): array
|
||||
{
|
||||
$status = [
|
||||
'redis_fallback' => false,
|
||||
'warning_message' => ''
|
||||
];
|
||||
|
||||
// Session 설정에서 현재 드라이버 확인
|
||||
$sessionConfig = config('Session');
|
||||
if ($sessionConfig->driver === DatabaseHandler::class) {
|
||||
$status['redis_fallback'] = true;
|
||||
$status['warning_message'] = '세션 서버(Redis) 장애로 임시 모드로 운영 중입니다. 시스템 관리자에게 문의하세요.';
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON 응답에 시스템 상태 추가
|
||||
*/
|
||||
private function jsonResponse(array $data): \CodeIgniter\HTTP\ResponseInterface
|
||||
{
|
||||
$systemStatus = $this->getSystemStatus();
|
||||
$data['system'] = $systemStatus;
|
||||
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
public function index(): string
|
||||
{
|
||||
$user_id = get_cookie('save_id');
|
||||
if (!empty($user_id)) {
|
||||
$this->data['user_id'] = $user_id;
|
||||
} else {
|
||||
delete_cookie('save_id');
|
||||
}
|
||||
|
||||
return view('pages/login', $this->data);
|
||||
@@ -57,7 +91,7 @@ class Login extends BaseController
|
||||
];
|
||||
|
||||
if (!$this->validate($rules)) {
|
||||
return $this->response->setJSON([
|
||||
return $this->jsonResponse([
|
||||
'code' => '1',
|
||||
'errors' => $this->validator->getErrors()
|
||||
]);
|
||||
@@ -80,7 +114,7 @@ class Login extends BaseController
|
||||
|
||||
$this->loginModel->insertUserLog($logs);
|
||||
|
||||
return $this->response->setJSON([
|
||||
return $this->jsonResponse([
|
||||
'code' => '1',
|
||||
'msg' => '존재하지 않는 아이디입니다.'
|
||||
]);
|
||||
@@ -94,7 +128,7 @@ class Login extends BaseController
|
||||
|
||||
$this->loginModel->insertUserLog($logs);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
return $this->jsonResponse([
|
||||
'code' => '1',
|
||||
'msg' => '잘못된 비밀번호 입니다.'
|
||||
]);
|
||||
@@ -133,7 +167,7 @@ class Login extends BaseController
|
||||
|
||||
$this->session->set($newdata);
|
||||
|
||||
return $this->response->setJSON([
|
||||
return $this->jsonResponse([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
@@ -146,7 +180,17 @@ class Login extends BaseController
|
||||
log_message('error', '[LOGIN ERROR] ' . $e->getMessage());
|
||||
log_message('error', $e->getTraceAsString());
|
||||
|
||||
return $this->response->setJSON([
|
||||
// 세션 관련 에러인지 확인
|
||||
$errorMessage = $e->getMessage();
|
||||
if (stripos($errorMessage, 'session') !== false ||
|
||||
stripos($errorMessage, 'redis') !== false) {
|
||||
return $this->jsonResponse([
|
||||
'code' => '8',
|
||||
'msg' => '세션 서비스 오류입니다. 시스템 관리자에게 문의해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->jsonResponse([
|
||||
'code' => '9',
|
||||
'msg' => '서버 내부 오류가 발생했습니다. 잠시 후 다시 시도해주세요.'
|
||||
]);
|
||||
@@ -157,7 +201,9 @@ class Login extends BaseController
|
||||
public function out()
|
||||
{
|
||||
$this->session->destroy();
|
||||
return redirect()->to('/login');
|
||||
return redirect()
|
||||
->to('/login')
|
||||
->deleteCookie('save_id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
222
app/Controllers/Manage/WorkerLog.php
Normal file
222
app/Controllers/Manage/WorkerLog.php
Normal file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
|
||||
class WorkerLog extends BaseController
|
||||
{
|
||||
/**
|
||||
* Worker 로그 통합 뷰어
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->data['title'] = 'Worker 로그 통합 관리';
|
||||
|
||||
// 로그 디렉토리 목록
|
||||
$logDirs = [
|
||||
'api_receiver' => ROOTPATH . 'worker/logs',
|
||||
'naver_worker' => WRITEPATH . 'logs/worker'
|
||||
];
|
||||
|
||||
// 날짜 필터 (기본값: 오늘)
|
||||
$date = $this->request->getGet('date') ?? date('Y-m-d');
|
||||
$logType = $this->request->getGet('type') ?? 'all';
|
||||
|
||||
$logs = [];
|
||||
|
||||
// API Receiver 로그 읽기
|
||||
if ($logType === 'all' || $logType === 'api_receiver') {
|
||||
$apiLogFile = $logDirs['api_receiver'] . '/' . $date . '.log';
|
||||
if (file_exists($apiLogFile)) {
|
||||
$logs['api_receiver'] = $this->parseLogFile($apiLogFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Naver Worker 로그 읽기
|
||||
if ($logType === 'all' || $logType === 'naver_worker') {
|
||||
$workerLogFile = $logDirs['naver_worker'] . '/' . $date . '.log';
|
||||
if (file_exists($workerLogFile)) {
|
||||
$logs['naver_worker'] = $this->parseLogFile($workerLogFile);
|
||||
}
|
||||
|
||||
// Failed 로그도 읽기
|
||||
$failedLogFile = $logDirs['naver_worker'] . '/' . $date . '_failed.log';
|
||||
if (file_exists($failedLogFile)) {
|
||||
$logs['naver_worker_failed'] = $this->parseLogFile($failedLogFile);
|
||||
}
|
||||
}
|
||||
|
||||
// 모든 로그를 시간순으로 통합 정렬
|
||||
$allLogs = [];
|
||||
foreach ($logs as $type => $entries) {
|
||||
foreach ($entries as $entry) {
|
||||
$entry['source'] = $type;
|
||||
$allLogs[] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
// 시간 역순 정렬 (최신순)
|
||||
usort($allLogs, function($a, $b) {
|
||||
return strtotime($b['timestamp']) - strtotime($a['timestamp']);
|
||||
});
|
||||
|
||||
$this->data['logs'] = $allLogs;
|
||||
$this->data['date'] = $date;
|
||||
$this->data['logType'] = $logType;
|
||||
$this->data['logDirs'] = $logDirs;
|
||||
|
||||
// 사용 가능한 날짜 목록 (최근 30일)
|
||||
$this->data['availableDates'] = $this->getAvailableLogDates($logDirs);
|
||||
|
||||
return view('pages/manage/worker_log', $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 파일 파싱
|
||||
*/
|
||||
private function parseLogFile($filePath)
|
||||
{
|
||||
$logs = [];
|
||||
$lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$logs[] = $this->parseLogLine($line);
|
||||
}
|
||||
|
||||
return $logs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 한 줄 파싱
|
||||
*/
|
||||
private function parseLogLine($line)
|
||||
{
|
||||
// 로그 포맷: [2025-12-22 10:30:45] [INFO] [NaverWorker::run:95] 메시지
|
||||
if (preg_match('/\[(.+?)\]\s*\[(.+?)\]\s*(?:\[(.+?)\]\s*)?(.+)/', $line, $matches)) {
|
||||
return [
|
||||
'timestamp' => $matches[1],
|
||||
'level' => $matches[2],
|
||||
'location' => $matches[3] ?? '',
|
||||
'message' => $matches[4]
|
||||
];
|
||||
}
|
||||
|
||||
// 파싱 실패한 경우 원본 그대로
|
||||
return [
|
||||
'timestamp' => date('Y-m-d H:i:s'),
|
||||
'level' => 'UNKNOWN',
|
||||
'location' => '',
|
||||
'message' => $line
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 파일이 존재하는 날짜 목록 가져오기
|
||||
*/
|
||||
private function getAvailableLogDates($logDirs)
|
||||
{
|
||||
$dates = [];
|
||||
|
||||
foreach ($logDirs as $dir) {
|
||||
if (!is_dir($dir)) continue;
|
||||
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $file) {
|
||||
if (preg_match('/(\d{4}-\d{2}-\d{2})(?:_failed)?\.log$/', $file, $matches)) {
|
||||
$dates[$matches[1]] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dates = array_keys($dates);
|
||||
rsort($dates); // 최신순 정렬
|
||||
|
||||
return array_slice($dates, 0, 30); // 최근 30일만
|
||||
}
|
||||
|
||||
/**
|
||||
* 실시간 로그 스트리밍 (Ajax)
|
||||
*/
|
||||
public function stream()
|
||||
{
|
||||
$type = $this->request->getGet('type') ?? 'naver_worker';
|
||||
$lastId = (int) ($this->request->getGet('lastId') ?? 0);
|
||||
|
||||
$logDirs = [
|
||||
'api_receiver' => ROOTPATH . 'worker/logs',
|
||||
'naver_worker' => WRITEPATH . 'logs/worker'
|
||||
];
|
||||
|
||||
$logFile = $logDirs[$type] . '/' . date('Y-m-d') . '.log';
|
||||
|
||||
$newLogs = [];
|
||||
if (file_exists($logFile)) {
|
||||
$lines = file($logFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
|
||||
// lastId 이후의 로그만 반환
|
||||
if ($lastId < count($lines)) {
|
||||
$newLines = array_slice($lines, $lastId);
|
||||
|
||||
foreach ($newLines as $line) {
|
||||
$newLogs[] = $this->parseLogLine($line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'success' => true,
|
||||
'logs' => $newLogs,
|
||||
'lastId' => $lastId + count($newLogs)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 파일 다운로드
|
||||
*/
|
||||
public function download()
|
||||
{
|
||||
$date = $this->request->getGet('date') ?? date('Y-m-d');
|
||||
$type = $this->request->getGet('type') ?? 'naver_worker';
|
||||
|
||||
$logDirs = [
|
||||
'api_receiver' => ROOTPATH . 'worker/logs',
|
||||
'naver_worker' => WRITEPATH . 'logs/worker'
|
||||
];
|
||||
|
||||
$logFile = $logDirs[$type] . '/' . $date . '.log';
|
||||
|
||||
if (!file_exists($logFile)) {
|
||||
return $this->response->setStatusCode(404)->setBody('로그 파일을 찾을 수 없습니다.');
|
||||
}
|
||||
|
||||
return $this->response->download($logFile, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 로그 파일 삭제
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$date = $this->request->getPost('date');
|
||||
$type = $this->request->getPost('type');
|
||||
|
||||
if (!$date || !$type) {
|
||||
return $this->response->setJSON(['success' => false, 'message' => '필수 파라미터 누락']);
|
||||
}
|
||||
|
||||
$logDirs = [
|
||||
'api_receiver' => ROOTPATH . 'worker/logs',
|
||||
'naver_worker' => WRITEPATH . 'logs/worker'
|
||||
];
|
||||
|
||||
$logFile = $logDirs[$type] . '/' . $date . '.log';
|
||||
|
||||
if (file_exists($logFile)) {
|
||||
unlink($logFile);
|
||||
return $this->response->setJSON(['success' => true, 'message' => '로그 파일이 삭제되었습니다.']);
|
||||
}
|
||||
|
||||
return $this->response->setJSON(['success' => false, 'message' => '로그 파일을 찾을 수 없습니다.']);
|
||||
}
|
||||
}
|
||||
366
app/Controllers/Manage/WorkerLogController.php
Normal file
366
app/Controllers/Manage/WorkerLogController.php
Normal file
@@ -0,0 +1,366 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Manage;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Entities\NaverWorkerLogModel;
|
||||
|
||||
class WorkerLogController extends BaseController
|
||||
{
|
||||
protected $logModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logModel = new NaverWorkerLogModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* 실패 로그 목록 (오류 유형별 분석)
|
||||
*/
|
||||
public function failedList()
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
// 1. 전체 통계
|
||||
$stats = [
|
||||
'total_fail' => $this->logModel->where('status', 'FAIL')->countAllResults(false),
|
||||
'retry_available' => $this->logModel
|
||||
->where('status', 'FAIL')
|
||||
->groupStart()
|
||||
->where('retry_cnt IS NULL')
|
||||
->orWhere('retry_cnt <', 3)
|
||||
->groupEnd()
|
||||
->countAllResults(false),
|
||||
'retry_exhausted' => $this->logModel
|
||||
->where('status', 'FAIL')
|
||||
->where('retry_cnt >=', 3)
|
||||
->countAllResults(false),
|
||||
];
|
||||
|
||||
// 2. 오류 유형별 분류
|
||||
$errorTypes = $this->classifyErrors();
|
||||
|
||||
// 3. 최근 실패 목록
|
||||
$recentFails = $this->logModel
|
||||
->select('seq, atcl_no, status, error_msg, retry_cnt, created_at')
|
||||
->where('status', 'FAIL')
|
||||
->orderBy('created_at', 'DESC')
|
||||
->findAll(50);
|
||||
|
||||
// 각 오류에 대한 해결 가이드 추가
|
||||
foreach ($recentFails as &$log) {
|
||||
$log['error_type'] = $this->detectErrorType($log['error_msg']);
|
||||
$log['solution'] = $this->getSolution($log['error_type']);
|
||||
$log['can_retry'] = $this->canRetry($log);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'stats' => $stats,
|
||||
'errorTypes' => $errorTypes,
|
||||
'logs' => $recentFails
|
||||
];
|
||||
|
||||
return view('manage/worker_log/failed_list', array_merge($this->data, $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 오류 유형 분류
|
||||
*/
|
||||
protected function classifyErrors()
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$errorPatterns = [
|
||||
'foreign_key' => [
|
||||
'pattern' => 'foreign key constraint',
|
||||
'label' => 'FK 제약조건 위반',
|
||||
'severity' => 'high',
|
||||
'count' => 0
|
||||
],
|
||||
'duplicate' => [
|
||||
'pattern' => 'Duplicate entry',
|
||||
'label' => '중복 데이터',
|
||||
'severity' => 'medium',
|
||||
'count' => 0
|
||||
],
|
||||
'missing_user' => [
|
||||
'pattern' => 'usr_sq.*users 테이블에 없음',
|
||||
'label' => '담당자 정보 없음',
|
||||
'severity' => 'medium',
|
||||
'count' => 0
|
||||
],
|
||||
'empty_payload' => [
|
||||
'pattern' => '빈 페이로드',
|
||||
'label' => '빈 데이터',
|
||||
'severity' => 'low',
|
||||
'count' => 0
|
||||
],
|
||||
'api_error' => [
|
||||
'pattern' => 'API.*FAIL|HTTP.*40[0-9]|HTTP.*50[0-9]',
|
||||
'label' => 'API 통신 오류',
|
||||
'severity' => 'medium',
|
||||
'count' => 0
|
||||
],
|
||||
'unknown' => [
|
||||
'pattern' => '',
|
||||
'label' => '기타 오류',
|
||||
'severity' => 'low',
|
||||
'count' => 0
|
||||
]
|
||||
];
|
||||
|
||||
$failedLogs = $this->logModel
|
||||
->select('error_msg')
|
||||
->where('status', 'FAIL')
|
||||
->findAll();
|
||||
|
||||
foreach ($failedLogs as $log) {
|
||||
$classified = false;
|
||||
|
||||
foreach ($errorPatterns as $key => &$pattern) {
|
||||
if ($key === 'unknown') continue;
|
||||
|
||||
if ($pattern['pattern'] && preg_match('/' . $pattern['pattern'] . '/i', $log['error_msg'])) {
|
||||
$pattern['count']++;
|
||||
$classified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$classified) {
|
||||
$errorPatterns['unknown']['count']++;
|
||||
}
|
||||
}
|
||||
|
||||
return $errorPatterns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 오류 유형 감지
|
||||
*/
|
||||
protected function detectErrorType($errorMsg)
|
||||
{
|
||||
if (!$errorMsg) return 'unknown';
|
||||
|
||||
if (stripos($errorMsg, 'foreign key constraint') !== false) {
|
||||
return 'foreign_key';
|
||||
}
|
||||
if (stripos($errorMsg, 'Duplicate entry') !== false) {
|
||||
return 'duplicate';
|
||||
}
|
||||
if (stripos($errorMsg, 'usr_sq') !== false && stripos($errorMsg, 'users 테이블') !== false) {
|
||||
return 'missing_user';
|
||||
}
|
||||
if (stripos($errorMsg, '빈 페이로드') !== false) {
|
||||
return 'empty_payload';
|
||||
}
|
||||
if (preg_match('/API.*FAIL|HTTP.*40[0-9]|HTTP.*50[0-9]/i', $errorMsg)) {
|
||||
return 'api_error';
|
||||
}
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
* 오류 유형별 해결 방법
|
||||
*/
|
||||
protected function getSolution($errorType)
|
||||
{
|
||||
$solutions = [
|
||||
'foreign_key' => [
|
||||
'title' => 'DB 데이터 수정 필요',
|
||||
'steps' => [
|
||||
'1. 참조하는 테이블의 데이터가 존재하는지 확인',
|
||||
'2. region 테이블의 orphaned usr_sq 값 수정',
|
||||
'3. TypeSParameterMapper의 폴백 로직 확인'
|
||||
],
|
||||
'auto_retry' => false
|
||||
],
|
||||
'duplicate' => [
|
||||
'title' => '중복 데이터 처리',
|
||||
'steps' => [
|
||||
'1. 기존 데이터 확인 (atcl_no로 검색)',
|
||||
'2. 중복 원인 파악 (동일 요청 2회 수신?)',
|
||||
'3. 필요시 기존 데이터 삭제 후 재처리'
|
||||
],
|
||||
'auto_retry' => false
|
||||
],
|
||||
'missing_user' => [
|
||||
'title' => '담당자 정보 수정됨 - 재처리 가능',
|
||||
'steps' => [
|
||||
'✅ TypeSParameterMapper가 자동 폴백 적용됨',
|
||||
'✅ 바로 재처리 가능 (usr_sq=1로 처리됨)'
|
||||
],
|
||||
'auto_retry' => true
|
||||
],
|
||||
'empty_payload' => [
|
||||
'title' => '잘못된 요청 데이터',
|
||||
'steps' => [
|
||||
'1. raw_payload 확인',
|
||||
'2. 네이버 API 응답 확인',
|
||||
'3. 재처리 불가 - 데이터 삭제 권장'
|
||||
],
|
||||
'auto_retry' => false
|
||||
],
|
||||
'api_error' => [
|
||||
'title' => 'API 통신 오류',
|
||||
'steps' => [
|
||||
'1. 일시적 오류인지 확인 (네트워크, 타임아웃)',
|
||||
'2. 네이버 API 서버 상태 확인',
|
||||
'3. 일시적 오류면 재처리 가능'
|
||||
],
|
||||
'auto_retry' => true
|
||||
],
|
||||
'unknown' => [
|
||||
'title' => '원인 미상',
|
||||
'steps' => [
|
||||
'1. error_msg 상세 확인',
|
||||
'2. 로그 파일 확인',
|
||||
'3. 개발팀 검토 필요'
|
||||
],
|
||||
'auto_retry' => false
|
||||
]
|
||||
];
|
||||
|
||||
return $solutions[$errorType] ?? $solutions['unknown'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 재시도 가능 여부
|
||||
*/
|
||||
protected function canRetry($log)
|
||||
{
|
||||
// 재시도 횟수 체크
|
||||
if (($log['retry_cnt'] ?? 0) >= 3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 오류 유형별 재시도 가능 여부
|
||||
$errorType = $this->detectErrorType($log['error_msg']);
|
||||
$solution = $this->getSolution($errorType);
|
||||
|
||||
return $solution['auto_retry'] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 선택한 로그 재처리 (AJAX)
|
||||
*/
|
||||
public function retrySelected()
|
||||
{
|
||||
$logIds = $this->request->getPost('log_ids');
|
||||
|
||||
if (empty($logIds) || !is_array($logIds)) {
|
||||
return $this->response->setJSON([
|
||||
'success' => false,
|
||||
'message' => '재처리할 로그를 선택해주세요.'
|
||||
]);
|
||||
}
|
||||
|
||||
$naverService = new \App\Services\NaverService();
|
||||
$results = [
|
||||
'success' => 0,
|
||||
'fail' => 0,
|
||||
'details' => []
|
||||
];
|
||||
|
||||
foreach ($logIds as $logId) {
|
||||
$log = $this->logModel->find($logId);
|
||||
|
||||
if (!$log) {
|
||||
$results['details'][] = [
|
||||
'id' => $logId,
|
||||
'status' => 'error',
|
||||
'message' => '로그를 찾을 수 없습니다.'
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 재시도 가능 여부 체크
|
||||
if (!$this->canRetry($log)) {
|
||||
$results['details'][] = [
|
||||
'id' => $logId,
|
||||
'atcl_no' => $log['atcl_no'],
|
||||
'status' => 'skip',
|
||||
'message' => '재시도 불가능 (횟수 초과 또는 수정 필요)'
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
// 재처리
|
||||
$this->logModel->update($logId, ['status' => 'RETRY']);
|
||||
|
||||
$responseJson = json_decode($log['raw_payload'], true);
|
||||
$payload = $responseJson['request_data'] ?? [];
|
||||
|
||||
if (empty($payload)) {
|
||||
throw new \Exception("빈 페이로드 데이터");
|
||||
}
|
||||
|
||||
$insertId = $naverService->processArticle($payload);
|
||||
|
||||
$this->logModel->update($logId, [
|
||||
'atcl_no' => $payload['articleNumber'] ?? null,
|
||||
'status' => 'SUCCESS',
|
||||
'target_db_id' => $insertId,
|
||||
'error_msg' => null,
|
||||
'retry_cnt' => ($log['retry_cnt'] ?? 0) + 1
|
||||
]);
|
||||
|
||||
$results['success']++;
|
||||
$results['details'][] = [
|
||||
'id' => $logId,
|
||||
'atcl_no' => $log['atcl_no'],
|
||||
'status' => 'success',
|
||||
'message' => "성공 (DB ID: {$insertId})"
|
||||
];
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$this->logModel->update($logId, [
|
||||
'status' => 'FAIL',
|
||||
'error_msg' => $e->getMessage(),
|
||||
'retry_cnt' => ($log['retry_cnt'] ?? 0) + 1
|
||||
]);
|
||||
|
||||
$results['fail']++;
|
||||
$results['details'][] = [
|
||||
'id' => $logId,
|
||||
'atcl_no' => $log['atcl_no'],
|
||||
'status' => 'fail',
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'success' => true,
|
||||
'results' => $results
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 로그 상세 (AJAX)
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$log = $this->logModel->find($id);
|
||||
|
||||
if (!$log) {
|
||||
return $this->response->setJSON([
|
||||
'success' => false,
|
||||
'message' => '로그를 찾을 수 없습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
// raw_payload JSON 파싱
|
||||
$log['parsed_payload'] = json_decode($log['raw_payload'], true);
|
||||
$log['error_type'] = $this->detectErrorType($log['error_msg']);
|
||||
$log['solution'] = $this->getSolution($log['error_type']);
|
||||
$log['can_retry'] = $this->canRetry($log);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'success' => true,
|
||||
'log' => $log
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ class Assign extends BaseController
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
$draw = (int) $this->request->getGet('draw') ?: 1;
|
||||
|
||||
$data = [
|
||||
'bonbu' => $this->request->getGet('bonbu'),
|
||||
@@ -42,12 +43,18 @@ class Assign extends BaseController
|
||||
'srchTxt' => $this->request->getGet('srchTxt'),
|
||||
];
|
||||
|
||||
$totalCount = $this->assignModel->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->assignModel->getUserList($start, $end, $data);
|
||||
|
||||
// 첫 번째 행에서 total_count 추출 (없으면 0)
|
||||
$totalCount = !empty($datas) ? (int)$datas[0]['total_count'] : 0;
|
||||
|
||||
// 각 행에서 total_count 컬럼 제거
|
||||
foreach ($datas as &$row) {
|
||||
unset($row['total_count']);
|
||||
}
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'draw' => $draw,
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
|
||||
163
app/Controllers/V2/BaseV2Controller.php
Normal file
163
app/Controllers/V2/BaseV2Controller.php
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\common\CodeModel;
|
||||
|
||||
/**
|
||||
* BaseV2Controller
|
||||
* V2 모듈 공통 로직: lists / getResultList / excel
|
||||
*
|
||||
* 하위 클래스에서 구현해야 하는 메서드:
|
||||
* - createModel() : 모듈 전용 Model 인스턴스 반환
|
||||
* - getCodeKeys() : lists()에서 로드할 코드 카테고리 배열 반환
|
||||
* - getViewName() : lists()에서 렌더링할 뷰 경로 반환
|
||||
* - getSearchKeys() : getResultList/excel에서 수집할 GET 파라미터 키 배열 반환
|
||||
*/
|
||||
abstract class BaseV2Controller extends BaseController
|
||||
{
|
||||
protected $model;
|
||||
protected $codeModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->codeModel = new CodeModel();
|
||||
$this->model = $this->createModel();
|
||||
}
|
||||
|
||||
abstract protected function createModel();
|
||||
abstract protected function getCodeKeys(): array;
|
||||
abstract protected function getViewName(): string;
|
||||
abstract protected function getSearchKeys(): array;
|
||||
|
||||
public function lists(): string
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists($this->getCodeKeys());
|
||||
$sido = $this->model->getAreaList();
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['codes'] = $codes;
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
|
||||
return view($this->getViewName(), $this->data);
|
||||
}
|
||||
|
||||
public function getResultList()
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
|
||||
$data = $this->buildSearchData();
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
$data = $this->buildSearchData();
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(['data' => $datas]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getSearchKeys()에 정의된 키만 GET에서 수집해서 배열로 반환
|
||||
*/
|
||||
protected function buildSearchData(): array
|
||||
{
|
||||
$data = [];
|
||||
foreach ($this->getSearchKeys() as $key) {
|
||||
$rawValue = $this->request->getGet($key);
|
||||
$data[$key] = $this->normalizeSearchValue($key, $rawValue);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 공통 파라미터 정규화
|
||||
* - null/공백은 빈 문자열로 통일
|
||||
* - 문자열은 trim 처리
|
||||
* - 날짜 키(date 포함)는 형식 검증 실패 시 빈 문자열로 처리
|
||||
*/
|
||||
protected function normalizeSearchValue(string $key, $value)
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return array_map(static function ($item) {
|
||||
if ($item === null) {
|
||||
return '';
|
||||
}
|
||||
if (is_string($item)) {
|
||||
$item = trim($item);
|
||||
return $item === '' ? '' : $item;
|
||||
}
|
||||
return $item;
|
||||
}, $value);
|
||||
}
|
||||
|
||||
if ($value === null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
$value = trim($value);
|
||||
if ($value === '') {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isDateKey($key) && !$this->isValidDateValue((string) $value)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 날짜 성격 파라미터 판별
|
||||
* 예: receipt_sdate, receipt_edate, complete_sdate, stat_complete_date 등
|
||||
*/
|
||||
protected function isDateKey(string $key): bool
|
||||
{
|
||||
return strpos($key, 'date') !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 허용 날짜 형식 검증
|
||||
* - YYYY-MM-DD
|
||||
* - YYYYMMDD
|
||||
*/
|
||||
protected function isValidDateValue(string $value): bool
|
||||
{
|
||||
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $value) === 1) {
|
||||
[$year, $month, $day] = explode('-', $value);
|
||||
return checkdate((int) $month, (int) $day, (int) $year);
|
||||
}
|
||||
|
||||
if (preg_match('/^\d{8}$/', $value) === 1) {
|
||||
$year = substr($value, 0, 4);
|
||||
$month = substr($value, 4, 2);
|
||||
$day = substr($value, 6, 2);
|
||||
return checkdate((int) $month, (int) $day, (int) $year);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,133 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\results\M415Model;
|
||||
use App\Models\v2\M703Model;
|
||||
use App\Models\v2\M710Model;
|
||||
use App\Models\v2\M703Model;
|
||||
|
||||
class M703 extends BaseController
|
||||
class M703 extends BaseV2Controller
|
||||
{
|
||||
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M703Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M703Model();
|
||||
}
|
||||
|
||||
public function lists()
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['CP_ID', 'STEP_VERIFICATION', 'RECEIPT_STATUS3', 'FAX_CORP']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
|
||||
return view("pages/v2/m703/lists", $this->data);
|
||||
return ['CP_ID', 'STEP_VERIFICATION', 'RECEIPT_STATUS3', 'FAX_CORP'];
|
||||
}
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m703/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력
|
||||
'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'chk_rec' => $this->request->getGet('chk_rec'), // 동의서 유무
|
||||
'fax_corp' => $this->request->getGet('fax_corp'), // 팩스업체
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'chk_atcl_no',
|
||||
'caller_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'vrfcreq_way',
|
||||
'vrfc_type_sub',
|
||||
'target_yn',
|
||||
'rcpt_cpid',
|
||||
'chk_rec',
|
||||
'fax_corp',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 엑셀 다운로드
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력
|
||||
'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'chk_rec' => $this->request->getGet('chk_rec'), // 동의서 유무
|
||||
'fax_corp' => $this->request->getGet('fax_corp'), // 팩스업체
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 상세화면
|
||||
public function detail($id)
|
||||
{
|
||||
$id = (int) $id;
|
||||
$naver = new NaverApiClient();
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
@@ -161,11 +93,11 @@ class M703 extends BaseController
|
||||
$apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
|
||||
$villa_rlet_type_cd = ['A05', 'A06'];
|
||||
if (in_array($article['rlet_type_cd'], $apt_rlet_type_cd)) { // apt 단지
|
||||
// $detail_hscp = $this->call_kiso_api->aptDetail($article['hscp_no']);
|
||||
$detail_hscp = $naver->aptDetail($article['hscp_no']);
|
||||
}
|
||||
|
||||
if (in_array($article['rlet_type_cd'], $villa_rlet_type_cd)) { // villa 단지
|
||||
// $detail_hscp = $this->call_kiso_api->villaDetail($article['hscp_no']);
|
||||
$detail_hscp = $naver->villaDetail($article['hscp_no']);
|
||||
}
|
||||
|
||||
$this->data['hscp_info'] = $hscp_info;
|
||||
@@ -400,6 +332,8 @@ class M703 extends BaseController
|
||||
// 결과저장
|
||||
public function saveResult()
|
||||
{
|
||||
$naver = new NaverApiClient();
|
||||
|
||||
try {
|
||||
|
||||
$fax_sq = $this->request->getPost('fax_sq');
|
||||
@@ -461,8 +395,7 @@ class M703 extends BaseController
|
||||
//2.아무렇지않게 행동한다
|
||||
$send_result['result'] = 'success';
|
||||
} else {
|
||||
// $this->load->library('call_kiso_api');
|
||||
// $send_result = $this->call_kiso_api->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
|
||||
$send_result = $naver->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
|
||||
}
|
||||
|
||||
if ($send_result['result'] == 'success') {
|
||||
|
||||
@@ -1,129 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\MyUpload;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\results\M415Model;
|
||||
use App\Models\v2\M710Model;
|
||||
use Exception;
|
||||
use App\Models\v2\M704Model;
|
||||
|
||||
class M704 extends BaseController
|
||||
class M704 extends BaseV2Controller
|
||||
{
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M704Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M704Model();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'TEL_FAIL_CAUSE', 'ARTICLE_TYPE']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
return view("pages/v2/m704/lists", $this->data);
|
||||
return ['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'TEL_FAIL_CAUSE', 'ARTICLE_TYPE'];
|
||||
}
|
||||
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m704/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'stat_complete_date' => $this->request->getGet('stat_complete_date'), // 진행상태별시간유형
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 진행상태별시간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 진행상태별시간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
|
||||
'corp_own' => $this->request->getGet('corp_own'), // 법인
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'stat_complete_date',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'vrfcreq_way',
|
||||
'vrfc_type_sub',
|
||||
'rcpt_cpid',
|
||||
'rlet_type_cd',
|
||||
'reference_file_url_yn',
|
||||
'corp_own',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
// 엑셀 다운로드
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'stat_complete_date' => $this->request->getGet('stat_complete_date'), // 진행상태별시간유형
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 진행상태별시간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 진행상태별시간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
|
||||
'corp_own' => $this->request->getGet('corp_own'), // 법인
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 상세화면
|
||||
public function detail($id)
|
||||
{
|
||||
$id = (int) $id;
|
||||
$naver = new NaverApiClient();
|
||||
|
||||
if ($id <= 0) {
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
@@ -137,6 +75,33 @@ class M704 extends BaseController
|
||||
$phone_list = $this->model->getPhoneNumber(); // 주택임대사업자번호 리스트
|
||||
$tel = $this->model->getRecordInfo($id, '3'); //녹취파일
|
||||
|
||||
$complexList = [];
|
||||
$ptpList = [];
|
||||
|
||||
// 아파트단지목록
|
||||
$complexList = $naver->complexList($data['address_code']);
|
||||
|
||||
// 평형목록
|
||||
$ptpList = $naver->ptpList($data['hscp_no']);
|
||||
|
||||
$hscp_info = [];
|
||||
if (!empty($data['hscp_no'])) {
|
||||
$apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
|
||||
$villa_rlet_type_cd = ['A05', 'A06'];
|
||||
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $apt_rlet_type_cd)) { // apt 단지
|
||||
$detail_hscp = $naver->aptDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $villa_rlet_type_cd)) { // villa 단지
|
||||
$detail_hscp = $naver->villaDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
$hscp_info = $detail_hscp['result'];
|
||||
|
||||
}
|
||||
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
$this->data['data'] = $data;
|
||||
@@ -145,10 +110,99 @@ class M704 extends BaseController
|
||||
$this->data['regist2'] = $regist2;
|
||||
$this->data['phone_list'] = $phone_list;
|
||||
$this->data['tel'] = $tel;
|
||||
$this->data['complexList'] = $complexList;
|
||||
$this->data['ptpList'] = $ptpList;
|
||||
$this->data['detail_hscp'] = $hscp_info;
|
||||
|
||||
return view("pages/v2/m704/detail", $this->data);
|
||||
}
|
||||
|
||||
// 상세정보 수정
|
||||
public function modifyInfo()
|
||||
{
|
||||
$naver = new NaverApiClient();
|
||||
|
||||
try {
|
||||
|
||||
$atcl_vr_sq = $this->request->post('rcpt_key', TRUE); //순번
|
||||
$atcl_hscp_nm = $this->request->getPost('atcl_hscp_nm'); //단지명
|
||||
$atcl_ptp_nm = $this->request->getPost('atcl_ptp_nm'); //평형명
|
||||
$atcl_vrfc_type = $this->request->getPost('atcl_vrtc_way'); //검증구분
|
||||
$trade_type = $this->request->getPost('trade_type_cd'); //거래구분
|
||||
$atcl_addr1 = $this->request->getPost('atcl_addr1'); //상세주소1 폐기예정
|
||||
$atcl_addr1a = $this->request->getPost('atcl_addr1a'); // 리 주소
|
||||
$atcl_addr1b = $this->request->getPost('atcl_addr1b'); // 공동 : 동 주소, 비공동 : 지번주소
|
||||
$atcl_addr2 = $this->request->getPost('atcl_addr2'); //상세주소2
|
||||
$atcl_hscp_no = $this->request->getPost('atcl_hscp_no'); //단지번호
|
||||
$atcl_ptp_no = $this->request->getPost('atcl_ptp_no'); //단지명
|
||||
$atcl_amt1 = $this->request->getPost('atcl_amt1');
|
||||
$atcl_amt2 = $this->request->getPost('atcl_amt2');
|
||||
$atcl_amt3 = $this->request->getPost('atcl_amt3');
|
||||
$atcl_amt4 = $this->request->getPost('atcl_amt4'); // 분양권매매 가격 2
|
||||
$isale_amt = $this->request->getPost('isale_amt'); // 분양가
|
||||
$prem_amt = $this->request->getPost('prem_amt'); // 프리미엄가
|
||||
$atcl_floor = $this->request->getPost('atcl_floor'); // 층
|
||||
$atcl_floor2 = $this->request->getPost('atcl_floor2'); // 총층
|
||||
|
||||
$result = $this->model->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, $atcl_amt4, $isale_amt, $prem_amt);
|
||||
$resVrfc = $this->model->saveModifyVrfc($atcl_vr_sq, $atcl_vrfc_type);
|
||||
|
||||
if ($result['error_number'] != 0) {
|
||||
throw new \Exception($result['error_message']);
|
||||
} else {
|
||||
//API 호출
|
||||
$resultData = $this->model->getDetail($atcl_vr_sq);
|
||||
|
||||
$modifyInfo = $naver->modifyInfo(
|
||||
$resultData['data']['atcl_no'],
|
||||
$resultData['data']['hscp_no'],
|
||||
$resultData['data']['ptp_no'],
|
||||
$resultData['data']['bild_nm'],
|
||||
$resultData['data']['rm_no'],
|
||||
$resultData['data']['trade_type_cd'],
|
||||
$resultData['data']['deal_amt'],
|
||||
$resultData['data']['wrrnt_amt'],
|
||||
$resultData['data']['lease_amt'],
|
||||
$resultData['data']['isale_amt'],
|
||||
$resultData['data']['prem_amt'],
|
||||
$resultData['data']['floor'],
|
||||
$resultData['data']['floor2'],
|
||||
$resultData['data']['charger'],
|
||||
$resultData['data']['address_code'],
|
||||
$resultData['data']['address2'],
|
||||
$resultData['data']['address2a'],
|
||||
$resultData['data']['address2b'],
|
||||
$resultData['data']['address3'],
|
||||
$resultData['data']['sply_spc'],
|
||||
$resultData['data']['excls_spc'],
|
||||
$resultData['data']['tot_spc'],
|
||||
$resultData['data']['grnd_spc'],
|
||||
$resultData['data']['bldg_spc']
|
||||
);
|
||||
|
||||
if ($modifyInfo['result'] != 'success') { //결과값 확인
|
||||
$return = $modifyInfo['error'];
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $modifyInfo['error']['code'], $modifyInfo['error']['message'], $err_time, $resultData['data']['atcl_no']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 파일업로드
|
||||
public function uploadFile()
|
||||
{
|
||||
@@ -248,6 +302,470 @@ class M704 extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 전화실패
|
||||
public function contactFail()
|
||||
{
|
||||
try {
|
||||
|
||||
$vr_sq = $this->request->getPost('vr_sq');
|
||||
|
||||
// UPDATE v2_vrfc_req
|
||||
$this->model->saveContactFail($vr_sq);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 전화확인정보 저장
|
||||
public function saveTel()
|
||||
{
|
||||
/*
|
||||
1.0.1 POST 데이터 받기.
|
||||
1.1.1 1차 검증인지 2차검증인지 확인.
|
||||
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
|
||||
1.2.1 v2_confirms에 데이터가 있는지 확인.
|
||||
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
|
||||
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
|
||||
1.4.2 상태변경 하기 : 전화(서류)확인중 상태로 변경. (수정변경이력 저장)
|
||||
1.5.1 녹취파일 서버에 UPLOAD (수정변경이력 저장)
|
||||
1.6.1 기존파일 탐색.
|
||||
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
|
||||
1.8.1 기존파일 없음 : v2_files INSERT.
|
||||
1.9.1 개인정보 제공동의, 매물주소, 가격거래구분, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
|
||||
1.10.1 API 전송.
|
||||
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 전화(서류)확인완료 상태. (수정변경이력 저장)
|
||||
*/
|
||||
|
||||
$naver = new NaverApiClient();
|
||||
$model710 = new M710Model();
|
||||
$model415 = new M415Model();
|
||||
$v2DailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
$toDay = date('Y-m-d H:i:s');
|
||||
$atcl_vrtc_way = $this->request->getPost('atcl_vrtc_way');
|
||||
$atcl_vr_sq = $this->request->getPost('rcpt_key');
|
||||
$tel_agree = $this->request->getPost('tel_agree');
|
||||
|
||||
// 개인정보 제공 동의가 승인일 경우 필수 필드 검증
|
||||
if ($tel_agree == '10000') {
|
||||
$validation = \Config\Services::validation();
|
||||
|
||||
$validation->setRules([
|
||||
'tel_conf_yn_2' => [
|
||||
'label' => '매물주소',
|
||||
'rules' => 'required',
|
||||
'errors' => ['required' => '{field} 정보확인 결과를 선택해주세요.']
|
||||
],
|
||||
'tel_conf_yn_3' => [
|
||||
'label' => '가격 거래구분',
|
||||
'rules' => 'required',
|
||||
'errors' => ['required' => '{field} 정보확인 결과를 선택해주세요.']
|
||||
],
|
||||
'tel_conf_yn_4' => [
|
||||
'label' => '의뢰인정보',
|
||||
'rules' => 'required',
|
||||
'errors' => ['required' => '{field} 정보확인 결과를 선택해주세요.']
|
||||
],
|
||||
]);
|
||||
|
||||
if (!$validation->withRequest($this->request)->run()) {
|
||||
$errors = $validation->getErrors();
|
||||
throw new \Exception(implode(', ', $errors));
|
||||
}
|
||||
}
|
||||
|
||||
// POST 데이터 받기
|
||||
$tel_suc = $this->request->getPost('tel_suc');
|
||||
$tel_conf_yn_2 = $this->request->getPost('tel_conf_yn_2');
|
||||
$tel_conf_yn_3 = $this->request->getPost('tel_conf_yn_3');
|
||||
$tel_conf_yn_4 = $this->request->getPost('tel_conf_yn_4');
|
||||
$tel_conf_yn_5 = $this->request->getPost('tel_conf_yn_5');
|
||||
$tel_conf_yn_info_2 = $this->request->getPost('tel_conf_yn_info_2');
|
||||
$tel_conf_yn_info_3 = $this->request->getPost('tel_conf_yn_info_3');
|
||||
$tel_conf_yn_info_4 = $this->request->getPost('tel_conf_yn_info_4');
|
||||
$address_code = $this->request->getPost('address_code');
|
||||
$reg_chk_val = $this->request->getPost('reg_chk_val');
|
||||
$tel_file_yn = $this->request->getPost('tel_file_yn');
|
||||
$memo = $this->request->getPost('memo_tel');
|
||||
$tel_fail_cause = $this->request->getPost('tel_fail_cause');
|
||||
|
||||
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
|
||||
$resStat = $this->model->chkStat($atcl_vr_sq);
|
||||
$v2_vrfc_req = $v2DailyModel->get_v2_vrfc_req($atcl_vr_sq);
|
||||
$reg_try_cnt = $this->model->getRegTry($atcl_vr_sq);
|
||||
$rlet_type_cd = $model415->get_rlet_type_cd($atcl_vr_sq);
|
||||
|
||||
$try_cnt = '0';
|
||||
if ($resStat['stat_cd'] >= '40' || $resStat['stat_cd'] == '19') {
|
||||
throw new \Exception('이미 저장된 데이터입니다.');
|
||||
} else {
|
||||
$this->model->InsCharger($atcl_vr_sq); //담당자가 없을 경우 강제로 session 정보로 넣어준다
|
||||
|
||||
$resultCnt = $this->model->chkTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
|
||||
$chkHistoryStat = $this->model->chkHistoryStat($atcl_vr_sq); // history에 등기부등본 확인중인적이 있는지 확인
|
||||
if ($resultCnt['try_cnt'] == 0) { //1차 검증일 때
|
||||
$try_cnt = '1';
|
||||
} else if ($resultCnt['try_cnt'] == 1) { //2차 검증일 때
|
||||
$try_cnt = '2';
|
||||
} else if ($resultCnt['try_cnt'] == 2) { //2차 검증이상 일 때
|
||||
$try_cnt = '2';
|
||||
} else {
|
||||
$try_cnt = intval($try_cnt) + 1;
|
||||
}
|
||||
|
||||
$result = $this->model->chkConfirm($atcl_vr_sq, '');
|
||||
|
||||
if ($result == 0) {
|
||||
if ($tel_conf_yn_2 == '10000' && $tel_conf_yn_3 == '10000' && $tel_conf_yn_4 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->m704_model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
|
||||
}
|
||||
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
|
||||
} else {
|
||||
if ($tel_conf_yn_2 == '10000' && $tel_conf_yn_3 == '10000' && $tel_conf_yn_4 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 10, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
}
|
||||
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
|
||||
}
|
||||
|
||||
//v2_vrfc_req INSERT//상태변경 TABLE INSERT : 전화(서류)확인중 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '30', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '30');
|
||||
|
||||
// 불일치건이면서 등기부등본 불일치 1회 이상일 경우 초기상태를 등기부등본 상태로 변경
|
||||
if ($chk_type == '0' && $reg_try_cnt['reg_try_cnt'] == '1') {
|
||||
$this->model->chgStat($atcl_vr_sq, '40', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '40');
|
||||
}
|
||||
|
||||
|
||||
if ($chk_type == '0' && ($reg_try_cnt['reg_try_cnt'] == '1' || $reg_try_cnt['reg_try_cnt'] == '2')) { // $reg_try_cnt['reg_try_cnt'] 는 등기부등본 실패횟수
|
||||
log_message('debug', 'm704 insertChkList : ' . $atcl_vr_sq);
|
||||
//v2_check_list 매물정보확인 INSERT : 전화매물확인 페이지에서 통신하는 등기부등본 확인 API이므로 값을 강제로 넣어줌.
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '21', '20000', '불일치');
|
||||
|
||||
//v2_check_list 의뢰인정보 INSERT : 전화매물확인 페이지에서 통신하는 등기부등본 확인 API이므로 값을 강제로 넣어줌.
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '22', '20000', '불일치');
|
||||
|
||||
} else {
|
||||
//v2_check_list 확인여부 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T11', $tel_agree, '');
|
||||
|
||||
if ($tel_agree == '10000') {
|
||||
//v2_check_list 매물주소 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T12', $tel_conf_yn_2, $tel_conf_yn_info_2);
|
||||
|
||||
//v2_check_list 가격거래구분 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T13', $tel_conf_yn_3, $tel_conf_yn_info_3);
|
||||
|
||||
//v2_check_list 의뢰인정보 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T14', $tel_conf_yn_4, $tel_conf_yn_info_4);
|
||||
} else {
|
||||
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T12');
|
||||
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T13');
|
||||
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T14');
|
||||
}
|
||||
if (!empty($tel_conf_yn_5)) {
|
||||
// $this->m704_model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T15', $tel_conf_yn_5, $tel_conf_yn_5);
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'T15', $tel_conf_yn_5, '');
|
||||
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T11');
|
||||
} else {
|
||||
$this->model->deleteChkList($atcl_vr_sq, $atcl_vrtc_way, 'T15');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//memo 저장
|
||||
if (!empty($memo)) {
|
||||
$this->model->saveMemo([$memo, $atcl_vr_sq]);
|
||||
}
|
||||
//전화실패 사유 저장
|
||||
if (!empty($tel_fail_cause)) {
|
||||
$this->model->up_tel_fail_cause($atcl_vr_sq, $tel_fail_cause);
|
||||
}
|
||||
|
||||
//확인정보 수정 로그 찍기
|
||||
log_message('debug', 'checking >> 검증횟수(등기부등본) : ' . $reg_try_cnt['reg_try_cnt'] . '/' . ' >> chk_type : ' . $chk_type . ' 매물번호 : ' . $atcl_vr_sq);
|
||||
|
||||
// 전화서류가 불일치이고 등기부등본 실패횟수가 1회일 때 바로 등기부등본 불일치 >> 검증실패 처리
|
||||
// [s] 2015.09.08 등기부등본 검증 API 추가
|
||||
if ($chk_type == '0' && ($reg_try_cnt['reg_try_cnt'] == '1' || $reg_try_cnt['reg_try_cnt'] == '2')) {
|
||||
log_message('debug', '704 page (등기부등본 불일치) >> before call api / 매물번호 : ' . $atcl_vr_sq);
|
||||
|
||||
//☆
|
||||
$sendData = $this->model->getDatacertAPI($atcl_vr_sq, 'R');
|
||||
$t_yn = $model710->get_send_yn('T');
|
||||
|
||||
if ($t_yn['stop_yn'] == 'N') { //전송금지
|
||||
//1.해당매물정보를v2_stop_api_save_info에다 넣음
|
||||
$model710->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'T2', '');
|
||||
//2.아무렇지않게 행동한다
|
||||
$send_result['result'] = 'success';
|
||||
} else {
|
||||
//API 호출
|
||||
$send_result = $naver->certification($sendData['atclNo'], $try_cnt, $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['date'], $sendData['modifyInfo'], $sendData['ownerVerifiable']);
|
||||
}
|
||||
|
||||
if ($send_result['result'] == 'success') {
|
||||
log_message('debug', '704 page (등기부등본 불일치) >> success call api / 매물번호 : ' . $atcl_vr_sq);
|
||||
|
||||
// 전화서류를 처리한 모든건을 카운트 하는
|
||||
$result_query1 = $this->model->chgStat($atcl_vr_sq, '38', $toDay);
|
||||
|
||||
//상태변경 TABLE INSERT : 등기부등본 불일치 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
$this->model->chgRegTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
//★검증실패
|
||||
if ($atcl_vrtc_way == 'M' || $atcl_vrtc_way == 'O') { //모바일은 등기가 첨 시작이니까 insert해줘야함
|
||||
if (!($atcl_vrtc_way == 'M' && in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03')))) {//만약 분양권들이면 넘어가고 아니면 체크
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_way, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_way, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
|
||||
}
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0302', '1', 'add'); // 최종실패로 저장
|
||||
} else {
|
||||
if (isset($send_result['error'])) {
|
||||
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
|
||||
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
|
||||
throw new \Exception($error_message);
|
||||
} else {
|
||||
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sendData = $this->model->getDataConfirmAPI($atcl_vr_sq);
|
||||
|
||||
$t_yn = $model710->get_send_yn('T');
|
||||
|
||||
if ($t_yn['stop_yn'] == 'N') { //전송금지
|
||||
//1.해당매물정보를v2_stop_api_save_info에다 넣음
|
||||
$model710->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'T1', '');
|
||||
//2.아무렇지않게 행동한다
|
||||
$send_result['result'] = 'success';
|
||||
} else {
|
||||
//API 호출
|
||||
$send_result = $naver->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
|
||||
}
|
||||
|
||||
if ($send_result['result'] == 'success' || $send_result['error']['code'] == 'VC013') {
|
||||
// 검증단계가 상이하더라도 상태값이 변경될 수 있도록 함.
|
||||
if ($tel_agree == '10000' && $chk_type == '1') {
|
||||
//상태변경 TABLE INSERT : 전화(서류)확인 완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '35', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '35'); //v2_vrfc_req INSERT
|
||||
|
||||
// 전화서류를 처리한 모든건을 카운트
|
||||
$this->model->chgStat($atcl_vr_sq, '38', $toDay);
|
||||
|
||||
if ($reg_chk_val == '1') {
|
||||
|
||||
//등기부등본 확인 대상은 전화(서류)확인 완료 후 -> 등기부등본 확인중 상태로 변경.
|
||||
$result_query8 = $this->model->chgStat($atcl_vr_sq, '40', $toDay);
|
||||
$chgVrfc40 = $this->model->chgStatVrfc($atcl_vr_sq, '40'); //v2_vrfc_req INSERT
|
||||
|
||||
//★등기 로 넘어갈때
|
||||
//0.통화실패 여부를 확인한다
|
||||
$cnt = $model415->getCallfailForHistory($atcl_vr_sq);
|
||||
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
|
||||
//1.서류전화 들어온시간
|
||||
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
|
||||
//2.서류/전화 확인일자
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$sf = 'T';
|
||||
$model415->insert_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $sf);
|
||||
}
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0201', '1', 'add'); // 일치로 저장
|
||||
} else {
|
||||
//등기부등본 확인 대상이 아닌 경우 전화(서류)확인 완료 후 -> 검증 완료 상태로 변경.
|
||||
$result_query8 = $this->model->chgStat($atcl_vr_sq, '60', $toDay);
|
||||
$chgVrfc40 = $this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
|
||||
|
||||
//★검증완료일때
|
||||
//0.통화실패 여부를 확인한다
|
||||
$cnt = $model415->getCallfailForHistory($atcl_vr_sq);
|
||||
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
|
||||
//1.서류전화 들어온시간
|
||||
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
|
||||
//2.서류/전화 확인일자
|
||||
$tel_doc_conf_dt = $model415->getConfTimeForHistory($atcl_vr_sq);
|
||||
//3.검증완료시간
|
||||
$finishTime = $model415->get_60_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0206', '1', 'add'); // 전화확인완료 등기부등본확인 안함 저장
|
||||
}
|
||||
} else {
|
||||
if ($try_cnt == '1') {
|
||||
// 전화서류를 처리한 모든건을 카운트
|
||||
$result_query19 = $this->model->chgStat($atcl_vr_sq, '38', $toDay);
|
||||
|
||||
//상태변경 TABLE INSERT : 전화(서류)확인 불일치 상태로 변경
|
||||
$result_query7 = $this->model->chgStat($atcl_vr_sq, '39', $toDay);
|
||||
$chgVrfc35 = $this->model->chgStatVrfc($atcl_vr_sq, '39'); //v2_vrfc_req INSERT
|
||||
|
||||
//★불일치
|
||||
//0.통화실패 여부를 확인한다
|
||||
$cnt = $model415->getCallfailForHistory($atcl_vr_sq);
|
||||
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
|
||||
//1.서류전화 들어온시간
|
||||
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
|
||||
//2.서류/전화 불일치 시간
|
||||
$tel_doc_conf_dt = $model415->getFaxFailTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$sf = 'F';
|
||||
$model415->insert_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $sf);
|
||||
}
|
||||
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$res_try = $this->model->chgTryCnt($atcl_vr_sq, '1');
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0301', '1', 'add'); // 1차실패로 저장
|
||||
} else if ($try_cnt == '2') { //상태변경 TABLE INSERT : 전화(서류)확인 불일치 상태로 변경
|
||||
// 전화서류를 처리한 모든건을 카운트
|
||||
$this->model->chgStat($atcl_vr_sq, '38', $toDay);
|
||||
|
||||
$this->model->chgStat($atcl_vr_sq, '39', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '39'); //v2_vrfc_req INSERT
|
||||
|
||||
//v2_vrfc_req try_cnt 값을 2로 update
|
||||
$this->model->chgTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
|
||||
//★ 검증실패
|
||||
//0.통화실패 여부를 확인한다
|
||||
$cnt = $this->model->getCallfailForHistory($atcl_vr_sq);
|
||||
if (empty($cnt)) { //통화실패가 없어야 통계를 구한다
|
||||
//1.서류전화 들어온시간
|
||||
$insert_tm = $model415->getSaveTimeForHistory($atcl_vr_sq);
|
||||
//2.서류/전화 불일치 시간
|
||||
$tel_doc_conf_dt = $model415->getFaxFailTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $v2_vrfc_req['vrfc_type'], $insert_tm['insert_tm'], $tel_doc_conf_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0302', '1', 'add'); // 최종실패로 저장
|
||||
}
|
||||
|
||||
if (in_array($tel_agree, array('20001', '20002'))) {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0203', '1', 'add'); // 거부로 저장
|
||||
} elseif (in_array($tel_agree, array('20003', '20004', '20005'))) {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0204', '1', 'add'); // 무응답 외
|
||||
} else {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'T0202', '1', 'add'); // 불일치
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (isset($send_result['error'])) {
|
||||
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
|
||||
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
|
||||
throw new \Exception($error_message);
|
||||
} else {
|
||||
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 다음 매물정보 조회
|
||||
public function getNextTelInfo()
|
||||
|
||||
@@ -1,83 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\Common;
|
||||
use App\Libraries\MyUpload;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\results\M415Model;
|
||||
use App\Models\v2\M710Model;
|
||||
use App\Models\v2\M705Model;
|
||||
|
||||
class M705 extends BaseController
|
||||
class M705 extends BaseV2Controller
|
||||
{
|
||||
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M705Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M705Model();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'TEL_FAIL_CAUSE', 'ARTICLE_TYPE']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
return view("pages/v2/m705/lists", $this->data);
|
||||
return ['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'TEL_FAIL_CAUSE', 'ARTICLE_TYPE'];
|
||||
}
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m705/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'chk_spc_yn' => $this->request->getGet('chk_spc_yn'), // 면적여부
|
||||
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
|
||||
'corp_own' => $this->request->getGet('corp_own'), // 법인
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'vrfcreq_way',
|
||||
'vrfc_type_sub',
|
||||
'rcpt_cpid',
|
||||
'rlet_type_cd',
|
||||
'chk_spc_yn',
|
||||
'reference_file_url_yn',
|
||||
'corp_own',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
// 배정확인
|
||||
public function getNotAssign()
|
||||
{
|
||||
try {
|
||||
@@ -150,9 +127,10 @@ class M705 extends BaseController
|
||||
// 상세화면
|
||||
public function detail($id)
|
||||
{
|
||||
$id = (int) $id;
|
||||
$naver = new NaverApiClient();
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
@@ -165,6 +143,24 @@ class M705 extends BaseController
|
||||
$display = $this->model->getDisplay('M705_detail');
|
||||
$reference = $this->model->getAllRecordInfo($id, '7'); //참고용파일 (2017.09.26 추가)
|
||||
|
||||
$hscp_info = [];
|
||||
if (!empty($data['hscp_no'])) {
|
||||
$apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
|
||||
$villa_rlet_type_cd = ['A05', 'A06'];
|
||||
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $apt_rlet_type_cd)) { // apt 단지
|
||||
$detail_hscp = $naver->aptDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $villa_rlet_type_cd)) { // villa 단지
|
||||
$detail_hscp = $naver->villaDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
$hscp_info = $detail_hscp['result'];
|
||||
|
||||
}
|
||||
|
||||
$this->data['codes'] = $codes;
|
||||
$this->data['data'] = $data;
|
||||
$this->data['record'] = $record;
|
||||
@@ -172,6 +168,7 @@ class M705 extends BaseController
|
||||
$this->data['memo'] = $memo;
|
||||
$this->data['display'] = $display;
|
||||
$this->data['reference'] = $reference;
|
||||
$this->data['detail_hscp'] = $hscp_info;
|
||||
|
||||
return view("pages/v2/m705/detail", $this->data);
|
||||
}
|
||||
@@ -258,23 +255,23 @@ class M705 extends BaseController
|
||||
$usr_id = session('usr_id');
|
||||
$vr_sq = $this->request->getPost('vr_sq');
|
||||
|
||||
$file = $this->request->getFile('file');
|
||||
|
||||
if ($file && $file->isValid() && !$file->hasMoved()) {
|
||||
|
||||
$files = $this->request->getFiles();
|
||||
|
||||
$uploadPath = "/upload/v2_file/" . $vr_sq . "/";
|
||||
|
||||
$file = $files['files'];
|
||||
$arrUploadfile = [];
|
||||
if ($file->isValid() && !$file->hasMoved()) {
|
||||
$uploadData = $lib->do_upload2($file, $uploadPath);
|
||||
|
||||
if ($uploadData !== false) {
|
||||
$arrUploadfile[] = $uploadData;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($arrUploadfile)) {
|
||||
foreach ($arrUploadfile as $key => $uploadFile) {
|
||||
|
||||
$data = [
|
||||
'vr_sq' => $vr_sq,
|
||||
// 'file_sq' => $this->request->getPost('file_sq'),
|
||||
@@ -288,20 +285,22 @@ class M705 extends BaseController
|
||||
'img_width' => null,
|
||||
'usr_id' => $usr_id,
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($data)) {
|
||||
// print_r($data);
|
||||
// exit;
|
||||
|
||||
// if (!empty($data)) {
|
||||
|
||||
// 파일업로드 정보 저장
|
||||
$this->model->saveFileInfo($data);
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
@@ -317,6 +316,384 @@ class M705 extends BaseController
|
||||
|
||||
}
|
||||
|
||||
// 매물정보 저장
|
||||
public function saveRegi()
|
||||
{
|
||||
/*
|
||||
1.0.1 POST 데이터 받기.
|
||||
1.1.1 1차 검증인지 2차검증인지 확인.
|
||||
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
|
||||
1.2.1 v2_confirms에 데이터가 있는지 확인.
|
||||
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
|
||||
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
|
||||
1.4.2 상태변경 하기 : 등기부등본 확인중 상태로 변경. (수정변경이력 저장)
|
||||
1.5.1 이미지파일 서버에 UPLOAD (수정변경이력 저장)
|
||||
1.6.1 기존파일 탐색.
|
||||
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
|
||||
1.8.1 기존파일 없음 : v2_files INSERT.
|
||||
1.9.1 매물주소, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
|
||||
1.10.1 API 전송.
|
||||
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 등기부등본 확인완료 상태. (수정변경이력 저장)
|
||||
*/
|
||||
|
||||
$naver = new NaverApiClient();
|
||||
$model710 = new M710Model();
|
||||
$model415 = new M415Model();
|
||||
$v2DailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
$toDay = date('Y-m-d H:i:s');
|
||||
$atcl_vrtc_way = 'R'; //검증구분
|
||||
$atcl_vr_sq = $this->request->getPost('rcpt_key');
|
||||
// $atcl_no = $this->request->getPost('atcl_no');
|
||||
$reg_conf_yn_1 = $this->request->getPost('reg_conf_yn_1'); //확인내용
|
||||
$reg_conf_yn_2 = $this->request->getPost('reg_conf_yn_2'); //매물주소
|
||||
$reg_conf_yn_3 = $this->request->getPost('reg_conf_yn_3'); //의뢰인정보
|
||||
$reg_conf_yn_info_2 = $this->request->getPost('reg_conf_yn_info_2'); //매물주소
|
||||
$reg_conf_yn_info_3 = $this->request->getPost('reg_conf_yn_info_3'); //의뢰인정보
|
||||
$memo = $this->request->getPost('memo'); //메모
|
||||
$owner_verifiable = $this->request->getPost('owner_verifiable'); //실소유주 확인여부
|
||||
$noimg_chk_chk = $this->request->getPost('noimg_chk_chk'); // 등기부등본이미지 파일없음.
|
||||
$img_chk_chk = $this->request->getPost('img_chk_chk'); // 등기소, 리얼탑 열람, 리얼탑 기열람, 열람
|
||||
$atcl_vrtc_type = $this->request->getPost('atcl_vrtc_type'); // 검증구분
|
||||
$vrfc_type_sub = $this->request->getPost('vrfc_type_sub'); // 하위검증구분
|
||||
$arr_uncnfrm_status = $this->request->getPost('arr_uncnfrm_status'); // 등기부등본 미확인여부 상세
|
||||
$try_cnt = '0';
|
||||
|
||||
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
|
||||
$resStat = $this->model->chkStat($atcl_vr_sq);
|
||||
$v2_vrfc_req = $v2DailyModel->get_v2_vrfc_req($atcl_vr_sq);
|
||||
$rlet_type_cd = $model415->get_rlet_type_cd($atcl_vr_sq);
|
||||
|
||||
if ($resStat['stat_cd'] >= '60' || $resStat['stat_cd'] == '19') {
|
||||
throw new \Exception('이미 저장된 데이터입니다.');
|
||||
} else {
|
||||
|
||||
$resultCnt = $this->model->chkRegiTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
|
||||
if ($resultCnt['reg_try_cnt'] == 0) { // 1차 검증일 때
|
||||
log_message('debug', '705 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 0 ');
|
||||
$try_cnt = '1';
|
||||
} else if ($resultCnt['reg_try_cnt'] == 1) { // 2차 검증일 때
|
||||
log_message('debug', '705 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 1 ');
|
||||
$try_cnt = '2';
|
||||
} else {
|
||||
log_message('debug', '705 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 예외처리 ');
|
||||
$try_cnt = '2';
|
||||
//$try_cnt = intval($try_cnt) + 1;
|
||||
}
|
||||
|
||||
$result = $this->model->chkConfirm($atcl_vr_sq, $atcl_vrtc_way);
|
||||
if ($result == 0) { //v2_confirm 존재하지 않는다면
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 1, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
// 수정한 시간이 현재시간10분전 보다 클 경우 수정불가능
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
|
||||
} else {
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 1, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
}
|
||||
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
|
||||
}
|
||||
|
||||
|
||||
$this->model->InsResChar($atcl_vr_sq); //담당자 업데이트
|
||||
|
||||
// 모바일v1,v2고 등기부등본 미확인여부 상세 저장
|
||||
if ($vrfc_type_sub == 'M1' || $vrfc_type_sub == 'O1') {
|
||||
$this->model->add_cert_uncnfrm_status($atcl_vr_sq, $arr_uncnfrm_status);
|
||||
if (strpos($arr_uncnfrm_status, '20020') !== false) { //등기부등본 미확인여부 상세에 20020(파일 오첨부)있고
|
||||
if ($vrfc_type_sub == 'M1') { // 모바일v1일땐 코드 20020,코멘트x
|
||||
$reg_conf_yn_2 = '20020';
|
||||
$reg_conf_yn_info_2 = '';
|
||||
} else { // 모바일v2일땐 일반 불일치코드,코멘트=파일 오첨부
|
||||
$reg_conf_yn_info_2 = '파일 오첨부';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//v2_check_list 확인여부 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '21', $reg_conf_yn_2, $reg_conf_yn_info_2);
|
||||
|
||||
//v2_check_list 매물주소 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '22', $reg_conf_yn_3, $reg_conf_yn_info_3);
|
||||
|
||||
//memo 저장
|
||||
$this->model->saveMemo([$memo, $atcl_vr_sq]);
|
||||
|
||||
//실소유주 확인 저장
|
||||
$this->model->update_owner_verifiable($atcl_vr_sq, $owner_verifiable);
|
||||
|
||||
|
||||
$sendData = $this->model->getDatacertAPI($atcl_vr_sq, 'R');
|
||||
|
||||
//이미지 파일 없음 && 홍보확인서 V2일 경우
|
||||
log_message('debug', '705 noimage_chk_chk sendData_return1 => ' . $sendData['atclNo'] . ' ::: ' . json_encode($sendData) . PHP_EOL);
|
||||
if ($noimg_chk_chk == "Y" && $sendData['vrfcType'] == "D2") {
|
||||
// $sendData['ownerVerifiable'] = false;
|
||||
}
|
||||
|
||||
$d_yn = $this->m710_model->get_send_yn('D');
|
||||
|
||||
if ($d_yn['stop_yn'] == 'N') { //전송금지
|
||||
//1.해당매물정보를v2_stop_api_save_info에다 넣음
|
||||
$model710->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'D', '');
|
||||
//2.아무렇지않게 행동한다
|
||||
$send_result['result'] = 'success';
|
||||
} else {
|
||||
//API 호출
|
||||
$send_result = $naver->certification($sendData['atclNo'], $try_cnt, $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['date'], $sendData['modifyInfo'], $sendData['ownerVerifiable']);
|
||||
}
|
||||
|
||||
if ($send_result['result'] == 'success') {
|
||||
if ($chk_type == '1') {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인완료 상태로 변경
|
||||
$result_query7 = $this->model->chgStat($atcl_vr_sq, '45', $toDay);
|
||||
$chgVrfc45 = $this->model->chgStatVrfc($atcl_vr_sq, '45'); //v2_vrfc_req INSERT
|
||||
$statFaxUp45 = $this->model->chgStatFax($atcl_vr_sq, '45'); //fax_imgs
|
||||
|
||||
//상태변경 TABLE INSERT : 검증완료 상태로 변경
|
||||
$result_query8 = $this->model->chgStat($atcl_vr_sq, '60', $toDay);
|
||||
$chgVrfc60 = $this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
|
||||
$statFaxUp60 = $this->model->chgStatFax($atcl_vr_sq, '60'); //fax_imgs
|
||||
|
||||
// ★ 검증완료
|
||||
//0.불일치 이력이 있는지 확인
|
||||
$cnt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
if (empty($cnt)) { //검증완료일땐 불일치가없어야 통계포함된다
|
||||
if ($atcl_vrtc_type == 'M' || $atcl_vrtc_type == 'O') { //모바일은 등기가 첨 시작이니까 insert해줘야함
|
||||
if (!($atcl_vrtc_type == 'M' && in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03')))) {//만약 분양권들이면 넘어가고 아니면 체크
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인완료 시간
|
||||
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
|
||||
//3.검증완료시간
|
||||
$finishTime = $model415->get_60_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인완료 시간
|
||||
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
|
||||
}
|
||||
}
|
||||
if ($noimg_chk_chk == 'Y') {
|
||||
$this->model->chgStat($atcl_vr_sq, '70', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'Y'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0103', '1', 'add'); // 등기부등본이미지 없음 저장
|
||||
}
|
||||
if ($img_chk_chk == 'O') {
|
||||
$this->model->chgStat($atcl_vr_sq, '76', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'O'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0105', '1', 'add'); // (열람)간소화확인으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'T') {
|
||||
$this->model->chgStat($atcl_vr_sq, '80', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'T'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0111', '1', 'add'); // 등기소로 일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'R') {
|
||||
$this->model->chgStat($atcl_vr_sq, '86', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'R'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0107', '1', 'add'); // 리얼탑 열람 일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'G') {
|
||||
$this->model->chgStat($atcl_vr_sq, '87', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'G'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0108', '1', 'add'); // 리얼탑 기열람 일치으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
}
|
||||
} else {
|
||||
if ($atcl_vrtc_type == 'M') {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
|
||||
$result_query7 = $this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$chgVrfc49 = $this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$statFaxUp49 = $this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$res_try = $this->model->chgRegiTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$result_query9 = $this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$chgVrfc69 = $this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$statFaxUp69 = $this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
// ★모바일이고 검증실패
|
||||
if (!in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03'))) {//만약 분양권들이면 넘어가고 아니면 체크
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
} else {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
|
||||
$result_query7 = $this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$chgVrfc49 = $this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$statFaxUp49 = $this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
//등기부등본 확인중 상태로 변경.
|
||||
$result_query30 = $this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 49 => 30'); //검증결과 변동사항 HISTORY
|
||||
$chgVrfc40 = $this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
|
||||
$statFaxUp40 = $this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
|
||||
|
||||
if ($try_cnt == '1') {
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '1');
|
||||
if ($atcl_vrtc_type == 'T') {
|
||||
//검증구분이 전화매물일 경우 사전에 일치로 처리된 값을 초기화 시켜준다.
|
||||
$this->model->resetTelConf($atcl_vr_sq);
|
||||
}
|
||||
|
||||
// ★1차실패
|
||||
if ($atcl_vrtc_type == 'O') {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$sf = 'F';
|
||||
$model415->update_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $sf);
|
||||
}
|
||||
} else if ($try_cnt == '2') {
|
||||
//v2_vrfc_req try_cnt 값을 2로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
// ★모바일 이외 검증실패
|
||||
if ($atcl_vrtc_type == 'O') {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($noimg_chk_chk == 'Y') {
|
||||
$this->model->chgStat($atcl_vr_sq, '70', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'Y'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0103', '1', 'add'); // 등기부등본이미지 없음 저장
|
||||
}
|
||||
if ($img_chk_chk == 'O') {
|
||||
$this->model->chgStat($atcl_vr_sq, '77', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'O'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0105', '1', 'add'); // (열람)간소화확인으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'T') {
|
||||
$this->model->chgStat($atcl_vr_sq, '85', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'T'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0112', '1', 'add'); // 등기소 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'R') {
|
||||
$this->model->chgStat($atcl_vr_sq, '88', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'R'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0109', '1', 'add'); // 리얼탑 열람 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'G') {
|
||||
$this->model->chgStat($atcl_vr_sq, '89', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'G'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0110', '1', 'add'); // 리얼탑 기열람 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
if (isset($send_result['error'])) {
|
||||
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
|
||||
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
|
||||
throw new \Exception($error_message);
|
||||
} else {
|
||||
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 다음매물 확인
|
||||
public function getNextInfo()
|
||||
{
|
||||
|
||||
@@ -1,118 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\results\M415Model;
|
||||
use App\Models\v2\M710Model;
|
||||
use Exception;
|
||||
use App\Models\v2\M706Model;
|
||||
|
||||
class M706 extends BaseController
|
||||
class M706 extends BaseV2Controller
|
||||
{
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M706Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M706Model();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
return view("pages/v2/m706/lists", $this->data);
|
||||
return ['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID'];
|
||||
}
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m706/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'vrfcreq_way',
|
||||
'rcpt_cpid',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 엑셀 다운로드
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 상세화면
|
||||
public function detail($id)
|
||||
{
|
||||
$id = (int) $id;
|
||||
$naver = new NaverApiClient();
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
@@ -124,6 +66,15 @@ class M706 extends BaseController
|
||||
$memo = $this->model->getMemo($id);
|
||||
$history = $this->model->getHistory($id);
|
||||
|
||||
$complexList = [];
|
||||
$ptpList = [];
|
||||
|
||||
// 아파트단지목록
|
||||
$complexList = $naver->complexList($data['address_code']);
|
||||
|
||||
// 평형목록
|
||||
$ptpList = $naver->ptpList($data['hscp_no']);
|
||||
|
||||
$this->data['codes'] = $codes;
|
||||
$this->data['regist'] = $regist;
|
||||
$this->data['record'] = $record;
|
||||
@@ -132,8 +83,477 @@ class M706 extends BaseController
|
||||
$this->data['memo'] = $memo;
|
||||
$this->data['history'] = $history;
|
||||
|
||||
$this->data['complexList'] = $complexList;
|
||||
$this->data['ptpList'] = $ptpList;
|
||||
|
||||
|
||||
return view("pages/v2/m706/detail", $this->data);
|
||||
}
|
||||
|
||||
// 매물정보 수정
|
||||
public function modifyInfo()
|
||||
{
|
||||
$naver = new NaverApiClient();
|
||||
|
||||
try {
|
||||
$atcl_vr_sq = $this->request->getPost('rcpt_key'); //순번
|
||||
$atcl_hscp_nm = $this->request->getPost('atcl_hscp_nm'); //단지명
|
||||
$atcl_ptp_nm = $this->request->getPost('atcl_ptp_nm'); //평형명
|
||||
$atcl_vrfc_type = $this->request->getPost('atcl_vrtc_way'); //검증구분
|
||||
$trade_type = $this->request->getPost('trade_type_cd'); //거래구분
|
||||
$atcl_addr1 = $this->request->getPost('atcl_addr1'); //상세주소1 폐기예정
|
||||
$atcl_addr1a = $this->request->getPost('atcl_addr1a'); // 리 주소
|
||||
$atcl_addr1b = $this->request->getPost('atcl_addr1b'); // 공동 : 동 주소, 비공동 : 지번주소
|
||||
$atcl_addr2 = $this->request->getPost('atcl_addr2'); //상세주소2
|
||||
$atcl_hscp_no = $this->request->getPost('atcl_hscp_no'); //단지번호
|
||||
$atcl_ptp_no = $this->request->getPost('atcl_ptp_no'); //단지명
|
||||
$atcl_amt1 = $this->request->getPost('atcl_amt1');
|
||||
$atcl_amt2 = $this->request->getPost('atcl_amt2');
|
||||
$atcl_amt3 = $this->request->getPost('atcl_amt3');
|
||||
$atcl_floor = $this->request->getPost('atcl_floor');
|
||||
$atcl_floor2 = $this->request->getPost('atcl_floor2'); // 총층
|
||||
|
||||
$return = '';
|
||||
if ($trade_type == 'A1') {
|
||||
$return = limitHscpMarketPriceInfo($this, $trade_type, $atcl_hscp_no, $atcl_ptp_no, $atcl_amt1);
|
||||
} elseif ($trade_type == 'B1') {
|
||||
$return = limitHscpMarketPriceInfo($this, $trade_type, $atcl_hscp_no, $atcl_ptp_no, $atcl_amt2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (empty($return)) {
|
||||
$result = $this->model->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);
|
||||
$this->model->saveModifyVrfc($atcl_vr_sq, $atcl_vrfc_type);
|
||||
|
||||
|
||||
if ($result['error_number'] != 0) {
|
||||
throw new \Exception($result['error_message']);
|
||||
} else {
|
||||
//API 호출
|
||||
$resultData = $this->model->getDetail($atcl_vr_sq);
|
||||
|
||||
$modifyInfo = $naver->modifyInfo(
|
||||
$resultData['data']['atcl_no'],
|
||||
$resultData['data']['hscp_no'],
|
||||
$resultData['data']['ptp_no'],
|
||||
$resultData['data']['bild_nm'],
|
||||
$resultData['data']['rm_no'],
|
||||
$resultData['data']['trade_type_cd'],
|
||||
$resultData['data']['deal_amt'],
|
||||
$resultData['data']['wrrnt_amt'],
|
||||
$resultData['data']['lease_amt'],
|
||||
$resultData['data']['isale_amt'],
|
||||
$resultData['data']['prem_amt'],
|
||||
$resultData['data']['floor'],
|
||||
$resultData['data']['floor2'],
|
||||
$resultData['data']['charger'],
|
||||
$resultData['data']['address_code'],
|
||||
$resultData['data']['address2'],
|
||||
$resultData['data']['address2a'],
|
||||
$resultData['data']['address2b'],
|
||||
$resultData['data']['address3'],
|
||||
$resultData['data']['sply_spc'],
|
||||
$resultData['data']['excls_spc'],
|
||||
$resultData['data']['tot_spc'],
|
||||
$resultData['data']['grnd_spc'],
|
||||
$resultData['data']['bldg_spc']
|
||||
);
|
||||
|
||||
if ($modifyInfo['result'] != 'success') { //결과값 확인
|
||||
$return = $modifyInfo['error'];
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $modifyInfo['error']['code'], $modifyInfo['error']['message'], $err_time, $resultData['data']['atcl_no']);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'code' => '0',
|
||||
'msg' => '정상적으로 저장되었습니다.',
|
||||
]);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON(body: [
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 서류확인정보 저장
|
||||
public function saveDocu()
|
||||
{
|
||||
/*
|
||||
1.0.1 POST 데이터 받기.
|
||||
1.1.1 1차 검증인지 2차검증인지 확인.
|
||||
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
|
||||
1.2.1 v2_confirms에 데이터가 있는지 확인.
|
||||
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
|
||||
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
|
||||
1.4.2 상태변경 하기 : 전화(서류)확인중 상태로 변경. (수정변경이력 저장)
|
||||
1.5.1 이미지파일 서버에 UPLOAD (수정변경이력 저장)
|
||||
1.6.1 기존파일 탐색.
|
||||
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
|
||||
1.8.1 기존파일 없음 : v2_files INSERT.
|
||||
1.9.1 확인여부 + 홍보확인서 미확인여부 상세, 매물주소, 가격거래구분, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
|
||||
1.10.1 API 전송.
|
||||
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 전화(서류)확인완료 상태. (수정변경이력 저장)
|
||||
*/
|
||||
$naver = new NaverApiClient();
|
||||
$model710 = new M710Model();
|
||||
$model415 = new M415Model();
|
||||
$v2DailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
$toDay = date('Y-m-d H:i:s'); //오늘날짜
|
||||
$atcl_vrtc_way = $this->request->getPost('atcl_vrtc_way');
|
||||
$atcl_vr_sq = $this->request->getPost('rcpt_key');
|
||||
$arr = $this->request->getPost('chTotal');
|
||||
$fax_conf_res_d11 = $this->request->getPost('fax_conf_res_d11');
|
||||
$fax_conf_yn_1 = $this->request->getPost('fax_conf_yn_1');
|
||||
$fax_conf_yn_2 = $this->request->getPost('fax_conf_yn_2');
|
||||
$fax_conf_yn_3 = $this->request->getPost('fax_conf_yn_3');
|
||||
$fax_conf_yn_4 = $this->request->getPost('fax_conf_yn_4');
|
||||
$fax_conf_yn_info_2 = $this->request->getPost('fax_conf_yn_info_2');
|
||||
$fax_conf_yn_info_3 = $this->request->getPost('fax_conf_yn_info_3');
|
||||
$fax_conf_yn_info_4 = $this->request->getPost('fax_conf_yn_info_4');
|
||||
$reg_chk_val = $this->request->getPost('reg_chk_val');
|
||||
$memo = $this->request->getPost('memo_fax');
|
||||
$try_cnt = '0';
|
||||
|
||||
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
|
||||
$resStat = $this->model->chkStat($atcl_vr_sq);
|
||||
$v2_vrfc_req = $v2DailyModel->get_v2_vrfc_req($atcl_vr_sq);
|
||||
|
||||
|
||||
if ((int) $resStat['stat_cd'] >= 40 || (int) $resStat['stat_cd'] == '190') {
|
||||
throw new \Exception('이미 저장된 데이터입니다.');
|
||||
} else {
|
||||
$this->model->InsCharger($atcl_vr_sq); //담당자가 없을 경우 강제로 session 정보로 넣어준다
|
||||
|
||||
$resultCnt = $this->model->chkTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
|
||||
if ($resultCnt['try_cnt'] == 0) { //1차 검증일 때
|
||||
$try_cnt = '1';
|
||||
} else if ($resultCnt['try_cnt'] == 1) { //2차 검증일 때
|
||||
$try_cnt = '2';
|
||||
} else {
|
||||
$try_cnt = intval($try_cnt) + 1;
|
||||
}
|
||||
|
||||
$result = $this->model->chkConfirm($atcl_vr_sq, '');
|
||||
if ($result == 0) { //v2_confirm 존재하지 않는다면
|
||||
if ($fax_conf_yn_2 == '10000' && $fax_conf_yn_3 == '10000' && $fax_conf_yn_4 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
}
|
||||
|
||||
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
|
||||
} else {
|
||||
if ($fax_conf_yn_2 == '10000' && $fax_conf_yn_3 == '10000' && $fax_conf_yn_4 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
}
|
||||
|
||||
$resUpdate = $this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
|
||||
}
|
||||
|
||||
//상태변경 TABLE INSERT : 전화(서류)확인중 상태로 변경
|
||||
$result_query2 = $this->model->chgStat($atcl_vr_sq, '30', $toDay);
|
||||
$chgVrfc = $this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
|
||||
|
||||
//v2_check_list 확인여부 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D11', $fax_conf_res_d11, $arr);
|
||||
//v2_check_list 매물주소 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D12', $fax_conf_yn_2, $fax_conf_yn_info_2);
|
||||
//v2_check_list 가격거래구분 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D13', $fax_conf_yn_3, $fax_conf_yn_info_3);
|
||||
//v2_check_list 의뢰인정보 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, 'D14', $fax_conf_yn_4, $fax_conf_yn_info_4);
|
||||
|
||||
//memo 저장
|
||||
if (!empty($memo)) {
|
||||
$this->model->saveMemo([$memo, $usr_id, $atcl_vr_sq]);
|
||||
}
|
||||
|
||||
//API 호출
|
||||
$sendData = $this->model->getDataConfirmAPI($atcl_vr_sq);
|
||||
|
||||
if ($fax_conf_yn_4 == '10000' || (int) $try_cnt < 2) {
|
||||
$send_result = $naver->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
|
||||
if ($send_result['result'] == 'success') { //HISTORY
|
||||
if ($fax_conf_res_d11 == '10000' && $chk_type == '1') {
|
||||
|
||||
//상태변경 TABLE INSERT : 전화(서류)확인 완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '35', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '35'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '35'); //fax_imgs
|
||||
|
||||
if ($reg_chk_val == '1') {
|
||||
//등기부등본 확인 대상은 전화(서류)확인 완료 후 -> 등기부등본 확인중 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '40', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '40'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '40'); //fax_imgs
|
||||
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0201', '1', 'add'); // 일치로 저장
|
||||
} else {
|
||||
//등기부등본 확인 대상이 아닌 경우 전화(서류)확인 완료 후 -> 검증 완료 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '60', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '60'); //fax_imgs
|
||||
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0205', '1', 'add'); // 홍보확인서완료 등기부등본확인 안함 저장
|
||||
}
|
||||
} else {
|
||||
//상태변경 TABLE INSERT : 전화(서류)확인 불일치
|
||||
$this->model->chgStat($atcl_vr_sq, '39', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '39'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '39'); //fax_imgs
|
||||
|
||||
|
||||
if ($try_cnt == '1') {
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$this->model->chgTryCnt($atcl_vr_sq, '1');
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0301', '1', 'add'); // 1차실패로 저장
|
||||
} else if ($try_cnt == '2') {
|
||||
//v2_vrfc_req try_cnt 값을 2로 update
|
||||
$this->model->chgTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0302', '1', 'add'); // 2차실패로 저장
|
||||
}
|
||||
|
||||
if ($fax_conf_res_d11 == '20013') {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0203', '1', 'add'); // 기타로 저장
|
||||
} else {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0202', '1', 'add'); // 불일치로 저장
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($send_result['error'])) {
|
||||
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
|
||||
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
|
||||
throw new \Exception($error_message);
|
||||
} else {
|
||||
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->model->chgStat($atcl_vr_sq, '39', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '39'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '39'); //fax_imgs
|
||||
|
||||
$this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 39 => 30'); //검증결과 변동사항 HISTORY
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
|
||||
|
||||
throw new Exception('의뢰인정보 불일치로 저장되었습니다.');
|
||||
}
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'code' => '0',
|
||||
'msg' => '정상적으로 저장되었습니다.',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON(body: [
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 등기부등본 정보 저장
|
||||
public function saveRegi()
|
||||
{
|
||||
/*
|
||||
1.0.1 POST 데이터 받기.
|
||||
1.1.1 1차 검증인지 2차검증인지 확인.
|
||||
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
|
||||
1.2.1 v2_confirms에 데이터가 있는지 확인.
|
||||
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
|
||||
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
|
||||
1.4.2 상태변경 하기 : 등기부등본 확인중 상태로 변경. (수정변경이력 저장)
|
||||
1.5.1 이미지파일 서버에 UPLOAD (수정변경이력 저장)
|
||||
1.6.1 기존파일 탐색.
|
||||
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
|
||||
1.8.1 기존파일 없음 : v2_files INSERT.
|
||||
1.9.1 매물주소, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
|
||||
1.10.1 API 전송.
|
||||
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 등기부등본 확인완료 상태. (수정변경이력 저장)
|
||||
*/
|
||||
$naver = new NaverApiClient();
|
||||
$model710 = new M710Model();
|
||||
$model415 = new M415Model();
|
||||
$v2DailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
|
||||
$mode = $this->request->getGet('mode');
|
||||
$usr_id = session('usr_id');
|
||||
$toDay = date('Y-m-d H:i:s');
|
||||
$atcl_vrtc_way = 'R';
|
||||
$atcl_vr_sq = $this->request->getPost('rcpt_key');
|
||||
$reg_conf_yn_1 = $this->request->getPost('reg_conf_yn_1');
|
||||
$reg_conf_yn_2 = $this->request->getPost('reg_conf_yn_2');
|
||||
$reg_conf_yn_3 = $this->request->getPost('reg_conf_yn_3');
|
||||
$reg_conf_yn_info_2 = $this->request->getPost('reg_conf_yn_info_2');
|
||||
$reg_conf_yn_info_3 = $this->request->getPost('reg_conf_yn_info_3');
|
||||
$memo = $this->request->getPost('memo_reg');
|
||||
$try_cnt = '0';
|
||||
|
||||
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
|
||||
$resStat = $this->model->chkStat($atcl_vr_sq);
|
||||
$v2_vrfc_req = $this->model->get_v2_vrfc_req($atcl_vr_sq);
|
||||
|
||||
if ((int) $resStat['stat_cd'] >= 60 || (int) $resStat['stat_cd'] == 19) {
|
||||
throw new \Exception('이미 저장된 데이터입니다.');
|
||||
} else {
|
||||
$this->model->InsResChar($atcl_vr_sq); //담당자가 없을 경우 강제로 session 정보로 넣어준다
|
||||
|
||||
$resultCnt = $this->model->chkRegiTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
|
||||
if ($resultCnt['reg_try_cnt'] == 0) { //1차 검증일 때
|
||||
$try_cnt = '1';
|
||||
} else if ($resultCnt['reg_try_cnt'] == 1) { //2차 검증일 때
|
||||
$try_cnt = '2';
|
||||
} else {
|
||||
$try_cnt = intval($try_cnt) + 1;
|
||||
}
|
||||
|
||||
$result = $this->model->chkConfirm($atcl_vr_sq, $atcl_vrtc_way);
|
||||
if ($result == 0) {
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
}
|
||||
|
||||
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
|
||||
} else {
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
}
|
||||
|
||||
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
|
||||
}
|
||||
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인중 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '40', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '40'); //v2_vrfc_req INSERT
|
||||
|
||||
//v2_check_list 확인여부 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '21', $reg_conf_yn_2, $reg_conf_yn_info_2);
|
||||
|
||||
//v2_check_list 매물주소 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '22', $reg_conf_yn_3, $reg_conf_yn_info_3);
|
||||
|
||||
//memo 저장
|
||||
if (!empty($memo)) {
|
||||
$this->model->saveMemo([$memo, $atcl_vr_sq]);
|
||||
}
|
||||
|
||||
//API 호출
|
||||
$sendData = $this->model->getDatacertAPI($atcl_vr_sq, 'R');
|
||||
$send_result = $naver->certification($sendData['atclNo'], $try_cnt, $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['date'], $sendData['modifyInfo'], $sendData['ownerVerifiable']);
|
||||
if ($send_result['result'] == 'success') {
|
||||
if ($chk_type == '1') {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '45', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '45'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '45'); //fax_imgs
|
||||
|
||||
//상태변경 TABLE INSERT : 검증완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '60', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '60'); //fax_imgs
|
||||
|
||||
$v2_vrfc_req->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
//등기부등본 확인중 상태로 변경.
|
||||
$this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 49 => 30'); //검증결과 변동사항 HISTORY
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
|
||||
|
||||
if ($try_cnt == '1') {
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '1');
|
||||
} else if ($try_cnt == '2') {
|
||||
|
||||
//v2_vrfc_req try_cnt 값을 2로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
}
|
||||
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
}
|
||||
} else {
|
||||
if (isset($send_result['error'])) {
|
||||
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
|
||||
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
|
||||
throw new \Exception($error_message);
|
||||
} else {
|
||||
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'code' => '0',
|
||||
'msg' => '정상적으로 저장되었습니다.',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON(body: [
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,126 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\Common;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\results\M415Model;
|
||||
use App\Models\v2\M710Model;
|
||||
use Exception;
|
||||
use App\Models\v2\M708Model;
|
||||
|
||||
class M708 extends BaseController
|
||||
class M708 extends BaseV2Controller
|
||||
{
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M708Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M708Model();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['CP_ID', 'STEP_VERIFICATION', 'RECEIPT_STATUS3', 'ARTICLE_TYPE']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
return view("pages/v2/m708/lists", $this->data);
|
||||
return ['CP_ID', 'STEP_VERIFICATION', 'RECEIPT_STATUS3', 'ARTICLE_TYPE'];
|
||||
}
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m708/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력
|
||||
'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'rcpt_v2' => $this->request->getGet('rcpt_v2'), // 검증방식
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'chk_atcl_no',
|
||||
'caller_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'target_yn',
|
||||
'rcpt_cpid',
|
||||
'rlet_type_cd',
|
||||
'rcpt_v2',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 엑셀 다운로드
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력
|
||||
'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'rcpt_v2' => $this->request->getGet('rcpt_v2'), // 검증방식
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 상세화면
|
||||
public function detail($id)
|
||||
{
|
||||
$id = (int) $id;
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
@@ -129,7 +67,6 @@ class M708 extends BaseController
|
||||
$data = $this->model->getDetail($id);
|
||||
$memo = $this->model->getMemo($id);
|
||||
|
||||
|
||||
$article = null;
|
||||
$confirm = null;
|
||||
if (!empty($data)) {
|
||||
@@ -360,6 +297,11 @@ class M708 extends BaseController
|
||||
// 확인결과 저장
|
||||
public function saveResult()
|
||||
{
|
||||
$naver = new NaverApiClient();
|
||||
$model710 = new M710Model();
|
||||
$model415 = new M415Model();
|
||||
$v2DailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
$fax_sq = $this->request->getPost('fax_sq');
|
||||
$vr_sq = $this->request->getPost('vr_sq');
|
||||
@@ -387,9 +329,72 @@ class M708 extends BaseController
|
||||
}
|
||||
|
||||
// DB에 결과 저장
|
||||
// $this->model->saveHongBoFAX($fax_sq, $vr_sq, $atcl_no, $work_type, $send_yn, $result_d11, $comment_d11, $fax_conf_yn_1, $fax_conf_yn_2, $fax_conf_yn_3, $fax_conf_info_1, $fax_conf_info_2, $fax_conf_info_3, $file_type);
|
||||
$return = $this->model->saveHongBoFAX($fax_sq, $vr_sq, $atcl_no, $work_type, $send_yn, $result_d11 ?? null, $comment_d11 ?? null, $fax_conf_yn_1 ?? null, $fax_conf_yn_2 ?? null, $fax_conf_yn_3 ?? null, $fax_conf_info_1 ?? null, $fax_conf_info_2 ?? null, $fax_conf_info_3 ?? null, $file_type);
|
||||
|
||||
if (empty($return['code']) && $work_type == '2') {
|
||||
// 검증센터에 데이터를 전송한다.
|
||||
$sendData = $this->model->getDataConfirmAPI($vr_sq);
|
||||
|
||||
if (($fax_conf_yn_3 ?? 'N') == 'Y' || (int) $article['try_cnt'] < 1) {
|
||||
$send_result = $naver->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
|
||||
|
||||
if ($send_result['result'] == 'success') {
|
||||
$this->model->InsCharger($vr_sq);
|
||||
|
||||
// DB에 상태값을 전송완료로 저장한다.
|
||||
if (empty($sendData['success'])) {
|
||||
$stat_cd = '39'; // 서류/전화 확인 실패
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 전송완료 상태로 변경..
|
||||
|
||||
if ($sendData['try_cnt'] >= '1') {
|
||||
$stat_cd = '69'; // 검증실패
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 전송완료 상태로 변경..
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0302', '1', 'add'); // 최종실패로 저장
|
||||
} else {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0301', '1', 'add'); // 1차실패로 저장
|
||||
}
|
||||
// $res_try = $this->m708_model->chgTryCnt($vr_sq, intval($sendData['try_cnt']) +1);
|
||||
|
||||
$this->model->increseTryCnt($vr_sq);
|
||||
|
||||
if (($result_d11 ?? '') == '20013') {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0203', '1', 'add'); // 기타로 저장
|
||||
} else {
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0202', '1', 'add'); // 불일치로 저장
|
||||
}
|
||||
} else {
|
||||
$stat_cd = '35'; // 서류/전화 확인 성공
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 전송완료 상태로 변경..
|
||||
|
||||
$rgbk_cofirm = $this->model->getRgbk_confirm($vr_sq);
|
||||
if ($rgbk_cofirm == '1') {
|
||||
$stat_cd = '40';
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 등기부등본 확인중 상태로 변경..
|
||||
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0201', '1', 'add'); // 일치로 저장
|
||||
} else {
|
||||
$stat_cd = '60';
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 검증완료 상태로 변경..
|
||||
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0205', '1', 'add'); // 홍보확인서완료 등기부등본확인 안함 저장
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new \Exception($send_result['error']);
|
||||
}
|
||||
} else {
|
||||
$stat_cd = '39'; // 서류/전화 확인 실패
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd);
|
||||
|
||||
$stat_cd = '30'; // 서류/전화 확인 중
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd);
|
||||
|
||||
$this->model->increseTryCnt($vr_sq);
|
||||
|
||||
throw new \Exception('의뢰인 정보 불일치로 저장되었습니다.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
@@ -408,14 +413,131 @@ class M708 extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
// 분양계약서 저장
|
||||
// 분양계약서 조회
|
||||
public function saveBunyangCnt()
|
||||
{
|
||||
try {
|
||||
|
||||
$vr_sq = $this->request->getPost('vr_sq');
|
||||
|
||||
$rsrv_sq = $this->model->get_rsrv_sq($vr_sq);
|
||||
$cnt = $this->model->getI8Cnt($rsrv_sq['rsrv_sq']);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success',
|
||||
'cnt' => $cnt,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 분양계약서 저장
|
||||
public function saveResult3()
|
||||
{
|
||||
$naver = new NaverApiClient();
|
||||
$v2StDailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
|
||||
$fax_sq = $this->request->getPost('fax_sq');
|
||||
$vr_sq = $this->request->getPost('vr_sq');
|
||||
$atcl_no = $this->request->getPost('atcl_no');
|
||||
$work_type = $this->request->getPost('work_type');
|
||||
|
||||
$resyn = $this->request->getPost('resYn');
|
||||
$dbusageagryn = $this->request->getPost('dbUsageAgrYn');
|
||||
$send_yn = 'Y'; // 업데이트 된다면 미처리->처리상태로 변경
|
||||
|
||||
$article = $this->model->getArticleInfo2($atcl_no, $vr_sq);
|
||||
$v2_vrfc_req = $v2StDailyModel->get_v2_vrfc_req($vr_sq);
|
||||
|
||||
if ((int) $article['stat_cd'] >= 40) {
|
||||
throw new \Exception('이미 저장된 데이터입니다.');
|
||||
} else {
|
||||
if (!empty($resyn)) {
|
||||
$this->model->updateResDB($resyn, $dbusageagryn, $vr_sq);
|
||||
}
|
||||
|
||||
// DB에 결과를 저장한다.
|
||||
$return = $this->model->saveresult3FAX($fax_sq, $vr_sq, $atcl_no, $work_type, $send_yn, $result_d11 ?? null, $comment_d11 ?? null, $fax_conf_yn_1 ?? null, $fax_conf_yn_2 ?? null, $fax_conf_yn_3 ?? null, $fax_conf_info_1 ?? null, $fax_conf_info_2 ?? null, $fax_conf_info_3 ?? null);
|
||||
|
||||
if (empty($return['code']) && $work_type == '2') {
|
||||
// 검증센터에 데이터를 전송한다.
|
||||
$sendData = $this->model->getDataConfirmAPI($vr_sq);
|
||||
|
||||
if (($fax_conf_yn_3 ?? 'N') == 'Y' || $article['try_cnt'] < '1') {
|
||||
$send_result = $naver->confirm($sendData['atclNo'], $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['modifyInfo'], $sendData['date']);
|
||||
|
||||
if ($send_result['result'] == 'success') {
|
||||
$this->model->InsCharger($vr_sq);
|
||||
|
||||
// DB에 상태값을 전송완료로 저장한다.
|
||||
if (empty($sendData['success'])) {
|
||||
$stat_cd = '39'; // 서류/전화 확인 실패
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 전송완료 상태로 변경
|
||||
|
||||
if ($sendData['try_cnt'] >= '1') {
|
||||
$stat_cd = '69'; // 검증실패
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 전송완료 상태로 변경..
|
||||
$v2StDailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0302', '1', 'add'); // 최종실패로 저장
|
||||
} else {
|
||||
$v2StDailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0301', '1', 'add'); // 1차실패로 저장
|
||||
}
|
||||
// $res_try = $this->m708_model->chgTryCnt($vr_sq, intval($sendData['try_cnt']) +1);
|
||||
|
||||
$this->model->increseTryCnt($vr_sq);
|
||||
|
||||
if (($result_d11 ?? '') == '20013') {
|
||||
$v2StDailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0203', '1', 'add'); // 기타로 저장
|
||||
} else {
|
||||
$v2StDailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0202', '1', 'add'); // 불일치로 저장
|
||||
}
|
||||
} else {
|
||||
$stat_cd = '35'; // 서류/전화 확인 성공
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 전송완료 상태로 변경..
|
||||
|
||||
$rgbk_cofirm = $this->model->getRgbk_confirm($vr_sq);
|
||||
if ($rgbk_cofirm == '1') {
|
||||
$stat_cd = '40';
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 등기부등본 확인중 상태로 변경..
|
||||
|
||||
$v2StDailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0201', '1', 'add'); // 일치로 저장
|
||||
} else {
|
||||
$stat_cd = '60';
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd); // 검증완료 상태로 변경..
|
||||
|
||||
$v2StDailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'D0205', '1', 'add'); // 홍보확인서완료 등기부등본확인 안함 저장
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new \Exception($send_result['error']);
|
||||
}
|
||||
} else {
|
||||
$stat_cd = '39'; // 서류/전화 확인 실패
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd);
|
||||
|
||||
$stat_cd = '30'; // 서류/전화 확인 중
|
||||
$this->model->saveChangeStep($fax_sq, $vr_sq, $stat_cd);
|
||||
|
||||
$this->model->increseTryCnt($vr_sq);
|
||||
|
||||
|
||||
throw new \Exception('의뢰인 정보 불일치로 저장되었습니다.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
|
||||
@@ -1,125 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\Common;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Models\v2\M709Model;
|
||||
|
||||
class M709 extends BaseController
|
||||
class M709 extends BaseV2Controller
|
||||
{
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M709Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M709Model();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['CP_ID', 'STEP_VERIFICATION', 'RECEIPT_STATUS3', 'ARTICLE_TYPE']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
return view("pages/v2/m709/lists", $this->data);
|
||||
return ['CP_ID', 'STEP_VERIFICATION', 'RECEIPT_STATUS3', 'ARTICLE_TYPE'];
|
||||
}
|
||||
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m709/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력
|
||||
'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'rcpt_v2' => $this->request->getGet('rcpt_v2'), // 검증방식
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'chk_atcl_no',
|
||||
'caller_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'target_yn',
|
||||
'rcpt_cpid',
|
||||
'rlet_type_cd',
|
||||
'rcpt_v2',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'chk_atcl_no' => $this->request->getGet('chk_atcl_no'), // 매물번호입력
|
||||
'caller_no' => $this->request->getGet('caller_no'), // 발신팩스번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'target_yn' => $this->request->getGet('target_yn'), // 홍보확인서여부
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'rcpt_v2' => $this->request->getGet('rcpt_v2'), // 검증방식
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 상세화면
|
||||
public function detail($id)
|
||||
{
|
||||
$id = (int) $id;
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,132 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\Common;
|
||||
use App\Libraries\MyUpload;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\results\M415Model;
|
||||
use App\Models\v2\M712Model;
|
||||
|
||||
class M712 extends BaseController
|
||||
class M712 extends BaseV2Controller
|
||||
{
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M712Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M712Model();
|
||||
}
|
||||
|
||||
public function lists(): string
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'ARTICLE_TYPE']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
return view("pages/v2/m712/lists", $this->data);
|
||||
return ['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'ARTICLE_TYPE'];
|
||||
}
|
||||
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m712/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
|
||||
'ownerTypeCode' => $this->request->getGet('ownerTypeCode'), // 소유자 구분
|
||||
'document_not_received_yn' => $this->request->getGet('document_not_received_yn'), // 서류미수취
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'vrfcreq_way',
|
||||
'vrfc_type_sub',
|
||||
'rcpt_cpid',
|
||||
'rlet_type_cd',
|
||||
'reference_file_url_yn',
|
||||
'ownerTypeCode',
|
||||
'document_not_received_yn',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 엑셀 다운로드
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
|
||||
'ownerTypeCode' => $this->request->getGet('ownerTypeCode'), // 소유자 구분
|
||||
'document_not_received_yn' => $this->request->getGet('document_not_received_yn'), // 서류미수취
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 상세화면
|
||||
public function detail($id): string
|
||||
{
|
||||
|
||||
$id = (int) $id;
|
||||
$naver = new NaverApiClient();
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
@@ -139,12 +73,37 @@ class M712 extends BaseController
|
||||
$regist = $this->model->getRecordInfo($id, '2'); //등기부등본
|
||||
$display = $this->model->getDisplay('M705_detail');
|
||||
|
||||
$hscp_info = [];
|
||||
if (!empty($data['hscp_no'])) {
|
||||
$apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
|
||||
$villa_rlet_type_cd = ['A05', 'A06'];
|
||||
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $apt_rlet_type_cd)) { // apt 단지
|
||||
$detail_hscp = $naver->aptDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $villa_rlet_type_cd)) { // villa 단지
|
||||
$detail_hscp = $naver->villaDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
// print_r($data);
|
||||
// print_r($detail_hscp);
|
||||
// exit;
|
||||
|
||||
if (!empty($detail_hscp) && isset($detail_hscp['result'])) {
|
||||
$hscp_info = $detail_hscp['result'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->data['codes'] = $codes;
|
||||
$this->data['data'] = $data;
|
||||
$this->data['memo'] = $memo;
|
||||
$this->data['record'] = $record;
|
||||
$this->data['regist'] = $regist;
|
||||
$this->data['display'] = $display;
|
||||
$this->data['hscp_info'] = $hscp_info;
|
||||
|
||||
return view("pages/v2/m712/detail", $this->data);
|
||||
}
|
||||
@@ -294,14 +253,384 @@ class M712 extends BaseController
|
||||
// 정보저장
|
||||
public function saveRegi()
|
||||
{
|
||||
/*
|
||||
1.0.1 POST 데이터 받기.
|
||||
1.1.1 1차 검증인지 2차검증인지 확인.
|
||||
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
|
||||
1.2.1 v2_confirms에 데이터가 있는지 확인.
|
||||
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
|
||||
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
|
||||
1.4.2 상태변경 하기 : 등기부등본 확인중 상태로 변경. (수정변경이력 저장)
|
||||
1.5.1 이미지파일 서버에 UPLOAD (수정변경이력 저장)
|
||||
1.6.1 기존파일 탐색.
|
||||
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
|
||||
1.8.1 기존파일 없음 : v2_files INSERT.
|
||||
1.9.1 매물주소, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
|
||||
1.10.1 API 전송.
|
||||
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 등기부등본 확인완료 상태. (수정변경이력 저장)
|
||||
1.12.1 서류 확인내용 v2_article_info_etc document_cert_method 저장
|
||||
*/
|
||||
|
||||
$naver = new NaverApiClient();
|
||||
// $model710 = new M710Model();
|
||||
$model415 = new M415Model();
|
||||
$v2DailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
$toDay = date('Y-m-d H:i:s');
|
||||
$atcl_vrtc_way = 'R'; //검증구분
|
||||
$atcl_vr_sq = $this->request->getPost('rcpt_key');
|
||||
// $atcl_no = $this->request->getPost('atcl_no');
|
||||
$reg_conf_yn_1 = $this->request->getPost('reg_conf_yn_1'); //확인내용
|
||||
$reg_conf_yn_2 = $this->request->getPost('reg_conf_yn_2'); //매물주소
|
||||
$reg_conf_yn_3 = $this->request->getPost('reg_conf_yn_3'); //의뢰인정보
|
||||
$reg_conf_yn_info_2 = $this->request->getPost('reg_conf_yn_info_2'); //매물주소
|
||||
$reg_conf_yn_info_3 = $this->request->getPost('reg_conf_yn_info_3'); //의뢰인정보
|
||||
$memo = $this->request->getPost('memo'); //메모
|
||||
$owner_verifiable = $this->request->getPost('owner_verifiable'); //실소유주 확인여부
|
||||
$noimg_chk_chk = $this->request->getPost('noimg_chk_chk'); // 등기부등본이미지 파일없음.
|
||||
$img_chk_chk = $this->request->getPost('img_chk_chk'); // 등기소, 리얼탑 열람, 리얼탑 기열람, 열람
|
||||
$atcl_vrtc_type = $this->request->getPost('atcl_vrtc_type'); // 검증구분
|
||||
$vrfc_type_sub = $this->request->getPost('vrfc_type_sub'); // 하위검증구분
|
||||
$arr_uncnfrm_status = $this->request->getPost('arr_uncnfrm_status'); // 등기부등본 미확인여부 상세
|
||||
$ownerTypeCode = $this->request->getPost('ownerTypeCode'); // 소유자명 확인 일치 , 불일치
|
||||
$document_cert_method = $this->request->getPost('document_cert_method'); // 서류 내용 확인
|
||||
|
||||
if ($owner_verifiable == "1") {
|
||||
$owner_verifiable = true;
|
||||
} else {
|
||||
$owner_verifiable = false;
|
||||
}
|
||||
|
||||
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
|
||||
$resStat = $this->model->chkStat($atcl_vr_sq);
|
||||
$v2_vrfc_req = $v2DailyModel->get_v2_vrfc_req($atcl_vr_sq);
|
||||
$rlet_type_cd = $model415->get_rlet_type_cd($atcl_vr_sq);
|
||||
|
||||
if ((int) $resStat['stat_cd'] >= 60 || (int) $resStat['stat_cd'] == 19) {
|
||||
throw new \Exception('이미 저장된 데이터입니다.');
|
||||
} else {
|
||||
$resultCnt = $this->model->chkRegiTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
|
||||
if ($resultCnt['reg_try_cnt'] == 0) { // 1차 검증일 때
|
||||
log_message('debug', '712 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 0 ');
|
||||
$try_cnt = '1';
|
||||
} else if ($resultCnt['reg_try_cnt'] == 1) { // 2차 검증일 때
|
||||
log_message('debug', '712 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 1 ');
|
||||
$try_cnt = '2';
|
||||
} else {
|
||||
log_message('debug', '712 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 예외처리 ');
|
||||
$try_cnt = '2';
|
||||
//$try_cnt = intval($try_cnt) + 1;
|
||||
}
|
||||
|
||||
$result = $this->model->chkConfirm($atcl_vr_sq, $atcl_vrtc_way);
|
||||
if ($result == 0) { //v2_confirm 존재하지 않는다면
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 1, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
// 수정한 시간이 현재시간10분전 보다 클 경우 수정불가능
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
}
|
||||
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
|
||||
} else {
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 1, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
|
||||
}
|
||||
|
||||
|
||||
$this->model->InsResChar($atcl_vr_sq); //담당자 업데이트
|
||||
|
||||
// 모바일v1,v2고 등기부등본 미확인여부 상세 저장
|
||||
if ($vrfc_type_sub == 'M1' || $vrfc_type_sub == 'O1') {
|
||||
$this->model->add_cert_uncnfrm_status($atcl_vr_sq, $arr_uncnfrm_status);
|
||||
if (strpos($arr_uncnfrm_status, '20020') !== false) { //등기부등본 미확인여부 상세에 20020(파일 오첨부)있고
|
||||
if ($vrfc_type_sub == 'M1') { // 모바일v1일땐 코드 20020,코멘트x
|
||||
$reg_conf_yn_2 = '20020';
|
||||
$reg_conf_yn_info_2 = '';
|
||||
} else { // 모바일v2일땐 일반 불일치코드,코멘트=파일 오첨부
|
||||
$reg_conf_yn_info_2 = '파일 오첨부';
|
||||
}
|
||||
}
|
||||
}
|
||||
//v2_check_list 확인여부 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '21', $reg_conf_yn_2, $reg_conf_yn_info_2);
|
||||
|
||||
//v2_check_list 매물주소 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '22', $reg_conf_yn_3, $reg_conf_yn_info_3);
|
||||
|
||||
//memo 저장
|
||||
$this->model->saveMemo([$memo, $atcl_vr_sq]);
|
||||
|
||||
// document_cert_method
|
||||
$this->model->updatedocument_cert_method($atcl_vr_sq, $document_cert_method);
|
||||
|
||||
|
||||
//실소유주 확인 저장
|
||||
$this->model->update_owner_verifiable($atcl_vr_sq, $owner_verifiable);
|
||||
$sendData = $this->model->getDatacertAPI($atcl_vr_sq, 'R');
|
||||
|
||||
log_message('debug', '712 saveRegi => ' . $sendData['atclNo'] . ' ::: ' . json_encode($sendData) . PHP_EOL);
|
||||
|
||||
$d_yn = $this->model->get_send_yn('D');
|
||||
|
||||
if ($d_yn['stop_yn'] == 'N') { //전송금지
|
||||
//1.해당매물정보를v2_stop_api_save_info에다 넣음
|
||||
$this->model->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'D', '');
|
||||
//2.아무렇지않게 행동한다
|
||||
$send_result['result'] = 'success';
|
||||
} else {
|
||||
//API 호출
|
||||
$send_result = $naver->certification_712($sendData['atclNo'], $try_cnt, $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['date'], $sendData['modifyInfo'], $sendData['ownerVerifiable']);
|
||||
}
|
||||
|
||||
if ($send_result['result'] == 'success') {
|
||||
if ($chk_type == '1') {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '45', $toDay);
|
||||
$chgVrfc45 = $this->model->chgStatVrfc($atcl_vr_sq, '45'); //v2_vrfc_req INSERT
|
||||
$statFaxUp45 = $this->model->chgStatFax($atcl_vr_sq, '45'); //fax_imgs
|
||||
|
||||
//상태변경 TABLE INSERT : 검증완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '60', $toDay);
|
||||
$chgVrfc60 = $this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
|
||||
$statFaxUp60 = $this->model->chgStatFax($atcl_vr_sq, '60'); //fax_imgs
|
||||
|
||||
// ★ 검증완료
|
||||
//0.불일치 이력이 있는지 확인
|
||||
$cnt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
if (empty($cnt)) {
|
||||
if ($atcl_vrtc_type == 'M' || $atcl_vrtc_type == 'N') { //모바일은 등기가 첨 시작이니까 insert해줘야함
|
||||
if (!($atcl_vrtc_type == 'M' && in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03')))) {//만약 분양권들이면 넘어가고 아니면 체크
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인완료 시간
|
||||
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
|
||||
//3.검증완료시간
|
||||
$finishTime = $model415->get_60_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인완료 시간
|
||||
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($noimg_chk_chk == 'Y') {
|
||||
$this->model->chgStat($atcl_vr_sq, '70', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'Y'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0103', '1', 'add'); // 등기부등본이미지 없음 저장
|
||||
}
|
||||
if ($img_chk_chk == 'O') {
|
||||
$this->model->chgStat($atcl_vr_sq, '76', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'O'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0105', '1', 'add'); // (열람)간소화확인으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'T') {
|
||||
$this->model->chgStat($atcl_vr_sq, '80', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'T'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0111', '1', 'add'); // 등기소로 일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'R') {
|
||||
$this->model->chgStat($atcl_vr_sq, '86', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'R'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0107', '1', 'add'); // 리얼탑 열람 일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'G') {
|
||||
$this->model->chgStat($atcl_vr_sq, '87', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'G'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0108', '1', 'add'); // 리얼탑 기열람 일치으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
}
|
||||
} else {
|
||||
if ($atcl_vrtc_type == 'M') {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$chgVrfc49 = $this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$statFaxUp49 = $this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$chgVrfc69 = $this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$statFaxUp69 = $this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
// ★모바일이고 검증실패
|
||||
if (!in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03'))) {//만약 분양권들이면 넘어가고 아니면 체크
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
} else {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$chgVrfc49 = $this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$statFaxUp49 = $this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
//등기부등본 확인중 상태로 변경.
|
||||
$this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 49 => 30'); //검증결과 변동사항 HISTORY
|
||||
$chgVrfc40 = $this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
|
||||
$statFaxUp40 = $this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
|
||||
|
||||
if ($try_cnt == '1') {
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '1');
|
||||
if ($atcl_vrtc_type == 'T') {
|
||||
//검증구분이 전화매물일 경우 사전에 일치로 처리된 값을 초기화 시켜준다.
|
||||
$reset_query = $this->model->resetTelConf($atcl_vr_sq);
|
||||
}
|
||||
|
||||
// ★1차실패
|
||||
if ($atcl_vrtc_type == 'N') {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$sf = 'F';
|
||||
$model415->update_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $sf);
|
||||
}
|
||||
} else if ($try_cnt == '2') {
|
||||
//v2_vrfc_req try_cnt 값을 2로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$chgVrfc69 = $this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$statFaxUp69 = $this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
// ★모바일 이외 검증실패
|
||||
if ($atcl_vrtc_type == 'N') {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($noimg_chk_chk == 'Y') {
|
||||
$this->model->chgStat($atcl_vr_sq, '70', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'Y'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0103', '1', 'add'); // 등기부등본이미지 없음 저장
|
||||
}
|
||||
if ($img_chk_chk == 'O') {
|
||||
$this->model->chgStat($atcl_vr_sq, '77', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'O'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0105', '1', 'add'); // (열람)간소화확인으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'T') {
|
||||
$this->model->chgStat($atcl_vr_sq, '85', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'T'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0112', '1', 'add'); // 등기소 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'R') {
|
||||
$this->model->chgStat($atcl_vr_sq, '88', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'R'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0109', '1', 'add'); // 리얼탑 열람 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'G') {
|
||||
$this->model->chgStat($atcl_vr_sq, '89', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'G'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0110', '1', 'add'); // 리얼탑 기열람 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (isset($send_result['error'])) {
|
||||
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
|
||||
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
|
||||
throw new \Exception($error_message);
|
||||
} else {
|
||||
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
|
||||
@@ -1,129 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Controllers\V2\BaseV2Controller;
|
||||
use App\Libraries\MyUpload;
|
||||
use App\Models\common\CodeModel;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\results\M415Model;
|
||||
use App\Models\v2\M710Model;
|
||||
use App\Models\v2\M713Model;
|
||||
|
||||
class M713 extends BaseController
|
||||
class M713 extends BaseV2Controller
|
||||
{
|
||||
private $model, $codeModel;
|
||||
|
||||
public function __construct()
|
||||
protected function createModel()
|
||||
{
|
||||
$this->model = new M713Model();
|
||||
$this->codeModel = new CodeModel();
|
||||
return new M713Model();
|
||||
}
|
||||
|
||||
|
||||
public function lists(): string
|
||||
protected function getCodeKeys(): array
|
||||
{
|
||||
$codes = $this->codeModel->getCodeLists(['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'ARTICLE_TYPE']); // 코드조회
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
$bonbu = $this->model->getBonbuList();
|
||||
$team = $this->model->getTeamList();
|
||||
$user = $this->model->getUserList();
|
||||
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['bonbu'] = $bonbu;
|
||||
$this->data['team'] = $team;
|
||||
$this->data['user'] = $user;
|
||||
$this->data['codes'] = $codes;
|
||||
|
||||
return view("pages/v2/m713/lists", $this->data);
|
||||
return ['STEP_VERIFICATION', 'VRFCREQ_WAY', 'CP_ID', 'ARTICLE_TYPE'];
|
||||
}
|
||||
|
||||
public function getResultList()
|
||||
protected function getViewName(): string
|
||||
{
|
||||
$start = (int) $this->request->getGet('start') ?: 0;
|
||||
$end = (int) $this->request->getGet('length') ?: 10;
|
||||
return 'pages/v2/m713/lists';
|
||||
}
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'chk_spc_yn' => $this->request->getGet('chk_spc_yn'), // 면적확인
|
||||
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
|
||||
'corp_own' => $this->request->getGet('corp_own'), // 법인소유
|
||||
protected function getSearchKeys(): array
|
||||
{
|
||||
return [
|
||||
'atcl_no',
|
||||
'stat_cd',
|
||||
'realtor_nm',
|
||||
'charger_gbn',
|
||||
'assign_yn',
|
||||
'receipt_sdate',
|
||||
'receipt_edate',
|
||||
'complete_sdate',
|
||||
'complete_edate',
|
||||
'srcSido',
|
||||
'srcGugun',
|
||||
'srcDong',
|
||||
'bonbu',
|
||||
'team',
|
||||
'damdang',
|
||||
'vrfcreq_way',
|
||||
'vrfc_type_sub',
|
||||
'rcpt_cpid',
|
||||
'rlet_type_cd',
|
||||
'chk_spc_yn',
|
||||
'reference_file_url_yn',
|
||||
'corp_own',
|
||||
];
|
||||
|
||||
$totalCount = $this->model->getTotalCount($data);
|
||||
|
||||
$datas = $this->model->getResultList($start, $end, $data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'recordsTotal' => $totalCount,
|
||||
'recordsFiltered' => $totalCount,
|
||||
'data' => $datas,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
// 엑셀 다운로드
|
||||
public function excel()
|
||||
{
|
||||
try {
|
||||
|
||||
$data = [
|
||||
'atcl_no' => $this->request->getGet('atcl_no'), // 매물번호
|
||||
'stat_cd' => $this->request->getGet('stat_cd'), // 현재상태
|
||||
'realtor_nm' => $this->request->getGet('realtor_nm'), // 중개소
|
||||
'charger_gbn' => $this->request->getGet('charger_gbn'), // 배정여부
|
||||
'assign_yn' => $this->request->getGet('assign_yn'), // 배정여부2
|
||||
'receipt_sdate' => $this->request->getGet('receipt_sdate'), // 접수기간1
|
||||
'receipt_edate' => $this->request->getGet('receipt_edate'), // 접수기간2
|
||||
'complete_sdate' => $this->request->getGet('complete_sdate'), // 완료기간1
|
||||
'complete_edate' => $this->request->getGet('complete_edate'), // 완료기간2
|
||||
'srcSido' => $this->request->getGet('srcSido'), // 시도
|
||||
'srcGugun' => $this->request->getGet('srcGugun'), // 시군구
|
||||
'srcDong' => $this->request->getGet('srcDong'), // 읍면동
|
||||
'bonbu' => $this->request->getGet('bonbu'), // 본부
|
||||
'team' => $this->request->getGet('team'), // 팀
|
||||
'damdang' => $this->request->getGet('damdang'), // 담당
|
||||
'vrfcreq_way' => $this->request->getGet('vrfcreq_way'), // 검증방식1
|
||||
'vrfc_type_sub' => $this->request->getGet('vrfc_type_sub'), // 검증방식2
|
||||
'rcpt_cpid' => $this->request->getGet('rcpt_cpid'), // 매체사
|
||||
'rlet_type_cd' => $this->request->getGet('rlet_type_cd'), // 매물종류
|
||||
'chk_spc_yn' => $this->request->getGet('chk_spc_yn'), // 면적확인
|
||||
'reference_file_url_yn' => $this->request->getGet('reference_file_url_yn'), // 참고용
|
||||
'corp_own' => $this->request->getGet('corp_own'), // 법인소유
|
||||
];
|
||||
|
||||
$datas = $this->model->getExcelList($data);
|
||||
|
||||
return $this->response->setJSON(body: [
|
||||
'data' => $datas,
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$e->getPrevious()->getTraceAsString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 상세화면
|
||||
public function detail($id): string
|
||||
{
|
||||
$id = (int) $id;
|
||||
$naver = new NaverApiClient();
|
||||
$id = (string) $id;
|
||||
|
||||
if ($id <= 0) {
|
||||
if ($id === '') {
|
||||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
@@ -138,6 +74,30 @@ class M713 extends BaseController
|
||||
|
||||
$sido = $this->model->getAreaList(); // 지역조회
|
||||
|
||||
$hscp_info = [];
|
||||
if (!empty($data['hscp_no'])) {
|
||||
$apt_rlet_type_cd = ['A01', 'A02', 'A03', 'A04', 'B01', 'B02', 'B03'];
|
||||
$villa_rlet_type_cd = ['A05', 'A06'];
|
||||
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $apt_rlet_type_cd)) { // apt 단지
|
||||
$detail_hscp = $naver->aptDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
if (in_array($data['rlet_type_cd'], $villa_rlet_type_cd)) { // villa 단지
|
||||
$detail_hscp = $naver->villaDetail($data['hscp_no']);
|
||||
}
|
||||
|
||||
// print_r($data);
|
||||
// print_r($detail_hscp);
|
||||
// exit;
|
||||
|
||||
if (!empty($detail_hscp) && isset($detail_hscp['result'])) {
|
||||
$hscp_info = $detail_hscp['result'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->data['codes'] = $codes;
|
||||
$this->data['data'] = $data;
|
||||
$this->data['memo'] = $memo;
|
||||
@@ -145,6 +105,7 @@ class M713 extends BaseController
|
||||
$this->data['regist'] = $regist;
|
||||
$this->data['display'] = $display;
|
||||
$this->data['sido'] = $sido;
|
||||
$this->data['hscp_info'] = $hscp_info;
|
||||
|
||||
return view("pages/v2/m713/detail", $this->data);
|
||||
}
|
||||
@@ -293,6 +254,414 @@ class M713 extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function saveModify()
|
||||
{
|
||||
try {
|
||||
|
||||
$vr_sq = $this->request->getPost('vr_sq');
|
||||
$owner_birth = $this->request->getPost('owner_birth');
|
||||
$address2 = $this->request->getPost('address2');
|
||||
$address2a = $this->request->getPost('address2a');
|
||||
$address2b = $this->request->getPost('address2b');
|
||||
$address3 = $this->request->getPost('address3');
|
||||
$address4 = $this->request->getPost('address4');
|
||||
$address_code = $this->request->getPost('dong');
|
||||
$hscp_no = $this->request->getPost('hscp_no');
|
||||
$hscp_nm = $this->request->getPost('hscp_nm');
|
||||
$owner_birth = trim($owner_birth);
|
||||
|
||||
$this->model->modify_info($vr_sq, $owner_birth, $address2, $address2a, $address2b, $address3, $address4, $address_code, $hscp_no, $hscp_nm);
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 등기부등본 저장
|
||||
public function saveRegi()
|
||||
{
|
||||
/*
|
||||
1.0.1 POST 데이터 받기.
|
||||
1.1.1 1차 검증인지 2차검증인지 확인.
|
||||
1.1.2 1차, 2차 검증이면 v2_confirm.type에 넣을 값을 알맞게 셋팅.
|
||||
1.2.1 v2_confirms에 데이터가 있는지 확인.
|
||||
1.3.1 데이터가 있음 : success 여부 판단 후 updateConfirm 실행 success값만 UPDATE. (수정변경이력 저장)
|
||||
1.4.1 데이터가 없음 : success 여부 판단 후 insertConfirm 실행 v2_confirms INSERT. (수정변경이력 저장)
|
||||
1.4.2 상태변경 하기 : 등기부등본 확인중 상태로 변경. (수정변경이력 저장)
|
||||
1.5.1 이미지파일 서버에 UPLOAD (수정변경이력 저장)
|
||||
1.6.1 기존파일 탐색.
|
||||
1.7.1 기존파일 있음 : 기존파일 use_yn 'N'으로 UPDATE 후 v2_files INSERT.
|
||||
1.8.1 기존파일 없음 : v2_files INSERT.
|
||||
1.9.1 매물주소, 의뢰인 정보 v2_check_list INSERT. (수정변경이력 저장)
|
||||
1.10.1 API 전송.
|
||||
1.11.1 API 전송결과 : SUCCESS 이면 상태값 변경 : 등기부등본 확인완료 상태. (수정변경이력 저장)
|
||||
*/
|
||||
|
||||
$naver = new NaverApiClient();
|
||||
$model710 = new M710Model();
|
||||
$model415 = new M415Model();
|
||||
$v2DailyModel = new V2StDailyModel();
|
||||
|
||||
try {
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
$toDay = date('Y-m-d H:i:s');
|
||||
$atcl_vrtc_way = 'R'; //검증구분
|
||||
$atcl_vr_sq = $this->request->getPost('rcpt_key');
|
||||
// $atcl_no = $this->request->getPost('atcl_no');
|
||||
$reg_conf_yn_1 = $this->request->getPost('reg_conf_yn_1'); //확인내용
|
||||
$reg_conf_yn_2 = $this->request->getPost('reg_conf_yn_2'); //매물주소
|
||||
$reg_conf_yn_3 = $this->request->getPost('reg_conf_yn_3'); //의뢰인정보
|
||||
$reg_conf_yn_info_2 = $this->request->getPost('reg_conf_yn_info_2'); //매물주소
|
||||
$reg_conf_yn_info_3 = $this->request->getPost('reg_conf_yn_info_3'); //의뢰인정보
|
||||
$memo = $this->request->getPost('memo'); //메모
|
||||
$owner_verifiable = $this->request->getPost('owner_verifiable'); //실소유주 확인여부
|
||||
$noimg_chk_chk = $this->request->getPost('noimg_chk_chk'); // 등기부등본이미지 파일없음.
|
||||
$img_chk_chk = $this->request->getPost('img_chk_chk'); // 등기소, 리얼탑 열람, 리얼탑 기열람, 열람
|
||||
$atcl_vrtc_type = $this->request->getPost('atcl_vrtc_type'); // 검증구분
|
||||
$vrfc_type_sub = $this->request->getPost('vrfc_type_sub'); // 하위검증구분
|
||||
$arr_uncnfrm_status = $this->request->getPost('arr_uncnfrm_status'); // 등기부등본 미확인여부 상세
|
||||
|
||||
//상태가 이미 등기부등본확인중 이상이면 저장하지 않는다.
|
||||
$resStat = $this->model->chkStat($atcl_vr_sq);
|
||||
$v2_vrfc_req = $v2DailyModel->get_v2_vrfc_req($atcl_vr_sq);
|
||||
$rlet_type_cd = $model415->get_rlet_type_cd($atcl_vr_sq);
|
||||
|
||||
if ((int) $resStat['stat_cd'] >= 60 || (int) $resStat['stat_cd'] == 19) {
|
||||
throw new \Exception('이미 저장된 데이터입니다.');
|
||||
} else {
|
||||
$resultCnt = $this->model->chkRegiTryCnt($atcl_vr_sq); //1차검증인지 2차검증인지 확인 쿼리 : v2_vrfc_req.type_cnt
|
||||
if ($resultCnt['reg_try_cnt'] == 0) { // 1차 검증일 때
|
||||
log_message('debug', '713 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 0 ');
|
||||
$try_cnt = '1';
|
||||
} else if ($resultCnt['reg_try_cnt'] == 1) { // 2차 검증일 때
|
||||
log_message('debug', '713 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 1 ');
|
||||
$try_cnt = '2';
|
||||
} else {
|
||||
log_message('debug', '713 page >> 매물번호 : ' . $atcl_vr_sq . ' 등기부등본 불일치 횟수 : 예외처리 ');
|
||||
$try_cnt = '2';
|
||||
//$try_cnt = intval($try_cnt) + 1;
|
||||
}
|
||||
|
||||
$result = $this->model->chkConfirm($atcl_vr_sq, $atcl_vrtc_way);
|
||||
if ($result == 0) { //v2_confirm 존재하지 않는다면
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 1, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
// 수정한 시간이 현재시간10분전 보다 클 경우 수정불가능
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
}
|
||||
$this->model->insertConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type, $try_cnt);
|
||||
} else {
|
||||
if ($reg_conf_yn_2 == '10000' && $reg_conf_yn_3 == '10000') { //success 여부 판단
|
||||
$chk_type = '1';
|
||||
//$chk_delay = '0'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
} else {
|
||||
// 2015.06.29 추가
|
||||
// 불일치가 날 경우에 10분 이내에 다시 불일치 처리 불가능(같은 매물을 두사람이 중복처리할 가능성 사전 방지)
|
||||
// 1. 현재 매물의 마지막으로 업데이트 된 시간을 가져옴.
|
||||
// 2. 현재 시간과 비교하여 10분 이내면 경고창을 띄어줌.
|
||||
|
||||
$chk_type = '0';
|
||||
//$chk_delay = '1'; //지연여부
|
||||
//$chk_zombie = '0'; //좀비매물
|
||||
|
||||
$result_tm = $this->model->getUpdateFailTime($atcl_vr_sq);
|
||||
$update_tm = $result_tm['insert_tm'];
|
||||
$ten_ago = date("Y-m-d H:i:s", mktime(date("H"), date("i") - 1, date("s"), date("m"), date("d"), date("Y")));
|
||||
|
||||
if ($update_tm > $ten_ago) {
|
||||
// 수정한 시간이 현재시간10분전 보다 클 경우 수정불가능
|
||||
throw new \Exception('이미 불일치 처리 된 매물입니다.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->model->updateConfirm($atcl_vr_sq, $atcl_vrtc_way, $chk_type);
|
||||
}
|
||||
|
||||
|
||||
$this->model->InsResChar($atcl_vr_sq); //담당자 업데이트
|
||||
|
||||
// 모바일v1,v2고 등기부등본 미확인여부 상세 저장
|
||||
if ($vrfc_type_sub == 'M1' || $vrfc_type_sub == 'O1') {
|
||||
$this->model->add_cert_uncnfrm_status($atcl_vr_sq, $arr_uncnfrm_status);
|
||||
if (strpos($arr_uncnfrm_status, '20020') !== false) { //등기부등본 미확인여부 상세에 20020(파일 오첨부)있고
|
||||
if ($vrfc_type_sub == 'M1') { // 모바일v1일땐 코드 20020,코멘트x
|
||||
$reg_conf_yn_2 = '20020';
|
||||
$reg_conf_yn_info_2 = '';
|
||||
} else { // 모바일v2일땐 일반 불일치코드,코멘트=파일 오첨부
|
||||
$reg_conf_yn_info_2 = '파일 오첨부';
|
||||
}
|
||||
}
|
||||
}
|
||||
//v2_check_list 확인여부 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '21', $reg_conf_yn_2, $reg_conf_yn_info_2);
|
||||
|
||||
//v2_check_list 매물주소 INSERT
|
||||
$this->model->insertChkList($atcl_vr_sq, $atcl_vrtc_way, '22', $reg_conf_yn_3, $reg_conf_yn_info_3);
|
||||
|
||||
//memo 저장
|
||||
$this->model->saveMemo([$memo, $atcl_vr_sq]);
|
||||
|
||||
//실소유주 확인 저장
|
||||
$this->model->update_owner_verifiable($atcl_vr_sq, $owner_verifiable);
|
||||
|
||||
$sendData = $this->model->getDatacertAPI($atcl_vr_sq, 'R');
|
||||
|
||||
//이미지 파일 없음 && 홍보확인서 V2일 경우
|
||||
log_message('debug', '713 noimage_chk_chk sendData_return1 => ' . $sendData['atclNo'] . ' ::: ' . json_encode($sendData) . PHP_EOL);
|
||||
if ($noimg_chk_chk == "Y" && $sendData['vrfcType'] == "D2") {
|
||||
// $sendData['ownerVerifiable'] = false;
|
||||
}
|
||||
|
||||
$d_yn = $model710->get_send_yn('O');
|
||||
if ($d_yn['stop_yn'] == 'N') { //전송금지
|
||||
//1.해당매물정보를v2_stop_api_save_info에다 넣음
|
||||
$model710->insert_v2_stop_api_save_info($sendData['atclNo'], $atcl_vr_sq, 'O', '');
|
||||
//2.아무렇지않게 행동한다
|
||||
$send_result['result'] = 'success';
|
||||
} else {
|
||||
//API 호출
|
||||
$send_result = $naver->certification($sendData['atclNo'], $try_cnt, $sendData['success'], $sendData['checkList'], $sendData['charger'], $sendData['date'], $sendData['modifyInfo'], $sendData['ownerVerifiable']);
|
||||
}
|
||||
|
||||
if ($send_result['result'] == 'success') {
|
||||
if ($chk_type == '1') {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '45', $toDay);
|
||||
$chgVrfc45 = $this->model->chgStatVrfc($atcl_vr_sq, '45'); //v2_vrfc_req INSERT
|
||||
$statFaxUp45 = $this->model->chgStatFax($atcl_vr_sq, '45'); //fax_imgs
|
||||
|
||||
//상태변경 TABLE INSERT : 검증완료 상태로 변경
|
||||
$this->model->chgStat($atcl_vr_sq, '60', $toDay);
|
||||
$chgVrfc60 = $this->model->chgStatVrfc($atcl_vr_sq, '60'); //v2_vrfc_req INSERT
|
||||
$statFaxUp60 = $this->model->chgStatFax($atcl_vr_sq, '60'); //fax_imgs
|
||||
|
||||
// ★ 검증완료
|
||||
//0.불일치 이력이 있는지 확인
|
||||
$cnt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
if (empty($cnt)) { //검증완료일땐 불일치가없어야 통계포함된다
|
||||
if ($atcl_vrtc_type == 'M' || $atcl_vrtc_type == 'O') { //모바일은 등기가 첨 시작이니까 insert해줘야함
|
||||
if (!($atcl_vrtc_type == 'M' && in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03')))) {//만약 분양권들이면 넘어가고 아니면 체크
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인완료 시간
|
||||
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
|
||||
//3.검증완료시간
|
||||
$finishTime = $model415->get_60_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인완료 시간
|
||||
$cert_comple_dt = $model415->get_cert_confTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
|
||||
}
|
||||
}
|
||||
if ($noimg_chk_chk == 'Y') {
|
||||
$this->model->chgStat($atcl_vr_sq, '70', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'Y'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0103', '1', 'add'); // 등기부등본이미지 없음 저장
|
||||
}
|
||||
if ($img_chk_chk == 'O') {
|
||||
$this->model->chgStat($atcl_vr_sq, '76', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'O'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0105', '1', 'add'); // (열람)간소화확인으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'T') {
|
||||
$this->model->chgStat($atcl_vr_sq, '80', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'T'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0111', '1', 'add'); // 등기소로 일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'R') {
|
||||
$this->model->chgStat($atcl_vr_sq, '86', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'R'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0107', '1', 'add'); // 리얼탑 열람 일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
} else if ($img_chk_chk == 'G') {
|
||||
$this->model->chgStat($atcl_vr_sq, '87', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'G'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0108', '1', 'add'); // 리얼탑 기열람 일치으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0101', '1', 'add'); // 일치로 저장
|
||||
}
|
||||
} else {
|
||||
if ($atcl_vrtc_type == 'M') {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
|
||||
$result_query7 = $this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$chgVrfc49 = $this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$statFaxUp49 = $this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$res_try = $this->model->chgRegiTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$result_query9 = $this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$chgVrfc69 = $this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$statFaxUp69 = $this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
// ★모바일이고 검증실패
|
||||
if (!in_array($rlet_type_cd['rlet_type_cd'], array('B01', 'B02', 'B03'))) {//만약 분양권들이면 넘어가고 아니면 체크
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
}
|
||||
} else {
|
||||
//상태변경 TABLE INSERT : 등기부등본 확인 불일치 상태로 변경
|
||||
$result_query7 = $this->model->chgStat($atcl_vr_sq, '49', $toDay);
|
||||
$chgVrfc49 = $this->model->chgStatVrfc($atcl_vr_sq, '49'); //v2_vrfc_req INSERT
|
||||
$statFaxUp49 = $this->model->chgStatFax($atcl_vr_sq, '49'); //fax_imgs
|
||||
|
||||
//등기부등본 확인중 상태로 변경.
|
||||
$this->model->saveChangedHistory($atcl_vr_sq, '30', 'C9', $usr_id, '상태변경 : 49 => 30'); //검증결과 변동사항 HISTORY
|
||||
$chgVrfc40 = $this->model->chgStatVrfc($atcl_vr_sq, '30'); //v2_vrfc_req INSERT
|
||||
$statFaxUp40 = $this->model->chgStatFax($atcl_vr_sq, '30'); //fax_imgs
|
||||
|
||||
if ($try_cnt == '1') {
|
||||
//v2_vrfc_req try_cnt 값을 1로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '1');
|
||||
if ($atcl_vrtc_type == 'T') {
|
||||
//검증구분이 전화매물일 경우 사전에 일치로 처리된 값을 초기화 시켜준다.
|
||||
$reset_query = $this->model->resetTelConf($atcl_vr_sq);
|
||||
}
|
||||
|
||||
// ★1차실패
|
||||
if ($atcl_vrtc_type == 'O') {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$sf = 'F';
|
||||
$model415->update_v2_time_required_Conf($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $sf);
|
||||
}
|
||||
} else if ($try_cnt == '2') {
|
||||
//v2_vrfc_req try_cnt 값을 2로 update
|
||||
$this->model->chgRegiTryCnt($atcl_vr_sq, '2');
|
||||
|
||||
//상태변경 TABLE INSERT : 검증실패 상태로 변경.
|
||||
$result_query9 = $this->model->chgStat($atcl_vr_sq, '69', $toDay);
|
||||
$chgVrfc69 = $this->model->chgStatVrfc($atcl_vr_sq, '69'); //v2_vrfc_req INSERT
|
||||
$statFaxUp69 = $this->model->chgStatFax($atcl_vr_sq, '69'); //fax_imgs
|
||||
|
||||
// ★모바일 이외 검증실패
|
||||
if ($atcl_vrtc_type == 'O') {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_M_timeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.검증실패시간
|
||||
$finishTime = $model415->get_69_ForHistory($atcl_vr_sq);
|
||||
//4.해당 정보를 테이블에 넣는다
|
||||
$model415->insert_v2_time_required_M($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm'], $finishTime['insert_tm']);
|
||||
} else {
|
||||
//1.등기부등본 확인중 시간
|
||||
$tel_doc_conf_dt = $model415->get_cert_ing_TimeForHistory($atcl_vr_sq);
|
||||
//2.등기부등본 확인실패 시간
|
||||
$cert_comple_dt = $model415->get_cert_failTimeForHistory($atcl_vr_sq);
|
||||
//3.해당 정보를 테이블에 넣는다
|
||||
$model415->update_v2_time_required_Conf_Done($v2_vrfc_req['atcl_no'], $v2_vrfc_req['cpid'], $atcl_vrtc_type, $tel_doc_conf_dt['insert_tm'], $cert_comple_dt['insert_tm']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($noimg_chk_chk == 'Y') {
|
||||
$this->model->chgStat($atcl_vr_sq, '70', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'Y'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0103', '1', 'add'); // 등기부등본이미지 없음 저장
|
||||
}
|
||||
if ($img_chk_chk == 'O') {
|
||||
$this->model->chgStat($atcl_vr_sq, '77', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'O'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0105', '1', 'add'); // (열람)간소화확인으로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'T') {
|
||||
$this->model->chgStat($atcl_vr_sq, '85', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'T'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0112', '1', 'add'); // 등기소 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'R') {
|
||||
$this->model->chgStat($atcl_vr_sq, '88', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'R'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0109', '1', 'add'); // 리얼탑 열람 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
} else if ($img_chk_chk == 'G') {
|
||||
$this->model->chgStat($atcl_vr_sq, '89', $toDay);
|
||||
$this->model->updateStat($atcl_vr_sq, 'G'); // reg_status를 업데이트해준다.
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0110', '1', 'add'); // 리얼탑 기열람 불일치로 저장
|
||||
$v2DailyModel->set_v2_st_daily(NULL, $v2_vrfc_req['cpid'], 'R0102', '1', 'add'); // 불일치로 저장
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($send_result['error'])) {
|
||||
$error_message = $send_result['error']['code'] . "\\n" . $send_result['error']['message'];
|
||||
|
||||
// API 호출 에러 발생시 해당 내용들을 DB에 저장해준다.
|
||||
$err_time = date("Y-m-d H:i:s");
|
||||
$this->model->saveApiErr($atcl_vr_sq, $send_result['error']['code'], $send_result['error']['message'], $err_time, $v2_vrfc_req['atcl_no']);
|
||||
throw new \Exception($error_message);
|
||||
} else {
|
||||
throw new \Exception('네이버 전송 중 오류가 발생되었습니다. 다시 시도하세요.');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->response->setJSON([
|
||||
'code' => '0',
|
||||
'msg' => 'success'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->response->setJSON([
|
||||
'code' => '9',
|
||||
'msg' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// 다음매물확인
|
||||
public function nextRegi()
|
||||
{
|
||||
|
||||
75
app/Controllers/V2/V2StDailyModel.php
Normal file
75
app/Controllers/V2/V2StDailyModel.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
namespace App\Controllers\V2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class V2StDailyModel extends Model
|
||||
{
|
||||
/**
|
||||
* 일자별 통계데이터에 값 집어 넣기...
|
||||
* 반환값 없음.
|
||||
* @param date $sd_date 날짜 값이 없을경우 현재날짜로 입력됨.
|
||||
* @param string $cpid CPID
|
||||
* @param string $gbn_cd 코드값 (category='STATISTICS_DAILY3')
|
||||
* @param int $cnt 더할 숫자..
|
||||
* @param string $cnt_type 숫자를 더할것인지.. 아니변 변경할것인지.
|
||||
*/
|
||||
public function set_v2_st_daily($st_date, $cpid, $gbn_cd, $cnt, $cnt_type = 'add')
|
||||
{
|
||||
/**
|
||||
* insert into v2_st_daily (sd_date, cpid, gbn_cd, cnt) values ($sd_date, $cpid, $gbn_cd, $cnt)
|
||||
* on duplicate key update cnt = values(cnt); // $cnt_type='change'
|
||||
* on duplicate key update cnt = cnt + $cnt; // $cnt_type='add'
|
||||
*/
|
||||
if (empty($cnt))
|
||||
$cnt = '0';
|
||||
|
||||
$sql_dup = "";
|
||||
switch (strtolower($cnt_type)) {
|
||||
case 'add':
|
||||
$sql_dup = "on duplicate key update cnt = cnt + " . $cnt;
|
||||
break;
|
||||
|
||||
case 'change':
|
||||
$sql_dup = "on duplicate key update cnt = values(cnt)";
|
||||
break;
|
||||
}
|
||||
if (empty($st_date)) {
|
||||
$sql = "insert into v2_st_daily (st_date, cpid, gbn_cd, cnt) values (now(), ?, ?, ?)" . $sql_dup;
|
||||
$data = array(
|
||||
$cpid,
|
||||
$gbn_cd,
|
||||
$cnt
|
||||
);
|
||||
} else {
|
||||
$sql = "insert into v2_st_daily (st_date, cpid, gbn_cd, cnt) values (?, ?, ?, ?)" . $sql_dup;
|
||||
$data = array(
|
||||
$st_date,
|
||||
$cpid,
|
||||
$gbn_cd,
|
||||
$cnt
|
||||
);
|
||||
}
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
$return['error_number'] = $this->db->_error_number();
|
||||
$return['error_message'] = $this->db->_error_message();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 지정한 매물의 요청번호를 이용하여 요청내역을 가져온다.
|
||||
*/
|
||||
public function get_v2_vrfc_req($vr_sq)
|
||||
{
|
||||
$columns = "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,memo,contact_fail_cnt,sync_yn,reg_try_cnt";
|
||||
$builder = $this->db->table('v2_vrfc_req');
|
||||
$builder->select($columns, false);
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$row = $builder->get()->getRowArray();
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
204
app/Controllers/Webfax/Crontab.php
Normal file
204
app/Controllers/Webfax/Crontab.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\webfax\FaxModel;
|
||||
use App\Libraries\Qrcode;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
|
||||
class Crontab extends BaseController
|
||||
{
|
||||
/**
|
||||
* Fax 수신 이미지(tiff)를 jpg로 변경하고 Thumbnail을 만드는 작업...
|
||||
* (CLI 전용)
|
||||
*/
|
||||
public function convertedFaxImages()
|
||||
{
|
||||
// ✅ CLI 전용 보호
|
||||
if (!is_cli()) {
|
||||
throw new PageNotFoundException();
|
||||
}
|
||||
|
||||
/** @var FaxModel $faxModel */
|
||||
$faxModel = model(FaxModel::class);
|
||||
$qrCode = new Qrcode();
|
||||
|
||||
$res = $faxModel->selectFaxListNotExistsThumb();
|
||||
$fileCnt = 0;
|
||||
$receiver = 'uds_tiff';
|
||||
|
||||
if (empty($res)) {
|
||||
CLI::write('No target fax images.', 'yellow');
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($res as $row) {
|
||||
$fileCnt++;
|
||||
CLI::write("\n\n[{$fileCnt}] Processing...", 'green');
|
||||
|
||||
$mid = $row['mid'] ?? null;
|
||||
$file_name = $row['file_name'] ?? '';
|
||||
$save_path = $row['save_path'] ?? '';
|
||||
$caller_no = $row['caller_no'] ?? '';
|
||||
$callee_no = $row['callee_no'] ?? '';
|
||||
$tiff_file_name = $row['file_name'] ?? '';
|
||||
$tiff_file_size = $row['file_size'] ?? '';
|
||||
$recv_time = $row['recv_time'] ?? '';
|
||||
$save_time = $row['save_time'] ?? '';
|
||||
|
||||
if (empty($save_path) || empty($file_name)) {
|
||||
CLI::write(' - skip: save_path or file_name empty', 'yellow');
|
||||
continue;
|
||||
}
|
||||
|
||||
// ✅ pathinfo로 안전하게 처리
|
||||
$ext = strtolower(pathinfo($file_name, PATHINFO_EXTENSION));
|
||||
$base = pathinfo($file_name, PATHINFO_FILENAME);
|
||||
|
||||
if (!in_array($ext, ['tif', 'tiff'], true)) {
|
||||
CLI::write(" - skip: not tif/tiff ({$ext})", 'yellow');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (substr($save_path, -1) !== '/') {
|
||||
$save_path .= '/';
|
||||
}
|
||||
|
||||
$tiffPath = $save_path . $file_name;
|
||||
if (!is_file($tiffPath)) {
|
||||
CLI::write(" - skip: file not found ({$tiffPath})", 'yellow');
|
||||
continue;
|
||||
}
|
||||
|
||||
CLI::write(" - TIFF: {$tiffPath}");
|
||||
|
||||
try {
|
||||
// ✅ TIFF 다중 페이지 안전 처리
|
||||
$im = new \Imagick();
|
||||
$im->readImage($tiffPath);
|
||||
|
||||
// coalesce: 멀티프레임 안정화(특히 tiff/gif 계열)
|
||||
$frames = $im->coalesceImages();
|
||||
|
||||
$index = 0;
|
||||
foreach ($frames as $frame) {
|
||||
try {
|
||||
// 페이지별 정보
|
||||
$image_width = (int) $frame->getImageWidth();
|
||||
$image_height = (int) $frame->getImageHeight();
|
||||
$image_size = (int) $frame->getImageLength();
|
||||
|
||||
// 출력 경로
|
||||
$jpgName = "{$base}_{$index}.jpg";
|
||||
$jpgPath = $save_path . $jpgName;
|
||||
$thumbName = "{$base}_{$index}_thumb.jpg";
|
||||
$thumbPath = $save_path . $thumbName;
|
||||
|
||||
// ✅ JPG로 변환(페이지별로 frame clone 사용 권장)
|
||||
$page = clone $frame;
|
||||
|
||||
// 이미지 포맷/품질(필요시 조정)
|
||||
$page->setImageFormat('jpeg');
|
||||
$page->setImageCompression(\Imagick::COMPRESSION_JPEG);
|
||||
$page->setImageCompressionQuality(85);
|
||||
|
||||
// ✅ 리사이즈 (가로 800 제한)
|
||||
if ($image_width > 800) {
|
||||
$resize_width = 800;
|
||||
$ratio = $resize_width / max(1, $image_width);
|
||||
$resize_height = (int) round($image_height * $ratio);
|
||||
$page->resizeImage($resize_width, $resize_height, \Imagick::FILTER_LANCZOS, 1, true);
|
||||
}
|
||||
|
||||
if (!$page->writeImage($jpgPath)) {
|
||||
CLI::write(" - fail: write jpg ({$jpgPath})", 'red');
|
||||
$page->clear();
|
||||
$page->destroy();
|
||||
$index++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// ✅ QR scan (실패해도 계속)
|
||||
$qrcode_data = '';
|
||||
try {
|
||||
$qrcode_data = (string) $qrCode->scan($jpgPath);
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'QR scan failed: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// ✅ 썸네일은 clone으로 (원본/페이지 훼손 방지)
|
||||
$thumb = clone $page;
|
||||
$thumb->thumbnailImage(105, 80, true);
|
||||
|
||||
if (!$thumb->writeImage($thumbPath)) {
|
||||
CLI::write(" - fail: write thumb ({$thumbPath})", 'red');
|
||||
// 그래도 JPG는 만들어졌으니 다음 진행은 정책에 따라 선택
|
||||
}
|
||||
|
||||
CLI::write(" - JPG: {$jpgPath}");
|
||||
CLI::write(" - THUMB: {$thumbPath}");
|
||||
|
||||
// ✅ DB 저장 (기존 시그니처 유지)
|
||||
$faxModel->insertFaxImgs(
|
||||
$mid,
|
||||
$jpgName,
|
||||
$save_path,
|
||||
$thumbName,
|
||||
$image_width,
|
||||
$image_height,
|
||||
$image_size,
|
||||
$qrcode_data,
|
||||
$caller_no,
|
||||
$callee_no,
|
||||
$tiff_file_name,
|
||||
$tiffPath,
|
||||
$tiff_file_size,
|
||||
$recv_time,
|
||||
$save_time,
|
||||
$receiver
|
||||
);
|
||||
|
||||
// ✅ 권한 처리 (에러 숨기지 말고 로그)
|
||||
if (!@chmod($jpgPath, 0666)) {
|
||||
log_message('error', "chmod failed: {$jpgPath}");
|
||||
}
|
||||
if (!@chmod($thumbPath, 0666)) {
|
||||
log_message('error', "chmod failed: {$thumbPath}");
|
||||
}
|
||||
|
||||
log_message('debug', $jpgPath);
|
||||
log_message('debug', $thumbPath);
|
||||
|
||||
// ✅ 메모리 정리(프레임 단위)
|
||||
$thumb->clear();
|
||||
$thumb->destroy();
|
||||
$page->clear();
|
||||
$page->destroy();
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', 'Frame 처리 실패: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
// 다음 페이지
|
||||
$index++;
|
||||
}
|
||||
|
||||
// ✅ 전체 메모리 정리
|
||||
$frames->clear();
|
||||
$frames->destroy();
|
||||
|
||||
$im->clear();
|
||||
$im->destroy();
|
||||
|
||||
gc_collect_cycles();
|
||||
|
||||
CLI::write(" - done.\n", 'green');
|
||||
} catch (\Throwable $e) {
|
||||
// 기존 writeLog 사용 중이면 그걸로 교체 가능
|
||||
log_message('error', 'TIFF 처리 실패: ' . $e->getMessage());
|
||||
CLI::write(" - error: " . $e->getMessage(), 'red');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,11 +13,32 @@ class AuthCheck implements FilterInterface
|
||||
$session = session();
|
||||
log_message('debug', 'URI PATH: ' . service('uri')->getPath());
|
||||
|
||||
try {
|
||||
// 세션 읽기 시도
|
||||
$loggedIn = $session->get('logged_in');
|
||||
|
||||
// 로그인 체크
|
||||
if (!$session->get('logged_in')) {
|
||||
if (!$loggedIn) {
|
||||
// 로그인 안 되어 있으면 로그인 페이지로
|
||||
return redirect()->to('/login');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 세션 오류 (Redis 다운 등) - 모든 예외 catch
|
||||
log_message('error', '[SESSION ERROR in AuthCheck] ' . $e->getMessage());
|
||||
|
||||
// AJAX 요청인 경우 JSON 응답
|
||||
if ($request->isAJAX()) {
|
||||
return service('response')
|
||||
->setStatusCode(503)
|
||||
->setJSON([
|
||||
'code' => '8',
|
||||
'msg' => '세션 서비스 오류입니다. 페이지를 새로고침 해주세요. (Redis)'
|
||||
]);
|
||||
}
|
||||
|
||||
// 일반 요청인 경우 로그인 페이지로 리다이렉트 (에러 메시지 포함)
|
||||
return redirect()->to('/login')->with('error', '세션 서비스 오류입니다. 시스템 관리자에게 문의해주세요.');
|
||||
}
|
||||
}
|
||||
|
||||
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
|
||||
|
||||
13
app/Helpers/cron_helper.php
Normal file
13
app/Helpers/cron_helper.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('get_linux_hostname')) {
|
||||
/**
|
||||
* hostname을 읽어옴... $_SERVER['HOSTNAME']을 대신해서 사용하기 위함.
|
||||
*/
|
||||
function get_linux_hostname()
|
||||
{
|
||||
preg_match('/HOSTNAME=(.*)/', file_get_contents('/etc/sysconfig/network'), $network);
|
||||
list($key, $hostname) = explode('=', $network[0]);
|
||||
return $hostname;
|
||||
}
|
||||
}
|
||||
@@ -7,40 +7,33 @@ if (!function_exists('limitHscpMarketPriceInfo')) {
|
||||
* @param string $ptp_no 평형코드
|
||||
* @param string $atcl_amt 가격
|
||||
*/
|
||||
function limitHscpMarketPriceInfo($CI, $trade_type, $hscp_no, $ptp_no, $atcl_amt)
|
||||
function limitHscpMarketPriceInfo($trade_type, $hscp_no, $ptp_no, $atcl_amt)
|
||||
{
|
||||
$return = array();
|
||||
|
||||
if (!empty($hscp_no) && !empty($ptp_no)) {
|
||||
|
||||
$hscpMarketPriceInfo = $CI->call_kiso_api->hscpMarketPriceInfo($hscp_no, $ptp_no);
|
||||
$naver = new \App\Libraries\NaverApiClient();
|
||||
$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)) {
|
||||
@@ -245,8 +238,17 @@ if (!function_exists('db_now')) {
|
||||
function db_now(?string $format = null)
|
||||
{
|
||||
if ($format) {
|
||||
|
||||
$mysqlFormat = strtr($format, [
|
||||
'Y' => '%Y', 'y' => '%y',
|
||||
'm' => '%m', 'n' => '%c',
|
||||
'd' => '%d', 'j' => '%e',
|
||||
'H' => '%H', 'h' => '%h',
|
||||
'i' => '%i', 's' => '%s',
|
||||
'A' => '%p', 'a' => '%p',
|
||||
]);
|
||||
// 포맷이 있으면 DATE_FORMAT(NOW(), '포맷') 형태로 생성
|
||||
return new \CodeIgniter\Database\RawSql("DATE_FORMAT(NOW(), '$format')");
|
||||
return new \CodeIgniter\Database\RawSql("DATE_FORMAT(NOW(), '$mysqlFormat')");
|
||||
}
|
||||
// 포맷이 없으면 기본 NOW() 반환
|
||||
return new \CodeIgniter\Database\RawSql('NOW()');
|
||||
@@ -307,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));
|
||||
}
|
||||
@@ -6,7 +6,7 @@ if (! function_exists('write_custom_log')) {
|
||||
*/
|
||||
function write_custom_log($message, $level = 'INFO', $type = 'service')
|
||||
{
|
||||
$logDir = WRITEPATH . 'logs/worker';
|
||||
$logDir = WRITEPATH . 'logs';
|
||||
if (!is_dir($logDir)) {
|
||||
@mkdir($logDir, 0777, true);
|
||||
}
|
||||
@@ -31,8 +31,8 @@ if (! function_exists('write_custom_log')) {
|
||||
}
|
||||
// ----------------------------
|
||||
|
||||
$suffix = ($type === 'failed') ? '_failed' : '';
|
||||
$logFile = $logDir . '/' . date('Y-m-d') . $suffix . '.log';
|
||||
$suffix = ($type === 'failed') ? '-failed' : '';
|
||||
$logFile = $logDir . '/log-' . date('Y-m-d') . $suffix . '.log';
|
||||
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$singleLine = str_replace(["\r", "\n", "\t"], " ", $message);
|
||||
|
||||
35
app/Helpers/query_log_helper.php
Normal file
35
app/Helpers/query_log_helper.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('write_query_log')) {
|
||||
/**
|
||||
* SQL 쿼리 로그를 writable/logs/sql-query-{date}.log에 기록
|
||||
*
|
||||
* @param string $message 로그 메시지
|
||||
* @param string $sql SQL 쿼리 (선택)
|
||||
*/
|
||||
function write_query_log(string $message, string $sql = '')
|
||||
{
|
||||
$logDir = WRITEPATH . 'logs';
|
||||
$logFile = $logDir . '/sql-query-' . date('Y-m-d') . '.log';
|
||||
|
||||
$timestamp = date('Y-m-d H:i:s');
|
||||
$logMessage = "[{$timestamp}] {$message}";
|
||||
|
||||
if (!empty($sql)) {
|
||||
$logMessage .= "\nSQL: {$sql}";
|
||||
}
|
||||
|
||||
$logMessage .= "\n" . str_repeat('-', 80) . "\n";
|
||||
|
||||
// 로그 디렉토리 확인 및 생성
|
||||
if (!is_dir($logDir)) {
|
||||
mkdir($logDir, 0755, true);
|
||||
}
|
||||
|
||||
// 파일에 쓰기
|
||||
file_put_contents($logFile, $logMessage, FILE_APPEND | LOCK_EX);
|
||||
|
||||
// log_message도 호출 (작동하면 좋고, 안되도 파일에는 기록됨)
|
||||
log_message('error', $message);
|
||||
}
|
||||
}
|
||||
82
app/Helpers/redis_helper.php
Normal file
82
app/Helpers/redis_helper.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('get_redis_connection')) {
|
||||
/**
|
||||
* Redis 연결을 반환하는 헬퍼 함수
|
||||
* .env 환경변수에서 설정을 읽어 Redis에 연결합니다.
|
||||
*
|
||||
* @param string $type 'worker' 또는 'session' (기본값: 'worker')
|
||||
* @return Redis|false Redis 객체 또는 연결 실패 시 false
|
||||
* @throws RedisException
|
||||
*/
|
||||
function get_redis_connection(string $type = 'worker')
|
||||
{
|
||||
$redis = new \Redis();
|
||||
|
||||
try {
|
||||
// 타입에 따라 다른 환경변수 사용
|
||||
if ($type === 'session') {
|
||||
$host = env('SESSION_REDIS_HOST', '127.0.0.1');
|
||||
$port = env('SESSION_REDIS_PORT', '6379');
|
||||
$database = env('SESSION_REDIS_DATABASE', '0');
|
||||
$password = env('SESSION_REDIS_PASSWORD', '');
|
||||
} else {
|
||||
// worker, default
|
||||
$host = env('REDIS_HOST', '127.0.0.1');
|
||||
$port = env('REDIS_PORT', '6379');
|
||||
$database = env('REDIS_DATABASE', '9');
|
||||
$password = env('REDIS_PASSWORD', '');
|
||||
}
|
||||
|
||||
// Redis 연결 (타임아웃: 0.5초)
|
||||
$timeout = 0.5;
|
||||
$success = $redis->connect($host, (int)$port, $timeout);
|
||||
|
||||
if (!$success) {
|
||||
log_message('error', "Redis connection failed: {$host}:{$port}");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 비밀번호 인증 (있는 경우)
|
||||
if (!empty($password)) {
|
||||
$redis->auth($password);
|
||||
}
|
||||
|
||||
// 데이터베이스 선택
|
||||
$redis->select((int)$database);
|
||||
|
||||
return $redis;
|
||||
|
||||
} catch (\RedisException $e) {
|
||||
log_message('error', "Redis connection error: " . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_redis_config')) {
|
||||
/**
|
||||
* Redis 설정 정보를 배열로 반환
|
||||
*
|
||||
* @param string $type 'worker' 또는 'session'
|
||||
* @return array Redis 설정 배열
|
||||
*/
|
||||
function get_redis_config(string $type = 'worker'): array
|
||||
{
|
||||
if ($type === 'session') {
|
||||
return [
|
||||
'host' => env('SESSION_REDIS_HOST', '127.0.0.1'),
|
||||
'port' => env('SESSION_REDIS_PORT', '6379'),
|
||||
'database' => env('SESSION_REDIS_DATABASE', '0'),
|
||||
'password' => env('SESSION_REDIS_PASSWORD', ''),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'host' => env('REDIS_HOST', '127.0.0.1'),
|
||||
'port' => env('REDIS_PORT', '6379'),
|
||||
'database' => env('REDIS_DATABASE', '9'),
|
||||
'password' => env('REDIS_PASSWORD', ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,151 @@ class Common
|
||||
return $pagination;
|
||||
}
|
||||
|
||||
/**
|
||||
* 워터마킹하기
|
||||
*/
|
||||
public function watermarking($imagePath, $watermark_info, $wmText, $cpid, $key = '')
|
||||
{
|
||||
$uploader = new MyUpload();
|
||||
|
||||
$wmImagePath = ''; // 워터마크 이미지의 경로
|
||||
$wmSpaceHeihgt = 0; // 워터마크 이미지 하단 공백
|
||||
$wmFont = ''; // 워터마크 텍스트(글꼴)
|
||||
$wmFontSize = 13; // 워터마크 텍스트(글꼴) 크기
|
||||
$wmTextHeight = 17; // 워터마크 텍스트의 높이
|
||||
$wmTextColor = '#FFFFFF'; // 워터마크 텍스트의 칼라
|
||||
$wmTextAlpha = 0.5; // 워터마크 텍스트 투명도
|
||||
|
||||
try {
|
||||
$img = new \Imagick();
|
||||
if (is_string($imagePath) && is_file($imagePath)) {
|
||||
$img->readImage($imagePath);
|
||||
} elseif (is_string($imagePath) && filter_var($imagePath, FILTER_VALIDATE_URL)) {
|
||||
$headers = @get_headers($imagePath, 1) ?: [];
|
||||
$blob = @file_get_contents($imagePath);
|
||||
$contentType = '';
|
||||
if (!empty($headers)) {
|
||||
$contentType = is_array($headers['Content-Type'] ?? null)
|
||||
? end($headers['Content-Type'])
|
||||
: ($headers['Content-Type'] ?? '');
|
||||
}
|
||||
log_message('info', '[watermarking] source url={url} status={status} content_type={ctype} size={size}', [
|
||||
'url' => $imagePath,
|
||||
'status' => is_array($headers) && isset($headers[0]) ? $headers[0] : '(no status)',
|
||||
'ctype' => $contentType,
|
||||
'size' => $blob === false ? 0 : strlen($blob),
|
||||
]);
|
||||
if ($blob === false) {
|
||||
throw new \RuntimeException('Failed to load image from URL');
|
||||
}
|
||||
$img->readImageBlob($blob);
|
||||
} else {
|
||||
$img->readImageBlob($imagePath);
|
||||
}
|
||||
|
||||
$hImg = $img->getImageHeight();
|
||||
$wImg = $img->getImageWidth();
|
||||
|
||||
foreach ($watermark_info as $watermark) {
|
||||
if (strtolower($watermark['cpid']) == strtolower($cpid)) {
|
||||
$img_w_min = intval($watermark['img_width_min']);
|
||||
$img_w_max = intval($watermark['img_width_max']);
|
||||
if (($img_w_min <= $wImg) and ($img_w_max >= $wImg)) {
|
||||
$wmImagePath = $watermark['wm_img_path'];
|
||||
$wmSpaceHeihgt = $watermark['wm_space'];
|
||||
$wmFont = $watermark['text_font'];
|
||||
$wmFontSize = intval($watermark['text_size']);
|
||||
$wmTextHeight = intval($watermark['text_pixel']);
|
||||
$wmTextColor = $watermark['text_color'];
|
||||
$wmTextAlpha = $watermark['text_opacity'] / 100;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($wmImagePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 워터마크 이미지 경로 처리
|
||||
if (substr($wmImagePath, 0, 1) == '/') {
|
||||
$wmImagePath = substr($wmImagePath, 1);
|
||||
}
|
||||
|
||||
// ROOTPATH와 결합하여 절대 경로 생성 (img 폴더는 프로젝트 루트에 있음)
|
||||
$fullWmPath = ROOTPATH . $wmImagePath;
|
||||
|
||||
if (!is_file($fullWmPath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$wm = new \Imagick($fullWmPath);
|
||||
$hWm = $wm->getImageHeight();
|
||||
$wWm = $wm->getImageWidth();
|
||||
|
||||
$wmImgLeft = floor(($wImg - $wWm) / 2);
|
||||
$wmImgTop = floor(($hImg - $hWm - $wmSpaceHeihgt - $wmTextHeight) / 2); // 워터마크 이미지의 위치 top
|
||||
$wmTxtTop = $wmImgTop + $hWm + $wmSpaceHeihgt + ($wmTextHeight * 0.6); // 워터마크 텍스트의 위치
|
||||
|
||||
$img->compositeImage($wm, \Imagick::COMPOSITE_OVER, $wmImgLeft, $wmImgTop);
|
||||
$wm->destroy();
|
||||
|
||||
// 워터마크 텍스트가 있는 경우에만 텍스트 그리기
|
||||
if (!empty($wmText)) {
|
||||
$draw = new \ImagickDraw();
|
||||
|
||||
// 폰트 경로: img/watermark/fonts/
|
||||
if (!empty($wmFont)) {
|
||||
$fontPath = ROOTPATH . 'img/watermark/fonts/' . $wmFont;
|
||||
if (is_file($fontPath)) {
|
||||
$draw->setFont($fontPath);
|
||||
}
|
||||
}
|
||||
|
||||
$draw->setFontSize($wmFontSize);
|
||||
$draw->setFillColor(new \ImagickPixel($wmTextColor));
|
||||
// $draw->setFillAlpha( $wmTextAlpha );
|
||||
$draw->setFillOpacity($wmTextAlpha); // 워터마크 텍스트 투명도 설정
|
||||
$draw->setTextAlignment(2); // center
|
||||
$draw->setStrokeAntialias(1);
|
||||
$draw->setStrokeWidth(1);
|
||||
$draw->setStrokeColor(new \ImagickPixel('#000000'));
|
||||
// $draw->setStrokeAlpha(0.1);
|
||||
$draw->setStrokeOpacity(0.1);
|
||||
$draw->annotation($wImg / 2, $wmTxtTop, $wmText);
|
||||
|
||||
$img->drawImage($draw);
|
||||
$draw->destroy();
|
||||
}
|
||||
|
||||
// $img->writeImage();
|
||||
|
||||
$watermark_img = $img->getImageBlob();
|
||||
|
||||
if (empty($key)) {
|
||||
throw new \RuntimeException('Empty upload key');
|
||||
}
|
||||
|
||||
$ok = $uploader->upload_object_storage_imagick2($key, $watermark_img);
|
||||
if (!$ok) {
|
||||
log_message('error', '[watermarking] upload failed key={key} cpid={cpid}', [
|
||||
'key' => $key,
|
||||
'cpid' => $cpid,
|
||||
]);
|
||||
}
|
||||
$img->destroy();
|
||||
|
||||
// $object_upload = $this->upload->upload_object_storage($imagePath , $imagePath , 'data');
|
||||
} catch (\Throwable $e) {
|
||||
log_message('error', '[watermarking] Exception: {message} at {file}:{line}', [
|
||||
'message' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 서버상의 위치를 웹상의 위치로 변경한다...
|
||||
|
||||
57
app/Libraries/FormValidation.php
Normal file
57
app/Libraries/FormValidation.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
class FormValidation
|
||||
{
|
||||
/**
|
||||
* 한글, 영문, 숫자, 대시, 언더바만 가능하게 한다. utf-8 기준.
|
||||
*
|
||||
* @param string $str 검증할 문자열
|
||||
* @param string|null $error 에러 메시지 (참조로 전달)
|
||||
* @return bool
|
||||
*/
|
||||
public function korean_alpha_dash(string $str, ?string &$error = null): bool
|
||||
{
|
||||
if (!preg_match('/^[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}0-9a-zA-Z_-]+$/u', $str)) {
|
||||
$error = '한글, 영문, 숫자, 대시, 언더바만 입력 가능합니다.';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 문자열 형식이 Date가 맞는지 확인한다.
|
||||
*
|
||||
* @param string $str 검증할 날짜 문자열
|
||||
* @param string $format 날짜 형식 (기본값: Y-m-d)
|
||||
* @param string|null $error 에러 메시지 (참조로 전달)
|
||||
* @return bool
|
||||
*/
|
||||
public function is_date(string $str, string $format = 'Y-m-d', ?string &$error = null): bool
|
||||
{
|
||||
try {
|
||||
if (empty($format)) {
|
||||
$format = 'Y-m-d';
|
||||
}
|
||||
|
||||
$date = strtotime($str);
|
||||
|
||||
if ($date === false) {
|
||||
$error = '올바른 날짜 형식이 아닙니다.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$strDate = date($format, $date);
|
||||
|
||||
if (strcmp($str, $strDate) !== 0) {
|
||||
$error = "날짜 형식이 {$format}와 일치하지 않습니다.";
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$error = '날짜 검증 중 오류가 발생했습니다.';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class MyUpload
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 업로드 요청
|
||||
* 파일 업로드 요청 (Object Storage 전용)
|
||||
* 추가일 2025.12.24
|
||||
* 작성자 - yangsh
|
||||
*/
|
||||
@@ -73,39 +73,40 @@ class MyUpload
|
||||
|
||||
$newName = $file->getRandomName();
|
||||
|
||||
// ✅ PHP 임시 업로드 파일 경로 (writable로 move() 필요 없음)
|
||||
// ✅ PHP 임시 업로드 파일 경로
|
||||
$tmpFile = $file->getTempName();
|
||||
if (!is_file($tmpFile)) {
|
||||
$this->set_error('upload_temp_file_missing');
|
||||
log_message('error', 'do_upload2 temp file missing: ' . $tmpFile);
|
||||
log_message('error', '[MyUpload] Temp file missing: ' . $tmpFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// ✅ 클라우드에 올라갈 "Key"를 직접 만든다 (로컬 경로 절대 넣지 말기)
|
||||
// 예시: upload/tmp/랜덤파일명 또는 upload/apt_file/{rcpt_no}/...
|
||||
// ✅ 클라우드에 올라갈 "Key"
|
||||
$objectKey = $filePath . $newName;
|
||||
|
||||
// 클라우드 업로드 (필수)
|
||||
$up = $this->upload_object_storage($objectKey, $tmpFile, 'file');
|
||||
|
||||
if ($up === false) {
|
||||
$this->set_error('upload_destination_cloud_error');
|
||||
$this->set_error('cloud_upload_failed');
|
||||
log_message('error', '[MyUpload] Cloud upload failed: ' . $objectKey);
|
||||
@unlink($tmpFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
// (선택) tmp 파일 삭제
|
||||
// tmp 파일 삭제
|
||||
@unlink($tmpFile);
|
||||
|
||||
$this->s3_data = [
|
||||
'object_key' => $objectKey,
|
||||
'object_storage_url' => $up['object_storage_url'] ?? null,
|
||||
'origin_name' => $file->getClientName(),
|
||||
'file_name' => basename($objectKey), // xxxx.jpg
|
||||
'base_name' => pathinfo($objectKey, PATHINFO_FILENAME), // xxxx
|
||||
'ext' => pathinfo($objectKey, PATHINFO_EXTENSION), // jpg
|
||||
'file_name' => basename($objectKey),
|
||||
'base_name' => pathinfo($objectKey, PATHINFO_FILENAME),
|
||||
'ext' => pathinfo($objectKey, PATHINFO_EXTENSION),
|
||||
];
|
||||
|
||||
|
||||
log_message('debug', 's3_data=' . json_encode($this->s3_data ?? null, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
|
||||
|
||||
log_message('info', '[MyUpload] Cloud upload success: ' . $objectKey);
|
||||
|
||||
return $this->s3_data;
|
||||
}
|
||||
@@ -386,6 +387,7 @@ class MyUpload
|
||||
'Key' => ltrim($object_storage_upload_path, '/'),
|
||||
'Body' => $blobData,
|
||||
'ACL' => 'public-read',
|
||||
'ContentType' => 'image/jpeg',
|
||||
]);
|
||||
|
||||
|
||||
|
||||
@@ -2,11 +2,22 @@
|
||||
|
||||
namespace App\Libraries;
|
||||
|
||||
use App\Models\common\CommonModel;
|
||||
use App\Models\v2\M712Model;
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class NaverApiClient
|
||||
{
|
||||
protected $baseUrl = 'https://test-b2b.land.naver.com';
|
||||
protected $charger = '';
|
||||
|
||||
private $commonModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->commonModel = new CommonModel();
|
||||
}
|
||||
|
||||
/**
|
||||
* [GET] 매물 정보 조회
|
||||
*/
|
||||
@@ -21,16 +32,231 @@ class NaverApiClient
|
||||
/**
|
||||
* [PUT] 매물 정보 수정
|
||||
* @param string $articleNumber 매물번호
|
||||
* @param string charger 변경자
|
||||
* @param array $updateData 수정할 데이터 (tradeType, price, space 등)
|
||||
* string $tradeType 거래유형 (SALE:매매, JEONSE:전세, MONTHLY_RENT:월세, PRE_SALE:분양)
|
||||
* boolean $isResidntsExistence 거주여부
|
||||
* object $address 주소정보 공동 (complexNumber, pyeongTypeNumber, buildingName, hoName, correspondenceFloorCount) 비공동(legalDivisionNumber,jibunAddress,liAddress,etcAddress,referenceAddress,longitude,latitude,correspondenceFloorCount,totalFloorCount,undergroundFloorCount)
|
||||
* object $price 가격정보 (dealAmount,warrantyAmount,leaseAmount,preSaleAmount,premiumAmount,preSaleOptionAmount)
|
||||
* object $space 면적정보[비공동] (supplySpace,exclusiveSpace,totalSpace,groundSpace,buildingSpace)
|
||||
* object $facilities 비공동시설정보 (roomCount)
|
||||
*/
|
||||
/** 현장확인 수정시 */
|
||||
public function updateArticleInfo(string $articleNumber, array $updateData, string $charger = 'admin'): ?array
|
||||
{
|
||||
$this->charger = $charger;
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-site/{$articleNumber}?charger={$this->charger}";
|
||||
|
||||
log_message('info', "[updateArticleInfo] 호출됨 - URL: {$url}, 데이터: " . json_encode($updateData, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
$result = $this->request('PUT', $url, $updateData);
|
||||
|
||||
log_message('info', "[updateArticleInfo] 결과 - " . ($result === null ? 'NULL' : json_encode($result, JSON_UNESCAPED_UNICODE)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** 일반매물 수정시 */
|
||||
public function v2updateArticleInfo(string $articleNumber, array $updateData, string $charger = 'admin'): ?array
|
||||
{
|
||||
$this->charger = $charger;
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-article/{$articleNumber}?charger={$this->charger}";
|
||||
|
||||
return $this->request('PUT', $url, $updateData);
|
||||
log_message('info', "[v2updateArticleInfo] 호출됨 - URL: {$url}, 데이터: " . json_encode($updateData, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
$result = $this->request('PUT', $url, $updateData);
|
||||
|
||||
log_message('info', "[v2updateArticleInfo] 결과 - " . ($result === null ? 'NULL' : json_encode($result, JSON_UNESCAPED_UNICODE)));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* [POST] 4.매물검증 결과관리
|
||||
* API:POST /kiso/center/verification-article/{매물번호}/report?charger={담당자명}
|
||||
* @param string $articleNumber 매물번호
|
||||
* @param string charger 변경자
|
||||
* @param array $reportData 검증결과데이터
|
||||
* string $reportType 검증결과유형 (검증통과:VERIFIED, 검증실패:FAILED, 최종실패:REJECTED)
|
||||
* array $verificationConfirms 검증결과목록
|
||||
* string $ownerBirthDate 소유자 생년월일
|
||||
* Boolean $isOwnerVerifiable 소유자 검증여부
|
||||
*/
|
||||
public function postArticleVerificationReport(string $articleNumber, array $reportData, string $charger = 'admin'): ?array
|
||||
{
|
||||
$this->charger = $charger;
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-article/{$articleNumber}/report?charger={$this->charger}";
|
||||
|
||||
return $this->request('POST', $url, $reportData);
|
||||
}
|
||||
|
||||
/**
|
||||
* [POST] 5.현장확인 정보 전송
|
||||
* API:POST /kiso/center//verification-article/media/{매물번호}
|
||||
* @param string $articleNumber 매물번호
|
||||
* @param array $movies 동영상 ($url)
|
||||
* @param array $photos 사진 ($fileName, $url)
|
||||
* @param array photo360s 360사진 ($fileName, $url, $desc)
|
||||
* @param string $charger 변경자
|
||||
*/
|
||||
public function postArticleMediaInfo(string $articleNumber, array $movies, array $photos, array $photo360s, string $charger = 'admin'): ?array
|
||||
{
|
||||
$this->charger = $charger;
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-article/media/{$articleNumber}?charger={$this->charger}";
|
||||
|
||||
$data = [
|
||||
'movies' => $movies,
|
||||
'photos' => $photos,
|
||||
'photo360s' => $photo360s
|
||||
];
|
||||
|
||||
return $this->request('POST', $url, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* [POST] 6.매물 정보 가격수정
|
||||
* @param string $articleNumber 매물번호
|
||||
* @param array $priceData 가격 수정 데이터
|
||||
* API:PATCH /kiso/center/verification-article/price/{매물번호}?charger={변경자}
|
||||
* priceType int 가격유형 (DEAL:매매, WARRANTY:보증금, LEASE:월세, PRE_SALE:분양, PREMIUM:프리미엄, PRE_SALE_OPTION:분양옵션)
|
||||
* dealAmount Int 매매금액
|
||||
* warrantyAmount Int 보증금
|
||||
* leaseAmount Int 월세금액
|
||||
* preSaleAmount Int 분양금액
|
||||
* premiumAmount Int 프리미엄금액
|
||||
* preSaleOptionAmount Int 분양옵션금액
|
||||
*/
|
||||
public function postArticlePriceUpdate(string $articleNumber, array $priceData, string $charger = 'admin'): ?array
|
||||
{
|
||||
$this->charger = $charger;
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-article/price/{$articleNumber}?charger={$this->charger}";
|
||||
|
||||
return $this->request('PATCH', $url, $priceData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 현장확인 슬롯 동기화
|
||||
* API (가) - /kiso/center/site-slot
|
||||
* 신규/변경 일자별 데이터 전송
|
||||
* @syncData array
|
||||
* @param string $baseDate 기준일자(ISO 8601 형식: YYYY-MM-DD 예: 2024-01-31)
|
||||
* @param string $legalDivisionNumber 구역번호 "1111000000"
|
||||
* @param object slots 오전/오후/ 슬롯 정보
|
||||
[
|
||||
{
|
||||
"baseDate": "2025-04-30",
|
||||
"legalDivisionNumber": "1111000000",
|
||||
"slots": {
|
||||
"am": { "max": 10, "reserved": 0 },
|
||||
"pm": { "max": 100, "reserved": 0 }
|
||||
}
|
||||
}
|
||||
]
|
||||
*/
|
||||
public function syncSiteSlot($syncData){
|
||||
$url = $this->baseUrl . "/kiso/center/verification-site/slots";
|
||||
return $this->request('POST', $url, $syncData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 현장확인 매물검증 결과 관리
|
||||
* API: POST /kiso/center/verification-site/{매물번호}/report?charger={담당자명}
|
||||
* @param string $type 현장확인 S11: 예약, S21: 방문, S31: 검수
|
||||
* @param string $code 결과코드 10000: 성공, 20000: 실패, 30000: 지연, 20121: 방문전취소, 20122:방문후취소, 20123:촬영후취소
|
||||
* @param string $message 내용
|
||||
* @param string $reserveDate 예약 년월일 2005-07-31
|
||||
*/
|
||||
public function verificationSiteReport(string $articleNumber, array $reportData, string $charger = 'admin'): ?array
|
||||
{
|
||||
$this->charger = $charger;
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-site/{$articleNumber}/report?charger={$this->charger}";
|
||||
|
||||
return $this->request('POST', $url, $reportData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 단지/평형 시세조회()
|
||||
* @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
|
||||
// ];
|
||||
|
||||
// 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
|
||||
{
|
||||
$url = "{$this->baseUrl}/site/submitSyncResult.nhn";
|
||||
@@ -38,15 +264,333 @@ class NaverApiClient
|
||||
return $this->request('GET', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 단지상세정보조회
|
||||
* hscpNo : 단지번호(숫자)
|
||||
*/
|
||||
public function aptDetail($hscpNo)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/confirms/APTDetail?hscpNo={$hscpNo}";
|
||||
return $this->request('GET', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 빌라 단지상세정보 조회
|
||||
* hscpNo : 단지번호(숫자)
|
||||
*/
|
||||
|
||||
public function villaDetail($hscpNo)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/confirms/villa/{$hscpNo}";
|
||||
return $this->request('GET', $url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 단지목록
|
||||
* cortarNo : 법정동코드
|
||||
*/
|
||||
public function complexList($cortarNo)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(2);
|
||||
$url = $url['api_server'] . "/common/complexList.nhn?cortarNo={$cortarNo}";
|
||||
return $this->request('GET', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 평형목록
|
||||
* rletNo : 단지번호
|
||||
*/
|
||||
public function ptpList($rletNo)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(2);
|
||||
$url = $url['api_server'] . "/common/ptpList.nhn?rletNo={$rletNo}";
|
||||
return $this->request('GET', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 가격수정
|
||||
* @param String atclNo 매물번호
|
||||
* @param integer dealAmt 매매가, 전세(보증금) 단위 : 만원
|
||||
* @param integer wrrntAmt 전세가(보증금) 단위 : 만원
|
||||
* @param integer leaseAmt 월세가 단위 : 만원
|
||||
* @param integer isaleAmt 분양가 단위 : 만원
|
||||
* @param integer premAmt 프리미엄 단위 : 만원
|
||||
* @param integer charger 담당자id
|
||||
*/
|
||||
public function priceChange($atclNo, $dealAmt, $wrrntAmt, $leaseAmt, $isaleAmt, $premAmt, $charger)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/confirms/priceChange";
|
||||
|
||||
$postData = [
|
||||
"atclNo" => $atclNo,
|
||||
"dealAmt" => $dealAmt,
|
||||
"wrrntAmt" => $wrrntAmt,
|
||||
"leaseAmt" => $leaseAmt,
|
||||
"isaleAmt" => $isaleAmt,
|
||||
"premAmt" => $premAmt,
|
||||
"charger" => $charger
|
||||
];
|
||||
|
||||
return $this->request('POST', $url, $postData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 매물정보수정
|
||||
* @param String atclNo 매물번호
|
||||
* @param integer hscpNo 단지번호
|
||||
* @param integer ptpNo 평형번호
|
||||
* @param String bildNm 동이름
|
||||
* @param String rmNo 호수
|
||||
* @param String tradeType 거래종류(A1,B1,B2 / 변경시 B1 <-> B2만 가능)
|
||||
* @param integer dealAmt 매매가, 전세(보증금) 단위 : 만원
|
||||
* @param integer wrrntAmt 전세가(보증금) 단위 : 만원
|
||||
* @param integer leaseAmt 월세가 단위 : 만원
|
||||
* @param integer isaleAmt 분양가 단위 : 만원
|
||||
* @param integer premAmt 프리미엄 단위 : 만원
|
||||
* @param integer floor 층
|
||||
* @param integer charger 담당자id
|
||||
*
|
||||
* @param String addressCode 주소코드 : 비공동 주택 법정동 코드
|
||||
* @param String address2 지번주소 : 비공동 주택 지번 주소
|
||||
* @param String address3 기타주소 : 비공동 주택 기타 주소
|
||||
* @param float splySpc 공급면적
|
||||
* @param float exclsSpc 대지면적
|
||||
* @param float totSpc 전체면적
|
||||
* @param float grndSpc 대지면적
|
||||
* @param float bldgSpc 건축면적
|
||||
*
|
||||
*/
|
||||
public function modifyInfo($atclNo, $hscpNo, $ptpNo, $bildNm, $rmNo, $tradeType, $dealAmt, $wrrntAmt, $leaseAmt, $isaleAmt, $premAmt, $floor, $floor2, $charger, $addressCode, $address2, $address2a, $address2b, $address3, $splySpc, $exclsSpc, $totSpc, $grndSpc, $bldgSpc)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/confirms/modifyInfo";
|
||||
|
||||
// 공통
|
||||
$postData = [
|
||||
"atclNo" => $atclNo,
|
||||
"tradeType" => $tradeType,
|
||||
"dealAmt" => $dealAmt,
|
||||
"wrrntAmt" => $wrrntAmt,
|
||||
"leaseAmt" => $leaseAmt,
|
||||
"isaleAmt" => $isaleAmt,
|
||||
"charger" => $charger
|
||||
];
|
||||
|
||||
// 공동주택
|
||||
$apartData["hscpNo"] = $hscpNo;
|
||||
$apartData["ptpNo"] = $ptpNo;
|
||||
$apartData["bildNm"] = $address2; // 네이버에서 보내주는거랑 수정되어 전달하는 거랑 다른 타입임. 2014년 11월 13일 수정
|
||||
$apartData["rmNo"] = $address3; // 네이버에서 보내주는거랑 수정되어 전달하는 거랑 다른 타입임. 2014년 11월 13일 수정
|
||||
// $apartData["bildNm"] = $bildNm;
|
||||
// $apartData["rmNo"] = $rmNo;
|
||||
$apartData["premAmt"] = $premAmt;
|
||||
$apartData["floor"] = $floor;
|
||||
$apartData["floor2"] = $floor2;
|
||||
|
||||
// 비공동주택 연동
|
||||
$detachData["addressCode"] = $addressCode;
|
||||
$detachData["address2"] = $address2;
|
||||
$detachData["address2a"] = $address2a;
|
||||
$detachData["address2b"] = $address2b;
|
||||
$detachData["address3"] = $address3;
|
||||
$detachData["splySpc"] = $splySpc;
|
||||
$detachData["exclsSpc"] = $exclsSpc;
|
||||
$detachData["totSpc"] = $totSpc;
|
||||
$detachData["grndSpc"] = $grndSpc;
|
||||
$detachData["bldgSpc"] = $bldgSpc;
|
||||
$detachData["floor"] = $floor;
|
||||
$detachData["floor2"] = $floor2;
|
||||
|
||||
if (!empty($hscpNo)) { //공동주택일 때
|
||||
$postData = array_merge($postData, $apartData);
|
||||
} else { //비공동주택일 때
|
||||
$postData = array_merge($postData, $detachData);
|
||||
}
|
||||
|
||||
return $this->request('POST', $url, $postData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 검증결과 전송
|
||||
* @param String atclNo 매물번호
|
||||
* @param boolean success 성공여부
|
||||
* @param array checkList 확인정보 array('type'=>'T11','code'=>'10000','comment'=>'01|02|03'); 또는 array('type'=>'T11','code'=>'10000','comment'=>'코멘트');
|
||||
* @param String charger 담당자 사번
|
||||
* @param array modifyInfo 공동 비공동에 따라 다른 배열을 넘긴다.
|
||||
* @param String date 상담일시
|
||||
*/
|
||||
public function confirm($atclNo, $success, $checkList, $charger, $modifyInfo, $date)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/confirms/confirm";
|
||||
|
||||
$postData = [
|
||||
"atclNo" => $atclNo,
|
||||
"success" => $success,
|
||||
"checkList" => $checkList,
|
||||
"charger" => $charger,
|
||||
"modifyInfo" => $modifyInfo,
|
||||
"date" => $date,
|
||||
];
|
||||
|
||||
return $this->request('POST', $url, $postData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 등기부 등본 확인 결과
|
||||
* @param String atclNo 매물번호
|
||||
* @param String type 1: 1차 확인(등기부확인) / 2: 2차 확인(최종확인 또는 중개업소 TM)
|
||||
* @param boolean success 성공여부
|
||||
* @param array checkList 확인정보
|
||||
* @param String charger 담당자 사번
|
||||
* @param String date 상담일시
|
||||
* @param array modifyInfo 수정정보 - success:true 에서만 허용
|
||||
*/
|
||||
public function certification($atclNo, $type, $success, $checkList, $charger, $date, $modifyInfo, $ownerVerifiable)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/confirms/certification";
|
||||
|
||||
$postData = [
|
||||
"atclNo" => $atclNo,
|
||||
"type" => $type,
|
||||
"success" => $success,
|
||||
"checkList" => $checkList,
|
||||
"charger" => $charger,
|
||||
"date" => $date,
|
||||
"modifyInfo" => $modifyInfo,
|
||||
"ownerVerifiable" => $ownerVerifiable
|
||||
];
|
||||
|
||||
return $this->request('POST', $url, $postData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 등기부 등본 확인 결과
|
||||
* 712 OwnerVerifiable 전송 오류 우회 테스트
|
||||
*/
|
||||
public function certification_712($atclNo, $type, $success, $checkList, $charger, $date, $modifyInfo, $ownerVerifiable)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/confirms/certification";
|
||||
|
||||
$model712 = new M712Model();
|
||||
$data = $model712->getOwnerVerifiable($atclNo);
|
||||
|
||||
$ov = $data['OwnerVerifiable_change'];
|
||||
if (isset($ov)) {
|
||||
if ($ov > 0) {
|
||||
$ownerVerifiable = true;
|
||||
} else {
|
||||
$ownerVerifiable = false;
|
||||
}
|
||||
} else {
|
||||
$ownerVerifiable = null;
|
||||
}
|
||||
|
||||
$postData = [
|
||||
"atclNo" => $atclNo,
|
||||
"type" => $type,
|
||||
"success" => $success,
|
||||
"checkList" => $checkList,
|
||||
"charger" => $charger,
|
||||
"date" => $date,
|
||||
"modifyInfo" => $modifyInfo,
|
||||
"ownerVerifiable" => $ownerVerifiable
|
||||
];
|
||||
|
||||
log_message('debug', '712 certification_712 => ' . $atclNo . ' ::: ' . json_encode($postData) . PHP_EOL);
|
||||
|
||||
return $this->request('POST', $url, $postData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 현장확인 거주인 여부 변경
|
||||
*/
|
||||
public function residentsExistence($reserveNumber, $isResidentsExist)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/residents/existence";
|
||||
|
||||
$postData = [
|
||||
'reserveNumber' => $reserveNumber,
|
||||
'isResidentsExist' => $isResidentsExist
|
||||
];
|
||||
|
||||
return $this->request('POST', $url, $postData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 예약확인 완료
|
||||
*/
|
||||
public function reserveSuccess($reserveNo, $modyfyYn, $agency, $team, $staff, $staffTel, $reserveYmd, $apm)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/site/reserveSuccess.nhn";
|
||||
|
||||
$getData = ['reserveNo' => $reserveNo, 'modyfyYn' => $modyfyYn, 'agency' => $agency, 'team' => $team, 'staff' => $staff, 'staffTel' => $staffTel, 'reserveYmd' => $reserveYmd, 'apm' => $apm];
|
||||
|
||||
return $this->request('POST', $url, $getData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 예약확인 실패
|
||||
*/
|
||||
public function reserveFail($reserveNo, $errorCode, $etcTxt)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/site/reserveFail.nhn";
|
||||
|
||||
$getData = ['reserveNo' => $reserveNo, 'errorCode' => $errorCode, 'errorDesc' => $etcTxt];
|
||||
|
||||
return $this->request('POST', $url, $getData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 촬영 실패
|
||||
*/
|
||||
public function shootFail($reserveNo, $errorCode, $etcTxt)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/site/shootFail.nhn";
|
||||
|
||||
$getData = ['reserveNo' => $reserveNo, 'errorCode' => $errorCode, 'errorDesc' => $etcTxt];
|
||||
|
||||
return $this->request('POST', $url, $getData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 현장확인2 및 썸네일 검수 실패
|
||||
*/
|
||||
public function inspectFail($reserveNumber, $failDescription)
|
||||
{
|
||||
$url = $this->commonModel->getCompanyInfo(3);
|
||||
$url = $url['api_server'] . "/site/vr/inspect/fail";
|
||||
|
||||
$postData = [
|
||||
'reserveNumber' => $reserveNumber,
|
||||
'failDescription' => $failDescription
|
||||
];
|
||||
|
||||
return $this->request('POST', $url, $postData);
|
||||
}
|
||||
|
||||
/**
|
||||
* CURL 공통 실행 함수
|
||||
*/
|
||||
private function request(string $method, string $url, ?array $data = null): ?array
|
||||
{
|
||||
/**
|
||||
* curl --location 'https://test-b2b.land.naver.com/kiso/center/verification-article/2500000001?charger=admin' \
|
||||
--header 'X-Naver-Client-Id: yqBbvQZ123_hjH3b3Df9' \
|
||||
*/
|
||||
// 요청 데이터 로깅
|
||||
if ($data) {
|
||||
log_message('info', "[Naver API $method REQUEST] URL: $url | Data: " . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
} else {
|
||||
log_message('info', "[Naver API $method REQUEST] URL: $url");
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
@@ -79,18 +623,49 @@ class NaverApiClient
|
||||
'X-Naver-Client-Id: yqBbvQZ123_hjH3b3Df9'
|
||||
]);
|
||||
}
|
||||
} elseif ($method === 'PATCH') {
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
|
||||
if ($data) {
|
||||
$payload = json_encode($data);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($payload),
|
||||
'X-Naver-Client-Id: yqBbvQZ123_hjH3b3Df9'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$curlError = curl_error($ch);
|
||||
$curlErrno = curl_errno($ch);
|
||||
curl_close($ch);
|
||||
|
||||
// CURL 오류 체크
|
||||
if ($curlErrno !== 0) {
|
||||
log_message('error', "[Naver API $method CURL ERROR] URL: $url | Error ($curlErrno): $curlError");
|
||||
return [
|
||||
'error' => true,
|
||||
'error_type' => 'CURL_ERROR',
|
||||
'curl_errno' => $curlErrno,
|
||||
'curl_error' => $curlError,
|
||||
'url' => $url
|
||||
];
|
||||
}
|
||||
|
||||
// 결과 로그 기록 (성공/실패 모두 기록하여 추적 가능하게 함)
|
||||
if ($httpCode === 200 || $httpCode === 202) {
|
||||
log_message('info', "[Naver API $method SUCCESS] URL: $url | Response: $response");
|
||||
log_message('info', "[Naver API $method SUCCESS] URL: $url | Code: $httpCode | Response: $response");
|
||||
} else {
|
||||
log_message('error', "[Naver API $method FAIL] URL: $url | Code: $httpCode | Response: $response");
|
||||
return null;
|
||||
return [
|
||||
'error' => true,
|
||||
'error_type' => 'HTTP_ERROR',
|
||||
'http_code' => $httpCode,
|
||||
'response' => $response,
|
||||
'url' => $url
|
||||
];
|
||||
}
|
||||
|
||||
return json_decode($response, true);
|
||||
|
||||
29
app/Libraries/qrcode.php
Normal file
29
app/Libraries/qrcode.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class Qrcode
|
||||
{
|
||||
|
||||
public function scan($filename)
|
||||
{
|
||||
$data = '';
|
||||
$file = urldecode($filename);
|
||||
|
||||
if (!file_exists($file)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$image = new ZBarCodeImage($file);
|
||||
$scanner = new ZBarCodeScanner();
|
||||
$barcode = $scanner->scan($image);
|
||||
if (!empty($barcode)) {
|
||||
foreach ($barcode as $code) {
|
||||
$data .= ',' . $code['data'];
|
||||
}
|
||||
if (!empty($data))
|
||||
$data = substr($data, 1);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
47
app/Models/Entities/ChangedHistoryModel.php
Normal file
47
app/Models/Entities/ChangedHistoryModel.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Entities;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class ChangedHistoryModel extends Model
|
||||
{
|
||||
protected $table = 'changed_history';
|
||||
protected $primaryKey = 'seq';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $protectFields = true;
|
||||
|
||||
protected $allowedFields = [
|
||||
'rcpt_sq',
|
||||
'rcpt_stat',
|
||||
'changed_type',
|
||||
'changed_id',
|
||||
'changed_tm',
|
||||
'remark',
|
||||
];
|
||||
|
||||
/**
|
||||
* 정보변경 이력 1건 저장
|
||||
*/
|
||||
public function addHistory(
|
||||
int $rcptSq,
|
||||
?string $rcptStat,
|
||||
?string $changedType,
|
||||
?string $changedId,
|
||||
?string $remark,
|
||||
?string $changedTm = null
|
||||
): bool {
|
||||
$data = [
|
||||
'rcpt_sq' => $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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
36
app/Models/Entities/RegionModel.php
Normal file
36
app/Models/Entities/RegionModel.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Entities;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class RegionModel extends Model
|
||||
{
|
||||
protected $table = 'region_codes';
|
||||
protected $primaryKey = 'region_cd';
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $useTimestamps = false;
|
||||
|
||||
protected $allowedFields = [
|
||||
'region_cd', 'region_nm', 'use_yn', 'dept_sq', 'usr_sq'
|
||||
];
|
||||
|
||||
/**
|
||||
* 지역 코드로 담당자 정보 조회
|
||||
*
|
||||
* @param string $regionCd 지역 코드 (sectorNumber)
|
||||
* @return array|null ['dept_sq' => 26, 'usr_sq' => 1] 또는 null
|
||||
*/
|
||||
public function getChargeByRegionCd($regionCd)
|
||||
{
|
||||
if (empty($regionCd)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->select('dept_sq, usr_sq')
|
||||
->where('region_cd', $regionCd)
|
||||
->where('use_yn', 'Y')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace App\Models\Entities;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class V2ArticleInfoModel extends Model
|
||||
class V2articleinfoModel extends Model
|
||||
{
|
||||
protected $table = 'v2_article_info';
|
||||
protected $primaryKey = 'vr_sq';
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace App\Models\Entities;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class V2ArticleInfoEtcModel extends Model
|
||||
class V2articleinfoetcModel extends Model
|
||||
{
|
||||
protected $table = 'v2_article_info_etc';
|
||||
protected $primaryKey = 'vr_sq';
|
||||
|
||||
132
app/Models/Entities/V2modifyinfoModel.php
Normal file
132
app/Models/Entities/V2modifyinfoModel.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Entities;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
/**
|
||||
* V2ModifyInfoModel
|
||||
*
|
||||
* v2_modify_info 테이블 - 수정정보 모델
|
||||
* 부동산 매물의 수정된 정보를 저장하는 테이블
|
||||
*/
|
||||
class V2modifyinfoModel extends Model
|
||||
{
|
||||
protected $table = 'v2_modify_info';
|
||||
protected $primaryKey = 'vr_sq';
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $allowedFields = [
|
||||
'vr_sq',
|
||||
'bildNo',
|
||||
'bild_nm',
|
||||
'rm_no',
|
||||
'floor',
|
||||
'floor2',
|
||||
'ugrodFloor',
|
||||
'address_code',
|
||||
'address2',
|
||||
'address2a',
|
||||
'address2b',
|
||||
'address3',
|
||||
'address4',
|
||||
'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',
|
||||
];
|
||||
|
||||
// 검증 규칙
|
||||
// protected $validationRules = [
|
||||
// 'vr_sq' => 'required|integer',
|
||||
// 'bild_nm' => 'string|max_length[60]',
|
||||
// 'rm_no' => 'string|max_length[30]',
|
||||
// 'floor' => 'integer',
|
||||
// 'floor2' => 'integer',
|
||||
// 'ugrodFloor' => 'integer',
|
||||
// 'address_code' => 'string|max_length[10]',
|
||||
// 'address2' => 'string|max_length[300]',
|
||||
// 'address2a' => 'string|max_length[300]',
|
||||
// 'address2b' => 'string|max_length[300]',
|
||||
// 'address3' => 'string|max_length[300]',
|
||||
// 'address4' => 'string|max_length[1000]',
|
||||
// 'trade_type' => 'string|max_length[2]',
|
||||
// 'deal_amt' => 'integer',
|
||||
// 'wrrnt_amt' => 'integer',
|
||||
// 'lease_amt' => 'integer',
|
||||
// 'isale_amt' => 'integer',
|
||||
// 'prem_amt' => 'integer',
|
||||
// 'sply_spc' => 'numeric',
|
||||
// 'excls_spc' => 'numeric',
|
||||
// 'tot_spc' => 'numeric',
|
||||
// 'grnd_spc' => 'numeric',
|
||||
// 'bldg_spc' => 'numeric',
|
||||
// 'hscp_no' => 'string|max_length[30]',
|
||||
// 'hscp_nm' => 'string|max_length[60]',
|
||||
// 'ptp_no' => 'string|max_length[30]',
|
||||
// 'ptp_nm' => 'string|max_length[60]',
|
||||
// 'modify_yn' => 'in_list[Y,N]',
|
||||
// ];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// 콜백
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* 검증요청순번(vr_sq)으로 수정정보 조회
|
||||
*/
|
||||
public function getByVrSq(int $vrSq): ?array
|
||||
{
|
||||
return $this->find($vrSq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정정보 저장 (없으면 insert, 있으면 update)
|
||||
* REPLACE INTO 사용으로 효율성 증대
|
||||
*/
|
||||
public function saveModifyInfo(int $vrSq, array $data): bool
|
||||
{
|
||||
$data['vr_sq'] = $vrSq;
|
||||
return $this->replace($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정여부가 Y인 데이터 조회
|
||||
*/
|
||||
public function getModifiedInfo(): array
|
||||
{
|
||||
return $this->where('modify_yn', 'Y')->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 검증요청의 수정여부 업데이트
|
||||
*/
|
||||
public function updateModifyYn(int $vrSq, string $yn = 'Y'): bool
|
||||
{
|
||||
return $this->update($vrSq, ['modify_yn' => $yn]);
|
||||
}
|
||||
}
|
||||
231
app/Models/Entities/V2urlimgsaveModel.php
Normal file
231
app/Models/Entities/V2urlimgsaveModel.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Entities;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
/**
|
||||
* V2UrlImgSaveModel
|
||||
*
|
||||
* v2_url_img_save 테이블 - URL 이미지 저장 관리
|
||||
* 홍보 및 등기 이미지 URL을 수신하여 저장 상태를 관리하는 테이블
|
||||
*/
|
||||
class V2urlimgsaveModel extends Model
|
||||
{
|
||||
protected $table = 'v2_url_img_save';
|
||||
protected $primaryKey = 'pk';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $allowedFields = [
|
||||
'pk',
|
||||
'url',
|
||||
'type',
|
||||
'atcl_no',
|
||||
'vr_sq',
|
||||
'status',
|
||||
'try_cnt',
|
||||
'insert_dt',
|
||||
'server_nm',
|
||||
];
|
||||
|
||||
// 검증 규칙
|
||||
protected $validationRules = [
|
||||
'url' => 'string',
|
||||
'type' => 'in_list[1,2]',
|
||||
'atcl_no' => 'string|max_length[10]',
|
||||
'vr_sq' => 'integer',
|
||||
'status' => 'in_list[save,ing,done,err]',
|
||||
'try_cnt' => 'integer|less_than_equal_to[3]',
|
||||
'insert_dt' => 'valid_date',
|
||||
'server_nm' => 'string|max_length[20]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// 콜백
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ['setInsertDate'];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
/**
|
||||
* 삽입 전 insert_dt 자동 설정
|
||||
*/
|
||||
protected function setInsertDate(array $data)
|
||||
{
|
||||
if (!isset($data['data']['insert_dt'])) {
|
||||
$data['data']['insert_dt'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태별 데이터 조회 (save, ing, done, err)
|
||||
*/
|
||||
public function getByStatus(string $status): array
|
||||
{
|
||||
return $this->where('status', $status)->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* vr_sq로 데이터 조회
|
||||
*/
|
||||
public function getByVrSq(int $vrSq): array
|
||||
{
|
||||
return $this->where('vr_sq', $vrSq)->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* type과 vr_sq로 데이터 조회
|
||||
*/
|
||||
public function getByTypeAndVrSq(string $type, int $vrSq): array
|
||||
{
|
||||
return $this->where('type', $type)
|
||||
->where('vr_sq', $vrSq)
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* atcl_no로 데이터 조회
|
||||
*/
|
||||
public function getByAtclNo(string $atclNo): array
|
||||
{
|
||||
return $this->where('atcl_no', $atclNo)->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장 대기 중인 데이터 조회 (save 상태)
|
||||
*/
|
||||
public function getPendingSave(): array
|
||||
{
|
||||
return $this->where('status', 'save')
|
||||
->where('try_cnt <', 3)
|
||||
->orderBy('insert_dt', 'ASC')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장 중인 데이터 조회 (ing 상태)
|
||||
*/
|
||||
public function getSaving(): array
|
||||
{
|
||||
return $this->where('status', 'ing')->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장 실패 데이터 조회 (err 상태)
|
||||
*/
|
||||
public function getErrors(): array
|
||||
{
|
||||
return $this->where('status', 'err')->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 이미지 상태 업데이트
|
||||
*/
|
||||
public function updateStatus(int $pk, string $status): bool
|
||||
{
|
||||
return $this->update($pk, ['status' => $status]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 재시도 횟수 증가
|
||||
*/
|
||||
public function incrementTryCount(int $pk): bool
|
||||
{
|
||||
$current = $this->find($pk);
|
||||
if (!$current) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tryCount = ($current['try_cnt'] ?? 0) + 1;
|
||||
$status = $tryCount >= 3 ? 'err' : 'save';
|
||||
|
||||
return $this->update($pk, [
|
||||
'try_cnt' => $tryCount,
|
||||
'status' => $status,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장 완료 처리
|
||||
*/
|
||||
public function markAsDone(int $pk): bool
|
||||
{
|
||||
return $this->update($pk, ['status' => 'done']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장 중 표시
|
||||
*/
|
||||
public function markAsProcessing(int $pk): bool
|
||||
{
|
||||
return $this->update($pk, ['status' => 'ing']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장 실패 표시
|
||||
*/
|
||||
public function markAsError(int $pk): bool
|
||||
{
|
||||
return $this->update($pk, ['status' => 'err']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 특정 vr_sq의 모든 이미지 저장 완료
|
||||
*/
|
||||
public function markAllDoneByVrSq(int $vrSq): bool
|
||||
{
|
||||
return $this->where('vr_sq', $vrSq)
|
||||
->set(['status' => 'done'])
|
||||
->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* type별 통계
|
||||
*/
|
||||
public function getStatisticsByType(int $vrSq): array
|
||||
{
|
||||
$result = [
|
||||
'1' => ['total' => 0, 'done' => 0, 'ing' => 0, 'save' => 0, 'err' => 0],
|
||||
'2' => ['total' => 0, 'done' => 0, 'ing' => 0, 'save' => 0, 'err' => 0],
|
||||
];
|
||||
|
||||
$records = $this->where('vr_sq', $vrSq)->findAll();
|
||||
|
||||
foreach ($records as $record) {
|
||||
$type = $record['type'];
|
||||
if (!isset($result[$type])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$type]['total']++;
|
||||
$status = $record['status'];
|
||||
if (isset($result[$type][$status])) {
|
||||
$result[$type][$status]++;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장할 준비된 데이터 조회 (제한 개수)
|
||||
*/
|
||||
public function getNextBatch(int $limit = 10): array
|
||||
{
|
||||
return $this->where('status', 'save')
|
||||
->where('try_cnt <', 3)
|
||||
->orderBy('insert_dt', 'ASC')
|
||||
->limit($limit)
|
||||
->findAll();
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,45 @@ class VrfcReqModel extends Model {
|
||||
// Model implementation here
|
||||
protected $table = 'v2_vrfc_req';
|
||||
protected $primaryKey = 'vr_sq';
|
||||
|
||||
// 기본값 (명시 안 해도 됨)
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
|
||||
protected $allowedFields = [
|
||||
'reqSeq',
|
||||
'atcl_no',
|
||||
'step',
|
||||
'cpid',
|
||||
'cp_atcl_id',
|
||||
'trade_type',
|
||||
'realtor_nm',
|
||||
'realtor_tel_no',
|
||||
'seller_tel_no',
|
||||
'vrfc_type',
|
||||
'rgbk_confirm',
|
||||
'req_type',
|
||||
'rdate',
|
||||
'cpTelNo',
|
||||
'stat_cd',
|
||||
'try_cnt',
|
||||
'insert_user',
|
||||
'insert_tm',
|
||||
'memo',
|
||||
'contact_fail_cnt',
|
||||
'sync_yn',
|
||||
'reg_try_cnt',
|
||||
'tel_fail_cause',
|
||||
'rgbk_confirm_owner_nm',
|
||||
'direct_trad_yn',
|
||||
'confirm_doc_img_url',
|
||||
'confirm_doc_owner_check_yn',
|
||||
'owner_verifiable',
|
||||
'vrfc_cmpl_type',
|
||||
'rgbk_doc_img_url',
|
||||
'certRegister',
|
||||
'referenceFileUrl'
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
// public function insertV2Article(array $articleInfo): bool
|
||||
|
||||
154
app/Models/Entities/WatermarkModel.php
Normal file
154
app/Models/Entities/WatermarkModel.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Entities;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class WatermarkModel extends Model
|
||||
{
|
||||
protected $table = 'watermark';
|
||||
protected $primaryKey = ['cpid', 'wm_type']; // 복합키
|
||||
|
||||
protected $useAutoIncrement = false;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $allowedFields = [
|
||||
'cpid',
|
||||
'wm_type',
|
||||
'wm_img_path',
|
||||
'wm_img_height',
|
||||
'wm_img_width',
|
||||
'wm_position',
|
||||
'wm_img_opacity',
|
||||
'wm_space',
|
||||
'text_font',
|
||||
'text_color',
|
||||
'text_opacity',
|
||||
'text_size',
|
||||
'text_pixel',
|
||||
'img_width_min',
|
||||
'img_width_max'
|
||||
];
|
||||
|
||||
protected $useTimestamps = false;
|
||||
|
||||
protected $validationRules = [
|
||||
'cpid' => 'required|max_length[20]',
|
||||
'wm_type' => 'required|integer',
|
||||
'wm_img_path' => 'required|max_length[300]',
|
||||
'wm_img_height' => 'required|integer',
|
||||
'wm_img_width' => 'required|integer',
|
||||
'wm_position' => 'required|max_length[2]',
|
||||
'wm_img_opacity' => 'required|integer',
|
||||
'wm_space' => 'required|integer',
|
||||
'img_width_min' => 'required|integer',
|
||||
'img_width_max' => 'required|integer'
|
||||
];
|
||||
|
||||
protected $validationMessages = [];
|
||||
protected $skipValidation = false;
|
||||
|
||||
/**
|
||||
* 워터마크 정보 조회 (복합키)
|
||||
*
|
||||
* @param string $cpid
|
||||
* @param int $wm_type
|
||||
* @return array|null
|
||||
*/
|
||||
public function getWatermark($cpid, $wm_type)
|
||||
{
|
||||
return $this->where('cpid', $cpid)
|
||||
->where('wm_type', $wm_type)
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* cpid로 워터마크 목록 조회
|
||||
*
|
||||
* @param string $cpid
|
||||
* @return array
|
||||
*/
|
||||
public function getWatermarksByCpid($cpid)
|
||||
{
|
||||
return $this->where('cpid', $cpid)->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 워터마크 타입별 조회
|
||||
*
|
||||
* @param int $wm_type
|
||||
* @return array
|
||||
*/
|
||||
public function getWatermarksByType($wm_type)
|
||||
{
|
||||
return $this->where('wm_type', $wm_type)->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 워터마크 정보 저장/업데이트
|
||||
*
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function saveWatermark($data)
|
||||
{
|
||||
if (!isset($data['cpid']) || !isset($data['wm_type'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 복합키로 기존 데이터 확인
|
||||
$existing = $this->getWatermark($data['cpid'], $data['wm_type']);
|
||||
|
||||
if ($existing) {
|
||||
// 업데이트
|
||||
return $this->where('cpid', $data['cpid'])
|
||||
->where('wm_type', $data['wm_type'])
|
||||
->set($data)
|
||||
->update();
|
||||
} else {
|
||||
// 삽입
|
||||
return $this->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 워터마크 삭제 (복합키)
|
||||
*
|
||||
* @param string $cpid
|
||||
* @param int $wm_type
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteWatermark($cpid, $wm_type)
|
||||
{
|
||||
return $this->where('cpid', $cpid)
|
||||
->where('wm_type', $wm_type)
|
||||
->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* cpid로 모든 워터마크 삭제
|
||||
*
|
||||
* @param string $cpid
|
||||
* @return bool
|
||||
*/
|
||||
public function deleteAllByCpid($cpid)
|
||||
{
|
||||
return $this->where('cpid', $cpid)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 이미지 크기 범위로 워터마크 조회
|
||||
*
|
||||
* @param string $cpid
|
||||
* @param int $img_width
|
||||
* @return array|null
|
||||
*/
|
||||
public function getWatermarkByImageSize($cpid, $img_width)
|
||||
{
|
||||
return $this->where('cpid', $cpid)
|
||||
->where('img_width_min <=', $img_width)
|
||||
->where('img_width_max >=', $img_width)
|
||||
->findAll();
|
||||
}
|
||||
}
|
||||
@@ -115,6 +115,22 @@ class DeptModel extends Model
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 부서검색(상세)
|
||||
*/
|
||||
public function getDeptDetail($dept_sq)
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE dept_sq = ?";
|
||||
|
||||
$data = array($dept_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
// 조직별통계
|
||||
public function getDeptStatistics($data)
|
||||
{
|
||||
@@ -135,7 +151,7 @@ class DeptModel extends Model
|
||||
$builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
|
||||
} else {
|
||||
|
||||
$builder->where('a.isSiteVRVerification', 'N');
|
||||
// $builder->where('a.isSiteVRVerification', 'N');
|
||||
|
||||
// 접수일자
|
||||
/*
|
||||
@@ -228,10 +244,7 @@ class DeptModel extends Model
|
||||
$builder->groupStart()
|
||||
->like('a.agent_nm', $data['srchTxt'])
|
||||
->orLike('a.sellr_nm', $data['srchTxt'])
|
||||
->groupEnd();
|
||||
|
||||
$builder->groupStart()
|
||||
->like('a.agent_head_tel', $data['srchTxt'])
|
||||
->orLike('a.agent_head_tel', $data['srchTxt'])
|
||||
->orLike('a.sellr_tel_no', $data['srchTxt'])
|
||||
->groupEnd();
|
||||
}
|
||||
@@ -277,7 +290,7 @@ class DeptModel extends Model
|
||||
$builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
|
||||
} else {
|
||||
|
||||
$builder->where('a.isSiteVRVerification', 'N');
|
||||
// $builder->where('a.isSiteVRVerification', 'N');
|
||||
|
||||
// 접수일자
|
||||
/*
|
||||
@@ -418,7 +431,7 @@ class DeptModel extends Model
|
||||
$builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
|
||||
} else {
|
||||
|
||||
$builder->where('b.req_rec_yn', 'Y');
|
||||
// $builder->where('b.req_rec_yn', 'Y');
|
||||
|
||||
// 접수일자
|
||||
/*
|
||||
@@ -662,7 +675,7 @@ class DeptModel extends Model
|
||||
$builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
|
||||
} else {
|
||||
|
||||
$builder->where('b.req_rec_yn', 'Y');
|
||||
// $builder->where('b.req_rec_yn', 'Y');
|
||||
|
||||
// 접수일자
|
||||
/*
|
||||
@@ -769,10 +782,7 @@ class DeptModel extends Model
|
||||
$builder->groupStart()
|
||||
->like('a.agent_nm', $data['srchTxt'])
|
||||
->orLike('a.sellr_nm', $data['srchTxt'])
|
||||
->groupEnd();
|
||||
|
||||
$builder->groupStart()
|
||||
->like('a.agent_head_tel', $data['srchTxt'])
|
||||
->orLike('a.agent_head_tel', $data['srchTxt'])
|
||||
->orLike('a.sellr_tel_no', $data['srchTxt'])
|
||||
->groupEnd();
|
||||
}
|
||||
@@ -782,8 +792,9 @@ class DeptModel extends Model
|
||||
|
||||
$builder->orderBy('a.rcpt_atclno', 'DESC');
|
||||
|
||||
if (empty($data['type'])) {
|
||||
$builder->limit($end, $start);
|
||||
|
||||
}
|
||||
|
||||
// echo $builder->getCompiledSelect(false);
|
||||
$rows = $builder->get()->getResultArray();
|
||||
@@ -845,97 +856,32 @@ class DeptModel extends Model
|
||||
|
||||
$builder = $this->db->table('receipt a');
|
||||
|
||||
$builder->select("a.rcpt_sq
|
||||
,a.comp_sq
|
||||
,a.rcpt_rating
|
||||
,a.rcpt_key
|
||||
,a.rcpt_atclno
|
||||
,a.rcpt_type
|
||||
,a.rcpt_product
|
||||
,a.rcpt_product_nm
|
||||
,a.rcpt_product_area
|
||||
,a.rcpt_product_price
|
||||
,a.rcpt_product_info1
|
||||
,a.rcpt_product_info2
|
||||
,a.rcpt_product_info3
|
||||
,a.rcpt_product_info4
|
||||
,a.rcpt_product_info5
|
||||
,a.rcpt_ptp_nm
|
||||
,a.rcpt_office
|
||||
,(CASE WHEN a.rcpt_agent IS NULL THEN 'N' ELSE 'Y' END) as rcpt_agent
|
||||
,a.rcpt_sido
|
||||
,a.rcpt_gugun
|
||||
,a.rcpt_dong
|
||||
,IFNULL(a.rcpt_hscp_nm, '') AS rcpt_hscp_nm
|
||||
,IFNULL(a.rcpt_ho, '') AS rcpt_ho
|
||||
,a.rcpt_dtl_addr
|
||||
,a.rcpt_li_addr
|
||||
,a.rcpt_jibun_addr
|
||||
,IFNULL(a.rcpt_etc_addr, '') AS rcpt_etc_addr
|
||||
,a.rcpt_floor
|
||||
,a.rcpt_tm
|
||||
,a.rcpt_stat
|
||||
,a.rcpt_x
|
||||
,a.rcpt_y
|
||||
,a.rcpt_living_yn
|
||||
,a.cust_nm
|
||||
,a.cust_tel1
|
||||
,a.cust_tel2
|
||||
,a.cust_zip
|
||||
,a.cust_addr1
|
||||
,a.cust_addr2
|
||||
,a.remark
|
||||
,a.agent_id
|
||||
,a.agent_nm
|
||||
,a.agent_head
|
||||
,a.agent_head_tel
|
||||
,a.agent_contact
|
||||
,a.agent_contact_tel
|
||||
,IFNULL(a.agent_tel, '') AS agent_tel
|
||||
,a.sply_spc
|
||||
,a.excls_spc
|
||||
,a.room_cnt
|
||||
,a.exp_spc_yn
|
||||
,a.agent_fax
|
||||
,DATE_FORMAT(COALESCE(b.rsrv_date, a.rsrv_date), '%Y-%m-%d') AS rsrv_date
|
||||
,COALESCE(b.rsrv_tm_ap, a.rsrv_tm_ap) as rsrv_tm_ap
|
||||
,a.insert_usr
|
||||
,a.insert_tm
|
||||
,a.update_usr
|
||||
,a.update_tm
|
||||
,a.svc_type1
|
||||
,a.svc_type2
|
||||
,a.reconf_yn
|
||||
,f.cd_nm as trade_type_nm
|
||||
,b.rsrv_sq
|
||||
,b.dept_sq
|
||||
,b.usr_sq
|
||||
,b.rsrv_tm_hour
|
||||
,b.result_cd1
|
||||
,b.result_cd2
|
||||
,b.result_msg
|
||||
,b.request_msg
|
||||
,b.photo_save_dt
|
||||
,b.rsrv_delay_dt
|
||||
,b.rsrv_cplt_dt
|
||||
,b.check_dt
|
||||
,b.check_cplt_dt
|
||||
,b.record_cplt_dt
|
||||
,get_code_name('RECEIPT_STATUS1', substring(a.rcpt_stat, 1, 2)) AS rcpt_stat_nm
|
||||
,c.region_nm as addr
|
||||
,b.result_save_dt
|
||||
,u.usr_nm
|
||||
,d.dept_nm
|
||||
,a.exp_photo_yn
|
||||
,a.ground_plan
|
||||
,CASE (SELECT COUNT(1) FROM result_imgs WHERE rsrv_sq=b.rsrv_sq AND img_type = 'I1' AND use_yn = 'Y') WHEN 0 THEN 'N' ELSE 'Y' END conf_img_yn
|
||||
,CASE (SELECT COUNT(1) FROM result_imgs WHERE rsrv_sq=b.rsrv_sq AND img_type = 'I5' AND use_yn = 'Y') WHEN 0 THEN 'N' ELSE 'Y' END ground_plan_yn
|
||||
,a.exp_movie_yn
|
||||
,a.direct_trad_yn
|
||||
,a.sellr_nm
|
||||
,a.sellr_tel_no
|
||||
,a.isSiteVRVerification
|
||||
,a.isPromotionApply");
|
||||
$builder->select("
|
||||
CASE WHEN b.result_cd1 = '90' THEN get_code_name('RECEIPT_STATUS2', b.result_cd2) ELSE '' END AS '매물ID',
|
||||
a.rcpt_atclno AS '예약일자',
|
||||
b.rsrv_tm_hour AS '중개사명',
|
||||
b.photo_save_dt AS '대표전화',
|
||||
a.agent_contact_tel AS '담당자전화',
|
||||
CASE
|
||||
WHEN IFNULL(a.rcpt_jibun_addr, '') = '' THEN
|
||||
CASE
|
||||
WHEN IFNULL(a.rcpt_hscp_nm, '') = '' THEN
|
||||
CONCAT(c.region_nm, ' ', a.rcpt_dtl_addr, ' ', a.rcpt_ho)
|
||||
ELSE
|
||||
CONCAT(c.region_nm, ' ', a.rcpt_hscp_nm, ' ', a.rcpt_dtl_addr, ' ', a.rcpt_ho)
|
||||
END
|
||||
ELSE
|
||||
CASE
|
||||
WHEN IFNULL(a.rcpt_li_addr, '') != '' THEN
|
||||
CONCAT(c.region_nm, ' ', a.rcpt_li_addr, ' ', a.rcpt_jibun_addr, ' ', a.rcpt_etc_addr)
|
||||
ELSE
|
||||
CONCAT(c.region_nm, ' ', a.rcpt_jibun_addr, ' ', a.rcpt_etc_addr)
|
||||
END
|
||||
END AS '주소',
|
||||
a.rcpt_product_nm AS '매물종류',
|
||||
a.rcpt_product_info1 AS '거래구분',
|
||||
u.usr_nm AS '담당자',
|
||||
b.request_msg AS '중개사 요청사항'");
|
||||
|
||||
$builder->join('result b', 'a.rcpt_sq = b.rcpt_sq', 'left');
|
||||
$builder->join('region_codes c', 'a.rcpt_dong = c.region_cd', 'inner');
|
||||
@@ -958,7 +904,7 @@ class DeptModel extends Model
|
||||
$builder->where('a.rcpt_atclno', $data['rcpt_atclno']);
|
||||
} else {
|
||||
|
||||
$builder->where('b.req_rec_yn', 'Y');
|
||||
// $builder->where('b.req_rec_yn', 'Y');
|
||||
|
||||
// 접수일자
|
||||
/*
|
||||
@@ -1065,10 +1011,7 @@ class DeptModel extends Model
|
||||
$builder->groupStart()
|
||||
->like('a.agent_nm', $data['srchTxt'])
|
||||
->orLike('a.sellr_nm', $data['srchTxt'])
|
||||
->groupEnd();
|
||||
|
||||
$builder->groupStart()
|
||||
->like('a.agent_head_tel', $data['srchTxt'])
|
||||
->orLike('a.agent_head_tel', $data['srchTxt'])
|
||||
->orLike('a.sellr_tel_no', $data['srchTxt'])
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
@@ -212,75 +212,88 @@ class ProcessibleModel extends Model
|
||||
// 지역별 수량 저장
|
||||
public function saveArea($data)
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
$usr_sq = session('usr_sq');
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
$sql = "INSERT INTO service_count
|
||||
(sc_date, region_cd, am_cnt, pm_cnt, day_cnt, insert_usr, insert_tm, update_usr, update_tm)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, NOW(), ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE am_cnt=values(am_cnt), pm_cnt=values(pm_cnt), day_cnt=values(day_cnt), update_usr=values(update_usr)
|
||||
";
|
||||
|
||||
$datas = [
|
||||
$data['sc_date'],
|
||||
$data['region_cd'],
|
||||
$data['am_cnt'],
|
||||
$data['pm_cnt'],
|
||||
((int) $data['am_cnt'] + (int) $data['pm_cnt']),
|
||||
$usr_sq,
|
||||
$usr_sq
|
||||
$insertData = [
|
||||
'sc_date' => $data['sc_date'],
|
||||
'region_cd' => $data['region_cd'],
|
||||
'am_cnt' => $data['am_cnt'],
|
||||
'pm_cnt' => $data['pm_cnt'],
|
||||
'day_cnt' => (int)$data['am_cnt'] + (int)$data['pm_cnt'],
|
||||
'insert_usr' => $usr_sq,
|
||||
'insert_tm' => $now,
|
||||
'update_usr' => $usr_sq,
|
||||
'update_tm' => $now
|
||||
];
|
||||
|
||||
if ($this->db->query($sql, $datas) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장실패',
|
||||
];
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
// CI4 Query Builder upsert (INSERT ... ON DUPLICATE KEY UPDATE)
|
||||
$result = $this->db->table('service_count')->upsert($insertData);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'success' => $result !== false,
|
||||
'msg' => $result !== false ? '성공' : '저장실패'
|
||||
];
|
||||
}
|
||||
|
||||
public function saveCount($data)
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
$usr_sq = session('usr_sq');
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
$sql = "INSERT INTO service_count
|
||||
(sc_date, region_cd, am_cnt, pm_cnt, day_cnt, insert_usr, insert_tm, update_usr, update_tm)
|
||||
VALUES
|
||||
(?, ?, ?, ?, ?, ?, NOW(), ?, NOW())
|
||||
ON DUPLICATE KEY UPDATE am_cnt=values(am_cnt), pm_cnt=values(pm_cnt), day_cnt=values(day_cnt), update_usr=values(update_usr)
|
||||
";
|
||||
|
||||
$datas = [
|
||||
'0000-00-00',
|
||||
$data['region_cd'],
|
||||
$data['am_cnt'],
|
||||
$data['pm_cnt'],
|
||||
((int) $data['am_cnt'] + (int) $data['pm_cnt']),
|
||||
$usr_sq,
|
||||
$usr_sq
|
||||
$insertData = [
|
||||
'sc_date' => '0000-00-00',
|
||||
'region_cd' => $data['region_cd'],
|
||||
'am_cnt' => $data['am_cnt'],
|
||||
'pm_cnt' => $data['pm_cnt'],
|
||||
'day_cnt' => (int)$data['am_cnt'] + (int)$data['pm_cnt'],
|
||||
'insert_usr' => $usr_sq,
|
||||
'insert_tm' => $now,
|
||||
'update_usr' => $usr_sq,
|
||||
'update_tm' => $now
|
||||
];
|
||||
|
||||
if ($this->db->query($sql, $datas) === false) {
|
||||
// CI4 Query Builder upsert
|
||||
$result = $this->db->table('service_count')->upsert($insertData);
|
||||
|
||||
// 실행된 쿼리 로그 출력
|
||||
$lastQuery = $this->db->getLastQuery();
|
||||
log_message('info', '[ProcessibleModel::saveCount] Query: ' . $lastQuery);
|
||||
log_message('info', '[ProcessibleModel::saveCount] Affected Rows: ' . $this->db->affectedRows());
|
||||
|
||||
if ($result === false) {
|
||||
$error = $this->db->error();
|
||||
log_message('error', '[ProcessibleModel::saveCount] Error: ' . json_encode($error));
|
||||
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장실패',
|
||||
'msg' => '저장실패: ' . ($error['message'] ?? '알 수 없는 오류'),
|
||||
'query' => (string) $lastQuery,
|
||||
'error' => $error
|
||||
];
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'query' => (string) $lastQuery,
|
||||
'affected_rows' => $this->db->affectedRows()
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 슬롯 동기화
|
||||
*
|
||||
*/
|
||||
public function getSyncSlotData($baseDate, $region_cd)
|
||||
{
|
||||
|
||||
$sql = "SELECT sc_date, region_cd, am_cnt, pm_cnt, day_cnt FROM service_count WHERE sc_date = ? AND region_cd IN ?";
|
||||
$datas = [
|
||||
$baseDate,
|
||||
$region_cd
|
||||
];
|
||||
$query = $this->db->query($sql, $datas);
|
||||
return $query->getResultArray();
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,50 +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()."<br>";
|
||||
$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(string $category, string $code): array
|
||||
{
|
||||
return $this->db->table('codes')
|
||||
->select('category, category_nm, cd, cd_nm')
|
||||
->where('category', $category)
|
||||
->where('cd', $code)
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
}
|
||||
@@ -17,4 +17,12 @@ class CommonModel extends Model
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getCompanyInfo($compSq)
|
||||
{
|
||||
$sql = "SELECT api_server, api_key, comp_nm FROM companies WHERE comp_sq = ?";
|
||||
$data = [$compSq];
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
}
|
||||
@@ -146,4 +146,21 @@ class ReceiptModel extends Model
|
||||
$data = [$imgSq, $faxSq];
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// receipt 에서 지정한 1건만 가져온다.
|
||||
public function selectReceiptOne($rcpt_sq)
|
||||
{
|
||||
$sql = "SELECT a.rcpt_sq,a.comp_sq,a.rcpt_rating,a.rcpt_key,a.rcpt_atclno,a.rcpt_type,a.rcpt_product,a.rcpt_product_nm,a.rcpt_product_area,a.rcpt_product_price,a.rcpt_product_info1,a.rcpt_product_info2,a.rcpt_product_info3,a.rcpt_product_info4,a.rcpt_product_info5,a.rcpt_office,a.rcpt_agent,a.rcpt_sido,a.rcpt_gugun,a.rcpt_dong,a.rcpt_hscp_nm,a.rcpt_dtl_addr,a.rcpt_floor,a.rcpt_bunji,a.rcpt_ho,a.rcpt_tm,a.rcpt_stat,a.rcpt_x,a.rcpt_y,a.rcpt_living_yn,a.cust_nm,a.cust_tel1,a.cust_tel2,a.cust_zip,a.cust_addr1,a.cust_addr2,a.remark,a.agent_id,a.agent_nm,a.agent_head,a.agent_head_tel,a.agent_contact,a.agent_contact_tel,a.agent_fax,a.rsrv_date,a.rsrv_tm_ap,a.insert_usr,a.insert_tm,a.update_usr,a.update_tm,a.svc_type1,a.svc_type2,a.reconf_yn,a.rcpt_exps_type" .
|
||||
", b.region_nm" .
|
||||
", c.rsrv_sq" .
|
||||
" FROM receipt a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = a.rcpt_dong" .
|
||||
" LEFT JOIN result c on c.rcpt_sq = a.rcpt_sq" .
|
||||
" WHERE a.rcpt_sq = ?" .
|
||||
" limit 1";
|
||||
$data = [$rcpt_sq];
|
||||
$query = $this->db->query($sql, $data);
|
||||
|
||||
return $query->getRowArray();
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ class AssignModel extends Model
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
$sql = "SELECT
|
||||
COUNT(*) AS cnt
|
||||
COUNT(DISTINCT b.usr_sq) AS cnt
|
||||
FROM result a
|
||||
INNER JOIN users b ON b.usr_sq = a.usr_sq
|
||||
INNER JOIN receipt d ON d.rcpt_sq = a.rcpt_sq
|
||||
@@ -139,13 +139,13 @@ class AssignModel extends Model
|
||||
|
||||
if (!empty($data['srchTxt'])) {
|
||||
if ($data['srchType'] === "1") {
|
||||
$sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
$sql .= "AND b.usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
} else if ($data['srchType'] === "2") {
|
||||
$sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
$sql .= "AND b.usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
} else {
|
||||
$sql .= "AND (
|
||||
usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
b.usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
OR b.usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
) ";
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,11 @@ class AssignModel extends Model
|
||||
public function getUserList($start, $end, $data)
|
||||
{
|
||||
$sql = "SELECT
|
||||
b.usr_nm, b.usr_id, b.usr_sq, c.dept_sq, c.pdept_sq, c.depth
|
||||
sub.*,
|
||||
COUNT(*) OVER() as total_count
|
||||
FROM (
|
||||
SELECT
|
||||
b.usr_nm, b.usr_id, b.usr_sq
|
||||
, SUM(CASE WHEN a.rsrv_tm_hour IN ('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24') THEN 1 ELSE 0 END) TODAY
|
||||
, SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '09' THEN 1 ELSE 0 END) AM09
|
||||
, SUM(CASE WHEN a.rsrv_tm_ap = 'AM' AND a.rsrv_tm_hour = '10' THEN 1 ELSE 0 END) AM10
|
||||
@@ -212,20 +216,20 @@ class AssignModel extends Model
|
||||
|
||||
if (!empty($data['srchTxt'])) {
|
||||
if ($data['srchType'] === "1") {
|
||||
$sql .= "AND usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
$sql .= "AND b.usr_id like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
} else if ($data['srchType'] === "2") {
|
||||
$sql .= "AND usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
$sql .= "AND b.usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' ) ";
|
||||
} else {
|
||||
$sql .= "AND (
|
||||
usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
OR usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
b.usr_id like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
OR b.usr_nm like CONCAT('%', '{$data['srchTxt']}', '%' )
|
||||
) ";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "GROUP BY b.usr_id, b.usr_nm ";
|
||||
|
||||
$sql .= "LIMIT {$start}, {$end}";
|
||||
$sql .= "GROUP BY b.usr_id, b.usr_nm
|
||||
) sub
|
||||
LIMIT {$start}, {$end}";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
@@ -191,6 +191,42 @@ class M415Model extends Model
|
||||
return $res;
|
||||
}
|
||||
|
||||
// 서류/전화 확인완료 시간 = 등기부등본 확인중 시간
|
||||
public function getConfTimeForHistory($vr_sq)
|
||||
{
|
||||
$sql = "select insert_tm from v2_chg_history" .
|
||||
" where vr_sq = ?" .
|
||||
" and stat_cd = '35'" .
|
||||
" 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_60_ForHistory($vr_sq)
|
||||
{
|
||||
$sql = "select insert_tm from v2_chg_history" .
|
||||
" where vr_sq = ?" .
|
||||
" and stat_cd = '60'" .
|
||||
" 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_cert_ing_TimeForHistory($vr_sq)
|
||||
{
|
||||
@@ -338,4 +374,228 @@ class M415Model extends Model
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
//전화확인 - 통화실패 카운트
|
||||
public function getCallfailForHistory($vr_sq)
|
||||
{
|
||||
$sql = "SELECT 'x' from v2_chg_history" .
|
||||
" WHERE vr_sq = ?" .
|
||||
" AND chg_type= 'C29'" .
|
||||
" ORDER BY seq desc" .
|
||||
" LIMIT 1";
|
||||
$data = array(
|
||||
$vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$res = $query->getRowArray();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
// 서류/전화 인입시간
|
||||
public function getSaveTimeForHistory($vr_sq)
|
||||
{
|
||||
$sql = "select insert_tm from v2_chg_history" .
|
||||
" where vr_sq = ?" .
|
||||
" and stat_cd = '30'" .
|
||||
" 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_cert_failTimeForHistory($vr_sq)
|
||||
{
|
||||
$sql = "select insert_tm from v2_chg_history" .
|
||||
" where vr_sq = ?" .
|
||||
" and stat_cd = '49'" .
|
||||
" 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 insert_v2_time_required_M($atcl_no, $cpid, $vrfc_type, $insert_tm, $cert_comple_dt, $finishTime)
|
||||
{
|
||||
if (substr($insert_tm, 0, 10) == substr($cert_comple_dt, 0, 10)) {
|
||||
if (('12:00:00' < substr($insert_tm, -8)) && (substr($insert_tm, -8) < '13:00:00')) {//접수시간이 12~13시 사이면 13시로 해준다
|
||||
if ($cert_comple_dt > '13:00:00') { //검증완료가 13시 '이후'에 끝나면 접수시간을 13시로 변경해준다
|
||||
$insert_tm = date("Y-m-d", time()) . " 13:00:00";
|
||||
}
|
||||
} else if (
|
||||
(substr($insert_tm, -8) > '17:30:00' || substr($insert_tm, -8) < '08:59:59') && //접수와 확인완료시간이 모두 17:30:00 ~ 09:00:00 사이가 아니면
|
||||
(substr($cert_comple_dt, -8) < '17:30:00' || substr($cert_comple_dt, -8) < '08:59:59')
|
||||
) {
|
||||
$insert_tm = date("Y-m-d", time()) . " 09:00:00";
|
||||
}
|
||||
} else {
|
||||
if (substr($insert_tm, -8) > '17:30:00' || substr($insert_tm, -8) < '08:59:59') {
|
||||
$insert_tm = date("Y-m-d", time()) . " 09:00:00";
|
||||
}
|
||||
}
|
||||
$stan_date = substr($insert_tm, 0, 10);
|
||||
|
||||
$sql = "INSERT INTO v2_time_required(stan_date, atcl_no, cpid, vrfc_type, insert_tm, cert_comple_dt, cert_required_tm, tot_required_tm)" .
|
||||
" VALUES(?, ?, ?, ?, ?, ?, TIMEDIFF(?,?), TIMEDIFF(?,?)) " .
|
||||
" ON DUPLICATE KEY UPDATE insert_tm = VALUES(insert_tm), tel_doc_conf_dt=VALUES(tel_doc_conf_dt),conf_required_tm = VALUES(conf_required_tm),tot_required_tm = VALUES(tot_required_tm) ";
|
||||
$data = array(
|
||||
$stan_date,
|
||||
$atcl_no,
|
||||
$cpid,
|
||||
$vrfc_type,
|
||||
$insert_tm,
|
||||
$cert_comple_dt,
|
||||
$cert_comple_dt,
|
||||
$insert_tm,
|
||||
$cert_comple_dt,
|
||||
$insert_tm
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
//등기부등본 확인완료(불일치)
|
||||
public function update_v2_time_required_Conf($atcl_no, $cpid, $vrfc_type, $tel_doc_conf_dt, $cert_comple_dt, $sf)
|
||||
{
|
||||
if ($sf == 'F') {
|
||||
if (substr($tel_doc_conf_dt, 0, 10) == substr($cert_comple_dt, 0, 10)) {
|
||||
if (('12:00:00' < substr($tel_doc_conf_dt, -8)) && (substr($tel_doc_conf_dt, -8) < '13:00:00')) {//전서확인시간이 12~13시 사이면 13시로 해준다
|
||||
// if (substr($finishTime, -8) > '13:00:00'){ //등본완료가 13시 '이후'에 끝나면 전서확인시간을 13시로 변경해준다
|
||||
// $tel_doc_conf_dt = date("Y-m-d",time())." 13:00:00";
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
$sql = "UPDATE v2_time_required " .
|
||||
" SET cert_comple_dt = ?" .
|
||||
" ,cert_required_tm = TIMEDIFF(?,?)" .//등본 소요시간 = 등본완료시간-전/서확인완료시간
|
||||
" WHERE atcl_no = ?";
|
||||
$data = array(
|
||||
$cert_comple_dt,
|
||||
$cert_comple_dt,
|
||||
$tel_doc_conf_dt,
|
||||
$atcl_no
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
// echo $this->db->last_query().'<br>';
|
||||
}
|
||||
|
||||
// 최초! 등기부등본 확인중 시간-모바일용
|
||||
public function get_cert_M_timeForHistory($vr_sq)
|
||||
{
|
||||
$sql = "select insert_tm from v2_chg_history" .
|
||||
" where vr_sq = ?" .
|
||||
" and stat_cd = '40'" .
|
||||
" and chg_type= 'C9'" .
|
||||
" limit 1";
|
||||
$data = array(
|
||||
$vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$res = $query->getRowArray();
|
||||
|
||||
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)
|
||||
{
|
||||
$sql = "select insert_tm from v2_chg_history" .
|
||||
" where vr_sq = ?" .
|
||||
" and stat_cd = '69'" .
|
||||
" 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 update_v2_time_required_Conf_Done($atcl_no, $cpid, $vrfc_type, $tel_doc_conf_dt, $cert_comple_dt)
|
||||
{
|
||||
//1.검증소요시간 가져온다
|
||||
$sql = "SELECT conf_required_tm" .
|
||||
" FROM v2_time_required" .
|
||||
" WHERE atcl_no = ?";
|
||||
$data = array(
|
||||
$atcl_no
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
|
||||
$res = $query->row_array();
|
||||
|
||||
if (substr($tel_doc_conf_dt, 0, 10) == substr($cert_comple_dt, 0, 10)) {
|
||||
if (('12:00:00' < substr($tel_doc_conf_dt, -8)) && (substr($tel_doc_conf_dt, -8) < '13:00:00')) {//전서확인시간이 12~13시 사이면 13시로 해준다
|
||||
if (substr($cert_comple_dt, -8) > '13:00:00') { //등본완료가 13시 '이후'에 끝나면 전서확인시간을 13시로 변경해준다
|
||||
$tel_doc_conf_dt = date("Y-m-d", time()) . " 13:00:00";
|
||||
}
|
||||
}
|
||||
}
|
||||
//2.등본소요시간, 등본완료시간, 총소요시간을 넣는다
|
||||
$sql = "UPDATE v2_time_required " .
|
||||
" SET cert_comple_dt = ?" .
|
||||
" ,cert_required_tm = TIMEDIFF(?,?)" . //등본 소요시간 = 등본완료시간-전/서확인완료시간
|
||||
" ,tot_required_tm = ADDTIME(?,TIMEDIFF(?,?))" .//총소요시간 = 검증소요시간+등본소요시간
|
||||
" WHERE atcl_no = ?";
|
||||
$data = array(
|
||||
$cert_comple_dt,
|
||||
$cert_comple_dt,
|
||||
$tel_doc_conf_dt,
|
||||
$res['conf_required_tm'],
|
||||
$cert_comple_dt,
|
||||
$tel_doc_conf_dt,
|
||||
$atcl_no
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function get_rlet_type_cd($vr_sq)
|
||||
{
|
||||
$sql = "SELECT rlet_type_cd
|
||||
FROM v2_article_info
|
||||
WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$res = $query->getRowArray();
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
119
app/Models/v2/BaseV2Model.php
Normal file
119
app/Models/v2/BaseV2Model.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
/**
|
||||
* BaseV2Model
|
||||
* V2 모듈 공통 메서드: 지역/본부/팀/담당자 조회
|
||||
* 각 모듈 Model은 이 클래스를 상속받아 getTotalCount/getResultList/getExcelList 등 모듈 고유 메서드만 구현합니다.
|
||||
*/
|
||||
abstract class BaseV2Model extends Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부 조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 담당자 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
}
|
||||
@@ -1,121 +1,12 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\webfax\FaxModel;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M701Model extends Model
|
||||
class M701Model extends BaseV2Model
|
||||
{
|
||||
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
$sql = "SELECT
|
||||
@@ -143,7 +34,7 @@ class M701Model extends Model
|
||||
|
||||
// 매물번호
|
||||
if (!empty($data['atcl_no'])) {
|
||||
$sql .= "AND a.atcl = '{$data['atcl_no']}' ";
|
||||
$sql .= "AND a.atcl_no = '{$data['atcl_no']}' ";
|
||||
} else {
|
||||
// 현재상태
|
||||
if (!empty($data['stat_cd'])) {
|
||||
@@ -308,13 +199,13 @@ class M701Model extends Model
|
||||
b.stat_cd,
|
||||
c.bild_nm,
|
||||
b.vrfc_type,
|
||||
c.rm_no,
|
||||
IFNULL(c.rm_no, '') as rm_no,
|
||||
c.floor,
|
||||
c.address_code,
|
||||
c.address2,
|
||||
m.address2a,
|
||||
m.address2b,
|
||||
c.address3,
|
||||
IFNULL(c.address_code, '') as address_code,
|
||||
IFNULL(c.address2, '') as address2,
|
||||
IFNULL(m.address2a, '') as address2a,
|
||||
IFNULL(m.address2b, '') as address2b,
|
||||
IFNULL(c.address3, '') as address3,
|
||||
c.trade_type,
|
||||
c.deal_amt,
|
||||
c.wrrnt_amt,
|
||||
@@ -331,7 +222,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,
|
||||
@@ -363,7 +254,7 @@ class M701Model extends Model
|
||||
|
||||
// 매물번호
|
||||
if (!empty($data['atcl_no'])) {
|
||||
$sql .= "AND a.atcl = '{$data['atcl_no']}' ";
|
||||
$sql .= "AND a.atcl_no = '{$data['atcl_no']}' ";
|
||||
} else {
|
||||
// 현재상태
|
||||
if (!empty($data['stat_cd'])) {
|
||||
@@ -552,7 +443,7 @@ class M701Model extends Model
|
||||
|
||||
// 매물번호
|
||||
if (!empty($data['atcl_no'])) {
|
||||
$sql .= "AND a.atcl = '{$data['atcl_no']}' ";
|
||||
$sql .= "AND a.atcl_no = '{$data['atcl_no']}' ";
|
||||
} else {
|
||||
// 현재상태
|
||||
if (!empty($data['stat_cd'])) {
|
||||
@@ -747,7 +638,7 @@ class M701Model extends Model
|
||||
c.bild_nm,
|
||||
b.vrfc_type as vrfc_type_cd,
|
||||
b.memo,
|
||||
c.rm_no,
|
||||
IFNULL(c.rm_no, '') as rm_no,
|
||||
c.floor,
|
||||
c.floor2,
|
||||
c.address_code,
|
||||
@@ -887,6 +778,179 @@ class M701Model extends Model
|
||||
}
|
||||
|
||||
|
||||
// 가격수정
|
||||
public function changePrice($param)
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$detail = $this->getDetail($param['rcpt_key']);
|
||||
|
||||
if ($param['trade_type'] != 'B2') {
|
||||
// 월세가 아닐경우에는 월세가에 0으로 ....
|
||||
$data['lease_amt'] = $param['atcl_amt3'];
|
||||
}
|
||||
|
||||
if (!empty($param['atcl_amt1']))
|
||||
$data['deal_amt'] = $param['atcl_amt1'];
|
||||
if (!empty($param['atcl_amt2']))
|
||||
$data['wrrnt_amt'] = $param['atcl_amt2'];
|
||||
if (!empty($param['atcl_amt3']))
|
||||
$data['lease_amt'] = $param['atcl_amt3']; // 월세이고 월세가격이 입력되지 않았으면... 원래 금액으로
|
||||
if (!empty($param['atcl_amt4']))
|
||||
$data['deal_amt'] = $param['atcl_amt4'];
|
||||
if (!empty($param['isale_amt']))
|
||||
$data['isale_amt'] = $param['isale_amt'];
|
||||
if (!empty($param['prem_amt']))
|
||||
$data['prem_amt'] = $param['prem_amt'];
|
||||
|
||||
$data['modify_yn'] = 'Y';
|
||||
|
||||
$builder = $this->db->table('v2_modify_info');
|
||||
$ok = $builder->where('vr_sq', $param['rcpt_key'])->update($data);
|
||||
if ($ok === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$memo = "가격변경 ";
|
||||
$this->saveHistory($detail['vr_sq'], $detail['pre_stat_cd'], 'C25', $usr_id, $memo);
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
];
|
||||
}
|
||||
|
||||
// 정보수정
|
||||
public function modifyInfo($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, $atcl_amt4, $isale_amt, $prem_amt)
|
||||
{
|
||||
$this->db->transStart();
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$detail = $this->getDetail($atcl_vr_sq);
|
||||
|
||||
if ($trade_type != 'B2') {
|
||||
// 월세가 아닐경우에는 월세가에 0으로 ....
|
||||
$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_amt4))
|
||||
$data['deal_amt'] = $atcl_amt4;
|
||||
if (!empty($isale_amt))
|
||||
$data['isale_amt'] = $isale_amt;
|
||||
if (!empty($prem_amt))
|
||||
$data['prem_amt'] = $prem_amt;
|
||||
if (!empty($atcl_floor))
|
||||
$data['floor'] = $atcl_floor;
|
||||
if (!empty($atcl_floor2))
|
||||
$data['floor2'] = $atcl_floor2;
|
||||
$data['modify_yn'] = 'Y';
|
||||
|
||||
$builder = $this->db->table('v2_modify_info');
|
||||
$ok = $builder->where('vr_sq', $atcl_vr_sq)->update($data);
|
||||
if ($ok === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
$current_url = current_url();
|
||||
|
||||
|
||||
$memo = "상세정보수정 ";
|
||||
$this->saveHistory(vr_sq: $detail['vr_sq'], stat_cd: $detail['pre_stat_cd'], chg_type: 'C25', usr_id: $usr_id, memo: $memo);
|
||||
|
||||
$faxModel = new FaxModel();
|
||||
$faxModel->updateAddress($atcl_vr_sq, $detail['address_code'], $data['address2'], $data['address3'], $data['hscp_no'], $data['hscp_nm']);
|
||||
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function saveModifyVrfc($atcl_vr_sq, $atcl_vrfc_type)
|
||||
{
|
||||
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$list = $this->get_detail($atcl_vr_sq); //변경된 내용 비교를 위해.
|
||||
|
||||
$data['vrfc_type'] = $atcl_vrfc_type;
|
||||
|
||||
$this->db->where('vr_sq', $atcl_vr_sq);
|
||||
$this->db->trans_start();
|
||||
$this->db->update('v2_vrfc_req', $data);
|
||||
|
||||
$data['vrfc_type_cd'] = $atcl_vrfc_type;
|
||||
$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) {
|
||||
// $changed = $this->what_is_changed($list['data'], $data, $atcl_vr_sq);
|
||||
if (!empty($changed)) {
|
||||
$this->saveHistory($list['data']['vr_sq'], $list['data']['pre_stat_cd'], 'C25', $usr_id, "상세정보 수정");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->transComplete();
|
||||
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 = [
|
||||
$err_sq,
|
||||
$err_code,
|
||||
$err_nm,
|
||||
$err_time,
|
||||
$err_no,
|
||||
$err_server
|
||||
];
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// 상태변경
|
||||
public function chgArticleStatus($data)
|
||||
{
|
||||
@@ -961,6 +1025,601 @@ class M701Model extends Model
|
||||
];
|
||||
}
|
||||
|
||||
// 현재상태확인
|
||||
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 chkTryCnt($vr_sq)
|
||||
{
|
||||
$columns = 'a.try_cnt';
|
||||
$builder = $this->db->table('v2_vrfc_req a');
|
||||
$builder->select($columns);
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$query = $builder->get();
|
||||
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function chkRegiTryCnt($atcl_vr_sq)
|
||||
{ //1차 검증인지 2차 검증인지 확인.
|
||||
$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($vr_sq, $reg_yn)
|
||||
{
|
||||
$columns = "a.vr_sq";
|
||||
$builder = $this->db->table('v2_confirm a');
|
||||
$builder->select($columns);
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
|
||||
if ($reg_yn) {
|
||||
$builder->where('vrfc_type', $reg_yn); // 등기부등본 정보 확인시
|
||||
}
|
||||
|
||||
$query = $builder->get();
|
||||
$result = $query->getNumRows();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function insertConfirm($vr_sq, $vrfc_type, $success, $type, $usr_id = '', $usr_sq = '')
|
||||
{
|
||||
if (empty($usr_sq))
|
||||
$usr_sq = session('usr_sq');
|
||||
if (empty($usr_id))
|
||||
$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()) " .
|
||||
" ON DUPLICATE KEY UPDATE" .
|
||||
" success=values(success), charger=values(charger)
|
||||
, date=values(date), update_user=values(update_user), update_tm=values(update_tm)";
|
||||
|
||||
$data = [
|
||||
$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,
|
||||
];
|
||||
|
||||
$builder = $this->db->table('v2_confirm');
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$builder->where('vrfc_type', $vrfc_type);
|
||||
$builder->update($data);
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function chgStat($vr_sq, $stat_cd, $insert_tm)
|
||||
{
|
||||
$usr_sq = session('usr_sq');
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$list = $this->getDetail($vr_sq);
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
$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 = [
|
||||
$vr_sq,
|
||||
$stat_cd,
|
||||
$usr_sq,
|
||||
$insert_tm,
|
||||
];
|
||||
|
||||
if ($this->db->query($sql, $data) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$this->saveHistory($list['vr_sq'], $stat_cd, 'C9', $usr_id, '서류확인 정보 변경');
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
];
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
// 파일정보 저장
|
||||
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 insertChkList($vr_sq, $vrfc_type, $type, $code, $comment)
|
||||
{
|
||||
if (is_array($comment)) {
|
||||
$comment = implode('|', $comment);
|
||||
}
|
||||
|
||||
$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 = [
|
||||
$vr_sq,
|
||||
$vrfc_type,
|
||||
$type,
|
||||
$code,
|
||||
$comment,
|
||||
$usr_sq
|
||||
];
|
||||
|
||||
|
||||
$res = $this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function chgTryCnt($vr_sq, $try_cnt)
|
||||
{ //v2_vrfc_req try_cnt 값 변경.
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET try_cnt = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$try_cnt,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증결과 전송 API를 위한 데이터 조회..
|
||||
*/
|
||||
public function getDataConfirmAPI($vr_sq)
|
||||
{
|
||||
// 요청정보
|
||||
$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
|
||||
FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$rowVrfcReq = $query->getRowArray();
|
||||
|
||||
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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$rowArticleInfo = $query->getRowArray();
|
||||
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
|
||||
// 수정정보
|
||||
$sql = "SELECT vr_sq, bild_nm, rm_no, floor, address_code, address2, address3, address4, 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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$rowModifyInfo = $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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq, $rowVrfcReq['vrfc_type']]);
|
||||
$rowConfirm = $query->getRowArray();
|
||||
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
|
||||
// 확인정보
|
||||
$sql = "SELECT type, code, comment, ownerNm, ownerBirth FROM v2_check_list WHERE vr_sq = ? AND vrfc_type = ? AND type LIKE CONCAT(vrfc_type, '%')";
|
||||
$query = $this->db->query($sql, [$vr_sq, $rowVrfcReq['vrfc_type']]);
|
||||
$resCheckList = $query->getResultArray();
|
||||
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
|
||||
if (!empty($rowConfirm)) {
|
||||
log_message('debug', implode(', ', $rowConfirm));
|
||||
}
|
||||
|
||||
$atclNo = $rowVrfcReq['atcl_no'] ?? null;
|
||||
$success = !empty($rowConfirm['success']);
|
||||
$charger = $rowConfirm['charger'] ?? null;
|
||||
$date = $rowConfirm['date'] ?? null;
|
||||
$tryCnt = $rowVrfcReq['try_cnt'] ?? 0;
|
||||
|
||||
$checkList = [];
|
||||
foreach ($resCheckList as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['ownerBirth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if (($rowModifyInfo['modify_yn'] ?? 'N') === 'Y') {
|
||||
if (!empty($rowModifyInfo['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'hscpNo' => $rowModifyInfo['hscp_no'],
|
||||
'ptpNo' => $rowModifyInfo['ptp_no'],
|
||||
'bildNm' => $rowModifyInfo['address2'],
|
||||
'rmNo' => $rowModifyInfo['address3'],
|
||||
'tradeType' => $rowModifyInfo['trade_type'],
|
||||
'dealAmt' => $rowModifyInfo['deal_amt'],
|
||||
'wrrntAmt' => $rowModifyInfo['wrrnt_amt'],
|
||||
'leaseAmt' => $rowModifyInfo['lease_amt'],
|
||||
'isaleAmt' => $rowModifyInfo['isale_amt'],
|
||||
'premAmt' => $rowModifyInfo['prem_amt'],
|
||||
'floor' => $rowModifyInfo['floor'],
|
||||
];
|
||||
} else {
|
||||
// 비공동주택
|
||||
$modifyInfo = [
|
||||
'addressCode' => $rowModifyInfo['address_code'],
|
||||
'address2' => $rowModifyInfo['address2'],
|
||||
'address3' => $rowModifyInfo['address3'],
|
||||
'tradeType' => $rowModifyInfo['trade_type'],
|
||||
'dealAmt' => $rowModifyInfo['deal_amt'],
|
||||
'wrrntAmt' => $rowModifyInfo['wrrnt_amt'],
|
||||
'leaseAmt' => $rowModifyInfo['lease_amt'],
|
||||
'splySpc' => $rowModifyInfo['sply_spc'],
|
||||
'exclsSpc' => $rowModifyInfo['excls_spc'],
|
||||
'totSpc' => $rowModifyInfo['tot_spc'],
|
||||
'grndSpc' => $rowModifyInfo['grnd_spc'],
|
||||
'bldgSpc' => $rowModifyInfo['bldg_spc'],
|
||||
'floor' => $rowModifyInfo['floor'],
|
||||
'floor2' => $rowModifyInfo['floor2'],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'try_cnt' => $tryCnt,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'try_cnt' => $tryCnt,
|
||||
];
|
||||
}
|
||||
|
||||
/* 등기부등본 API 호출*/
|
||||
/**
|
||||
* $vrfc_type: 값이 R이면 등기부등본
|
||||
*/
|
||||
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, reg_try_cnt, owner_verifiable
|
||||
FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$rowVrfcReq = $query->getRowArray();
|
||||
|
||||
if (!empty($vrfc_type)) {
|
||||
$rowVrfcReq['vrfc_type'] = $vrfc_type;
|
||||
}
|
||||
|
||||
log_message('debug', (string) $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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$rowArticleInfo = $query->getRowArray();
|
||||
|
||||
log_message('debug', (string) $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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$rowModifyInfo = $query->getRowArray();
|
||||
|
||||
log_message('debug', (string) $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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq, $rowVrfcReq['vrfc_type']]);
|
||||
$rowConfirm = $query->getRowArray();
|
||||
|
||||
log_message('debug', (string) $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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq, $rowVrfcReq['vrfc_type']]);
|
||||
$resCheckList = $query->getResultArray();
|
||||
|
||||
log_message('debug', (string) $this->db->getLastQuery());
|
||||
|
||||
if (!empty($rowConfirm)) {
|
||||
log_message('debug', implode(', ', $rowConfirm));
|
||||
}
|
||||
|
||||
$atclNo = $rowVrfcReq['atcl_no'] ?? null;
|
||||
$type = $rowVrfcReq['try_cnt'] ?? null;
|
||||
$success = !empty($rowConfirm['success']);
|
||||
$charger = $rowConfirm['charger'] ?? null;
|
||||
$date = $rowConfirm['date'] ?? null;
|
||||
|
||||
switch ($rowVrfcReq['owner_verifiable'] ?? null) {
|
||||
case '1':
|
||||
case 'true':
|
||||
$ownerVerifiable = true;
|
||||
break;
|
||||
default:
|
||||
$ownerVerifiable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$checkList = [];
|
||||
foreach ($resCheckList as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['owner_birth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if (($rowModifyInfo['modify_yn'] ?? 'N') === 'Y') {
|
||||
if (!empty($rowModifyInfo['hscp_no'])) {
|
||||
$modifyInfo = [
|
||||
'hscpNo' => $rowModifyInfo['hscp_no'],
|
||||
'ptpNo' => $rowModifyInfo['ptp_no'],
|
||||
'bildNm' => $rowModifyInfo['address2'],
|
||||
'rmNo' => $rowModifyInfo['address3'],
|
||||
'tradeType' => $rowModifyInfo['trade_type'],
|
||||
'dealAmt' => $rowModifyInfo['deal_amt'],
|
||||
'wrrntAmt' => $rowModifyInfo['wrrnt_amt'],
|
||||
'leaseAmt' => $rowModifyInfo['lease_amt'],
|
||||
'isaleAmt' => $rowModifyInfo['isale_amt'],
|
||||
'premAmt' => $rowModifyInfo['prem_amt'],
|
||||
'floor' => $rowModifyInfo['floor'],
|
||||
];
|
||||
} else {
|
||||
$modifyInfo = [
|
||||
'addressCode' => $rowModifyInfo['address_code'],
|
||||
'address2' => $rowModifyInfo['address2'],
|
||||
'address3' => $rowModifyInfo['address3'],
|
||||
'tradeType' => $rowModifyInfo['trade_type'],
|
||||
'dealAmt' => $rowModifyInfo['deal_amt'],
|
||||
'wrrntAmt' => $rowModifyInfo['wrrnt_amt'],
|
||||
'leaseAmt' => $rowModifyInfo['lease_amt'],
|
||||
'splySpc' => $rowModifyInfo['sply_spc'],
|
||||
'exclsSpc' => $rowModifyInfo['excls_spc'],
|
||||
'totSpc' => $rowModifyInfo['tot_spc'],
|
||||
'grndSpc' => $rowModifyInfo['grnd_spc'],
|
||||
'bldgSpc' => $rowModifyInfo['bldg_spc'],
|
||||
'floor' => $rowModifyInfo['floor'],
|
||||
'floor2' => $rowModifyInfo['floor2'],
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function getUpdateFailTime1($vr_sq)
|
||||
{
|
||||
$sql = "select vr_sq, stat_cd, insert_user, insert_tm " .
|
||||
"from v2_chg_stat " .
|
||||
"where vr_sq = ? and stat_cd = '39' " .
|
||||
"order by insert_tm desc " .
|
||||
"limit 1";
|
||||
$data = array($vr_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
|
||||
}
|
||||
|
||||
public function getUpdateFailTime2($vr_sq)
|
||||
{
|
||||
$sql = "select vr_sq, stat_cd, insert_user, insert_tm " .
|
||||
"from v2_chg_stat " .
|
||||
"where vr_sq = ? and stat_cd = '49' " .
|
||||
"order by insert_tm desc " .
|
||||
"limit 1";
|
||||
$data = array($vr_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function deleteChkList($vr_sq, $vrfc_type, $type)
|
||||
{
|
||||
$sql = "delete from v2_check_list where vr_sq = ? and vrfc_type = ? and type = ?";
|
||||
$data = array(
|
||||
$vr_sq,
|
||||
$vrfc_type,
|
||||
$type
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function up_tel_fail_cause($vr_sq, $tel_fail_cause)
|
||||
{
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET tel_fail_cause = ? " .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$tel_fail_cause,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// 변경이력 저장
|
||||
public function saveHistory($vr_sq, $stat_cd, $chg_type, $usr_id, $memo)
|
||||
|
||||
@@ -1,119 +1,11 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\webfax\FaxModel;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M702Model extends Model
|
||||
class M702Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -294,13 +186,13 @@ class M702Model extends Model
|
||||
b.stat_cd,
|
||||
c.bild_nm,
|
||||
b.vrfc_type as vrfc_type_cd,
|
||||
c.rm_no,
|
||||
IFNULL(c.rm_no, '') as rm_no,
|
||||
c.floor,
|
||||
c.address_code,
|
||||
c.address2,
|
||||
k.address2a,
|
||||
k.address2b,
|
||||
c.address3,
|
||||
IFNULL(c.address2, '') as address2,
|
||||
IFNULL(k.address2a, '') as address2a,
|
||||
IFNULL(k.address2b, '') as address2b,
|
||||
IFNULL(c.address3, '') as address3,
|
||||
c.trade_type,
|
||||
c.deal_amt,
|
||||
c.wrrnt_amt,
|
||||
@@ -316,7 +208,7 @@ class M702Model extends Model
|
||||
c.ptp_no,
|
||||
d.insert_tm as update_res_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,
|
||||
@@ -740,6 +632,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 +716,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 +928,490 @@ 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 chgTryCnt($vr_sq, $try_cnt)
|
||||
{ //v2_vrfc_req try_cnt 값 변경.
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET try_cnt = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$try_cnt,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// 변경이력 조회
|
||||
public function getHistory($vr_sq)
|
||||
{
|
||||
|
||||
@@ -2,119 +2,11 @@
|
||||
namespace App\Models\v2;
|
||||
|
||||
use App\Models\receipt\ReceiptModel;
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\webfax\FaxModel;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M703Model extends Model
|
||||
class M703Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -1504,8 +1396,9 @@ class M703Model extends Model
|
||||
$this->saveChangedHistory($vr_sq, '35', 'C9', $insert_id, '현장확인 매물');
|
||||
|
||||
|
||||
$fax = $this->fax_model->selectFax($fax_sq); // fax 이미지 파일 가져오기
|
||||
$receipt = $this->receipt_model->selectReceiptOne($vr_sq); // 매물정보 가져오기
|
||||
$faxModel = new FaxModel();
|
||||
$fax = $faxModel->selectFax($fax_sq); // fax 이미지 파일 가져오기
|
||||
$receipt = $this->selectReceiptOne($vr_sq); // 매물정보 가져오기
|
||||
|
||||
// 40: 촬영, 70: 검수지연... 상태가 촬용 이전 또는 검수지연 상태일 경우에만 홍보확인서를 등록한다.
|
||||
if (substr($receipt['rcpt_stat'], 0, 2) <= '40' || substr($receipt['rcpt_stat'], 0, 2) == '70') {
|
||||
@@ -2115,8 +2008,8 @@ class M703Model extends Model
|
||||
*/
|
||||
public function saveChangeStep($fax_sq, $vr_sq, $stat_cd)
|
||||
{
|
||||
$insert_user = $this->session->userdata('usr_sq');
|
||||
$insert_id = $this->session->userdata('usr_id');
|
||||
$insert_user = session('usr_sq');
|
||||
$insert_id = session('usr_id');
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
|
||||
@@ -1,119 +1,11 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\webfax\FaxModel;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M704Model extends Model
|
||||
class M704Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -787,6 +679,149 @@ class M704Model extends Model
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
/* 매물정보를 수정 */
|
||||
//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, $atcl_amt4, $isale_amt, $prem_amt){
|
||||
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, $atcl_amt4, $isale_amt, $prem_amt)
|
||||
{
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$list = $this->getDetail($atcl_vr_sq); // 변경된 내용 비교를 위해.
|
||||
|
||||
if ($trade_type != 'B2') {
|
||||
// 월세가 아닐경우에는 월세가에 0으로 ....
|
||||
$atcl_amt3 = '0';
|
||||
$data['lease_amt'] = $atcl_amt3;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
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_amt4))
|
||||
$data['deal_amt'] = $atcl_amt4;
|
||||
if (!empty($isale_amt))
|
||||
$data['isale_amt'] = $isale_amt;
|
||||
if (!empty($prem_amt))
|
||||
$data['prem_amt'] = $prem_amt;
|
||||
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);
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
$current_url = current_url();
|
||||
log_message('debug', "{$current_url} :: {$last_query}");
|
||||
|
||||
$data['trade_type_cd'] = $trade_type;
|
||||
$error = $this->db->error();
|
||||
$return['error_number'] = $error['code'];
|
||||
$return['error_message'] = $error['message'];
|
||||
|
||||
if (empty($return['error_number'])) {
|
||||
// 로그를 남긴다.
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$changed = $this->whatIsChanged($list, $data, $atcl_vr_sq);
|
||||
if (!empty($changed)) {
|
||||
$this->saveChangedHistory($list['vr_sq'], $list['pre_stat_cd'], 'C25', $usr_id, $changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
// 홍보확인서인 경우 주소 변경시 FAX 이미지의 정보도 함께 변경한다.
|
||||
$faxModel = new FaxModel();
|
||||
$faxModel->updateAddress($atcl_vr_sq, $list['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 = [];
|
||||
$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);
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
$current_url = current_url();
|
||||
log_message('debug', "{$current_url} :: {$last_query}");
|
||||
|
||||
$data['vrfc_type_cd'] = $atcl_vrfc_type;
|
||||
|
||||
$error = $this->db->error();
|
||||
$return['error_number'] = $error['code'];
|
||||
$return['error_message'] = $error['message'];
|
||||
|
||||
if (empty($return['error_number'])) {
|
||||
// 로그를 남긁다.
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$changed = $this->whatIsChanged($list, $data, $atcl_vr_sq);
|
||||
if (!empty($changed)) {
|
||||
$this->saveChangedHistory($list['vr_sq'], $list['pre_stat_cd'], 'C25', $usr_id, $changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
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
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// 메모조회
|
||||
public function getMemo($vr_sq)
|
||||
{
|
||||
@@ -971,6 +1006,30 @@ class M704Model extends Model
|
||||
];
|
||||
}
|
||||
|
||||
// 전화실패
|
||||
public function saveContactFail($vr_sq)
|
||||
{
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$sql = "update v2_vrfc_req set contact_fail_cnt = ifnull(contact_fail_cnt, 0) +1 where vr_sq = ?";
|
||||
$data = array($vr_sq);
|
||||
|
||||
if ($this->db->query($sql, $data) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '통화실패 처리중 오류가 발생했습니다.',
|
||||
];
|
||||
}
|
||||
|
||||
$row = $this->getDetail($vr_sq);
|
||||
|
||||
$this->saveChangedHistory($vr_sq, $row['data']['stat_cd'], 'C29', $usr_id, '통화실패');
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
];
|
||||
}
|
||||
|
||||
// 다음 전화매물 가져오기
|
||||
public function getNextTelInfo($vr_sq)
|
||||
{
|
||||
@@ -1003,4 +1062,409 @@ class M704Model extends Model
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/* 현재 상태 확인 */
|
||||
public function chkStat($vr_sq)
|
||||
{
|
||||
$sql = "SELECT stat_cd FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// 1차 검증인지 2차 검증인지 확인.
|
||||
$sql = "SELECT try_cnt FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$atcl_vr_sq]);
|
||||
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
/*
|
||||
* 등기부등본 확인중의 상태인 적이 있었는지 확인
|
||||
*/
|
||||
public function chkHistoryStat($atcl_vr_sq)
|
||||
{
|
||||
$sql = "select count(a.stat_cd) from v2_chg_history a " .
|
||||
"where vr_sq = ? and stat_cd = 40 " .
|
||||
"order by vr_sq desc;";
|
||||
$data = array(
|
||||
$atcl_vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function chkConfirm($atcl_vr_sq, $reg_yn = null)
|
||||
{
|
||||
$builder = $this->db->table('v2_confirm');
|
||||
$builder->select('vr_sq');
|
||||
$builder->where('vr_sq', $atcl_vr_sq);
|
||||
|
||||
if ($reg_yn) {
|
||||
$builder->where('vrfc_type', $reg_yn);
|
||||
}
|
||||
|
||||
$query = $builder->get();
|
||||
return $query->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 getUpdateFailTime($vr_sq)
|
||||
{
|
||||
$sql = "select vr_sq, stat_cd, insert_user, insert_tm " .
|
||||
"from v2_chg_stat " .
|
||||
"where vr_sq = ? and stat_cd = 39 " .
|
||||
"order by insert_tm desc " .
|
||||
"limit 1";
|
||||
$data = array($vr_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function updateConfirm($vr_sq, $vrfc_type, $success)
|
||||
{
|
||||
$data = [
|
||||
'success' => $success
|
||||
];
|
||||
|
||||
$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'];
|
||||
$return['error_message'] = $error['message'];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
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 = [
|
||||
$vr_sq,
|
||||
$stat_cd,
|
||||
$usr_sq,
|
||||
$insert_tm
|
||||
];
|
||||
|
||||
$this->db->transStart();
|
||||
$res = $this->db->query($sql, $data);
|
||||
|
||||
$error = $this->db->error();
|
||||
$return['error_number'] = $error['code'];
|
||||
$return['error_message'] = $error['message'];
|
||||
|
||||
if (empty($return['error_number'])) {
|
||||
// 로그를 남긴다.
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$changed = "전화확인 정보 저장";
|
||||
if (!empty($changed)) {
|
||||
$this->saveChangedHistory($list['vr_sq'], $stat_cd, 'C9', $usr_id, $changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
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'];
|
||||
$return['error_message'] = $error['message'];
|
||||
|
||||
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'];
|
||||
$return['error_message'] = $error['message'];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function chgRegTryCnt($vr_sq, $reg_try_cnt)
|
||||
{
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET reg_try_cnt = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$reg_try_cnt,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$res = $this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function chgTryCnt($vr_sq, $try_cnt)
|
||||
{ //v2_vrfc_req try_cnt 값 변경.
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET try_cnt = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$try_cnt,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$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);
|
||||
$log_v = $this->db->getLastQuery();
|
||||
log_message('debug', "704 => " . $log_v);
|
||||
|
||||
}
|
||||
|
||||
public function deleteChkList($vr_sq, $vrfc_type, $type)
|
||||
{
|
||||
$sql = "delete from v2_check_list where vr_sq = ? and vrfc_type = ? and type = ?";
|
||||
$data = array(
|
||||
$vr_sq,
|
||||
$vrfc_type,
|
||||
$type
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function up_tel_fail_cause($vr_sq, $tel_fail_cause)
|
||||
{
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET tel_fail_cause = ? " .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$tel_fail_cause,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$res = $this->db->query($sql, $data);
|
||||
echo $this->db->getLastQuery();
|
||||
$return['error_number'] = $this->db->_error_number();
|
||||
$return['error_message'] = $this->db->_error_message();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/* 검증결과 전송 API를 위한 데이터 조회. */
|
||||
public function getDataConfirmAPI($vr_sq)
|
||||
{
|
||||
// 요청정보
|
||||
$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" .
|
||||
" FROM v2_vrfc_req where vr_sq = ?";
|
||||
$data = [$vr_sq];
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row_vrfc_req = $query->getRowArray();
|
||||
|
||||
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 = [$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, address4, 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 = [$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 = [$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 cl_sq, vr_sq, vrfc_type, type, code, comment, ownerNm, ownerBirth insert_user, insert_tm " .
|
||||
" FROM v2_check_list where vr_sq = ? and vrfc_type = ? and type like concat(vrfc_type, '%')";
|
||||
$data = [$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'];
|
||||
$success = empty($row_confirm['success']) ? false : true;
|
||||
$charger = $row_confirm['charger'];
|
||||
$date = $row_confirm['date'];
|
||||
|
||||
$checkList = [];
|
||||
foreach ($res_check_list as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['ownerBirth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if ($row_modify_info['modify_yn'] == 'Y') {
|
||||
if (!empty($row_modify_info['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'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 = [
|
||||
'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 [
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'try_cnt' => '',
|
||||
];
|
||||
} else {
|
||||
return array(
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,119 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M705Model extends Model
|
||||
class M705Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -248,22 +139,22 @@ class M705Model extends Model
|
||||
}
|
||||
|
||||
// 본부
|
||||
if (!empty($data['bonbu'])) {
|
||||
if ($data['charger_gbn'] === "1") {
|
||||
$sql .= "AND a.dept1_sq = '{$data['bonbu']}' ";
|
||||
} else {
|
||||
$sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' ";
|
||||
}
|
||||
}
|
||||
// if (!empty($data['bonbu'])) {
|
||||
// if ($data['charger_gbn'] === "1") {
|
||||
// $sql .= "AND a.dept1_sq = '{$data['bonbu']}' ";
|
||||
// } else {
|
||||
// $sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' ";
|
||||
// }
|
||||
// }
|
||||
|
||||
// 팀
|
||||
if (!empty($data['team'])) {
|
||||
if ($data['charger_gbn'] === "1") {
|
||||
$sql .= "AND a.dept2_sq = '{$data['team']}' ";
|
||||
} else {
|
||||
$sql .= "AND a.reg_dept2_sq = '{$data['team']}' ";
|
||||
}
|
||||
}
|
||||
// if (!empty($data['team'])) {
|
||||
// if ($data['charger_gbn'] === "1") {
|
||||
// $sql .= "AND a.dept2_sq = '{$data['team']}' ";
|
||||
// } else {
|
||||
// $sql .= "AND a.reg_dept2_sq = '{$data['team']}' ";
|
||||
// }
|
||||
// }
|
||||
|
||||
// 매물종류
|
||||
if (!empty($data['rlet_type_cd'])) {
|
||||
@@ -479,22 +370,22 @@ class M705Model extends Model
|
||||
}
|
||||
|
||||
// 본부
|
||||
if (!empty($data['bonbu'])) {
|
||||
if ($data['charger_gbn'] === "1") {
|
||||
$sql .= "AND a.dept1_sq = '{$data['bonbu']}' ";
|
||||
} else {
|
||||
$sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' ";
|
||||
}
|
||||
}
|
||||
// if (!empty($data['bonbu'])) {
|
||||
// if ($data['charger_gbn'] === "1") {
|
||||
// $sql .= "AND a.dept1_sq = '{$data['bonbu']}' ";
|
||||
// } else {
|
||||
// $sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' ";
|
||||
// }
|
||||
// }
|
||||
|
||||
// 팀
|
||||
if (!empty($data['team'])) {
|
||||
if ($data['charger_gbn'] === "1") {
|
||||
$sql .= "AND a.dept2_sq = '{$data['team']}' ";
|
||||
} else {
|
||||
$sql .= "AND a.reg_dept2_sq = '{$data['team']}' ";
|
||||
}
|
||||
}
|
||||
// if (!empty($data['team'])) {
|
||||
// if ($data['charger_gbn'] === "1") {
|
||||
// $sql .= "AND a.dept2_sq = '{$data['team']}' ";
|
||||
// } else {
|
||||
// $sql .= "AND a.reg_dept2_sq = '{$data['team']}' ";
|
||||
// }
|
||||
// }
|
||||
|
||||
// 매물종류
|
||||
if (!empty($data['rlet_type_cd'])) {
|
||||
@@ -526,6 +417,8 @@ class M705Model extends Model
|
||||
|
||||
$sql .= "LIMIT {$start}, {$end}";
|
||||
|
||||
// echo $sql;
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
@@ -739,22 +632,22 @@ class M705Model extends Model
|
||||
}
|
||||
|
||||
// 본부
|
||||
if (!empty($data['bonbu'])) {
|
||||
if ($data['charger_gbn'] === "1") {
|
||||
$sql .= "AND a.dept1_sq = '{$data['bonbu']}' ";
|
||||
} else {
|
||||
$sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' ";
|
||||
}
|
||||
}
|
||||
// if (!empty($data['bonbu'])) {
|
||||
// if ($data['charger_gbn'] === "1") {
|
||||
// $sql .= "AND a.dept1_sq = '{$data['bonbu']}' ";
|
||||
// } else {
|
||||
// $sql .= "AND a.reg_dept1_sq = '{$data['bonbu']}' ";
|
||||
// }
|
||||
// }
|
||||
|
||||
// 팀
|
||||
if (!empty($data['team'])) {
|
||||
if ($data['charger_gbn'] === "1") {
|
||||
$sql .= "AND a.dept2_sq = '{$data['team']}' ";
|
||||
} else {
|
||||
$sql .= "AND a.reg_dept2_sq = '{$data['team']}' ";
|
||||
}
|
||||
}
|
||||
// if (!empty($data['team'])) {
|
||||
// if ($data['charger_gbn'] === "1") {
|
||||
// $sql .= "AND a.dept2_sq = '{$data['team']}' ";
|
||||
// } else {
|
||||
// $sql .= "AND a.reg_dept2_sq = '{$data['team']}' ";
|
||||
// }
|
||||
// }
|
||||
|
||||
// 매물종류
|
||||
if (!empty($data['rlet_type_cd'])) {
|
||||
@@ -1032,6 +925,7 @@ class M705Model extends Model
|
||||
$sql = "UPDATE v2_files SET use_yn = 'N' WHERE vr_sq = {$data['vr_sq']} AND use_yn = 'Y' AND file_type '2'";
|
||||
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO v2_files
|
||||
(vr_sq, file_type, view_odr, file_path, file_name, file_ext, file_size, insert_user, insert_tm, cloud_upload_yn)
|
||||
@@ -1049,14 +943,13 @@ class M705Model extends Model
|
||||
];
|
||||
|
||||
|
||||
if ($this->db->query($sql, $param)) {
|
||||
if ($this->db->query($sql, $param) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '파일정보 저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
@@ -1094,4 +987,476 @@ class M705Model extends Model
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function chkRegiTryCnt($atcl_vr_sq)
|
||||
{
|
||||
// 1차 검증인지 2차 검증인지 확인
|
||||
$sql = "SELECT reg_try_cnt
|
||||
FROM v2_vrfc_req
|
||||
WHERE vr_sq = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$atcl_vr_sq]);
|
||||
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function chkConfirm($atcl_vr_sq, $reg_yn)
|
||||
{
|
||||
// 검증결과 table에 있는지 확인.
|
||||
$builder = $this->db->table('v2_confirm');
|
||||
$builder->select('vr_sq');
|
||||
$builder->where('vr_sq', $atcl_vr_sq);
|
||||
|
||||
if ($reg_yn) {
|
||||
$builder->where('vrfc_type', $reg_yn); // 등기부등본 정보 확인시
|
||||
}
|
||||
|
||||
$query = $builder->get();
|
||||
$result = $query->getNumRows();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUpdateFailTime($vr_sq)
|
||||
{
|
||||
$sql = "select vr_sq, stat_cd, insert_user, insert_tm " .
|
||||
"from v2_chg_stat " .
|
||||
"where vr_sq = ? and stat_cd = '49' " .
|
||||
"order by insert_tm desc " .
|
||||
"limit 1";
|
||||
$data = array($vr_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
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'],
|
||||
'error_message' => $error['message']
|
||||
];
|
||||
}
|
||||
|
||||
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 add_cert_uncnfrm_status($vr_sq, $cert_uncnfrm_status)
|
||||
{
|
||||
$builder = $this->db->table('v2_article_info');
|
||||
$builder->select('vr_sq, atcl_no');
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
|
||||
$query = $builder->get();
|
||||
|
||||
if ($query->getNumRows() > 0) {
|
||||
$row = $query->getRowArray();
|
||||
$atcl_no = $row['atcl_no'];
|
||||
|
||||
$sql = "INSERT INTO v2_article_info_etc (vr_sq, atcl_no, cert_uncnfrm_status)" .
|
||||
" VALUES (?, ?, ?)" .
|
||||
" ON DUPLICATE KEY UPDATE cert_uncnfrm_status = ?";
|
||||
|
||||
$data = [
|
||||
$vr_sq,
|
||||
$atcl_no,
|
||||
$cert_uncnfrm_status,
|
||||
$cert_uncnfrm_status
|
||||
];
|
||||
|
||||
$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);
|
||||
|
||||
}
|
||||
|
||||
// 메모저장
|
||||
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) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '파일정보 저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$row = $this->getDetail($data[1]);
|
||||
|
||||
$memo = "메모변경 : " . $row['memo'] . " => " . $data[0];
|
||||
$this->saveChangedHistory($data[1], $row['pre_stat_cd'], 'C19', $usr_id, $memo);
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
];
|
||||
}
|
||||
|
||||
public function update_owner_verifiable($vr_sq, $owner_verifiable)
|
||||
{
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET owner_verifiable = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$owner_verifiable,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
$s = $this->db->getLastQuery();
|
||||
log_message('debug', "====update_owner_verifiable====" . $s);
|
||||
}
|
||||
|
||||
/* 등기부등본 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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$row_vrfc_req = $query->getRowArray();
|
||||
|
||||
if (!empty($vrfc_type)) {
|
||||
$row_vrfc_req['vrfc_type'] = $vrfc_type;
|
||||
}
|
||||
|
||||
log_message('debug', 'getDatacertApi_query => ' . $this->db->getLastQuery());
|
||||
log_message('debug', 'getDatacertApi_result => ' . json_encode($row_vrfc_req));
|
||||
|
||||
// 매물정보
|
||||
$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, vrfc_type_sub" .
|
||||
" FROM v2_article_info WHERE vr_sq = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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'];
|
||||
|
||||
switch ($row_vrfc_req['owner_verifiable']) {
|
||||
case "1":
|
||||
case "true":
|
||||
$ownerVerifiable = true;
|
||||
break;
|
||||
default:
|
||||
$ownerVerifiable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$checkList = [];
|
||||
foreach ($res_check_list as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['owner_birth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if ($row_modify_info['modify_yn'] == 'Y') {
|
||||
if (!empty($row_modify_info['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'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 = [
|
||||
'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_data = [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'vrfcType' => $row_article_info['vrfc_type_sub'],
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
|
||||
log_message('debug', "705 getDatacertAPI_1 {$atclNo} ::: " . json_encode($return_data) . PHP_EOL);
|
||||
|
||||
return $return_data;
|
||||
} else {
|
||||
$return_data = [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'vrfcType' => $row_article_info['vrfc_type_sub'],
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
|
||||
log_message('debug', "705 getDatacertAPI_2 {$atclNo} ::: " . json_encode($return_data) . PHP_EOL);
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
}
|
||||
|
||||
public function chgStat($vr_sq, $stat_cd, $insert_tm)
|
||||
{
|
||||
$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 = [
|
||||
$vr_sq,
|
||||
$stat_cd,
|
||||
$usr_sq,
|
||||
$insert_tm
|
||||
];
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
$error = $this->db->error();
|
||||
$return = [
|
||||
'error_number' => $error['code'],
|
||||
'error_message' => $error['message']
|
||||
];
|
||||
|
||||
if (empty($return['error_number'])) {
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$changed = $this->whatIsChanged($list, $data, '');
|
||||
if (!empty($changed)) {
|
||||
$this->saveChangedHistory($list['vr_sq'], $stat_cd, 'C9', $usr_id, $changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
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'],
|
||||
'error_message' => $error['message']
|
||||
];
|
||||
}
|
||||
|
||||
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'],
|
||||
'error_message' => $error['message']
|
||||
];
|
||||
}
|
||||
|
||||
public function updateStat($vr_sq, $reg_status)
|
||||
{
|
||||
$data = ['reg_status' => $reg_status];
|
||||
|
||||
$builder = $this->db->table('v2_article_info');
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$builder->update($data);
|
||||
|
||||
$error = $this->db->error();
|
||||
|
||||
return [
|
||||
'error' => [
|
||||
'code' => $error['code'],
|
||||
'message' => $error['message']
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function resetTelConf($vr_sq)
|
||||
{
|
||||
$sql = "update v2_check_list " .
|
||||
"set code = '' " .
|
||||
"where type in ('T11', 'T12', 'T13', 'T14') " .
|
||||
"and vr_sq = ?";
|
||||
|
||||
$data = array($vr_sq);
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,119 +1,11 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\webfax\FaxModel;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M706Model extends Model
|
||||
class M706Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -757,6 +649,679 @@ class M706Model extends Model
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
/* 매물정보를 수정 */
|
||||
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)
|
||||
{
|
||||
$session = session();
|
||||
$usr_id = $session->get('usr_id');
|
||||
|
||||
$list = $this->getDetail($atcl_vr_sq);
|
||||
|
||||
$data = [];
|
||||
|
||||
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);
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
$current_url = current_url();
|
||||
log_message('debug', $current_url . ' :: ' . $last_query);
|
||||
|
||||
$data['trade_type_cd'] = $trade_type;
|
||||
$return['error_number'] = $this->db->error()['code'];
|
||||
$return['error_message'] = $this->db->error()['message'];
|
||||
|
||||
if (empty($return['error_number'])) {
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
if (!empty($changed)) {
|
||||
$this->saveChangedHistory($list['vr_sq'], $list['pre_stat_cd'], 'C25', $usr_id, "매물정보 수정");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->transComplete();
|
||||
|
||||
// 홍보확인서인 경우 주소 변경시 FAX 이미지의 정보도 함께 변경한다.
|
||||
$faxModel = new FaxModel();
|
||||
$faxModel->updateAddress($atcl_vr_sq, $list['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->where('vr_sq', $atcl_vr_sq);
|
||||
$this->db->trans_start();
|
||||
$this->db->update('v2_vrfc_req', $data);
|
||||
|
||||
$data['vrfc_type_cd'] = $atcl_vrfc_type;
|
||||
//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->saveChangedHistory($list['data']['vr_sq'], $list['data']['pre_stat_cd'], 'C25', $usr_id, "매물정보 저장");
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->db->trans_complete();
|
||||
return $return;
|
||||
}
|
||||
|
||||
/* 현재 상태 확인 */
|
||||
public function chkStat($vr_sq)
|
||||
{
|
||||
$sql = "SELECT stat_cd FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
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)
|
||||
{
|
||||
// 1차 검증인지 2차 검증인지 확인.
|
||||
$builder = $this->db->table('v2_vrfc_req');
|
||||
$builder->select('try_cnt');
|
||||
$builder->where('vr_sq', $atcl_vr_sq);
|
||||
|
||||
$query = $builder->get();
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function chkConfirm($atcl_vr_sq, $reg_yn = null)
|
||||
{
|
||||
// 검증결과 table에 있는지 확인.
|
||||
$builder = $this->db->table('v2_confirm');
|
||||
$builder->select('vr_sq');
|
||||
$builder->where('vr_sq', $atcl_vr_sq);
|
||||
|
||||
if ($reg_yn) {
|
||||
$builder->where('vrfc_type', $reg_yn); // 등기부등본 정보 확인시
|
||||
}
|
||||
|
||||
$query = $builder->get();
|
||||
return $query->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_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);
|
||||
|
||||
$return = [
|
||||
'error_number' => $this->db->error()['code'],
|
||||
'error_message' => $this->db->error()['message']
|
||||
];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
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 = [
|
||||
$vr_sq,
|
||||
$stat_cd,
|
||||
$usr_sq,
|
||||
$insert_tm
|
||||
];
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
$query = $this->db->query($sql, $data);
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
log_message('debug', $last_query);
|
||||
|
||||
$return['error_number'] = $this->db->error()['code'];
|
||||
$return['error_message'] = $this->db->error()['message'];
|
||||
|
||||
if (empty($return['error_number'])) {
|
||||
// 로그를 남긴다.
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
$changed = $this->whatIsChanged($list, $data, '');
|
||||
if (!empty($changed)) {
|
||||
$this->saveChangedHistory($list['vr_sq'], $stat_cd, 'C9', $usr_id, $changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
log_message('debug', $last_query);
|
||||
|
||||
$return['error_number'] = $this->db->error()['code'];
|
||||
$return['error_message'] = $this->db->error()['message'];
|
||||
|
||||
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);
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
log_message('debug', $last_query);
|
||||
|
||||
$return['error_number'] = $this->db->error()['code'];
|
||||
$return['error_message'] = $this->db->error()['message'];
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function chgTryCnt($vr_sq, $try_cnt)
|
||||
{ //v2_vrfc_req try_cnt 값 변경.
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET try_cnt = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$try_cnt,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$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
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증결과 전송 API를 위한 데이터 조회..
|
||||
*/
|
||||
public function getDataConfirmAPI($vr_sq)
|
||||
{
|
||||
// 요청정보
|
||||
$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" .
|
||||
" FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$row_vrfc_req = $query->getRowArray();
|
||||
|
||||
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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$query->getRowArray();
|
||||
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
|
||||
// 수정정보
|
||||
$sql = "SELECT vr_sq, bild_nm, rm_no, floor, address_code, address2, address3, address4, 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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$row_confirm = $query->getRowArray();
|
||||
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
|
||||
// 확인정보
|
||||
$sql = "SELECT type, code, comment, ownerNm, ownerBirth FROM v2_check_list WHERE vr_sq = ? AND vrfc_type = ? AND type LIKE CONCAT(vrfc_type, '%')";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$res_check_list = $query->getResultArray();
|
||||
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
|
||||
log_message('debug', implode(', ', $row_confirm));
|
||||
|
||||
$atclNo = $row_vrfc_req['atcl_no'];
|
||||
$success = empty($row_confirm['success']) ? false : true;
|
||||
$charger = $row_confirm['charger'];
|
||||
$date = $row_confirm['date'];
|
||||
$try_cnt = $row_vrfc_req['try_cnt'];
|
||||
|
||||
$checkList = [];
|
||||
foreach ($res_check_list as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['ownerBirth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if ($row_modify_info['modify_yn'] === 'Y') {
|
||||
if (!empty($row_modify_info['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'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 = [
|
||||
'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 [
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'try_cnt' => $try_cnt,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'try_cnt' => $try_cnt,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// 1차 검증인지 2차 검증인지 확인.
|
||||
$builder = $this->db->table('v2_vrfc_req');
|
||||
$builder->select('reg_try_cnt');
|
||||
$builder->where('vr_sq', $atcl_vr_sq);
|
||||
|
||||
$query = $builder->get();
|
||||
|
||||
$last_query = $this->db->getLastQuery();
|
||||
log_message('debug', $last_query);
|
||||
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
/* 등기부등본 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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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'];
|
||||
$ownerVerifiable = ($row_vrfc_req['owner_verifiable'] === 'false') ? false : true;
|
||||
|
||||
$checkList = [];
|
||||
foreach ($res_check_list as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['owner_birth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if ($row_modify_info['modify_yn'] === 'Y') {
|
||||
if (!empty($row_modify_info['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'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 = [
|
||||
'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 [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 메모저장
|
||||
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) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '파일정보 저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$row = $this->getDetail($data[1]);
|
||||
|
||||
$memo = "메모변경 : " . $row['memo'] . " => " . $data[0];
|
||||
$this->saveChangedHistory($data[1], $row['pre_stat_cd'], 'C19', $usr_id, $memo);
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
];
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// 정보변경 이력 저장
|
||||
public function saveChangedHistory($vr_sq, $stat_cd, $chg_type, $usr_id, $memo)
|
||||
{
|
||||
$sql = "INSERT INTO v2_chg_history" .
|
||||
" (vr_sq, stat_cd, chg_type, insert_id, insert_tm, memo)" .
|
||||
" VALUES" .
|
||||
" (?, ?, ?, ?, now(), ?)";
|
||||
|
||||
$data = [
|
||||
$vr_sq,
|
||||
$stat_cd,
|
||||
$chg_type,
|
||||
$usr_id,
|
||||
$memo
|
||||
];
|
||||
|
||||
$res = $this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// 변경이력 조회
|
||||
public function getHistory($id)
|
||||
{
|
||||
|
||||
@@ -1,119 +1,12 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\receipt\ReceiptModel;
|
||||
use App\Models\webfax\FaxModel;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M708Model extends Model
|
||||
class M708Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -961,7 +854,7 @@ class M708Model extends Model
|
||||
$current_tm = date('Y-m-d H:i:s');
|
||||
$article = $this->getArticleInfo2($atcl_no, $vr_sq);
|
||||
|
||||
$this->saveFaxImgs($fax_sq, '2', $vr_sq, $atcl_no, $article['cpid'], $article['realtor_nm'], $article['stat_cd'], $current_tm, $article['address_code'], $article['address2']);
|
||||
$this->saveFaxImgs($fax_sq, '2', $vr_sq, $atcl_no, $article['cpid'], $article['realtor_nm'], $article['stat_cd'], $current_tm, $article['address_code'], $article['address2'], 'Y');
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
@@ -1215,6 +1108,754 @@ class M708Model extends Model
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* 매물정보와 FAX를 연결해 준다.
|
||||
*/
|
||||
public function saveArticleFAX($memo, $fax_sq, $vr_sq, $atcl_no, $work_type, $result_d11, $comment_d11, $fax_conf_yn_1, $fax_conf_yn_2, $fax_conf_yn_3, $fax_conf_info_1, $fax_conf_info_2, $fax_conf_info_3, $stat_cd = '')
|
||||
{
|
||||
// 1. 매물정보 저장 fax_imgs
|
||||
// 2.1 확인결과 저장 v2_confirms
|
||||
// 2.2 확인정보 체크 v2_check_list
|
||||
// 3.1 검증요청 상태변경 v2_vrfc_req
|
||||
// 3.2 상태변경 저장 v2_chg_stat
|
||||
// 4. 첨부파일 저장 v2_files
|
||||
// 5. 변경이력 저장 v2_chg_history
|
||||
// 6. kiso 전송하기
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
$article = NULL;
|
||||
$current_tm = date('Y-m-d H:i:s');
|
||||
$insert_user = session('usr_sq');
|
||||
$insert_id = session('usr_id');
|
||||
$update_user = $insert_user;
|
||||
|
||||
switch ($work_type) {
|
||||
case '1': // 현장확인매물
|
||||
$article = $this->getArticleInfo1($atcl_no, $vr_sq);
|
||||
|
||||
// 1. 매물정보 저장 fax_imgs
|
||||
$this->saveFaxImgs($fax_sq, $work_type, $vr_sq, $atcl_no, $article['cpid'], $article['realtor_nm'], '35', $current_tm, $article['address_code'], $article['address2'], 'Y');
|
||||
|
||||
// 2.1 확인결과 저장 v2_confirm
|
||||
|
||||
if ($result_d11 == '10000' && $fax_conf_yn_1 == 'Y' && $fax_conf_yn_2 == 'Y' && $fax_conf_yn_3 == 'Y') {
|
||||
$success = TRUE;
|
||||
} else {
|
||||
$success = FALSE;
|
||||
}
|
||||
|
||||
$fax = $this->getDetail($fax_sq);
|
||||
$this->saveV2Confirm($vr_sq, 'D', $success, '1', $fax['charger'], $current_tm, $insert_user, $update_user, $work_type);
|
||||
|
||||
// 2.2 확인정보 체크 v2_check_list
|
||||
// $fax_conf_yn_1, $fax_conf_yn_2, $fax_conf_yn_3,
|
||||
// $fax_conf_info_1, $fax_conf_info_2, $fax_conf_info_3
|
||||
if (is_array($comment_d11)) {
|
||||
$comment = implode('|', $comment_d11);
|
||||
} else {
|
||||
$comment = $comment_d11;
|
||||
}
|
||||
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D11', $result_d11, $comment, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_1 == 'Y') {
|
||||
$fax_conf_yn_1 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_1 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D12', $fax_conf_yn_1, $fax_conf_info_1, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_2 == 'Y') {
|
||||
$fax_conf_yn_2 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_2 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D13', $fax_conf_yn_2, $fax_conf_info_2, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_3 == 'Y') {
|
||||
$fax_conf_yn_3 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_3 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D14', $fax_conf_yn_3, $fax_conf_info_3, $insert_user);
|
||||
|
||||
$this->saveV2ChgHistory($vr_sq, '35', 'C9', $insert_id, '현장확인 매물');
|
||||
|
||||
$faxModel = new FaxModel();
|
||||
$fax = $faxModel->selectFax($fax_sq); // fax 이미지 파일 가져오기
|
||||
|
||||
$receiptModel = new ReceiptModel();
|
||||
$receipt = $receiptModel->selectReceiptOne($vr_sq); // 매물정보 가져오기
|
||||
|
||||
// 40: 촬영, 70: 검수지연... 상태가 촬용 이전 또는 검수지연 상태일 경우에만 홍보확인서를 등록한다.
|
||||
if (substr($receipt['rcpt_stat'], 0, 2) <= '40' || substr($receipt['rcpt_stat'], 0, 2) == '70') {
|
||||
$arrImagePath = array(
|
||||
'/home/confirms/test-admin.confirms.co.kr/upload/',
|
||||
'/home/confirms/upload/',
|
||||
'/home/www/admin.confirms.co.kr/upload/',
|
||||
'/home/www/upload/',
|
||||
'/image/confirms_upload/',
|
||||
'/misc/image/confirms_upload/',
|
||||
'/storage/web/admin.confirms.co.kr/src/upload/',
|
||||
'/storage/web/admin.confirms.co.kr/upload/',
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/upload/',
|
||||
);
|
||||
|
||||
$image_path = str_replace($arrImagePath, '/upload/', $fax['file_path']);
|
||||
|
||||
$receiptModel->saveFaxImage($fax_sq, $receipt['rcpt_sq'], $receipt['rsrv_sq'], 'I1', $image_path, $fax['file_name'], '.jpg', $fax['img_size'], $fax['img_width'], $fax['img_height'], $receipt);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case '2': // 일반확인매물
|
||||
$article = $this->getArticleInfo2($atcl_no, $vr_sq);
|
||||
|
||||
$try_cnt = $article['try_cnt']; // 0 -> 1 차시도, 1 -> 2 차시도
|
||||
$try_cnt = $try_cnt + 1;
|
||||
|
||||
//memo 저장
|
||||
$res_memo = $this->saveMemo([$memo, $vr_sq]);
|
||||
|
||||
$stat_cd = "30"; // 전화/서류 확인 중
|
||||
|
||||
if ($result_d11 == '10000' && $fax_conf_yn_1 == 'Y' && $fax_conf_yn_2 == 'Y' && $fax_conf_yn_3 == 'Y') {
|
||||
$success = TRUE; // 전화/서류 확인 성공
|
||||
} else {
|
||||
$success = FALSE; // 전화/서류 확인 실패
|
||||
}
|
||||
|
||||
// 1. 매물정보 저장 fax_imgs
|
||||
$r = $this->saveFaxImgs($fax_sq, $work_type, $article['vr_sq'], $article['atcl_no'], $article['cpid'], $article['realtor_nm'], $stat_cd, $current_tm, $article['address_code'], $article['address2'], 'Y');
|
||||
|
||||
// 2.1 확인결과 저장 v2_confirm
|
||||
$fax = $this->getDetail($fax_sq);
|
||||
$this->saveV2Confirm($vr_sq, 'D', $success, $try_cnt, $fax['charger'], $current_tm, $insert_user, $update_user, $work_type);
|
||||
|
||||
// 2.2 확인정보 체크 v2_check_list
|
||||
// $fax_conf_yn_1, $fax_conf_yn_2, $fax_conf_yn_3,
|
||||
// $fax_conf_info_1, $fax_conf_info_2, $fax_conf_info_3
|
||||
if (is_array($comment_d11)) {
|
||||
$comment = implode('|', $comment_d11);
|
||||
} else {
|
||||
$comment = $comment_d11;
|
||||
}
|
||||
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D11', $result_d11, $comment, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_1 == 'Y') {
|
||||
$fax_conf_yn_1 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_1 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D12', $fax_conf_yn_1, $fax_conf_info_1, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_2 == 'Y') {
|
||||
$fax_conf_yn_2 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_2 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D13', $fax_conf_yn_2, $fax_conf_info_2, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_3 == 'Y') {
|
||||
$fax_conf_yn_3 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_3 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D14', $fax_conf_yn_3, $fax_conf_info_3, $insert_user);
|
||||
|
||||
if ($success == TRUE) {
|
||||
$stat_cd = '35'; // 서류확인완료
|
||||
$this->saveV2ChgStat($vr_sq, $stat_cd, $insert_user);
|
||||
|
||||
$rgbk_confirm = $this->getRgbk_confirm($vr_sq);
|
||||
if (empty($rgbk_confirm)) {
|
||||
// 등기부등본 확인이 불필요할 경우
|
||||
$stat_cd = '60'; // 등기부등본 확인 중
|
||||
$this->saveV2ChgStat($vr_sq, $stat_cd, $insert_user);
|
||||
} else {
|
||||
// 등기부등본 확인이 필요할 경우
|
||||
$stat_cd = '40'; // 등기부등본 확인 중
|
||||
$this->saveV2ChgStat($vr_sq, $stat_cd, $insert_user);
|
||||
}
|
||||
} else {
|
||||
$stat_cd = '39'; // 서류확인 불일치
|
||||
$this->saveV2ChgStat($vr_sq, $stat_cd, $insert_user);
|
||||
}
|
||||
|
||||
// 3.1 검증요청 상태변경 v2_vrfc_req
|
||||
$this->saveV2VrfcReq($vr_sq, $stat_cd);
|
||||
|
||||
// 4. 첨부파일 저장 v2_files
|
||||
// fax_sq, mid, file_name, file_path, thumbnail, img_width, img_height, img_size, img_sq, remark, work_type, atcl_no, cpid, realtor_nm, stat_cd, proc_tm, send_tm, address_code, address2, charger
|
||||
$pos = strpos($fax['file_name'], '.');
|
||||
if ($pos === false) {
|
||||
$file_ext = '';
|
||||
} else {
|
||||
$file_ext = substr($fax['file_name'], $pos);
|
||||
}
|
||||
$this->saveV2Files($vr_sq, $fax['file_path'], $fax['file_name'], $file_ext, $fax['img_size'], $fax['img_width'], $fax['img_height'], $insert_user);
|
||||
|
||||
// 5. 변경이력 저장 v2_chg_history
|
||||
$memo = '';
|
||||
$this->saveV2ChgHistory($vr_sq, $stat_cd, 'C9', $insert_id, $memo);
|
||||
|
||||
break;
|
||||
|
||||
default: // 오류
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function saveHongBoFAX($fax_sq, $vr_sq, $atcl_no, $work_type, $send_yn, $result_d11, $comment_d11, $fax_conf_yn_1, $fax_conf_yn_2, $fax_conf_yn_3, $fax_conf_info_1, $fax_conf_info_2, $fax_conf_info_3, $file_type, $stat_cd = '')
|
||||
{
|
||||
// 1. 매물정보 저장 fax_imgs
|
||||
// 2.1 확인결과 저장 v2_confirms
|
||||
// 2.2 확인정보 체크 v2_check_list
|
||||
// 3.1 검증요청 상태변경 v2_vrfc_req
|
||||
// 3.2 상태변경 저장 v2_chg_stat
|
||||
// 4. 첨부파일 저장 v2_files
|
||||
// 5. 변경이력 저장 v2_chg_history
|
||||
// 6. kiso 전송하기
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
$article = NULL;
|
||||
$current_tm = date('Y-m-d H:i:s');
|
||||
$insert_user = session('usr_sq');
|
||||
$insert_id = session('usr_id');
|
||||
$update_user = $insert_user;
|
||||
|
||||
$article = $this->getArticleInfo1($atcl_no, $vr_sq);
|
||||
|
||||
// 1. 매물정보 저장 fax_imgs
|
||||
$this->saveFaxImgs($fax_sq, $work_type, $vr_sq, $atcl_no, $article['cpid'], $article['realtor_nm'], '35', $current_tm, $article['address_code'], $article['address2'], $send_yn);
|
||||
|
||||
|
||||
// 2.1 확인결과 저장 v2_confirm
|
||||
|
||||
if ($result_d11 == '10000' && $fax_conf_yn_1 == 'Y' && $fax_conf_yn_2 == 'Y' && $fax_conf_yn_3 == 'Y') {
|
||||
$success = TRUE;
|
||||
} else {
|
||||
$success = FALSE;
|
||||
}
|
||||
|
||||
$fax = $this->getDetail($fax_sq);
|
||||
$this->saveV2Confirm($vr_sq, 'D', $success, '1', $fax['charger'], $current_tm, $insert_user, $update_user, $work_type);
|
||||
|
||||
// 2.2 확인정보 체크 v2_check_list
|
||||
// $fax_conf_yn_1, $fax_conf_yn_2, $fax_conf_yn_3,
|
||||
// $fax_conf_info_1, $fax_conf_info_2, $fax_conf_info_3
|
||||
if (is_array($comment_d11)) {
|
||||
$comment = implode('|', $comment_d11);
|
||||
} else {
|
||||
$comment = $comment_d11;
|
||||
}
|
||||
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D11', $result_d11, $comment, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_1 == 'Y') {
|
||||
$fax_conf_yn_1 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_1 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D12', $fax_conf_yn_1, $fax_conf_info_1, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_2 == 'Y') {
|
||||
$fax_conf_yn_2 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_2 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D13', $fax_conf_yn_2, $fax_conf_info_2, $insert_user);
|
||||
|
||||
if ($fax_conf_yn_3 == 'Y') {
|
||||
$fax_conf_yn_3 = '10000';
|
||||
} else {
|
||||
$fax_conf_yn_3 = '20000';
|
||||
}
|
||||
$this->saveV2CheckList($vr_sq, 'D', 'D14', $fax_conf_yn_3, $fax_conf_info_3, $insert_user);
|
||||
|
||||
$this->saveV2ChgHistory($vr_sq, '35', 'C9', $insert_id, '현장확인 매물');
|
||||
|
||||
$faxModel = new FaxModel();
|
||||
$fax = $faxModel->selectFax($fax_sq); // fax 이미지 파일 가져오기
|
||||
|
||||
$receiptModel = new ReceiptModel();
|
||||
$receipt = $receiptModel->selectReceiptOne($vr_sq); // 매물정보 가져오기
|
||||
|
||||
// 40: 촬영, 70: 검수지연... 상태가 촬용 이전 또는 검수지연 상태일 경우에만 홍보확인서를 등록한다.
|
||||
if (substr($receipt['rcpt_stat'], 0, 2) <= '40' || substr($receipt['rcpt_stat'], 0, 2) == '70') {
|
||||
$arrImagePath = array(
|
||||
'/home/confirms/test-admin.confirms.co.kr/upload/',
|
||||
'/home/confirms/upload/',
|
||||
'/home/www/admin.confirms.co.kr/upload/',
|
||||
'/home/www/upload/',
|
||||
'/image/confirms_upload/',
|
||||
'/misc/image/confirms_upload/',
|
||||
'/storage/web/admin.confirms.co.kr/src/upload/',
|
||||
'/storage/web/admin.confirms.co.kr/upload/',
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/upload/',
|
||||
);
|
||||
|
||||
$image_path = str_replace($arrImagePath, '/upload/', $fax['file_path']);
|
||||
|
||||
$receiptModel->saveFaxImage($fax_sq, $receipt['rcpt_sq'], $receipt['rsrv_sq'], $file_type, $image_path, $fax['file_name'], '.jpg', $fax['img_size'], $fax['img_width'], $fax['img_height'], $receipt);
|
||||
}
|
||||
|
||||
|
||||
$this->db->transComplete();
|
||||
$return = array(
|
||||
'code' => $this->db->_error_number(),
|
||||
'message' => $this->db->_error_message(),
|
||||
);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 검증결과 저장하기
|
||||
*/
|
||||
public function saveV2Confirm($vr_sq, $vrfc_type, $success, $type, $charger, $date, $insert_user, $update_user, $work_type = '2')
|
||||
{
|
||||
$insert_user = session('usr_sq');
|
||||
$insert_id = session('usr_id');
|
||||
$update_user = $insert_user;
|
||||
|
||||
// DB에서 변경되지 전 값을 읽어온다.
|
||||
$sql = "select success, type, charger, date from v2_confirm" .
|
||||
" where vr_sq = ?" .
|
||||
" and vrfc_type = ?";
|
||||
$data = array(
|
||||
$vr_sq,
|
||||
$vrfc_type
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$data_table = array();
|
||||
if ($query->getNumRows() > 0) {
|
||||
$data_table = $query->getRowArray();
|
||||
}
|
||||
|
||||
$date = str_replace(array(' ', '-', ':'), '', $date);
|
||||
$sql = "INSERT INTO v2_confirm" .
|
||||
" (vr_sq, vrfc_type, success, type, charger, date, insert_user, insert_tm, update_user, update_tm, work_type)" .
|
||||
" VALUES" .
|
||||
" (?, ?, ?, ?, ?, ?, ?, now(), ?, now(), ?)" .
|
||||
" ON DUPLICATE KEY UPDATE" .
|
||||
" success=values(success), type=values(type), charger=values(charger), date=values(date), update_user=values(update_user), update_tm=values(update_tm), work_type=values(work_type)";
|
||||
|
||||
$data = array(
|
||||
'vr_sq' => $vr_sq,
|
||||
'vrfc_type' => $vrfc_type,
|
||||
'success' => $success,
|
||||
'type' => $type,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'insert_user' => $insert_user,
|
||||
'update_user' => $update_user,
|
||||
'work_type' => $work_type
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
// 변경이력 저장하기
|
||||
if (!empty($data_table)) {
|
||||
$this->saveV2ChgHistory($vr_sq, '30', 'C27', $insert_id, "검증결과 정보 저장");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 확인정보 저장하기
|
||||
*/
|
||||
public function saveV2CheckList($vr_sq, $vrfc_type, $type, $code, $comment, $insert_user)
|
||||
{
|
||||
$insert_id = session('usr_id');
|
||||
|
||||
$sql = "select code, comment from v2_check_list" .
|
||||
" where vr_sq = ?" .
|
||||
" and type = ?";
|
||||
$data = array(
|
||||
$vr_sq,
|
||||
$type
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$data_table = array();
|
||||
if ($query->getNumRows() > 0) {
|
||||
$data_table = $query->getRowArray();
|
||||
}
|
||||
|
||||
$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' => $vr_sq,
|
||||
'vrfc_type' => $vrfc_type,
|
||||
'type' => $type,
|
||||
'code' => $code,
|
||||
'comment' => $comment,
|
||||
'insert_user' => $insert_user
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
// 변경이력 저장하기
|
||||
if (!empty($data_table)) {
|
||||
$this->saveV2ChgHistory($vr_sq, '30', 'C27', $insert_id, "확인정보 저장");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태변경시간 등록
|
||||
*/
|
||||
public function saveV2ChgStat($vr_sq, $stat_cd, $insert_user)
|
||||
{
|
||||
$sql = "INSERT INTO v2_chg_stat" .
|
||||
" (vr_sq, stat_cd, insert_user, insert_tm)" .
|
||||
" VALUES" .
|
||||
" (?, ?, ?, now())" .
|
||||
" ON DUPLICATE KEY UPDATE" .
|
||||
" insert_user=VALUES(insert_user), insert_tm=VALUES(insert_tm)";
|
||||
$data = array($vr_sq, $stat_cd, $insert_user);
|
||||
$this->db->query($sql, $data);
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* 전송 후 FAX에 상태 및 전송시간을 저장한다.
|
||||
*/
|
||||
public function saveFaxImgsAfterSend($fax_sq, $vr_sq, $stat_cd, $send_tm = '')
|
||||
{
|
||||
if (empty($send_tm))
|
||||
$send_tm = date('Y-m-d H:i:s');
|
||||
|
||||
$data_fax_imgs = [
|
||||
'stat_cd' => $stat_cd,
|
||||
'send_tm' => $send_tm,
|
||||
];
|
||||
|
||||
$builder = $this->db->table('fax_imgs');
|
||||
$builder->where('fax_sq', $fax_sq);
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$builder->update($data_fax_imgs);
|
||||
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증요청 v2_vrfc_req의 상태 stat_cd를 업데이트한다.
|
||||
*/
|
||||
public function saveV2VrfcReq($vr_sq, $stat_cd)
|
||||
{
|
||||
|
||||
$sql = "update v2_vrfc_req" .
|
||||
" set stat_cd = ?" .
|
||||
" where vr_sq = ?";
|
||||
$data = array($stat_cd, $vr_sq);
|
||||
|
||||
$res = $this->db->query($sql, $data);
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
log_message('debug', $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* 홍보확인서를 매물정보에 등록한다.
|
||||
*/
|
||||
public function saveV2Files($vr_sq, $file_path, $file_name, $file_ext, $file_size, $img_width, $img_height, $insert_user)
|
||||
{
|
||||
$arrImagePath = array(
|
||||
'/home/confirms/test-admin.confirms.co.kr/upload/',
|
||||
'/home/confirms/upload/',
|
||||
'/home/www/admin.confirms.co.kr/upload/',
|
||||
'/home/www/upload/',
|
||||
'/image/confirms_upload/',
|
||||
'/misc/image/confirms_upload/',
|
||||
'/storage/web/admin.confirms.co.kr/src/upload/',
|
||||
'/storage/web/admin.confirms.co.kr/upload/',
|
||||
$_SERVER['DOCUMENT_ROOT'] . '/upload/',
|
||||
);
|
||||
|
||||
$file_path = str_replace($arrImagePath, '/upload/', $file_path);
|
||||
$file_type = '1'; // 홍보확인서
|
||||
|
||||
|
||||
// 1. 홍보확이서 등록여부 확인
|
||||
$sql = "SELECT count(*) file_cnt FROM v2_files" .
|
||||
" WHERE vr_sq = ?" .
|
||||
" AND file_type = ?" .
|
||||
" AND file_path = ?" .
|
||||
" AND file_name = ?" .
|
||||
" AND use_yn = 'Y'";
|
||||
$data = array(
|
||||
$vr_sq,
|
||||
$file_type,
|
||||
$file_path,
|
||||
$file_name
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
if (empty($row['file_cnt'])) {
|
||||
// 2. 다른파일로 등록된 경우를 위해서 업데이트
|
||||
$sql = "UPDATE v2_files SET use_yn = 'N' WHERE vr_sq = ? AND file_type = ?";
|
||||
$data = array($vr_sq, $file_type);
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
// 3. 등록
|
||||
$sql = "INSERT INTO v2_files " .
|
||||
" (vr_sq, use_yn, file_type, view_odr, file_path, file_name, file_ext, file_size, img_width, img_height, insert_user, insert_tm)" .
|
||||
" VALUES" .
|
||||
" (?, 'Y', ?, '1', ?, ?, ?, ?, ?, ?, ?, NOW())";
|
||||
|
||||
$data = array($vr_sq, $file_type, $file_path, $file_name, $file_ext, $file_size, $img_width, $img_height, $insert_user);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증결과 전송 API를 위한 데이터 조회..
|
||||
*/
|
||||
public function getDataConfirmAPI($vr_sq)
|
||||
{
|
||||
// 요청정보
|
||||
$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" .
|
||||
" FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$row_vrfc_req = $query->getRowArray();
|
||||
|
||||
// 매물정보
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$query->getRowArray();
|
||||
|
||||
// 수정정보
|
||||
$sql = "SELECT vr_sq, bild_nm, rm_no, floor, address_code, address2, address3, address4, 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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$row_modify_info = $query->getRowArray();
|
||||
|
||||
// 검증결과
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$row_confirm = $query->getRowArray();
|
||||
|
||||
// 확인정보
|
||||
$sql = "SELECT type, code, comment, ownerNm, ownerBirth FROM v2_check_list WHERE vr_sq = ? AND vrfc_type = ? AND type LIKE CONCAT(vrfc_type, '%')";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$res_check_list = $query->getResultArray();
|
||||
|
||||
$atclNo = $row_vrfc_req['atcl_no'];
|
||||
$success = empty($row_confirm['success']) ? false : true;
|
||||
$charger = $row_confirm['charger'];
|
||||
$date = $row_confirm['date'];
|
||||
$try_cnt = $row_vrfc_req['try_cnt'];
|
||||
|
||||
$checkList = [];
|
||||
foreach ($res_check_list as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['ownerBirth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if ($row_modify_info['modify_yn'] == 'Y') {
|
||||
if (!empty($row_modify_info['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'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 = [
|
||||
'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 [
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'try_cnt' => $try_cnt,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'try_cnt' => $try_cnt,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 담당자를 지정해준다.
|
||||
*/
|
||||
public function InsCharger($vr_sq)
|
||||
{
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$sql = "UPDATE v2_article_info" .
|
||||
" SET charger = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
|
||||
$data = array(
|
||||
$usr_id,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 상태를 변경한다.
|
||||
*/
|
||||
public function saveChangeStep($fax_sq, $vr_sq, $stat_cd)
|
||||
{
|
||||
$insert_user = session('usr_sq');
|
||||
$insert_id = session('usr_id');
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
// 1. 검증요청 상태변경 v2_vrfc_req
|
||||
$this->saveV2VrfcReq($vr_sq, $stat_cd);
|
||||
|
||||
// 2. 상태변경 저장 v2_chg_stat
|
||||
$this->saveV2ChgStat($vr_sq, $stat_cd, $insert_user);
|
||||
|
||||
// 3. 변경이력 저장 v2_chg_history
|
||||
$this->saveV2ChgHistory($vr_sq, $stat_cd, 'C9', $insert_id, "");
|
||||
|
||||
// 4. FAX에 최종 저장시 상태값 저장
|
||||
$this->saveFaxImgsAfterSend($fax_sq, $vr_sq, $stat_cd, $send_tm = '');
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
$return = array(
|
||||
'code' => $this->db->_error_number(),
|
||||
'message' => $this->db->_error_message(),
|
||||
);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 값을 실패횟수 값을 증가시킨다.
|
||||
*/
|
||||
public function increseTryCnt($vr_sq)
|
||||
{
|
||||
$sql = "update v2_vrfc_req set try_cnt = ifnull(try_cnt,0) +1 where vr_sq = ?";
|
||||
$data = array($vr_sq);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function getI8Cnt($rsrv_sq)
|
||||
{
|
||||
$sql = "SELECT COUNT(img_sq) cnt" .
|
||||
" FROM result_imgs" .
|
||||
" WHERE rsrv_sq = ?" .
|
||||
" AND img_type = 'I8'" .
|
||||
" AND use_yn = 'Y'";
|
||||
$data = array($rsrv_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function get_rsrv_sq($rcpt_sq)
|
||||
{
|
||||
$sql = "SELECT rsrv_sq " .
|
||||
" FROM result" .
|
||||
" WHERE rcpt_sq = ?";
|
||||
$data = array($rcpt_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
|
||||
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) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '파일정보 저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$row = $this->getDetail($data[1]);
|
||||
|
||||
$memo = "메모변경 : " . $row['memo'] . " => " . $data[0];
|
||||
$this->saveChangedHistory($data[1], $row['pre_stat_cd'], 'C19', $usr_id, $memo);
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 변경이력 저장하기
|
||||
*/
|
||||
public function saveV2ChgHistory($vr_sq, $stat_cd, $chg_type, $insert_id, $memo)
|
||||
{
|
||||
$sql = "INSERT INTO v2_chg_history" .
|
||||
" (vr_sq, stat_cd, chg_type, insert_id, insert_tm, memo)" .
|
||||
" VALUES" .
|
||||
" (?, ?, ?, ?, now(), ?)";
|
||||
|
||||
$data = array($vr_sq, $stat_cd, $chg_type, $insert_id, $memo);
|
||||
$this->db->query($sql, $data);
|
||||
log_message('debug', $this->db->getLastQuery());
|
||||
}
|
||||
|
||||
|
||||
// 변경내용 저장
|
||||
public function saveChangedHistory($rcpt_sq, $rcpt_stat, $changed_type, $usr_id, $remark)
|
||||
|
||||
@@ -1,119 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M709Model extends Model
|
||||
class M709Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 사용자 부서 조회
|
||||
public function getDepartmentPath($usr_sq)
|
||||
|
||||
@@ -1,121 +1,11 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M710Model extends Model
|
||||
class M710Model extends BaseV2Model
|
||||
{
|
||||
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
$sql = "SELECT
|
||||
@@ -704,4 +594,19 @@ class M710Model extends Model
|
||||
}
|
||||
|
||||
|
||||
public function get_send_yn($type)
|
||||
{
|
||||
$sql = "SELECT stop_yn
|
||||
FROM v2_stop_api_chg_stat
|
||||
WHERE TYPE = ?
|
||||
ORDER BY pk DESC
|
||||
LIMIT 1";
|
||||
$date = array(
|
||||
$type
|
||||
);
|
||||
$query = $this->db->query($sql, $date);
|
||||
$return = $query->getRowArray();
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M711Model extends Model
|
||||
class M711Model extends BaseV2Model
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,119 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M712Model extends Model
|
||||
class M712Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -906,6 +797,504 @@ class M712Model extends Model
|
||||
}
|
||||
}
|
||||
|
||||
/* 현재 상태 확인 */
|
||||
public function chkStat($vr_sq)
|
||||
{
|
||||
$sql = "SELECT stat_cd FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
//1차 검증인지 2차 검증인지 확인.
|
||||
public function chkRegiTryCnt($atcl_vr_sq)
|
||||
{
|
||||
$sql = "SELECT reg_try_cnt FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
$query = $this->db->query($sql, [$atcl_vr_sq]);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
//검증결과 table에 있는지 확인.
|
||||
public function chkConfirm($atcl_vr_sq, $reg_yn)
|
||||
{
|
||||
$builder = $this->db->table('v2_confirm a');
|
||||
$builder->select('a.vr_sq');
|
||||
$builder->where('vr_sq', $atcl_vr_sq);
|
||||
|
||||
if ($reg_yn) {
|
||||
$builder->where('vrfc_type', $reg_yn);
|
||||
}
|
||||
|
||||
$query = $builder->get();
|
||||
return $query->getNumRows();
|
||||
}
|
||||
|
||||
public function getUpdateFailTime($vr_sq)
|
||||
{
|
||||
$sql = "select vr_sq, stat_cd, insert_user, insert_tm " .
|
||||
"from v2_chg_stat " .
|
||||
"where vr_sq = ? and stat_cd = '49' " .
|
||||
"order by insert_tm desc " .
|
||||
"limit 1";
|
||||
$data = array($vr_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
//v2_confirm INSERT
|
||||
public function insertConfirm($vr_sq, $vrfc_type, $success, $type, $usr_id = '', $usr_sq = '')
|
||||
{
|
||||
|
||||
if (empty($usr_sq))
|
||||
$usr_sq = session('usr_sq');
|
||||
if (empty($usr_id))
|
||||
$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()) " .
|
||||
" ON DUPLICATE KEY UPDATE" .
|
||||
" success=values(success), type=values(type), charger=values(charger), date=values(date)
|
||||
, update_user=values(update_user), update_tm=values(update_tm)";
|
||||
|
||||
$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,
|
||||
];
|
||||
|
||||
$builder = $this->db->table('v2_confirm');
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$builder->where('vrfc_type', $vrfc_type);
|
||||
$builder->update($data);
|
||||
|
||||
return [
|
||||
'error_number' => $this->db->error()['code'],
|
||||
'error_message' => $this->db->error()['message']
|
||||
];
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
//echo $this->db->last_query();
|
||||
$res = $this->db->query($sql, $data);
|
||||
$log_v = $this->db->getLastQuery();
|
||||
log_message('debug', $log_v);
|
||||
}
|
||||
|
||||
public function add_cert_uncnfrm_status($vr_sq, $cert_uncnfrm_status)
|
||||
{
|
||||
$sql = "UPDATE v2_article_info_etc" .
|
||||
" SET cert_uncnfrm_status = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$cert_uncnfrm_status,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$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
|
||||
);
|
||||
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* update updatedocument_cert_method
|
||||
*/
|
||||
public function updatedocument_cert_method($vr_sq, $document_cert_method)
|
||||
{
|
||||
$sql = "UPDATE v2_article_info_etc SET " .
|
||||
" document_cert_method = ? " .
|
||||
" WHERE vr_sq = ? ";
|
||||
|
||||
$document_cert_method = json_encode($document_cert_method, JSON_UNESCAPED_UNICODE);
|
||||
if ($document_cert_method == 'false') {
|
||||
$document_cert_method = NULL;
|
||||
}
|
||||
$data = array(
|
||||
$document_cert_method,
|
||||
$vr_sq
|
||||
);
|
||||
$this->db->query($sql, $data);
|
||||
$s = $this->db->getLastQuery();
|
||||
log_message('debug', "====updatedocument_cert_method:712====" . $s);
|
||||
}
|
||||
|
||||
public function update_owner_verifiable($vr_sq, $owner_verifiable)
|
||||
{
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET owner_verifiable = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$owner_verifiable,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
$s = $this->db->getLastQuery();
|
||||
log_message('debug', "====update_owner_verifiable:712====" . $s);
|
||||
}
|
||||
|
||||
/* 등기부등본 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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$row_vrfc_req = $query->getRowArray();
|
||||
|
||||
if (!empty($vrfc_type)) {
|
||||
$row_vrfc_req['vrfc_type'] = $vrfc_type;
|
||||
}
|
||||
|
||||
log_message('debug', 'getDatacertApi_query => ' . $this->db->getLastQuery());
|
||||
log_message('debug', 'getDatacertApi_result => ' . json_encode($row_vrfc_req));
|
||||
|
||||
// 매물정보
|
||||
$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, vrfc_type_sub" .
|
||||
" FROM v2_article_info where vr_sq = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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 = ?";
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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'] ?? '';
|
||||
|
||||
switch ($row_vrfc_req['owner_verifiable']) {
|
||||
case "1":
|
||||
case "true":
|
||||
$ownerVerifiable = true;
|
||||
break;
|
||||
default:
|
||||
$ownerVerifiable = false;
|
||||
break;
|
||||
}
|
||||
|
||||
$checkList = [];
|
||||
foreach ($res_check_list as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['owner_birth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if ($row_modify_info['modify_yn'] == 'Y') {
|
||||
if (!empty($row_modify_info['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'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 = [
|
||||
'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 [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'vrfcType' => $row_article_info['vrfc_type_sub'],
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'vrfcType' => $row_article_info['vrfc_type_sub'],
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function get_send_yn($type)
|
||||
{
|
||||
$sql = "SELECT stop_yn
|
||||
FROM v2_stop_api_chg_stat
|
||||
WHERE TYPE = ?
|
||||
ORDER BY pk DESC
|
||||
LIMIT 1";
|
||||
$date = array(
|
||||
$type
|
||||
);
|
||||
$query = $this->db->query($sql, $date);
|
||||
$return = $query->getRowArray();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function insert_v2_stop_api_save_info($atcl_no, $vr_sq, $type, $fax_sq)
|
||||
{
|
||||
$sql = "INSERT INTO v2_stop_api_save_info(atcl_no,vr_sq,type,status,stop_dt,fax_sq)" .
|
||||
" VALUE(?,?,?,'stop',now(),?)";
|
||||
$date = array(
|
||||
$atcl_no,
|
||||
$vr_sq,
|
||||
$type,
|
||||
$fax_sq
|
||||
);
|
||||
$this->db->query($sql, $date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 712 소유자 확인 을 위한 쿼리
|
||||
*/
|
||||
public function getOwnerVerifiable($atcl_no)
|
||||
{
|
||||
$sql = "select * ,
|
||||
case
|
||||
when owner_verifiable = 'true' then '1'
|
||||
when owner_verifiable = '1' then '1'
|
||||
when owner_verifiable = 'false' then '0'
|
||||
when owner_verifiable = '0' then '0'
|
||||
ELSE null
|
||||
END AS OwnerVerifiable_change
|
||||
from v2_vrfc_req where atcl_no = ? ";
|
||||
$data = array(
|
||||
$atcl_no
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function chgStat($vr_sq, $stat_cd, $insert_tm)
|
||||
{ //상태변경 TABLE INSERT
|
||||
|
||||
$usr_sq = session('usr_sq');
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$list = $this->get_detail($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);
|
||||
|
||||
$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->saveChangedHistory($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);
|
||||
|
||||
return [
|
||||
'error_number' => $this->db->error()['code'],
|
||||
'error_message' => $this->db->error()['message']
|
||||
];
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return [
|
||||
'error_number' => $this->db->error()['code'],
|
||||
'error_message' => $this->db->error()['message']
|
||||
];
|
||||
}
|
||||
|
||||
//v2_vrfc_req try_cnt 값 변경.
|
||||
public function chgRegiTryCnt($vr_sq, $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 resetTelConf($vr_sq)
|
||||
{
|
||||
$sql = "update v2_check_list " .
|
||||
"set code = '' " .
|
||||
"where type in ('T11', 'T12', 'T13', 'T14') " .
|
||||
"and vr_sq = ?";
|
||||
|
||||
$data = array($vr_sq);
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
// 메모저장
|
||||
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) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '파일정보 저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$row = $this->getDetail($data[1]);
|
||||
|
||||
$memo = "메모변경 : " . $row['memo'] . " => " . $data[0];
|
||||
$this->saveChangedHistory($data[1], $row['pre_stat_cd'], 'C19', $usr_id, $memo);
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
];
|
||||
}
|
||||
|
||||
// 정보변경 이력 저장
|
||||
public function saveChangedHistory($vr_sq, $stat_cd, $chg_type, $usr_id, $memo)
|
||||
|
||||
@@ -1,119 +1,10 @@
|
||||
<?php
|
||||
namespace App\Models\v2;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
use App\Models\v2\BaseV2Model;
|
||||
|
||||
class M713Model extends Model
|
||||
class M713Model extends BaseV2Model
|
||||
{
|
||||
// 지역 목록 조회
|
||||
public function getAreaList($sido = '', $gugun = '')
|
||||
{
|
||||
|
||||
if (!empty($gugun)) {
|
||||
$gugun = substr($gugun, '0', '5');
|
||||
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,5),'00000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000'" .
|
||||
" AND a.region_cd LIKE '%00'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
|
||||
$query = $this->db->query($sql, [$gugun]);
|
||||
|
||||
} else if (!empty($sido)) {
|
||||
$chk_sido = substr($sido, '0', '2');
|
||||
|
||||
if ($chk_sido === '36') {
|
||||
$sido = substr($sido, '0', '4');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,4),'000000') " .
|
||||
"WHERE a.region_cd LIKE concat(?, '%') " .
|
||||
"AND a.region_cd NOT LIKE '%000000' " .
|
||||
"AND a.region_cd LIKE '%00' " .
|
||||
"AND a.use_yn = 'Y' " .
|
||||
"AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000')) " .
|
||||
"ORDER BY a.region_nm ASC";
|
||||
} else {
|
||||
$sido = substr($sido, '0', '2');
|
||||
$sql = "SELECT a.region_cd, TRIM(REPLACE(a.region_nm, b.region_nm, '')) region_nm" .
|
||||
" FROM region_codes a" .
|
||||
" LEFT JOIN region_codes b ON b.region_cd = CONCAT(SUBSTR(a.region_cd,1,2),'00000000')" .
|
||||
" WHERE a.region_cd LIKE concat(?, '%')" .
|
||||
" AND a.region_cd NOT LIKE '%00000000'" .
|
||||
" AND a.region_cd LIKE '%00000'" .
|
||||
" AND a.use_yn = 'Y'" .
|
||||
" AND EXISTS (SELECT 'x' FROM region_codes c WHERE c.region_cd LIKE CONCAT(SUBSTR(a.region_cd,1,5),'%') AND c.region_cd > CONCAT(SUBSTR(a.region_cd,1,5),'00000'))" .
|
||||
" ORDER BY a.region_nm ASC";
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, [$sido]);
|
||||
} else {
|
||||
$sql = "SELECT a.region_cd, a.region_nm " .
|
||||
"FROM region_codes a " .
|
||||
"WHERE (a.region_cd LIKE '%00000000' " .
|
||||
"AND a.use_yn = 'Y') " .
|
||||
"OR region_cd = 3611000000;";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
}
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속본부조회
|
||||
public function getBonbuList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm, dept_desc, dept_head, use_yn, depth, insert_tm, insert_usr, update_tm, update_usr, lft, rgt" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 1" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY lft";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 소속팀 조회
|
||||
public function getTeamList()
|
||||
{
|
||||
$sql = "SELECT dept_sq, pdept_sq, dept_nm" .
|
||||
" FROM departments" .
|
||||
" WHERE depth = 2" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY dept_nm";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
// 유저 조회
|
||||
public function getUserList()
|
||||
{
|
||||
$sql = "SELECT
|
||||
a.usr_sq, a.usr_id, a.usr_nm, a.dept_sq
|
||||
FROM users a
|
||||
WHERE
|
||||
a.usr_level IN ('3','4','40','5','50','6','60','61','62','7','8','70')
|
||||
AND a.use_yn = 'Y'
|
||||
AND EXISTS (
|
||||
SELECT 'x' FROM departments a1 INNER JOIN departments a2 ON a2.lft BETWEEN a1.lft AND a1.rgt AND a2.use_yn = 'Y'
|
||||
WHERE 1=1 AND a2.dept_sq = a.dept_sq AND a1.use_yn = 'Y'
|
||||
)
|
||||
ORDER BY a.usr_level DESC, a.usr_nm ASC ";
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
public function getTotalCount($data)
|
||||
{
|
||||
@@ -930,6 +821,535 @@ class M713Model extends Model
|
||||
}
|
||||
}
|
||||
|
||||
/* 현재 상태 확인 */
|
||||
public function chkStat($vr_sq)
|
||||
{
|
||||
$sql = "SELECT stat_cd FROM v2_vrfc_req WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$vr_sq
|
||||
);
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function chkTryCnt($atcl_vr_sq)
|
||||
{
|
||||
// 1차 검증인지 2차 검증인지 확인.
|
||||
$sql = "SELECT a.try_cnt FROM v2_vrfc_req a WHERE vr_sq = ?";
|
||||
$query = $this->db->query($sql, [$atcl_vr_sq]);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function chkRegiTryCnt($atcl_vr_sq)
|
||||
{
|
||||
$sql = "SELECT a.reg_try_cnt FROM v2_vrfc_req a WHERE vr_sq = ?";
|
||||
$query = $this->db->query($sql, [$atcl_vr_sq]);
|
||||
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('vr_sq', $atcl_vr_sq);
|
||||
|
||||
if ($reg_yn) {
|
||||
$builder->where('vrfc_type', $reg_yn); // 등기부등본 정보 확인시
|
||||
}
|
||||
|
||||
$query = $builder->get();
|
||||
$result = $query->getNumRows();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getUpdateFailTime($vr_sq)
|
||||
{
|
||||
$sql = "select vr_sq, stat_cd, insert_user, insert_tm " .
|
||||
"from v2_chg_stat " .
|
||||
"where vr_sq = ? and stat_cd = '49' " .
|
||||
"order by insert_tm desc " .
|
||||
"limit 1";
|
||||
$data = array($vr_sq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
$res = $this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function updateConfirm($vr_sq, $vrfc_type, $success): void
|
||||
{
|
||||
$data = [
|
||||
'success' => $success
|
||||
];
|
||||
|
||||
$builder = $this->db->table('v2_confirm');
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$builder->where('vrfc_type', $vrfc_type);
|
||||
$builder->update($data);
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
//echo $this->db->last_query();
|
||||
$res = $this->db->query($sql, $data);
|
||||
$log_v = $this->db->getLastQuery();
|
||||
log_message('debug', $log_v);
|
||||
}
|
||||
|
||||
public function add_cert_uncnfrm_status($vr_sq, $cert_uncnfrm_status)
|
||||
{
|
||||
$sql = "UPDATE v2_article_info_etc" .
|
||||
" SET cert_uncnfrm_status = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$cert_uncnfrm_status,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
public function update_owner_verifiable($vr_sq, $owner_verifiable)
|
||||
{
|
||||
$sql = "UPDATE v2_vrfc_req" .
|
||||
" SET owner_verifiable = ?" .
|
||||
" WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$owner_verifiable,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
$s = $this->db->getLastQuery();
|
||||
log_message('debug', "====update_owner_verifiable====" . $s);
|
||||
}
|
||||
|
||||
/* 등기부등본 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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$row_vrfc_req = $query->getRowArray();
|
||||
|
||||
if (!empty($vrfc_type)) {
|
||||
$row_vrfc_req['vrfc_type'] = $vrfc_type;
|
||||
}
|
||||
|
||||
log_message('debug', 'getDatacertApi_query => ' . $this->db->getLastQuery());
|
||||
log_message('debug', 'getDatacertApi_result => ' . json_encode($row_vrfc_req));
|
||||
|
||||
// 매물정보
|
||||
$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, vrfc_type_sub" .
|
||||
" FROM v2_article_info WHERE vr_sq = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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 = ?";
|
||||
|
||||
$query = $this->db->query($sql, [$vr_sq, $row_vrfc_req['vrfc_type']]);
|
||||
$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'] ?? '';
|
||||
|
||||
$ownerVerifiable = match ($row_vrfc_req['owner_verifiable']) {
|
||||
"1", "true" => true,
|
||||
default => false,
|
||||
};
|
||||
|
||||
$checkList = [];
|
||||
foreach ($res_check_list as $row) {
|
||||
$checkList[] = [
|
||||
'type' => $row['type'],
|
||||
'code' => $row['code'],
|
||||
'comment' => $row['comment'],
|
||||
'ownerNm' => $row['ownerNm'],
|
||||
'ownerBirth' => $row['owner_birth'],
|
||||
];
|
||||
}
|
||||
|
||||
$modifyInfo = [];
|
||||
if ($row_modify_info['modify_yn'] == 'Y') {
|
||||
if (!empty($row_modify_info['hscp_no'])) {
|
||||
// 공동주택
|
||||
$modifyInfo = [
|
||||
'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 = [
|
||||
'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_data = [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'modifyInfo' => $modifyInfo,
|
||||
'date' => $date,
|
||||
'vrfcType' => $row_article_info['vrfc_type_sub'],
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
|
||||
log_message('debug', "713 getDatacertAPI_1 {$atclNo} ::: " . json_encode($return_data) . PHP_EOL);
|
||||
|
||||
return $return_data;
|
||||
} else {
|
||||
$return_data = [
|
||||
'atclNo' => $atclNo,
|
||||
'type' => $type,
|
||||
'success' => $success,
|
||||
'checkList' => $checkList,
|
||||
'charger' => $charger,
|
||||
'date' => $date,
|
||||
'vrfcType' => $row_article_info['vrfc_type_sub'],
|
||||
'ownerVerifiable' => $ownerVerifiable,
|
||||
];
|
||||
|
||||
log_message('debug', "713 getDatacertAPI_2 {$atclNo} ::: " . json_encode($return_data) . PHP_EOL);
|
||||
|
||||
return $return_data;
|
||||
}
|
||||
}
|
||||
|
||||
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 = [
|
||||
$vr_sq,
|
||||
$stat_cd,
|
||||
$usr_sq,
|
||||
$insert_tm
|
||||
];
|
||||
|
||||
$this->db->transStart();
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
$error = $this->db->error();
|
||||
$return = [
|
||||
'error_number' => $error['code'],
|
||||
'error_message' => $error['message']
|
||||
];
|
||||
|
||||
if (empty($return['error_number'])) {
|
||||
// 로그를 남긴다.
|
||||
if ($this->db->affectedRows() > 0) {
|
||||
// $changed = $this->what_is_changed($list, $data, '');
|
||||
// if (!empty($changed)) {
|
||||
$this->saveChangedHistory($list['vr_sq'], $stat_cd, 'C9', $usr_id, "상태변경 저장");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
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'],
|
||||
'error_message' => $error['message']
|
||||
];
|
||||
}
|
||||
|
||||
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'],
|
||||
'error_message' => $error['message']
|
||||
];
|
||||
}
|
||||
|
||||
public function updateStat($vr_sq, $reg_status)
|
||||
{
|
||||
$data = ['reg_status' => $reg_status];
|
||||
|
||||
$builder = $this->db->table('v2_article_info');
|
||||
$builder->where('vr_sq', $vr_sq);
|
||||
$builder->update($data);
|
||||
|
||||
$error = $this->db->error();
|
||||
return [
|
||||
'error' => [
|
||||
'code' => $error['code'],
|
||||
'message' => $error['message']
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
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
|
||||
);
|
||||
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function modify_info($vr_sq, $owner_birth, $address2, $address2a, $address2b, $address3, $address4, $address_code, $hscp_no, $hscp_nm)
|
||||
{
|
||||
$this->db->transStart();
|
||||
$usr_id = session('usr_id');
|
||||
|
||||
$sql = "UPDATE v2_modify_info
|
||||
SET address2 = ?
|
||||
,address2a = ?
|
||||
,address2b = ?
|
||||
,address3 = ?
|
||||
,address4 = ?
|
||||
,address_code = ?
|
||||
,hscp_no = ?
|
||||
,hscp_nm = ?
|
||||
,modify_yn = 'Y'
|
||||
WHERE vr_sq = ?";
|
||||
$data = array(
|
||||
$address2,
|
||||
$address2a,
|
||||
$address2b,
|
||||
$address3,
|
||||
$address4,
|
||||
$address_code,
|
||||
$hscp_no,
|
||||
$hscp_nm,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
if ($this->db->query($sql, $data) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$sql2 = "UPDATE v2_article_info
|
||||
SET owner_birth = ?
|
||||
,address2 = ?
|
||||
,address3 = ?
|
||||
,address_code = ?
|
||||
,hscp_no = ?
|
||||
,hscp_nm = ?
|
||||
WHERE vr_sq = ?";
|
||||
$data2 = array(
|
||||
$owner_birth,
|
||||
$address2,
|
||||
$address3,
|
||||
$address_code,
|
||||
$hscp_no,
|
||||
$hscp_nm,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
if ($this->db->query($sql2, $data2) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$sql3 = "UPDATE v2_article_info_etc
|
||||
SET address2a = ?
|
||||
,address2b = ?
|
||||
WHERE vr_sq = ?";
|
||||
$data3 = array(
|
||||
$address2a,
|
||||
$address2b,
|
||||
$vr_sq
|
||||
);
|
||||
|
||||
if ($this->db->query($sql3, $data) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$this->saveChangedHistory($vr_sq, '40', 'C34', $usr_id, '생년월일 정보 변경');
|
||||
|
||||
$this->db->transComplete();
|
||||
return [
|
||||
'success' => true,
|
||||
];
|
||||
}
|
||||
|
||||
// 메모저장
|
||||
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) === false) {
|
||||
return [
|
||||
'success' => false,
|
||||
'msg' => '파일정보 저장 실패',
|
||||
];
|
||||
}
|
||||
|
||||
$row = $this->getDetail($data[1]);
|
||||
|
||||
$memo = "메모변경 : " . $row['memo'] . " => " . $data[0];
|
||||
$this->saveChangedHistory($data[1], $row['pre_stat_cd'], 'C19', $usr_id, $memo);
|
||||
|
||||
return [
|
||||
'success' => true
|
||||
];
|
||||
}
|
||||
|
||||
// 정보변경 이력 저장
|
||||
public function saveChangedHistory($vr_sq, $stat_cd, $chg_type, $usr_id, $memo)
|
||||
|
||||
207
app/Models/webfax/FaxModel.php
Normal file
207
app/Models/webfax/FaxModel.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
namespace App\Models\webfax;
|
||||
|
||||
use CodeIgnier\Model;
|
||||
|
||||
class FaxModel extends Model
|
||||
{
|
||||
/**
|
||||
* FAX 내용중 하나만 가져오기
|
||||
*/
|
||||
public function selectFax($faxSq)
|
||||
{
|
||||
$sql = "SELECT mid, caller_no, recv_time, fax_sq, file_path, file_name, thumbnail, img_width, img_height, img_size" .
|
||||
" FROM fax_imgs" .
|
||||
" WHERE fax_sq = ?";
|
||||
$data = array($faxSq);
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getRowArray();
|
||||
}
|
||||
|
||||
public function selectFaxListNotExistsThumb()
|
||||
{
|
||||
helper('cron');
|
||||
|
||||
if (!isset($_SERVER["HOSTNAME"])) {
|
||||
$_SERVER["HOSTNAME"] = get_linux_hostname();
|
||||
}
|
||||
if (empty($_SERVER["HOSTNAME"])) {
|
||||
$_SERVER["HOSTNAME"] = "unknown";
|
||||
}
|
||||
|
||||
$_SERVER["HOSTNAME"] = "unknown";
|
||||
$data = [$_SERVER["HOSTNAME"]];
|
||||
|
||||
$sql = "UPDATE uds_tiff a" .
|
||||
" SET a.etc1 = ?" .
|
||||
" WHERE NOT EXISTS (SELECT 'x' FROM fax_imgs a1 WHERE a1.mid = a.mid)" .
|
||||
" AND a.recv_time >= DATE_ADD(NOW(), INTERVAL -7 DAY)" .
|
||||
" AND a.etc1 = ''" .
|
||||
" limit 100";
|
||||
$this->db->query($sql, $data);
|
||||
|
||||
$sql = "SELECT a.mid,a.eid,a.pages,a.caller_no,a.callee_no,a.file_name,REPLACE(a.save_path, a.file_name,'') save_path,a.file_size,a.recv_time,a.save_time" .
|
||||
" FROM uds_tiff a" .
|
||||
" WHERE NOT EXISTS (SELECT 'x' FROM fax_imgs a1 WHERE a1.mid = a.mid)" .
|
||||
" AND a.recv_time >= DATE_ADD(NOW(), INTERVAL -7 DAY)" .
|
||||
" AND a.etc1 = ?";
|
||||
$query = $this->db->query($sql, $data);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* tiff 이미지 jpg로 변환 및 썸네일 생성
|
||||
*/
|
||||
public function insertFaxImgs($mid, $file_name, $file_path, $thumbnail, $img_width, $img_height, $img_size, $qrcode = '', $caller_no, $callee_no, $tiff_file_name, $tiff_save_path, $tiff_file_size, $recv_time, $save_time, $receiver)
|
||||
{
|
||||
$sql = "INSERT INTO fax_imgs" .
|
||||
" (MID, file_name, file_path, thumbnail, img_width, img_height, img_size, qrcode, caller_no, callee_no, tiff_file_name, tiff_save_path, tiff_file_size, recv_time, save_time, receiver)" .
|
||||
" VALUES" .
|
||||
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$data = [$mid, $file_name, $file_path, $thumbnail, $img_width, $img_height, $img_size, $qrcode, $caller_no, $callee_no, $tiff_file_name, $tiff_save_path, $tiff_file_size, $recv_time, $save_time, $receiver];
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function insertFaxImgs2($mid, $file_name, $file_path, $thumbnail, $img_width, $img_height, $img_size, $qrcode = '', $caller_no, $callee_no, $tiff_file_name, $tiff_save_path, $tiff_file_size, $recv_time, $save_time, $receiver)
|
||||
{
|
||||
$sql = "INSERT INTO fax_imgs" .
|
||||
" (MID, file_name, file_path, thumbnail, img_width, img_height, img_size, qrcode, caller_no, callee_no, tiff_file_name, tiff_save_path, tiff_file_size, recv_time, save_time, receiver)" .
|
||||
" VALUES" .
|
||||
" (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
$data = [$mid, $file_name, $file_path, $thumbnail, $img_width, $img_height, $img_size, $qrcode, $caller_no, $callee_no, $tiff_file_name, $tiff_save_path, $tiff_file_size, $recv_time, $save_time, $receiver];
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
public function selectFaxListTran()
|
||||
{
|
||||
|
||||
if (!isset($_SERVER["HOSTNAME"])) {
|
||||
$_SERVER["HOSTNAME"] = get_linux_hostname();
|
||||
}
|
||||
|
||||
$data = [$_SERVER["HOSTNAME"]];
|
||||
|
||||
$sql = "SELECT TR_MSGID, TR_TITLE, TR_SENDFAXNUM, TR_RECVFAXNUM, TR_RECVTIME, TR_FILENAMELIST" .
|
||||
" FROM FC_RECV_TRAN a" .
|
||||
" WHERE NOT EXISTS (SELECT 'x' FROM fax_imgs a1 WHERE a1.mid = a.TR_MSGID AND a1.receiver != 'uds_tiff')" .
|
||||
" AND a.TR_RECVTIME >= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL -7 DAY), '%Y%m%d%h%i%s')";
|
||||
|
||||
$query = $this->db->query($sql, $data);
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* FAX이미지를 홍보확인서에서 선택할 경우...
|
||||
*/
|
||||
public function updateImgSqOnFaxImgs($faxSq, $imgSq)
|
||||
{
|
||||
$sql = "UPDATE fax_imgs" .
|
||||
" SET img_sq = ?" .
|
||||
" WHERE fax_sq = ?";
|
||||
|
||||
$data = [$imgSq, $faxSq];
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 홍보확인서를 재지정했을 경우 기존의 홍보확인서는 선택되지 않음으로 ...
|
||||
*/
|
||||
public function updateImgSqNullOnFaxImgs($imgSq)
|
||||
{
|
||||
$sql = "UPDATE fax_imgs" .
|
||||
" SET img_sq = null" .
|
||||
" WHERE img_sq = ?";
|
||||
$data = [$imgSq];
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 비고를 지정한다.
|
||||
*/
|
||||
public function updateRemark($faxSq, $remark)
|
||||
{
|
||||
$sql = "UPDATE fax_imgs" .
|
||||
" SET remark = ?" .
|
||||
" WHERE fax_sq = ?";
|
||||
$data = [$remark, $faxSq];
|
||||
$this->db->query($sql, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 홍보확인서의 주소가 업데이트 되었을 경우
|
||||
* @param bigint $vr_sq receipt 테이블의 PK (rcpt_sq) 또는 v2_vrfc_req 테이블의 PK (vr_sq)
|
||||
* @param string $address_code 법정동코드
|
||||
* @param string $address2 상세주소
|
||||
* @param string $address3 기타주소
|
||||
* @param string $hscp_no 단지번호
|
||||
* @param string $hscp_nm 단지명
|
||||
*/
|
||||
public function updateAddress($vr_sq, $address_code, $address2, $address3, $hscp_no, $hscp_nm)
|
||||
{
|
||||
$data = [];
|
||||
if (!empty($address_code))
|
||||
$data['address_code'] = $address_code;
|
||||
if (!empty($address2))
|
||||
$data['address2'] = $address2;
|
||||
if (!empty($address3))
|
||||
$data['address3'] = $address3;
|
||||
// if (!empty($address4)) $data['address4'] = $address4;
|
||||
if (!empty($hscp_no))
|
||||
$data['hscp_no'] = $hscp_no;
|
||||
if (!empty($hscp_nm))
|
||||
$data['hscp_nm'] = $hscp_nm;
|
||||
|
||||
if (!empty($data)) {
|
||||
$where = [
|
||||
'vr_sq' => $vr_sq
|
||||
];
|
||||
$this->db->update('fax_imgs', $data, $where);
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAddress2($vr_sq, $address_code, $address2, $address2a, $address2b, $address3, $hscp_no, $hscp_nm)
|
||||
{
|
||||
$data = array();
|
||||
if (!empty($address_code))
|
||||
$data['address_code'] = $address_code;
|
||||
if (!empty($address2))
|
||||
$data['address2'] = $address2;
|
||||
if (!empty($address2))
|
||||
$data['address2a'] = $address2a;
|
||||
if (!empty($address2))
|
||||
$data['address2b'] = $address2b;
|
||||
if (!empty($address3))
|
||||
$data['address3'] = $address3;
|
||||
// if (!empty($address4)) $data['address4'] = $address4;
|
||||
if (!empty($hscp_no))
|
||||
$data['hscp_no'] = $hscp_no;
|
||||
if (!empty($hscp_nm))
|
||||
$data['hscp_nm'] = $hscp_nm;
|
||||
|
||||
if (!empty($data)) {
|
||||
$where = [
|
||||
'vr_sq' => $vr_sq
|
||||
];
|
||||
$this->db->update('fax_imgs', $data, $where);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 팩스건수 가져오기 -> 화면 최상단에 건수 보여줌.
|
||||
*/
|
||||
public function getFaxCount()
|
||||
{
|
||||
$sql = "SELECT
|
||||
date_format(now(), '%H') as base_time
|
||||
,(SELECT count(*) FROM uds_tiff where save_time >= concat(date_format(now(), '%Y-%m-%d %H'), ':00:00')) as enfax_count
|
||||
,(SELECT COUNT(*) FROM FC_RECV_TRAN where TR_RECVTIME >= concat(date_format(now(), '%Y%m%d%H'), '0000')) as lgfax_count
|
||||
";
|
||||
$query = $this->db->query($sql);
|
||||
|
||||
$row = $query->getRowArray();
|
||||
|
||||
return $row;
|
||||
}
|
||||
}
|
||||
125
app/Services/Handlers/TypeSHandler.php
Normal file
125
app/Services/Handlers/TypeSHandler.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Handlers;
|
||||
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Services\ParameterMapper\TypeSParameterMapper;
|
||||
use App\Models\Entities\ReceiptModel;
|
||||
use App\Models\Entities\ResultModel;
|
||||
use App\Models\Entities\NaverRawStagingModel;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Type S 핸들러
|
||||
* 현장확인 매물 (A01) 데이터 처리
|
||||
*/
|
||||
class TypeSHandler
|
||||
{
|
||||
private $receiptModel;
|
||||
private $resultModel;
|
||||
private $stagingModel;
|
||||
private $db;
|
||||
private $parameterMapper;
|
||||
private $naverClient;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->receiptModel = new ReceiptModel();
|
||||
$this->resultModel = new ResultModel();
|
||||
$this->stagingModel = new NaverRawStagingModel();
|
||||
$this->parameterMapper = new TypeSParameterMapper();
|
||||
$this->naverClient = new \App\Libraries\NaverApiClient();
|
||||
helper('log');
|
||||
}
|
||||
|
||||
/**
|
||||
* Type S 메인 처리 로직
|
||||
*/
|
||||
public function handle(string $articleNumber, array $rawData, array $payload): int
|
||||
{
|
||||
CLI::write(CLI::color('🟢 Type S 처리 시작 :: ' . $articleNumber, 'green'));
|
||||
|
||||
// CI 트랜잭션 strict 모드에서는 이전 실패 상태가 누적될 수 있으므로 시작 전에 초기화
|
||||
if (method_exists($this->db, 'resetTransStatus')) {
|
||||
$this->db->resetTransStatus();
|
||||
}
|
||||
|
||||
$this->db->transBegin();
|
||||
|
||||
try {
|
||||
// 1. Receipt 데이터 저장
|
||||
$receiptData = $this->parameterMapper->mapReceipt($articleNumber, $rawData, $payload);
|
||||
write_custom_log("Result Insert 데이터: " . json_encode($receiptData, JSON_UNESCAPED_UNICODE), 'INFO', 'service');
|
||||
if (!$this->receiptModel->insert($receiptData)) {
|
||||
$lastQuery = (string)$this->receiptModel->getLastQuery();
|
||||
$errors = json_encode($this->receiptModel->errors());
|
||||
write_custom_log("Receipt Insert 실패 | SQL: $lastQuery | Errors: $errors", 'ERROR', 'service');
|
||||
throw new Exception("Receipt Insert 실패: " . json_encode($this->receiptModel->errors()));
|
||||
}
|
||||
$rcptSq = $this->receiptModel->getInsertID();
|
||||
|
||||
$receiptInsertSql = (string)$this->receiptModel->getLastQuery(); // Receipt SQL 캡처
|
||||
CLI::write(CLI::color("✅ Receipt 저장 성공 (ID: $rcptSq)", 'blue'));
|
||||
|
||||
// 2. Result 데이터 저장
|
||||
$resultData = $this->parameterMapper->mapResult($rcptSq, $rawData);
|
||||
write_custom_log("Result Insert 데이터: " . json_encode($resultData, JSON_UNESCAPED_UNICODE), 'INFO', 'service');
|
||||
|
||||
if (!$this->resultModel->insert($resultData)) {
|
||||
$lastQuery = (string)$this->resultModel->getLastQuery();
|
||||
$errors = json_encode($this->resultModel->errors());
|
||||
write_custom_log("Result Insert 실패 | SQL: $lastQuery | Errors: $errors", 'ERROR', 'service');
|
||||
throw new Exception("Result Insert 실패: $errors");
|
||||
}
|
||||
|
||||
$resultInsertSql = (string)$this->resultModel->getLastQuery(); // Result SQL 캡처
|
||||
write_custom_log("Result Insert 성공 | SQL: $resultInsertSql", 'INFO', 'service');
|
||||
CLI::write(CLI::color('✅ Result 저장 성공', 'blue'));
|
||||
|
||||
// 3. 트랜잭션 커밋
|
||||
$this->db->transComplete();
|
||||
if ($this->db->transStatus() === false) {
|
||||
$dbError = $this->db->error();
|
||||
$errorJson = json_encode($dbError, JSON_UNESCAPED_UNICODE);
|
||||
$receiptLastQuery = (string)$this->receiptModel->getLastQuery();
|
||||
$resultLastQuery = (string)$this->resultModel->getLastQuery();
|
||||
|
||||
write_custom_log(
|
||||
"Type S DB 트랜잭션 최종 실패 | DB Error: {$errorJson} | ReceiptLastQuery: {$receiptLastQuery} | ResultLastQuery: {$resultLastQuery}",
|
||||
'ERROR',
|
||||
'service'
|
||||
);
|
||||
throw new Exception("Type S DB 트랜잭션 최종 실패");
|
||||
}
|
||||
|
||||
// 4. 로그 기록
|
||||
write_custom_log("Type S 처리 성공 | Atcl: $articleNumber | Rcpt_sq: $rcptSq", 'INFO', 'service');
|
||||
write_custom_log("Receipt Insert SQL: " . $receiptInsertSql, 'INFO', 'service');
|
||||
write_custom_log("Result Insert SQL: " . $resultInsertSql, 'INFO', 'service');
|
||||
|
||||
// 5. 네이버 예약 정보 동기화 (비동기)
|
||||
// try {
|
||||
// // $syncResult = $this->naverClient->submitSyncResult($rawData['reserveNo'] ?? '');
|
||||
// $rsrv_date = $receiptData['rsrv_date'] ?? null;
|
||||
// $reportData = [
|
||||
// 'type' => 'S11',
|
||||
// 'code' => '10000',
|
||||
// 'message' => '현장확인 예약',
|
||||
// 'reserveDate' => $rsrv_date
|
||||
// ];
|
||||
// $syncResult = $this->naverClient->verificationSiteReport($articleNumber, $reportData);
|
||||
// write_custom_log("Naver Sync Result Response: " . json_encode($syncResult), 'INFO', 'service');
|
||||
// } catch (Exception $e) {
|
||||
// write_custom_log("Naver Sync 실패 (계속 진행): " . $e->getMessage(), 'WARN', 'service');
|
||||
// }
|
||||
|
||||
return $rcptSq;
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->db->transRollback();
|
||||
write_custom_log("Type S 처리 실패: " . $e->getMessage(), 'ERROR', 'service');
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
325
app/Services/Handlers/TypeV2Handler.php
Normal file
325
app/Services/Handlers/TypeV2Handler.php
Normal file
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Handlers;
|
||||
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Services\ParameterMapper\TypeV2ParameterMapper;
|
||||
use App\Models\Entities\VrfcReqModel;
|
||||
use App\Models\Entities\V2articleinfoModel;
|
||||
use App\Models\Entities\V2articleinfoetcModel;
|
||||
use App\Models\Entities\V2modifyinfoModel;
|
||||
use App\Models\Entities\V2urlimgsaveModel;
|
||||
use App\Services\StatusService;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* Type V2 핸들러
|
||||
* 일반/서류/비공동 매물 (D04, F01 등) 데이터 처리
|
||||
*/
|
||||
class TypeV2Handler
|
||||
{
|
||||
private $vrfcReqModel;
|
||||
private $articleInfoModel;
|
||||
private $articleInfoEtcModel;
|
||||
private $modifyInfoModel;
|
||||
private $urlImgSaveModel;
|
||||
private $statusService;
|
||||
private $db;
|
||||
private $parameterMapper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = \Config\Database::connect();
|
||||
$this->vrfcReqModel = new VrfcReqModel();
|
||||
$this->articleInfoModel = new V2articleinfoModel();
|
||||
$this->articleInfoEtcModel = new V2articleinfoetcModel();
|
||||
$this->modifyInfoModel = new V2modifyinfoModel();
|
||||
$this->urlImgSaveModel = new V2urlimgsaveModel();
|
||||
$this->statusService = new StatusService();
|
||||
$this->parameterMapper = new TypeV2ParameterMapper();
|
||||
helper('log');
|
||||
}
|
||||
|
||||
/**
|
||||
* Type V2 메인 처리 로직
|
||||
*/
|
||||
public function handle(string $articleNumber, array $rawData, array $payload): int
|
||||
{
|
||||
CLI::write(CLI::color('🟢 Type V2 처리 시작 :: ' . $articleNumber, 'green'));
|
||||
write_custom_log("TypeV2Handler 진입 | Atcl: $articleNumber | Payload: " . json_encode($payload), 'INFO', 'service');
|
||||
|
||||
try {
|
||||
$requestType = $payload['requestType'] ?? 'REG';
|
||||
CLI::write(CLI::color("🔵 RequestType: $requestType", 'cyan'));
|
||||
|
||||
switch ($requestType) {
|
||||
case 'REG':
|
||||
return $this->handleRegister($articleNumber, $rawData, $payload);
|
||||
case 'MOD':
|
||||
return $this->handleModify($articleNumber, $rawData, $payload);
|
||||
case 'CNC':
|
||||
return $this->handleCancel($articleNumber, $rawData, $payload);
|
||||
default:
|
||||
throw new Exception("알 수 없는 requestType: $requestType");
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
$errorDetail = "Type V2 처리 실패 | Atcl: $articleNumber | Error: " . $e->getMessage() . " | File: " . $e->getFile() . ":" . $e->getLine();
|
||||
write_custom_log($errorDetail, 'ERROR', 'service');
|
||||
CLI::write(CLI::color("❌ " . $errorDetail, 'red'));
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 신규 등록 처리
|
||||
*/
|
||||
private function handleRegister(string $articleNumber, array $rawData, array $payload): int
|
||||
{
|
||||
CLI::write(CLI::color('🔵 V2 신규 등록 시작', 'cyan'));
|
||||
|
||||
// 파라미터 준비
|
||||
$vrfcReqParam = $this->parameterMapper->mapVrfcReq($articleNumber, $rawData, $payload);
|
||||
$articleInfoParam = $this->parameterMapper->mapArticleInfo($articleNumber, $rawData, $payload);
|
||||
$articleInfoEtcParam = $this->parameterMapper->mapArticleInfoEtc($articleNumber, $rawData);
|
||||
$modifyInfoParam = $this->parameterMapper->mapModifyInfo($articleNumber, $rawData, $payload);
|
||||
|
||||
// 검증 요청 저장 또는 업데이트
|
||||
$vrSq = $this->insertOrUpdateVrfcReq($vrfcReqParam);
|
||||
|
||||
// 기사 정보 저장
|
||||
$articleInfoParam['vr_sq'] = $vrSq;
|
||||
if (!$this->articleInfoModel->replace($articleInfoParam)) {
|
||||
throw new Exception("ArticleInfo Insert 실패: " . json_encode($this->db->error()));
|
||||
}
|
||||
CLI::write(CLI::color('✅ ArticleInfo 저장 성공', 'blue'));
|
||||
|
||||
// 기사 정보 추가 저장
|
||||
$articleInfoEtcParam['vr_sq'] = $vrSq;
|
||||
if (!$this->articleInfoEtcModel->replace($articleInfoEtcParam)) {
|
||||
CLI::write(CLI::color('❌ ArticleInfoEtc 저장 실패 :: ' . json_encode($articleInfoEtcParam), 'red'));
|
||||
throw new Exception("ArticleInfoEtc Insert 실패: " . json_encode($this->db->error()));
|
||||
}
|
||||
CLI::write(CLI::color('✅ ArticleInfoEtc 저장 성공', 'blue'));
|
||||
|
||||
// 수정 정보 입력 (있으면 update, 없으면 insert)
|
||||
$modifyInfoParam['vr_sq'] = $vrSq;
|
||||
|
||||
$sql = $this->modifyInfoModel->builder()->set($modifyInfoParam)->getCompiledInsert();
|
||||
CLI::write(CLI::color("\n[생성된 쿼리 예상안]:", 'yellow'));
|
||||
CLI::write($sql);
|
||||
|
||||
if (!$this->modifyInfoModel->replace($modifyInfoParam)) {
|
||||
CLI::write(CLI::color('❌ modifyInfoParam 저장 실패 :: ' . json_encode($modifyInfoParam), 'red'));
|
||||
throw new Exception("ModifyInfo 저장 실패: " . json_encode($this->db->error() . " sql: " . $this->modifyInfoModel->getLastQuery()));
|
||||
}
|
||||
CLI::write(CLI::color('✅ ModifyInfo 저장 성공', 'blue'));
|
||||
|
||||
// URL 이미지 저장 (v2_url_img_save 테이블)
|
||||
$files = $rawData['files'] ?? [];
|
||||
if (!empty($files)) {
|
||||
$fileExtracted = $this->parameterMapper->extractFilesByType($files);
|
||||
$this->saveUrlImagesToDb($fileExtracted, $articleNumber, $vrSq);
|
||||
}
|
||||
|
||||
// 상태 기록
|
||||
$this->statusService->recordStatusAndHistory($vrSq, '10', 'C9', "NEW 신규접수 : 10");
|
||||
|
||||
write_custom_log("V2 신규 등록 성공 | Atcl: $articleNumber | VR_SQ: $vrSq", 'INFO', 'service');
|
||||
|
||||
return $vrSq;
|
||||
}
|
||||
|
||||
/**
|
||||
* 수정 처리
|
||||
*/
|
||||
private function handleModify(string $articleNumber, array $rawData, array $payload): int
|
||||
{
|
||||
CLI::write(CLI::color('🔵 V2 수정 시작', 'cyan'));
|
||||
|
||||
// 기존 검증 요청 확인
|
||||
$existing = $this->vrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
if (!$existing) {
|
||||
CLI::write(CLI::color("⚠️ 수정할 기존 데이터가 없음 → 신규 등록으로 전환 (Atcl: $articleNumber)", 'yellow'));
|
||||
write_custom_log("MOD → REG 자동 전환 | Atcl: $articleNumber | 사유: 기존 데이터 없음", 'WARNING', 'service');
|
||||
return $this->handleRegister($articleNumber, $rawData, $payload);
|
||||
}
|
||||
$vrSq = $existing['vr_sq'];
|
||||
$stat_cd = $existing['stat_cd'];
|
||||
|
||||
// 파라미터 준비 (MOD 타입)
|
||||
$vrfcReqParam = $this->parameterMapper->mapVrfcReq($articleNumber, $rawData, $payload);
|
||||
$articleInfoParam = $this->parameterMapper->mapArticleInfo($articleNumber, $rawData, $payload);
|
||||
$articleInfoEtcParam = $this->parameterMapper->mapArticleInfoEtc($articleNumber, $rawData);
|
||||
$modifyInfoParam = $this->parameterMapper->mapModifyInfo($articleNumber, $rawData, $payload);
|
||||
|
||||
$vrfcReqParam['stat_cd'] = '30';
|
||||
$vrfcReqParam['insert_tm'] = date('Y-m-d H:i:s');
|
||||
$vrfcReqParam['sync_yn'] = 'Y';
|
||||
|
||||
// 데이터 업데이트
|
||||
if (!$this->vrfcReqModel->update($vrSq, $vrfcReqParam)) {
|
||||
throw new Exception("VrfcReq Update 실패");
|
||||
}
|
||||
|
||||
// 기사 정보 저장
|
||||
$articleInfoParam['vr_sq'] = $vrSq;
|
||||
if (!$this->articleInfoModel->replace($articleInfoParam)) {
|
||||
throw new Exception("ArticleInfo Insert 실패: " . json_encode($this->db->error()));
|
||||
}
|
||||
CLI::write(CLI::color('✅ ArticleInfo 저장 성공', 'blue'));
|
||||
|
||||
// 기사 정보 추가 저장
|
||||
$articleInfoEtcParam['vr_sq'] = $vrSq;
|
||||
if (!$this->articleInfoEtcModel->replace($articleInfoEtcParam)) {
|
||||
throw new Exception("ArticleInfoEtc Insert 실패: " . json_encode($this->db->error()));
|
||||
}
|
||||
CLI::write(CLI::color('✅ ArticleInfoEtc 저장 성공', 'blue'));
|
||||
|
||||
// 수정 정보 입력 (있으면 update, 없으면 insert)
|
||||
if (!$this->modifyInfoModel->saveModifyInfo($vrSq, $modifyInfoParam)) {
|
||||
throw new Exception("ModifyInfo 저장 실패: " . json_encode($this->db->error()));
|
||||
}
|
||||
CLI::write(CLI::color('✅ ModifyInfo 저장 성공', 'blue'));
|
||||
|
||||
// URL 이미지 저장 (v2_url_img_save 테이블)
|
||||
$files = $rawData['files'] ?? [];
|
||||
if (!empty($files)) {
|
||||
$fileExtracted = $this->parameterMapper->extractFilesByType($files);
|
||||
$this->saveUrlImagesToDb($fileExtracted, $articleNumber, $vrSq);
|
||||
}
|
||||
|
||||
$this->statusService->recordStatusAndHistory($vrSq, '30', 'C9', "재접수 상태변경 : {$stat_cd} => 30");
|
||||
CLI::write(CLI::color('✅ VrfcReq 수정 성공', 'blue'));
|
||||
|
||||
return $vrSq;
|
||||
}
|
||||
|
||||
/**
|
||||
* 취소 처리
|
||||
*/
|
||||
private function handleCancel(string $articleNumber, array $rawData, array $payload): int
|
||||
{
|
||||
CLI::write(CLI::color('🔵 V2 취소 시작', 'cyan'));
|
||||
|
||||
// 기존 검증 요청 확인
|
||||
$existing = $this->vrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
if (!$existing) {
|
||||
CLI::write(CLI::color("⚠️ 취소할 데이터가 없음 → 무시 (Atcl: $articleNumber)", 'yellow'));
|
||||
write_custom_log("CNC 무시 | Atcl: $articleNumber | 사유: 기존 데이터 없음", 'WARNING', 'service');
|
||||
return 0; // 취소할 데이터가 없으므로 0 반환
|
||||
}
|
||||
|
||||
$vrSq = $existing['vr_sq'];
|
||||
$stat_cd = $existing['stat_cd'];
|
||||
|
||||
// 파라미터 준비 (MOD 타입)
|
||||
$vrfcReqParam = $this->parameterMapper->mapVrfcReq($articleNumber, $rawData, $payload);
|
||||
$vrfcReqParam['stat_cd'] = '19';
|
||||
$vrfcReqParam['insert_tm'] = date('Y-m-d H:i:s');
|
||||
$vrfcReqParam['req_type'] = 'D';
|
||||
|
||||
// 상태를 취소로 업데이트
|
||||
if (!$this->vrfcReqModel->update($vrSq, $vrfcReqParam)) {
|
||||
throw new Exception("VrfcReq Cancel 실패");
|
||||
}
|
||||
|
||||
$this->statusService->recordStatusAndHistory($vrSq, '19', 'C9', "재접수 상태변경 : {$stat_cd} => 19");
|
||||
CLI::write(CLI::color('✅ 취소 처리 완료', 'blue'));
|
||||
|
||||
write_custom_log("V2 취소 성공 | Atcl: $articleNumber | VR_SQ: $vrSq", 'INFO', 'service');
|
||||
|
||||
return $vrSq;
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 요청 저장 또는 업데이트
|
||||
*/
|
||||
private function insertOrUpdateVrfcReq(array $vrfcReqParam): int
|
||||
{
|
||||
$articleNumber = $vrfcReqParam['atcl_no'];
|
||||
$existing = $this->vrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
|
||||
if ($existing) {
|
||||
// 업데이트
|
||||
$vrSq = $existing['vr_sq'] ?? $existing['id'];
|
||||
CLI::write(CLI::color("🟡 기존 데이터 발견 (atcl_no: $articleNumber) -> 업데이트", 'yellow'));
|
||||
|
||||
if (!$this->vrfcReqModel->update($vrSq, $vrfcReqParam)) {
|
||||
$this->logAndThrowError($vrfcReqParam, "VrfcReq Update 실패 :: $articleNumber");
|
||||
}
|
||||
CLI::write(CLI::color("✅ Update 성공 (vr_sq: $vrSq)", 'blue'));
|
||||
|
||||
return $vrSq;
|
||||
} else {
|
||||
// 신규 등록
|
||||
if (!$this->vrfcReqModel->insert($vrfcReqParam)) {
|
||||
$this->logAndThrowError($vrfcReqParam, "VrfcReq Insert 실패 :: $articleNumber");
|
||||
}
|
||||
|
||||
$vrSq = $this->vrfcReqModel->getInsertID();
|
||||
CLI::write(CLI::color("✅ Insert 성공 (vr_sq: $vrSq, atcl_no: $articleNumber)", 'blue'));
|
||||
|
||||
return $vrSq;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 에러 로깅 및 예외 발생
|
||||
*/
|
||||
private function logAndThrowError(array $data, string $message): void
|
||||
{
|
||||
$dbError = $this->db->error();
|
||||
CLI::write(CLI::color('❌ SQL ERROR', 'red', 'bold'));
|
||||
CLI::write(CLI::color('메시지: ', 'white') . $dbError['message']);
|
||||
CLI::write(CLI::color('쿼리: ', 'white') . (string)$this->vrfcReqModel->getLastQuery());
|
||||
|
||||
throw new Exception($message . ": " . $dbError['message']);
|
||||
}
|
||||
|
||||
/**
|
||||
* URL 이미지를 v2_url_img_save 테이블에 저장
|
||||
*
|
||||
* @param array $fileExtracted extractFilesByType로 추출된 파일 배열
|
||||
* @param string $atclNo 기사번호
|
||||
* @param int $vrSq 검증요청ID
|
||||
*/
|
||||
private function saveUrlImagesToDb(array $fileExtracted, string $atclNo, int $vrSq): void
|
||||
{
|
||||
$fileTypes = [
|
||||
'certRegister' => '2', // 등기부등본
|
||||
'confirmDocImgUrl' => '2', // 확인서이미지
|
||||
'referenceFileUrl' => '1' // 홍보자료
|
||||
];
|
||||
|
||||
$saveCount = 0;
|
||||
|
||||
foreach ($fileTypes as $key => $type) {
|
||||
if (!empty($fileExtracted[$key]) && is_array($fileExtracted[$key])) {
|
||||
foreach ($fileExtracted[$key] as $url) {
|
||||
if (!empty($url)) {
|
||||
$insertData = [
|
||||
'url' => $url,
|
||||
'type' => $type,
|
||||
'atcl_no' => $atclNo,
|
||||
'vr_sq' => $vrSq,
|
||||
'status' => 'save',
|
||||
'try_cnt' => 0
|
||||
];
|
||||
|
||||
if ($this->urlImgSaveModel->insert($insertData)) {
|
||||
$saveCount++;
|
||||
} else {
|
||||
CLI::write(CLI::color("⚠️ URL 저장 실패: $url", 'yellow'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($saveCount > 0) {
|
||||
CLI::write(CLI::color("✅ URL 이미지 저장 완료: $saveCount개", 'blue'));
|
||||
write_custom_log("URL 이미지 저장 | Atcl: $atclNo | VR_SQ: $vrSq | Count: $saveCount", 'INFO', 'service');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,542 +4,94 @@ namespace App\Services;
|
||||
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use App\Libraries\NaverApiClient;
|
||||
use App\Models\Entities\VrfcReqModel;
|
||||
use App\Models\Entities\V2stdailyModel;
|
||||
use App\Models\Entities\NaverRawStagingModel;
|
||||
use App\Models\Entities\ReceiptModel;
|
||||
use App\Models\Entities\ResultModel;
|
||||
use App\Services\StatusService; // 추가
|
||||
use App\Services\Handlers\TypeSHandler;
|
||||
use App\Services\Handlers\TypeV2Handler;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* 네이버 부동산 매물 처리 서비스
|
||||
*
|
||||
* 네이버 API 응답을 받아서 타입별 처리 로직으로 위임하는 오케스트레이터 역할
|
||||
* - Type S, S_VR: 현장확인 (A01)
|
||||
* - Type V2: 일반/서류/비공동 (D04, F01 등)
|
||||
*/
|
||||
class NaverService
|
||||
{
|
||||
protected $db;
|
||||
protected $naverClient, $VrfcReqModel, $V2stdailyModel, $statusService, $rawStagingModel, $receiptModel, $resultModel;
|
||||
private $db;
|
||||
private $naverClient;
|
||||
private $rawStagingModel;
|
||||
private $typeSHandler;
|
||||
private $typeV2Handler;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = \Config\Database::connect();
|
||||
|
||||
$this->naverClient = new NaverApiClient();
|
||||
$this->VrfcReqModel = model(VrfcReqModel::class);
|
||||
$this->V2stdailyModel = model(V2stdailyModel::class);
|
||||
$this->rawStagingModel = model(NaverRawStagingModel::class);
|
||||
|
||||
$this->receiptModel = model(ReceiptModel::class);
|
||||
$this->resultModel = model(ResultModel::class);
|
||||
$this->statusService = new StatusService(); // 인스턴스 생성
|
||||
|
||||
$this->rawStagingModel = new NaverRawStagingModel();
|
||||
$this->typeSHandler = new TypeSHandler();
|
||||
$this->typeV2Handler = new TypeV2Handler();
|
||||
helper('log');
|
||||
}
|
||||
|
||||
/**
|
||||
* 메인 프로세스: 요청 타입에 따른 분기 처리
|
||||
* 메인 프로세스: 네이버 API 호출 및 타입별 처리
|
||||
*
|
||||
* @param array $payload 요청 페이로드 (articleNumber, requestType 등)
|
||||
* @return int 처리된 ID (rcpt_sq 또는 vr_sq)
|
||||
* @throws Exception
|
||||
*/
|
||||
public function processArticle(array $payload)
|
||||
public function processArticle(array $payload): int
|
||||
{
|
||||
$articleNumber = $payload['articleNumber'];
|
||||
$requestType = $payload['requestType'] ?? '';
|
||||
|
||||
CLI::write(CLI::color('🟢 getArticleInfo Start :: ' . $articleNumber, 'green'));
|
||||
|
||||
try {
|
||||
// 1. 네이버 API 호출
|
||||
$response = $this->naverClient->getArticleInfo($articleNumber);
|
||||
if (!$response || $response['code'] !== 'success') {
|
||||
throw new \Exception("네이버 API 응답 에러: $articleNumber");
|
||||
throw new Exception("네이버 API 응답 에러: $articleNumber");
|
||||
}
|
||||
|
||||
$rawData = $response['data'];
|
||||
$vType = $rawData['verificationTypeCode'] ?? '';
|
||||
|
||||
// 2. [Staging] 원본 DB 저장 (JSON 타입 컬럼 활용)
|
||||
$this->rawStagingModel->insert([
|
||||
// 2. 원본 데이터 Staging 저장
|
||||
$insertResult = $this->rawStagingModel->insert([
|
||||
'atcl_no' => $articleNumber,
|
||||
'verification_type' => $vType,
|
||||
'request_type' => $requestType,
|
||||
'raw_json' => $rawData // 모델에서 json_encode 처리됨
|
||||
'raw_json' => $rawData
|
||||
]);
|
||||
|
||||
if (!$insertResult) {
|
||||
$dbError = $this->db->error();
|
||||
write_custom_log("naver_raw_staging Insert 실패 | Atcl: $articleNumber | Error: " . json_encode($dbError), 'ERROR', 'service');
|
||||
throw new Exception("naver_raw_staging 저장 실패: " . json_encode($dbError));
|
||||
}
|
||||
|
||||
CLI::write(CLI::color('🟢 임시테이블 저장 완료', 'green'));
|
||||
|
||||
// 3. 타입별 분기 처리
|
||||
if ($vType === 'S') {
|
||||
// [Type S] 현장확인 응답 처리 (A01 등)
|
||||
return $this->processTypeS($articleNumber, $rawData, $payload);
|
||||
CLI::write(CLI::color("🔵 검증타입 확인: vType = $vType", 'cyan'));
|
||||
write_custom_log("타입별 분기 | Atcl: $articleNumber | vType: $vType | requestType: $requestType", 'INFO', 'service');
|
||||
|
||||
if ($vType === 'S' || $vType === 'S_VR') {
|
||||
CLI::write(CLI::color('🟢 Type S Handler 호출', 'green'));
|
||||
return $this->typeSHandler->handle($articleNumber, $rawData, $payload);
|
||||
} else {
|
||||
// [Type D/기타] 서류확인/비공동 처리 (D04, F01 등)
|
||||
return $this->processTypeV2($articleNumber, $rawData, $payload);
|
||||
CLI::write(CLI::color('🟢 Type V2 Handler 호출', 'green'));
|
||||
$result = $this->typeV2Handler->handle($articleNumber, $rawData, $payload);
|
||||
write_custom_log("TypeV2Handler 완료 | Atcl: $articleNumber | Result: $result", 'INFO', 'service');
|
||||
return $result;
|
||||
}
|
||||
|
||||
// $vrfcParams = $this->mapToDatabaseParams($response['data'], $payload);
|
||||
// write_custom_log("PROCESS_START | Type: $requestType | Atcl: $articleNumber", 'INFO', 'service');
|
||||
|
||||
// switch ($requestType) {
|
||||
// case 'REG': // 신규 등록
|
||||
// $vr_sq = $this->insertVrfcReq($articleNumber, $vrfcParams);
|
||||
// if ($vr_sq) $this->V2stdailyModel->set_v2_st_daily(null, $vrfcParams['cpid'], $vrfcParams['vrfc_type'] . '0103', '1', 'add');
|
||||
// break;
|
||||
|
||||
// case 'MOD': // 수정
|
||||
// $vr_sq = $this->updateVrfcReq($articleNumber, $vrfcParams);
|
||||
// if ($vr_sq) $this->V2stdailyModel->set_v2_st_daily(null, $vrfcParams['cpid'], $vrfcParams['vrfc_type'] . '0102', '1', 'add');
|
||||
// break;
|
||||
|
||||
// case 'CNC': // 취소
|
||||
// $vr_sq = $this->deleteVrfcReq($articleNumber, $vrfcParams);
|
||||
// if ($vr_sq) $this->V2stdailyModel->set_v2_st_daily(null, $vrfcParams['cpid'], 'A0101', '1', 'add');
|
||||
// break;
|
||||
|
||||
// // case 'FIN': // 완료
|
||||
// // $vr_sq = $this->finVrfcReq($articleNumber, $vrfcParams);
|
||||
// // if ($vr_sq) $this->V2stdailyModel->set_v2_st_daily(null, $vrfcParams['cpid'], 'A0101', '1', 'add');
|
||||
// // break;
|
||||
|
||||
// default:
|
||||
// throw new \Exception("알 수 없는 requestType: $requestType");
|
||||
// }
|
||||
|
||||
// return ['vr_sq' => $vr_sq, 'articleNumber' => $articleNumber];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [Type S] 현장확인 응답 처리 (A01 등)
|
||||
*/
|
||||
private function processTypeS($articleNumber, $rawData, $payload)
|
||||
{
|
||||
$now = db_now();
|
||||
|
||||
// 시작 전 트랜잭션
|
||||
$this->db->transStart();
|
||||
|
||||
|
||||
switch ( trim($rawData['tradeType']) ) {
|
||||
case '매매': $trade_type = 'A1'; break;
|
||||
case '전세': $trade_type = 'B1'; break;
|
||||
case '월세': $trade_type = 'B2'; break;
|
||||
case '단기임대': $trade_type = 'B3'; break;
|
||||
}
|
||||
|
||||
/* 좌표와 전용면적을 기준으로 */
|
||||
if( in_array($rawData['realEstateTypeCode'], array('C01', 'C02'))){
|
||||
$ground_plan = 'N';
|
||||
} else {
|
||||
$ground_plan = 'Y';
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. receipt 데이터 준비
|
||||
$receiptData = [
|
||||
'comp_sq' => '2',
|
||||
'rcpt_rating' => '3',
|
||||
'rcpt_key' => $articleNumber,
|
||||
'rcpt_atclno' => $articleNumber,
|
||||
'rcpt_product' => $rawData['realEstateTypeCode'] ?? null,
|
||||
'rcpt_product_nm' => $rawData['realEstateType'] ?? null,
|
||||
'rcpt_product_info1'=> $rawData['tradeType'] ?? null,
|
||||
'rcpt_product_info2'=> $rawData['price']['dealAmount'] ?? '0',
|
||||
'rcpt_product_info4'=> $rawData['price']['preSaleAmount'] ?? '0',
|
||||
'rcpt_product_info5'=> $rawData['price']['premiumAmount'] ?? '0',
|
||||
'rcpt_living_yn' => ($rawData['site']['isRegistration'] ?? false) ? 'Y' : 'N',
|
||||
'rcpt_agent' => $rawData['realtor']['realtorName'] ?? null,
|
||||
'rcpt_sido' => mb_substr($rawData['address']['legalDivision']['cityNumber'] ?? '', 0, 5),
|
||||
'rcpt_gugun' => mb_substr($rawData['address']['legalDivision']['divisionNumber'] ?? '', 0, 10),
|
||||
'rcpt_dong' => $rawData['address']['legalDivision']['sectorNumber'] ?? null,
|
||||
'rcpt_hscp_nm' => $rawData['address']['complexName'] ?? null,
|
||||
'rcpt_hscp_no' => $rawData['address']['complexNumber'] ?? null,
|
||||
'rcpt_ptp_nm' => null,
|
||||
'rcpt_ptp_no' => $rawData['address']['pyeongTypeNumber'] ?? null,
|
||||
'rcpt_dtl_addr' => trim(($rawData['address']['legalDivision']['legalDivisionAddress'] ?? '') . $rawData['address']['buildingName'] . '동 ' . ($rawData['address']['hoName'] ?? '') . '호'),
|
||||
'rcpt_etc_addr' => $rawData['address']['hoName'] ?? null,
|
||||
'rcpt_floor' => $rawData['floor']['correspondenceFloorCount'] ?? null,
|
||||
'rcpt_floor2' => $rawData['floor']['totalFloorCount'] ?? null,
|
||||
'rcpt_exps_type' => '',
|
||||
'rcpt_exp_photo_yn' => 'Y',
|
||||
'rcpt_deal_type' => $rawData['tradeTypeCode'] ?? null,
|
||||
'rcpt_product_nm' => $rawData['tradeType'] ?? null,
|
||||
'trade_type' => $trade_type ?? null,
|
||||
'ground_plan' => $ground_plan,
|
||||
'excls_spce' => $rawData['space']['exclusiveSpace'] ?? null,
|
||||
'sply_spc' => $rawData['space']['supplySpace'] ?? null,
|
||||
'tot_spc' => $rawData['space']['totalSpace'] ?? null,
|
||||
'grnd_spc' => $rawData['space']['groundSpace'] ?? null,
|
||||
'bldg_spc' => $rawData['space']['buildingSpace'] ?? null,
|
||||
'share_spc' => $rawData['space']['supplySpace']-$rawData['space']['exclusiveSpace'] ?? null,
|
||||
'room_cnt' => $rawData['facilities']['roomCount'] ?? null,
|
||||
'cupnNo' => $rawData['couponNumber'] ?? null,
|
||||
'roomSiteAtclRgstCnt' => $rawData['site']['monthlyRegisterCount'] ?? null,
|
||||
'roomSiteAtclExpsCnt' => $rawData['site']['monthlyExposureCount'] ?? null,
|
||||
'direct_trad_yn' => ($rawData['seller']['isDirectTrade'] ?? false) ? 'Y' : 'N',
|
||||
'sellr_nm' => $rawData['seller']['sellerName'] ?? null,
|
||||
'sellr_tel_no' => $rawData['seller']['sellerTelephoneNumber'] ?? null,
|
||||
'rcpt_ref_addr' => $rawData['address']['etcAddress'] ?? null,
|
||||
'rcpt_tm' => $now,
|
||||
'rcpt_stat' => '100000',
|
||||
'rcpt_x' => $rawData['address']['longitude'] ?? null,
|
||||
'rcpt_y' => $rawData['address']['latitude'] ?? null,
|
||||
'agent_id' => '',
|
||||
'agent_nm' => $rawData['realtor']['realtorName'] ?? null,
|
||||
'agent_head_tel' => $rawData['realtor']['representativeCellphoneNumber'] ?? null,
|
||||
'rsrv_date' => $rawData['site']['visitReserveDate'] ?? null,
|
||||
'rsrv_tm_ap' => '00', // 컬럼명이 rsrv_tm_ap 인지 확인 필요 (제공해주신 스키마 기준)
|
||||
'insert_tm' => $now,
|
||||
'rcpt_cpid' => $rawData['cpId'] ?? 'naver',
|
||||
'room_cnt' => $rawData['facilities']['roomCount'] ?? null,
|
||||
'isSiteVRVerification' => ($rawData['site']['isVrVerification'] ?? false) ? 'Y' : 'N',
|
||||
'isPromotionApply' => ($rawData['site']['isVrRepresentativeApply'] ?? false) ? 'Y' : 'N',
|
||||
];
|
||||
|
||||
if (!$this->receiptModel->insert($receiptData)) {
|
||||
throw new \Exception("Receipt Insert 실패: " . json_encode($this->receiptModel->errors()));
|
||||
}
|
||||
|
||||
$rcpt_sq = $this->receiptModel->getInsertID();
|
||||
|
||||
if ( $receiptData['isVrVerification'] == "Y") {
|
||||
$dept_sq = '29';
|
||||
$usr_sq = '1993';
|
||||
}
|
||||
|
||||
// 2. result 데이터 준비
|
||||
$resultData = [
|
||||
'rcpt_sq' => $rcpt_sq,
|
||||
'use_yn' => 'Y',
|
||||
'cust_nm' => '',
|
||||
'rsrv_date' => $rawData['site']['visitReserveDate'] ?? null,
|
||||
'rsrv_tm_ap' => '00', // 컬럼명이 rsrv_tm_ap 인지 확인 필요 (제공해주신 스키마 기준)
|
||||
'result_cd1' => '10',
|
||||
'result_cd2' => '1000',
|
||||
'result_cd3' => '100000',
|
||||
'insert_tm' => $now,
|
||||
'insert_usr' => 0,
|
||||
'update_tm' => $now,
|
||||
'update_usr' => 0,
|
||||
'dept_sq' => $dept_sq, // 필요 시 매핑 로직 추가
|
||||
'usr_sq' => $usr_sq, // 필요 시 매핑 로직 추가
|
||||
'resYn' => ($rawData['site']['isRegistration'] ?? false) ? 'Y' : 'N',
|
||||
];
|
||||
|
||||
if (!$this->resultModel->insert($resultData)) {
|
||||
throw new \Exception("Result Insert 실패");
|
||||
}
|
||||
|
||||
$this->db->transComplete();
|
||||
// 성공 로그 생성 쿼리 포함
|
||||
write_custom_log("Type S 처리 성공 | Atcl: $articleNumber | Rcpt_sq: $rcpt_sq", 'INFO', 'service');
|
||||
write_custom_log("Receipt Insert SQL: " . (string)$this->receiptModel->getLastQuery(), 'INFO', 'service');
|
||||
write_custom_log("Result Insert SQL: " . (string)$this->resultModel->getLastQuery(), 'INFO', 'service');
|
||||
|
||||
// 예약 정보 동기화 전송
|
||||
$return = $this->naverClient->submitSyncResult($rawData['reserveNo']);
|
||||
write_custom_log("Naver Sync Result Response: " . json_encode($return), 'INFO', 'service');
|
||||
|
||||
// transComplete 이후에 transStatus를 확인하는 것이 CI4의 표준입니다.
|
||||
if ($this->db->transStatus() === false) {
|
||||
// transComplete가 실패하면 자동으로 롤백되지만, 명시적 예외 처리가 안전합니다.
|
||||
// 로그 남기기
|
||||
write_custom_log("Type S DB 트랜잭션 최종 실패", 'ERROR', 'service');
|
||||
throw new \Exception("Type S DB 트랜잭션 최종 실패");
|
||||
}
|
||||
|
||||
return $rcpt_sq;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// 이미 transComplete 내부에서 실패 시 롤백되지만, 예외 발생 시 수동 롤백 보장
|
||||
// if ($this->db->transEnabled()) {
|
||||
$this->db->transRollback();
|
||||
// }
|
||||
} catch (Exception $e) {
|
||||
write_custom_log("processArticle 실패: " . $e->getMessage(), 'ERROR', 'service');
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
public function processTypeV2($articleNumber, $rawData, $payload){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* [REG] 신규 등록
|
||||
*/
|
||||
private function insertVrfcReq($articleNumber, $params)
|
||||
{
|
||||
CLI::write(CLI::color('🟢 매물 정보 시작', 'green'));
|
||||
$existing = $this->VrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
if ($existing) throw new \Exception("중복 등록 시도: $articleNumber");
|
||||
|
||||
$params['stat_cd'] = '10';
|
||||
$params['insert_user'] = '0';
|
||||
$params['req_type'] = 'C';
|
||||
|
||||
if (!$this->VrfcReqModel->insert($params)) {
|
||||
$sql = (string)$this->VrfcReqModel->getLastQuery();
|
||||
write_custom_log("INSERT_FAILED | Atcl: $articleNumber | SQL: $sql", 'ERROR', 'failed');
|
||||
throw new \Exception("신규 등록 실패");
|
||||
}
|
||||
|
||||
$vr_sq = $this->VrfcReqModel->getInsertID();
|
||||
$this->statusService->recordStatusAndHistory($vr_sq, '10', 'C9', "신규접수 : 10");
|
||||
|
||||
return $vr_sq;
|
||||
}
|
||||
|
||||
/**
|
||||
* [MOD] 수정 처리
|
||||
*/
|
||||
private function updateVrfcReq($articleNumber, $params)
|
||||
{
|
||||
|
||||
// 1. 데이터 존재 여부 확인
|
||||
$existing = $this->VrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
|
||||
if (!$existing) {
|
||||
// [A] 데이터가 없으면 먼저 신규 등록(10) 실행
|
||||
write_custom_log("MOD_NOT_FOUND | Atcl: $articleNumber | First, Insert new data.", 'INFO', 'service');
|
||||
|
||||
$vr_sq = $this->insertVrfcReq($articleNumber, $params);
|
||||
|
||||
// 새로 등록된 정보를 다시 가져옴 (updateProcess를 태우기 위해)
|
||||
$existing = $this->VrfcReqModel->find($vr_sq);
|
||||
|
||||
// 통계 기록 (신규 등록 건으로 카운트)
|
||||
$this->V2stdailyModel->set_v2_st_daily(null, $params['cpid'], $params['vrfc_type'] . '0103', '1', 'add');
|
||||
}
|
||||
|
||||
$params['stat_cd'] = '30';
|
||||
$params['req_type'] = 'U';
|
||||
$params['insert_tm'] = db_now();
|
||||
|
||||
return $this->updateProcess($existing, $params, 'MOD', "재접수 상태변경: {$existing['stat_cd']} => 30");
|
||||
}
|
||||
|
||||
/**
|
||||
* [CNC] 취소 처리
|
||||
*/
|
||||
private function deleteVrfcReq($articleNumber, $params)
|
||||
{
|
||||
try {
|
||||
$existing = $this->findExisting($articleNumber);
|
||||
} catch (\Exception $e) {
|
||||
// 취소(CNC)하려는데 데이터가 없으면 이미 지워졌거나 오류일 수 있습니다.
|
||||
// 여기서는 로그만 남기고 종료하거나, 필요 시 Exception을 던집니다.
|
||||
throw new \Exception("CNC_NOT_FOUND | Atcl: $articleNumber WARNING service");
|
||||
}
|
||||
$params['stat_cd'] = '19';
|
||||
$params['req_type'] = 'D';
|
||||
|
||||
return $this->updateProcess($existing, $params, 'CNC', "취소 처리: {$existing['stat_cd']} => 19");
|
||||
}
|
||||
|
||||
/**
|
||||
* [FIN] 완료 처리
|
||||
*/
|
||||
private function finVrfcReq($articleNumber, $params)
|
||||
{
|
||||
try {
|
||||
$existing = $this->findExisting($articleNumber);
|
||||
} catch (\Exception $e) {
|
||||
// 완료(FIN)하려는데 데이터가 없으면 이미 지워졌거나 오류일 수 있습니다.
|
||||
// 여기서는 로그만 남기고 종료하거나, 필요 시 Exception을 던집니다.
|
||||
throw new \Exception("FIN_NOT_FOUND | Atcl: $articleNumber WARNING service");
|
||||
}
|
||||
$params['stat_cd'] = '60';
|
||||
$params['req_type'] = 'F';
|
||||
|
||||
return $this->updateProcess($existing, $params, 'FIN', "완료 처리: {$existing['stat_cd']} => 60");
|
||||
}
|
||||
|
||||
// --- 내부 공통 유틸리티 함수 ---
|
||||
|
||||
private function findExisting($articleNumber) {
|
||||
$existing = $this->VrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
if (!$existing) throw new \Exception("해당 매물 없음: $articleNumber 재등록 필요");
|
||||
return $existing;
|
||||
}
|
||||
|
||||
/**
|
||||
* 공통 업데이트 및 이력 기록 로직 (Lock 최소화)
|
||||
*/
|
||||
private function updateProcess($existing, $params, $type, $memo)
|
||||
{
|
||||
$vr_sq = $existing['vr_sq'];
|
||||
|
||||
if (!$this->VrfcReqModel->update($vr_sq, $params)) {
|
||||
$sql = (string)$this->VrfcReqModel->getLastQuery();
|
||||
write_custom_log("UPDATE_FAILED | Type: $type | vr_sq: $vr_sq | SQL: $sql", 'ERROR', 'failed');
|
||||
throw new \Exception("[$type] 업데이트 실패");
|
||||
}
|
||||
|
||||
$this->statusService->recordStatusAndHistory($vr_sq, $params['stat_cd'], 'C9', $memo);
|
||||
return $vr_sq;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API 데이터를 DB 컬럼에 맞게 변환
|
||||
*/
|
||||
private function mapToDatabaseParams(array $articleInfo, array $payload): array
|
||||
{
|
||||
$files = $articleInfo['files'] ?? [];
|
||||
$certRegister = [];
|
||||
$confirm_doc_img_url = [];
|
||||
$referenceFileUrl = [];
|
||||
$requestDatetime = date('YmdHis', strtotime($payload['requestDatetime'] ?? 'now'));
|
||||
|
||||
foreach ($files as $file) {
|
||||
$fileTypeCode = $file['fileTypeCode'];
|
||||
if ($fileTypeCode == 'RCDOC') {
|
||||
$certRegister[] = $file['fileUrl'];
|
||||
} elseif ($fileTypeCode == 'ADDOC') {
|
||||
$confirm_doc_img_url[] = $file['fileUrl'];
|
||||
} elseif ($fileTypeCode == 'REFER') {
|
||||
$referenceFileUrl[] = $file['fileUrl'];
|
||||
}
|
||||
}
|
||||
|
||||
$ownerTypeRaw = $articleInfo['seller']['ownerTypeCode'] ?? null;
|
||||
|
||||
$vrfc_params = [
|
||||
'reqSeq' => '',
|
||||
'atcl_no' => $articleInfo['articleNumber'],
|
||||
'step' => '',
|
||||
'cpid' => $articleInfo['cpId'],
|
||||
'cp_atcl_id' => $articleInfo['cpArticleNumber'],
|
||||
'trade_type' => $articleInfo['tradeTypeCode'],
|
||||
'realtor_nm' => $articleInfo['realtor']['realtorName'],
|
||||
'realtor_tel_no' => $articleInfo['realtor']['representativeCellphoneNumber'],
|
||||
'seller_tel_no' => $articleInfo['seller']['sellerTelephoneNumber'],
|
||||
'vrfc_type' => $articleInfo['verificationTypeCode'],
|
||||
'rgbk_confirm' => $articleInfo['isUnregisteredVerificationRequested'] ? 'Y' : 'N',
|
||||
'req_type' => '',
|
||||
'rdate' => $requestDatetime ?? db_now('Y-m-d H:i:s'),
|
||||
'cpTelNo' => $articleInfo['seller']['sellerTelephoneNumber'],
|
||||
'stat_cd' => '',
|
||||
'try_cnt' => '0',
|
||||
'insert_user' => '',
|
||||
'insert_tm' => db_now(),
|
||||
'memo' => '',
|
||||
'contact_fail_cnt' => '0',
|
||||
'sync_yn' => 'Y',
|
||||
'reg_try_cnt' => '0',
|
||||
'tel_fail_cause' => null,
|
||||
'rgbk_confirm_owner_nm' => $articleInfo['seller']['ownerName'] ?? null,
|
||||
'direct_trad_yn' => $articleInfo['seller']['isDirectTrade'] === true ? 'Y' : 'N',
|
||||
'confirm_doc_img_url' => empty($confirm_doc_img_url) ? null : json_encode($confirm_doc_img_url, JSON_UNESCAPED_UNICODE),
|
||||
'confirm_doc_owner_check_yn' => '',
|
||||
'owner_verifiable' => null,
|
||||
'vrfc_cmpl_type' => null,
|
||||
'rgbk_doc_img_url' => null,
|
||||
'certRegister' => empty($certRegister) ? null : json_encode($certRegister, JSON_UNESCAPED_UNICODE),
|
||||
'referenceFileUrl' => empty($referenceFileUrl) ? null : json_encode($referenceFileUrl, JSON_UNESCAPED_UNICODE),
|
||||
];
|
||||
|
||||
$articl_info_param = [
|
||||
'address_code' => $articleInfo['address']['legalDivision']['sectorNumber'] ?? '', //읍면동코드
|
||||
'address1' => $articleInfo['address']['legalDivision']['legalDivisionAddress'] ?? '', //법정도 주소
|
||||
'address2' => $articleInfo['address']['jibunAddress'] ?? '',
|
||||
'address3' => $articleInfo['address']['referenceAddress'] ?? '',
|
||||
'address4' => $articleInfo['address']['etcAddress'] ?? '',
|
||||
'sply_spc' => $articleInfo['space']['supplySpace'] ?? 0,
|
||||
'excls_spc' => $articleInfo['space']['exclusiveSpace'] ?? 0,
|
||||
'tot_spc' => $articleInfo['space']['totalSpace'] ?? 0,
|
||||
'grnd_spc' => $articleInfo['space']['groundSpace'] ?? 0,
|
||||
'bldg_spc' => $articleInfo['space']['buildingSpace'] ?? 0,
|
||||
'deal_amt' => $articleInfo['price']['dealAmount'] ?? 0, // 매매금액
|
||||
'wrrnt_amt' => $articleInfo['price']['warrantyAmount'] ?? 0, // 보증금
|
||||
'lease_amt' => $articleInfo['price']['leaseAmount'] ?? 0, // 월세가 -> 임대가
|
||||
'isale_amt' => $articleInfo['price']['preSaleAmount'] ?? 0, // 분양가
|
||||
'prem_amt' => $articleInfo['price']['premiumAmount'] ?? 0, // 프리미엄
|
||||
'sise' => null, // 매매, 전세 시세
|
||||
'floor' => $articleInfo['floor']['correspondenceFloorCount'] ?? 0, // 층 / 해당 층
|
||||
'_correspondenceFloorType' => $articleInfo['floor']['correspondenceFloorType'] ?? null, // 층 / 해당 층 타입 // 기존 없음
|
||||
'floor2' => $articleInfo['floor']['totalFloorCount'] ?? 0, // 층 / 총 층수 // 기존 없음
|
||||
'_undergroundFloorCount' => $articleInfo['floor']['undergroundFloorCount'] ?? 0, // 층 / 지하 층수 // 기존 없음
|
||||
'rdate' => $requestDatetime ?? db_now('Y-m-d H:i:s'),
|
||||
'seller_tel_no' => $articleInfo['seller']['sellerTelephoneNumber'] ?? null,
|
||||
'seller_nm' => $articleInfo['seller']['sellerName'] ?? null,
|
||||
'ownerTelNo' => $articleInfo['seller']['ownerTelephoneNumber'] ?? null, // 소유자전화번호 기존 없음
|
||||
'ownerNm' => $articleInfo['seller']['ownerName'] ?? null, // 소유자명 기존 없음
|
||||
'_isOwnerCertificationAgree' => $articleInfo['seller']['isOwnerCertificationAgree'] ?? null, // 소유자확인동의여부 기존 없음
|
||||
'direct_trad_yn' => $articleInfo['seller']['isDirectTrade'] ?? null, // 직거래여부 기존 없음
|
||||
'realtor_nm' => $articleInfo['realtor']['realtorName'] ?? null,
|
||||
'realtor_tel_no' => $articleInfo['realtor']['representativeCellphoneNumber'] ?? null,
|
||||
'_representativeTelephoneNumber' => $articleInfo['realtor']['representativeTelephoneNumber'] ?? null, // 중개사대표전화번호 기존 없음
|
||||
'hscp_no' => $articleInfo['address']['complexNumber'] ?? null,
|
||||
'hscp_nm' => $articleInfo['address']['complexName'] ?? null,
|
||||
'ptp_no' => $articleInfo['address']['pyeongTypeNumber'] ?? null,
|
||||
'ptp_nm' => null,
|
||||
'charger' => null,
|
||||
'req_price_yn' => 'N',
|
||||
'reg_charger' => null,
|
||||
'dept1_sq' => null,
|
||||
'dept2_sq' => null,
|
||||
'reg_dept2_sq' => null,
|
||||
'reg_dept1_sq' => null,
|
||||
'dong_ho_chk' => $articleInfo['address']['isDongHoChecked'] ?? null,
|
||||
'hscplqry_lv' => $articleInfo['address']['inquiryLevel'] ?? null,
|
||||
'chg_trade_type' => null,
|
||||
'chg_address2' => null,
|
||||
'chg_address3' => null,
|
||||
'chg_seller_tel' => null,
|
||||
'chg_amt' => null,
|
||||
'reg_status' => null,
|
||||
'cupnNo' => null,
|
||||
'roomSiteAtclRgstCnt' => null,
|
||||
'roomSiteAtclExpsCnt' => null,
|
||||
'redvlp_area_nm' => $articleInfo['address']['redevelopmentArea']['redevelopmentAreaName'] ?? null,
|
||||
'biz_stp_desc' => $articleInfo['address']['redevelopmentArea']['businessStep'] ?? null,
|
||||
'cert_register' => empty($certRegister) ? null : json_encode($certRegister, JSON_UNESCAPED_UNICODE),
|
||||
'confirm_doc_img_url' => empty($confirm_doc_img_url) ? null : json_encode($confirm_doc_img_url, JSON_UNESCAPED_UNICODE),
|
||||
'confirm_doc_owner_check_yn' => $articleInfo['seller']['isOwnerCertificationAgree'] === true ? 'Y' : 'N',
|
||||
'owner_birth' => $articleInfo['seller']['ownerBirthDate'] ?? null,
|
||||
'vrfc_type_sub' => null,
|
||||
'cert_register_save_yn' => '',
|
||||
'confirm_doc_img_url_save_yn' => '',
|
||||
'reference_file_url' => empty($referenceFileUrl) ? null : json_encode($referenceFileUrl, JSON_UNESCAPED_UNICODE),
|
||||
'reference_file_url_save_yn' => '',
|
||||
'reference_file_url_yn' => empty($referenceFileUrl) ? 'N' : 'Y',
|
||||
'registerBookUniqueNo' => null, // 검증 참고란
|
||||
'relationSellerAndOwner' => null, // 의뢰인과 소유주 관계
|
||||
'ownerTypeCode' => getOwnerTypeCodeNo($ownerTypeRaw) ?? null, // 소유자구분코드
|
||||
'registerBookUniqueNumber' => null, // 등기부 고유번호
|
||||
];
|
||||
|
||||
|
||||
$article_info_etc_param = [
|
||||
'corp_own' => $ownerTypeRaw == 'CORP' ? 'Y' : 'N',
|
||||
'bild_no' => null, // 건물번호
|
||||
'address2a' => $articleInfo['address']['liAddress'] ?? null, // 지번주소
|
||||
'address2b' => $articleInfo['address']['jibunAddress'] ?? null, // 도로명주소
|
||||
'expsStartYmdt' => $articleInfo['exposureStartDateTime'] ?? null,
|
||||
'vrfcAutoPassYn' => $articleInfo['isAutoVerificationRequested'] === true ? 'Y' : 'N',
|
||||
'registerBookUniqueNo' => null,
|
||||
'ownerTypeCode' => getOwnerTypeCodeNo($ownerTypeRaw) ?? null,
|
||||
'orgRepCphNo' => null,
|
||||
'orgRepTelNo' => null,// 원중개사 대표자명
|
||||
'orgRltrNm' => null, // 원중개사 대표자명
|
||||
'smsSendTime' => null, // 서류확인 내용
|
||||
'document_cert_method' => null,
|
||||
'noRgbkVrfcReqYn' => $articleInfo['isUnregisteredVerificationRequested'] === true ? 'Y' : 'N',
|
||||
'areaByBdbkVrfcReqYn' => $articleInfo['isBuildingRegisterAreaCheckRequested'] === true ? 'Y' : 'N', //건축물대장기준 면적검증요청 여부 Y / N 또는 항목미전송
|
||||
'orgAtclNo' => null, // 원매물 번호
|
||||
'atclStatCd' => null, // 매물상태코드 J1W : 공동중개 검증 원)중개사 확인 요청
|
||||
'repNm' => $articleInfo['realtor']['representativeName'] ?? null, // 원중개사 대표자명
|
||||
'cpName' => $articleInfo['realtor']['realtorName'], // 중개업소 대표자명 ?
|
||||
'document_not_received' => null,
|
||||
'final_failure' => null
|
||||
];
|
||||
|
||||
// $vrfc_params = array_merge($vrfc_params, $articl_info_param, $article_info_etc_param);
|
||||
|
||||
// 개인: INDIV => 0
|
||||
// 법인: CORP => 1
|
||||
// 외국인: FRGNR => 2
|
||||
// 위임장: DELEG => 3
|
||||
|
||||
return $vrfc_params;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
139
app/Services/ParameterMapper/BaseParameterMapper.php
Normal file
139
app/Services/ParameterMapper/BaseParameterMapper.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ParameterMapper;
|
||||
|
||||
/**
|
||||
* 파라미터 매퍼 기본 추상 클래스
|
||||
* 네이버 API 응답을 데이터베이스 파라미터로 변환하는 로직을 정의
|
||||
*/
|
||||
abstract class BaseParameterMapper
|
||||
{
|
||||
protected $db;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->db = \Config\Database::connect();
|
||||
helper('log');
|
||||
}
|
||||
|
||||
/**
|
||||
* 추상 메서드: 매핑 로직 구현
|
||||
*/
|
||||
abstract public function map(string $articleNumber, array $rawData, array $payload): array;
|
||||
|
||||
/**
|
||||
* 소유자 타입 코드 변환
|
||||
*/
|
||||
protected function mapOwnerTypeCode(?string $ownerTypeCodeRaw): ?int
|
||||
{
|
||||
return match($ownerTypeCodeRaw) {
|
||||
"INDIV" => 0,
|
||||
"CORP" => 1,
|
||||
"FRGNR" => 2,
|
||||
"DELEG" => 3,
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 거래 유형 변환
|
||||
*/
|
||||
protected function mapTradeType(?string $tradeType): ?string
|
||||
{
|
||||
return match(trim($tradeType ?? '')) {
|
||||
'매매' => 'A1',
|
||||
'전세' => 'B1',
|
||||
'월세' => 'B2',
|
||||
'단기임대' => 'B3',
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 배열 추출 (save_yn 플래그 포함)
|
||||
*/
|
||||
public function extractFilesByType(array $files): array
|
||||
{
|
||||
$certRegister = [];
|
||||
$confirmDocImgUrl = [];
|
||||
$referenceFileUrl = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$fileTypeCode = $file['fileTypeCode'] ?? '';
|
||||
$fileUrl = $file['originalFileUrl'] ?? '';
|
||||
|
||||
switch ($fileTypeCode) {
|
||||
case 'RCDOC':
|
||||
$certRegister[] = $fileUrl;
|
||||
break;
|
||||
case 'ADDOC':
|
||||
$confirmDocImgUrl[] = $fileUrl;
|
||||
break;
|
||||
case 'REFER':
|
||||
$referenceFileUrl[] = $fileUrl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'certRegister' => $certRegister,
|
||||
'confirmDocImgUrl' => $confirmDocImgUrl,
|
||||
'referenceFileUrl' => $referenceFileUrl,
|
||||
'cert_register_save_yn' => !empty($certRegister) ? 'Y' : 'N',
|
||||
'confirm_doc_img_url_save_yn' => !empty($confirmDocImgUrl) ? 'Y' : 'N',
|
||||
'reference_file_url_save_yn' => !empty($referenceFileUrl) ? 'Y' : 'N',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 URL을 v2_url_img_save 테이블에 저장
|
||||
* @param array $files 파일 배열
|
||||
* @param string $atclNo 매물번호
|
||||
* @param int $vrSq 검증요청순번
|
||||
*/
|
||||
protected function saveUrlImagesToDb(array $files, string $atclNo, int $vrSq): bool
|
||||
{
|
||||
if (empty($files)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$urlImgModel = new \App\Models\Entities\V2urlimgsaveModel();
|
||||
|
||||
foreach ($files as $file) {
|
||||
$fileTypeCode = $file['fileTypeCode'] ?? '';
|
||||
$fileUrl = $file['originalFileUrl'] ?? '';
|
||||
|
||||
if (empty($fileUrl)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// type 매핑: RCDOC, ADDOC = 2(등기), REFER = 1(홍보)
|
||||
$type = in_array($fileTypeCode, ['RCDOC', 'ADDOC']) ? '2' : '1';
|
||||
|
||||
$data = [
|
||||
'url' => $fileUrl,
|
||||
'type' => $type,
|
||||
'atcl_no' => $atclNo,
|
||||
'vr_sq' => $vrSq,
|
||||
'status' => 'save',
|
||||
'try_cnt' => 0,
|
||||
'server_nm' => gethostname(),
|
||||
];
|
||||
|
||||
if (!$urlImgModel->insert($data)) {
|
||||
write_custom_log("URL 이미지 저장 실패: " . json_encode($data), 'ERROR', 'service');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 필수 필드 안전하게 로드
|
||||
*/
|
||||
protected function getSafeData(array $data, string $key, $default = null)
|
||||
{
|
||||
return $data[$key] ?? $default;
|
||||
}
|
||||
}
|
||||
187
app/Services/ParameterMapper/TypeSParameterMapper.php
Normal file
187
app/Services/ParameterMapper/TypeSParameterMapper.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ParameterMapper;
|
||||
|
||||
use App\Models\Entities\RegionModel;
|
||||
|
||||
/**
|
||||
* Type S 파라미터 매퍼
|
||||
* 현장확인 매물 (A01 등) 데이터를 Receipt 테이블용 파라미터로 변환
|
||||
*/
|
||||
class TypeSParameterMapper extends BaseParameterMapper
|
||||
{
|
||||
private $regionModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->regionModel = new RegionModel();
|
||||
}
|
||||
/**
|
||||
* Receipt 테이블용 파라미터 생성
|
||||
*/
|
||||
public function mapReceipt(string $articleNumber, array $rawData, array $payload): array
|
||||
{
|
||||
$now = db_now();
|
||||
$address = $rawData['address'] ?? [];
|
||||
$space = $rawData['space'] ?? [];
|
||||
$price = $rawData['price'] ?? [];
|
||||
$floor = $rawData['floor'] ?? [];
|
||||
$seller = $rawData['seller'] ?? [];
|
||||
$realtor = $rawData['realtor'] ?? [];
|
||||
|
||||
// 평면도 여부 결정
|
||||
$groundPlan = in_array($rawData['realEstateTypeCode'] ?? '', ['C01', 'C02']) ? 'N' : 'Y';
|
||||
|
||||
// 거래 유형 코드 (tradeTypeCode 우선, 없으면 tradeType 한글을 변환)
|
||||
$tradeType = $rawData['tradeTypeCode'] ?? $this->mapTradeType($rawData['tradeType'] ?? null);
|
||||
|
||||
return [
|
||||
'comp_sq' => '2',
|
||||
'rcpt_rating' => '3',
|
||||
'rcpt_key' => $articleNumber,
|
||||
'rcpt_atclno' => $articleNumber,
|
||||
'rcpt_product' => $rawData['realEstateTypeCode'] ?? null,
|
||||
'rcpt_product_nm' => $rawData['realEstateType'] ?? null,
|
||||
'rcpt_product_info1' => $rawData['tradeType'] ?? null,
|
||||
'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,
|
||||
'rcpt_gugun' => $address['legalDivision']['divisionNumber'] ?? null,
|
||||
'rcpt_dong' => $address['legalDivision']['sectorNumber'] ?? null,
|
||||
'rcpt_hscp_nm' => $address['complexName'] ?? null,
|
||||
'rcpt_hscp_no' => $address['complexNumber'] ?? null,
|
||||
'rcpt_ptp_nm' => null,
|
||||
'rcpt_ptp_no' => $address['pyeongTypeNumber'] ?? null,
|
||||
'rcpt_dtl_addr' => trim(
|
||||
($address['legalDivision']['legalDivisionAddress'] ?? '') .
|
||||
($address['buildingName'] ?? '') .
|
||||
'동 ' . ($address['hoName'] ?? '') . '호'
|
||||
),
|
||||
'rcpt_etc_addr' => $address['hoName'] ?? null,
|
||||
'rcpt_floor' => $floor['correspondenceFloorCount'] ?? null,
|
||||
'rcpt_floor2' => $floor['totalFloorCount'] ?? null,
|
||||
'rcpt_exps_type' => '',
|
||||
'rcpt_exp_photo_yn' => 'Y',
|
||||
'rcpt_deal_type' => $rawData['tradeTypeCode'] ?? null,
|
||||
'trade_type' => $tradeType,
|
||||
'ground_plan' => $groundPlan,
|
||||
'excls_spce' => $space['exclusiveSpace'] ?? null,
|
||||
'sply_spc' => $space['supplySpace'] ?? null,
|
||||
'tot_spc' => $space['totalSpace'] ?? null,
|
||||
'grnd_spc' => $space['groundSpace'] ?? null,
|
||||
'bldg_spc' => $space['buildingSpace'] ?? null,
|
||||
'share_spc' => ($space['supplySpace'] ?? 0) - ($space['exclusiveSpace'] ?? 0),
|
||||
'room_cnt' => $rawData['facilities']['roomCount'] ?? null,
|
||||
'cupnNo' => $rawData['couponNumber'] ?? null,
|
||||
'roomSiteAtclRgstCnt' => $rawData['site']['monthlyRegisterCount'] ?? null,
|
||||
'roomSiteAtclExpsCnt' => $rawData['site']['monthlyExposureCount'] ?? null,
|
||||
'direct_trad_yn' => ($seller['isDirectTrade'] ?? false) ? 'Y' : 'N',
|
||||
'sellr_nm' => $seller['sellerName'] ?? null,
|
||||
'sellr_tel_no' => $seller['sellerTelephoneNumber'] ?? null,
|
||||
'rcpt_ref_addr' => $address['etcAddress'] ?? null,
|
||||
'rcpt_tm' => $now,
|
||||
'rcpt_stat' => '100000',
|
||||
'rcpt_x' => $address['longitude'] ?? null,
|
||||
'rcpt_y' => $address['latitude'] ?? null,
|
||||
'agent_id' => '',
|
||||
'agent_nm' => $realtor['realtorName'] ?? null,
|
||||
'agent_head_tel' => $realtor['representativeCellphoneNumber'] ?? null,
|
||||
'rsrv_date' => $rawData['site']['visitReserveDate'] ?? null,
|
||||
'rsrv_tm_ap' => '00',
|
||||
'insert_tm' => $now,
|
||||
'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
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Result 테이블용 파라미터 생성
|
||||
*/
|
||||
public function mapResult(int $rcptSq, array $rawData): array
|
||||
{
|
||||
$now = db_now();
|
||||
|
||||
$address = $rawData['address'] ?? [];
|
||||
$sectorNumber = $address['legalDivision']['sectorNumber'] ?? null;
|
||||
|
||||
// VR 검증 여부 확인
|
||||
$isVrVerification = ($rawData['site']['isVrVerification'] ?? false);
|
||||
|
||||
// 1. 지역별 담당자 조회
|
||||
$charge = null;
|
||||
if ($sectorNumber) {
|
||||
$charge = $this->regionModel->getChargeByRegionCd($sectorNumber);
|
||||
log_message('info', "[TypeSParameterMapper] 지역코드: {$sectorNumber}, 조회 결과: " . json_encode($charge, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
|
||||
// 2. 기본 담당자 설정 (지역별 담당자가 없으면)
|
||||
$deptSq = $charge['dept_sq'] ?? '26';
|
||||
$usrSq = $charge['usr_sq'] ?? '1';
|
||||
|
||||
// 담당자 존재 여부 검증 (users 테이블 확인)
|
||||
if ($usrSq && $usrSq !== '1') {
|
||||
$db = \Config\Database::connect();
|
||||
$userExists = $db->table('users')->where('usr_sq', $usrSq)->countAllResults() > 0;
|
||||
if (!$userExists) {
|
||||
log_message('warning', "[TypeSParameterMapper] usr_sq={$usrSq}가 users 테이블에 없음. 기본값(1)으로 폴백");
|
||||
$usrSq = '1';
|
||||
$deptSq = '26';
|
||||
}
|
||||
}
|
||||
|
||||
log_message('info', "[TypeSParameterMapper] 기본 담당자 - dept_sq: {$deptSq}, usr_sq: {$usrSq}, VR검증: " . ($isVrVerification ? 'Y' : 'N'));
|
||||
|
||||
// 3. VR 검증인 경우 환경별 담당자로 덮어쓰기
|
||||
if ($isVrVerification) {
|
||||
log_message('info', "[TypeSParameterMapper] ENVIRONMENT 상수 값: " . ENVIRONMENT);
|
||||
|
||||
if (ENVIRONMENT === 'development') {
|
||||
$deptSq = '29';
|
||||
$usrSq = '472'; // vradmin
|
||||
log_message('info', "[TypeSParameterMapper] VR 검증 (DEV) - dept_sq: {$deptSq}, usr_sq: {$usrSq}");
|
||||
} else {
|
||||
// production - TODO: 실제 프로덕션 VR 담당자로 변경 필요
|
||||
$deptSq = '29';
|
||||
$usrSq = '472'; // 임시: vradmin (프로덕션 VR 담당자 확인 후 수정)
|
||||
log_message('warning', "[TypeSParameterMapper] VR 검증 (PROD) - 프로덕션 VR 담당자 미설정, 임시 담당자 사용: usr_sq={$usrSq}");
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'rcpt_sq' => $rcptSq,
|
||||
'use_yn' => 'Y',
|
||||
'cust_nm' => '',
|
||||
'rsrv_date' => $rawData['site']['visitReserveDate'] ?? null,
|
||||
'rsrv_tm_ap' => '00',
|
||||
'result_cd1' => '10',
|
||||
'result_cd2' => '1000',
|
||||
'result_cd3' => '100000',
|
||||
'insert_tm' => $now,
|
||||
'insert_usr' => 0,
|
||||
'update_tm' => $now,
|
||||
'update_usr' => 0,
|
||||
'dept_sq' => $deptSq,
|
||||
'usr_sq' => $usrSq,
|
||||
'resYn' => ($rawData['site']['isRegistration'] ?? false) ? 'Y' : 'N',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 인터페이스 구현: 기본 map 메서드
|
||||
* (실제로는 mapReceipt와 mapResult를 분리하여 사용)
|
||||
*/
|
||||
public function map(string $articleNumber, array $rawData, array $payload): array
|
||||
{
|
||||
return $this->mapReceipt($articleNumber, $rawData, $payload);
|
||||
}
|
||||
}
|
||||
277
app/Services/ParameterMapper/TypeV2ParameterMapper.php
Normal file
277
app/Services/ParameterMapper/TypeV2ParameterMapper.php
Normal file
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\ParameterMapper;
|
||||
|
||||
/**
|
||||
* Type V2 파라미터 매퍼
|
||||
* 일반/서류/비공동 매물 데이터를 V2 테이블용 파라미터로 변환
|
||||
*/
|
||||
class TypeV2ParameterMapper extends BaseParameterMapper
|
||||
{
|
||||
/**
|
||||
* V2 검증 요청 파라미터 생성
|
||||
*/
|
||||
public function mapVrfcReq(string $articleNumber, array $rawData, array $payload): array
|
||||
{
|
||||
$now = db_now();
|
||||
$step = $rawData['step'] ?? '00';
|
||||
$rdate = date("YmdHis", strtotime($payload['requestDate'] ?? db_now('YmdHis')));
|
||||
|
||||
$files = $rawData['files'] ?? [];
|
||||
$fileExtracted = $this->extractFilesByType($files);
|
||||
|
||||
$reqType = $this->mapRequestType($payload['requestType'] ?? '');
|
||||
|
||||
return [
|
||||
'reqSeq' => '',
|
||||
'atcl_no' => $articleNumber,
|
||||
'step' => $step,
|
||||
'cpid' => $rawData['cpId'] ?? 'naver',
|
||||
'cp_atcl_id' => $rawData['cpArticleNumber'] ?? '',
|
||||
'trade_type' => $rawData['tradeTypeCode'] ?? '',
|
||||
'realtor_nm' => $rawData['realtor']['realtorName'] ?? null,
|
||||
'realtor_tel_no' => $rawData['realtor']['representativeCellphoneNumber'] ?? null,
|
||||
'seller_tel_no' => $rawData['seller']['cellphoneNumber'] ?? null,
|
||||
'vrfc_type' => $rawData['verificationTypeCode'] ?? 'D',
|
||||
'rgbk_confirm' => ($rawData['isNeedRegisterBookConfirm'] ?? false) ? 'Y' : 'N',
|
||||
'req_type' => $reqType,
|
||||
'rdate' => $rdate,
|
||||
'cpTelNo' => null,
|
||||
'stat_cd' => '10',
|
||||
'insert_user' => 0,
|
||||
'insert_tm' => $now,
|
||||
'sync_yn' => 'N',
|
||||
'rgbk_confirm_owner_nm' => null,
|
||||
'direct_trad_yn' => ($rawData['seller']['isDirectTrade'] ?? false) ? 'Y' : 'N',
|
||||
'confirm_doc_img_url' => json_encode($fileExtracted['confirmDocImgUrl']),
|
||||
'confirm_doc_owner_check_yn' => ($rawData['seller']['isOwnerCertificationAgree'] ?? false) ? 'Y' : 'N',
|
||||
'certRegister' => json_encode($fileExtracted['certRegister']),
|
||||
'referenceFileUrl' => json_encode($fileExtracted['referenceFileUrl']),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 기사 정보 파라미터 생성
|
||||
*/
|
||||
public function mapArticleInfo(string $articleNumber, array $rawData, array $payload): array
|
||||
{
|
||||
$address = $rawData['address'] ?? [];
|
||||
$space = $rawData['space'] ?? [];
|
||||
$price = $rawData['price'] ?? [];
|
||||
$floor = $rawData['floor'] ?? [];
|
||||
$seller = $rawData['seller'] ?? [];
|
||||
$realtor = $rawData['realtor'] ?? [];
|
||||
|
||||
$files = $rawData['files'] ?? [];
|
||||
$fileExtracted = $this->extractFilesByType($files);
|
||||
|
||||
$ownerTypeCode = $this->mapOwnerTypeCode($rawData['ownerTypeCode'] ?? null);
|
||||
$ownerCheckYn = ($seller['isOwnerCertificationAgree'] ?? false) ? 'Y' : 'N';
|
||||
|
||||
$vrfcTypeSub = $this->mapVrfcTypeSub($rawData['verificationTypeCode'] ?? '', $ownerCheckYn);
|
||||
|
||||
return [
|
||||
'atcl_no' => $articleNumber,
|
||||
'cpid' => $rawData['cpId'] ?? null,
|
||||
'cp_atcl_id' => $rawData['cpArticleNumber'] ?? null,
|
||||
'rlet_type_cd' => $rawData['realEstateTypeCode'] ?? null,
|
||||
'trade_type' => $rawData['tradeTypeCode'] ?? null,
|
||||
'address_code' => $address['legalDivision']['sectorNumber'] ?? null,
|
||||
'address1' => $address['complexName'] ?? null,
|
||||
'address2' => trim(($address['buildingName'] ?? '') . ' ' . ($address['hoName'] ?? '')),
|
||||
'address3' => $address['legalDivision']['legalDivisionAddress'] ?? null,
|
||||
'sply_spc' => $space['supplySpace'] ?? null,
|
||||
'excls_spc' => $space['exclusiveSpace'] ?? null,
|
||||
'tot_spc' => $space['totalSpace'] ?? null,
|
||||
'grnd_spc' => $space['groundSpace'] ?? null,
|
||||
'bldg_spc' => $space['buildingSpace'] ?? null,
|
||||
'deal_amt' => $price['dealAmount'] ?? 0,
|
||||
'wrrnt_amt' => $price['warrantyAmount'] ?? 0,
|
||||
'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,
|
||||
'rdate' => date("Y-m-d H:i:s", strtotime($payload['requestDatetime'] ?? 'now')),
|
||||
'seller_tel_no' => $seller['sellerTelephoneNumber'] ?? null,
|
||||
'seller_nm' => $seller['sellerName'] ?? null,
|
||||
'realtor_nm' => $realtor['realtorName'] ?? null,
|
||||
'realtor_tel_no' => $realtor['representativeTelephoneNumber'] ?? null,
|
||||
'hscp_no' => $address['complexNumber'] ?? null,
|
||||
'hscp_nm' => $address['complexName'] ?? null,
|
||||
'ptp_no' => $address['pyeongTypeNumber'] ?? null,
|
||||
'ptp_nm' => $address['pyeongTypeNumber'] ?? null,
|
||||
'charger' => null,
|
||||
'req_price_yn' => 'N',
|
||||
'reg_charger' => null,
|
||||
'dept1_sq' => null,
|
||||
'dept2_sq' => null,
|
||||
'reg_dept2_sq' => null,
|
||||
'reg_dept1_sq' => null,
|
||||
'dong_ho_chk' => ($address['isDongHoCheck'] ?? false) ? 'Y' : 'N',
|
||||
'hscplqry_lv' => $address['inquiryLevel'] ?? null,
|
||||
'ownerNm' => $seller['ownerName'] ?? null,
|
||||
'ownerTelNo' => $seller['ownerTelephoneNumber'] ?? null,
|
||||
'chg_trade_type' => null,
|
||||
'chg_address2' => null,
|
||||
'chg_address3' => null,
|
||||
'chg_seller_tel' => null,
|
||||
'chg_amt' => null,
|
||||
'reg_status' => null,
|
||||
'cupnNo' => null,
|
||||
'roomSiteAtclRgstCnt' => null,
|
||||
'roomSiteAtclExpsCnt' => null,
|
||||
'redvlp_area_nm' => $address['redevelopAreaName'] ?? null,
|
||||
'biz_stp_desc' => $address['bizStepDescription'] ?? null,
|
||||
'cert_register' => json_encode($fileExtracted['certRegister'], JSON_UNESCAPED_UNICODE),
|
||||
'direct_trad_yn' => ($seller['isDirectTrade'] ?? false) ? 'Y' : 'N',
|
||||
'confirm_doc_img_url' => json_encode($fileExtracted['confirmDocImgUrl'], JSON_UNESCAPED_UNICODE),
|
||||
'confirm_doc_owner_check_yn' => $ownerCheckYn,
|
||||
'owner_birth' => null,
|
||||
'vrfc_type_sub' => $vrfcTypeSub,
|
||||
'cert_register_save_yn' => $fileExtracted['cert_register_save_yn'] ?? 'N',
|
||||
'confirm_doc_img_url_save_yn' => $fileExtracted['confirm_doc_img_url_save_yn'] ?? 'N',
|
||||
'address4' => $address['etcAddress'] ?? null,
|
||||
'reference_file_url' => !empty($fileExtracted['referenceFileUrl']) ? implode('|', $fileExtracted['referenceFileUrl']) : '',
|
||||
'reference_file_url_save_yn' => $fileExtracted['reference_file_url_save_yn'] ?? 'N',
|
||||
'registerBookUniqueNo' => $rawData['verificationReference'] ?? null,
|
||||
'relationSellerAndOwner' => null,
|
||||
'ownerTypeCode' => $ownerTypeCode,
|
||||
'registerBookUniqueNumber' => null
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 기사 정보 추가 파라미터 생성
|
||||
*/
|
||||
public function mapArticleInfoEtc(string $articleNumber, array $rawData): array
|
||||
{
|
||||
$address = $rawData['address'] ?? [];
|
||||
$realtor = $rawData['realtor'] ?? [];
|
||||
|
||||
// 공동주택: 동 정보, 비공동: 지번주소
|
||||
$address2b = ($rawData['realEstateTypeCode'] === 'A01')
|
||||
? $address['buildingName']
|
||||
: ($address['jibunAddress'] ?? null);
|
||||
|
||||
$ownerTypeCode = $this->mapOwnerTypeCode($rawData['ownerTypeCode'] ?? null);
|
||||
|
||||
return [
|
||||
'atcl_no' => $articleNumber,
|
||||
'vir_addr_yn' => $this->mapYesNo($address['isVirtualAddress'] ?? null),
|
||||
'bild_no' => null,
|
||||
'vrfcMthdTpcd' => null,
|
||||
'cert_uncnfrm_status' => null,
|
||||
'expsStartYmdt' => $rawData['exposureStartDateTime'] ?? null,
|
||||
'vrfcAutoPassYn' => ($rawData['isAutoVerificationRequested'] ?? false) ? 'Y' : 'N',
|
||||
'address2a' => $address['liAddress'] ?? null,
|
||||
'address2b' => $address2b,
|
||||
'registerBookUniqueNo' => null,
|
||||
'ownerTypeCode' => $ownerTypeCode,
|
||||
'orgRepCphNo' => null,
|
||||
'orgRepTelNo' => null,
|
||||
'orgRltrNm' => null,
|
||||
'orgRepNm' => null,
|
||||
'smsSendTime' => null,
|
||||
'document_cert_method' => null,
|
||||
'noRgbkVrfcReqYn' => $this->mapYesNo($address['isUnregisteredVerificationRequested'] ?? null),
|
||||
'areaByBdbkVrfcReqYn' => $this->mapYesNo($address['isBuildingRegisterAreaCheckRequested'] ?? null),
|
||||
'orgAtclNo' => null,
|
||||
'atclStatCd' => null,
|
||||
'repNm' => $realtor['realtorName'] ?? null,
|
||||
'cpName' => $rawData['cpId'],
|
||||
'document_not_received' => null,
|
||||
'final_failure' => null,
|
||||
];
|
||||
}
|
||||
/**
|
||||
* modify_info 파라미터 생성
|
||||
*/
|
||||
public function mapModifyInfo(string $articleNumber, array $rawData, array $payload): array
|
||||
{
|
||||
$address = $rawData['address'] ?? [];
|
||||
$space = $rawData['space'] ?? [];
|
||||
$price = $rawData['price'] ?? [];
|
||||
$floor = $rawData['floor'] ?? [];
|
||||
|
||||
// 공동주택: 동 정보, 비공동: 지번주소
|
||||
$address2b = ($rawData['realEstateTypeCode'] === 'A01')
|
||||
? $address['buildingName']
|
||||
: ($address['jibunAddress'] ?? null);
|
||||
|
||||
return [
|
||||
// 'atcl_no' => $articleNumber,
|
||||
'bild_nm' => $address['buildingName'] ?? null,
|
||||
'rm_no' => $address['hoName'] ?? null,
|
||||
'floor' => $floor['correspondenceFloorCount'] ?? null,
|
||||
'floor2' => $floor['totalFloorCount'] ?? null,
|
||||
'address_code' => $address['legalDivision']['sectorNumber'] ?? null,
|
||||
'address2' => trim(($address['buildingName'] ?? '') . ' ' . ($address['hoName'] ?? '')),
|
||||
'address2a' => $address['liAddress'] ?? null,
|
||||
'address2b' => $address2b,
|
||||
'address3' => $address['legalDivision']['legalDivisionAddress'] ?? null,
|
||||
'address4' => $address['etcAddress'] ?? null,
|
||||
'trade_type' => $rawData['tradeTypeCode'] ?? null,
|
||||
'deal_amt' => $price['dealAmount'] ?? 0,
|
||||
'wrrnt_amt' => $price['warrantyAmount'] ?? 0,
|
||||
'lease_amt' => $price['leaseAmount'] ?? 0,
|
||||
'isale_amt' => $price['preSaleAmount'] ?? 0,
|
||||
'prem_amt' => $price['premiumAmount'] ?? 0,
|
||||
'sply_spc' => $space['supplySpace'] ?? null,
|
||||
'excls_spc' => $space['exclusiveSpace'] ?? null,
|
||||
'tot_spc' => $space['totalSpace'] ?? null,
|
||||
'grnd_spc' => $space['groundSpace'] ?? null,
|
||||
'bldg_spc' => $space['buildingSpace'] ?? null,
|
||||
'hscp_no' => $address['complexNumber'] ?? null,
|
||||
'hscp_nm' => $address['complexName'] ?? null,
|
||||
'ptp_no' => $address['pyeongTypeNumber'] ?? null,
|
||||
'ptp_nm' => $address['pyeongTypeNumber'] ?? null,
|
||||
'modify_yn' => 'N'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 인터페이스 구현
|
||||
*/
|
||||
public function map(string $articleNumber, array $rawData, array $payload): array
|
||||
{
|
||||
return $this->mapVrfcReq($articleNumber, $rawData, $payload);
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청 타입 매핑
|
||||
*/
|
||||
private function mapRequestType(string $requestType): string
|
||||
{
|
||||
return match($requestType) {
|
||||
'REG' => 'C',
|
||||
'MOD' => 'U',
|
||||
'CNC' => 'D',
|
||||
default => '0',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 검증 타입 세부 매핑
|
||||
*/
|
||||
private function mapVrfcTypeSub(string $vrfcType, string $ownerCheckYn): string
|
||||
{
|
||||
return match($vrfcType) {
|
||||
'D' => $ownerCheckYn === 'Y' ? 'D2' : 'D1',
|
||||
'N' => 'N2',
|
||||
default => $vrfcType . '1',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* boolean을 Y/N으로 변환
|
||||
*/
|
||||
private function mapYesNo($value): ?string
|
||||
{
|
||||
if ($value === true) return 'Y';
|
||||
if ($value === false) return 'N';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ class StatusService
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->V2chgstatModel = model(V2chgstatModel::class);
|
||||
$this->V2chghistoryModel = model(V2chghistoryModel::class);
|
||||
// $this->V2chgstatModel = model(V2chgstatModel::class);
|
||||
// $this->V2chghistoryModel = model(V2chghistoryModel::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,22 +20,24 @@ class StatusService
|
||||
*/
|
||||
public function recordStatusAndHistory($vr_sq, $stat_cd, $chg_type, $memo)
|
||||
{
|
||||
$statModel = model(V2chgstatModel::class);
|
||||
$histModel = model(V2chghistoryModel::class);
|
||||
// 1. 상태(stat) 저장 (Insert or Update)
|
||||
try {
|
||||
$this->V2chgstatModel->saveChgstat([
|
||||
$statModel->saveChgstat([
|
||||
'vr_sq' => $vr_sq,
|
||||
'stat_cd' => $stat_cd,
|
||||
'insert_user' => '0',
|
||||
'insert_tm' => db_now()
|
||||
], 'I');
|
||||
} catch (\Exception $e) {
|
||||
$lastSql = (string)$this->V2chgstatModel->getLastQuery();
|
||||
$lastSql = (string)$statModel->getLastQuery();
|
||||
write_custom_log("STAT_SAVE_ERR | vr_sq: $vr_sq | SQL: $lastSql | Msg: " . $e->getMessage(), 'ERROR', 'failed');
|
||||
}
|
||||
|
||||
// 2. 이력(history) 저장
|
||||
try {
|
||||
$this->V2chghistoryModel->v2_savehistory([
|
||||
$histModel->v2_savehistory([
|
||||
'vr_sq' => $vr_sq,
|
||||
'stat_cd' => $stat_cd,
|
||||
'chg_type' => $chg_type,
|
||||
@@ -44,7 +46,7 @@ class StatusService
|
||||
'insert_tm' => db_now()
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
$lastSql = (string)$this->V2chghistoryModel->getLastQuery();
|
||||
$lastSql = (string)$histModel->getLastQuery();
|
||||
write_custom_log("HIST_SAVE_ERR | vr_sq: $vr_sq | SQL: $lastSql | Msg: " . $e->getMessage(), 'ERROR', 'failed');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,3 +55,5 @@
|
||||
|
||||
<link href="/architectui/assets/styles/vendors.98288b227c064e6a107f.css" rel="stylesheet">
|
||||
<link href="/architectui/assets/styles/main.98288b227c064e6a107f.css" rel="stylesheet">
|
||||
<link href="/architectui/assets/styles/custom.css" rel="stylesheet">
|
||||
<link href="/common/css/custom.css" rel="stylesheet">
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
<head>
|
||||
<?= $this->include('layouts/header') ?>
|
||||
<?= $this->renderSection('page_styles') ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -148,6 +149,8 @@
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?= $this->renderSection('page_scripts') ?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
2
app/Views/layouts/partials/datatables_bs5_css.php
Normal file
2
app/Views/layouts/partials/datatables_bs5_css.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.0.7/css/dataTables.bootstrap5.min.css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
3
app/Views/layouts/partials/datatables_bs5_js.php
Normal file
3
app/Views/layouts/partials/datatables_bs5_js.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<script src="https://cdn.datatables.net/2.0.7/js/dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/2.0.7/js/dataTables.bootstrap5.min.js"></script>
|
||||
<script defer src="/architectui/assets/js/datatable.kor.js"></script>
|
||||
2
app/Views/layouts/partials/datatables_css.php
Normal file
2
app/Views/layouts/partials/datatables_css.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/2.0.7/css/dataTables.dataTables.min.css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
2
app/Views/layouts/partials/datatables_js.php
Normal file
2
app/Views/layouts/partials/datatables_js.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<script src="https://cdn.datatables.net/2.0.7/js/dataTables.min.js"></script>
|
||||
<script defer src="/architectui/assets/js/datatable.kor.js"></script>
|
||||
67
app/Views/layouts/partials/datatables_v2_layout_helpers.php
Normal file
67
app/Views/layouts/partials/datatables_v2_layout_helpers.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<script type="text/javascript">
|
||||
/**
|
||||
* DataTables v2 layout topEnd 버튼 헬퍼
|
||||
* @param {Object} options - 옵션 객체
|
||||
* @param {boolean} options.showSendButton - 등기부등본 전송 버튼 표시 여부 (기본값: false)
|
||||
* @param {string} options.sendButtonText - 전송 버튼 텍스트
|
||||
* @param {boolean} options.showExcelButton - 엑셀 버튼 표시 여부 (기본값: true)
|
||||
* @param {string} options.excelButtonId - 엑셀 버튼 id
|
||||
* @param {string} options.excelButtonClass - 엑셀 버튼 class
|
||||
* @param {string} options.excelButtonHtml - 엑셀 버튼 innerHTML
|
||||
* @returns {Function} DataTable layout.topEnd 콜백 함수
|
||||
*/
|
||||
function v2TopEndButtons(options) {
|
||||
const opts = options || {};
|
||||
|
||||
return function () {
|
||||
const container = document.createElement('div');
|
||||
container.className = 'd-flex';
|
||||
container.style.gap = '8px';
|
||||
container.style.justifyContent = 'flex-end';
|
||||
|
||||
if (opts.showSendButton === true) {
|
||||
const btnSend = document.createElement('button');
|
||||
btnSend.className = 'btn btn-sm btn-outline-light';
|
||||
btnSend.textContent = opts.sendButtonText || '등기부등본 전송';
|
||||
container.append(btnSend);
|
||||
}
|
||||
|
||||
if (opts.showExcelButton !== false) {
|
||||
const btnExcel = document.createElement('button');
|
||||
btnExcel.id = opts.excelButtonId || 'excel-download';
|
||||
btnExcel.className = opts.excelButtonClass || 'btn btn-sm btn-outline-success';
|
||||
btnExcel.innerHTML = opts.excelButtonHtml || '<i class="fa fa-fw fa-file-excel-o" aria-hidden="true"></i> 엑셀다운로드';
|
||||
container.append(btnExcel);
|
||||
}
|
||||
|
||||
return container;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* DataTables v2 layout bottomStart/bottomEnd 통합 설정
|
||||
* @param {Object} options - 옵션 객체
|
||||
* @param {boolean} options.hasPageLength - pageLength 표시 여부 (기본값: true)
|
||||
* @param {boolean} options.hasInfo - info 표시 여부 (기본값: true)
|
||||
* @returns {Object} { bottomStart, bottomEnd } 객체
|
||||
*/
|
||||
function v2BottomLayout(options) {
|
||||
const opts = options || {};
|
||||
const hasPageLength = opts.hasPageLength !== false;
|
||||
const hasInfo = opts.hasInfo !== false;
|
||||
|
||||
const config = {};
|
||||
|
||||
if (hasPageLength && hasInfo) {
|
||||
config.bottomStart = ['pageLength', 'info'];
|
||||
} else if (hasPageLength) {
|
||||
config.bottomStart = 'pageLength';
|
||||
} else if (hasInfo) {
|
||||
config.bottomStart = 'info';
|
||||
}
|
||||
|
||||
config.bottomEnd = 'paging';
|
||||
|
||||
return config;
|
||||
}
|
||||
</script>
|
||||
@@ -39,13 +39,13 @@
|
||||
$serverIp = $_SERVER['SERVER_ADDR'] ?? '';
|
||||
|
||||
// 개발 서버
|
||||
$devServers = ['192.168.200.8', '192.168.10.231'];
|
||||
$devServers = ['192.168.200.8', '192.168.10.231', '172.18.0.5'];
|
||||
|
||||
// 도커 테스트 서버
|
||||
$dockerServers = ['172.18.0.2'];
|
||||
|
||||
// 테스트 서버
|
||||
$testServers = ['192.168.200.9', '192.168.10.237', '175.126.191.182'];
|
||||
$testServers = ['192.168.200.9', '192.168.10.237', '175.126.191.182', '192.168.10.243'];
|
||||
|
||||
// 운영 서버 IP 매핑
|
||||
$prodServers = [
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
if (in_array($serverIp, $devServers, true)) {
|
||||
// 개발
|
||||
echo "<img src='/img/gnb_dev_00.png' alt='' />";
|
||||
echo "개발";
|
||||
|
||||
} elseif (in_array($serverIp, $dockerServers, true)) {
|
||||
// 도커
|
||||
@@ -80,8 +80,6 @@
|
||||
|
||||
echo "{$serverName}";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</li>
|
||||
@@ -101,6 +99,15 @@
|
||||
// 3. 끝 슬래시 정리
|
||||
$path = rtrim($path, '/');
|
||||
switch ($path) {
|
||||
case "/article/receipt/detail":
|
||||
$path = "/article/receipt/lists";
|
||||
break;
|
||||
case "/article/dept/detail":
|
||||
$path = "/article/dept/lists";
|
||||
break;
|
||||
case "/article/record/detail":
|
||||
$path = "/article/record/lists";
|
||||
break;
|
||||
case "/board/notice/write":
|
||||
case "/board/notice/modify":
|
||||
case "/board/notice/detail":
|
||||
|
||||
@@ -21,12 +21,12 @@
|
||||
<div class="modal-body">
|
||||
|
||||
<!-- 규칙 박스 -->
|
||||
<div class="border rounded-3 p-3 mb-3 bg-light">
|
||||
<div class="border rounded-3 p-3 mb-3">
|
||||
<fieldset class="mb-0">
|
||||
<legend class="fs-6 fw-semibold mb-2">컨펌스 시스템 비밀번호 작성규칙</legend>
|
||||
<ul class="mb-0 ps-3">
|
||||
<li class="mb-2">
|
||||
<div class="fw-semibold">- 최소길이</div>
|
||||
<div class="fw-semibold">최소길이</div>
|
||||
<div class="text-muted small">
|
||||
최소 8자리 이상 : 영어 대문자, 소문자, 숫자, 특수문자 중 최소 2종류 조합
|
||||
</div>
|
||||
|
||||
410
app/Views/manage/worker_log/failed_list.php
Normal file
410
app/Views/manage/worker_log/failed_list.php
Normal file
@@ -0,0 +1,410 @@
|
||||
<?= $this->extend('layouts/main') ?>
|
||||
|
||||
<?= $this->section('page_styles') ?>
|
||||
<style>
|
||||
.stats-card {
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
.stats-card h3 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
.stats-card .number {
|
||||
font-size: 32px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
.stats-card.total { background: #f8f9fa; border-left: 4px solid #6c757d; }
|
||||
.stats-card.retryable { background: #d1ecf1; border-left: 4px solid #17a2b8; }
|
||||
.stats-card.exhausted { background: #f8d7da; border-left: 4px solid #dc3545; }
|
||||
|
||||
.error-type-badge {
|
||||
display: inline-block;
|
||||
padding: 4px 12px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.severity-high { background: #dc3545; color: white; }
|
||||
.severity-medium { background: #ffc107; color: #000; }
|
||||
.severity-low { background: #28a745; color: white; }
|
||||
|
||||
.solution-box {
|
||||
background: #e7f3ff;
|
||||
border-left: 4px solid #007bff;
|
||||
padding: 15px;
|
||||
margin-top: 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.solution-box h5 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #004085;
|
||||
}
|
||||
.solution-box ul {
|
||||
margin: 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.log-table {
|
||||
font-size: 13px;
|
||||
}
|
||||
.log-table th {
|
||||
background: #f8f9fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
.log-table .error-msg {
|
||||
max-width: 300px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
.log-table .error-msg:hover {
|
||||
overflow: visible;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.badge-retry-count {
|
||||
background: #6c757d;
|
||||
color: white;
|
||||
padding: 2px 8px;
|
||||
border-radius: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.btn-retry-selected {
|
||||
position: sticky;
|
||||
top: 20px;
|
||||
z-index: 100;
|
||||
}
|
||||
</style>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
<div class="app-page-title">
|
||||
<div class="page-title-wrapper">
|
||||
<div class="page-title-heading">
|
||||
<div class="page-title-icon">
|
||||
<i class="pe-7s-attention icon-gradient bg-mean-fruit"></i>
|
||||
</div>
|
||||
<div>
|
||||
Worker 실패 로그 관리
|
||||
<div class="page-title-subheading">
|
||||
처리 실패한 작업을 분석하고 재처리합니다.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 통계 카드 -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-4">
|
||||
<div class="stats-card total">
|
||||
<h3>전체 실패 건수</h3>
|
||||
<p class="number"><?= number_format($stats['total_fail']) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="stats-card retryable">
|
||||
<h3>재시도 가능</h3>
|
||||
<p class="number"><?= number_format($stats['retry_available']) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="stats-card exhausted">
|
||||
<h3>재시도 횟수 초과</h3>
|
||||
<p class="number"><?= number_format($stats['retry_exhausted']) ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 오류 유형별 분석 -->
|
||||
<div class="main-card mb-3 card">
|
||||
<div class="card-header">오류 유형별 분석</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<?php foreach ($errorTypes as $key => $type): ?>
|
||||
<?php if ($type['count'] > 0): ?>
|
||||
<div class="col-md-4 mb-3">
|
||||
<span class="error-type-badge severity-<?= $type['severity'] ?>">
|
||||
<?= $type['label'] ?>
|
||||
</span>
|
||||
<strong><?= number_format($type['count']) ?>건</strong>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 실패 로그 목록 -->
|
||||
<div class="main-card mb-3 card">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<span>최근 실패 로그 (50건)</span>
|
||||
<button class="btn btn-primary btn-sm" id="retrySelected" disabled>
|
||||
<i class="fa fa-refresh"></i> 선택 항목 재처리
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover log-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="40">
|
||||
<input type="checkbox" id="selectAll">
|
||||
</th>
|
||||
<th width="80">ID</th>
|
||||
<th width="120">매물번호</th>
|
||||
<th width="100">오류 유형</th>
|
||||
<th>오류 메시지</th>
|
||||
<th width="80">재시도</th>
|
||||
<th width="150">발생시각</th>
|
||||
<th width="100">액션</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($logs as $log): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php if ($log['can_retry']): ?>
|
||||
<input type="checkbox" class="log-checkbox" value="<?= $log['seq'] ?>">
|
||||
<?php else: ?>
|
||||
<i class="fa fa-ban text-muted" title="재시도 불가"></i>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= $log['seq'] ?></td>
|
||||
<td><?= $log['atcl_no'] ?? '-' ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$typeInfo = $errorTypes[$log['error_type']] ?? ['label' => '기타', 'severity' => 'low'];
|
||||
?>
|
||||
<span class="error-type-badge severity-<?= $typeInfo['severity'] ?>">
|
||||
<?= $typeInfo['label'] ?>
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="error-msg" title="<?= esc($log['error_msg']) ?>">
|
||||
<?= esc($log['error_msg']) ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?php if ($log['retry_cnt'] > 0): ?>
|
||||
<span class="badge-retry-count"><?= $log['retry_cnt'] ?>회</span>
|
||||
<?php else: ?>
|
||||
-
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?= date('m-d H:i', strtotime($log['created_at'])) ?></td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-info view-detail" data-id="<?= $log['seq'] ?>">
|
||||
상세
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($logs)): ?>
|
||||
<tr>
|
||||
<td colspan="8" class="text-center text-muted py-4">
|
||||
실패한 로그가 없습니다.
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('modals') ?>
|
||||
<!-- 상세 모달 -->
|
||||
<div class="modal fade" id="detailModal" tabindex="-1">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">로그 상세 정보</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body" id="detailContent">
|
||||
<div class="text-center py-4">
|
||||
<div class="spinner-border" role="status"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">닫기</button>
|
||||
<button type="button" class="btn btn-primary" id="retryOne" style="display:none;">
|
||||
<i class="fa fa-refresh"></i> 재처리
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
|
||||
<?= $this->section('page_scripts') ?>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// 전체 선택
|
||||
$('#selectAll').on('change', function() {
|
||||
$('.log-checkbox').prop('checked', this.checked);
|
||||
updateRetryButton();
|
||||
});
|
||||
|
||||
// 개별 선택
|
||||
$('.log-checkbox').on('change', function() {
|
||||
updateRetryButton();
|
||||
});
|
||||
|
||||
// 재처리 버튼 활성화/비활성화
|
||||
function updateRetryButton() {
|
||||
const checked = $('.log-checkbox:checked').length;
|
||||
$('#retrySelected').prop('disabled', checked === 0);
|
||||
}
|
||||
|
||||
// 선택 항목 재처리
|
||||
$('#retrySelected').on('click', function() {
|
||||
const logIds = $('.log-checkbox:checked').map(function() {
|
||||
return $(this).val();
|
||||
}).get();
|
||||
|
||||
if (logIds.length === 0) {
|
||||
Swal.fire('알림', '재처리할 항목을 선택해주세요.', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: '재처리 확인',
|
||||
text: `선택한 ${logIds.length}건을 재처리하시겠습니까?`,
|
||||
icon: 'question',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: '재처리',
|
||||
cancelButtonText: '취소'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
retryLogs(logIds);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 재처리 실행
|
||||
function retryLogs(logIds) {
|
||||
const btn = $('#retrySelected');
|
||||
btn.prop('disabled', true).html('<i class="fa fa-spinner fa-spin"></i> 처리 중...');
|
||||
|
||||
$.ajax({
|
||||
url: '<?= base_url('manage/worker/retry') ?>',
|
||||
method: 'POST',
|
||||
data: { log_ids: logIds },
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
const results = response.results;
|
||||
let message = `성공: ${results.success}건, 실패: ${results.fail}건\n\n`;
|
||||
|
||||
results.details.forEach(detail => {
|
||||
const icon = detail.status === 'success' ? '✅' :
|
||||
detail.status === 'skip' ? '⏭' : '❌';
|
||||
message += `${icon} [${detail.atcl_no}] ${detail.message}\n`;
|
||||
});
|
||||
|
||||
Swal.fire({
|
||||
title: '재처리 완료',
|
||||
text: message,
|
||||
icon: results.success > 0 ? 'success' : 'warning',
|
||||
preConfirm: () => location.reload()
|
||||
});
|
||||
} else {
|
||||
Swal.fire('오류', response.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire('오류', '재처리 중 오류가 발생했습니다.', 'error');
|
||||
},
|
||||
complete: function() {
|
||||
btn.prop('disabled', false).html('<i class="fa fa-refresh"></i> 선택 항목 재처리');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 상세 보기
|
||||
$('.view-detail').on('click', function() {
|
||||
const logId = $(this).data('id');
|
||||
$('#detailContent').html('<div class="text-center py-4"><div class="spinner-border"></div></div>');
|
||||
$('#detailModal').modal('show');
|
||||
|
||||
$.ajax({
|
||||
url: `<?= base_url('manage/worker/detail') ?>/${logId}`,
|
||||
method: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
displayDetail(response.log);
|
||||
} else {
|
||||
$('#detailContent').html('<div class="alert alert-danger">' + response.message + '</div>');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$('#detailContent').html('<div class="alert alert-danger">로그를 불러오는 중 오류가 발생했습니다.</div>');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 상세 정보 표시
|
||||
function displayDetail(log) {
|
||||
const solution = log.solution;
|
||||
const errorType = log.error_type;
|
||||
|
||||
let html = `
|
||||
<div class="mb-3">
|
||||
<strong>로그 ID:</strong> ${log.seq}<br>
|
||||
<strong>매물번호:</strong> ${log.atcl_no || '-'}<br>
|
||||
<strong>상태:</strong> <span class="badge badge-danger">${log.status}</span><br>
|
||||
<strong>재시도 횟수:</strong> ${log.retry_cnt || 0}회<br>
|
||||
<strong>발생시각:</strong> ${log.created_at}
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<strong>오류 메시지:</strong>
|
||||
<div class="alert alert-danger">${log.error_msg}</div>
|
||||
</div>
|
||||
|
||||
<div class="solution-box mb-3">
|
||||
<h5>${solution.title}</h5>
|
||||
<ul>
|
||||
${solution.steps.map(step => `<li>${step}</li>`).join('')}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<strong>원본 Payload:</strong>
|
||||
<pre class="bg-light p-3" style="max-height: 300px; overflow-y: auto;">${JSON.stringify(log.parsed_payload, null, 2)}</pre>
|
||||
</div>
|
||||
`;
|
||||
|
||||
$('#detailContent').html(html);
|
||||
|
||||
// 재처리 버튼 표시
|
||||
if (log.can_retry) {
|
||||
$('#retryOne').show().off('click').on('click', function() {
|
||||
$('#detailModal').modal('hide');
|
||||
retryLogs([log.seq]);
|
||||
});
|
||||
} else {
|
||||
$('#retryOne').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?= $this->endSection() ?>
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user