feat: add party-size queueing and call modes

This commit is contained in:
wangxuming
2026-07-16 11:40:34 +08:00
parent 7f751bebae
commit 66951b4dc3
53 changed files with 3348 additions and 533 deletions

View File

@@ -31,10 +31,26 @@ seed command against production.
`POST /api/staff/projects/{id}/tickets` and
`POST /api/staff/projects/{id}/call-next` require an `Idempotency-Key` header.
Ticket creation requires an immutable integer `party_size` inside the project's
configured `min_party_size` / `max_party_size` range. A call-next request uses
`{ "expected_revision": 12, "mode": "TICKET|PEOPLE", "count": 5 }`.
`TICKET` selects up to `count` consecutive FIFO tickets. `PEOPLE` selects the
longest consecutive FIFO prefix whose total party size does not exceed `count`;
it never splits or skips a ticket and rejects when the first ticket alone is
larger than the requested target. Each mode has a separate project-level
anti-mistouch maximum.
If a phone already has active tickets, ticket creation returns
`DUPLICATE_PHONE`; repeat with the same request body except
`allow_duplicate: true` and a new idempotency key after the employee confirms.
`GET /api/public/projects` returns projects currently open for visitor
self-service, including each project's allowed party-size range.
`POST /api/public/projects/{id}/tickets` uses the same ticket
validation, queue locking and idempotency rules as the staff ticket flow, but
returns only the public ticket projection and a private status token. Public
ticket creation is rate-limited and audited as `PUBLIC_TICKET_CREATED`.
`POST /api/public/status/search` is a temporary non-production operational-test
endpoint. It accepts `{ "phone": "..." }` and returns all current active
tickets associated with that phone. It is disabled when `APP_ENV=production`;
@@ -50,6 +66,7 @@ go vet ./...
From the repository root, `make test-db` creates a disposable PostgreSQL
database and runs migration/maintenance integration tests.
Unit tests cover ETA, phone normalization, authenticated encryption, token
hashing and password hashing. PostgreSQL integration tests run through
Unit tests cover FIFO ticket/people selection, people-ahead ETA, phone
normalization, authenticated encryption, token hashing and password hashing.
PostgreSQL integration tests run through
`make test-db` against a disposable database.