feat(backend): integrate custom services across booking, payment, scheduling, today, and user modules
Update booking create/confirm/progress/reserve handlers to support custom_service_ids and custom overrides. Add UNION ALL queries to include custom_services in booking detail, payment summary, scheduling availability, today dashboard, and customer relationship queries. Ultraworked with Sisyphus (https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -408,18 +408,23 @@ func GetAvailableHours(w http.ResponseWriter, r *http.Request) {
|
||||
bookingRows, _ := db.DB.Query(r.Context(), `
|
||||
SELECT
|
||||
b.start_time,
|
||||
COALESCE(SUM(
|
||||
CASE
|
||||
COALESCE((SELECT SUM(dur) FROM (
|
||||
SELECT CASE
|
||||
WHEN bs.override_duration_minutes IS NOT NULL AND bs.override_duration_minutes > 0
|
||||
THEN bs.override_duration_minutes
|
||||
ELSE s.duration_minutes
|
||||
END AS dur
|
||||
FROM booking_services bs LEFT JOIN services s ON bs.service_id = s.id WHERE bs.booking_id = b.id
|
||||
UNION ALL
|
||||
SELECT CASE
|
||||
WHEN bcs.override_duration_minutes IS NOT NULL AND bcs.override_duration_minutes > 0
|
||||
THEN bcs.override_duration_minutes
|
||||
ELSE cs.duration_minutes
|
||||
END
|
||||
), 0) AS total_duration
|
||||
FROM booking_custom_services bcs LEFT JOIN custom_services cs ON bcs.custom_service_id = cs.id WHERE bcs.booking_id = b.id
|
||||
) sub), 0) AS total_duration
|
||||
FROM bookings b
|
||||
LEFT JOIN booking_services bs ON b.id = bs.booking_id
|
||||
LEFT JOIN services s ON bs.service_id = s.id
|
||||
WHERE b.start_time >= $1 AND b.start_time <= $2
|
||||
GROUP BY b.id, b.start_time
|
||||
ORDER BY b.start_time
|
||||
`, start, end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user