import { BuffetOrderEndReason, BuffetPlan, BuffetPlanInput, OrderAdditionPosReference, OrderAdditionStatus, OrderBuffet, SOBuffetAdditionDisabledReason, SOBuffetAdditionHistoryStatus } from '../models/buffet'; import { OOReasonCode } from '../models/online-integration'; import { OrderItem } from '../models/order'; import { SOGetStoreMenuResponse } from './online-ordering'; import { MultipleItems, SingleItem } from './response/common'; /** Admin 方案列表請求;一次回傳該店所有方案,沒有分頁。 */ export interface GetBuffetPlansRequest { /** SDIT 店家 ID;由後台目前選取的店家帶入並接受授權驗證。 */ storeId: string; } /** Admin 取得單一方案請求。 */ export interface GetBuffetPlanRequest { storeId: string; /** SDIT `BuffetPlan.id`。 */ planId: string; } /** Admin 建立方案請求;`isActive` 依 `item` 帶入的值寫入。 */ export interface CreateBuffetPlanRequest { storeId: string; item: BuffetPlanInput; } /** Admin 更新方案請求;`item.isActive` 會一併寫入,所以編輯表單必須帶目前的啟用狀態。 */ export interface UpdateBuffetPlanRequest { storeId: string; planId: string; item: BuffetPlanInput; } /** * Admin 刪除方案請求;後端為永久刪除,沒有軟刪除與還原。 * 進行中的桌次會因此無法再以 QR 加點,Admin 必須提醒店家於打烊後操作。 */ export interface DeleteBuffetPlanRequest { storeId: string; planId: string; } /** Admin 方案列表;沿用既有後台列表格式。 */ export interface GetBuffetPlansResponse extends MultipleItems { } /** Admin 取得單一方案;沿用既有後台單筆格式。 */ export interface GetBuffetPlanResponse extends SingleItem { } /** Admin 建立方案成功後的單筆結果;沿用既有後台單筆格式。 */ export interface CreateBuffetPlanResponse extends SingleItem { } /** Admin 更新方案成功後的單筆結果;沿用既有後台單筆格式。 */ export interface UpdateBuffetPlanResponse extends SingleItem { } /** Admin 刪除方案成功後回傳被刪除前的資料;沿用既有後台單筆格式。 */ export interface DeleteBuffetPlanResponse extends SingleItem { } /** 吃到飽 QR 主單的公開摘要;由 SDIT 依公開碼解析後回傳,消費者不可修改。 */ export interface SOBuffetOrderSummary { /** SDIT 吃到飽 `Order.id` 主單 ID;用於畫面識別,不取代 QR 公開碼做授權。 */ id: string; /** SDIT 桌位 ID;由 POS 開桌傳入並寫入主單。 */ tableId: string; /** SDIT 開桌時保存的桌位顯示名稱,供消費者確認所在桌次。 */ tableName: string; /** POS 開桌時輸入並由 SDIT 保存的人數;不是目前加入加點的人數。 */ numberOfCustomers: number; /** SDIT 主單的吃到飽時間與結束資訊摘要。 */ buffet: OrderBuffet; } /** * 公開顯示的方案摘要。 * 加點限制只供 SO Web 顯示與本機提示;送出時仍由後端重新驗證,前端不可自行放寬。 * 啟用狀態、方案收費商品與用餐時間設定不對外公開。 */ export interface SOBuffetPlanSummary { /** SDIT 方案 ID;來源為 `Order.buffet.planId` 對應的方案。 */ id: string; /** SDIT Admin 設定的方案名稱,供消費者顯示。 */ name: string; /** SDIT 專屬吃到飽菜單 ID;後端用於取得本次可點菜單。 */ menuId: string; /** 單輪品項總數上限;不限時省略。 */ maxTotalQuantityPerAddition?: number; /** 同一 `productId` 的單輪數量上限;不限時省略。 */ maxQuantityPerProductPerAddition?: number; /** 單輪不同 `productId` 的數量上限;不限時省略。 */ maxDistinctProductIdCountPerAddition?: number; /** 兩次成功送出加點的最小間隔,單位為分鐘;不限時省略。 */ minAdditionIntervalMinutes?: number; } /** SO Web 本輪送出操作是否可執行;由 SDIT 每次公開狀態讀取時計算。 */ export interface SOBuffetAdditionOperation { /** `true` 時才可呼叫送出加點 API;前端仍需處理送出瞬間的後端驗證失敗。 */ canSubmitAddition: boolean; /** 不可送出時可公開顯示的操作原因;可送出時省略,絕不回傳 POS 專用原因。 */ disabledReason?: SOBuffetAdditionDisabledReason; /** 加點間隔限制時,下一次可送出的 Unix epoch milliseconds;其他原因或無限制時省略。 */ nextAdditionAvailableAt?: number; } /** 掃描吃到飽 QR 後初始化點餐流程所需的公開 Context;不是單純的主單 DTO。 */ export interface SOGetBuffetOrderingContextResponse { /** 後端由 `publicOrderingAccessKey` 解析的 SDIT 店家 ID;前端僅能用於讀取既有公開店家資訊,不得從 URL 取得或用於吃到飽送單。 */ storeId: string; /** SDIT 依公開碼取得的吃到飽主單摘要;不是 POS 正式訂單。 */ order: SOBuffetOrderSummary; /** SDIT 依主單方案取得的公開方案摘要。 */ plan: SOBuffetPlanSummary; /** SDIT 當下解析的吃到飽公開菜單;直接沿用既有型別,`discountRules` 固定為空陣列。 */ menu: SOGetStoreMenuResponse; /** SDIT 依結束時間、菜單、商品與加點間隔計算的本輪操作狀態。 */ operation: SOBuffetAdditionOperation; } export interface SOSendBuffetAdditionResponse { /** * SDIT 建立的本次加點 ID(ULID)。 * 只在 POS 通知成功後回傳,供前端追蹤送出結果或導向歷史頁;不代表 POS 已接受。 * POS 以同一 ID 建立待接單、接受或拒絕時維持冪等。 */ additionId: string; /** 若方案設定加點間隔,SDIT 計算出的下一次可送 Unix epoch milliseconds;不限時省略。 */ nextAdditionAvailableAt?: number; } /** 歷史頁的一筆永久加點紀錄;由 SDIT 依主單讀取並回傳所有狀態。 */ export interface SOBuffetAdditionHistoryItem { /** SDIT ULID 加點 ID;對應 `OrderAddition.id`。 */ id: string; /** 消費者當初送出加點時的 Unix epoch milliseconds。 */ submittedAt: number; /** 消費者可理解的處理結果;由 SDIT 內部 `OrderAdditionStatus` 投影,不揭露 POS 或通知狀態。 */ status: SOBuffetAdditionHistoryStatus; /** SDIT 當初解析保存的不可變 `OrderItem` 快照,含正確價格與套餐結構。 */ items: OrderItem[]; /** 消費者當初的整筆備註;未填時省略。 */ note?: string; /** POS 做出接受或拒絕時的 Unix epoch milliseconds;尚未決策時省略。 */ decidedAt?: number; /** POS 拒絕時的既有 `OOReasonCode`;非拒絕時省略。 */ rejectReasonCode?: OOReasonCode; /** POS 拒絕時可選說明;非拒絕或沒有文字時省略。 */ rejectReasonMessage?: string; } /** 依加點時間排序的完整歷史;沿用既有列表 response,包含處理中、接受、拒絕與加點失敗。 */ export interface SOGetBuffetAdditionHistoryResponse extends MultipleItems { } /** POS 讀取某桌可開吃到飽方案的請求;由 POS 後端發出,非 POS 前端直連 SDIT。 */ export interface PosGetBuffetPlansRequest { /** SDIT 店家 ID;POS 後端依目前登入店家帶入,SDIT 用於授權與方案篩選。 */ storeId: string; /** POS/SDIT 共同桌位 ID;POS 後端依目前選取的內用桌帶入。 */ tableId: string; /** POS 後端送出查詢時的 Unix epoch milliseconds;供稽核與時段判斷。 */ requestedAt: number; } /** POS 可顯示並選取的一個吃到飽方案;由 SDIT 依啟用狀態與菜單時段過濾。 */ export interface PosBuffetPlanOption { /** SDIT `BuffetPlan.id`;POS 開桌請求必須回傳此值。 */ id: string; /** SDIT Admin 設定的方案名稱,供 POS 店員選擇時顯示。 */ name: string; /** SDIT 解析的方案收費 `OrderItem` 快照;POS 建立正式訂單時依人數使用。 */ product: OrderItem; /** 方案用餐時長,單位為分鐘;僅供 POS 顯示,實際結束時間由開桌回應為準。 */ diningDurationMinutes: number; /** 結束前停止加點分鐘數;僅供 POS 顯示,實際截止時間由開桌回應為準。 */ lastAdditionBeforeEndMinutes: number; } /** 目前可供該店、該時間新開桌的 SDIT 方案列表;沿用既有列表 response。 */ export interface PosGetBuffetPlansResponse extends MultipleItems { } /** POS 後端要求 SDIT 建立吃到飽線上主單的請求;POS 前端不得直接呼叫。 */ export interface PosCreateBuffetOrderRequest { /** SDIT 店家 ID;由 POS 後端依登入店家帶入並接受 SDIT 授權驗證。 */ storeId: string; /** 目前內用桌 ID;SDIT 用以寫入主單桌位資訊。 */ tableId: string; /** SDIT `BuffetPlan.id`;必須來自 `PosGetBuffetPlansResponse`。 */ planId: string; /** POS 店員輸入的人數;SDIT 以它建立方案商品數量。 */ numberOfCustomers: number; /** POS 後端發起開桌時的 Unix epoch milliseconds。 */ requestedAt: number; } /** SDIT 建立吃到飽主單成功後的資料;POS 後端接著才可建立本地正式訂單。 */ export interface PosCreateBuffetOrderResponse { /** SDIT `Order.id` 主單 ID;POS 寫入 `orders.integration_order_id` 的唯一值。 */ masterOrderId: string; /** SDIT 解析的方案商品 `OrderItem` 快照,數量已乘上開桌人數;供 POS 建立正式訂單。 */ initialItems: OrderItem[]; /** 一次回傳的原始公開點餐能力碼;只用於產生 QR URL,任何系統不得持久化原始值。 */ publicOrderingAccessKey: string; /** 含原始公開能力碼的 QR 路徑;POS 前端可用來產生或列印 QR Code。 */ qrUrl: string; /** SDIT 開桌時計算的預計用餐結束 Unix epoch milliseconds;POS 寫入 `orders.dining_time`。 */ estimatedDiningEndAt: number; /** SDIT 開桌時計算的最後可加點 Unix epoch milliseconds;POS 寫入 `orders.remaining_time_remind`。 */ lastAdditionDeadlineAt: number; } /** POS 店員整筆接受加點時,由 POS 後端送往 SDIT 的最終決策請求。 */ export interface PosAcceptBuffetAdditionRequest { /** SDIT 店家 ID;POS 後端帶入,SDIT 用於定位與授權。 */ storeId: string; /** SDIT `Order.id` 吃到飽主單 ID;POS 的 `integration_order_id` 對應此值。 */ masterOrderId: string; /** SDIT `OrderAddition.id` 加點 ID;POS 接受與後續明細來源對應此值。 */ additionId: string; /** POS 正式訂單號;SDIT 成功接受後,POS 才將差量寫入此正式單。 */ formalOrderNo: string; /** POS `customer_take_order.orders_no` 待接單號;用於稽核這次店員決策的來源。 */ pendingTakeOrderNo: string; /** POS 店員按接受時的 Unix epoch milliseconds。 */ decidedAt: number; } /** POS 店員整筆拒絕加點時,由 POS 後端送往 SDIT 的最終決策請求。 */ export interface PosRejectBuffetAdditionRequest { /** SDIT 店家 ID;POS 後端帶入,SDIT 用於定位與授權。 */ storeId: string; /** SDIT `Order.id` 吃到飽主單 ID。 */ masterOrderId: string; /** SDIT `OrderAddition.id` 加點 ID;只能拒絕尚未完成決策的同一筆加點。 */ additionId: string; /** POS 待接單號;對應 `customer_take_order.orders_no`。 */ pendingTakeOrderNo: string; /** 拒絕不併入正式單;若 POS 有對應主單,可選保存 POS 正式訂單號。 */ formalOrderNo?: string; /** POS 店員按拒絕時的 Unix epoch milliseconds。 */ decidedAt: number; /** POS 既有線上訂單取消原因 `OOReasonCode`;SDIT 保存後供消費者歷史頁顯示。 */ rejectReasonCode: OOReasonCode; /** POS 可選的拒絕說明;未填時省略,不可取代原因代碼判斷。 */ rejectReasonMessage?: string; } /** POS 本地結帳、刪單或作廢成功後,POS 後端要求 SDIT 關閉吃到飽主單的請求。 */ export interface PosCloseBuffetOrderRequest { /** SDIT 店家 ID;POS 後端帶入,SDIT 用於定位與授權。 */ storeId: string; /** SDIT `Order.id` 吃到飽主單 ID;POS 前端不得直接用此 ID 呼叫 SDIT。 */ masterOrderId: string; /** POS 本地交易成功完成時的 Unix epoch milliseconds;SDIT 寫入 `Order.buffet.endedAt`。 */ endedAt: number; /** POS 後端判定的關閉原因;SDIT 寫入 `Order.buffet.endReason` 並使 QR 失效。 */ endReason: BuffetOrderEndReason; } /** SDIT 通知 POS 建立一筆加點待接單的 payload;由 SDIT 後端發出,不是消費者 request。 */ export interface PosBuffetAdditionNotification { /** SDIT 店家 ID;POS 以此選擇正確店家資料與冪等範圍。 */ storeId: string; /** SDIT `Order.id` 主單 ID;POS 保存為待接單與正式單的 `integration_order_id`。 */ masterOrderId: string; /** SDIT `OrderAddition.id` 加點 ID;POS 保存為 `integration_addition_id` 並做通知冪等。 */ additionId: string; /** SDIT 已解析的不可變 `OrderItem` 快照;POS 建立待接單明細時使用,不可再信任前端 input。 */ items: OrderItem[]; /** 消費者本輪整筆備註;未填時省略。 */ note?: string; /** 消費者送出加點時的 Unix epoch milliseconds;POS 可供待接單排序與顯示。 */ submittedAt: number; } /** POS 接收 SDIT 新加點通知後的冪等回應。 */ export interface PosReceiveBuffetAdditionResponse { /** POS 新建或既有的待接單號,即 `customer_take_order.orders_no`。 */ pendingTakeOrderNo: string; /** `true` 表示本次首次建立待接單;`false` 表示相同加點 ID 的冪等重送。 */ created: boolean; } /** POS 接受或拒絕後,由 SDIT 回傳的加點決策結果摘要。 */ export interface BuffetAdditionDecisionResult { /** SDIT `OrderAddition.id` 加點 ID;回應必須與 request 的加點 ID 相同。 */ id: string; /** SDIT 成功寫入後的完成決策狀態,僅可能為 `accepted` 或 `rejected`。 */ status: OrderAdditionStatus; /** POS 關聯與決策資料;SDIT 接受或拒絕寫入成功後出現。 */ pos?: OrderAdditionPosReference; } export interface PosAcceptBuffetAdditionResponse { /** SDIT 已接受並保存的加點決策摘要;POS 收到後才可寫入正式訂單。 */ addition: BuffetAdditionDecisionResult; } export interface PosRejectBuffetAdditionResponse { /** SDIT 已拒絕並保存的加點決策摘要;POS 不得將品項併入正式訂單。 */ addition: BuffetAdditionDecisionResult; } export interface PosCloseBuffetOrderResponse { /** 已關閉的 SDIT `Order.id` 主單 ID;供 POS 後端確認冪等結果。 */ masterOrderId: string; /** SDIT 保存的實際結束 Unix epoch milliseconds。 */ endedAt: number; /** SDIT 保存的結束原因。 */ endReason: BuffetOrderEndReason; }