feat(backend): 开发订单管理和供应商管理功能

- 新增订单管理页面,实现订单列表展示、搜索、分页等功能
- 新增供应商管理页面,实现供应商列表展示、搜索、分页等功能- 添加订单和供应商相关模型及数据库迁移
- 实现订单状态更新和供应商信息编辑功能
- 优化后端路由结构,移除不必要的代码
This commit is contained in:
ylweng
2025-09-18 23:51:25 +08:00
parent 8637c05970
commit 5b6b50b60b
21 changed files with 3593 additions and 400 deletions

View File

@@ -4,11 +4,15 @@ info:
description: 订单管理相关接口文档
version: 1.0.0
servers:
- url: http://localhost:4330/api
description: 开发服务器
paths:
/api/orders/:
/orders/:
get:
summary: 获取订单列表
description: 获取系统中的订单列表,支持分页
description: 获取系统中的订单列表,支持分页和筛选
parameters:
- name: skip
in: query
@@ -24,15 +28,26 @@ paths:
schema:
type: integer
default: 100
- name: keyword
in: query
description: 搜索关键词(订单号)
required: false
schema:
type: string
- name: status
in: query
description: 订单状态筛选
required: false
schema:
type: string
enum: [pending, confirmed, processing, shipped, delivered, cancelled, returned, completed, archived]
responses:
'200':
description: 成功返回订单列表
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Order'
$ref: '#/components/schemas/PagedResponse'
'401':
description: 未授权
content:
@@ -45,6 +60,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth: []
post:
summary: 创建订单
description: 创建一个新的订单
@@ -53,7 +70,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/OrderCreate'
$ref: '#/components/schemas/CreateOrderRequest'
responses:
'200':
description: 成功创建订单
@@ -79,8 +96,10 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth: []
/api/orders/{order_id}:
/orders/{order_id}:
get:
summary: 获取订单详情
description: 根据订单ID获取订单详细信息
@@ -116,6 +135,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth: []
put:
summary: 更新订单信息
description: 根据订单ID更新订单信息
@@ -131,7 +152,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/OrderUpdate'
$ref: '#/components/schemas/UpdateOrderRequest'
responses:
'200':
description: 成功更新订单信息
@@ -163,6 +184,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth: []
delete:
summary: 删除订单
description: 根据订单ID删除订单
@@ -198,6 +221,66 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth: []
/orders/{order_id}/status:
patch:
summary: 更新订单状态
description: 根据订单ID更新订单状态
parameters:
- name: order_id
in: path
description: 订单ID
required: true
schema:
type: integer
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
status:
type: string
enum: [pending, confirmed, processing, shipped, delivered, cancelled, returned, completed, archived]
description: 订单状态
required:
- status
responses:
'200':
description: 成功更新订单状态
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
'404':
description: 订单未找到
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'401':
description: 未授权
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'422':
description: 请求参数验证失败
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
'500':
description: 服务器内部错误
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
security:
- bearerAuth: []
components:
schemas:
@@ -209,51 +292,75 @@ components:
description: 订单ID
order_no:
type: string
description: 订单号
description: 订单
buyer_id:
type: integer
description: 买家ID
seller_id:
supplier_id:
type: integer
description: 卖家ID
variety_type:
type: string
description: 品种类型
weight_range:
type: string
description: 重量范围
weight_actual:
description: 供应商ID
total_amount:
type: number
format: float
description: 实际重量
price_per_unit:
description: 订单总金额
advance_amount:
type: number
format: float
description: 单价
total_price:
description: 预付金额
final_amount:
type: number
format: float
description: 总价
advance_payment:
type: number
format: float
description: 预付款
final_payment:
type: number
format: float
description: 尾款
description: 尾款金额
status:
type: string
enum: [pending, confirmed, processing, shipped, delivered, cancelled, completed]
enum: [pending, confirmed, processing, shipped, delivered, cancelled, returned, completed, archived]
description: 订单状态
payment_status:
type: string
enum: [unpaid, partial_paid, fully_paid, refunded]
description: 支付状态
delivery_status:
type: string
enum: [pending, preparing, shipped, delivered, returned]
description: 发货状态
logistics_status:
type: string
enum: [pending, in_transit, delivered, exception]
description: 物流状态
quality_status:
type: string
enum: [pending, inspected, qualified, unqualified]
description: 质检状态
buyer_rating:
type: integer
description: 买家评分
buyer_comment:
type: string
description: 买家评论
supplier_rating:
type: integer
description: 供应商评分
supplier_comment:
type: string
description: 供应商评论
delivery_address:
type: string
description: 收货地址
delivery_time:
delivery_contact:
type: string
format: date-time
description: 交付时间
remark:
description: 收货联系人
delivery_phone:
type: string
description: 收货电话
expected_delivery_date:
type: string
format: date
description: 期望送达日期
actual_delivery_date:
type: string
format: date
description: 实际送达日期
notes:
type: string
description: 备注
created_at:
@@ -268,124 +375,158 @@ components:
- id
- order_no
- buyer_id
- seller_id
- variety_type
- weight_range
- price_per_unit
- total_price
- advance_payment
- final_payment
- supplier_id
- total_amount
- advance_amount
- final_amount
- status
- payment_status
- delivery_status
- logistics_status
- quality_status
- created_at
- updated_at
OrderCreate:
CreateOrderRequest:
type: object
properties:
buyer_id:
type: integer
description: 买家ID
seller_id:
supplier_id:
type: integer
description: 卖家ID
variety_type:
type: string
description: 品种类型
weight_range:
type: string
description: 重量范围
weight_actual:
description: 供应商ID
total_amount:
type: number
format: float
description: 实际重量
price_per_unit:
description: 订单总金额
advance_amount:
type: number
format: float
description: 单价
total_price:
description: 预付金额
final_amount:
type: number
format: float
description: 总价
advance_payment:
type: number
format: float
description: 预付款
final_payment:
type: number
format: float
description: 尾款
status:
type: string
enum: [pending, confirmed, processing, shipped, delivered, cancelled, completed]
description: 订单状态
description: 尾款金额
delivery_address:
type: string
description: 收货地址
delivery_time:
delivery_contact:
type: string
format: date-time
description: 交付时间
remark:
description: 收货联系人
delivery_phone:
type: string
description: 收货电话
expected_delivery_date:
type: string
format: date
description: 期望送达日期
notes:
type: string
description: 备注
required:
- buyer_id
- seller_id
- variety_type
- weight_range
- price_per_unit
- total_price
- supplier_id
- total_amount
- advance_amount
- final_amount
OrderUpdate:
UpdateOrderRequest:
type: object
properties:
buyer_id:
type: integer
description: 买家ID
seller_id:
supplier_id:
type: integer
description: 卖家ID
variety_type:
type: string
description: 品种类型
weight_range:
type: string
description: 重量范围
weight_actual:
description: 供应商ID
total_amount:
type: number
format: float
description: 实际重量
price_per_unit:
description: 订单总金额
advance_amount:
type: number
format: float
description: 单价
total_price:
description: 预付金额
final_amount:
type: number
format: float
description: 总价
advance_payment:
type: number
format: float
description: 预付款
final_payment:
type: number
format: float
description: 尾款
description: 尾款金额
status:
type: string
enum: [pending, confirmed, processing, shipped, delivered, cancelled, completed]
enum: [pending, confirmed, processing, shipped, delivered, cancelled, returned, completed, archived]
description: 订单状态
payment_status:
type: string
enum: [unpaid, partial_paid, fully_paid, refunded]
description: 支付状态
delivery_status:
type: string
enum: [pending, preparing, shipped, delivered, returned]
description: 发货状态
logistics_status:
type: string
enum: [pending, in_transit, delivered, exception]
description: 物流状态
quality_status:
type: string
enum: [pending, inspected, qualified, unqualified]
description: 质检状态
buyer_rating:
type: integer
description: 买家评分
buyer_comment:
type: string
description: 买家评论
supplier_rating:
type: integer
description: 供应商评分
supplier_comment:
type: string
description: 供应商评论
delivery_address:
type: string
description: 收货地址
delivery_time:
delivery_contact:
type: string
format: date-time
description: 交付时间
remark:
description: 收货联系人
delivery_phone:
type: string
description: 收货电话
expected_delivery_date:
type: string
format: date
description: 期望送达日期
actual_delivery_date:
type: string
format: date
description: 实际送达日期
notes:
type: string
description: 备注
PagedResponse:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Order'
total:
type: integer
description: 总记录数
skip:
type: integer
description: 跳过的记录数
limit:
type: integer
description: 返回的记录数
required:
- data
- total
- skip
- limit
Error:
type: object
properties:
@@ -393,4 +534,10 @@ components:
type: string
description: 错误信息
required:
- detail
- detail
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT