# API v1: 按 external_order_id 获取印染订单详情

## Endpoint

`GET /api/v1/printing-orders/by-external-order-id/{external_order_id}/`

用于通过外部订单编号精确查询本地印染订单详情，响应结构与 `GET /api/v1/printing-orders/{id}/` 使用同一个 `PrintingOrderDetailSerializer`。

## Path 参数

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `external_order_id` | string | 是 | 外部订单编号，对应 `PrintingOrder.external_order_id` |

## 权限

与 `printing-orders` ViewSet 保持一致：

- 用户必须已登录
- 用户必须属于印染工厂商户
- 用户需要具备 `printing.view_printingorder` 权限
- 仍受客户可见性过滤影响；拥有 `printing.view_all_printingorders` 可查看全部客户订单

## 成功响应

状态码：`200 OK`

```json
{
  "id": 123,
  "human_id": "20260626000123",
  "merchant_id": 1,
  "customer": 10,
  "customer_name": "测试客户",
  "customer_phone": "13900139000",
  "customer_area": "测试地区",
  "fabric": "通过外部编号查询",
  "width": "150cm",
  "external_order_id": "KD20410611",
  "external_customer_id": null,
  "external_customer_name": null,
  "external_employee_name": null,
  "is_invalid": false,
  "created_at": "2026-06-26T15:35:00+08:00",
  "updated_at": "2026-06-26T15:35:00+08:00"
}
```

实际返回字段以 `PrintingOrderDetailSerializer` 为准。

## 未找到

状态码：`404 Not Found`

```json
{
  "detail": "未找到该 external_order_id 对应的印染订单"
}
```

## 示例

```bash
curl -X GET "http://localhost:8100/api/v1/printing-orders/by-external-order-id/KD20410611/" \
  -H "Authorization: Bearer <token>"
```
