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:
2026-06-15 16:58:10 +01:00
co-authored by Sisyphus
parent ede0873c08
commit ad0af39237
8 changed files with 701 additions and 219 deletions
+15 -6
View File
@@ -135,12 +135,21 @@ func GetCustomerRelationshipHandler(w http.ResponseWriter, r *http.Request) {
}
rows, err := db.DB.Query(r.Context(), `
SELECT s.name, COUNT(*) as count
FROM booking_services bsvc
JOIN bookings b ON bsvc.booking_id = b.id
JOIN services s ON bsvc.service_id = s.id
WHERE b.user_id = $1 AND b.status = 'completed'
GROUP BY s.name
SELECT name, cnt FROM (
SELECT s.name, COUNT(*) as count, COUNT(*) as cnt
FROM booking_services bsvc
JOIN bookings b ON bsvc.booking_id = b.id
JOIN services s ON bsvc.service_id = s.id
WHERE b.user_id = $1 AND b.status = 'completed'
GROUP BY s.name
UNION ALL
SELECT cs.name, COUNT(*) as count, COUNT(*) as cnt
FROM booking_custom_services bcs
JOIN bookings b ON bcs.booking_id = b.id
JOIN custom_services cs ON bcs.custom_service_id = cs.id
WHERE b.user_id = $1 AND b.status = 'completed'
GROUP BY cs.name
) combined
ORDER BY count DESC
LIMIT 5
`, userID)