Files
vmall/docs/code_index/order.md
T
Chengdong ZhangandCursor 42579441fd feat(orders): sell provisioned services outside the physical cart
A service is bought directly and completed by the shop, without freight, promotions, or shipments. Quotes and threshold previews ignore leftover service lines, and a service after-sale offers refund only.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 12:48:18 +08:00

4.1 KiB

Index: Order & Freight

Domain design: docs/domains/orders.md. Specs: openspec/specs/order/, shipment/, shipping/, payment/ (change add-configurable-payments).

Backend (apps/api)

File Holds
src/modules/order/service.rs checkout transaction (cart or direct purchase, payment membership, header-hash idempotency), service start/deliver, cancel, shipping quote
src/modules/order/repo.rs ORDER_COLS/ORDER_ITEM_COLS, insert_order/insert_item, locks, status transitions
src/modules/order/handlers.rs /orders* customer routes, /shop/orders*, /admin/orders
src/modules/order/dto.rs OrderView, AddressBody, ShippingQuoteView
src/modules/payment/service.rs payment resolution, eligible methods, attempts, wallet collection, group cancellation
src/modules/payment/repo.rs payments/memberships/checkout_requests/attempts/receipts/refunds/commands/events rows
src/modules/payment/adapters.rs wallet + Stripe crypto-only Checkout adapter boundary, capabilities
src/modules/payment/worker.rs durable command lease/execute/recovery, supervised worker
src/modules/payment/webhooks.rs raw-body Stripe signature/timestamp verification, dedup inbox
src/modules/payment/refunds.rs original-method refund budgets, wallet/Stripe refund submission
src/modules/payment/admin.rs channel CRUD/revisions/audit/verify, operations list/detail, reconcile
src/modules/payment/handlers.rs /payments* owner routes, /admin/payments*, /payments/webhooks/stripe/{id}
src/modules/payment/dto.rs payment DTOs, text enums, config shapes
src/modules/fulfillment/ shipments for physical orders only: create (company-validated), ship, confirm-delivered
src/modules/freight/service.rs template CRUD, region rules, shop_fee() calculation, company dictionary
src/modules/freight/handlers.rs /shop/freight-templates*, /shipping/companies
migrations/0004_orders.sql orders/order_items/shipments base schema
migrations/0017_freight_templates.sql freight tables, orders.shipping_fee_minor, item snapshots, skus.weight_grams
migrations/0024_payments.sql payments domain, legacy-demo provenance, aftersale refund states
migrations/0025_checkout_request_header_hash.sql cart-independent header hash for checkout idempotency
migrations/0026_threshold_promotions.sql threshold rules, orders.threshold_promotion_id, coupon/threshold exclusivity check
migrations/0028_fulfillment_kinds.sql fulfillment_kind, order contact/details/delivery note, nullable shipping address
tests/orders.rs, tests/freight.rs, tests/payments.rs, tests/fulfillment_kinds.rs integration coverage

Shared contract (packages/shared/src)

types.ts: Order, OrderItem, Shipment, FreightTemplate*, ShippingCompany, ShippingQuote, Payment, CheckoutResult, PaymentAttemptResult, EligibleMethod, NextAction, PaymentChannel*, PaymentOperation*, RefundOperation. api.ts: checkout, resolvePayment, getPayment, listPaymentMethods, createPaymentAttempt, cancelPayment, quoteShipping, listShippingCompanies, shop freight CRUD, createShipment, shop.startFulfilment, shop.deliverService, admin channel/operations/reconcile methods. Order.shipping_address is null for a provisioned service; fulfillment_kind, contact, and delivery_note describe that order.

Frontends

  • Mall: pages/checkout/{index,pay,success}.vue (direct mode skips address, freight, and coupons), pages/goods/[id].vue (service buy-now), pages/user/orders/, pages/user/addresses.vue
  • Mobile: pages/checkout/, pages/orders/ (configured payment + return handling; service orders show contact and hide shipments), pages/product/[id].vue (service purchase disabled)
  • Shop-admin: pages/orders/ (service start-fulfilment and deliver), pages/shipments.vue, pages/freight-templates.vue, components/ProductForm.vue (fulfillment kind, freight template, SKU weight)
  • Admin: pages/orders.vue (read-only), pages/payment-channels.vue, pages/payments.vue (operations list/detail/reconcile)