From ece302d512a40649381be0fe2ae1df16e39fa67c Mon Sep 17 00:00:00 2001 From: Hermes Date: Fri, 25 Sep 2026 17:30:29 +0200 Subject: [PATCH] =?UTF-8?q?fix(autocall):=20=D1=81=D0=B0=D0=BC=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=B2=D0=BE=D0=B7=20=D0=BF=D0=B8=D1=88=D0=B5=D1=82=20?= =?UTF-8?q?=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20pickup=5Fdate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Решение владельца: у самовывоза дата живёт в pickup_date + pickup_time_slot, delivery_date/delivery_time робот не трогает (раньше дублировал в оба поля, и дата самовывоза всплывала в полях доставки). Маркер «согласовано роботом» общий — delivery_date_source='autocall': по нему работают карточка, фильтры и SQL-статус autocall_status(og); отдельного pickup_date_source в схеме нет. Проверено на боевой функции временными группами с метками в датах: самовывоз — pickup_date обновился, delivery_date остался нетронутым; доставка — delivery_date обновился, pickup_date нетронут. Временные группы удалены. Исторический дубль (единственный: ТП-010747) очищен — дата осталась в pickup_date. --- supabase/functions/autocall-result/index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/supabase/functions/autocall-result/index.ts b/supabase/functions/autocall-result/index.ts index 5e376f1..19f8194 100644 --- a/supabase/functions/autocall-result/index.ts +++ b/supabase/functions/autocall-result/index.ts @@ -196,16 +196,22 @@ Deno.serve(async (request) => { delivery_date_source: "autocall", delivery_status: "agreed", notification_status: "confirmed", - delivery_date: deliveryDate, called: true, called_at: new Date().toISOString(), called_comment: comment, next_notification_check_at: null, }; - if (timeSlot) update.delivery_time = timeSlot; + // Самовывоз и доставка живут в РАЗНЫХ полях (решение владельца): для + // самовывоза пишем только pickup_date + половину дня, delivery_date не + // трогаем — иначе дата дублируется в двух полях и всплывает в плане + // доставки. Маркер «согласовано роботом» общий — delivery_date_source, + // по нему работают и карточка, и SQL-статус autocall_status(og). if (isPickup) { update.pickup_date = deliveryDate; if (timeSlot) update.pickup_time_slot = timeSlot; + } else { + update.delivery_date = deliveryDate; + if (timeSlot) update.delivery_time = timeSlot; } await supabase.from("order_groups").update(update).eq("id", orderGroupId); }