Files
vmall/docs/code_index/order.md
T
Chengdong ZhangandCursor cc9a522589 feat(orders): provision paid services through shop tasks
Payment opens one provision task and a pending subscription. Delivery completes the order, a cancelled claim reopens it, and renewal records the chosen term without taking anchor stock.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 16:44:36 +08:00

5.2 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, direct purchase, configured direct purchase with expected-total 409, or subscription renewal), payment membership, header-hash idempotency, legacy service start/deliver (409), 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/provisioning/ manual provision/suspend/resume/terminate tasks, delivery, SLA, provisioning:manage grants, audit
src/modules/subscription/ subscription rows, payment hook, renewal extension, buyer/shop reads, lifecycle worker
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
migrations/0029_pricing.sql order item configuration, quote_snapshot, pricing_rule_id
migrations/0030_service_provisioning.sql subscriptions, provisioning tasks, shop permissions, SLA, delivery message kinds
migrations/0031_provision_task_replacement.sql provision uniqueness ignores cancelled tasks so a replacement can be opened
tests/orders.rs, tests/freight.rs, tests/payments.rs, tests/fulfillment_kinds.rs, tests/pricing.rs, tests/provisioning.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, provisioning task/permission/SLA methods, listMySubscriptions. Order.shipping_address is null for a provisioned service; fulfillment_kind, contact, and delivery_note describe that order. A configured line stores configuration, quote_snapshot, and pricing_rule_id; checkout accepts that configuration, expected_total_minor, and renew_subscription_id. Subscription and ProvisioningTask are the service records.

Frontends

  • Mall: pages/checkout/{index,pay,success}.vue (direct mode skips address, freight, and coupons; a configured purchase sends the quote and re-confirms a 409; renewal sends renew), pages/goods/[id].vue (service buy-now), pages/user/orders/, pages/user/services.vue, 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 orders link to provisioning), pages/provisioning/, 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)