feat: enhance Telegram notification to include total service cost
- Updated the Telegram notification message to display the total cost of services associated with an order, improving transparency for clients and masters. - Added logic to calculate the total price based on individual service prices and formatted the price for better readability.
This commit is contained in:
parent
01fbd1c696
commit
37c28353a9
@ -107,16 +107,28 @@ async function sendTelegramNotification(orderEntity: Order, isUpdate = false) {
|
||||
const clientName = order.client?.name || '-';
|
||||
const masterName = slot.master?.name || '-';
|
||||
|
||||
// Формируем список всех услуг
|
||||
const servicesList = order.services?.length
|
||||
? order.services.map(service => service.name).join(', ')
|
||||
: '-';
|
||||
// Формируем список всех услуг и вычисляем общую стоимость
|
||||
let servicesList = '-';
|
||||
let totalPrice = 0;
|
||||
|
||||
if (order.services?.length) {
|
||||
servicesList = order.services.map(service => service.name).join(', ');
|
||||
|
||||
// Вычисляем общую стоимость
|
||||
totalPrice = order.services.reduce((sum, service) => {
|
||||
return sum + (service.price || 0);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// Форматируем цену для отображения
|
||||
const priceText = totalPrice > 0 ? `${totalPrice.toLocaleString('ru-RU')} ₽` : 'Не указана';
|
||||
|
||||
const messageForMaster = `${heading}
|
||||
<b>Дата:</b> ${date}
|
||||
<b>Время:</b> ${timeStartString} - ${timeEndString}
|
||||
<b>Клиент:</b> ${clientName}
|
||||
<b>Услуги:</b> ${servicesList}
|
||||
<b>Стоимость:</b> ${priceText}
|
||||
<b>Статус:</b> ${emojiForState} ${stateLabel}`;
|
||||
|
||||
const messageForClient = `${heading}
|
||||
@ -124,6 +136,7 @@ async function sendTelegramNotification(orderEntity: Order, isUpdate = false) {
|
||||
<b>Время:</b> ${timeStartString} - ${timeEndString}
|
||||
<b>Мастер:</b> ${masterName}
|
||||
<b>Услуги:</b> ${servicesList}
|
||||
<b>Стоимость:</b> ${priceText}
|
||||
<b>Статус:</b> ${emojiForState} ${stateLabel}`;
|
||||
|
||||
if (masterTelegramId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user