feat: improve notifications - fix auth code tg duplicate, double order notify, add PAID label, expand text, add deliveryFeeAdjusted event
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
export function renderOrderCreatedTg({ orderId, totalCents, itemsCount }) {
|
||||
export function renderOrderCreatedTg({ orderId, totalCents, itemsCount, deliveryType }) {
|
||||
const total = (totalCents / 100).toLocaleString('ru-RU')
|
||||
return `📦 <b>Новый заказ</b> #${orderId.slice(0, 8)}\nТоваров: ${itemsCount} | Сумма: ${total} ₽`
|
||||
const nextAction = deliveryType === 'delivery'
|
||||
? 'Оплата будет доступна после уточнения стоимости доставки.'
|
||||
: 'Ожидает оплаты.'
|
||||
return `📦 <b>Новый заказ</b> #${orderId.slice(0, 8)}\nТоваров: ${itemsCount} | Сумма: ${total} ₽\n${nextAction}`
|
||||
}
|
||||
|
||||
export function renderOrderStatusChangedTg({ orderId, oldStatus, newStatus }) {
|
||||
const labels = {
|
||||
DRAFT: 'Черновик', PENDING_PAYMENT: 'Ожидает оплаты', IN_PROGRESS: 'В работе',
|
||||
DRAFT: 'Черновик', PENDING_PAYMENT: 'Ожидает оплаты', PAID: 'Оплачен', IN_PROGRESS: 'В работе',
|
||||
READY_FOR_PICKUP: 'Готов к выдаче', SHIPPED: 'Отправлен', DONE: 'Выполнен', CANCELLED: 'Отменён',
|
||||
}
|
||||
return `🔄 Заказ #${orderId.slice(0, 8)}\n${labels[oldStatus] || oldStatus} → <b>${labels[newStatus] || newStatus}</b>`
|
||||
@@ -21,9 +24,10 @@ export function renderPaymentStatusChangedTg({ orderId, paymentStatus }) {
|
||||
return `💳 Оплата заказа #${orderId.slice(0, 8)}: <b>${labels[paymentStatus] || paymentStatus}</b>`
|
||||
}
|
||||
|
||||
export function renderAdminOrderCreatedTg({ orderId, userEmail, totalCents, itemsCount }) {
|
||||
export function renderAdminOrderCreatedTg({ orderId, userEmail, totalCents, itemsCount, deliveryType }) {
|
||||
const total = (totalCents / 100).toLocaleString('ru-RU')
|
||||
return `🛒 <b>Новый заказ</b> #${orderId.slice(0, 8)}\nОт: ${userEmail}\nТоваров: ${itemsCount} | Сумма: ${total} ₽`
|
||||
const note = deliveryType === 'delivery' ? '\n\n⚠️ Скорректируйте стоимость доставки' : ''
|
||||
return `🛒 <b>Новый заказ</b> #${orderId.slice(0, 8)}\nОт: ${userEmail}\nТоваров: ${itemsCount} | Сумма: ${total} ₽${note}`
|
||||
}
|
||||
|
||||
export function renderAdminNewReviewTg({ rating, text, productTitle, userName }) {
|
||||
@@ -34,3 +38,8 @@ export function renderAdminNewReviewTg({ rating, text, productTitle, userName })
|
||||
export function renderAuthCodeTg({ code }) {
|
||||
return `🔐 Код входа: <b>${code}</b>`
|
||||
}
|
||||
|
||||
export function renderDeliveryFeeAdjustedTg({ orderId, totalCents }) {
|
||||
const total = (totalCents / 100).toLocaleString('ru-RU')
|
||||
return `💰 <b>Стоимость доставки скорректирована</b> для заказа #${orderId.slice(0, 8)}\nНовая сумма: ${total} ₽\n\nОжидает оплаты.`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user