Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d6b265fd2 | ||
|
|
d56d0c3450 | ||
|
|
a64ba1ad63 | ||
|
|
da5b76069c | ||
|
|
09dab5a40b | ||
|
|
7c1b986289 | ||
|
|
17126c92e3 | ||
|
|
43b01c84bf | ||
|
|
58d764a175 | ||
|
|
2d95dc203c | ||
|
|
3597adb94c | ||
|
|
1d71b9122c |
No files matched your search
@@ -0,0 +1,238 @@
|
||||
<title>Co-Lite Blueprint</title>
|
||||
<meta name="claude:viewport-fit-sides" content="cover">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&family=Space+Grotesk:wght@500;700&display=swap">
|
||||
<style>
|
||||
/* Layout: one reading column on a faint drafting grid; sections read top to bottom as now, next, later. */
|
||||
:root {
|
||||
--bg: #f4f7fb; --panel: #ffffff; --fg: #142235; --muted: #5a6b80; --line: #d3dce8;
|
||||
--grid: rgba(30, 90, 160, .06); --accent: #1d5fa8; --accent-soft: #e3edf9;
|
||||
--done: #1f7a4d; --done-soft: #e2f3ea; --now: #b26a00; --now-soft: #fbefd9; --owed: #a33b2b; --owed-soft: #f8e4e0;
|
||||
--f-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
|
||||
--f-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
|
||||
--f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
|
||||
--bg: #0d1724; --panel: #13202f; --fg: #e3ebf5; --muted: #93a4b8; --line: #263649;
|
||||
--grid: rgba(120, 170, 230, .06); --accent: #7fb2ec; --accent-soft: #1a2d44;
|
||||
--done: #6fcf9b; --done-soft: #15301f; --now: #f0b65a; --now-soft: #33260f; --owed: #f08b7a; --owed-soft: #3a1c17; color-scheme: dark } }
|
||||
:root[data-theme="dark"] {
|
||||
--bg: #0d1724; --panel: #13202f; --fg: #e3ebf5; --muted: #93a4b8; --line: #263649;
|
||||
--grid: rgba(120, 170, 230, .06); --accent: #7fb2ec; --accent-soft: #1a2d44;
|
||||
--done: #6fcf9b; --done-soft: #15301f; --now: #f0b65a; --now-soft: #33260f; --owed: #f08b7a; --owed-soft: #3a1c17; color-scheme: dark }
|
||||
|
||||
* { box-sizing: border-box }
|
||||
body {
|
||||
background: var(--bg);
|
||||
background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
|
||||
background-size: 24px 24px;
|
||||
color: var(--fg); font: 15px/1.6 var(--f-body);
|
||||
padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
|
||||
padding-block: 40px 64px;
|
||||
}
|
||||
.wrap { max-width: 980px; margin: 0 auto; display: grid; gap: 48px }
|
||||
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.2 }
|
||||
h1 { font-size: clamp(2rem, 5vw, 2.8rem); letter-spacing: -.01em }
|
||||
h2 { font-size: 1.45rem }
|
||||
h3 { font-size: 1.05rem }
|
||||
p { margin: 0; max-width: 68ch }
|
||||
.eyebrow { font: 500 .75rem var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--accent) }
|
||||
.muted { color: var(--muted) }
|
||||
section { display: grid; gap: 18px }
|
||||
.sheet { font: .78rem var(--f-mono); color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 20px; border-top: 1px solid var(--line); padding-top: 10px }
|
||||
|
||||
/* header */
|
||||
header { display: grid; gap: 14px }
|
||||
.lede { font-size: 1.08rem }
|
||||
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 6px }
|
||||
.fact { border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 12px 14px; min-width: 0 }
|
||||
.fact b { display: block; font: 600 1.5rem var(--f-display); font-variant-numeric: tabular-nums }
|
||||
.fact span { font-size: .85rem; color: var(--muted) }
|
||||
|
||||
/* status chips */
|
||||
.chip { display: inline-block; font: 500 .7rem var(--f-mono); letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 99px; white-space: nowrap }
|
||||
.chip.done { background: var(--done-soft); color: var(--done) }
|
||||
.chip.now { background: var(--now-soft); color: var(--now) }
|
||||
.chip.owed { background: var(--owed-soft); color: var(--owed) }
|
||||
.chip.later { background: var(--accent-soft); color: var(--accent) }
|
||||
|
||||
/* architecture */
|
||||
.arch { display: grid; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px }
|
||||
.tier { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: center }
|
||||
.tier > .label { font: 500 .75rem var(--f-mono); color: var(--muted); text-transform: uppercase; letter-spacing: .08em }
|
||||
.boxes { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0 }
|
||||
.box { border: 1px solid var(--line); border-radius: 5px; padding: 6px 10px; font-size: .85rem; background: var(--bg) }
|
||||
.box code { font: .78rem var(--f-mono); color: var(--accent) }
|
||||
.box.new { border-style: dashed; border-color: var(--now); }
|
||||
.down { text-align: center; color: var(--muted); font: .8rem var(--f-mono) }
|
||||
@media (max-width: 560px) { .tier { grid-template-columns: 1fr; gap: 6px } }
|
||||
|
||||
/* shipped grid */
|
||||
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px }
|
||||
.group { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 8px; align-content: start; min-width: 0 }
|
||||
.group ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; font-size: .92rem }
|
||||
|
||||
/* owed list */
|
||||
.owed-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none }
|
||||
.owed-list li { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--owed); border-radius: 6px; padding: 10px 14px }
|
||||
|
||||
/* roadmap */
|
||||
.road { display: grid; gap: 0; position: relative }
|
||||
.stage { display: grid; grid-template-columns: 56px 1fr; gap: 16px; padding-bottom: 22px; position: relative }
|
||||
.stage::before { content: ""; position: absolute; left: 27px; top: 44px; bottom: 0; width: 2px; background: var(--line) }
|
||||
.stage:last-child::before { display: none }
|
||||
.num { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font: 700 1.3rem var(--f-display); background: var(--panel); border: 2px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums }
|
||||
.stage.current .num { border-color: var(--now); color: var(--now) }
|
||||
.stage-body { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: grid; gap: 10px; min-width: 0 }
|
||||
.stage.current .stage-body { border-color: var(--now) }
|
||||
.stage-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px }
|
||||
.stage-body ul { margin: 0; padding-left: 18px; display: grid; gap: 3px; font-size: .92rem }
|
||||
.changes { display: grid; gap: 6px }
|
||||
.change { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; font-size: .9rem }
|
||||
.change code { font: .8rem var(--f-mono); color: var(--accent) }
|
||||
|
||||
/* tables */
|
||||
.tbl { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px }
|
||||
table { border-collapse: collapse; width: 100%; font-size: .9rem; min-width: 560px }
|
||||
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top }
|
||||
th { font: 500 .72rem var(--f-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted) }
|
||||
tr:last-child td { border-bottom: 0 }
|
||||
|
||||
.decisions { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px }
|
||||
.decision { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 4px; min-width: 0 }
|
||||
.decision .when { font: .72rem var(--f-mono); color: var(--muted) }
|
||||
</style>
|
||||
|
||||
<div class="wrap">
|
||||
|
||||
<header>
|
||||
<span class="eyebrow">Product blueprint · revision 4 December 2026</span>
|
||||
<h1>Co-Lite Blueprint</h1>
|
||||
<p class="lede">Co-Lite starts as an event CRM for INS and CV: it captures leads at events and from landing pages, and sales follows them up. It is growing into an event hosting platform with tickets, merch and membership, and will later open to any company as self-serve SaaS. <strong>Leads stay at the centre at every stage.</strong> Free events feed sales, and paid events feed sales too.</p>
|
||||
<div class="facts">
|
||||
<div class="fact"><b>40</b><span>changes shipped and archived</span></div>
|
||||
<div class="fact"><b>27</b><span>capabilities with live specs</span></div>
|
||||
<div class="fact"><b>2</b><span>companies at go-live (INS, CV)</span></div>
|
||||
<div class="fact"><b>15 Jan 2027</b><span>go-live deadline</span></div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section>
|
||||
<span class="eyebrow">How it fits together</span>
|
||||
<h2>Platform architecture</h2>
|
||||
<p class="muted">Spring Boot services cloned from the Solvway platform, with the MLM modules (bonus, stockist, inventory, tree) dropped. A rebuilt Next.js portal serves both staff screens and public visitor pages. Dashed boxes come with the second ticketing change.</p>
|
||||
<div class="arch">
|
||||
<div class="tier"><span class="label">Visitors</span><div class="boxes">
|
||||
<span class="box">Landing pages <code>/p/</code></span><span class="box">QR sign-up <code>/r/</code></span><span class="box">Invites <code>/i/</code></span><span class="box">Check-in <code>/c/</code></span><span class="box">Orders <code>/o/</code></span><span class="box new">Tickets <code>/t/</code></span>
|
||||
</div></div>
|
||||
<div class="tier"><span class="label">Staff</span><div class="boxes">
|
||||
<span class="box">Admin portal (Next.js): events, leads, dashboard, pages, WhatsApp, users, roles, audit</span>
|
||||
</div></div>
|
||||
<div class="down">▼ HTTPS</div>
|
||||
<div class="tier"><span class="label">Edge</span><div class="boxes"><span class="box">api-gateway: JWT, public path list, request log</span><span class="box">mobile-api: <code>/api/admin/**</code> and <code>/api/public/**</code>, rate limits</span></div></div>
|
||||
<div class="down">▼ internal</div>
|
||||
<div class="tier"><span class="label">Services</span><div class="boxes">
|
||||
<span class="box">counter: events, leads, pages, check-in<span class="new"></span></span><span class="box">system: companies, users, roles, labels</span><span class="box">auth</span><span class="box">email</span><span class="box">whatsapp</span><span class="box">log</span><span class="box">member (kept for later)</span>
|
||||
</div></div>
|
||||
<div class="tier"><span class="label">Data</span><div class="boxes"><span class="box">MySQL, one schema per service, every new table carries <code>company_id</code></span><span class="box">Redis: sessions, rate limits</span></div></div>
|
||||
<div class="tier"><span class="label">Runs on</span><div class="boxes"><span class="box">Docker Compose locally</span><span class="box">Kubernetes manifests (kustomize base + prod overlay)</span></div></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="eyebrow">Built</span>
|
||||
<h2>What is shipped <span class="chip done">done</span></h2>
|
||||
<div class="groups">
|
||||
<div class="group"><h3>Foundation and operations</h3><ul>
|
||||
<li>Repository, local stack, seed data</li><li>Release CI and image packaging</li><li>Kubernetes manifests</li><li>Gateway request logging without bodies</li></ul></div>
|
||||
<div class="group"><h3>Admin, access and security</h3><ul>
|
||||
<li>Users, roles, permission modules</li><li>Login security, lockout, temporary passwords</li><li>Company scoping: INS and CV see only their own data</li><li>Audit log, email log</li></ul></div>
|
||||
<div class="group"><h3>Events and leads</h3><ul>
|
||||
<li>Events with teams, interests</li><li>Staff lead capture, listings, export</li><li>Lead dashboard, follow-up notifications</li><li>QR self-registration with personal codes</li><li>Invitations, capacity and invite cap</li><li>Venue check-in and attendance numbers</li></ul></div>
|
||||
<div class="group"><h3>Landing pages</h3><ul>
|
||||
<li>Visual on-page editor, drafts, templates</li><li>Hero, sections, features, steps, trust, FAQ, CTA</li><li>Sign-up forms with UTM tracking</li><li>Custom HTML, image upload, anchors</li><li>Top bar, footer, thank-you text, contact links</li><li>INS hotel-technology page built natively</li></ul></div>
|
||||
<div class="group"><h3>Ticket orders</h3><ul>
|
||||
<li>Tickets switch, payment instructions, hold days per event</li><li>Ticket types with price, quantity, sales end</li><li>Tickets page section; seats locked per order</li><li>Order page and order emails; holds expire</li><li>Staff orders: mark paid, cancel order or ticket, resend</li><li>Buyer becomes an event lead</li></ul></div>
|
||||
<div class="group"><h3>Messaging and language</h3><ul>
|
||||
<li>WhatsApp inbox</li><li>Simplified Chinese interface</li><li>Message catalogue filter</li></ul></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="eyebrow">Before 15 January 2027</span>
|
||||
<h2>Still owed for go-live <span class="chip owed">open</span></h2>
|
||||
<ul class="owed-list">
|
||||
<li><span class="chip owed">deploy</span><span>Kubernetes dry run on the real cluster, then the first apply.</span></li>
|
||||
<li><span class="chip owed">verify</span><span>WhatsApp end-to-end check once the business account is linked.</span></li>
|
||||
<li><span class="chip owed">legal</span><span>PDPA owner to confirm the shortened privacy notice on the landing form.</span></li>
|
||||
<li><span class="chip owed">content</span><span>Rebuild the INS landing page on the real server; it exists only in the local database today.</span></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="eyebrow">Where it is going</span>
|
||||
<h2>Roadmap</h2>
|
||||
<p class="muted">Order agreed with the owner on 4 December 2026. Each stage is brainstormed and approved as its own design before it is built.</p>
|
||||
<div class="road">
|
||||
|
||||
<div class="stage current"><div class="num">1</div><div class="stage-body">
|
||||
<div class="stage-head"><h3>Event ticketing</h3><span class="chip now">in progress</span></div>
|
||||
<p>Paid events sell tickets; free events keep today's lead flow. Buyers pay outside Co-Lite for now, by bank transfer or a payment link, and staff mark the order paid.</p>
|
||||
<div class="changes">
|
||||
<div class="change"><code>add-event-ticket-orders</code><span class="chip done">done</span><span class="muted">Ticket types, Tickets page block, orders with seat locking, holds that expire, order page and emails, staff order screens, buyer becomes a lead.</span></div>
|
||||
<div class="change"><code>add-event-tickets</code><span class="chip now">next</span><span class="muted">QR ticket per seat, buyer names attendees later, attendee consent, check-in at the door, invites count as free tickets.</span></div>
|
||||
</div>
|
||||
</div></div>
|
||||
|
||||
<div class="stage"><div class="num">2</div><div class="stage-body">
|
||||
<div class="stage-head"><h3>Merch collected at events</h3><span class="chip later">planned</span></div>
|
||||
<ul><li>Products with variants (size, colour) and a stock count</li><li>Sold alongside tickets in the same order</li><li>Handed over at check-in</li></ul>
|
||||
</div></div>
|
||||
|
||||
<div class="stage"><div class="num">3</div><div class="stage-body">
|
||||
<div class="stage-head"><h3>Merch shop with manual shipping</h3><span class="chip later">planned</span></div>
|
||||
<ul><li>Standalone shop, not tied to an event</li><li>Delivery address on the order; staff ship and mark it shipped</li><li>No courier integration at first</li></ul>
|
||||
</div></div>
|
||||
|
||||
<div class="stage"><div class="num">4</div><div class="stage-body">
|
||||
<div class="stage-head"><h3>Membership</h3><span class="chip later">planned</span></div>
|
||||
<ul><li>Member accounts: profile, My tickets, events attended. Tickets already held are claimed by mobile or email.</li><li>Member-only events, early access and member prices on tickets and merch</li><li>Points earned at check-in and on paid tickets, spent as discounts; tiers later</li><li>Referrals through invite links, one level only</li><li>Leads from free events invited to join; likely built on the kept customer portal</li></ul>
|
||||
</div></div>
|
||||
|
||||
<div class="stage"><div class="num">5</div><div class="stage-body">
|
||||
<div class="stage-head"><h3>Self-serve SaaS</h3><span class="chip later">planned</span></div>
|
||||
<ul><li>Companies sign up themselves on a Free or Premium plan</li><li>No admin needs to create the company by hand</li><li>Built on the company scoping already in place</li></ul>
|
||||
</div></div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="eyebrow">At any stage</span>
|
||||
<h2>Upgrades that wait for a trigger</h2>
|
||||
<div class="tbl"><table>
|
||||
<thead><tr><th>Upgrade</th><th>Trigger</th><th>What it changes</th></tr></thead>
|
||||
<tbody>
|
||||
<tr><td>Payment gateway (FPX, card)</td><td>A gateway account is chosen</td><td>Adds "pay now" to the same order; holds shrink from days to minutes</td></tr>
|
||||
<tr><td>Faster seat updates</td><td>An event with thousands rushing at once</td><td>Single conditional update instead of the event lock; CAPTCHA, cached pages, a load test</td></tr>
|
||||
<tr><td>Launch-day protection</td><td>Concert-size launches</td><td>Virtual waiting room, queued orders, member-only sales, ticketing as its own service</td></tr>
|
||||
<tr><td>Receipts, invoices, SST</td><td>When payment moves inside Co-Lite</td><td>Issued from the order instead of outside the system</td></tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<span class="eyebrow">Settled</span>
|
||||
<h2>Decisions that shape the build</h2>
|
||||
<div class="decisions">
|
||||
<div class="decision"><span class="when">foundation</span><h3>Leads are their own table</h3><p class="muted">Not a status on members. Every route in (QR, invite, page, ticket) creates or reuses a lead.</p></div>
|
||||
<div class="decision"><span class="when">30 Nov 2026</span><h3>Every new table has a company</h3><p class="muted">So INS and CV stay apart now, and SaaS later is a sign-up flow, not a rebuild.</p></div>
|
||||
<div class="decision"><span class="when">4 Dec 2026</span><h3>One order for every kind of item</h3><p class="muted">Order lines carry a kind: ticket now, merch pickup and shipping later, one checkout like a fan-platform shop.</p></div>
|
||||
<div class="decision"><span class="when">4 Dec 2026</span><h3>Attendees consent themselves</h3><p class="muted">A buyer's partner can attend without joining; they become a lead only after ticking the consent.</p></div>
|
||||
<div class="decision"><span class="when">4 Dec 2026</span><h3>No walk-ins on paid events</h3><p class="muted">Venue check-in admits ticket holders and registered invited guests only.</p></div>
|
||||
<div class="decision"><span class="when">4 Dec 2026</span><h3>No inventory service</h3><p class="muted">Seats and later merch stock are counted in the counter service with one locked, all-or-nothing write.</p></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="sheet"><span>Source: openspec/specs, openspec/changes/archive, docs/superpowers/specs/2026-12-04-event-ticketing-design.md</span><span>Status as of 4 December 2026</span></div>
|
||||
|
||||
</div>
|
||||
@@ -615,10 +615,15 @@ CREATE TABLE IF NOT EXISTS `ticket` (
|
||||
`cancelled_by` varchar(255) NULL,
|
||||
`checked_in_at` datetime NULL,
|
||||
`checked_in_by` varchar(255) NULL,
|
||||
`attendee_named_at` datetime NULL,
|
||||
`attendee_consent_at` datetime NULL,
|
||||
`attendee_notice_id` bigint NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uk_ticket_code` (`code`),
|
||||
KEY `idx_ticket_type_status` (`ticket_type_id`, `status`),
|
||||
KEY `idx_ticket_order` (`order_id`)
|
||||
KEY `idx_ticket_order` (`order_id`),
|
||||
KEY `idx_ticket_event_mobile` (`event_uuid`, `attendee_mobile_e164`),
|
||||
KEY `idx_ticket_event_email` (`event_uuid`, `attendee_email`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- add-event-ticket-orders/sql/02-event-tickets-module.sql
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,130 @@
|
||||
# Design
|
||||
|
||||
Product design: `docs/superpowers/specs/2026-12-04-event-ticketing-design.md` (approved 2026-12-04). This file holds the technical contracts. Change 1 (`add-event-ticket-orders`) already built the `ticket` table with `code`, the attendee columns, `event_lead_uuid` and the `checked_in_*` columns, so this change mostly fills them in.
|
||||
|
||||
## Context
|
||||
|
||||
- **Tickets and orders:**
|
||||
- Orders and tickets live in services-counter: `TicketOrderService` handles the request and `byToken`; `TicketOrderStaffService` handles mark paid, cancel and resend; `TicketOrderMailer` sends the order emails; `TicketOrderExpiryJob` expires holds.
|
||||
- mobile-api's `PublicPageService` holds the public order endpoints and `AdminTicketService` the staff ones.
|
||||
- The gateway's `JWTAuthFilter` lists the counter paths that are public.
|
||||
- **Venue self check-in:**
|
||||
- `EventCheckInService.lookup` returns `CHECKED_IN` or `FORM`.
|
||||
- The walk-in form posts to the existing register path with `attend=true`.
|
||||
- **Capacity:** "a registered invite counts toward capacity" already holds. `EventGuestService.register`, `TicketOrderService.create` and `EventHeadcountService` all add registered guests, walk-ins and held tickets. No work here.
|
||||
- **Leads:** `RegistrationService.register(RegisterRequest)` does the QR-registration matching and takes `source`, `consentNoticeId`, `consentAt` and `attend`. It returns the event lead uuid.
|
||||
- **Portal:**
|
||||
- `clientApi` redirects to `/login` on a 401.
|
||||
- `/api/auth/session` does not redirect, and tells whether a staff session exists.
|
||||
- `qrcode.react` draws QRs in the browser only.
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- Ticket codes on payment.
|
||||
- The `/t/<code>` page with its public and staff views.
|
||||
- Attendee naming on the order page.
|
||||
- Attendee consent.
|
||||
- The paid email with the tickets, the ticket email, and resend ticket.
|
||||
- Door check-in.
|
||||
- Self check-in rules on ticketed events.
|
||||
- The ticket counts.
|
||||
|
||||
**Non-Goals:**
|
||||
- Payment gateway.
|
||||
- Merch.
|
||||
- Member accounts.
|
||||
- WhatsApp ticket delivery: an attendee named with a mobile only gets no message; the buyer forwards the link.
|
||||
- Transferring a ticket to another order.
|
||||
- Printing tickets.
|
||||
|
||||
## Decisions
|
||||
|
||||
1. **Codes are issued when the order becomes Paid.** This happens inside the same transaction as the status change, at three places: `TicketOrderService.create` (free order), `TicketOrderStaffService.markPaid` (Awaiting payment or Expired), and nowhere else. Codes use the existing 22-character `RegistrationLinkService.newToken()`; `uk_ticket_code` guards uniqueness. Cancelling keeps the code, and validity is computed: the order is `PAID` and the ticket is `ACTIVE`.
|
||||
- *Alternative:* codes at request time. Rejected, because an unpaid order would then carry QRs that look real.
|
||||
2. **Ticket state, computed in one place.** `TicketState.of(order, ticket)` returns `VALID`, `CHECKED_IN`, `AWAITING`, `ORDER_CANCELLED`, `ORDER_EXPIRED` or `TICKET_CANCELLED`. The public page, the staff view, check-in and self check-in all use it.
|
||||
3. **Renaming replaces the code.** The attendee save is `POST ticket/attendee` with the order token, ticket id, name, mobile, email and `permission`. In one transaction it:
|
||||
- checks the order token and that the order is `PAID`;
|
||||
- checks the ticket is `ACTIVE` and not checked in;
|
||||
- sets a new code, `attendee_named_at`, the attendee fields, and clears `attendee_consent_at`, `attendee_notice_id` and `event_lead_uuid`;
|
||||
- after commit, sends the Ticket email when an email is set.
|
||||
- Normalisation and the `MOBILE_OR_EMAIL_REQUIRED`, name-length and email-format errors reuse the QR registration helpers in mobile-api.
|
||||
4. **Consent creates the lead through `RegistrationService.register`.** It is called with source `TICKET`, no salesperson, the company's current notice and `attend=false`. At check-in it is called with `attend=true`. The returned event lead uuid is stored on the ticket. An attendee whose details match a lead is linked to it, as QR registration already does.
|
||||
- **Unnamed tickets:** the consent needs a name and contact, so on the public page it is offered only for a named ticket. At the door, staff enter them first.
|
||||
5. **Staff view detection.** The `/t/[code]` page always loads the public view (`GET /api/public/tickets/{code}`). When `/api/auth/session` reports a session, it also calls `GET /api/admin/tickets/{code}`. That call is guarded by `@AdminModule("BO_EVENTS")` and scoped by company in mobile-api with `loadEvent(uuid, null)`, so another company's event is a 404. On 401, 403 or 404 the page stays public. The admin call uses a plain `fetch`, not `clientApi`, so a signed-out visitor is never bounced to login.
|
||||
6. **Check-in.** `POST /api/admin/tickets/{code}/checkin` takes optional `{name, mobile, email, consent}`, which are required when the ticket is unnamed. Refusals are 409 with the codes `ALREADY_CHECKED_IN|<time>`, `NOT_VALID|<state>` and `NOT_EVENT_DAY`. The update is conditional (`checked_in_at IS NULL`), so two scanners cannot both check a ticket in; the loser gets `ALREADY_CHECKED_IN`. The action is `@Audited`.
|
||||
7. **Self check-in on a ticketed event.** For `tickets_enabled` events only, `EventCheckInService.lookup` checks, in order:
|
||||
1. the oldest `ACTIVE` ticket on a `PAID` order of the event, not checked in, whose attendee mobile or email matches, or whose attendee is blank and whose order's buyer mobile or email matches. It is checked in with `checked_in_by = 'self'`, and the lead is marked attended when the ticket has one;
|
||||
2. a registered guest of the event, as today;
|
||||
3. otherwise the result is `SHOW_TICKET`.
|
||||
|
||||
The walk-in register path refuses a ticketed event with 409 `TICKETS_ONLY`. The welcome uses the attendee's first name, or the buyer's for an unnamed ticket.
|
||||
8. **QR PNG in mobile-api.** `GET /api/public/tickets/{code}/qr.png`:
|
||||
- checks the code shape and validity through counter `ticket/byCode`; an invalid or unknown code is 404;
|
||||
- encodes `<admin-portal-base>/t/<code>` with zxing `QRCodeWriter` at 300 px, written by `ImageIO`;
|
||||
- responds `Cache-Control: private, max-age=300`;
|
||||
- counts toward the `tkt:load` limit.
|
||||
|
||||
The portal proxies it like the page images. Emails use the absolute portal URL in `<img src>`.
|
||||
9. **Order page tickets.** Counter `byToken` adds `tickets: [{id, typeName, attendeeName, code, state, checkedInAt}]` only when the order is PAID. mobile-api passes them through without attendee mobile or email: the counter does not return those to the public call at all.
|
||||
10. **Emails.** `TicketOrderMailer`:
|
||||
- **PAID:** gains one block per active ticket: the type, the QR `<img>` and the link. It ends with "Name your attendees: <order link>".
|
||||
- **New kind TICKET:** sends one ticket to its attendee (or to the buyer, when staff resend an unnamed ticket), with the consent invitation link pointing to the ticket page.
|
||||
- All of them are sent after commit and are best effort, as today.
|
||||
11. **Counts.** `EventHeadcountService.Headcount` gains `ticketsAwaiting`, `ticketsPaid` and `ticketsCheckedIn`, from one grouped query over active tickets joined to their order status. The portal's GuestsCard shows them when the event sells tickets.
|
||||
12. **Limits.**
|
||||
- `tkt:load:<ip>` allows 120 per 10 minutes, for the ticket page and the QR together.
|
||||
- `tkt:submit:<ip>:<event>` allows 60 per 10 minutes, for naming and consent.
|
||||
- Staff check-in has no IP limit: it is an authenticated admin call.
|
||||
|
||||
## Data
|
||||
|
||||
`sql/01-ticket-attendees.sql` (services-counter, additive):
|
||||
|
||||
```sql
|
||||
ALTER TABLE `ticket`
|
||||
ADD COLUMN `attendee_named_at` datetime NULL,
|
||||
ADD COLUMN `attendee_consent_at` datetime NULL,
|
||||
ADD COLUMN `attendee_notice_id` bigint NULL,
|
||||
ADD KEY `idx_ticket_event_mobile` (`event_uuid`, `attendee_mobile_e164`),
|
||||
ADD KEY `idx_ticket_event_email` (`event_uuid`, `attendee_email`);
|
||||
```
|
||||
|
||||
- `sql/02-ticket-labels.sql` holds the labels, cut from `npm run i18n:sql`.
|
||||
- `sql/99-rollback.sql` drops the three columns and two keys. Codes stay, because change 1 owns the column.
|
||||
|
||||
## Endpoints
|
||||
|
||||
| Layer | Method and path | Auth |
|
||||
|---|---|---|
|
||||
| counter | `GET ticket/byCode/{code}` | public via gateway |
|
||||
| counter | `POST ticket/attendee` (order token, ticket id, attendee, permission) | public via gateway |
|
||||
| counter | `POST ticket/consent` (code, notice id) | public via gateway |
|
||||
| counter | `GET ticket/staff/{code}`, `POST ticket/checkin` | JWT (from mobile-api admin) |
|
||||
| counter | `POST ticketOrder/{id}/tickets/{ticketId}/resend` | JWT |
|
||||
| mobile-api | `GET /api/public/tickets/{code}`, `GET .../qr.png`, `POST .../consent` | public |
|
||||
| mobile-api | `POST /api/public/orders/{token}/tickets/{ticketId}/attendee` | public |
|
||||
| mobile-api | `GET /api/admin/tickets/{code}`, `POST /api/admin/tickets/{code}/checkin` | `BO_EVENTS` |
|
||||
| mobile-api | `POST /api/admin/events/{uuid}/orders/{orderId}/tickets/{ticketId}/resend` | `BO_EVENT_TICKETS` |
|
||||
| gateway | public: `GET /counter/ticket/byCode/[A-Za-z0-9_-]{22}`, `POST /counter/ticket/attendee`, `POST /counter/ticket/consent` | |
|
||||
| portal | `/t/[code]` page (public in the route guard); proxies for each mobile-api path above | |
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- **Mobile-only attendees get no ticket message.** The buyer shares the link. *Mitigation:* the order page shows each ticket's link with a copy button. WhatsApp delivery can follow once the business account is linked.
|
||||
- **A forwarded ticket link works for whoever holds it.** This is the same as any paper ticket; check-in is one-time. *Mitigation:* renaming replaces the code.
|
||||
- **Staff view on a phone needs a signed-in session in that phone's browser.** That is the existing portal login; the door staff sign in once.
|
||||
- **New dependency** `com.google.zxing:core`, MIT-style Apache 2.0, no transitive dependencies, used only for the email PNG.
|
||||
- **Self check-in matching an unnamed ticket to its buyer** lets the buyer check in once per unnamed ticket. Each lookup takes one ticket, which matches the buyer bringing friends whose names were never given. ponytail: no per-person cap; add one if abuse is seen.
|
||||
|
||||
## Migration Plan
|
||||
|
||||
1. Run `sql/01-ticket-attendees.sql` before the new services-counter starts. It is additive, and the old images ignore the columns.
|
||||
2. Deploy services-counter, mobile-api, api-gateway and the portal.
|
||||
3. Run `sql/02-ticket-labels.sql`.
|
||||
4. Orders paid before this release have tickets without codes. A one-off statement in `01` gives every active ticket on a PAID order a code, using `REPLACE(TO_BASE64(RANDOM_BYTES(16)), ...)` trimmed to the 22-character URL-safe form.
|
||||
5. **Rollback:** the previous images, then `99`.
|
||||
|
||||
## Open Questions
|
||||
|
||||
None for the owner. Builder calls are recorded above (decisions 4, 5 and 7) and in the release note.
|
||||
@@ -0,0 +1,85 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
Change 1 (`add-event-ticket-orders`, merged 2026-12-04) lets visitors request tickets and staff mark orders paid. A paid order still gives the buyer nothing to show at the door, and the venue's self check-in still offers the walk-in form, so anyone can walk into a paid event. This change adds the ticket itself: a QR code per seat, attendees, and check-in at the door.
|
||||
|
||||
The product design was approved on 2026-12-04: `docs/superpowers/specs/2026-12-04-event-ticketing-design.md`. This is the second and last change from that design.
|
||||
|
||||
## What Changes
|
||||
|
||||
- **Ticket codes:**
|
||||
- When an order becomes Paid, each of its active tickets gets an unguessable code. This includes free orders, which are Paid at once, and expired orders that staff mark paid.
|
||||
- The ticket's link is `/t/<code>`.
|
||||
- Unpaid, cancelled and expired tickets have no valid QR.
|
||||
- **Ticket page** `/t/<code>`:
|
||||
- **Public view:**
|
||||
- the event and ticket type;
|
||||
- the attendee's first name;
|
||||
- the ticket's state;
|
||||
- the QR image while the ticket is valid;
|
||||
- "This ticket is not valid" otherwise.
|
||||
- **Staff view:** for signed-in staff with `BO_EVENTS` in the event's company, on an event day, a large state banner and **Check in**. An unnamed ticket first asks for the attendee's name and mobile or email.
|
||||
- **Refusals:** a second check-in shows "Already checked in at <time>"; an unpaid, cancelled or expired ticket shows a red refusal.
|
||||
- **Naming attendees on the order page:**
|
||||
- Once an order is Paid, the order page lists its tickets, each with its link.
|
||||
- Per ticket, the buyer can name or rename the attendee (a name plus mobile or email). The save needs the tick "I have permission to share these details so their ticket can be sent".
|
||||
- Naming issues a new code, so the old QR stops working, and emails the attendee their ticket.
|
||||
- Naming is refused once the ticket is checked in.
|
||||
- **Attendee consent:**
|
||||
- A named attendee is not a lead.
|
||||
- The ticket page, and the staff view at check-in, offer an optional "Keep me updated about <company> events" with the company's privacy notice. Ticking it records the consent and makes the attendee an event lead with source `TICKET`, matched as in QR registration. The ticket email links to that page.
|
||||
- An attendee who never ticks it can still attend.
|
||||
- **Emails:**
|
||||
- "Order paid" now carries each ticket's QR image and link, plus a "Name your attendees" link to the order page.
|
||||
- A new **Ticket** email goes to a named attendee who has an email.
|
||||
- Staff can **Resend ticket** from the order detail.
|
||||
- **Door check-in:** checking a ticket in records who did it and when. An attendee who consented, now or earlier, has their event lead marked attended.
|
||||
- **Venue self check-in on a ticketed event:**
|
||||
- It checks in the attendee of a Paid ticket that is not yet checked in. If several match, it takes the oldest. An unnamed ticket counts as its buyer's.
|
||||
- It also checks in a registered invited guest, as today.
|
||||
- Anything else shows "Please show your ticket at the entrance" instead of the walk-in form.
|
||||
- Events without tickets keep today's flow unchanged.
|
||||
- **Event attendance numbers:** on a ticketed event they add tickets awaiting payment, tickets paid and tickets checked in.
|
||||
- **QR image for emails:** a public PNG at `/api/public/tickets/<code>/qr.png`. It encodes the ticket's `/t/<code>` link.
|
||||
- **Already done in change 1, so not repeated here:** a registered invite counts toward capacity alongside held tickets ("Capacity before the event").
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None. Tickets belong to the existing `event-ticketing` capability.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `event-ticketing`:
|
||||
- **Order Emails:** the paid email carries the tickets.
|
||||
- **New requirements:** ticket codes, the ticket page and invalid links, tickets on the order page, naming attendees, attendee consent, the ticket email, the staff ticket view, door check-in, resend ticket, and the ticket abuse limits.
|
||||
- `event-attendance`:
|
||||
- **Self check-in of a known person** and **Self check-in of a walk-in** now apply to events without tickets.
|
||||
- **New requirements:** self check-in on a ticketed event, no walk-ins on a ticketed event, and the ticket attendance numbers.
|
||||
|
||||
## Impact
|
||||
|
||||
- **services-counter:**
|
||||
- ticket code issuing on Paid;
|
||||
- ticket lookup, naming, consent and check-in services;
|
||||
- `EventCheckInService.lookup` on ticketed events;
|
||||
- headcount;
|
||||
- `TicketOrderMailer` (the paid email with tickets, and the ticket email).
|
||||
- **mobile-api:**
|
||||
- public endpoints for the ticket page, the QR PNG, naming attendees and attendee consent;
|
||||
- admin endpoints for the staff ticket view, check-in and resend ticket.
|
||||
- **api-gateway:** public path patterns for the new endpoints.
|
||||
- **admin-portal:**
|
||||
- `/t/[code]` page (public view and staff view);
|
||||
- the order page gains its tickets section;
|
||||
- a Resend ticket button on the order detail;
|
||||
- the guests card shows the ticket counts;
|
||||
- proxies and the route guard;
|
||||
- labels in English and zh-CN.
|
||||
- **Database:** `ticket` gains the attendee consent time, privacy notice id, and naming time.
|
||||
- **New dependency:**
|
||||
- **What:** `com.google.zxing:core` in mobile-api, to draw the email QR as a PNG. It has no transitive dependencies; the PNG is written with the JDK's `ImageIO`.
|
||||
- **Why it is needed:** nothing in the repo draws a QR server-side. The portal's `qrcode.react` renders in the browser only. Email clients block SVG and data-URI images, so the email needs a hosted PNG.
|
||||
- **No change for events without tickets.**
|
||||
@@ -0,0 +1,61 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Self check-in on a ticketed event
|
||||
|
||||
On an event that sells tickets, the check-in page SHALL match the mobile or email only to the attendee of a valid ticket that is not checked in, or to a registered guest. An unnamed ticket SHALL count as its buyer's, and the oldest ticket SHALL be used when several match. A matched ticket SHALL be checked in, and the attendee's event lead marked attended when they have consented. A matched registered guest SHALL be handled as on other events.
|
||||
|
||||
#### Scenario: Ticket holder checks in
|
||||
|
||||
- **GIVEN** `KL Hotel Tech Day` sells tickets and `Lim Wei` holds a valid ticket named with his mobile
|
||||
- **WHEN** he enters that mobile on the check-in page on the event day
|
||||
- **THEN** the page welcomes `Lim` and his ticket is checked in
|
||||
|
||||
### Requirement: No walk-ins on a ticketed event
|
||||
|
||||
On an event that sells tickets, when the value matches no valid unchecked ticket and no registered guest, the check-in page SHALL show "Please show your ticket at the entrance." It SHALL NOT offer or accept a walk-in submission.
|
||||
|
||||
#### Scenario: No walk-ins on a paid event
|
||||
|
||||
- **GIVEN** `KL Hotel Tech Day` sells tickets
|
||||
- **WHEN** a visitor whose mobile matches no valid ticket and no registered guest enters it
|
||||
- **THEN** the page says "Please show your ticket at the entrance." and shows no form
|
||||
- **AND** a walk-in submission sent directly is refused
|
||||
|
||||
### Requirement: Ticket attendance numbers
|
||||
|
||||
When the event sells tickets, the event page SHALL also show tickets awaiting payment, tickets paid and tickets checked in, counting active tickets only. The numbers SHALL agree with the event's orders.
|
||||
|
||||
#### Scenario: Ticket counts
|
||||
|
||||
- **GIVEN** `KL Hotel Tech Day` has 2 tickets awaiting payment and 5 paid tickets, 3 of them checked in
|
||||
- **WHEN** an admin opens the event page
|
||||
- **THEN** the page shows tickets awaiting payment 2, paid 5, checked in 3
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Self check-in of a known person
|
||||
|
||||
On the event days, the check-in page SHALL ask for one mobile or email, normalised as in staff capture. On an event that does not sell tickets, when the value matches a registered guest or an event lead of this event, that event lead SHALL be marked attended. After a check-in the page SHALL show "Welcome, <first name>. You're checked in." Checking in again SHALL show the same welcome and change nothing. The page SHALL show no personal details other than the first name.
|
||||
|
||||
#### Scenario: Registered guest checks in
|
||||
|
||||
- **GIVEN** `Tan Mei Ling` registered by invitation for `KL Expo`
|
||||
- **WHEN** she enters `012-555 0101` on the check-in page on the event day
|
||||
- **THEN** the page welcomes `Tan` and her event lead is attended
|
||||
- **AND** the guest list shows her as Attended
|
||||
|
||||
### Requirement: Self check-in of a walk-in
|
||||
|
||||
On an event that does not sell tickets, when the value matches an invited guest who has not registered, or no one, the check-in page SHALL show the walk-in form, blank, with the privacy consent. An accepted submission SHALL capture the person with the QR registration rules and no salesperson, link a matching guest, mark the event lead attended, and show the checked-in page.
|
||||
|
||||
#### Scenario: Invited but not registered
|
||||
|
||||
- **GIVEN** `Lim Wei` is Invited but never registered
|
||||
- **WHEN** he enters his mobile on the check-in page
|
||||
- **THEN** a blank walk-in form with the consent is shown, not his details
|
||||
- **AND** after he submits, he is Attended on the guest list
|
||||
|
||||
#### Scenario: Unknown walk-in
|
||||
|
||||
- **WHEN** a visitor whose mobile matches no one enters it and submits the walk-in form
|
||||
- **THEN** an event lead is captured for them and marked attended
|
||||
@@ -0,0 +1,191 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Ticket Codes
|
||||
|
||||
When an order becomes Paid, the system SHALL give each of its active tickets an unguessable code of 22 URL-safe characters, unique across all tickets. This SHALL apply when staff mark an order paid (also an Expired one) and when a free order is Paid at once. The ticket's link SHALL be `/t/<code>`. A ticket SHALL be valid only while its order is Paid and the ticket is active.
|
||||
|
||||
#### Scenario: Codes on payment
|
||||
|
||||
- **GIVEN** order `T-7K3M9Q` holds 2 `General` tickets and is Awaiting payment
|
||||
- **WHEN** staff mark it paid
|
||||
- **THEN** each ticket has its own code and link
|
||||
|
||||
#### Scenario: Free order
|
||||
|
||||
- **WHEN** a visitor requests 1 free `Community pass`
|
||||
- **THEN** the order is Paid and its ticket has a code at once
|
||||
|
||||
### Requirement: Ticket Page
|
||||
|
||||
The ticket link `/t/<code>` SHALL be public. It SHALL show the event name, dates and location, the ticket type, the attendee's first name (or "Not named yet") and the ticket's state. It SHALL show the QR image of its own link only while the ticket is valid and not checked in; a checked-in ticket SHALL show "Checked in at <time>". It SHALL never show the buyer's details, the attendee's mobile or email, or other tickets.
|
||||
|
||||
#### Scenario: Valid ticket
|
||||
|
||||
- **GIVEN** the ticket of `Tan Mei Ling` for `KL Hotel Tech Day` is valid
|
||||
- **WHEN** she opens its link
|
||||
- **THEN** the page shows the event, `General`, `Tan` and the QR image
|
||||
|
||||
### Requirement: Invalid Ticket Links
|
||||
|
||||
A ticket whose order is not Paid, or which is cancelled, SHALL show "This ticket is not valid" with no QR. An unknown code SHALL show "This ticket link is not valid." and nothing else.
|
||||
|
||||
#### Scenario: Cancelled ticket
|
||||
|
||||
- **GIVEN** a Paid order's ticket was cancelled by staff
|
||||
- **WHEN** someone opens that ticket's link
|
||||
- **THEN** the page says the ticket is not valid and shows no QR
|
||||
|
||||
#### Scenario: Unknown link
|
||||
|
||||
- **WHEN** a visitor opens `/t/` with an unknown code
|
||||
- **THEN** the page says the ticket link is not valid
|
||||
|
||||
### Requirement: Tickets On The Order Page
|
||||
|
||||
Once an order is Paid, its order page SHALL list each active ticket with its type, attendee name (or "Not named yet"), state and ticket link. It SHALL NOT show any attendee's mobile or email.
|
||||
|
||||
#### Scenario: Paid order page
|
||||
|
||||
- **GIVEN** order `T-7K3M9Q` is Paid with 2 tickets, one named `Tan Mei Ling`
|
||||
- **WHEN** the buyer opens its link
|
||||
- **THEN** the page lists both tickets with their links, `Tan Mei Ling` and "Not named yet", without Tan's email
|
||||
|
||||
### Requirement: Naming Attendees
|
||||
|
||||
On a Paid order's page, the buyer SHALL be able to name or rename the attendee of each ticket on its own: a name of up to 100 characters and a mobile or an email, normalised as in QR registration. The save SHALL need the tick "I have permission to share these details so their ticket can be sent"; without it the save SHALL be refused with "Tick the box to confirm you may share these details."
|
||||
|
||||
#### Scenario: Permission not ticked
|
||||
|
||||
- **WHEN** the buyer saves an attendee without the permission tick
|
||||
- **THEN** the save is refused and nothing changes
|
||||
|
||||
### Requirement: Naming Effects
|
||||
|
||||
Saving an attendee SHALL replace the ticket's code, so the old link becomes unknown. It SHALL record the naming time, clear any earlier attendee consent and lead link on that ticket, and email the new attendee their ticket when an email was given.
|
||||
|
||||
#### Scenario: Name an attendee
|
||||
|
||||
- **GIVEN** `Aisyah`'s order `T-7K3M9Q` is Paid with 2 unnamed tickets
|
||||
- **WHEN** she names `Tan Mei Ling`, `tan@example.com`, on the first ticket and ticks the permission
|
||||
- **THEN** that ticket shows `Tan Mei Ling` with a new link
|
||||
- **AND** Tan receives the ticket email
|
||||
- **AND** the old link of that ticket says the ticket link is not valid
|
||||
|
||||
### Requirement: Naming Refusals
|
||||
|
||||
Naming SHALL be refused for a ticket that is checked in ("This ticket is already checked in."), cancelled, or on an order that is not Paid.
|
||||
|
||||
#### Scenario: Checked-in ticket
|
||||
|
||||
- **GIVEN** a ticket is checked in
|
||||
- **WHEN** the buyer tries to rename its attendee
|
||||
- **THEN** the save is refused with "This ticket is already checked in."
|
||||
|
||||
### Requirement: Attendee Is Not A Lead Without Consent
|
||||
|
||||
A named attendee SHALL NOT be an event lead, and SHALL NOT appear in event leads, lead lists, exports or the dashboard, until they consent themselves. Their details SHALL be used only to deliver and check the ticket. An attendee who never consents SHALL still be able to attend.
|
||||
|
||||
#### Scenario: Attendee never opts in
|
||||
|
||||
- **GIVEN** `Lim Wei` was named on a Paid ticket and never ticked the consent
|
||||
- **WHEN** staff open the event leads listing
|
||||
- **THEN** Lim does not appear
|
||||
|
||||
### Requirement: Attendee Consent
|
||||
|
||||
A valid ticket's page SHALL offer an optional "Keep me updated about <company> events" with the company's privacy notice in English and Bahasa Malaysia. Ticking it SHALL record the consent time and notice version on the ticket. It SHALL capture the attendee as an event lead with source `TICKET` and no salesperson, matched and normalised as in QR registration, and link the ticket to that event lead.
|
||||
|
||||
#### Scenario: Attendee opts in
|
||||
|
||||
- **GIVEN** `Tan Mei Ling` was named on a valid ticket
|
||||
- **WHEN** she ticks "Keep me updated about INS events" on her ticket page
|
||||
- **THEN** she is an event lead of `KL Hotel Tech Day` with source Ticket
|
||||
|
||||
### Requirement: Ticket Email
|
||||
|
||||
A named attendee with an email SHALL get a Ticket email in English and Bahasa Malaysia. It SHALL hold the event name, dates and location, the ticket type, the attendee name, the QR image, and the ticket link, which also offers the consent. The QR image SHALL be a PNG of the ticket link served at `/api/public/tickets/<code>/qr.png`. Each email SHALL be recorded in Emails, and a failed send SHALL NOT undo the naming.
|
||||
|
||||
#### Scenario: Ticket email
|
||||
|
||||
- **WHEN** the buyer names `Tan Mei Ling`, `tan@example.com`
|
||||
- **THEN** Tan receives an email with the QR image and her ticket link
|
||||
|
||||
### Requirement: Staff Ticket View
|
||||
|
||||
On the ticket page, a signed-in user with `BO_EVENTS` in the event's company (any company for super admins) SHALL see the staff view: the ticket's state as a large banner and, for a valid ticket that is not checked in, **Check in**. An unnamed ticket SHALL first ask for the attendee's name and a mobile or email. The staff view SHALL offer the same optional consent as the ticket page. Everyone else SHALL see only the public view.
|
||||
|
||||
#### Scenario: Another company's staff
|
||||
|
||||
- **WHEN** CV staff open a ticket of an INS event
|
||||
- **THEN** they see only the public view
|
||||
|
||||
### Requirement: Door Check-In
|
||||
|
||||
Check-in from the staff view SHALL record the time and the staff user on the ticket, and SHALL be written to the admin audit log. When the attendee has consented, now or earlier, their event lead SHALL be marked attended. An unnamed ticket SHALL take the name and contact entered by staff, normalised as in QR registration.
|
||||
|
||||
#### Scenario: Staff check in a named ticket
|
||||
|
||||
- **GIVEN** `Tan Mei Ling`'s ticket is valid and it is the event day
|
||||
- **WHEN** event staff scan her QR and tap Check in
|
||||
- **THEN** the ticket is checked in with their name and the time
|
||||
|
||||
#### Scenario: Unnamed ticket at the door
|
||||
|
||||
- **GIVEN** a valid ticket was never named
|
||||
- **WHEN** staff enter `Lim Wei` and his mobile and tap Check in
|
||||
- **THEN** the ticket is checked in with Lim as its attendee
|
||||
- **AND** no lead is created unless he ticked the consent
|
||||
|
||||
### Requirement: Door Check-In Refusals
|
||||
|
||||
Check-in SHALL change nothing and the staff view SHALL show:
|
||||
|
||||
- "Already checked in at <time>" for a checked-in ticket;
|
||||
- a red "Not valid: <reason>" banner for an invalid ticket, the reason being "awaiting payment", "order cancelled", "order expired" or "ticket cancelled";
|
||||
- "Check-in is only open on the event days." outside the event days.
|
||||
|
||||
#### Scenario: Second scan
|
||||
|
||||
- **WHEN** staff scan a checked-in ticket again
|
||||
- **THEN** the page shows "Already checked in at" the first time and nothing changes
|
||||
|
||||
#### Scenario: Unpaid ticket at the door
|
||||
|
||||
- **GIVEN** an order is Awaiting payment
|
||||
- **WHEN** staff open one of its ticket links
|
||||
- **THEN** the page shows "Not valid: awaiting payment" and no Check in button
|
||||
|
||||
### Requirement: Resend Ticket
|
||||
|
||||
Users with `BO_EVENT_TICKETS` SHALL be able to resend one valid ticket from the order detail. It SHALL go to its attendee's email when named with an email, otherwise to the buyer. The action SHALL be written to the admin audit log.
|
||||
|
||||
#### Scenario: Resend a ticket
|
||||
|
||||
- **GIVEN** a valid ticket is named `Tan Mei Ling`, `tan@example.com`
|
||||
- **WHEN** staff resend that ticket
|
||||
- **THEN** Tan receives the ticket email again
|
||||
|
||||
### Requirement: Ticket Abuse Limits
|
||||
|
||||
The public ticket page and its QR image SHALL be limited to 120 loads per client IP per 10 minutes. Naming attendees and attendee consent SHALL be limited to 60 submissions per client IP per event per 10 minutes. Above a limit the answer SHALL be "Too many requests from this device. Try again later." The QR image SHALL be served only for a valid code.
|
||||
|
||||
#### Scenario: Too many ticket loads
|
||||
|
||||
- **WHEN** one IP loads ticket pages 121 times within 10 minutes
|
||||
- **THEN** the 121st is refused with "Too many requests from this device. Try again later."
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Order Emails
|
||||
|
||||
The buyer SHALL get an email when their order is created (lines, total, payment instructions, hold expiry and order link), becomes Paid (lines, total, each ticket's QR image and link, and a "Name your attendees" link to the order page), Expires, or is Cancelled by staff. Each email SHALL be recorded in Emails. A failed send SHALL NOT undo the order change, and staff SHALL be able to resend the latest email of an order.
|
||||
|
||||
#### Scenario: Order received email
|
||||
|
||||
- **WHEN** `Aisyah` requests tickets
|
||||
- **THEN** she receives an email with the order reference, payment instructions, hold expiry and order link
|
||||
|
||||
#### Scenario: Paid email
|
||||
|
||||
- **WHEN** staff mark her order of 2 tickets Paid
|
||||
- **THEN** she receives a confirmation email with 2 QR images, their ticket links and a link to name her attendees
|
||||
@@ -0,0 +1,15 @@
|
||||
-- Co-Lite change add-event-tickets: attendee naming and consent on tickets, and the keys self check-in matches on.
|
||||
-- Target: `service-counter`. Additive only. Run before the new services-counter starts. Needs a user that may alter tables.
|
||||
USE `service-counter`;
|
||||
|
||||
ALTER TABLE `ticket`
|
||||
ADD COLUMN `attendee_named_at` datetime NULL COMMENT 'when the buyer last named the attendee',
|
||||
ADD COLUMN `attendee_consent_at` datetime NULL COMMENT 'when the attendee agreed to be kept updated',
|
||||
ADD COLUMN `attendee_notice_id` bigint NULL COMMENT 'privacy notice version they agreed to',
|
||||
ADD KEY `idx_ticket_event_mobile` (`event_uuid`, `attendee_mobile_e164`),
|
||||
ADD KEY `idx_ticket_event_email` (`event_uuid`, `attendee_email`);
|
||||
|
||||
-- Tickets of orders paid before this release get their code now (22 URL-safe characters, like the new ones).
|
||||
UPDATE `ticket` t JOIN `shop_order` o ON o.id = t.order_id
|
||||
SET t.code = LEFT(REPLACE(REPLACE(REPLACE(TO_BASE64(RANDOM_BYTES(16)), '+', '-'), '/', '_'), '=', ''), 22)
|
||||
WHERE o.status = 'PAID' AND t.status = 'ACTIVE' AND t.code IS NULL;
|
||||
@@ -0,0 +1,8 @@
|
||||
-- Co-Lite change add-event-tickets: rollback. Drops attendee naming times and consent records. Ticket codes stay (add-event-ticket-orders owns that column).
|
||||
USE `service-counter`;
|
||||
ALTER TABLE `ticket`
|
||||
DROP KEY `idx_ticket_event_mobile`,
|
||||
DROP KEY `idx_ticket_event_email`,
|
||||
DROP COLUMN `attendee_named_at`,
|
||||
DROP COLUMN `attendee_consent_at`,
|
||||
DROP COLUMN `attendee_notice_id`;
|
||||
@@ -0,0 +1,155 @@
|
||||
# Tasks
|
||||
|
||||
Design: `design.md` (technical contracts) and `docs/superpowers/specs/2026-12-04-event-ticketing-design.md` (product).
|
||||
|
||||
**Mode:** all tasks run serially in the main session (the owner asked for no worker subagents). Each task starts with failing tests (TDD).
|
||||
|
||||
## 1. Data
|
||||
|
||||
- [x] 1.1 Write the SQL:
|
||||
- `sql/01-ticket-attendees.sql`: the three `ticket` columns, the two keys, and codes for active tickets on Paid orders that have none;
|
||||
- `sql/99-rollback.sql`.
|
||||
|
||||
Mirror 01 in `local/seed/03-colite.sql` and apply it to the local database.
|
||||
- Depends on: none
|
||||
- Scope: `local/seed/**`, `openspec/changes/add-event-tickets/sql/**`
|
||||
- Verify: `SHOW CREATE TABLE ticket` shows the columns and keys; local Paid tickets have 22-character codes.
|
||||
|
||||
## 2. services-counter
|
||||
|
||||
- [x] 2.1 Ticket codes, ticket state and the ticket lookups.
|
||||
- Depends on: 1.1
|
||||
- Tests first:
|
||||
- **Codes:**
|
||||
- a free order's tickets get codes at creation;
|
||||
- mark paid (from Awaiting payment and from Expired) gives each active ticket a distinct 22-character code;
|
||||
- an Awaiting-payment order has none.
|
||||
- **`TicketState.of`:** valid, checked in, awaiting, order cancelled, order expired and ticket cancelled.
|
||||
- **`ticket/byCode`:**
|
||||
- returns the event, type, attendee first name, state and check-in time;
|
||||
- never returns mobile, email or buyer details;
|
||||
- an unknown code is 404 `TICKET_NOT_FOUND`.
|
||||
- **`byToken`:** lists tickets (id, type, attendee name, code, state) only when Paid, without contacts.
|
||||
- Scope: `solvway-services-counter/src/**`
|
||||
- Verify: `mvn -T 1C -q -pl solvway-services-counter verify`
|
||||
- [ ] 2.2 Naming attendees, consent and ticket emails.
|
||||
- Depends on: 2.1
|
||||
- Tests first:
|
||||
- **Naming:**
|
||||
- refused without `permission`, when the order is not Paid, when the ticket is cancelled, and when it is checked in (`ALREADY_CHECKED_IN`);
|
||||
- an unknown token or a ticket of another order is 404;
|
||||
- a save sets a new code and `attendee_named_at`, and clears consent and the lead link.
|
||||
- **Consent:**
|
||||
- refused on an invalid or unnamed ticket;
|
||||
- calls registration with source `TICKET`, the notice and no salesperson, and stores consent time, notice id and lead uuid.
|
||||
- **Mailer:**
|
||||
- PAID lists every active ticket with its QR `<img>` URL, its link and the "Name your attendees" link;
|
||||
- TICKET goes to the attendee's email;
|
||||
- naming with only a mobile sends nothing.
|
||||
- **Resend ticket:** goes to the attendee's email, else the buyer; refused for an invalid ticket.
|
||||
- Scope: `solvway-services-counter/src/**`
|
||||
- Verify: `mvn -T 1C -q -pl solvway-services-counter verify`
|
||||
- [ ] 2.3 Door check-in, self check-in rules and the counts.
|
||||
- Depends on: 2.2
|
||||
- Tests first:
|
||||
- **Staff check-in:**
|
||||
- records the time and user;
|
||||
- a second check-in gives `ALREADY_CHECKED_IN|<time>`;
|
||||
- each invalid state gives `NOT_VALID|<state>`;
|
||||
- outside the event days gives `NOT_EVENT_DAY`;
|
||||
- an unnamed ticket needs a name and contact;
|
||||
- consent creates the lead and marks it attended;
|
||||
- another company's ticket is 404.
|
||||
- **Self check-in on a ticketed event:**
|
||||
- a named attendee's ticket is checked in;
|
||||
- an unnamed ticket matches its buyer, oldest first;
|
||||
- a registered guest still works;
|
||||
- anything else gives `SHOW_TICKET`;
|
||||
- walk-in register is refused with `TICKETS_ONLY`.
|
||||
- On an event without tickets, the old results are unchanged.
|
||||
- **Headcount:** tickets awaiting, paid and checked in, counting active tickets only.
|
||||
- Scope: `solvway-services-counter/src/**`
|
||||
- Verify: `mvn -T 1C -q -pl solvway-services-counter verify`
|
||||
|
||||
## 3. mobile-api and gateway
|
||||
|
||||
- [ ] 3.1 Public ticket endpoints, the QR PNG and gateway paths.
|
||||
- Depends on: 2.3
|
||||
- Tests first:
|
||||
- **`GET /api/public/tickets/{code}`:**
|
||||
- a bad shape is 404 `TICKET_INVALID`;
|
||||
- the `tkt:load` limit applies;
|
||||
- the event fields are added.
|
||||
- **`qr.png`:**
|
||||
- the PNG decodes back to `<portal>/t/<code>`;
|
||||
- an invalid ticket is 404;
|
||||
- the response is `image/png`, `private`.
|
||||
- **Attendee save:**
|
||||
- name, mobile and email normalised as in QR registration;
|
||||
- a missing permission gives a field error;
|
||||
- counter refusals map to public messages;
|
||||
- the `tkt:submit` limit applies.
|
||||
- **Consent:** the current notice id is sent.
|
||||
- **Order view:** carries the tickets when Paid.
|
||||
- **Gateway:** the three counter paths are public, other shapes are not.
|
||||
- Adds `com.google.zxing:core` to `solvway-mobile-api/pom.xml`. This hotspot runs alone.
|
||||
- Scope: `solvway-mobile-api/**`, `solvway-api-gateway/src/**`
|
||||
- Verify: `mvn -T 1C -q -pl solvway-mobile-api,solvway-api-gateway verify`
|
||||
- [ ] 3.2 Admin ticket endpoints.
|
||||
- Depends on: 3.1
|
||||
- Tests first:
|
||||
- **`GET /api/admin/tickets/{code}`:** `BO_EVENTS` and company-scoped (another company's ticket is 404).
|
||||
- **`checkin`:** passes the body, maps 409 codes, is `@Audited`.
|
||||
- **Resend ticket:** under `BO_EVENT_TICKETS`, `@Audited`.
|
||||
- **Headcount:** passes the ticket counts.
|
||||
- **Check-in lookup:** passes `SHOW_TICKET`, and walk-in `TICKETS_ONLY` maps to its message.
|
||||
- Scope: `solvway-mobile-api/src/**`
|
||||
- Verify: `mvn -T 1C -q -pl solvway-mobile-api verify`
|
||||
|
||||
## 4. admin-portal
|
||||
|
||||
- [ ] 4.1 The ticket page `/t/[code]`.
|
||||
- Depends on: 3.2
|
||||
- Tests first:
|
||||
- **Public view:** valid, checked in, not valid and unknown.
|
||||
- **Consent:** only on a valid named ticket, with the notice.
|
||||
- **Staff view:**
|
||||
- shown only when the session and admin call succeed;
|
||||
- a 401, 403 or 404 keeps the public view and never redirects;
|
||||
- Check in;
|
||||
- the unnamed form;
|
||||
- the refusal banners.
|
||||
- **Routes:**
|
||||
- the route guard lets `/t/x` through;
|
||||
- the proxies send one X-Forwarded-For hop;
|
||||
- the PNG proxy passes bytes and content type.
|
||||
- Scope: `solvway-admin-portal/app/**`
|
||||
- Verify: `npx vitest run` (check the exit code), `npx tsc --noEmit`, `npm run lint`
|
||||
- [ ] 4.2 Order page tickets, staff resend, counts, venue check-in message and labels.
|
||||
- Depends on: 4.1
|
||||
- Tests first:
|
||||
- **Order page:**
|
||||
- a Paid order lists tickets with links and copy buttons;
|
||||
- the naming form, with the permission tick, mobile or email, and field errors;
|
||||
- a refusal for a checked-in ticket.
|
||||
- **Order detail:** Resend ticket per valid ticket.
|
||||
- **GuestsCard:** the three ticket counts on a ticketed event.
|
||||
- **`/c/[token]`:** shows "Please show your ticket at the entrance." for `SHOW_TICKET`, with no form.
|
||||
- **Labels:** English and zh-CN, plus `sql/02-ticket-labels.sql`; seed regenerated.
|
||||
- Scope: `solvway-admin-portal/app/**`, `openspec/changes/add-event-tickets/sql/**`, `local/seed/04-zh-cn-messages.sql`
|
||||
- Verify: `npx vitest run` (check the exit code), `npx tsc --noEmit`, `npm run lint`
|
||||
|
||||
## 5. Verify and ship
|
||||
|
||||
- [ ] 5.1 Rebuild the local stack, then check in Playwright, signing in through the form and clicking through.
|
||||
- On LC CV Expo, use the owner-approved test buyer "Tiket Test", tickets-test@example.com, and ask before any new order.
|
||||
- Open T-EKBD2K's order page and name an attendee. See the new link and that the old link is not valid.
|
||||
- On the ticket page, tick the consent and see the lead.
|
||||
- In the staff view, check a ticket in, then scan it again.
|
||||
- Check an unpaid ticket's refusal, and an unnamed ticket at the door.
|
||||
- Venue self check-in: a ticket holder, and a stranger who gets "show your ticket".
|
||||
- Check the counts on the event page and resend a ticket.
|
||||
- Take screenshots.
|
||||
- Depends on: 4.2
|
||||
- [ ] 5.2 Write the release note in `docs/deployment.md`. Open the PR to main and merge it, then archive the change in its own PR and republish the blueprint.
|
||||
- Depends on: 5.1
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-04
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -175,5 +175,5 @@ Design: `design.md` (technical contracts) and `docs/superpowers/specs/2026-12-04
|
||||
- Check the blocked paths: over 10 tickets, sold out, missing consent, and an unknown order link.
|
||||
- Take screenshots.
|
||||
- Depends on: 4.2
|
||||
- [ ] 5.2 Write the release note in `docs/deployment.md`. Open the PR to main and merge it, then archive the change in its own PR.
|
||||
- [x] 5.2 Write the release note in `docs/deployment.md`. Open the PR to main and merge it, then archive the change in its own PR.
|
||||
- Depends on: 5.1
|
||||
@@ -118,15 +118,7 @@ A guest's status SHALL be derived from the event lead it is linked to: Registere
|
||||
|
||||
### Requirement: Event attendance numbers
|
||||
|
||||
The event page SHALL show:
|
||||
|
||||
- invited: the number of guests, against the invitation cap when set;
|
||||
- registered: guests linked to an event lead;
|
||||
- attended: attended event leads;
|
||||
- walk-ins: event leads not linked to a guest;
|
||||
- total: registered guests plus walk-ins, against capacity when set.
|
||||
|
||||
The numbers SHALL agree with the guest list and the event leads listing. A total above capacity SHALL be shown, not hidden.
|
||||
The event page SHALL show invited guests (against the cap), registered guests, attended event leads, walk-ins (event leads linked to no guest and not created by a ticket order), held tickets (only when the event sells tickets), and a total of registered plus walk-ins plus held tickets (against capacity). The numbers SHALL agree with the guest list and event leads listing, and a total above capacity SHALL be shown.
|
||||
|
||||
#### Scenario: Numbers
|
||||
|
||||
@@ -134,6 +126,12 @@ The numbers SHALL agree with the guest list and the event leads listing. A total
|
||||
- **WHEN** an admin opens the event page
|
||||
- **THEN** the event page shows invited 40 of 50, registered 30, attended 35, walk-ins 15, total 45 of 100
|
||||
|
||||
#### Scenario: Ticket buyers are not walk-ins
|
||||
|
||||
- **GIVEN** `KL Hotel Tech Day` has 2 walk-ins, and a buyer whose order holds 3 tickets
|
||||
- **WHEN** an admin opens the event page
|
||||
- **THEN** the page shows walk-ins 2, held tickets 3, total 5
|
||||
|
||||
### Requirement: Check-in abuse limits
|
||||
|
||||
The check-in endpoints SHALL allow at most 300 lookups and submissions per IP per event per 10 minutes, answering "Too many attempts. Try again later." beyond that. The IP SHALL be determined as on the QR page. The check-in page SHALL NOT count against the QR page-load limit.
|
||||
|
||||
@@ -152,7 +152,7 @@ An accepted invite submission SHALL register the guest with the same normalisati
|
||||
|
||||
### Requirement: Capacity before the event
|
||||
|
||||
When an event has a capacity, invite registrations SHALL be refused before the event days once the number of registered guests plus walk-in event leads reaches it. A refused registration SHALL show "This event is full". On the event days (Malaysia, from the start date through the end date) no registration or check-in SHALL be refused for capacity. Staff capture SHALL never be refused for capacity.
|
||||
When an event has a capacity, invite registrations and ticket requests SHALL be refused before the event days once registered guests plus walk-in event leads plus held tickets would exceed it; an invite shows "This event is full". On the event days (Malaysia, start through end date) nothing SHALL be refused for capacity, though ticket types keep their own seats. Staff capture SHALL never be refused for capacity.
|
||||
|
||||
#### Scenario: Full before the event
|
||||
|
||||
@@ -166,6 +166,12 @@ When an event has a capacity, invite registrations SHALL be refused before the e
|
||||
- **WHEN** the third guest submits their invite
|
||||
- **THEN** they are registered
|
||||
|
||||
#### Scenario: Held tickets fill the event
|
||||
|
||||
- **GIVEN** `KL Expo` starts next week, has capacity 10, one registered guest and 9 held tickets
|
||||
- **WHEN** another guest submits their invite
|
||||
- **THEN** the page says the event is full and nothing is saved
|
||||
|
||||
### Requirement: Guest list access
|
||||
|
||||
Users with `BO_EVENTS` SHALL see an event's guest list with each guest's status, invite sent count and salesperson. Only users with `BO_EVENT_GUESTS` SHALL add, paste, remove, copy links for or send invites to guests. Guest endpoints SHALL apply the company scope as everywhere: staff only reach their company's events.
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
# event-ticketing Specification
|
||||
|
||||
## Purpose
|
||||
|
||||
Event ticket sales with payment outside Co-Lite: per-event ticket settings and types, buyer ticket requests from a landing page's Tickets section with seat holds, the buyer's order page and emails, hold expiry, and the staff order screens that mark orders paid or cancel orders and tickets.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: Ticket Settings On An Event
|
||||
|
||||
An event SHALL have a Tickets switch that is off by default, payment instructions of up to 1000 characters, and hold days from 1 to 14 that default to 3. Only users with `BO_EVENT_TICKETS` SHALL change them. While the switch is off, the event SHALL behave as it did before this change, and no ticket order SHALL be accepted for it. Turning the switch on SHALL require payment instructions.
|
||||
|
||||
#### Scenario: Turn tickets on
|
||||
|
||||
- **WHEN** a user with `BO_EVENT_TICKETS` turns Tickets on for `KL Hotel Tech Day` with payment instructions `Maybank 5140 1234 5678, ref your order number` and hold days 3
|
||||
- **THEN** the event shows Tickets on with those instructions and 3 hold days
|
||||
|
||||
#### Scenario: Instructions required
|
||||
|
||||
- **WHEN** a user turns Tickets on with empty payment instructions
|
||||
- **THEN** the save is refused on the payment instructions field and nothing changes
|
||||
|
||||
#### Scenario: Hold days out of range
|
||||
|
||||
- **WHEN** a user saves hold days 15
|
||||
- **THEN** the save is refused on the hold days field
|
||||
|
||||
#### Scenario: Without the permission
|
||||
|
||||
- **GIVEN** a user has `BO_EVENTS` but not `BO_EVENT_TICKETS`
|
||||
- **WHEN** they open the event
|
||||
- **THEN** they do not see the Tickets section
|
||||
|
||||
### Requirement: Ticket Types
|
||||
|
||||
A ticketed event SHALL have zero or more ticket types. Each type SHALL have a name of 1 to 80 characters unique within the event, a price in MYR from 0.00 to 99999.99 in whole sen, a quantity of at least 1, an optional sales end date (empty means the event's end date), a sort order and an enabled flag.
|
||||
|
||||
#### Scenario: Add types
|
||||
|
||||
- **WHEN** staff add `Early bird` at RM 150.00 quantity 20 and `General` at RM 250.00 quantity 100
|
||||
- **THEN** both types are listed in sort order with their prices and 20 and 100 seats left
|
||||
|
||||
### Requirement: Ticket Type Changes
|
||||
|
||||
A type with any order SHALL NOT be deleted, only disabled. A type's quantity SHALL NOT be set below the seats it holds. A price change SHALL apply only to orders made after it.
|
||||
|
||||
#### Scenario: Type with orders cannot be deleted
|
||||
|
||||
- **GIVEN** `Early bird` has an order
|
||||
- **WHEN** staff delete it
|
||||
- **THEN** the delete is refused with "This ticket type has orders. Disable it instead."
|
||||
|
||||
#### Scenario: Quantity below held seats
|
||||
|
||||
- **GIVEN** `Early bird` holds 12 seats
|
||||
- **WHEN** staff set its quantity to 10
|
||||
- **THEN** the save is refused on the quantity field
|
||||
|
||||
#### Scenario: Price change keeps old orders
|
||||
|
||||
- **GIVEN** an order holds 2 `General` tickets at RM 250.00
|
||||
- **WHEN** staff change `General` to RM 280.00
|
||||
- **THEN** that order still totals RM 500.00
|
||||
|
||||
### Requirement: Seats Held
|
||||
|
||||
A ticket SHALL hold a seat while its order is Awaiting payment or Paid and the ticket is not cancelled. A type's seats left SHALL be its quantity minus the seats it holds. Requests SHALL never cause a type to hold more seats than its quantity, including when requests arrive at the same moment. When the event has a capacity, a request made before the event days SHALL be refused if held tickets plus registered guests plus walk-in event leads would exceed it.
|
||||
|
||||
#### Scenario: Last seat taken once
|
||||
|
||||
- **GIVEN** `VIP` has 1 seat left
|
||||
- **WHEN** two visitors request 1 `VIP` ticket at the same moment
|
||||
- **THEN** one order is created and the other request is told `VIP` has only 0 left
|
||||
|
||||
#### Scenario: Expired order frees seats
|
||||
|
||||
- **GIVEN** an Awaiting-payment order holds 3 `General` tickets
|
||||
- **WHEN** it expires
|
||||
- **THEN** `General` shows 3 more seats left
|
||||
|
||||
#### Scenario: Event capacity
|
||||
|
||||
- **GIVEN** `KL Hotel Tech Day` starts next week with capacity 50, 45 held tickets and 3 registered guests
|
||||
- **WHEN** a visitor requests 3 tickets
|
||||
- **THEN** the request is refused with "Only 2 places are left for this event"
|
||||
|
||||
### Requirement: Ticket Request
|
||||
|
||||
A ticket request SHALL carry a quantity per ticket type from 0 to 10 with a total from 1 to 10, the buyer's name and email (both required), an optional mobile and company, and the privacy notice consent (required). Inputs SHALL be normalised and limited as in staff capture. An accepted request SHALL create one order with a line per type keeping its name and price at the time, one ticket per seat, an order reference unique within the company, and an unguessable link token.
|
||||
|
||||
#### Scenario: Request two types
|
||||
|
||||
- **WHEN** a visitor requests 2 `General` and 1 `VIP` as `Aisyah`, `aisyah@example.test`, and ticks the consent
|
||||
- **THEN** an order with 3 tickets totalling RM 1000.00 is Awaiting payment
|
||||
- **AND** the thank-you shows its reference, lines, total, payment instructions, hold expiry and a "View your order" link
|
||||
|
||||
#### Scenario: Missing email or consent
|
||||
|
||||
- **WHEN** a visitor submits without an email, or without ticking the consent
|
||||
- **THEN** nothing is saved and the error shows under that field
|
||||
|
||||
### Requirement: Ticket Request Refusals
|
||||
|
||||
A request SHALL be refused, saving nothing, when a requested type is disabled, past its sales end date or short of seats, naming the type and its seats left. A request SHALL be accepted only while the event has Tickets on, is enabled, has not passed its end date in Malaysia time, and its company has a privacy notice.
|
||||
|
||||
#### Scenario: Over ten
|
||||
|
||||
- **WHEN** a visitor requests 11 tickets
|
||||
- **THEN** the request is refused and nothing is saved
|
||||
|
||||
#### Scenario: Sales ended for a type
|
||||
|
||||
- **GIVEN** `Early bird` sales ended yesterday
|
||||
- **WHEN** a visitor requests 1 `Early bird`
|
||||
- **THEN** the request is refused naming `Early bird`
|
||||
|
||||
#### Scenario: Tickets turned off
|
||||
|
||||
- **GIVEN** staff turned Tickets off for `KL Hotel Tech Day`
|
||||
- **WHEN** a visitor submits a request
|
||||
- **THEN** the request is refused and nothing is saved
|
||||
|
||||
### Requirement: Free Orders
|
||||
|
||||
An order whose total is RM 0.00 SHALL be Paid when it is created, without staff action. Its thank-you page and email SHALL say the order is confirmed and SHALL NOT show payment instructions.
|
||||
|
||||
#### Scenario: Free ticket type
|
||||
|
||||
- **GIVEN** `Community pass` is priced RM 0.00
|
||||
- **WHEN** a visitor requests 2 `Community pass`
|
||||
- **THEN** the order is Paid at once and the thank-you says it is confirmed
|
||||
|
||||
### Requirement: Awaiting-Payment Limit Per Buyer
|
||||
|
||||
An email SHALL have at most 3 orders Awaiting payment per event. A further request SHALL be refused with "You already have orders awaiting payment for this event." and nothing SHALL be saved.
|
||||
|
||||
#### Scenario: Fourth unpaid order
|
||||
|
||||
- **GIVEN** `aisyah@example.test` has 3 orders Awaiting payment for `KL Hotel Tech Day`
|
||||
- **WHEN** she requests another ticket
|
||||
- **THEN** the request is refused with that message
|
||||
|
||||
### Requirement: Order States
|
||||
|
||||
An order SHALL be in one of four states:
|
||||
|
||||
- **Awaiting payment.**
|
||||
- **Paid.**
|
||||
- **Cancelled.**
|
||||
- **Expired.**
|
||||
|
||||
An order Awaiting payment SHALL hold its seats until its hold expiry, which is the creation time plus the event's hold days at the time of the request. After the hold expiry it SHALL become Expired within 15 minutes. Paid, Cancelled and Expired orders SHALL never expire.
|
||||
|
||||
#### Scenario: Hold runs out
|
||||
|
||||
- **GIVEN** an order made on 1 December at 10:00 with 3 hold days is still Awaiting payment
|
||||
- **WHEN** it is 4 December 10:15
|
||||
- **THEN** the order is Expired and its seats are free
|
||||
|
||||
### Requirement: Buyer Becomes An Event Lead
|
||||
|
||||
An accepted request SHALL match the buyer to a lead with the QR registration rules, including the existing-lead notes, and create the buyer's event lead with source TICKET, no salesperson, the consent time and notice version, and the page address and UTM values as for a FORM block. A buyer already captured at the event SHALL change nothing on that event lead except a note naming the order reference. These event leads SHALL appear in every lead listing, export and the dashboard.
|
||||
|
||||
#### Scenario: New buyer
|
||||
|
||||
- **WHEN** `Aisyah`, unknown to INS, requests tickets
|
||||
- **THEN** staff see `Aisyah` in the event's leads with source Ticket, NEW and OPEN
|
||||
|
||||
#### Scenario: Buyer already captured
|
||||
|
||||
- **GIVEN** `Aisyah` registered at `KL Hotel Tech Day` through the QR code
|
||||
- **WHEN** she requests tickets
|
||||
- **THEN** her event lead keeps source QR, and its notes name the order reference
|
||||
|
||||
### Requirement: Order Page
|
||||
|
||||
The order link `/o/<token>` SHALL show:
|
||||
|
||||
- the event's name, dates and location;
|
||||
- the order reference, lines, total, state and creation time;
|
||||
- while Awaiting payment, the payment instructions and hold expiry.
|
||||
|
||||
It SHALL show the buyer's name but no other personal details. An unknown token SHALL show "This order link is not valid." The page SHALL be limited to 120 loads per IP per 10 minutes.
|
||||
|
||||
#### Scenario: Unpaid order page
|
||||
|
||||
- **GIVEN** order `T-7K3M9Q` is Awaiting payment
|
||||
- **WHEN** the buyer opens its link
|
||||
- **THEN** the page shows the lines, total, payment instructions and hold expiry
|
||||
|
||||
#### Scenario: Unknown link
|
||||
|
||||
- **WHEN** a visitor opens `/o/` with an unknown token
|
||||
- **THEN** the page says the order link is not valid and shows nothing else
|
||||
|
||||
### Requirement: Order Emails
|
||||
|
||||
The buyer SHALL get an email when their order is created (lines, total, payment instructions, hold expiry and order link), becomes Paid (a confirmation with lines, total and order link), Expires, or is Cancelled by staff. Each email SHALL be recorded in Emails. A failed send SHALL NOT undo the order change, and staff SHALL be able to resend the latest email of an order.
|
||||
|
||||
#### Scenario: Order received email
|
||||
|
||||
- **WHEN** `Aisyah` requests tickets
|
||||
- **THEN** she receives an email with the order reference, payment instructions, hold expiry and order link
|
||||
|
||||
#### Scenario: Paid email
|
||||
|
||||
- **WHEN** staff mark her order Paid
|
||||
- **THEN** she receives a confirmation email
|
||||
|
||||
### Requirement: Staff Order Screens
|
||||
|
||||
The event's Tickets section SHALL list the event's orders with reference, buyer name, email, ticket count, total, state and creation time, newest first in pages of 50, filterable by state and searchable by reference, name, email or mobile. The order detail SHALL show the lines, tickets, buyer details, payment reference, and who changed the state and when. A user without `BO_EVENT_TICKETS` SHALL NOT see or reach these screens.
|
||||
|
||||
#### Scenario: Company separation
|
||||
|
||||
- **WHEN** INS staff open an order of a CV event by its address
|
||||
- **THEN** they get not found
|
||||
|
||||
### Requirement: Staff Order Actions
|
||||
|
||||
Users with `BO_EVENT_TICKETS` SHALL be able to mark an order paid with an optional payment reference of up to 100 characters (when Awaiting payment, or Expired with all its seats still available), cancel an order that is Awaiting payment or Paid (freeing its seats), cancel one ticket of such an order that has another uncancelled ticket (freeing the seat and lowering the total), and resend the latest order email. Each action SHALL be written to the admin audit log.
|
||||
|
||||
#### Scenario: Mark paid with reference
|
||||
|
||||
- **GIVEN** order `T-7K3M9Q` is Awaiting payment
|
||||
- **WHEN** staff mark it paid with reference `MBB 0412 883`
|
||||
- **THEN** the order is Paid with that reference, their name and the time
|
||||
- **AND** the audit log records the action
|
||||
|
||||
#### Scenario: Expired order after its seats were taken
|
||||
|
||||
- **GIVEN** order `T-7K3M9Q` expired, and its `VIP` seat was then taken by another order
|
||||
- **WHEN** staff mark it paid
|
||||
- **THEN** the action is refused with "Not enough seats left to confirm this order" and the order stays Expired
|
||||
|
||||
#### Scenario: Cancel one ticket
|
||||
|
||||
- **GIVEN** a Paid order holds 3 `General` tickets at RM 250.00
|
||||
- **WHEN** staff cancel one ticket
|
||||
- **THEN** the order holds 2 tickets, totals RM 500.00, and `General` has one more seat left
|
||||
|
||||
### Requirement: Ticket Request Abuse Limits
|
||||
|
||||
Ticket requests SHALL follow the QR registration limits: at most 60 requests per client IP per event in 10 minutes, answered above the limit with "Too many registrations from this device. Try again later." A request that fills the hidden honeypot field SHALL get the normal thank-you page and save nothing.
|
||||
|
||||
#### Scenario: Too many requests
|
||||
|
||||
- **WHEN** one IP submits 61 ticket requests for an event within 10 minutes
|
||||
- **THEN** the 61st is refused with "Too many registrations from this device. Try again later."
|
||||
|
||||
#### Scenario: Honeypot filled
|
||||
|
||||
- **WHEN** a request fills the hidden honeypot field
|
||||
- **THEN** the thank-you page shows and no order is saved
|
||||
@@ -846,3 +846,33 @@ A page with a top bar, a full-width hero with its sign-up form, and a trust stri
|
||||
|
||||
- **WHEN** a visitor opens a landing page with a sign-up form
|
||||
- **THEN** each text field, the service dropdown and the Register button are at least 44 px tall
|
||||
|
||||
### Requirement: Tickets Block
|
||||
|
||||
A page MAY hold TICKETS blocks. The page SHALL show each enabled ticket type of the block's event in sort order with its name, its price as `RM 150.00` or `Free`, and its seats left or "Sold out" or "Sales ended", a quantity picker per type with an order total of at most 10, the running total, the buyer's fields and the privacy consent. When the event no longer accepts requests, the block SHALL say ticket sales are closed and the rest of the page SHALL still show.
|
||||
|
||||
#### Scenario: Visitor sees ticket types
|
||||
|
||||
- **GIVEN** a published page with a TICKETS block for `KL Hotel Tech Day`, whose types are `Early bird` RM 150.00 with 12 left, `General` RM 250.00 with 80 left, and `VIP` RM 500.00 sold out
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the block lists the three types with their prices, shows "Sold out" for `VIP`, and offers no quantity for `VIP`
|
||||
|
||||
#### Scenario: Sales closed
|
||||
|
||||
- **GIVEN** the event of a TICKETS block ended yesterday
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the block says ticket sales are closed and the other blocks still show
|
||||
|
||||
### Requirement: Tickets Block Fields
|
||||
|
||||
A TICKETS block SHALL name one event of the page's company that is enabled, not ended and has Tickets on when saved. It MAY have a heading (120 characters), text (1000 characters), a section label, a look and a link name. The server SHALL refuse any other field. Both editors SHALL offer the block and pick its event from the company's events that qualify.
|
||||
|
||||
#### Scenario: Event without tickets
|
||||
|
||||
- **WHEN** staff save a TICKETS block for an event whose Tickets switch is off
|
||||
- **THEN** the save is refused on that block's event field
|
||||
|
||||
#### Scenario: Add a tickets block in the editor
|
||||
|
||||
- **WHEN** staff add a Tickets section in the on-page editor and pick `KL Hotel Tech Day`
|
||||
- **THEN** the canvas shows that event's ticket types
|
||||
@@ -222,6 +222,15 @@ describe("LandingPage thank-you text and footer", () => {
|
||||
expect(within(foot).getByText(/^© 2026/)).toHaveClass("border-t");
|
||||
});
|
||||
|
||||
it("ends the page at the footer: no blank strip below a closing footer", () => {
|
||||
const { unmount } = render(<LandingPage company={company} page={page([{ type: "FAQ", items: [{ question: "Q", answer: "A" }] }, footer])} />);
|
||||
expect(screen.getByRole("main")).not.toHaveClass("pb-8");
|
||||
expect(screen.getByRole("main")).not.toHaveClass("py-8");
|
||||
unmount();
|
||||
render(<LandingPage company={company} page={page([footer, { type: "FAQ", items: [{ question: "Q", answer: "A" }] }])} />);
|
||||
expect(screen.getByRole("main").className).toMatch(/p[by]-8/);
|
||||
});
|
||||
|
||||
it("keeps markup in footer text as text", () => {
|
||||
render(<LandingPage company={company} page={page([{ type: "FOOTER", cards: [{ title: "Call", text: "<b>Call</b> +60 12-833 2775" }] }])} />);
|
||||
const foot = screen.getByRole("contentinfo");
|
||||
|
||||
@@ -347,7 +347,8 @@ export function LandingPage({ company, page, banner, preview, frameBase, edit }:
|
||||
)}
|
||||
</div>
|
||||
</header>}
|
||||
<main className={page.hideHeader ? "pb-8" : "py-8"}>
|
||||
{/* A closing footer is the page's end: no padding below it. */}
|
||||
<main className={`${page.hideHeader ? "" : "pt-8"} ${page.blocks.at(-1)?.type === "FOOTER" ? "" : "pb-8"}`}>
|
||||
<h1 className={page.hideHeader ? "sr-only" : `${WIDTH} mb-10 text-3xl font-semibold sm:text-4xl`}>{page.title}</h1>
|
||||
<div>
|
||||
{page.blocks.map((block, i) => (
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 15 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="7" fill="#2563EB"/><path d="M20.5 11.2a7 7 0 1 0 0 9.6" fill="none" stroke="#fff" stroke-width="3.2" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 225 B |
@@ -1 +0,0 @@
|
||||
<?xml version="1.0"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4000 4000"><path d="M2186.36,1601.76c-24.12,17.98-58.25,13.01-76.24-11.11-282.34-378.65-297.94-846.34-34.79-1042.55,24.12-17.98,58.25-13.01,76.24,11.11s13.01,58.25-11.11,76.24c-214.99,160.3-189.41,559.59,57.01,890.08,17.98,24.12,13.01,58.25-11.11,76.24Z" fill="#8e3b19"></path><path d="M2635.68,951.73c-75.77-7.45-150.69,3.21-222.99,29.66-337,123.31-699.95,146.55-1057.37,114.64-67.05-5.99-133.3.63-197.22,21.17-401.04,128.82-558.27,755.87-351.19,1400.57,207.08,644.7,700.06,1062.9,1101.1,934.09,21.26-6.83,41.82-15.07,61.67-24.64,118.07-56.93,251.94-66.89,380.59-41.76,14.91,2.91,30.01,5.13,45.29,6.63,419.19,41.25,812.78-471.61,879.08-1145.49,66.31-673.89-219.76-1253.62-638.96-1294.86Z" fill="#de0d06"></path><ellipse cx="1440.04" cy="1951.4" rx="363.18" ry="541" transform="translate(-77.15 59.36) rotate(-2.3)" fill="#f23f3a"></ellipse><path d="M1827.99,2875.26c62.28,135.79,38.86,279.77-52.3,321.58-91.16,41.81-215.55-34.38-277.82-170.18-62.28-135.79-38.86-279.76,52.3-321.57,91.16-41.81,215.55,34.38,277.82,170.17Z" fill="#f23f3a"></path></svg>
|
||||
|
Before Width: | Height: | Size: 1.1 KiB |
+21
@@ -0,0 +1,21 @@
|
||||
package com.solvway.services.counter.controller;
|
||||
|
||||
import com.solvway.services.counter.service.TicketService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/** Tickets (add-event-tickets). byCode is a public path; mobile-api checks the code's shape first. */
|
||||
@RestController
|
||||
@RequestMapping("/counter/ticket")
|
||||
@AllArgsConstructor
|
||||
public class TicketController {
|
||||
private final TicketService service;
|
||||
|
||||
@GetMapping("/byCode/{code}")
|
||||
public TicketService.TicketView byCode(@PathVariable String code) {
|
||||
return service.byCode(code);
|
||||
}
|
||||
}
|
||||
@@ -63,4 +63,13 @@ public class Ticket {
|
||||
|
||||
@Column(name = "checked_in_by")
|
||||
private String checkedInBy;
|
||||
|
||||
@Column(name = "attendee_named_at")
|
||||
private LocalDateTime attendeeNamedAt;
|
||||
|
||||
@Column(name = "attendee_consent_at")
|
||||
private LocalDateTime attendeeConsentAt;
|
||||
|
||||
@Column(name = "attendee_notice_id")
|
||||
private Long attendeeNoticeId;
|
||||
}
|
||||
+2
@@ -22,6 +22,8 @@ public interface TicketRepository extends JpaRepository<Ticket, Long> {
|
||||
|
||||
List<Ticket> findByOrderIdOrderByIdAsc(long orderId);
|
||||
|
||||
java.util.Optional<Ticket> findByCode(String code);
|
||||
|
||||
/** Active tickets per order for one page of the staff list: one query, no N+1. */
|
||||
@Query("select new com.solvway.services.counter.repo.TicketCount(t.orderId, count(t)) from Ticket t"
|
||||
+ " where t.orderId in :orderIds and t.status = 'ACTIVE' group by t.orderId")
|
||||
|
||||
+15
-2
@@ -76,14 +76,26 @@ public class TicketOrderService {
|
||||
|
||||
/** The public order page: the buyer's name but no other personal details. */
|
||||
public record OrderView(long companyId, Long eventUuid, String reference, String status, String buyerName, int totalSen,
|
||||
LocalDateTime holdUntil, LocalDateTime createdAt, List<LineView> lines) {}
|
||||
LocalDateTime holdUntil, LocalDateTime createdAt, List<LineView> lines, List<OrderTicket> tickets) {}
|
||||
|
||||
/** add-event-tickets: a Paid order's ticket on its order page; never the attendee's contact. */
|
||||
public record OrderTicket(long id, String typeName, String attendeeName, String code, String state, LocalDateTime checkedInAt) {}
|
||||
|
||||
public OrderView byToken(String token) {
|
||||
ShopOrder o = orders.findByToken(token).orElseThrow(() -> status(HttpStatus.NOT_FOUND, "ORDER_NOT_FOUND"));
|
||||
List<LineView> views = lines.findByOrderIdOrderByIdAsc(o.getId()).stream()
|
||||
.map(l -> new LineView(l.getName(), l.getUnitPriceSen(), l.getQuantity())).toList();
|
||||
List<OrderTicket> paid = List.of();
|
||||
if (ShopOrder.PAID.equals(o.getStatus())) {
|
||||
Map<Long, String> names = lines.findByOrderIdOrderByIdAsc(o.getId()).stream()
|
||||
.collect(Collectors.toMap(ShopOrderLine::getId, ShopOrderLine::getName));
|
||||
paid = tickets.findByOrderIdOrderByIdAsc(o.getId()).stream().filter(t -> Ticket.ACTIVE.equals(t.getStatus()))
|
||||
.map(t -> new OrderTicket(t.getId(), names.get(t.getOrderLineId()), t.getAttendeeName(), t.getCode(),
|
||||
TicketState.of(o, t), t.getCheckedInAt()))
|
||||
.toList();
|
||||
}
|
||||
return new OrderView(o.getCompanyId(), o.getEventUuid(), o.getReference(), o.getStatus(), o.getBuyerName(), o.getTotalSen(),
|
||||
o.getHoldUntil(), o.getCreatedAt(), views);
|
||||
o.getHoldUntil(), o.getCreatedAt(), views, paid);
|
||||
}
|
||||
|
||||
public Result request(Request r) {
|
||||
@@ -175,6 +187,7 @@ public class TicketOrderService {
|
||||
ticket.setOrderId(o.getId());
|
||||
ticket.setOrderLineId(line.getId());
|
||||
ticket.setTicketTypeId(t.getId());
|
||||
if (total == 0) ticket.setCode(TicketState.newCode()); // add-event-tickets: a free order is Paid at once
|
||||
tickets.save(ticket);
|
||||
}
|
||||
views.add(new LineView(t.getName(), t.getPriceSen(), l.quantity()));
|
||||
|
||||
+6
@@ -110,6 +110,12 @@ public class TicketOrderStaffService {
|
||||
o.setPaymentRef(ref);
|
||||
o.setLastEmail(TicketOrderMailer.PAID);
|
||||
orders.save(o);
|
||||
for (Ticket t : tickets.findByOrderIdOrderByIdAsc(o.getId())) { // add-event-tickets: the codes come with payment
|
||||
if (Ticket.ACTIVE.equals(t.getStatus()) && t.getCode() == null) {
|
||||
t.setCode(TicketState.newCode());
|
||||
tickets.save(t);
|
||||
}
|
||||
}
|
||||
mailer.send(o, TicketOrderMailer.PAID);
|
||||
}
|
||||
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.solvway.services.counter.service;
|
||||
|
||||
import com.solvway.services.counter.repo.ShopOrderLineRepository;
|
||||
import com.solvway.services.counter.repo.ShopOrderRepository;
|
||||
import com.solvway.services.counter.repo.TicketRepository;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.solvway.services.counter.model.ShopOrder;
|
||||
import com.solvway.services.counter.model.ShopOrderLine;
|
||||
import com.solvway.services.counter.model.Ticket;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/** add-event-tickets: tickets by their code. */
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TicketService {
|
||||
private final TicketRepository tickets;
|
||||
private final ShopOrderRepository orders;
|
||||
private final ShopOrderLineRepository lines;
|
||||
|
||||
/** The public ticket page: no buyer details and no attendee contact. */
|
||||
public record TicketView(long companyId, long eventUuid, String typeName, String attendeeFirstName, boolean named, String state,
|
||||
LocalDateTime checkedInAt) {}
|
||||
|
||||
public TicketView byCode(String code) {
|
||||
Ticket t = ticket(code);
|
||||
ShopOrder o = orders.findById(t.getOrderId()).orElseThrow(TicketService::notFound);
|
||||
String typeName = lines.findById(t.getOrderLineId()).map(ShopOrderLine::getName).orElse(null);
|
||||
return new TicketView(t.getCompanyId(), t.getEventUuid(), typeName, firstName(t.getAttendeeName()), t.getAttendeeName() != null,
|
||||
TicketState.of(o, t), t.getCheckedInAt());
|
||||
}
|
||||
|
||||
Ticket ticket(String code) {
|
||||
if (code == null) throw notFound();
|
||||
return tickets.findByCode(code).orElseThrow(TicketService::notFound);
|
||||
}
|
||||
|
||||
static ResponseStatusException notFound() {
|
||||
return new ResponseStatusException(HttpStatus.NOT_FOUND, "TICKET_NOT_FOUND");
|
||||
}
|
||||
|
||||
static String firstName(String name) {
|
||||
if (name == null || name.isBlank()) return null;
|
||||
String t = name.strip();
|
||||
int sp = t.indexOf(' ');
|
||||
return sp < 0 ? t : t.substring(0, sp);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.solvway.services.counter.service;
|
||||
|
||||
import com.solvway.services.counter.model.ShopOrder;
|
||||
import com.solvway.services.counter.model.Ticket;
|
||||
|
||||
/** add-event-tickets: one ticket's state, the single rule the ticket page, the door and self check-in all use. */
|
||||
public final class TicketState {
|
||||
public static final String VALID = "VALID";
|
||||
public static final String CHECKED_IN = "CHECKED_IN";
|
||||
public static final String AWAITING = "AWAITING";
|
||||
public static final String ORDER_CANCELLED = "ORDER_CANCELLED";
|
||||
public static final String ORDER_EXPIRED = "ORDER_EXPIRED";
|
||||
public static final String TICKET_CANCELLED = "TICKET_CANCELLED";
|
||||
|
||||
private TicketState() {}
|
||||
|
||||
public static String of(ShopOrder order, Ticket ticket) {
|
||||
if (Ticket.CANCELLED.equals(ticket.getStatus())) return TICKET_CANCELLED;
|
||||
return switch (order.getStatus()) {
|
||||
case ShopOrder.PAID -> ticket.getCheckedInAt() != null ? CHECKED_IN : VALID;
|
||||
case ShopOrder.CANCELLED -> ORDER_CANCELLED;
|
||||
case ShopOrder.EXPIRED -> ORDER_EXPIRED;
|
||||
default -> AWAITING;
|
||||
};
|
||||
}
|
||||
|
||||
/** A new ticket code: 22 URL-safe characters, as the other link tokens. */
|
||||
public static String newCode() {
|
||||
return RegistrationLinkService.newToken();
|
||||
}
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
package com.solvway.services.counter.service;
|
||||
|
||||
import com.solvway.services.counter.model.Event;
|
||||
import com.solvway.services.counter.model.ShopOrder;
|
||||
import com.solvway.services.counter.model.ShopOrderLine;
|
||||
import com.solvway.services.counter.model.Ticket;
|
||||
import com.solvway.services.counter.model.TicketType;
|
||||
import com.solvway.services.counter.repo.EventGuestRepository;
|
||||
import com.solvway.services.counter.repo.EventLeadRepository;
|
||||
import com.solvway.services.counter.repo.EventRepository;
|
||||
import com.solvway.services.counter.repo.ShopOrderLineRepository;
|
||||
import com.solvway.services.counter.repo.ShopOrderRepository;
|
||||
import com.solvway.services.counter.repo.TicketRepository;
|
||||
import com.solvway.services.counter.repo.TicketTypeRepository;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** add-event-tickets: codes on payment, ticket state, the code lookup and the order page's tickets (spec: Ticket Codes, Ticket Page,
|
||||
* Invalid Ticket Links, Tickets On The Order Page). */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class TicketCodesTest {
|
||||
private static final long COMPANY = 7L;
|
||||
private static final long EVENT = 900L;
|
||||
private static final LocalDate TODAY = LocalDate.now(ZoneId.of("Asia/Kuala_Lumpur"));
|
||||
private static final String CODE_SHAPE = "[A-Za-z0-9_-]{22}";
|
||||
|
||||
@Mock private EventRepository events;
|
||||
@Mock private TicketTypeRepository types;
|
||||
@Mock private TicketRepository tickets;
|
||||
@Mock private ShopOrderRepository orders;
|
||||
@Mock private ShopOrderLineRepository lines;
|
||||
@Mock private EventGuestRepository guests;
|
||||
@Mock private EventLeadRepository eventLeads;
|
||||
@Mock private RegistrationService registration;
|
||||
@Mock private TicketOrderMailer mailer;
|
||||
|
||||
private TicketOrderService orderService;
|
||||
private TicketOrderStaffService staff;
|
||||
private TicketService ticketService;
|
||||
private final List<Ticket> saved = new ArrayList<>();
|
||||
private ShopOrder order;
|
||||
private ShopOrderLine line;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
TicketTypeService typeService = new TicketTypeService(events, types, tickets, lines);
|
||||
orderService = new TicketOrderService(new TransactionTemplate(mock(PlatformTransactionManager.class)), events, typeService, types,
|
||||
orders, lines, tickets, guests, eventLeads, registration, mailer);
|
||||
staff = new TicketOrderStaffService(events, typeService, types, tickets, orders, lines, mailer);
|
||||
ticketService = new TicketService(tickets, orders, lines);
|
||||
Event event = new Event();
|
||||
event.setUuid(EVENT);
|
||||
event.setCompanyId(COMPANY);
|
||||
event.setDateStart(TODAY.plusDays(7).atTime(9, 0));
|
||||
event.setDateEnd(TODAY.plusDays(8).atTime(18, 0));
|
||||
event.setTicketsEnabled(true);
|
||||
event.setHoldDays(3);
|
||||
lenient().when(events.lockByUuid(EVENT)).thenReturn(Optional.of(event));
|
||||
TicketType free = new TicketType();
|
||||
free.setId(5L);
|
||||
free.setCompanyId(COMPANY);
|
||||
free.setEventUuid(EVENT);
|
||||
free.setName("Community pass");
|
||||
free.setQuantity(50);
|
||||
free.setEnabled(true);
|
||||
TicketType general = new TicketType();
|
||||
general.setId(2L);
|
||||
general.setCompanyId(COMPANY);
|
||||
general.setEventUuid(EVENT);
|
||||
general.setName("General");
|
||||
general.setPriceSen(25000);
|
||||
general.setQuantity(50);
|
||||
general.setEnabled(true);
|
||||
lenient().when(types.findByEventUuidOrderBySortAscIdAsc(EVENT)).thenReturn(List.of(general, free));
|
||||
lenient().when(orders.saveAndFlush(any(ShopOrder.class))).thenAnswer(i -> {
|
||||
ShopOrder o = i.getArgument(0);
|
||||
o.setId(300L);
|
||||
return o;
|
||||
});
|
||||
lenient().when(orders.save(any(ShopOrder.class))).thenAnswer(i -> i.getArgument(0));
|
||||
lenient().when(lines.save(any(ShopOrderLine.class))).thenAnswer(i -> {
|
||||
ShopOrderLine l = i.getArgument(0);
|
||||
l.setId(400L);
|
||||
return l;
|
||||
});
|
||||
lenient().when(tickets.save(any(Ticket.class))).thenAnswer(i -> {
|
||||
saved.add(i.getArgument(0));
|
||||
return i.getArgument(0);
|
||||
});
|
||||
lenient().when(registration.register(any())).thenReturn(new RegistrationService.RegisterResult("CREATED", null));
|
||||
|
||||
order = new ShopOrder();
|
||||
order.setId(300L);
|
||||
order.setCompanyId(COMPANY);
|
||||
order.setEventUuid(EVENT);
|
||||
order.setReference("T-7K3M9Q");
|
||||
order.setStatus(ShopOrder.AWAITING);
|
||||
order.setBuyerName("Aisyah Rahman");
|
||||
order.setBuyerEmail("a@example.test");
|
||||
lenient().when(orders.findById(300L)).thenReturn(Optional.of(order));
|
||||
line = new ShopOrderLine();
|
||||
line.setId(400L);
|
||||
line.setOrderId(300L);
|
||||
line.setItemId(2L);
|
||||
line.setName("General");
|
||||
line.setUnitPriceSen(25000);
|
||||
line.setQuantity(2);
|
||||
lenient().when(lines.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(line));
|
||||
lenient().when(lines.findById(400L)).thenReturn(Optional.of(line));
|
||||
}
|
||||
|
||||
private static TicketOrderService.Request request(long typeId, int qty) {
|
||||
return new TicketOrderService.Request(COMPANY, EVENT, List.of(new TicketOrderService.LineRequest(typeId, qty)), "Aisyah",
|
||||
"a@example.test", null, null, 77L, LocalDateTime.now(), null, null, null, null);
|
||||
}
|
||||
|
||||
private static Ticket ticket(long id, String status) {
|
||||
Ticket t = new Ticket();
|
||||
t.setId(id);
|
||||
t.setCompanyId(COMPANY);
|
||||
t.setEventUuid(EVENT);
|
||||
t.setOrderId(300L);
|
||||
t.setOrderLineId(400L);
|
||||
t.setTicketTypeId(2L);
|
||||
t.setStatus(status);
|
||||
return t;
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFreeOrdersTicketsGetDistinctCodesAtOnce() {
|
||||
orderService.request(request(5L, 3));
|
||||
assertThat(saved).hasSize(3).allSatisfy(t -> assertThat(t.getCode()).matches(CODE_SHAPE));
|
||||
assertThat(new HashSet<>(saved.stream().map(Ticket::getCode).toList())).hasSize(3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAwaitingOrdersTicketsHaveNoCode() {
|
||||
orderService.request(request(2L, 2));
|
||||
assertThat(saved).hasSize(2).allSatisfy(t -> assertThat(t.getCode()).isNull());
|
||||
}
|
||||
|
||||
@Test
|
||||
void markPaidGivesEachActiveTicketACode() {
|
||||
Ticket a = ticket(1L, Ticket.ACTIVE), b = ticket(2L, Ticket.ACTIVE), c = ticket(3L, Ticket.CANCELLED);
|
||||
when(tickets.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(a, b, c));
|
||||
staff.markPaid(new TicketOrderStaffService.PayRequest(COMPANY, EVENT, 300L, null, "staff1"));
|
||||
assertThat(a.getCode()).matches(CODE_SHAPE);
|
||||
assertThat(b.getCode()).matches(CODE_SHAPE).isNotEqualTo(a.getCode());
|
||||
assertThat(c.getCode()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void anExpiredOrderMarkedPaidGetsCodes() {
|
||||
order.setStatus(ShopOrder.EXPIRED);
|
||||
Ticket a = ticket(1L, Ticket.ACTIVE);
|
||||
when(tickets.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(a));
|
||||
staff.markPaid(new TicketOrderStaffService.PayRequest(COMPANY, EVENT, 300L, null, "staff1"));
|
||||
assertThat(a.getCode()).matches(CODE_SHAPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void ticketStateCoversEveryCase() {
|
||||
Ticket t = ticket(1L, Ticket.ACTIVE);
|
||||
order.setStatus(ShopOrder.PAID);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.VALID);
|
||||
t.setCheckedInAt(LocalDateTime.now());
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.CHECKED_IN);
|
||||
t.setCheckedInAt(null);
|
||||
t.setStatus(Ticket.CANCELLED);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.TICKET_CANCELLED);
|
||||
t.setStatus(Ticket.ACTIVE);
|
||||
order.setStatus(ShopOrder.AWAITING);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.AWAITING);
|
||||
order.setStatus(ShopOrder.CANCELLED);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.ORDER_CANCELLED);
|
||||
order.setStatus(ShopOrder.EXPIRED);
|
||||
assertThat(TicketState.of(order, t)).isEqualTo(TicketState.ORDER_EXPIRED);
|
||||
}
|
||||
|
||||
@Test
|
||||
void byCodeShowsTheTicketWithoutContactDetails() {
|
||||
order.setStatus(ShopOrder.PAID);
|
||||
Ticket t = ticket(1L, Ticket.ACTIVE);
|
||||
t.setCode("abcdefghijklmnopqrstuv");
|
||||
t.setAttendeeName("Tan Mei Ling");
|
||||
t.setAttendeeEmail("tan@example.test");
|
||||
t.setAttendeeMobileE164("+60125550101");
|
||||
when(tickets.findByCode("abcdefghijklmnopqrstuv")).thenReturn(Optional.of(t));
|
||||
TicketService.TicketView v = ticketService.byCode("abcdefghijklmnopqrstuv");
|
||||
assertThat(v.companyId()).isEqualTo(COMPANY);
|
||||
assertThat(v.eventUuid()).isEqualTo(EVENT);
|
||||
assertThat(v.typeName()).isEqualTo("General");
|
||||
assertThat(v.attendeeFirstName()).isEqualTo("Tan");
|
||||
assertThat(v.named()).isTrue();
|
||||
assertThat(v.state()).isEqualTo(TicketState.VALID);
|
||||
assertThat(v.toString()).doesNotContain("tan@example.test", "+60125550101", "Aisyah");
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnknownCodeIsNotFound() {
|
||||
when(tickets.findByCode("zzzzzzzzzzzzzzzzzzzzzz")).thenReturn(Optional.empty());
|
||||
assertThatThrownBy(() -> ticketService.byCode("zzzzzzzzzzzzzzzzzzzzzz")).isInstanceOfSatisfying(ResponseStatusException.class, e -> {
|
||||
assertThat(e.getStatusCode().value()).isEqualTo(404);
|
||||
assertThat(e.getReason()).isEqualTo("TICKET_NOT_FOUND");
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void thePaidOrderPageListsTicketsWithoutContacts() {
|
||||
order.setStatus(ShopOrder.PAID);
|
||||
Ticket a = ticket(1L, Ticket.ACTIVE), b = ticket(2L, Ticket.ACTIVE), c = ticket(3L, Ticket.CANCELLED);
|
||||
a.setCode("aaaaaaaaaaaaaaaaaaaaaa");
|
||||
a.setAttendeeName("Tan Mei Ling");
|
||||
a.setAttendeeEmail("tan@example.test");
|
||||
b.setCode("bbbbbbbbbbbbbbbbbbbbbb");
|
||||
when(orders.findByToken("tokentokentokentokento")).thenReturn(Optional.of(order));
|
||||
when(tickets.findByOrderIdOrderByIdAsc(300L)).thenReturn(List.of(a, b, c));
|
||||
TicketOrderService.OrderView v = orderService.byToken("tokentokentokentokento");
|
||||
assertThat(v.tickets()).extracting(TicketOrderService.OrderTicket::id).containsExactly(1L, 2L);
|
||||
assertThat(v.tickets().get(0)).isEqualTo(new TicketOrderService.OrderTicket(1L, "General", "Tan Mei Ling", "aaaaaaaaaaaaaaaaaaaaaa",
|
||||
TicketState.VALID, null));
|
||||
assertThat(v.tickets().get(1).attendeeName()).isNull();
|
||||
assertThat(v.toString()).doesNotContain("tan@example.test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnpaidOrderPageHasNoTickets() {
|
||||
when(orders.findByToken("tokentokentokentokento")).thenReturn(Optional.of(order));
|
||||
assertThat(orderService.byToken("tokentokentokentokento").tickets()).isEmpty();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user