Fix: notificacion WhatsApp cita al convertir presupuesto usa plantilla
This commit is contained in:
18
server.js
18
server.js
@@ -5227,17 +5227,11 @@ app.post("/budgets/:id/convert", authMiddleware, async (req, res) => {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({ guild_id, cp, useDelay: false })
|
body: JSON.stringify({ guild_id, cp, useDelay: false })
|
||||||
}).catch(e => console.error("Error lanzando automatización interna:", e));
|
}).catch(e => console.error("Error lanzando automatización interna:", e));
|
||||||
|
|
||||||
if (budget.client_phone) {
|
|
||||||
const msg = `✅ *PRESUPUESTO ACEPTADO*\n\nHola ${budget.client_name}, confirmamos la aceptación del presupuesto por un total de *${budget.total}€*.\n\nEn breve un técnico se pondrá en contacto contigo para agendar la cita. ¡Gracias por confiar en nosotros!`;
|
|
||||||
sendWhatsAppAuto(budget.client_phone, msg, `cliente_${req.user.accountId}`, false).catch(console.error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (budget.client_phone && date && time) {
|
|
||||||
// Asignación directa a un técnico con fecha y hora
|
if (budget.client_phone && date && time) {
|
||||||
const [y, m, d] = date.split('-');
|
// Cita ya agendada (fecha y técnico asignados): usamos la plantilla "Cita Creada" configurada en Configuración > Plantillas
|
||||||
const msg = `✅ *PRESUPUESTO ACEPTADO*\n\nHola ${budget.client_name}, confirmamos la aceptación del presupuesto por un total de *${budget.total}€*.\n\nEl servicio ha sido agendado para el *${d}/${m}/${y} a las ${time}*. ¡Gracias por confiar en nosotros!`;
|
triggerWhatsAppEvent(req.user.accountId, newServiceId, 'wa_evt_date').catch(console.error);
|
||||||
sendWhatsAppAuto(budget.client_phone, msg, `cliente_${req.user.accountId}`, false).catch(console.error);
|
|
||||||
|
|
||||||
if (assigned_to) {
|
if (assigned_to) {
|
||||||
const statusQ = await pool.query("SELECT id FROM service_statuses WHERE owner_id=$1 AND name ILIKE '%asignado%' LIMIT 1", [req.user.accountId]);
|
const statusQ = await pool.query("SELECT id FROM service_statuses WHERE owner_id=$1 AND name ILIKE '%asignado%' LIMIT 1", [req.user.accountId]);
|
||||||
@@ -5246,6 +5240,10 @@ app.post("/budgets/:id/convert", authMiddleware, async (req, res) => {
|
|||||||
await pool.query("UPDATE scraped_services SET raw_data = $1 WHERE id = $2", [JSON.stringify(rawData), newServiceId]);
|
await pool.query("UPDATE scraped_services SET raw_data = $1 WHERE id = $2", [JSON.stringify(rawData), newServiceId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (budget.client_phone) {
|
||||||
|
|
||||||
|
const msg = `✅ *PRESUPUESTO ACEPTADO*\n\nHola ${budget.client_name}, confirmamos la aceptación del presupuesto por un total de *${budget.total}€*.\n\nEn breve un técnico se pondrá en contacto contigo para agendar la cita. ¡Gracias por confiar en nosotros!`;
|
||||||
|
sendWhatsAppAuto(budget.client_phone, msg, `cliente_${req.user.accountId}`, false).catch(console.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- INICIO TRAZABILIDAD ---
|
// --- INICIO TRAZABILIDAD ---
|
||||||
|
|||||||
Reference in New Issue
Block a user