result 입력시 usr_sq dept_sq 를 region_codes 에서 가져오는 로직 넣기
This commit is contained in:
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,20 @@
|
|||||||
|
|
||||||
namespace App\Services\ParameterMapper;
|
namespace App\Services\ParameterMapper;
|
||||||
|
|
||||||
|
use App\Models\Entities\RegionModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type S 파라미터 매퍼
|
* Type S 파라미터 매퍼
|
||||||
* 현장확인 매물 (A01 등) 데이터를 Receipt 테이블용 파라미터로 변환
|
* 현장확인 매물 (A01 등) 데이터를 Receipt 테이블용 파라미터로 변환
|
||||||
*/
|
*/
|
||||||
class TypeSParameterMapper extends BaseParameterMapper
|
class TypeSParameterMapper extends BaseParameterMapper
|
||||||
{
|
{
|
||||||
|
private $regionModel;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->regionModel = new RegionModel();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Receipt 테이블용 파라미터 생성
|
* Receipt 테이블용 파라미터 생성
|
||||||
*/
|
*/
|
||||||
@@ -97,9 +105,33 @@ class TypeSParameterMapper extends BaseParameterMapper
|
|||||||
{
|
{
|
||||||
$now = db_now();
|
$now = db_now();
|
||||||
|
|
||||||
// VR 검증 여부에 따른 담당자 설정
|
$address = $rawData['address'] ?? [];
|
||||||
$deptSq = ($rawData['site']['isVrVerification'] ?? false) ? '29' : null;
|
$sectorNumber = $address['legalDivision']['sectorNumber'] ?? null;
|
||||||
$usrSq = ($rawData['site']['isVrVerification'] ?? false) ? '1993' : null;
|
|
||||||
|
// VR 검증 여부 확인
|
||||||
|
$isVrVerification = ($rawData['site']['isVrVerification'] ?? false);
|
||||||
|
|
||||||
|
// 1. 지역별 담당자 조회
|
||||||
|
$charge = null;
|
||||||
|
if ($sectorNumber) {
|
||||||
|
$charge = $this->regionModel->getChargeByRegionCd($sectorNumber);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 기본 담당자 설정 (지역별 담당자가 없으면)
|
||||||
|
$deptSq = $charge['dept_sq'] ?? '26';
|
||||||
|
$usrSq = $charge['usr_sq'] ?? '1';
|
||||||
|
|
||||||
|
// 3. VR 검증인 경우 환경별 담당자로 덮어쓰기
|
||||||
|
if ($isVrVerification) {
|
||||||
|
if (ENVIRONMENT === 'development') {
|
||||||
|
$deptSq = '29';
|
||||||
|
$usrSq = '472';
|
||||||
|
} else {
|
||||||
|
// production
|
||||||
|
$deptSq = '33';
|
||||||
|
$usrSq = '1993';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'rcpt_sq' => $rcptSq,
|
'rcpt_sq' => $rcptSq,
|
||||||
|
|||||||
Reference in New Issue
Block a user