diff --git a/app/Services/Handlers/TypeSHandler.php b/app/Services/Handlers/TypeSHandler.php index 52f2292..9493fb9 100644 --- a/app/Services/Handlers/TypeSHandler.php +++ b/app/Services/Handlers/TypeSHandler.php @@ -39,17 +39,26 @@ class TypeSHandler 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')); @@ -71,7 +80,16 @@ class TypeSHandler // 3. νŠΈλžœμž­μ…˜ 컀밋 $this->db->transComplete(); if ($this->db->transStatus() === false) { - write_custom_log("Type S DB νŠΈλžœμž­μ…˜ μ΅œμ’… μ‹€νŒ¨", 'ERROR', 'service'); + $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 νŠΈλžœμž­μ…˜ μ΅œμ’… μ‹€νŒ¨"); }