Configuracion para guardar en base de datos
This commit is contained in:
@@ -190,7 +190,7 @@ export class WhatsappService implements OnModuleInit, OnModuleDestroy {
|
||||
const telefono = jid.split("@")[0];
|
||||
|
||||
try {
|
||||
const lead = await this.leadsService.findOrCreate(telefono);
|
||||
let lead = await this.leadsService.findOrCreate(telefono);
|
||||
|
||||
if (ESTADOS_TERMINALES.includes(lead.estado_actual)) {
|
||||
this.logger.log(
|
||||
@@ -299,21 +299,18 @@ export class WhatsappService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
this.logger.log(`LUISA [${telefono}]: ${respuesta}`);
|
||||
|
||||
if (entidad && Object.keys(entidad).length > 0) {
|
||||
await this.leadsService.updateDatos(lead.id, entidad);
|
||||
}
|
||||
|
||||
if (nuevoEstado === "fin_viable" || nuevoEstado === "fin_no_viable") {
|
||||
await this.leadsService.marcarViable(
|
||||
lead,
|
||||
nuevoEstado === "fin_viable",
|
||||
if (
|
||||
(entidad && Object.keys(entidad).length > 0) ||
|
||||
nuevoEstado ||
|
||||
(viable !== undefined && viable !== null)
|
||||
) {
|
||||
lead = await this.leadsService.persistirTurno(lead.id, entidad ?? {}, {
|
||||
nuevoEstado,
|
||||
viable,
|
||||
});
|
||||
this.logger.log(
|
||||
`Lead id=${lead.id} en DB — estado=${lead.estado_actual}, espacio=${lead.espacio ?? "-"}, rango_m2=${lead.rango_m2 ?? "-"}, estilo=${lead.estilo ?? "-"}, urgencia=${lead.urgencia ?? "-"}, presupuesto=${lead.presupuesto_declarado ?? "-"}`,
|
||||
);
|
||||
this.logger.log(`Lead id=${lead.id} finalizado como ${nuevoEstado}`);
|
||||
} else if (nuevoEstado) {
|
||||
await this.leadsService.updateEstado(lead, nuevoEstado);
|
||||
this.logger.log(`Lead id=${lead.id} avanzado a estado=${nuevoEstado}`);
|
||||
} else if (viable !== undefined && viable !== null) {
|
||||
await this.leadsService.marcarViable(lead, viable);
|
||||
}
|
||||
|
||||
await this.conversacionService.guardarMensaje(
|
||||
|
||||
Reference in New Issue
Block a user