true, 'found' => false, ], JSON_UNESCAPED_UNICODE); exit; } if (mb_strlen($merchant, 'UTF-8') < 2) { echo json_encode([ 'ok' => true, 'found' => false, ], JSON_UNESCAPED_UNICODE); exit; } try { $suggested = suggest_category_from_merchant(user_id(), $merchant, $transactionType); if (!$suggested) { echo json_encode([ 'ok' => true, 'found' => false, ], JSON_UNESCAPED_UNICODE); exit; } echo json_encode([ 'ok' => true, 'found' => true, 'category_id' => (int)$suggested['category_id'], 'category_name' => (string)$suggested['category_name'], 'category_type' => (string)$suggested['category_type'], 'pattern_text' => (string)($suggested['pattern_text'] ?? ''), 'keyword' => (string)($suggested['keyword'] ?? $suggested['pattern_text'] ?? ''), 'match_type' => (string)($suggested['match_type'] ?? ''), 'priority' => (int)($suggested['priority'] ?? 0), 'confidence' => (float)($suggested['confidence'] ?? 0), ], JSON_UNESCAPED_UNICODE); } catch (Throwable $e) { http_response_code(500); echo json_encode([ 'ok' => false, 'found' => false, 'message' => '자동추천 조회 실패', ], JSON_UNESCAPED_UNICODE); }