Chats: show which order a provider writes about, or that there is no order
- Provider messages store the order that was current when they wrote: a started order first, otherwise the nearest assigned one within -4h..+12h; none — "no order". - Admin chat: order tag above each provider message, "now / next" order strip in the conversation header, order number (or "no order") in the thread list. - Telegram notification to the team gets an order line or "no current order". - Test for the order-picking rule; demo shows both cases. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
23ffb2bf1d
commit
2772837e29
14 files changed
+321
-13
No files matched your search
@@ -233,9 +233,27 @@ async function handle(event: DomainEvent) {
|
||||
return;
|
||||
}
|
||||
case 'concierge.message': {
|
||||
const msg = await db.conciergeMessage.findUnique({ where: { id: event.messageId }, include: { client: { include: { user: true } }, provider: { include: { user: true } }, thread: true } });
|
||||
const msg = await db.conciergeMessage.findUnique({
|
||||
where: { id: event.messageId },
|
||||
include: { client: { include: { user: true } }, provider: { include: { user: true } }, thread: true, order: { include: { service: true, district: true } } },
|
||||
});
|
||||
if (!msg) return;
|
||||
const from = msg.client ? who(msg.client.user) : `${escapeHtml(msg.provider?.name ?? '')} · ${adminT('bot.admin.provider')}`;
|
||||
let from = msg.client ? who(msg.client.user) : `${escapeHtml(msg.provider?.name ?? '')} · ${adminT('bot.admin.provider')}`;
|
||||
// исполнитель: по какому заказу пишет, или что сейчас без заказа
|
||||
if (msg.providerId) {
|
||||
const o = msg.order;
|
||||
const orderLine = o
|
||||
? [
|
||||
adminT('bot.admin.order', { number: o.number }),
|
||||
adminT(`services.${o.service.code}.name`),
|
||||
formatDateTime('ru', o.scheduledAt, { weekday: 'short', day: 'numeric', month: 'short', hour: '2-digit', minute: '2-digit' }),
|
||||
o.district ? adminT(`districts.${o.district.code}`) : null,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(' · ')
|
||||
: adminT('bot.admin.noOrder');
|
||||
from += `\n📦 ${escapeHtml(orderLine)}`;
|
||||
}
|
||||
const peer = msg.clientId ? `c:${msg.clientId}` : `p:${msg.providerId}`;
|
||||
const channel = msg.thread ? `${adminT(msg.thread.channel === 'CONCIERGE' ? 'bot.admin.channelConcierge' : 'bot.admin.channelSupport')} · ` : '';
|
||||
const body = msg.text ? escapeHtml(msg.text) : '';
|
||||
|
||||
Reference in new issue
Block a user