feat(hotelGroups): add offer display fields and related logic
- Add new database columns (coverImage, priceAmount, priceUnit, tags, status) to HotelGroup model - Create hotel_group_dict serializer to handle image/coverImage synchronization and tag formatting - Update site config endpoints to use the new serializer and filter published hotel groups - Add Alembic migration for the new database schema changes - Update test fixtures and API contract tests for the new fields - Revise public and admin API documentation to document the new hotel group fields and usage rules
This commit is contained in:
@@ -101,7 +101,7 @@ Public API 输出规则:
|
||||
|
||||
### `HomeCard`
|
||||
|
||||
`HomeCard` 用于首页“特色酒店”与“万趣用车”两个普通卡片模块。MiniAPP 只消费卡片展示字段,不在这两个模块里读取商品本体或线路商品关联。
|
||||
`HomeCard` 用于首页“万趣用车”等普通内容卡片模块。MiniAPP 只消费卡片展示字段,不在这些模块里读取商品本体或线路商品关联。
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
@@ -112,10 +112,30 @@ Public API 输出规则:
|
||||
| `isActive` | `boolean` | 否 | 是否启用;Public API 通常只返回启用卡片 |
|
||||
| `sortOrder` | `number` | 否 | 后台展示顺序;Public API 按该字段升序输出 |
|
||||
|
||||
### `HotelCard`
|
||||
|
||||
`HotelCard` 用于首页“特色酒店”模块。该模块按管理端“特价优惠”同类配置方式维护标题、描述、价格、标签、封面图和发布状态,但仍然只代表首页酒店展示卡片,不绑定商品本体。
|
||||
|
||||
| 字段 | 类型 | 必填 | 说明 |
|
||||
| --- | --- | --- | --- |
|
||||
| `id` | `string` | 是 | 后端生成的酒店卡片 ID |
|
||||
| `title` | `string` | 是 | 酒店卡片标题 |
|
||||
| `description` | `string \| null` | 否 | 酒店卡片描述 |
|
||||
| `image` | `string \| null` | 否 | 兼容旧字段;后端会与 `coverImage` 保持一致 |
|
||||
| `coverImage` | `string \| null` | 否 | 酒店封面图主字段;MiniAPP 优先使用该字段 |
|
||||
| `priceAmount` | `number \| null` | 否 | 价格数值,前端可按页面需要展示 |
|
||||
| `priceUnit` | `string \| null` | 否 | 价格单位文案,例如 `起/晚` |
|
||||
| `tags` | `string[]` | 否 | 酒店标签,最多 3 个 |
|
||||
| `status` | `"draft" \| "published"` | 否 | 发布状态;Public API 只返回 `published` |
|
||||
| `isActive` | `boolean` | 否 | 是否启用;Public API 只返回启用项 |
|
||||
| `sortOrder` | `number` | 否 | 后台展示顺序;Public API 按该字段升序输出 |
|
||||
|
||||
Public API 输出规则:
|
||||
- `GET /api/public/site-config` 只返回启用的 `hotelGroups` 和 `vehicleOptions`。
|
||||
- `GET /api/public/site-config` 只返回 `status="published"` 且 `isActive=true` 的 `hotelGroups`。
|
||||
- `GET /api/public/site-config` 只返回启用的 `vehicleOptions`。
|
||||
- 两个数组按后台 `sortOrder` 升序返回。
|
||||
- 字段缺失、数组为空或图片为空时,MiniAPP 使用 `src/content.ts` 的本地特色酒店/万趣用车内容兜底。
|
||||
- `hotelGroups` 字段缺失、数组为空或没有可用图片时,MiniAPP 使用 `src/content.ts` 的本地特色酒店内容兜底;酒店图片优先取 `coverImage`,再取 `image`。
|
||||
- `vehicleOptions` 字段缺失、数组为空或图片为空时,MiniAPP 使用 `src/content.ts` 的本地万趣用车内容兜底。
|
||||
|
||||
### `PublicProduct`
|
||||
|
||||
@@ -193,7 +213,7 @@ Public API 输出规则:
|
||||
| `ctaBanners` | `CtaBanner[]` | “更多服务”卡片配置 |
|
||||
| `campaigns` | `Campaign[]` | 活动元信息,可用于“特价优惠”入口;当前不包含活动产品结果列表 |
|
||||
| `routeSections` | `RouteSection[]` | “精选线路”子分组定义 |
|
||||
| `hotelGroups` | `HomeCard[]` | “特色酒店”卡片配置,只返回启用项 |
|
||||
| `hotelGroups` | `HotelCard[]` | “特色酒店”卡片配置,只返回 `published` 且启用项 |
|
||||
| `vehicleOptions` | `HomeCard[]` | “万趣用车”卡片配置,只返回启用项 |
|
||||
|
||||
#### 首页模块数据归属
|
||||
@@ -203,7 +223,7 @@ Public API 输出规则:
|
||||
| 特价优惠 | `site-config.campaigns` + `/api/public/products` | 当前 Public API 只返回活动元信息,不直接返回“特价优惠结果列表”。MiniAPP 若要展示活动线路,可按活动标题、标签或后续扩展的活动产品关联从 `/api/public/products` 中筛选。 |
|
||||
| 精选线路 | `site-config.routeSections` + `/api/public/products` | `routeSections` 返回动态分组与 `productIds`;具体产品卡片数据由 `/api/public/products.items` 提供。后台可按任务新增、删除、停用和排序分组,用户侧不假设固定三组。 |
|
||||
| 更多服务 | `site-config.ctaBanners` | 返回启用服务卡片,按后台排序展示;无有效配置时回退本地 `bottomCtas` 内容。 |
|
||||
| 特色酒店 | `site-config.hotelGroups` | 返回启用酒店卡片,按后台排序展示;无有效配置时回退本地内容。 |
|
||||
| 特色酒店 | `site-config.hotelGroups` | 返回 `published` 且启用的酒店卡片,按后台排序展示;MiniAPP 优先消费 `coverImage`,无有效配置时回退本地内容。 |
|
||||
| 万趣用车 | `site-config.vehicleOptions` | 返回启用用车卡片,按后台排序展示;无有效配置时回退本地内容。 |
|
||||
|
||||
#### 响应示例
|
||||
@@ -284,6 +304,11 @@ Public API 输出规则:
|
||||
"title": "经典酒店",
|
||||
"description": "城市接驳、景区度假和温泉休整,适合首游贵州的小包团动线。",
|
||||
"image": "/assets/guizhou/bailian-hot-spring.jpg",
|
||||
"coverImage": "/assets/guizhou/bailian-hot-spring.jpg",
|
||||
"priceAmount": 68000,
|
||||
"priceUnit": "起/晚",
|
||||
"tags": ["温泉", "亲子"],
|
||||
"status": "published",
|
||||
"isActive": true,
|
||||
"sortOrder": 0
|
||||
}
|
||||
@@ -476,7 +501,7 @@ Public API 输出规则:
|
||||
- “精选线路”由 `site-config.routeSections` 定义动态分组标题、副文案和商品 ID 顺序,由 `/api/public/products.items` 提供产品详情;客户端不依赖固定分组 ID 或固定三组数量。
|
||||
- `routeSections` 缺失、为空或无法匹配到有效商品时,MiniAPP 使用 `src/content.ts` 的本地精选线路内容回退。
|
||||
- `ctaBanners` 缺失或为空时,MiniAPP 使用 `src/content.ts` 的本地 `bottomCtas` 内容回退。
|
||||
- “特色酒店”和“万趣用车”分别由 `site-config.hotelGroups`、`site-config.vehicleOptions` 提供;字段缺失、数组为空或图片为空时使用本地内容兜底。
|
||||
- “特色酒店”和“万趣用车”分别由 `site-config.hotelGroups`、`site-config.vehicleOptions` 提供;特色酒店优先使用 `coverImage`,字段缺失、数组为空或图片为空时使用本地内容兜底。
|
||||
- “特价优惠”当前没有独立 Public 结果列表字段;`site-config.campaigns` 只提供活动元信息,活动线路需通过产品标签/关键词筛选或后续扩展活动产品关联字段。
|
||||
- 产品搜索当前主要在前端执行,依赖 `title`、`tags`、`destination.name`、`summary`。
|
||||
- 产品详情页当前使用已加载的产品列表数据;后续可改为进入详情页时请求 `GET /api/public/products/{product_id}`。
|
||||
@@ -489,7 +514,7 @@ Public API 输出规则:
|
||||
- 为 `GET /api/public/site-config` 验证返回 JSON 包含 `heroSlides`、`destinations`、`map`、`themes`、`ctaBanners`、`campaigns`、`routeSections`、`hotelGroups`、`vehicleOptions` 数组字段。
|
||||
- 为 `GET /api/public/site-config` 验证 `routeSections` 表达“精选线路”子分组;接口返回当前已配置且启用的分组,未配置时返回空数组并由 MiniAPP 本地内容兜底。
|
||||
- 为 `GET /api/public/site-config` 验证 `routeSections` 只返回启用分组,且 `productIds` 不包含未发布商品。
|
||||
- 为 `GET /api/public/site-config` 验证 `hotelGroups` 和 `vehicleOptions` 只返回启用卡片,并按 `sortOrder` 升序。
|
||||
- 为 `GET /api/public/site-config` 验证 `hotelGroups` 只返回 `published` 且启用卡片,包含 `coverImage`、价格和标签字段;验证 `vehicleOptions` 只返回启用卡片,并按 `sortOrder` 升序。
|
||||
- 为 `GET /api/public/products` 验证响应结构为 `{ items: [...] }`,并覆盖 `keyword`、`destinationId`、`status`、`take` 参数。
|
||||
- 为 `GET /api/public/products/{product_id}` 验证 UUID、数字 `sourceId` 和 404 场景。
|
||||
- 为 `GET /api/public/destinations` 验证只返回启用目的地及别名字段。
|
||||
|
||||
Reference in New Issue
Block a user