수정
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -46,9 +46,11 @@ class TypeV2Handler
|
||||
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':
|
||||
@@ -62,7 +64,9 @@ class TypeV2Handler
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
write_custom_log("Type V2 처리 실패: " . $e->getMessage(), 'ERROR', 'service');
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -136,7 +140,9 @@ class TypeV2Handler
|
||||
// 기존 검증 요청 확인
|
||||
$existing = $this->vrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
if (!$existing) {
|
||||
throw new Exception("수정할 기존 데이터가 없습니다. Atcl: $articleNumber");
|
||||
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'];
|
||||
@@ -199,7 +205,9 @@ class TypeV2Handler
|
||||
// 기존 검증 요청 확인
|
||||
$existing = $this->vrfcReqModel->where('atcl_no', $articleNumber)->first();
|
||||
if (!$existing) {
|
||||
throw new Exception("취소할 기존 데이터가 없습니다. Atcl: $articleNumber");
|
||||
CLI::write(CLI::color("⚠️ 취소할 데이터가 없음 → 무시 (Atcl: $articleNumber)", 'yellow'));
|
||||
write_custom_log("CNC 무시 | Atcl: $articleNumber | 사유: 기존 데이터 없음", 'WARNING', 'service');
|
||||
return 0; // 취소할 데이터가 없으므로 0 반환
|
||||
}
|
||||
|
||||
$vrSq = $existing['vr_sq'];
|
||||
|
||||
@@ -59,19 +59,33 @@ class NaverService
|
||||
$vType = $rawData['verificationTypeCode'] ?? '';
|
||||
|
||||
// 2. 원본 데이터 Staging 저장
|
||||
$this->rawStagingModel->insert([
|
||||
$insertResult = $this->rawStagingModel->insert([
|
||||
'atcl_no' => $articleNumber,
|
||||
'verification_type' => $vType,
|
||||
'request_type' => $requestType,
|
||||
'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. 타입별 분기 처리
|
||||
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 {
|
||||
return $this->typeV2Handler->handle($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;
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
Reference in New Issue
Block a user