feat: full Room Service backend integration
- Migrations 086-088: room_service_settings, menu_items, orders+order_items - Backend: /api/hotels/:slug/room-service/* routes (settings, menu CRUD, orders CRUD, public config, public order status) - push.ts: sendPushToHotel() — push to all hotel staff on new order - On new order: in-app notification + push to hotel staff - api.ts: RoomService types + roomService API methods - RoomServicePage: replaced mocked state with real API, 30s polling, add/edit/delete menu items modal, real advance/cancel order - GuestRoomServicePage: fetches real menu + config, uses hotel payment methods, submits real order, polls status every 15s Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
12
backend/migrations/086_room_service_settings.sql
Normal file
12
backend/migrations/086_room_service_settings.sql
Normal file
@@ -0,0 +1,12 @@
|
||||
-- Migration 086 — Room Service: settings per hotel
|
||||
|
||||
CREATE TABLE room_service_settings (
|
||||
hotel_id UUID PRIMARY KEY REFERENCES hotels(id) ON DELETE CASCADE,
|
||||
is_active BOOLEAN NOT NULL DEFAULT true,
|
||||
service_charge_pct INTEGER NOT NULL DEFAULT 0,
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
-- Auto-create settings for existing hotels
|
||||
INSERT INTO room_service_settings (hotel_id)
|
||||
SELECT id FROM hotels ON CONFLICT DO NOTHING;
|
||||
18
backend/migrations/087_room_service_menu.sql
Normal file
18
backend/migrations/087_room_service_menu.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- Migration 087 — Room Service: menu items
|
||||
|
||||
CREATE TABLE room_service_menu_items (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
hotel_id UUID NOT NULL REFERENCES hotels(id) ON DELETE CASCADE,
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL DEFAULT 'Основные',
|
||||
price NUMERIC(10,2) NOT NULL,
|
||||
emoji TEXT NOT NULL DEFAULT '🍽️',
|
||||
prep_time_min INTEGER NOT NULL DEFAULT 15,
|
||||
is_popular BOOLEAN NOT NULL DEFAULT false,
|
||||
is_stop_list BOOLEAN NOT NULL DEFAULT false,
|
||||
is_active BOOLEAN NOT NULL DEFAULT true,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX ON room_service_menu_items(hotel_id, is_active);
|
||||
32
backend/migrations/088_room_service_orders.sql
Normal file
32
backend/migrations/088_room_service_orders.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
-- Migration 088 — Room Service: orders & order items
|
||||
|
||||
CREATE TABLE room_service_orders (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
hotel_id UUID NOT NULL REFERENCES hotels(id) ON DELETE CASCADE,
|
||||
room_number TEXT NOT NULL,
|
||||
guest_name TEXT NOT NULL DEFAULT '',
|
||||
order_type TEXT NOT NULL DEFAULT 'room' CHECK (order_type IN ('room', 'restaurant')),
|
||||
scheduled_time TEXT,
|
||||
status TEXT NOT NULL DEFAULT 'new'
|
||||
CHECK (status IN ('new','preparing','ready','delivered','cancelled')),
|
||||
payment_method TEXT, -- name from hotel_payment_methods (snapshot)
|
||||
subtotal NUMERIC(10,2) NOT NULL DEFAULT 0,
|
||||
service_charge NUMERIC(10,2) NOT NULL DEFAULT 0,
|
||||
total NUMERIC(10,2) NOT NULL DEFAULT 0,
|
||||
notes TEXT,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE room_service_order_items (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
order_id UUID NOT NULL REFERENCES room_service_orders(id) ON DELETE CASCADE,
|
||||
menu_item_id UUID REFERENCES room_service_menu_items(id) ON DELETE SET NULL,
|
||||
name TEXT NOT NULL,
|
||||
emoji TEXT NOT NULL DEFAULT '🍽️',
|
||||
price NUMERIC(10,2) NOT NULL,
|
||||
quantity INTEGER NOT NULL DEFAULT 1
|
||||
);
|
||||
|
||||
CREATE INDEX ON room_service_orders(hotel_id, status);
|
||||
CREATE INDEX ON room_service_orders(hotel_id, created_at DESC);
|
||||
Reference in New Issue
Block a user