<?php
/**
 * 酒店查询API - 独立模块，不含婚宴酒店
 * 支持城市搜索、价格/星级筛选、详情查询
 * 数据结构设计兼容第三方API接入
 */
header('Content-Type: application/json; charset=utf-8');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header('Access-Control-Allow-Headers: Content-Type');

// 错误处理
set_error_handler(function($errno, $errstr) {
    echo json_encode(['success' => false, 'message' => '系统错误: ' . $errstr]);
    exit;
});

class HotelAPI {
    
    private static $hotels = [];
    private static $initialized = false;
    
    /**
     * 初始化酒店数据
     * 数据结构设计为兼容携程/美团等第三方API格式
     */
    public static function init() {
        if (self::$initialized) return;
        self::$initialized = true;
        
        // 酒店数据模板 - 模拟真实API返回格式
        $hotelData = [
            // ========== 阳泉本地酒店 ==========
            [
                'id' => 'YQ001',
                'name' => '阳泉豪远国际酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '豪远酒店集团',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '城区',
                'address' => '阳泉市城区北大街5号',
                'location' => ['lat' => 37.8572, 'lng' => 113.5832],
                'phone' => '0353-2038888',
                'price' => ['min' => 398, 'max' => 680, 'avg' => 480],
                'rating' => 4.8,
                'review_count' => 1256,
                'tags' => ['市中心', '商务出行', '免费停车', '早餐'],
                'facilities' => [
                    '免费WiFi', '停车场', '健身房', '室内泳池', '餐厅', 
                    '会议室', '行李寄存', '叫醒服务', '洗衣服务'
                ],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.8m大床', 'area' => '28㎡', 'price' => 398, 'inventory' => 15],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '30㎡', 'price' => 418, 'inventory' => 10],
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '38㎡', 'price' => 528, 'inventory' => 8],
                    ['name' => '商务套房', 'bed' => '2.0m大床', 'area' => '55㎡', 'price' => 680, 'inventory' => 5],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['阳泉火车站(2km)', '阳泉市政府(500m)', '北山公园(1km)'],
                'description' => '阳泉首家五星级酒店，位于市中心繁华地段，设施齐全，服务一流。',
                'status' => 'available'
            ],
            [
                'id' => 'YQ002',
                'name' => '阳泉宾馆',
                'star' => 4,
                'star_name' => '四星级高档',
                'brand' => '阳泉宾馆',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '城区',
                'address' => '阳泉市城区南大街23号',
                'location' => ['lat' => 37.8518, 'lng' => 113.5798],
                'phone' => '0353-2023456',
                'price' => ['min' => 268, 'max' => 450, 'avg' => 320],
                'rating' => 4.5,
                'review_count' => 892,
                'tags' => ['历史名店', '交通便利', '中式餐厅'],
                'facilities' => ['免费WiFi', '停车场', '中餐厅', '会议室', '洗衣服务', '行李寄存'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.8m大床', 'area' => '25㎡', 'price' => 268, 'inventory' => 20],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '28㎡', 'price' => 288, 'inventory' => 15],
                    ['name' => '豪华套房', 'bed' => '2.0m大床', 'area' => '45㎡', 'price' => 450, 'inventory' => 6],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['阳泉火车站(1.5km)', '南山公园(800m)'],
                'description' => '阳泉老牌宾馆，历史悠久，服务周到，性价比高。',
                'status' => 'available'
            ],
            [
                'id' => 'YQ003',
                'name' => '如家精选酒店(阳泉火车站店)',
                'star' => 3,
                'star_name' => '三星级舒适',
                'brand' => '如家酒店',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '城区',
                'address' => '阳泉市城区德胜东街18号',
                'location' => ['lat' => 37.8625, 'lng' => 113.5912],
                'phone' => '0353-5612345',
                'price' => ['min' => 159, 'max' => 220, 'avg' => 180],
                'rating' => 4.2,
                'review_count' => 567,
                'tags' => ['火车站旁', '性价比高', '干净舒适'],
                'facilities' => ['免费WiFi', '24小时热水', '空调', '电视', '吹风机'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.5m大床', 'area' => '20㎡', 'price' => 159, 'inventory' => 25],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '22㎡', 'price' => 179, 'inventory' => 20],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天12点前免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['阳泉火车站(200m)', '汽车站(500m)'],
                'description' => '连锁品牌酒店，位置便利，干净整洁，适合商旅出行。',
                'status' => 'available'
            ],
            [
                'id' => 'YQ004',
                'name' => '7天优品酒店(阳泉市政府店)',
                'star' => 2,
                'star_name' => '经济型',
                'brand' => '7天酒店',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '城区',
                'address' => '阳泉市城区桃北中路45号',
                'location' => ['lat' => 37.8568, 'lng' => 113.5856],
                'phone' => '0353-2298777',
                'price' => ['min' => 128, 'max' => 168, 'avg' => 145],
                'rating' => 3.9,
                'review_count' => 423,
                'tags' => ['经济型', '位置便利', '自助早餐'],
                'facilities' => ['免费WiFi', '空调', '电视', '独立卫浴', '24小时前台'],
                'images' => [],
                'rooms' => [
                    ['name' => '经济大床房', 'bed' => '1.5m大床', 'area' => '18㎡', 'price' => 128, 'inventory' => 30],
                    ['name' => '经济双床房', 'bed' => '1.2m双床', 'area' => '20㎡', 'price' => 148, 'inventory' => 25],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['阳泉市政府(300m)', '商业街(500m)'],
                'description' => '经济实惠，干净卫生，适合预算有限的旅客。',
                'status' => 'available'
            ],
            [
                'id' => 'YQ005',
                'name' => '阳泉汇通商务酒店',
                'star' => 4,
                'star_name' => '四星级高档',
                'brand' => '汇通酒店',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '矿区',
                'address' => '阳泉市矿区北大街88号',
                'location' => ['lat' => 37.8725, 'lng' => 113.5689],
                'phone' => '0353-4089999',
                'price' => ['min' => 228, 'max' => 380, 'avg' => 280],
                'rating' => 4.3,
                'review_count' => 356,
                'tags' => ['商务区', '会议设施', '棋牌娱乐'],
                'facilities' => ['免费WiFi', '停车场', '棋牌室', '会议室', '餐厅', '茶室'],
                'images' => [],
                'rooms' => [
                    ['name' => '商务大床房', 'bed' => '1.8m大床', 'area' => '30㎡', 'price' => 228, 'inventory' => 18],
                    ['name' => '商务双床房', 'bed' => '1.2m双床', 'area' => '32㎡', 'price' => 248, 'inventory' => 12],
                    ['name' => '商务套房', 'bed' => '2.0m大床', 'area' => '50㎡', 'price' => 380, 'inventory' => 6],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['矿区商业中心(500m)', '阳煤集团(1km)'],
                'description' => '矿区商务型酒店，适合商务洽谈和团队入住。',
                'status' => 'available'
            ],
            [
                'id' => 'YQ006',
                'name' => '汉庭酒店(阳泉天桥店)',
                'star' => 3,
                'star_name' => '三星级舒适',
                'brand' => '汉庭酒店',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '城区',
                'address' => '阳泉市城区天桥街12号',
                'location' => ['lat' => 37.8492, 'lng' => 113.5723],
                'phone' => '0353-2516666',
                'price' => ['min' => 169, 'max' => 230, 'avg' => 195],
                'rating' => 4.1,
                'review_count' => 678,
                'tags' => ['连锁品牌', '服务规范', '位置佳'],
                'facilities' => ['免费WiFi', '24小时前台', '空调', '电视', '吹风机', '行李寄存'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.5m大床', 'area' => '22㎡', 'price' => 169, 'inventory' => 22],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '24㎡', 'price' => 189, 'inventory' => 18],
                    ['name' => '高级大床房', 'bed' => '1.8m大床', 'area' => '28㎡', 'price' => 230, 'inventory' => 8],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天12点前免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['天桥商圈(100m)', '公交总站(300m)'],
                'description' => '华住集团旗下品牌，标准化服务，干净舒适。',
                'status' => 'available'
            ],
            [
                'id' => 'YQ007',
                'name' => '阳泉金花园大酒店',
                'star' => 4,
                'star_name' => '四星级高档',
                'brand' => '金花园酒店',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '郊区',
                'address' => '阳泉市郊区平坦镇桃林沟村',
                'location' => ['lat' => 37.8234, 'lng' => 113.5234],
                'phone' => '0353-5066666',
                'price' => ['min' => 288, 'max' => 480, 'avg' => 350],
                'rating' => 4.4,
                'review_count' => 289,
                'tags' => ['度假村', '环境优美', '农家特色'],
                'facilities' => ['免费WiFi', '停车场', '花园', '餐厅', 'KTV', '会议室', '烧烤区'],
                'images' => [],
                'rooms' => [
                    ['name' => '园景大床房', 'bed' => '1.8m大床', 'area' => '35㎡', 'price' => 288, 'inventory' => 15],
                    ['name' => '园景双床房', 'bed' => '1.2m双床', 'area' => '38㎡', 'price' => 308, 'inventory' => 10],
                    ['name' => '花园套房', 'bed' => '2.0m大床', 'area' => '60㎡', 'price' => 480, 'inventory' => 4],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前2天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '需提前申请'
                ],
                'nearby' => ['桃林沟景区(500m)', '农家乐(周边)'],
                'description' => '郊区度假型酒店，环境清幽，适合休闲度假。',
                'status' => 'available'
            ],
            [
                'id' => 'YQ008',
                'name' => '格林豪泰酒店(阳泉市政府店)',
                'star' => 3,
                'star_name' => '三星级舒适',
                'brand' => '格林豪泰',
                'city' => '阳泉',
                'city_code' => 'YQ',
                'district' => '城区',
                'address' => '阳泉市城区南山北路56号',
                'location' => ['lat' => 37.8534, 'lng' => 113.5756],
                'phone' => '0353-2034567',
                'price' => ['min' => 149, 'max' => 199, 'avg' => 165],
                'rating' => 4.0,
                'review_count' => 534,
                'tags' => ['连锁酒店', '商务首选', '周边配套全'],
                'facilities' => ['免费WiFi', '停车场', '餐厅', '会议室', '商务中心'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.5m大床', 'area' => '20㎡', 'price' => 149, 'inventory' => 28],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '22㎡', 'price' => 169, 'inventory' => 22],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['市政府(400m)', '南山公园(600m)'],
                'description' => '格林酒店集团品牌，商务出行首选。',
                'status' => 'available'
            ],
            
            // ========== 太原酒店 ==========
            [
                'id' => 'TY001',
                'name' => '太原万达文华酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '万达文华',
                'city' => '太原',
                'city_code' => 'TY',
                'district' => '杏花岭区',
                'address' => '太原市杏花岭区解放北路169号',
                'location' => ['lat' => 37.8821, 'lng' => 112.5632],
                'phone' => '0351-7778888',
                'price' => ['min' => 588, 'max' => 1200, 'avg' => 750],
                'rating' => 4.9,
                'review_count' => 2156,
                'tags' => ['高端商务', '万达广场', '豪华设施'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', 'SPA', '餐厅', '行政酒廊', '停车场'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '45㎡', 'price' => 588, 'inventory' => 20],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '48㎡', 'price' => 628, 'inventory' => 15],
                    ['name' => '行政套房', 'bed' => '2.0m大床', 'area' => '75㎡', 'price' => 980, 'inventory' => 8],
                    ['name' => '总统套房', 'bed' => '2.2m大床', 'area' => '150㎡', 'price' => 1200, 'inventory' => 2],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前2天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['万达广场(楼下)', '太原火车站(3km)'],
                'description' => '太原顶级五星级酒店，万达集团旗下奢华品牌。',
                'status' => 'available'
            ],
            [
                'id' => 'TY002',
                'name' => '山西国贸大饭店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '国贸酒店',
                'city' => '太原',
                'city_code' => 'TY',
                'district' => '小店区',
                'address' => '太原市小店区长风街18号',
                'location' => ['lat' => 37.7352, 'lng' => 112.5689],
                'phone' => '0351-7654321',
                'price' => ['min' => 498, 'max' => 880, 'avg' => 620],
                'rating' => 4.7,
                'review_count' => 1567,
                'tags' => ['地标建筑', '商务中心', '高端餐饮'],
                'facilities' => ['免费WiFi', '停车场', '健身房', '游泳池', '中餐厅', '西餐厅', '会议室'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.8m大床', 'area' => '35㎡', 'price' => 498, 'inventory' => 25],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '38㎡', 'price' => 528, 'inventory' => 20],
                    ['name' => '商务套房', 'bed' => '2.0m大床', 'area' => '60㎡', 'price' => 880, 'inventory' => 10],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['长风商务区(500m)', '山西大剧院(1km)'],
                'description' => '太原地标性酒店，位于长风商务区核心位置。',
                'status' => 'available'
            ],
            [
                'id' => 'TY003',
                'name' => '全季酒店(太原长风街店)',
                'star' => 4,
                'star_name' => '四星级高档',
                'brand' => '全季酒店',
                'city' => '太原',
                'city_code' => 'TY',
                'district' => '小店区',
                'address' => '太原市小店区亲贤北街58号',
                'location' => ['lat' => 37.7421, 'lng' => 112.5723],
                'phone' => '0351-2345678',
                'price' => ['min' => 298, 'max' => 420, 'avg' => 350],
                'rating' => 4.5,
                'review_count' => 892,
                'tags' => ['中端连锁', '设计简约', '服务周到'],
                'facilities' => ['免费WiFi', '停车场', '餐厅', '会议室', '洗衣服务'],
                'images' => [],
                'rooms' => [
                    ['name' => '高级大床房', 'bed' => '1.8m大床', 'area' => '28㎡', 'price' => 298, 'inventory' => 30],
                    ['name' => '高级双床房', 'bed' => '1.2m双床', 'area' => '30㎡', 'price' => 318, 'inventory' => 25],
                    ['name' => '零压大床房', 'bed' => '2.0m大床', 'area' => '35㎡', 'price' => 420, 'inventory' => 10],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['亲贤街商圈(200m)', '茂业百货(500m)'],
                'description' => '华住集团中端品牌，东方美学设计风格。',
                'status' => 'available'
            ],
            [
                'id' => 'TY004',
                'name' => '锦江之星(太原柳巷店)',
                'star' => 3,
                'star_name' => '三星级舒适',
                'brand' => '锦江之星',
                'city' => '太原',
                'city_code' => 'TY',
                'district' => '迎泽区',
                'address' => '太原市迎泽区柳巷南路15号',
                'location' => ['lat' => 37.8623, 'lng' => 112.5623],
                'phone' => '0351-8765432',
                'price' => ['min' => 179, 'max' => 239, 'avg' => 199],
                'rating' => 4.1,
                'review_count' => 567,
                'tags' => ['市中心', '步行街', '美食众多'],
                'facilities' => ['免费WiFi', '空调', '电视', '独立卫浴'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.5m大床', 'area' => '18㎡', 'price' => 179, 'inventory' => 35],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '20㎡', 'price' => 199, 'inventory' => 30],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['柳巷步行街(楼下)', '太原食品街(500m)'],
                'description' => '位于太原最繁华的柳巷商圈，周边美食购物便利。',
                'status' => 'available'
            ],
            
            // ========== 北京酒店 ==========
            [
                'id' => 'BJ001',
                'name' => '北京饭店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '北京饭店',
                'city' => '北京',
                'city_code' => 'BJ',
                'district' => '东城区',
                'address' => '北京市东城区东长安街33号',
                'location' => ['lat' => 39.9042, 'lng' => 116.4074],
                'phone' => '010-65137766',
                'price' => ['min' => 888, 'max' => 2500, 'avg' => 1200],
                'rating' => 4.9,
                'review_count' => 3567,
                'tags' => ['历史名店', '天安门旁', '国宴标准'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', 'SPA', '中餐厅', '西餐厅', '行政酒廊', '会议室'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '50㎡', 'price' => 888, 'inventory' => 15],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '55㎡', 'price' => 968, 'inventory' => 10],
                    ['name' => '行政套房', 'bed' => '2.0m大床', 'area' => '80㎡', 'price' => 1580, 'inventory' => 8],
                    ['name' => '总统套房', 'bed' => '2.2m大床', 'area' => '200㎡', 'price' => 2500, 'inventory' => 2],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前3天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['天安门(500m)', '王府井(1km)', '故宫(1km)'],
                'description' => '北京历史最悠久的豪华酒店，曾接待多位国家元首。',
                'status' => 'available'
            ],
            [
                'id' => 'BJ002',
                'name' => '如家酒店(北京西站店)',
                'star' => 3,
                'star_name' => '三星级舒适',
                'brand' => '如家酒店',
                'city' => '北京',
                'city_code' => 'BJ',
                'district' => '丰台区',
                'address' => '北京市丰台区莲花池东路120号',
                'location' => ['lat' => 39.8923, 'lng' => 116.3223],
                'phone' => '010-63958888',
                'price' => ['min' => 259, 'max' => 359, 'avg' => 299],
                'rating' => 4.0,
                'review_count' => 1234,
                'tags' => ['西站旁', '交通便利', '性价比高'],
                'facilities' => ['免费WiFi', '24小时热水', '空调', '电视'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.5m大床', 'area' => '20㎡', 'price' => 259, 'inventory' => 40],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '22㎡', 'price' => 299, 'inventory' => 35],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天12点前免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['北京西站(200m)', '莲花池公园(500m)'],
                'description' => '紧邻北京西站，适合赶火车旅客入住。',
                'status' => 'available'
            ],
            [
                'id' => 'BJ003',
                'name' => '北京7天连锁酒店(鸟巢店)',
                'star' => 2,
                'star_name' => '经济型',
                'brand' => '7天酒店',
                'city' => '北京',
                'city_code' => 'BJ',
                'district' => '朝阳区',
                'address' => '北京市朝阳区安立路66号',
                'location' => ['lat' => 39.9923, 'lng' => 116.3923],
                'phone' => '010-64805588',
                'price' => ['min' => 199, 'max' => 269, 'avg' => 229],
                'rating' => 3.8,
                'review_count' => 876,
                'tags' => ['奥运商圈', '经济型', '地铁直达'],
                'facilities' => ['免费WiFi', '空调', '电视', '独立卫浴'],
                'images' => [],
                'rooms' => [
                    ['name' => '经济大床房', 'bed' => '1.5m大床', 'area' => '18㎡', 'price' => 199, 'inventory' => 50],
                    ['name' => '经济双床房', 'bed' => '1.2m双床', 'area' => '20㎡', 'price' => 229, 'inventory' => 40],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['鸟巢(500m)', '水立方(600m)', '奥林匹克公园(1km)'],
                'description' => '位于奥运商圈，地铁8号线直达，经济实惠。',
                'status' => 'available'
            ],
            
            // ========== 石家庄酒店 ==========
            [
                'id' => 'SJZ001',
                'name' => '石家庄国际大厦酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '国际大厦',
                'city' => '石家庄',
                'city_code' => 'SJZ',
                'district' => '长安区',
                'address' => '石家庄市长安区中山东路301号',
                'location' => ['lat' => 38.0421, 'lng' => 114.5123],
                'phone' => '0311-86678888',
                'price' => ['min' => 458, 'max' => 850, 'avg' => 580],
                'rating' => 4.6,
                'review_count' => 1234,
                'tags' => ['市中心', '商务接待', '综合设施'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', '中餐厅', '会议室', '行政酒廊'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '40㎡', 'price' => 458, 'inventory' => 20],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '42㎡', 'price' => 488, 'inventory' => 15],
                    ['name' => '商务套房', 'bed' => '2.0m大床', 'area' => '65㎡', 'price' => 850, 'inventory' => 8],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['石家庄火车站(2km)', '北国商城(500m)'],
                'description' => '石家庄地标性五星级酒店，商务接待首选。',
                'status' => 'available'
            ],
            [
                'id' => 'SJZ002',
                'name' => '河北宾馆',
                'star' => 4,
                'star_name' => '四星级高档',
                'brand' => '河北宾馆',
                'city' => '石家庄',
                'city_code' => 'SJZ',
                'district' => '桥西区',
                'address' => '石家庄市桥西区自强路127号',
                'location' => ['lat' => 38.0323, 'lng' => 114.4823],
                'phone' => '0311-85266666',
                'price' => ['min' => 338, 'max' => 520, 'avg' => 400],
                'rating' => 4.4,
                'review_count' => 567,
                'tags' => ['省政府旁', '政务接待', '园林环境'],
                'facilities' => ['免费WiFi', '停车场', '花园', '餐厅', '会议室'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.8m大床', 'area' => '30㎡', 'price' => 338, 'inventory' => 25],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '32㎡', 'price' => 358, 'inventory' => 20],
                    ['name' => '商务套房', 'bed' => '2.0m大床', 'area' => '50㎡', 'price' => 520, 'inventory' => 10],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['省政府(300m)', '民心广场(500m)'],
                'description' => '老牌政务接待酒店，环境优雅，园林式设计。',
                'status' => 'available'
            ],
            
            // ========== 西安酒店 ==========
            [
                'id' => 'XA001',
                'name' => '西安香格里拉大酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '香格里拉',
                'city' => '西安',
                'city_code' => 'XA',
                'district' => '雁塔区',
                'address' => '西安市雁塔区科技路38号',
                'location' => ['lat' => 34.2321, 'lng' => 108.9123],
                'phone' => '029-88758888',
                'price' => ['min' => 758, 'max' => 1500, 'avg' => 950],
                'rating' => 4.8,
                'review_count' => 2567,
                'tags' => ['高新CBD', '豪华商务', '中西餐厅'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', 'SPA', '中餐厅', '行政酒廊'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '45㎡', 'price' => 758, 'inventory' => 25],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '48㎡', 'price' => 808, 'inventory' => 20],
                    ['name' => '行政套房', 'bed' => '2.0m大床', 'area' => '80㎡', 'price' => 1500, 'inventory' => 8],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前2天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['高新管委会(500m)', '世纪金花(1km)'],
                'description' => '国际顶级酒店品牌，西安高新区地标。',
                'status' => 'available'
            ],
            [
                'id' => 'XA002',
                'name' => '西安钟楼饭店',
                'star' => 4,
                'star_name' => '四星级高档',
                'brand' => '钟楼饭店',
                'city' => '西安',
                'city_code' => 'XA',
                'district' => '碑林区',
                'address' => '西安市碑林区南大街110号',
                'location' => ['lat' => 34.2612, 'lng' => 108.9523],
                'phone' => '029-87600000',
                'price' => ['min' => 368, 'max' => 580, 'avg' => 450],
                'rating' => 4.5,
                'review_count' => 1234,
                'tags' => ['钟楼旁', '古城中心', '旅游首选'],
                'facilities' => ['免费WiFi', '停车场', '餐厅', '会议室', '旅游咨询'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.8m大床', 'area' => '30㎡', 'price' => 368, 'inventory' => 30],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '32㎡', 'price' => 388, 'inventory' => 25],
                    ['name' => '观景套房', 'bed' => '2.0m大床', 'area' => '55㎡', 'price' => 580, 'inventory' => 10],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['钟楼(楼下)', '回民街(500m)', '碑林博物馆(1km)'],
                'description' => '位于西安市中心钟楼旁，古城旅游首选。',
                'status' => 'available'
            ],
            [
                'id' => 'XA003',
                'name' => '汉庭酒店(西安大雁塔店)',
                'star' => 3,
                'star_name' => '三星级舒适',
                'brand' => '汉庭酒店',
                'city' => '西安',
                'city_code' => 'XA',
                'district' => '雁塔区',
                'address' => '西安市雁塔区小寨东路8号',
                'location' => ['lat' => 34.2123, 'lng' => 108.9623],
                'phone' => '029-85258888',
                'price' => ['min' => 219, 'max' => 299, 'avg' => 259],
                'rating' => 4.2,
                'review_count' => 876,
                'tags' => ['大雁塔旁', '景区周边', '交通便利'],
                'facilities' => ['免费WiFi', '24小时前台', '行李寄存', '空调'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.5m大床', 'area' => '22㎡', 'price' => 219, 'inventory' => 35],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '24㎡', 'price' => 239, 'inventory' => 30],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住当天12点前免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['大雁塔(500m)', '大唐芙蓉园(1km)'],
                'description' => '紧邻大雁塔景区，适合旅游观光入住。',
                'status' => 'available'
            ],
            
            // ========== 郑州酒店 ==========
            [
                'id' => 'ZZ001',
                'name' => '郑州绿地JW万豪酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => 'JW万豪',
                'city' => '郑州',
                'city_code' => 'ZZ',
                'district' => '金水区',
                'address' => '郑州市金水区商务中央公园2号',
                'location' => ['lat' => 34.7621, 'lng' => 113.6823],
                'phone' => '0371-88938888',
                'price' => ['min' => 798, 'max' => 1600, 'avg' => 1000],
                'rating' => 4.9,
                'review_count' => 1892,
                'tags' => ['地标建筑', '高端商务', '城市景观'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', '水疗中心', '酒吧', '行政酒廊'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '50㎡', 'price' => 798, 'inventory' => 20],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '52㎡', 'price' => 858, 'inventory' => 15],
                    ['name' => '行政套房', 'bed' => '2.0m大床', 'area' => '85㎡', 'price' => 1600, 'inventory' => 6],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前2天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['郑东新区CBD(楼下)', '郑州东站(3km)'],
                'description' => '郑州地标建筑，郑东新区CBD核心酒店。',
                'status' => 'available'
            ],
            [
                'id' => 'ZZ002',
                'name' => '郑州希尔顿酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '希尔顿',
                'city' => '郑州',
                'city_code' => 'ZZ',
                'district' => '金水区',
                'address' => '郑州市金水区金水路288号',
                'location' => ['lat' => 34.7723, 'lng' => 113.6623],
                'phone' => '0371-66778888',
                'price' => ['min' => 688, 'max' => 1200, 'avg' => 850],
                'rating' => 4.7,
                'review_count' => 1567,
                'tags' => ['金水路', '商务中心', '国际品牌'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', 'SPA', '餐厅'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '42㎡', 'price' => 688, 'inventory' => 25],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '45㎡', 'price' => 728, 'inventory' => 20],
                    ['name' => '行政套房', 'bed' => '2.0m大床', 'area' => '70㎡', 'price' => 1200, 'inventory' => 8],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前2天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['紫荆山公园(500m)', '郑州火车站(2km)'],
                'description' => '国际知名酒店品牌，郑州商务首选。',
                'status' => 'available'
            ],
            
            // ========== 济南酒店 ==========
            [
                'id' => 'JN001',
                'name' => '济南香格里拉大酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '香格里拉',
                'city' => '济南',
                'city_code' => 'JN',
                'district' => '市中区',
                'address' => '济南市市中区泺源大街8号',
                'location' => ['lat' => 36.6521, 'lng' => 116.9923],
                'phone' => '0531-66668888',
                'price' => ['min' => 628, 'max' => 1200, 'avg' => 800],
                'rating' => 4.8,
                'review_count' => 1678,
                'tags' => ['泉城广场', '核心商圈', '高端商务'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', 'SPA', '中餐厅', '行政酒廊'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '42㎡', 'price' => 628, 'inventory' => 22],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '45㎡', 'price' => 668, 'inventory' => 18],
                    ['name' => '行政套房', 'bed' => '2.0m大床', 'area' => '75㎡', 'price' => 1200, 'inventory' => 6],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前2天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['泉城广场(楼下)', '趵突泉(500m)'],
                'description' => '济南顶级酒店，泉城广场核心位置。',
                'status' => 'available'
            ],
            [
                'id' => 'JN002',
                'name' => '济南贵和皇冠假日酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '皇冠假日',
                'city' => '济南',
                'city_code' => 'JN',
                'district' => '历下区',
                'address' => '济南市历下区天地坛街3号',
                'location' => ['lat' => 36.6623, 'lng' => 116.9823],
                'phone' => '0531-86029999',
                'price' => ['min' => 558, 'max' => 980, 'avg' => 700],
                'rating' => 4.6,
                'review_count' => 1234,
                'tags' => ['趵突泉旁', '景区周边', '国际品牌'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', '餐厅', '酒吧'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '38㎡', 'price' => 558, 'inventory' => 25],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '40㎡', 'price' => 598, 'inventory' => 20],
                    ['name' => '商务套房', 'bed' => '2.0m大床', 'area' => '60㎡', 'price' => 980, 'inventory' => 8],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['趵突泉(200m)', '大明湖(1km)'],
                'description' => '紧邻趵突泉景区，IHG旗下高端品牌。',
                'status' => 'available'
            ],
            
            // ========== 天津酒店 ==========
            [
                'id' => 'TJ001',
                'name' => '天津丽思卡尔顿酒店',
                'star' => 5,
                'star_name' => '五星级豪华',
                'brand' => '丽思卡尔顿',
                'city' => '天津',
                'city_code' => 'TJ',
                'district' => '和平区',
                'address' => '天津市和平区大沽北路167号',
                'location' => ['lat' => 39.1121, 'lng' => 117.2023],
                'phone' => '022-58578888',
                'price' => ['min' => 988, 'max' => 2000, 'avg' => 1300],
                'rating' => 4.9,
                'review_count' => 2156,
                'tags' => ['奢华五星', '欧式风格', '极致服务'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', '水疗中心', '酒吧', '行政酒廊'],
                'images' => [],
                'rooms' => [
                    ['name' => '豪华大床房', 'bed' => '2.0m大床', 'area' => '50㎡', 'price' => 988, 'inventory' => 18],
                    ['name' => '豪华双床房', 'bed' => '1.5m双床', 'area' => '52㎡', 'price' => 1058, 'inventory' => 12],
                    ['name' => '行政套房', 'bed' => '2.0m大床', 'area' => '85㎡', 'price' => 2000, 'inventory' => 6],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前3天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['天津站(1km)', '五大道(2km)'],
                'description' => '天津顶级奢华酒店，万豪集团旗下顶级品牌。',
                'status' => 'available'
            ],
            [
                'id' => 'TJ002',
                'name' => '天津海河假日酒店',
                'star' => 4,
                'star_name' => '四星级高档',
                'brand' => '假日酒店',
                'city' => '天津',
                'city_code' => 'TJ',
                'district' => '河北区',
                'address' => '天津市河北区海河东路凤凰商贸广场',
                'location' => ['lat' => 39.1523, 'lng' => 117.1823],
                'phone' => '022-26278888',
                'price' => ['min' => 368, 'max' => 580, 'avg' => 450],
                'rating' => 4.4,
                'review_count' => 892,
                'tags' => ['海河边', '意式风情区', '景观房'],
                'facilities' => ['免费WiFi', '室内泳池', '健身房', '餐厅', '会议室'],
                'images' => [],
                'rooms' => [
                    ['name' => '标准大床房', 'bed' => '1.8m大床', 'area' => '32㎡', 'price' => 368, 'inventory' => 28],
                    ['name' => '标准双床房', 'bed' => '1.2m双床', 'area' => '35㎡', 'price' => 398, 'inventory' => 22],
                    ['name' => '河景套房', 'bed' => '2.0m大床', 'area' => '55㎡', 'price' => 580, 'inventory' => 10],
                ],
                'policies' => [
                    'checkin' => '14:00后',
                    'checkout' => '12:00前',
                    'cancel' => '入住前1天免费取消',
                    'children' => '允许携带儿童',
                    'pets' => '不允许携带宠物'
                ],
                'nearby' => ['意式风情区(500m)', '天津之眼(1km)'],
                'description' => '位于海河畔，可欣赏天津之眼摩天轮景观。',
                'status' => 'available'
            ],
        ];
        
        self::$hotels = $hotelData;
    }
    
    /**
     * 搜索酒店
     * @param array $params 搜索参数
     * @return array 搜索结果
     */
    public static function search($params) {
        self::init();
        
        $city = $params['city'] ?? '';
        $minPrice = intval($params['min_price'] ?? 0);
        $maxPrice = intval($params['max_price'] ?? 99999);
        $star = $params['star'] ?? '';
        $keyword = $params['keyword'] ?? '';
        $page = intval($params['page'] ?? 1);
        $pageSize = intval($params['page_size'] ?? 10);
        $sortBy = $params['sort'] ?? 'star'; // star, price, rating
        
        $results = self::$hotels;
        
        // 城市筛选
        if (!empty($city)) {
            $results = array_filter($results, function($h) use ($city) {
                return stripos($h['city'], $city) !== false 
                    || stripos($h['district'], $city) !== false
                    || $h['city_code'] === strtoupper(substr($city, 0, 2));
            });
        }
        
        // 价格筛选
        $results = array_filter($results, function($h) use ($minPrice, $maxPrice) {
            return $h['price']['min'] >= $minPrice && $h['price']['min'] <= $maxPrice;
        });
        
        // 星级筛选
        if ($star !== '' && $star !== 'all') {
            $results = array_filter($results, function($h) use ($star) {
                return $h['star'] == intval($star);
            });
        }
        
        // 关键词搜索
        if (!empty($keyword)) {
            $results = array_filter($results, function($h) use ($keyword) {
                return stripos($h['name'], $keyword) !== false
                    || stripos($h['brand'], $keyword) !== false
                    || stripos($h['address'], $keyword) !== false;
            });
        }
        
        // 排序
        $results = array_values($results);
        switch ($sortBy) {
            case 'price':
                usort($results, function($a, $b) {
                    return $a['price']['min'] - $b['price']['min'];
                });
                break;
            case 'price_desc':
                usort($results, function($a, $b) {
                    return $b['price']['min'] - $a['price']['min'];
                });
                break;
            case 'rating':
                usort($results, function($a, $b) {
                    return $b['rating'] - $a['rating'];
                });
                break;
            case 'star':
            default:
                usort($results, function($a, $b) {
                    if ($a['star'] != $b['star']) {
                        return $b['star'] - $a['star'];
                    }
                    return $a['price']['min'] - $b['price']['min'];
                });
                break;
        }
        
        // 分页
        $total = count($results);
        $offset = ($page - 1) * $pageSize;
        $results = array_slice($results, $offset, $pageSize);
        
        return [
            'success' => true,
            'data' => $results,
            'pagination' => [
                'total' => $total,
                'page' => $page,
                'page_size' => $pageSize,
                'total_pages' => ceil($total / $pageSize),
                'has_more' => ($page * $pageSize) < $total
            ],
            'filters' => [
                'city' => $city,
                'min_price' => $minPrice,
                'max_price' => $maxPrice,
                'star' => $star,
                'keyword' => $keyword
            ]
        ];
    }
    
    /**
     * 获取酒店详情
     * @param string $id 酒店ID
     * @return array 酒店详情
     */
    public static function getDetail($id) {
        self::init();
        
        foreach (self::$hotels as $hotel) {
            if ($hotel['id'] === $id) {
                return [
                    'success' => true,
                    'data' => $hotel
                ];
            }
        }
        
        return [
            'success' => false,
            'message' => '酒店不存在',
            'code' => 404
        ];
    }
    
    /**
     * 获取热门城市列表
     * @return array 热门城市
     */
    public static function getHotCities() {
        self::init();
        
        $cities = [];
        foreach (self::$hotels as $hotel) {
            $cityCode = $hotel['city_code'];
            if (!isset($cities[$cityCode])) {
                $cities[$cityCode] = [
                    'code' => $cityCode,
                    'name' => $hotel['city'],
                    'hotel_count' => 0,
                    'min_price' => $hotel['price']['min'],
                    'max_star' => $hotel['star']
                ];
            }
            $cities[$cityCode]['hotel_count']++;
            if ($hotel['price']['min'] < $cities[$cityCode]['min_price']) {
                $cities[$cityCode]['min_price'] = $hotel['price']['min'];
            }
            if ($hotel['star'] > $cities[$cityCode]['max_star']) {
                $cities[$cityCode]['max_star'] = $hotel['star'];
            }
        }
        
        // 按酒店数量排序
        usort($cities, function($a, $b) {
            return $b['hotel_count'] - $a['hotel_count'];
        });
        
        return [
            'success' => true,
            'data' => array_values($cities)
        ];
    }
    
    /**
     * 检查房间可用性（模拟）
     * @param string $hotelId 酒店ID
     * @param string $roomId 房型名称
     * @param string $checkin 入住日期
     * @param string $checkout 离店日期
     * @return array 可用性结果
     */
    public static function checkAvailability($hotelId, $roomId, $checkin, $checkout) {
        self::init();
        
        $hotel = null;
        foreach (self::$hotels as $h) {
            if ($h['id'] === $hotelId) {
                $hotel = $h;
                break;
            }
        }
        
        if (!$hotel) {
            return ['success' => false, 'message' => '酒店不存在'];
        }
        
        $room = null;
        foreach ($hotel['rooms'] as $r) {
            if ($r['name'] === $roomId) {
                $room = $r;
                break;
            }
        }
        
        if (!$room) {
            return ['success' => false, 'message' => '房型不存在'];
        }
        
        // 模拟库存检查
        $available = $room['inventory'] > 0;
        $days = (strtotime($checkout) - strtotime($checkin)) / 86400;
        $totalPrice = $room['price'] * $days;
        
        return [
            'success' => true,
            'data' => [
                'available' => $available,
                'room' => $room,
                'checkin' => $checkin,
                'checkout' => $checkout,
                'days' => $days,
                'total_price' => $totalPrice,
                'hotel' => [
                    'id' => $hotel['id'],
                    'name' => $hotel['name'],
                    'phone' => $hotel['phone']
                ]
            ]
        ];
    }
}

// 处理请求
$action = $_GET['action'] ?? $_POST['action'] ?? 'search';

try {
    switch ($action) {
        case 'search':
            $result = HotelAPI::search($_GET);
            break;
        case 'detail':
            $id = $_GET['id'] ?? $_POST['id'] ?? '';
            $result = HotelAPI::getDetail($id);
            break;
        case 'hot_cities':
            $result = HotelAPI::getHotCities();
            break;
        case 'check_availability':
            $result = HotelAPI::checkAvailability(
                $_GET['hotel_id'] ?? $_POST['hotel_id'] ?? '',
                $_GET['room_id'] ?? $_POST['room_id'] ?? '',
                $_GET['checkin'] ?? $_POST['checkin'] ?? '',
                $_GET['checkout'] ?? $_POST['checkout'] ?? ''
            );
            break;
        default:
            $result = ['success' => false, 'message' => '未知操作: ' . $action];
    }
} catch (Exception $e) {
    $result = ['success' => false, 'message' => '系统错误: ' . $e->getMessage()];
}

echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);