---
name: meitu-pack-same-product-group
description: >-
  Packs Meitu ERP orders that share the same product (lineId) into a new tour
  group via cloud MCP pack_orders_to_group. Default window: travel dates in the
  next 3 calendar days (today .. today+2, Asia/Shanghai). Use when the user asks
  to 拼团 / 组团 / 把相同产品的订单拼成团.
---

# Meitu · 同产品订单拼团

将**同一线路产品**、**同一出行日起**、尚未成团的订单，通过 MCP 拼成新团。

## Prerequisites

1. Meitu Cloud MCP + PAT：`https://service.meitu.io/api/mcp`
2. Token 权限含：`orders.list`、`orders.get`（可选）、`groups.pack`；若需先确认订单则还需 `orders.update_status`
3. 写操作必须 `confirm: true`
4. Do **not** embed tokens in this skill or commit them

Docs: https://meitu.io/mcp

## Defaults（用户未另行指定时）

| 项 | 默认 |
|----|------|
| 日期窗口 | **未来 3 天**：`travelStartDate` ∈ `[今天, 今天+2]`（含首尾，时区 `Asia/Shanghai`） |
| 产品 | 用户给出的 `productId` / `lineId`；若只给名称则先 `list_products` 解析 |
| 成团方式 | `isNewGroup=true`（新建散拼团） |
| 未成团 | `hasGroup=0` |
| 订单状态 | 仅 **已确认** `orderStatus=3`（服务端拼团强制要求） |
| 最小笔数 | 同一出行日起 ≥ **2** 笔才自动拼团；仅 1 笔时询问用户是否仍要建团 |

## Workflow

```
- [ ] 1. Resolve productId (lineId)
- [ ] 2. Compute date window (default next 3 days)
- [ ] 3. list_orders: lineId + hasGroup=0 + orderStatus=3 + travelStartDateStart/End
- [ ] 4. Group rows by travelStartDate (same product already filtered)
- [ ] 5. For each cohort (≥2 orders): pack_orders_to_group (confirm=true)
- [ ] 6. Report groupId / skipped cohorts / errors
```

### 1. Resolve product

- User gives `productId` / `lineId` → use it.
- Or name keyword → `list_products` (`keyword` / `lineName`) → confirm one `lineId`.
- Optional: `get_product` for `lineDays` to sanity-check end dates.

### 2. Date window

```
today = Asia/Shanghai calendar date
start = today
end   = today + 2 days   # 共 3 个自然日
```

User may override (`未来一周` / 明确起止日期)。**不要**把「下单创建日」当成出行日；筛选字段是 `travelStartDateStart` / `travelStartDateEnd`。

### 3. List candidate orders

MCP `list_orders`（可分页直到取完）：

```json
{
  "lineId": <productId>,
  "hasGroup": 0,
  "orderStatus": 3,
  "travelStartDateStart": "<yyyy-MM-dd start>",
  "travelStartDateEnd": "<yyyy-MM-dd end>",
  "page": 1,
  "size": 100
}
```

Rules:

- Skip cancelled (`orderStatus=4`) — already excluded by status=3.
- Skip rows without `productId` / `lineId` match.
- If list is empty: report and stop (do not invent orders).
- If many draft orders (`orderStatus=1`) match the date/product but are not confirmed: call MCP `batch_update_order_status` with `orderStatus=3` and `confirm=true` **only when the user asks** to confirm then pack.

### 4. Bucket by travel start

Same product **must** share the **same** `travelStartDate` in one pack call (server rule).

```
cohorts = group by yyyy-MM-dd(travelStartDate)
```

### 5. Pack each cohort

For each cohort with ≥2 `orderId`s (or ≥1 after user OK):

MCP `pack_orders_to_group`:

```json
{
  "orderIds": [<id>, ...],
  "startDate": "<cohort travelStartDate yyyy-MM-dd>",
  "endDate": "<max travelEndDate in cohort, or start + lineDays - 1>",
  "isNewGroup": true,
  "lineId": <productId>,
  "groupName": "可选：线路名+日期",
  "confirm": true
}
```

Notes:

- **线路散拼**：必须带 `lineId`；不要与定制游(`groupType=4`) / 包团(`groupType=3`) 混拼。
- 若 cohort 全是定制游：`isNewGroup=true`，可省略 `lineId`，但需订单上已有行程；本 Skill **默认面向同产品线路单**，遇到定制单请改走定制拼团说明或跳过并报告。
- Do not set `isNewGroup=false` unless user names an existing `groupId`.

### 6. Report

Return for each cohort:

- `groupId`（成功）
- `orderIds` 数量与出行日
- 跳过原因（不足 2 笔 / 未确认 / 混类型 / API 错误）

ERP 团单：`https://app.meitu.io/` 团控/团单详情（以贵司路由为准）；可用 `get_group` 校验。

## Compliance

- Prefer dry-run list + summarize before `confirm=true` pack when the user did not say「直接拼团」.
- Never paste PAT into skills, repos, or public pages.

## More

- Field & tool reference: [reference.md](./reference.md)
- Pack index: https://meitu.io/skills/index.json
