Actualizar server.js
This commit is contained in:
@@ -2976,8 +2976,9 @@ app.post("/webhook/evolution", async (req, res) => {
|
|||||||
const cleanPhone = telefonoCliente.slice(-9);
|
const cleanPhone = telefonoCliente.slice(-9);
|
||||||
|
|
||||||
// 1. BUSCAMOS EL SINIESTRO (Extrayendo urgencia y población)
|
// 1. BUSCAMOS EL SINIESTRO (Extrayendo urgencia y población)
|
||||||
|
// 1. Añadimos s.assigned_to a la consulta
|
||||||
const svcQ = await pool.query(`
|
const svcQ = await pool.query(`
|
||||||
SELECT s.id, s.service_ref, u.full_name as worker_name, s.is_urgent,
|
SELECT s.id, s.service_ref, s.assigned_to, u.full_name as worker_name, s.is_urgent,
|
||||||
st.name as status_name, s.raw_data->>'scheduled_date' as cita,
|
st.name as status_name, s.raw_data->>'scheduled_date' as cita,
|
||||||
s.raw_data->>'Población' as poblacion
|
s.raw_data->>'Población' as poblacion
|
||||||
FROM scraped_services s
|
FROM scraped_services s
|
||||||
@@ -3017,6 +3018,7 @@ app.post("/webhook/evolution", async (req, res) => {
|
|||||||
estado: service.status_name || "En proceso",
|
estado: service.status_name || "En proceso",
|
||||||
operario: service.worker_name,
|
operario: service.worker_name,
|
||||||
cita: service.cita,
|
cita: service.cita,
|
||||||
|
worker_id: service.assigned_to,
|
||||||
poblacion: service.poblacion || "", // 👈 CRÍTICO para buscar rutas en la misma zona
|
poblacion: service.poblacion || "", // 👈 CRÍTICO para buscar rutas en la misma zona
|
||||||
is_urgent: service.is_urgent // 👈 CRÍTICO para que no pida cita en urgencias
|
is_urgent: service.is_urgent // 👈 CRÍTICO para que no pida cita en urgencias
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user