出库附件
管理出库单附件:列表、上传、修改、删除,以及批量修改与批量删除。附件属于通用仓库出库 SOP:合作商在门户上传,仓库在 ERP 打印后才能标记备货完成。
所有附件端点使用 request-token 认证,并要求能力 outbound_attachment_upload(中间件按 api/v1/outbound/attachment/ 前缀匹配,列表与删除同样需要该能力)。
附件列表
/channel/api/v1/outbound/attachment/listAuth: request-token (channel_partner)
列出出库单的有效附件。仅返回属于当前伙伴请求的附件。返回时 print_types 已解码为数组,并附加最近一次打印任务状态。
所需能力: outbound_attachment_upload
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
request_id | integer | 是 | 出库单 ID(兼容别名 id) |
响应
{
"code": 200,
"msg": "success",
"data": [
{
"id": 9001,
"outbound_id": 5001,
"scope_type": "outbound",
"scope_id": 5001,
"document_code": "packing_list",
"paper_type": "A4",
"paper_width_mm": 210,
"paper_height_mm": 297,
"name": "packing-list.pdf",
"file_url": "https://cdn.example.com/e2c/tmp/packing-list.pdf",
"file_type": "pdf",
"file_size": 204800,
"print_enabled": 1,
"print_copies": 2,
"print_scale": "portrait",
"print_types": ["print"],
"uploaded_by_type": "partner",
"uploaded_by_id": 42,
"sort_order": 0,
"status": 1,
"latest_print_status": "pending",
"created_at": "2026-11-11 10:10:00",
"updated_at": "2026-11-11 10:10:00"
}
]
}错误码
| code | 含义 |
|---|---|
| 909 | 未认证、令牌无效或不属于渠道伙伴 |
| 606 | 能力不足(需要 outbound_attachment_upload) |
| 400 | request_id 缺失 |
| 404 | 出库单不存在,或不属于当前伙伴 |
| 500 | 读取附件失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/outbound/attachment/list' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"request_id": 1001
}'上传附件
/channel/api/v1/outbound/attachment/uploadAuth: request-token (channel_partner)
上传 PDF / JPG / JPEG / PNG 附件,最大 10MB。仅 draft / pending / pending_approval / approved 可上传;warehouse_confirmed 及之后的状态、以及 rejected / cancelled 均不可操作。
所需能力: outbound_attachment_upload
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
request_id | integer | 是 | 出库单 ID |
scope_type | string | 否 | outbound / package / product,默认 outbound |
scope_id | integer | 否 | 包裹 ID 或出库明细 ID;package / product 时必填,且必须属于该出库单 |
name | string | 是 | 文件名,扩展名决定文件类型 |
file_url | string | 是* | 已上传文件地址 |
base64 | string | 是* | Base64 内容,支持 data:*;base64, 前缀 |
file_size | integer | 否 | 文件大小(字节);使用 base64 时以实际解码大小为准 |
document_code | string | 否 | 单据类型,默认 other,超长静默截断至 32 字符 |
paper_type | string | 否 | 纸张类型,默认 A4,超长静默截断至 32 字符 |
paper_width_mm | number | 否 | 纸张宽度(mm),默认 0,超出范围会被 clamp 到 0–2000 |
paper_height_mm | number | 否 | 纸张高度(mm),默认 0,超出范围会被 clamp 到 0–2000 |
print_enabled | boolean | 否 | 是否进入打印队列,默认 false |
print_copies | integer | 否 | 打印份数,默认 1 |
print_scale | string | 否 | portrait / landscape,默认 portrait |
print_types | string[] | 否 | print、e_sign、return_required,默认 [] |
sort_order | integer | 否 | 排序值,默认 0 |
* file_url 与 base64 必须提供且只提供一个。
响应
返回新建的附件记录。注意:上传响应中的 print_types 仍为 JSON 字符串,列表接口会解码为数组。
{
"code": 200,
"msg": "success",
"data": {
"id": 9001,
"outbound_id": 5001,
"scope_type": "outbound",
"scope_id": 5001,
"document_code": "packing_list",
"paper_type": "A4",
"paper_width_mm": 210,
"paper_height_mm": 297,
"name": "packing-list.pdf",
"file_url": "https://cdn.example.com/e2c/tmp/packing-list.pdf",
"file_type": "pdf",
"file_size": 204800,
"print_enabled": 1,
"print_copies": 2,
"print_scale": "portrait",
"print_types": "[\"print\"]",
"uploaded_by_type": "partner",
"uploaded_by_id": 42,
"sort_order": 0,
"status": 1,
"created_at": "2026-11-11 10:10:00",
"updated_at": "2026-11-11 10:10:00"
}
}错误码
| code | 含义 |
|---|---|
| 909 | 未认证、令牌无效或不属于渠道伙伴 |
| 606 | 能力不足(需要 outbound_attachment_upload) |
| 400 | 状态已锁定(warehouse_confirmed 及之后)、文件名缺失、扩展名不允许、file_url 与 base64 均缺失、Base64 非法、超过 10MB、scope_type 非法、scope_id 缺失或不属于该出库单 |
| 500 | 文件上传或落库失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/outbound/attachment/upload' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"request_id": 1001,
"scope_type": "outbound",
"name": "packing-list.pdf",
"base64": "JVBERi0xLjQK...",
"document_code": "packing_list",
"paper_type": "A4",
"print_enabled": true,
"print_copies": 2,
"print_scale": "portrait",
"print_types": [
"print"
]
}'修改附件
/channel/api/v1/outbound/attachment/updateAuth: request-token (channel_partner)
仅修改附件的打印参数与纸张信息,不替换文件。合作商只能修改自己上传的附件。仅 draft / pending / pending_approval / approved 可修改;warehouse_confirmed 及之后的状态、以及 rejected / cancelled 均不可操作。
所需能力: outbound_attachment_upload
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
request_id | integer | 是 | 出库单 ID |
attachment_id | integer | 是 | 附件 ID(兼容别名 id) |
document_code | string | 否 | 单据类型,超长静默截断至 32 字符 |
paper_type | string | 否 | 纸张类型,超长静默截断至 32 字符 |
paper_width_mm | number | 否 | 纸张宽度(mm),超出范围会被 clamp 到 0–2000 |
paper_height_mm | number | 否 | 纸张高度(mm),超出范围会被 clamp 到 0–2000 |
print_enabled | boolean | 否 | 是否进入打印队列 |
print_copies | integer | 否 | 打印份数,1–99 |
print_scale | string | 否 | portrait / landscape |
print_types | string[] | 否 | print、e_sign、return_required |
未提供任何可更新字段时直接返回当前附件,不报错。
响应
返回更新后的附件记录,print_types 为 JSON 字符串。
{
"code": 200,
"msg": "success",
"data": {
"id": 9001,
"outbound_id": 5001,
"scope_type": "outbound",
"scope_id": 5001,
"document_code": "packing_list",
"paper_type": "A4",
"paper_width_mm": 210,
"paper_height_mm": 297,
"name": "packing-list.pdf",
"file_url": "https://cdn.example.com/e2c/tmp/packing-list.pdf",
"file_type": "pdf",
"file_size": 204800,
"print_enabled": 1,
"print_copies": 3,
"print_scale": "portrait",
"print_types": "[\"print\",\"e_sign\"]",
"uploaded_by_type": "partner",
"uploaded_by_id": 42,
"sort_order": 0,
"status": 1,
"created_at": "2026-11-11 10:10:00",
"updated_at": "2026-11-11 10:20:00"
}
}错误码
| code | 含义 |
|---|---|
| 909 | 未认证、令牌无效或不属于渠道伙伴 |
| 606 | 能力不足(需要 outbound_attachment_upload) |
| 400 | 状态已锁定、只允许修改自己上传的附件 |
| 404 | 附件不存在或不属于该出库单 |
| 500 | 更新失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/outbound/attachment/update' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"request_id": 1001,
"attachment_id": 9001,
"print_enabled": true,
"print_copies": 3,
"print_types": [
"print",
"e_sign"
]
}'删除附件
/channel/api/v1/outbound/attachment/deleteAuth: request-token (channel_partner)
软删除合作商上传的附件(status 置为 0)。该端点不校验出库单状态;合作商只能删除自己上传的附件。
所需能力: outbound_attachment_upload
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
request_id | integer | 是 | 出库单 ID |
attachment_id | integer | 是 | 附件 ID(兼容别名 id) |
响应
{
"code": 200,
"msg": "success",
"data": null
}错误码
| code | 含义 |
|---|---|
| 909 | 未认证、令牌无效或不属于渠道伙伴 |
| 606 | 能力不足(需要 outbound_attachment_upload) |
| 400 | 只允许删除自己上传的附件 |
| 404 | 附件不存在或不属于该出库单 |
| 500 | 删除失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/outbound/attachment/delete' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"request_id": 1001,
"attachment_id": 9001
}'批量修改附件
/channel/api/v1/outbound/attachment/batch-updateAuth: request-token (channel_partner)
批量修改多个附件的打印参数。可操作状态为 draft / pending / pending_approval / approved / warehouse_confirmed;rejected / cancelled 不可操作。仅统计并更新属于合作商自己的附件,其余行被跳过。
所需能力: outbound_attachment_upload
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
request_id | integer | 是 | 出库单 ID |
attachment_ids | integer[] | 是 | 附件 ID 数组,不能为空 |
document_code | string | 否 | 单据类型,超长静默截断至 32 字符 |
paper_type | string | 否 | 纸张类型,超长静默截断至 32 字符 |
paper_width_mm | number | 否 | 纸张宽度(mm),超出范围会被 clamp 到 0–2000 |
paper_height_mm | number | 否 | 纸张高度(mm),超出范围会被 clamp 到 0–2000 |
print_enabled | boolean | 否 | 是否进入打印队列 |
print_copies | integer | 否 | 打印份数,1–99 |
print_scale | string | 否 | portrait / landscape |
print_types | string[] | 否 | print、e_sign、return_required |
响应
{
"code": 200,
"msg": "success",
"data": {
"updated": 2
}
}updated 为实际更新的附件数量;不属于当前合作商或不属于该出库单的 ID 不会计入。
错误码
| code | 含义 |
|---|---|
| 909 | 未认证、令牌无效或不属于渠道伙伴 |
| 606 | 能力不足(需要 outbound_attachment_upload) |
| 400 | request_id 或 attachment_ids 缺失、状态已锁定 |
| 404 | 出库单不存在,或不属于当前伙伴 |
| 500 | 批量更新失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/outbound/attachment/batch-update' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"request_id": 1001,
"attachment_ids": [
9001,
9002
],
"print_enabled": true,
"print_copies": 1,
"print_types": [
"print"
]
}'批量删除附件
/channel/api/v1/outbound/attachment/batch-deleteAuth: request-token (channel_partner)
批量软删除合作商上传的附件。该端点不校验出库单状态;不属于当前合作商或已不存在的附件会被跳过。
所需能力: outbound_attachment_upload
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
request_id | integer | 是 | 出库单 ID |
attachment_ids | integer[] | 是 | 附件 ID 数组,不能为空 |
响应
{
"code": 200,
"msg": "success",
"data": {
"deleted": 2
}
}deleted 为实际删除的附件数量;无权限或不存在的行被静默跳过。
该端点仅捕获最终异常,因此 request_id 不存在或不属于当前伙伴时返回 500(而非 404)。
错误码
| code | 含义 |
|---|---|
| 909 | 未认证、令牌无效或不属于渠道伙伴 |
| 606 | 能力不足(需要 outbound_attachment_upload) |
| 400 | request_id 或 attachment_ids 缺失 |
| 500 | 批量删除失败 |
cURL
curl -X POST 'https://apigate.e2c-energy.com/channel/api/v1/outbound/attachment/batch-delete' \
-H 'request-token: YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"request_id": 1001,
"attachment_ids": [
9001,
9002
]
}'