Files
vmall/openspec/specs/shop-coupons/spec.md
T
james cc07ac3230 chore(openspec): archive add-shop-coupons
Sync the shop-coupons capability plus the order, frontend-mall, and
frontend-shop-admin requirements into the main specs, and write the capability
Purpose the archive leaves as a placeholder.

Renaming the coupon scenario in the flash-sales and group-buying order deltas
to the exact name now in the main order spec keeps those changes archivable,
since a MODIFIED requirement replaces the whole block.
2026-09-18 12:13:49 +00:00

2.2 KiB

shop-coupons Specification

Purpose

Let a shop issue its own coupons and a customer claim and redeem them. A template owns the offer, window, and claim stock; claiming copies the terms into a customer-owned snapshot so later edits cannot rewrite a held coupon. Checkout redeems at most one owned coupon per generated shop order, applies a server-calculated discount, and restores the coupon when a pending-payment order is cancelled. Activity-priced shop orders reject coupons rather than stack.

Requirements

Requirement: Shop coupon template management

A shop_owner or shop_staff SHALL create, list, update, disable, and delete only that shop's coupon templates. A template SHALL contain localized title, fixed amount_minor, threshold_minor, enabled ISO currency, non-negative claim stock, and an inclusive active window; amount MUST be positive and threshold MUST NOT be negative.

Scenario: cross-shop template is hidden

  • WHEN a shop user requests or mutates another shop's coupon template
  • THEN the API returns 404

Requirement: Customer coupon claim and listing

An authenticated customer SHALL list owned coupons and claim an active template at most once. Claiming SHALL atomically create a user-held snapshot and decrement claim stock only when stock remains; listing SHALL distinguish claimed, redeemed, and expired coupons.

Scenario: concurrent final claim

  • WHEN two customers claim the final remaining template instance concurrently
  • THEN exactly one claim succeeds and the other receives 409

Requirement: Coupon redemption lifecycle

A claimed coupon SHALL be redeemable only by its owner, for its issuing shop, within its snapshot window, and when the shop-order subtotal reaches its snapshot threshold. Redemption SHALL bind the coupon to one order; cancellation of that pending-payment order SHALL restore it to claimed. Later activity-priced shop orders (flash sale or group buy) SHALL NOT redeem a coupon; those changes restated this exclusion on checkout.

Scenario: cancelled order restores coupon

  • WHEN a customer cancels a pending-payment order redeemed with a coupon
  • THEN the coupon again has claimed status and no order binding