/**
 * 合作商家数据模块
 * 包含22家合作商家的模拟数据
 */

// 商家ID起始值（避免与其他marker冲突）
const MERCHANT_MARKER_BASE_ID = 10000;

/**
 * 22家合作商家的模拟数据
 * 坐标数据为上海松江万达广场附近的示例坐标（松江万达坐标：31.0434°N, 121.2222°E）
 * 商家分布在松江万达广场周边约3公里范围内
 */
const MERCHANT_DATA = [
  {
    id: 1,
    name: 'Elijem爱聚花园咖啡厅',
    latitude:  31.0445,
    longitude: 121.2235,
    address: '上海市松江区广富林路658号万达广场2楼',
    merchantType: 'restaurant',
    description: '新疆知名的西餐厅',
    phone: '18599435525',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741587_id-1.jpg', // 菜品宣传图
      title: '迷雾交响曲特色水烟2人餐 特色水烟一壶+百香果冷萃茶或薄荷红茶2选1+小吃',
      sales: '半年售出2.8万+',
      ranking: '门店热销第一名',
      rating: 4.7,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 160,
      originalPrice: 194,
      discount: 34
    }
  },
  {
    id: 2,
    name: '蜀渊火锅',
    latitude: 31.0428,
    longitude: 121.2205,
    address: '上海市松江区广富林路658号万达广场3楼',
    merchantType: 'restaurant',
    description: '全疆知名的火锅公司',
    phone: '17771177888',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741588_id-2.jpg',
      title: '情侣套餐（红汤锅/鸳鸯锅、鲜鸭血、鲜切马尾、鸭胗花、鲜切麻辣牛肉、虎皮鸡爪、海带芽、豆芽、2分小料、纸巾、茶水）',
      sales: '半年售出3.4万+',
      ranking: '门店热销第一名',
      rating: 4.9,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 188,
      originalPrice: 260,
      discount: 72
    }
  },
  {
    id: 3,
    name: '木垒烧烤',
    latitude: 31.0452,
    longitude: 121.2248,
    address: '上海市松江区广富林路658号万达广场4楼',
    merchantType: 'restaurant',
    description: '全球知名烧烤品牌',
    phone: '13659990568',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741589_id-3.jpg',
      title: '黄面凉皮+烤羊筋1串+烤羊心1串+烤羊肝1串18 架子肉1公斤+菠菜面筋/凉拌韭菜/糖拌西红柿/花生米/水煮花生米/老虎菜/泡菜（7选2不可重复）+烤千叶豆腐/烤平菇/烤辣子/烤豆角+烤韭菜+烤金针菇（6选5可重复）',
      sales: '半年售出5.2万+',
      ranking: '门店热销第二名',
      rating: 4.6,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 140,
      originalPrice: 158,
      discount: 18
    }
  },
  {
    id: 4,
    name: '大胆公鸡大盘鸡',
    latitude: 31.0415,
    longitude: 121.2218,
    address: '上海市松江区广富林路658号万达广场B1层',
    merchantType: 'restaurant',
    description: '知名大盘鸡店',
    phone: '-',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741589_id-4.jpg',
      title: '中盘鸡双人餐（含凉菜、皮带面）',
      sales: '半年售出1.8万+',
      ranking: '门店热销第一名',
      rating: 4.9,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 130,
      originalPrice: 157,
      discount: 27
    }
  },
  {
    id: 5,
    name: '黎弯德咖啡',
    latitude: 31.0438,
    longitude: 121.2255,
    address: '上海市松江区广富林路658号万达广场1楼',
    merchantType: 'cofe',
    description: '知名咖啡品牌',
    phone: '09918529999',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741590_id-5.jpg',
      title: '阳光活力双人早餐哈勒瓦+北非蛋+早餐面包+早餐蔬菜沙拉+早餐水果拼盘+鸡蛋饼+自制小酱+甜橙果酱+蜂蜜奶酪+立顿红茶+红扁豆糊糊+恰玛古浓汤+早餐牛奶+早餐橙汁',
      sales: '半年售出2.1万+',
      ranking: '门店热销第一名',
      rating: 4.5,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 229,
      originalPrice: 267,
      discount: 38.0
    }
  },
  {
    id: 6,
    name: '巴特私房菜·新疆菜',
    latitude: 31.0422,
    longitude: 121.2198,
    address: '上海市松江区广富林路658号万达广场3楼',
    merchantType: 'restaurant',
    description: '新疆特色菜',
    phone: '15199083420',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741591_id-6.jpg',
      title: '2-3人餐火焰山果味辣子鸡+菠萝咕噜肉+蒜蓉西兰花+养生豆腐',
      sales: '半年售出8.5万+',
      ranking: '门店热销第一名',
      rating: 4.7,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 180,
      originalPrice: 222,
      discount: 42
    }
  },
  {
    id: 7,
    name: '迈花郎抓饭烤肉美食',
    latitude: 31.0448,
    longitude: 121.2185,
    address: '上海市松江区广富林路658号万达广场B1层',
    merchantType: 'restaurant',
    description: '知名个人抓饭店',
    phone: '-',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741592_id-7.jpg',
      title: '特色抓饭 【本店热销 】',
      sales: '半年售出1.2万+',
      ranking: '本店热门菜',
      rating: 4.6,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 30,
      originalPrice: 36,
      discount: 6
    }
  },
  {
    id: 8,
    name: 'Badroom',
    latitude: 31.0465,
    longitude: 121.2232,
    address: '上海市松江区广富林路658号万达广场5楼',
    merchantType: 'bar',
    description: '热门酒吧！',
    phone: '18164991818',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741593_id-8.jpg',
      title: '特调酒水 回忆/脑浆/SunSet29 摇滚不死（包死、慎点！！！）',
      sales: '半年售出6800+',
      ranking: '门店热销第一名',
      rating: 4.7,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 88,
      originalPrice: 98,
      discount: 10
    }
  },
  {
    id: 9,
    name: '小白房子.White House',
    latitude: 31.0418,
    longitude: 121.2242,
    address: '上海市松江区广富林路658号万达广场5楼',
    merchantType: 'bar',
    description: '全新木屋酒吧',
    phone: '18690660882',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741593_id-9.jpg',
      title: '1664啤酒/白/红12瓶',
      sales: '半年售出12.5万+',
      ranking: '门店热销第一名',
      rating: 4.8,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 399.99,
      originalPrice: 427.96,
      discount: 27.97
    }
  },
  {
    id: 10,
    name: 'Brat',
    latitude: 31.0458,
    longitude: 121.2215,
    address: '上海市松江区广富林路658号万达广场5楼',
    merchantType: 'bar',
    description: '美式酒吧!',
    phone: '19999124449',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741594_id-10.jpg',
      title: '一壶特调水烟+双杯美式',
      sales: '半年售出3.8万+',
      ranking: '门店热销第一名',
      rating: 4.5,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 120,
      originalPrice: 170,
      discount: 50
    }
  },
  {
    id: 11,
    name: '迪娜艺咖啡店',
    latitude: 31.0432,
    longitude: 121.2195,
    address: '上海市松江区广富林路658号万达广场1楼',
    merchantType: 'cofe',
    description: 'UG咖啡厅',
    phone: '15899227419',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741595_id-11.jpg',
      title: '香橙美式',
      sales: '半年售出6.8万+',
      ranking: '门店热销第一名',
      rating: 4.7,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 12,
      originalPrice: 15,
      discount: 3
    }
  },
  {
    id: 12,
    name: '羔娃咖啡',
    latitude: 31.0425,
    longitude: 121.2258,
    address: '上海市松江区广富林路658号万达广场1楼',
    merchantType: 'cofe',
    description: '蒙古风格咖啡馆',
    phone: '020-12345689',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741596_id-12.jpg',
      title: '蒙古包慕斯蛋糕 25',
      sales: '半年售出9.2万+',
      ranking: '门店热销第一名',
      rating: 4.6,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 25.0,
      originalPrice: 29.0,
      discount: 5.0
    }
  },
  {
    id: 13,
    name: '渡鸦 Whisky Bar',
    latitude: 31.0442,
    longitude: 121.2202,
    address: '上海市松江区广富林路658号万达广场5楼',
    merchantType: 'bar',
    description: '知名酒吧',
    phone: '13139622162',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741596_id-13.jpg',
      title: 'OHMYCAT无醇香槟1瓶+藜麦莎拉+烟熏马肉披萨+黑松露薯条+炸食拼盘',
      sales: '半年售出15.6万+',
      ranking: '门店热销第一名',
      rating: 4.8,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 350.0,
      originalPrice: 370.0,
      discount: 20.0
    }
  },
  {
    id: 14,
    name: '零点休闲馆',
    latitude: 31.0435,
    longitude: 121.2228,
    address: '上海市松江区广富林路658号万达广场4楼',
    merchantType: 'play',
    description: '玩乐大本营',
    phone: '-',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741597_id-14.jpg',
      title: '璟点中八或PS5一小时',
      sales: '半年售出4.5万+',
      ranking: '门店热销第一名',
      rating: 4.5,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 39,
      originalPrice: 58,
      discount: 19
    }
  },
  {
    id: 15,
    name: '古丽格拉斯蛋糕咖啡店',
    latitude: 31.0412,
    longitude: 121.2238,
    address: '上海市松江区广富林路658号万达广场1楼',
    merchantType: 'mall',
    description: 'UG蛋糕店',
    phone: '-',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741598_id-16.jpg',
      title: '巧克力蛋糕 29.9',
      sales: '半年售出18.9万+',
      ranking: '门店热销第一名',
      rating: 4.7,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 29.9,
      originalPrice: 39.0,
      discount: 10.0
    }
  },
  {
    id: 16,
    name: '疯玩岛潮玩街区 团建聚会',
    latitude: 31.0455,
    longitude: 121.2192,
    address: '上海市松江区广富林路658号万达广场4楼',
    merchantType: 'mall',
    description: '畅玩 娱乐',
    phone: '19289924725',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741598_id-16.jpg',
      title: '双人全天无限畅玩 送抓娃娃币50枚',
      sales: '半年售出2.3万+',
      ranking: '门店热销第一名',
      rating: 4.6,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 999.0,
      originalPrice: 1288.0,
      discount: 289.0
    }
  },
  {
    id: 17,
    name: '岩咖攀岩',
    latitude: 31.0428,
    longitude: 121.2245,
    address: '上海市松江区广富林路658号万达广场4楼',
    merchantType: 'play',
    description: '玩乐-畅玩',
    phone: '18040775611',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741598_id-17.jpg',
      title: '双人套餐 330',
      sales: '半年售出22.5万+',
      ranking: '门店热销第一名',
      rating: 4.9,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 330.0,
      originalPrice: 336.0,
      discount: 36
    }
  },
  {
    id: 18,
    name: '初墨手作 陶艺 银饰 拼豆',
    latitude: 31.0445,
    longitude: 121.2212,
    address: '上海市松江区广富林路658号万达广场4楼',
    merchantType: 'play',
    description: '新式娱乐',
    phone: '17726853579',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741599_id-18.jpg',
      title: '情侣/闺蜜粘土冰箱贴 110',
      sales: '半年售出19.8万+',
      ranking: '门店热销第一名',
      rating: 4.8,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 110.0,
      originalPrice: 136.0,
      discount: 26.0
    }
  },
  {
    id: 19,
    name: '喵呜豆社猫狗咖 撸猫撸狗 拼豆',
    latitude: 31.0438,
    longitude: 121.2208,
    address: '上海市松江区广富林路658号万达广场4楼',
    merchantType: 'play',
    description: '新玩乐项目',
    phone: '13629971015',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741600_id-19.jpg',
      title: '双人撸猫撸狗套餐不限时（包饮料+宠物投喂+赠品）',
      sales: '半年售出32.6万+',
      ranking: '门店热销第一名',
      rating: 4.7,
      shopName: '松江万达店',
      district: '松江区',
      groupPrice: 180.0,
      originalPrice: 220.0,
      discount: 40.0
    }
  },
  {
    id: 20,
    name: '开心麻花爆笑原创综艺同款新喜剧',
    latitude: 43.800000,
    longitude: 87.610000,
    address: '建中路2号',
    merchantType: 'play',
    description: '玩乐',
    phone: '0-0',
    dishInfo: {
      image: 'https://findme-1375214531.cos.ap-guangzhou.myqcloud.com/user/12852468/image/1766741601_id-20.jpg',
      title: '游乐 单人玩乐 【特价 150 】',
      sales: '半年售出28.4万+',
      ranking: '门店热销第一名',
      rating: 4.6,
      shopName: '天山区店',
      district: '天山区',
      groupPrice: 150.0,
      originalPrice: 160.0,
      discount: 10.0
    }
  }
];

/**
 * 将商家数据转换为地图marker格式
 * @param {Array} merchants - 商家数据数组
 * @returns {Array} marker数组
 */
function convertMerchantsToMarkers(merchants) {
  if (!merchants || !Array.isArray(merchants)) {
    return [];
  }

  return merchants.map((merchant, index) => {
    const markerId = MERCHANT_MARKER_BASE_ID + merchant.id;
    
    return {
      id: markerId,
      type: 'merchant',
      latitude: merchant.latitude,
      longitude: merchant.longitude,
      iconPath: '/images/map/marker_blank.png', // 使用透明图标，通过自定义callout显示名称
      width: 40,
      height: 40,
      customCallout: {
        anchorY: 0,
        anchorX: 0,
        display: 'ALWAYS' // 始终显示商家名称
      },
      merchantId: merchant.id,
      merchantType: merchant.merchantType || 'default',
      merchantName: merchant.name,
      name: merchant.name, // 兼容字段，WXML中使用
      merchantAddress: merchant.address,
      joinCluster: false // 商家标记不参与聚合
    };
  });
}

/**
 * 获取所有商家数据
 * @returns {Array} 商家数据数组
 */
function getAllMerchants() {
  return MERCHANT_DATA;
}

/**
 * 根据ID获取商家信息
 * @param {Number} id - 商家ID
 * @returns {Object|null} 商家信息对象
 */
function getMerchantById(id) {
  return MERCHANT_DATA.find(merchant => merchant.id === id) || null;
}

module.exports = {
  MERCHANT_DATA,
  MERCHANT_MARKER_BASE_ID,
  getAllMerchants,
  getMerchantById,
  convertMerchantsToMarkers
};
