Discounts and messages (Vendor)
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
Executive summary
Section titled “Executive summary”Discounts implements coupons against the real API (coupon module). Messages is a UI demo with hardcoded contacts—not a production messaging API.
Goals and non-goals
Section titled “Goals and non-goals”| Goals | Non-goals |
|---|---|
| Run coupon lifecycle safely | Provide chat/voicemail replacement |
| Warn that messages screen is demo | Build full messaging backend here |
Current platform behavior
Section titled “Current platform behavior”/dashboard/discounts— real service (vendor-coupons.api.ts)./dashboard/messages— static/demo only.
Sequence: happy path
Section titled “Sequence: happy path”- Owner/staff with
coupon→ manage coupons → verify at checkout/POS. - Ignore Messages for ops unless/until API exists.
Security and operations
Section titled “Security and operations”- Coupon abuse = revenue risk—use approval workflows outside the app if required.
Test scenarios (UAT / QA)
Section titled “Test scenarios (UAT / QA)”| ID | Scenario | Expected |
|---|---|---|
| DM1 | Create coupon | API persists; visible in list |
| DM2 | Messages screen | Demo only—no delivery guarantee |
| DM3 | Employee without coupon | Blocked |
Routes
Section titled “Routes”/dashboard/discounts— coupons (list, create, edit, duplicate, delete)/dashboard/messages— UI demo with hardcoded contacts (not wired to a messages API)
Discounts (coupons) — real API
Section titled “Discounts (coupons) — real API”Access: /dashboard/discounts maps to module coupon in vendor-module-access.ts.
Service: apps/vendor-web/src/services/vendor-coupons.api.ts.
| Action | Endpoint |
|---|---|
| Overview KPIs | GET /auth/vendor/context/coupons/overview |
| List | GET /auth/vendor/context/coupons — tabs (all / active / scheduled / expired), search, dates, store_id |
| One coupon | GET /auth/vendor/context/coupons/:id |
| Create | POST /vendor/coupons |
| Update | PATCH /vendor/coupons/:id |
| Duplicate | POST /vendor/coupons/:id/duplicate |
| Delete | DELETE /vendor/coupons/:id |
| Attach to order | POST /vendor/coupons/:id/attach-order — body { order_id, discount_amount } (same store as the coupon; records discount on the order row) |
Orders list (coupon detail): GET /vendor/orders accepts optional coupon_id (coupon primary key). When set, the API returns orders that redeemed that coupon (positive coupon_discount_amount, non-refund payment status, discount title matching the coupon code/title). Combine with search / store_id as needed.
Types (UI): e.g. percentage, fixed, free shipping (VendorCouponType). Rows include usage limits, min purchase, max discount, optional customer_ids / product_ids scoping — see list item shape in the service file for fields shown in the app.
Stacking: business rules for combining coupons live in the backend and POS checkout; the vendor SPA manages coupon definitions, not runtime stacking logic.
Messages — placeholder UI
Section titled “Messages — placeholder UI”apps/vendor-web/src/app/dashboard/messages/page.tsx uses a static in-memory contacts array (demo chat layout). There is no live messaging API hooked up in that page.
Related
Section titled “Related”- POS — coupons applied at checkout via
/pos/apply-coupon. - Vendor panel overview — module
coupon.