From fb9459476d254ceae4bf089a8e87e7bba34b4fec Mon Sep 17 00:00:00 2001 From: Panyaphorn Promchat <65160014@go.buu.ac.th> Date: Mon, 24 Mar 2025 04:14:32 +0700 Subject: [PATCH] Initial commit --- controllers/bookingController.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/controllers/bookingController.js b/controllers/bookingController.js index 01ad1f7..bfe3816 100644 --- a/controllers/bookingController.js +++ b/controllers/bookingController.js @@ -119,18 +119,14 @@ exports.bookingSummary = async (req, res) => { if (!appointmentId) { return res.status(400).send("ไม่พบรหัสการจอง"); } - - // พยายามดึงข้อมูลการจองจากตารางหลัก + + // ดึงข้อมูลการจองจากทั้ง appointments และ appointment_history let appointment = await bookingModel.getAppointmentById(appointmentId); - // ถ้าไม่พบ ลองดึงจากตารางประวัติ (appointment_history) if (!appointment) { - appointment = await bookingModel.getAppointmentFromHistoryById(appointmentId); - if (!appointment) { - throw new Error("ไม่พบการจอง"); - } + throw new Error("ไม่พบการจองในฐานข้อมูล"); } - + const user = await bookingModel.getUserById(appointment.user_id); const service = await bookingModel.getServiceById(appointment.service_id); const slot = await bookingModel.getBookingSlotById(appointment.booking_slot_id); -- GitLab