You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While The Lighted's primary ordering flow is via WhatsApp, the platform needs an orders module to track completed orders for analytics, revenue reporting, and loyalty token distribution. Orders are created when a customer confirms their WhatsApp order and an admin marks it as received.
Labels:
backendordersnestjsArea:
backend/src/modules/orders/order.entity.ts,backend/src/modules/orders/orders.service.ts,backend/src/modules/orders/orders.controller.ts,backend/src/modules/orders/orders.module.tsDifficulty: Advanced
Description
While The Lighted's primary ordering flow is via WhatsApp, the platform needs an orders module to track completed orders for analytics, revenue reporting, and loyalty token distribution. Orders are created when a customer confirms their WhatsApp order and an admin marks it as received.
Acceptance Criteria
backend/src/modules/orders/order.entity.ts:OrderStatusenum:PENDING,CONFIRMED,PREPARING,READY,DELIVERED,CANCELLEDOrderItemembedded entity:{ menuItemId: string; name: string; price: number; quantity: number }Orderentity columns:id(UUID),customerName(varchar),customerPhone(varchar, nullable),customerEmail(varchar, nullable),items(jsonb —OrderItem[]),subtotal(decimal),status(enum, defaultPENDING),notes(text, nullable),restaurantId(UUID),createdAt,updatedAtbackend/src/modules/orders/orders.service.tswithOrdersService:create(dto, restaurantId)— calculatessubtotalfrom items, creates orderfindAll(restaurantId, status?)— orderedcreatedAt DESC; optionally filtered by statusfindOne(id, restaurantId)— throwsNotFoundExceptionif not foundupdateStatus(id, status, restaurantId)— updates status, logs to auditgetStats(restaurantId, days)— returns{ totalOrders, totalRevenue, averageOrderValue, statusBreakdown }backend/src/modules/orders/orders.controller.tswith@Controller('orders'):POST /orders— public (no auth), creates order from cart checkoutGET /orders—@UseGuards(JwtAuthGuard), optional?statusfilterGET /orders/stats—@UseGuards(JwtAuthGuard), accepts?daysGET /orders/:id—@UseGuards(JwtAuthGuard)PUT /orders/:id/status—@UseGuards(JwtAuthGuard)backend/src/modules/orders/orders.module.ts— exportsOrdersService