Bỏ qua để đến nội dung

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.

Discounts implements coupons against the real API (coupon module). Messages is a UI demo with hardcoded contacts—not a production messaging API.


GoalsNon-goals
Run coupon lifecycle safelyProvide chat/voicemail replacement
Warn that messages screen is demoBuild full messaging backend here

  • /dashboard/discounts — real service (vendor-coupons.api.ts).
  • /dashboard/messages — static/demo only.

  1. Owner/staff with coupon → manage coupons → verify at checkout/POS.
  2. Ignore Messages for ops unless/until API exists.

  • Coupon abuse = revenue risk—use approval workflows outside the app if required.

IDScenarioExpected
DM1Create couponAPI persists; visible in list
DM2Messages screenDemo only—no delivery guarantee
DM3Employee without couponBlocked

  • /dashboard/discountscoupons (list, create, edit, duplicate, delete)
  • /dashboard/messagesUI demo with hardcoded contacts (not wired to a messages API)

Access: /dashboard/discounts maps to module coupon in vendor-module-access.ts.

Service: apps/vendor-web/src/services/vendor-coupons.api.ts.

ActionEndpoint
Overview KPIsGET /auth/vendor/context/coupons/overview
ListGET /auth/vendor/context/coupons — tabs (all / active / scheduled / expired), search, dates, store_id
One couponGET /auth/vendor/context/coupons/:id
CreatePOST /vendor/coupons
UpdatePATCH /vendor/coupons/:id
DuplicatePOST /vendor/coupons/:id/duplicate
DeleteDELETE /vendor/coupons/:id
Attach to orderPOST /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.

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.