false, 'message' => '', 'data' => [ 'areaPrice' => 0, 'unitPrice' => 0, 'totalPrice' => 0 ] ]; try { // 길이가 유효한지 확인 if ($length <= 0) { throw new Exception("유효하지 않은 길이 값: $length"); } // 과거 로직에 따른 계산 // 면적 단가 계산 (예시: 1㎡당 30,000원) $areaPrice = $length * 30000; // 실제로는 데이터베이스에서 가져와야 함 // 단가 계산 (면적 길이 × 면적 단가) $unitPrice = round($length * 30000); // 기본 수량 (실제로는 입력값에서 가져와야 함) $su = 1; // 합계 계산 (수량 × 단가) $totalPrice = round($su * $unitPrice); writeLog("계산 결과 - areaPrice: $areaPrice, unitPrice: $unitPrice, totalPrice: $totalPrice"); // 응답 데이터 설정 $response['success'] = true; $response['message'] = '계산 완료'; $response['data'] = [ 'areaPrice' => $areaPrice, 'unitPrice' => $unitPrice, 'totalPrice' => $totalPrice ]; // 추가 디버그 정보 $response['debug'] = [ 'inputLength' => $length, 'rowIndex' => $rowIndex, 'inputType' => $inputType, 'calculationMethod' => 'area_length * 30000', 'timestamp' => date('Y-m-d H:i:s') ]; } catch (Exception $e) { writeLog("오류 발생: " . $e->getMessage()); $response['success'] = false; $response['message'] = '계산 중 오류가 발생했습니다: ' . $e->getMessage(); $response['error'] = $e->getMessage(); } // JSON 응답 전송 $json_response = json_encode($response, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); writeLog("응답 전송: " . $json_response); echo $json_response; ?>