fix(notifications): dirigir todas las notificaciones de DripZone exclusivamente al WhatsApp personal de Carlos
This commit is contained in:
parent
6cebc76599
commit
8d4ba3ee88
@ -114,7 +114,6 @@ ${customerEmail ? `✉️ *Correo:* ${customerEmail}\n` : ''}
|
|||||||
⚡ ¡Consulta de inmediato con tus proveedores mayoristas para enviar cotización al cliente!`;
|
⚡ ¡Consulta de inmediato con tus proveedores mayoristas para enviar cotización al cliente!`;
|
||||||
|
|
||||||
sendWhatsAppMessage(CARLOS_PHONE, adminMessage).catch(() => {});
|
sendWhatsAppMessage(CARLOS_PHONE, adminMessage).catch(() => {});
|
||||||
sendWhatsAppMessage('120363428012905103@g.us', adminMessage).catch(() => {});
|
|
||||||
|
|
||||||
// 2. Confirmación automática al cliente por WhatsApp usando la plantilla registrada
|
// 2. Confirmación automática al cliente por WhatsApp usando la plantilla registrada
|
||||||
const settings = dataService.getSettings();
|
const settings = dataService.getSettings();
|
||||||
|
|||||||
@ -127,8 +127,7 @@ export async function sendWhatsAppMedia(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifica inmediatamente la publicación automática de un nuevo producto
|
* Notifica inmediatamente la publicación automática de un nuevo producto
|
||||||
* tanto al WhatsApp personal de Carlos (+57 316 745 5877) como al canal
|
* exclusivamente al WhatsApp personal de Carlos (+57 316 745 5877).
|
||||||
* de Notificaciones Almeira (120363428012905103@g.us).
|
|
||||||
*/
|
*/
|
||||||
export async function notifyNewProductPublished(
|
export async function notifyNewProductPublished(
|
||||||
product: any,
|
product: any,
|
||||||
@ -136,8 +135,7 @@ export async function notifyNewProductPublished(
|
|||||||
mediaUrl?: string
|
mediaUrl?: string
|
||||||
): Promise<{ success: boolean; dispatchedTo: string[] }> {
|
): Promise<{ success: boolean; dispatchedTo: string[] }> {
|
||||||
const NOTIFICATION_TARGETS = [
|
const NOTIFICATION_TARGETS = [
|
||||||
'573167455877', // Carlos (WhatsApp personal)
|
'573167455877', // Carlos (WhatsApp personal exclusivo)
|
||||||
'120363428012905103@g.us', // Notificaciones Almeira
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const retailPrice = product.retailPrice || 125000;
|
const retailPrice = product.retailPrice || 125000;
|
||||||
@ -273,7 +271,6 @@ export function buildOrderConfirmationMessage(order: any): string {
|
|||||||
*/
|
*/
|
||||||
export async function notifyAdminNewOrder(order: any): Promise<boolean> {
|
export async function notifyAdminNewOrder(order: any): Promise<boolean> {
|
||||||
const CARLOS_PHONE = '573167455877';
|
const CARLOS_PHONE = '573167455877';
|
||||||
const NOTIFICATION_GROUP = '120363428012905103@g.us';
|
|
||||||
|
|
||||||
const itemsSummary = (order.items || [])
|
const itemsSummary = (order.items || [])
|
||||||
.map((item: any) => `• 👟 *${item.productName || item.name}*\n 📏 Talla: *${item.size || 'Única'}* | Cantidad: *${item.quantity || 1}* | Valor: *${formatCOP((item.price || item.retailPrice || 0) * (item.quantity || 1))}*`)
|
.map((item: any) => `• 👟 *${item.productName || item.name}*\n 📏 Talla: *${item.size || 'Única'}* | Cantidad: *${item.quantity || 1}* | Valor: *${formatCOP((item.price || item.retailPrice || 0) * (item.quantity || 1))}*`)
|
||||||
@ -326,7 +323,7 @@ export async function notifyAdminNewOrder(order: any): Promise<boolean> {
|
|||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
try {
|
try {
|
||||||
// 1. Notificación principal al WhatsApp personal de Carlos CON LA FOTO DEL PRODUCTO
|
// Notificación exclusiva al WhatsApp personal de Carlos CON LA FOTO DEL PRODUCTO
|
||||||
let sentCarlos = false;
|
let sentCarlos = false;
|
||||||
if (resolvedImageUrl) {
|
if (resolvedImageUrl) {
|
||||||
sentCarlos = await sendWhatsAppMedia(CARLOS_PHONE, resolvedImageUrl, adminMessage);
|
sentCarlos = await sendWhatsAppMedia(CARLOS_PHONE, resolvedImageUrl, adminMessage);
|
||||||
@ -335,15 +332,6 @@ export async function notifyAdminNewOrder(order: any): Promise<boolean> {
|
|||||||
sentCarlos = await sendWhatsAppMessage(CARLOS_PHONE, adminMessage);
|
sentCarlos = await sendWhatsAppMessage(CARLOS_PHONE, adminMessage);
|
||||||
}
|
}
|
||||||
if (sentCarlos) success = true;
|
if (sentCarlos) success = true;
|
||||||
|
|
||||||
// 2. Notificación al canal de alertas (grupo) CON LA FOTO DEL PRODUCTO
|
|
||||||
let sentGroup = false;
|
|
||||||
if (resolvedImageUrl) {
|
|
||||||
sentGroup = await sendWhatsAppMedia(NOTIFICATION_GROUP, resolvedImageUrl, adminMessage).catch(() => false);
|
|
||||||
}
|
|
||||||
if (!sentGroup) {
|
|
||||||
await sendWhatsAppMessage(NOTIFICATION_GROUP, adminMessage).catch(() => {});
|
|
||||||
}
|
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
console.error('Error enviando notificación de pedido a Carlos:', err.message);
|
console.error('Error enviando notificación de pedido a Carlos:', err.message);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user