Files
wzdj/old/app/api/admin/meituan/sync/route.ts
2026-04-20 14:56:28 +08:00

78 lines
2.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 美团酒店/网咖 POI 同步接口(占位)
* 正式对接需签约美团酒店直连平台 https://openplatform-hotel.meituan.com
* 认证Header Authorization (MWS partnerId:signature HmacSHA1) + Date
* 返回 AES 加密,需 clientSecret 解密
*/
import { NextResponse } from "next/server"
export const dynamic = "force-dynamic"
/** 同步结果Mock 或真实拉取 */
export async function POST() {
const partnerId = process.env.MEITUAN_PARTNER_ID
const hasConfig = !!partnerId && !!process.env.MEITUAN_CLIENT_SECRET
if (!hasConfig) {
return NextResponse.json({
success: true,
data: {
source: "meituan",
synced: true,
message: "当前未配置美团密钥,返回模拟数据。签约后配置 MEITUAN_PARTNER_ID、MEITUAN_CLIENT_SECRET、MEITUAN_AES_KEY 即可对接真实 POI。",
pois: getMockMeituanPois(),
},
})
}
// TODO: 真实请求美团 POI 同步接口,解密后返回
return NextResponse.json({
success: true,
data: {
source: "meituan",
synced: true,
message: "已配置美团,此处应调用美团 API 并解密返回。",
pois: getMockMeituanPois(),
},
})
}
function getMockMeituanPois() {
return [
{
id: "meituan_1",
name: "美团·电竞主题酒店(厦门软件园店)",
type: "hotel" as const,
address: "厦门市思明区软件园二期观日路",
city: "厦门",
district: "思明区",
pricePerNight: 358,
rating: 4.8,
source: "meituan",
},
{
id: "meituan_2",
name: "美团·网鱼网咖(万达广场店)",
type: "cafe" as const,
address: "厦门市思明区万达广场金街",
city: "厦门",
district: "思明区",
pricePerHour: 12,
rating: 4.6,
source: "meituan",
},
{
id: "meituan_3",
name: "美团·杰拉电竞馆(银泰城店)",
type: "cafe" as const,
address: "厦门市集美区银泰城",
city: "厦门",
district: "集美区",
pricePerHour: 10,
rating: 4.5,
source: "meituan",
},
]
}