1
0
forked from erp-dev/erp

feat: retry haobuye sync order

This commit is contained in:
2026-04-07 16:56:46 +08:00
parent ebd687ccdd
commit 76ea445880
15 changed files with 1098 additions and 118 deletions

View File

@@ -1,6 +1,6 @@
# SalesItem 修改与删除 API 文档
本文档说明 `SalesItem` 销售品的修改与软删除接口。
本文档说明 `SalesItem` 销售品的修改、重建与软删除接口。
## 修改接口
@@ -91,6 +91,105 @@
}
```
## 重建接口
### 接口信息
- URL: `/api/v1/shipment/sales-items/{id}/rebuild/`
- Method: `POST`
- 认证: 需要登录JWT Token
说明:
- 该接口本质上等同于“软删除旧销售品 + 基于新的 `printing_job` 重建一个新销售品”
- 只有旧销售品的 `created_by` 本人才能执行这个操作
- 新销售品会保留旧销售品的 `created_by`
- 旧销售品若已关联出货单,则不允许重建
### 请求体
```json
{
"new_printing_job_id": 456,
"quantity": "66.50"
}
```
字段说明:
- `new_printing_job_id`: 必填,新的生产任务 ID
- `quantity`: 可选,新的数量;未传时沿用旧销售品数量
### 成功响应示例
```json
{
"detail": "销售品已重建",
"old_sales_item_id": 15,
"new_sales_item_id": 18,
"rebuild_record_id": 3,
"data": {
"id": 18,
"name": "测试销售品",
"quantity": "66.50",
"unit": 1,
"unit_display": "米",
"position": "A3-02",
"remark": "补充备注",
"printing_job_id": 456,
"printing_order_id": 80,
"external_order_id": "EXT-2026-010",
"customer_id": 8,
"customer_name": "客户A",
"shipment_id": null,
"shipment_date": null,
"created_at": "2026-04-06T16:00:00+08:00",
"created_by_id": 3,
"created_by_name": "测试员工",
"product_image_url": null
}
}
```
### 重建审计记录
每次成功重建时,会新增一条 `SalesItemRebuildRecord`,记录:
- `old_sales_item`
- `new_sales_item`
- `operator`
- `rebuilt_at`
- `old_printing_job_id`
- `new_printing_job_id`
- `old_quantity`
- `new_quantity`
### 错误响应示例
#### 1. 不是原创建者
```json
{
"detail": "只有销售品创建者才能执行重建"
}
```
#### 2. 旧销售品已关联出货单
```json
{
"detail": "已关联出货单的销售品不允许删除"
}
```
#### 3. 新生产任务无效
```json
{
"detail": "生产任务 999 不存在或不属于当前商户"
}
```
## 删除接口
### 接口信息