feat: backend MVP (auth/rbac, catalog, orders, fulfillment, invoices) + specs + scaffolds

This commit is contained in:
Chengdong Zhang
2026-09-17 12:43:22 +08:00
commit dc9fd31c5e
96 changed files with 17550 additions and 0 deletions
@@ -0,0 +1,21 @@
# Spec delta: invoice
## ADDED Requirements
### Requirement: Invoice request
Customers SHALL request at most one open invoice (发票) per order, with title, kind (`personal | company`), and tax_no required for company invoices. Amount equals the order total in the order currency.
#### Scenario: company invoice requires tax number
- **WHEN** requesting a company invoice without tax_no
- **THEN** the API returns 400
#### Scenario: duplicate rejected
- **WHEN** an order already has a requested or issued invoice
- **THEN** a second request returns 409
### Requirement: Invoice issuance
Merchants SHALL issue requested invoices of their own shop's orders; issuing sets invoice_no, issued_at and status `issued`.
#### Scenario: issue flow
- **WHEN** the shop issues a requested invoice
- **THEN** the customer sees status `issued` with an invoice number
@@ -0,0 +1,23 @@
# Spec delta: shipment
## ADDED Requirements
### Requirement: Shipment creation
Merchants SHALL create shipments (发货单) for their own orders in `paid` or `fulfilling` status, specifying carrier, tracking_no and per-item quantities.
#### Scenario: partial shipment
- **WHEN** an order has 3 units of item X and a shipment covers 2
- **THEN** a later shipment may cover the remaining 1; requesting more than the remainder returns 400
#### Scenario: status propagation
- **WHEN** the first shipment is created for a paid order
- **THEN** the order becomes `fulfilling`
- **WHEN** all ordered quantities are covered by shipped shipments
- **THEN** the order becomes `shipped`
### Requirement: Delivery confirmation
Customers SHALL confirm delivery of their own shipments; when every shipment of an order is delivered the order becomes `completed`.
#### Scenario: confirm delivered
- **WHEN** the customer confirms the only shipment of a shipped order
- **THEN** shipment becomes `delivered` and the order `completed`