Skip to main content

Orders

Read and cancel customer orders (GetOrder, GetTracking, CancelOrder) and list a shopper's order history (ListOrdersByShopper).

📄️Introduction

REST contract of the customer-ordering bounded context of the retail network, derived from the retail-network model (warehouse-docs network/model/model.yaml, contexts[customer-ordering].rest) and adjusted by the final cross-context decisions (contracts-delta E7, E9, E11 and Gap Register G7, G10, G12, G25, and the storefront extension NG1-NG3: saved addresses, checkout by saved address, shopper by e-mail and the order history). It turns a shopper's cart into a customer order: checkout promises and confirms every shipment group at delivery-promise before the order is placed, the order carries the ship-to address (synthetic PII, held only here), the tracking view is fed by events, and a customer cancellation is a request that order-sourcing decides. One restricted in-organization route, GET /orders/{orderId}/ship-to, is called only by shipping-and-tracking to print a label and is the only route that returns the address. There is no authentication anywhere in the network; 'restricted' means the route is not exposed through the storefront edge. Errors are RFC 9457 problem details (application/problem+json) whose type is /problems/<slug>. The shared problem types are not-found (404), illegal-transition (409), concurrent-update (409) and validation-failed (422). A POST or PUT retried under the same Idempotency-Key is answered from the store only when its first answer is final for the request; see the Idempotency-Key parameter for the refusals that are not stored. Optional fields are omitted when absent, never null. The one exception is the read-only analytics reports (tag reports, ADR 0018): served by cmd/co-reports on its own port (per-path server) from the separate analytical database, snake_case, with explicit nulls where a figure has no defined value.

📄️Request the cancellation of every group that is not yet locked (creates a cancellation request)

CancelOrder is a request (G12, G25). Every group still PROMISED (no node locked yet) moves to CANCELLATION_REQUESTED and CustomerOrderCancelled is published through the outbox with those groupNos; locked, shipped and delivered groups are untouched. order-sourcing decides: FulfillmentCancelled makes the group CANCELLED (the order is CANCELLED once every group is), FulfillmentCancelRefused returns the group to fulfilment (the vendor ships; the shopper path becomes a return). Refused with 409 cancel-after-lock (ErrCancelAfterLock) when no group is unlocked. Repeating the request, or cancelling a CANCELLED order, returns the order unchanged and publishes nothing.

📄️Order-side KPIs per UTC day

Per UTC day (of placedAt, cancelledAt and decidedAt respectively), from this context's own events only: orders_placed (CustomerOrderPlaced); orders_cancelled (DISTINCT orders with a CustomerOrderCancelled request that day: a request, order-sourcing may still refuse it, and not a cohort of that day's placements); consolidated_tier_orders (placed orders with at least one CONSOLIDATED group, ADR 0013); pickup_point_orders (placed orders to a pickup point, ADR 0016); split_shipment_orders (placed orders with two or more shipment groups) and split_shipment_share = split_shipment_orders / orders_placed, null on a day without placed orders; shopper_notices_decided (ShopperNoticeDecided, ADR 0017, whatever the notifier) with shopper_notices_by_kind (at most 5 families, most frequent first, ties by family) and shopper_notices_other (the notices of the families left out, so the total is always exact). Days with none of these facts are omitted. The response carries the projection's freshness (the same as GET /reports/freshness).

📄️List a shopper's order history, newest first

ListOrdersByShopper. Keyset pagination: the page is ordered placedAt descending with the orderId as the ascending tiebreak, `limit` defaults to 100 and is at most 500, and `cursor` is the nextCursor of the previous page (opaque). A bad limit is 400 invalid-limit, an undecodable cursor is 400 invalid-cursor and any other query parameter is 400 unknown-query-parameter. An unknown shopper is 404 not-found; a shopper without orders is an empty page. The items never carry the ship-to address.

📄️Place a customer order, promising and confirming every shipment group

PlaceOrder. For each shipment group the service calls delivery-promise MakePromise (POST /promises) with the offer the shopper saw and then ConfirmPromise (POST /promises/{promiseId}/confirmations) before anything is stored. If an offer expired or was consumed, or a confirm fails, it re-quotes (QuoteDeliveryOffers, POST /delivery-quotes) and answers 409 offer-not-quotable with the new offers; no order is placed. On success the order is PLACED and CustomerOrderPlaced is published through the outbox in the same transaction. The order id is derived from the Idempotency-Key, so a retry after a timeout reuses the same promises.