# 订单履约与交付看板 · 接口清单

约定：统一走站点数据访问层；错误返回 `{ code, message }`；所有写接口需带身份标识。

## 1. 订单

### 创建订单
`POST /order`
```json
{
  "source": "rfq|sample|quote|material",
  "rfqId": "string|null",
  "sampleId": "string|null",
  "quoteId": "string|null",
  "supplierId": "string",
  "orderType": "pcb|sample|material|test",
  "totalAmount": 12800,
  "currency": "CNY",
  "promiseLeadDays": 7,
  "remark": "string"
}
```
返回 `{ id, orderSn, status: "submitted" }`

### 列表
`GET /order?role=buyer|supplier&status=&keyword=&page=1&pageSize=20` → `{ list, total }`

### 详情
`GET /order/{id}` → `{ order, lots, processes, ships, checkbill, sla }`

### 状态流转
`POST /order/{id}/status`
```json
{ "to": "scheduled|in_production|testing|ready_to_ship|shipped|received|reconciling|completed|on_hold|rework|cancelled", "note": "string" }
```
约束：首件未通过时 `first_article → in_production` 返回 `ORDER_FIRST_ARTICLE_PENDING`。

### 导出
`GET /order/{id}/export` → 订单明细（含工艺要求、批次、交期）。

## 2. 批次 Lot

`POST /order/{id}/lot` → `{ lotNo, qtyTotal }`
`GET /order/{id}/lot` → `Lot[]`
`POST /order/lot/{lotId}/close` → `{ qtyGood, qtyDefect, note }`

## 3. 排产

`GET /order/schedule/calendar?supplierId=&from=&to=` → 设备/班组占用
`POST /order/schedule/{lotId}` → `{ equipment, team, startDate, endDate, priority }`

## 4. 工序报工

`POST /order/lot/{lotId}/process`
```json
{
  "processCode": "inner_layer|lamination|outer_layer|solder_mask|surface_finish|drilling|profile|flying_probe|aoi|final_check|packing|engineering",
  "operator": "string",
  "startAt": "2026-11-15 08:00",
  "finishAt": "2026-11-15 12:00",
  "qtyIn": 500,
  "qtyDefect": 3,
  "inspection": "pass|fail|conditional",
  "note": "string",
  "picUrls": ["string"]
}
```
错误码：`ORDER_PROCESS_ORDER_INVALID`、`ORDER_QTY_INVALID`、`ORDER_LOT_LOCKED`。

`GET /order/lot/{lotId}/process` → 工序时间线

## 5. 首件

`POST /order/lot/{lotId}/first-article` → `{ images: [], dimReport: "string", impedanceReport: "string" }`
`POST /order/lot/{lotId}/first-article/confirm` → `{ result: "pass|reject", reason: "string" }`
错误码：`ORDER_FA_REASON_REQUIRED`

## 6. 发货与物流

`POST /order/{id}/ship` → `{ lotId, carrier, trackingNo, qty, shipAt }`
`POST /order/ship/{shipId}/receive` → `{ receiveAt, inspection: "pass|fail", note }`

## 7. 对账

`POST /order/{id}/checkbill` → `{ items: [{ lotNo, qty, unitPrice, deduction, reason }], total }`
`GET /order/{id}/checkbill` → 对账明细与扣款依据

## 8. 预警

`GET /order/warn?supplierId=&level=` → `[{ orderId, lotNo, slaExpireAt, hoursLeft, reason }]`

## 9. 边界

- 不含支付、退款、分账接口；结算状态仅记录。
- 不含承运商轨迹订阅接口；物流轨迹以人工录入节点呈现。
- 附件走对象存储，未开通时仅保存文件名。