export default class Order { order: undefined } declare global { // orderapp domain/order.go OrderDiscount export interface IOrderDiscount { percent: number amount: number overrideItem?: boolean } // orderapp domain/order.go OrderRounding export interface IOrderRounding { type: 'up' | 'down' | 'off' | '' digits: number } // orderapp domain/merchant.go PaymentServiceCharge export interface IPaymentServiceCharge { percent: number amount: number } // orderapp domain/order.go OrderExtraPayment export interface IOrderExtraPayment { key: string paidAmount: number } // orderapp domain/order.go OrderCustomItem export interface IOrderCustomItem { name: string price: number quantity: number total: number cancelled: boolean } // orderapp delivery/order/view_history.go OrderHistory export interface IOrder { apiVersion?: string id: string serial: string orderSerial: string merchantId: string merchantName: string table: string // 桌號 customers: number // 客人 adults: number // 大人人數 children: number // 小孩人數 items: IOrderBatchItem[] // 每個 batch 裡面全部的 items,每個品項獨立一個 item remarks: string[] // 裡面全部 item 的 remarks tags: IMenuTag[] customItems: IOrderCustomItem[] // 自訂項目 discount?: IOrderDiscount // 舊版折扣 (棄用) modifiers: IPriceModifier[] surcharge: IOrderDiscount // 服務費 originalTotal: number // 原價總和 discountTotal: number // 舊版的折扣 calculatedDiscountTotal: number // modifiers 統計後折多少 surchargeTotal: number // 服務費總和 total: number // 原價 - 折扣 + 服務費 payments: IOrderPayment[] extraPayments: IOrderExtraPayment[] // 額外付款方式 paying: boolean // 客人正在要求付款 status: TOrderStatus // 訂單狀態 paidAt?: string // 付款時間 UTC ISO string cancelReason?: string // 取消原因 cancelIdentifier?: string // 取消者的 id takeawayStatus?: TOrderTakeawayStatus // 外帶狀態 code?: string // 外帶取餐碼 name?: string // 客人名字 phone?: string // 客人電話 address?: string // 地址 createdAt?: string // UTC ISO string pickupAt?: string // 客人取餐時間 UTC ISO string dropoffAt?: string // pickupp 客人取餐時間 UTC ISO string cancelledAt?: string // 取消時間 UTC ISO string version: number takeaway: boolean // 是否外帶訂單 delivery: boolean // 是否 pickupp 外送 deliveryStatus?: string // pickupp Delivery 狀況 pickuppOrderNumber?: string // pickupp order number batches: IOrderBatch[] // 點餐 deliveryType?: TDeliveryType shipping: IShipping // 運送方式 originalShippingFee?: number // 運費原價 discountShippingFee?: number // 運費折扣 shippingFee?: number // 運費(已折扣) shippingProvider: string // 運送提供者 memberId?: string // 會員編號 needTableware: boolean // 需要餐具 creditSales: boolean // 賒帳 mainOrderId: string // 空字串表示是主單,若有 id 是分單,mainOrderId 指向主單 subOrderIds: [] // 總單記錄所屬的分單 } export interface IPriceModifier { id?: string name?: string // 店家自訂的活動的名字(單一語言) type?: 'PROMOCODE' | 'RICECOIN' | 'MERCHANT' | 'SHIPPING_DISCOUNT' applyTo?: 'PRODUCT' | 'SHIPPING' | 'ALL' code?: string // promo code payload?: string // 如果是 RICECOIN 會存 ledger id percent: number // -20 就是 20% OFF = 8折 amount: number // -20 就是折 20 元 calculatedAmount?: number // 實際變動多少錢 overrideItem?: boolean // order level only } export interface IOrderPayment { id: string paymentMethod?: TPaymentMethod // 付款方式 paymentCharge?: IPaymentServiceCharge // 手續費 amount: number // 應付金額 paidAmount?: number // 實收金額 paymentTips?: number // 小費 change?: number // 找零 remark?: string // 備註 createdAt: Date // UTC ISO String } // orderapp delivery/order/view_batch.go OrderBatchView export interface IOrderBatch { deviceId?: string orderId: string orderSerial: string batchId: string index: number table: string items: IOrderBatchItem[] // 一個 item 可能會有多個數量 remark: string reconfirm?: boolean takeout: boolean // 外帶 storeDelivery: boolean // 是否外送訂單 shop: boolean // 是否網店訂單 takeaway: boolean // 是否外帶訂單 status: TOrderBatchStatus takeawayStatus?: TOrderTakeawayStatus deliveryType?: TDeliveryType createdAt: Date | string // UTC ISO String updatedAt: Date | string // UTC ISO String receivedAt?: string // UTC ISO String delivery: boolean // Deprecated 是否 pickupp 外送 deliveryStatus?: string // Deprecated pickupp status } // orderapp delivery/order/view_batch.go OrderBatchItemView export interface IOrderBatchItem { id: string ids: string[] // 每個項目的 id categoryId: string menuId: string // 不可信,可能會被取代為隨機 uuid 或 menuId 後面加字串,用來查 menu 時應使用 originMenuId setId: string originMenuId: string // 真正的 menu id setMenuIndex: number | null setName?: string setNameCode?: string name: string quantity: number divisor?: number originalTotal: number // 原價 price: number // 原價 - discount prices: number[] // 每個 item 的 total (包含選項、折扣等) discounts: number[] // 每個 item 的餐點折扣 (menu item discount) modifiers: IPriceModifier[][] // 其他的折扣不含 menu item discount totalDiscount: number // modifiers 統計後折多少 (不含 menu item 的 discount) totalDiscounts: number[] // 每個 item 的 modifiers 統計後折多少 (不含 menu item 的 discount) total: number // 全部東西都算完後這個餐點多少錢 totals: number[] // 每個 item 全部東西都算完後這個餐點多少錢 priceUndetermined: boolean excludeOrderDiscount: boolean excludedOrderSurcharge: boolean options: IOrderBatchItemOption[][] tags: IMenuTag[][] unconfirmed: boolean cancelled: boolean remarks: string[] // 每個品項的備註 code: string } // orderapp domain/order.go OrderMenuOption(MarshalJSON) export interface IOrderBatchItemOption { optionId: string // MenuOptionGroup.options 中選項的 id => app optionItemId assoOptionId: string categoryId: string name: string price: number quantity: number } export interface ICalculateOrderParams { batches: IAppOrderBatch[] deliveryType: TDeliveryType shipping: IShipping rounding: IOrderRounding surcharge: IOrderDiscount modifiers: IPriceModifier[] promoCodeId?: string usedRiceCoin?: number } export interface ICalculateOrderRequestData { batches: IOrderBatchRequestItem rounding: IOrderRounding shipping: IShipping surcharge: IOrderDiscount modifiers: IPriceModifier[] promocode?: string // promocode id withholding?: number // used ricecoin } // * Request get orders export interface IOrderRequestQuery { id?: string serial?: string table?: string // 桌號 tableGroup?: string // 桌號分組 q?: string // search in name phone type?: TDeliveryType // ,可逗號分隔查詢多個 status?: TOrderStatus // 訂單狀態,可逗號分隔查詢多個 takeawayStatus?: TOrderTakeawayStatus // 外送狀態,可逗號分隔查詢多個 shippingProvider?: string // 外送廠商,可逗號分隔查詢多個 paying?: boolean // 叫 waiter 過來付錢 creditSales?: boolean // 賒帳 from?: number to?: number limit?: number page?: number } export interface IClientOrderRequestQuery { merchantId: string table?: string status?: TOrderStatus isFilteredByMe?: boolean valid?: boolean | 'true' | 'false' | 'true,false' limit?: number withinCutoffTime?: boolean } // * Request Add export interface IAddOrderRequestData { orderID: string merchantID: string mainOrderID?: string table: string adults: number children: number deliveryType: TDeliveryType orderCutOffMins: number create: boolean from?: 'CUSTOMER_APP' | 'CUSTOMER_WEB' | 'MERCHANT' } // * Request Update export interface IUpdateOrderRequestData { name?: string phone?: string address?: string adults?: number children?: number remark?: string } // * Request Submit export interface ISubmitBatchParams { orderId: string orderBatch: IAppOrderBatch deliveryType: TDeliveryType payment?: IPayment shipping: IShipping takeawayInfo?: (IOrderBatchRequestTakeawayInfo | {}) ignoreUnavailable: boolean needTableware?: boolean lastSubOrder?: boolean promoCode?: string riceCoin?: string from?: 'CUSTOMER_APP' | 'CUSTOMER_WEB' | 'MERCHANT' } // orderapp delivery/order/submit.go SubmitRequest export interface IOrderBatchRequestData { batchID: string items: IOrderBatchRequestItem[] remark: string promoCode?: string riceCoin?: string ignoreUnavailable: boolean takeout: boolean takeawayInfo: IOrderBatchRequestTakeawayInfo | {} deliveryType: string shipping?: IShipping payment?: IPayment needTableware: boolean lastSubOrder?: boolean from?: 'CUSTOMER_APP' | 'CUSTOMER_WEB' | 'MERCHANT' status?: TOrderBatchStatus } export interface IUpdatePaymentRequestData { paidAmount?: number // 實收金額 paymentTips?: number // 小費 change?: number // 找零 } // orderapp delivery/order/submit.go SubmitRequestTakeawayInfo export interface IOrderBatchRequestTakeawayInfo { phone: string address: string name: string pickupAt: string // UTC ISO string dropoffAt: string // UTC ISO string payment: string source: string lat: number lng: number district: string floorRoom: string building: string scheduleAt: string // UTC ISO string shipping: IOrderBatchTakeawayInfoShipping } export interface IOrderBatchTakeawayInfoShipping { key: string | 'SYSTEM' name: string cost: number minAmount: number type: TDeliveryType minDeliveryMinute: number maxDeliveryMinute: number enabled: boolean discounts: number[] freightCollect: boolean areas: IOrderBatchTakeawayInfoShippingArea[] lalamove: boolean isSystem: boolean totalFee: number quotedTotalFee: number } export interface IOrderBatchTakeawayInfoShippingArea { district: string isDefault: boolean price: number providers: string[] payByMerchant: boolean discount: number } // orderapp delivery/order/submit.go SubmitRequestItem export interface IOrderBatchRequestItem { itemID?: string // request 時不用帶 customerID?: string menuID: string // 單點時就是 menu 的 id(IMenu.id)。套餐時指向 set menu 原始的 menu id (IMenu.menuId) setID?: string // 套餐 id setMenuID: string | null // set menu 自己的 id (IMenu.id) setMenuIndex: number | null setName?: string name: string desc: string divisor?: number price: number discount: number modifiers: IPriceModifier[] options: IOrderBatchRequestItemOption[] tags: IMenuTag[] remarks: string[] isSet: boolean } // orderapp delivery/order/additem.go AddItemRequestOption export interface IOrderBatchRequestItemOption { optionID: string name: string price: number quantity: number } // * Request Pay // orderapp delivery/order/pay.go PayRequest export interface IPayOrderData { payment: string amount: number extraPayment: string extraAmount: number tips: number } export interface IRecentPayment { id: string createdAt: string version: number customer: { id: string } custId: string token: string method: string // visa | master ... gateway: string // stripe } export interface ICreateWechatPaymentRequestData { pay_type: number // 800210 - App to App 800201 - QRC 800212 - JSAPI txamt: number out_trade_no: string txcurrcd: string // HKD } export interface IWechatData { pay_type: string sysdtm: string paydtm: string udid: string txcurrcd: string txdtm: string txamt: string resperr: string respmsg: string out_trade_no: string syssn: string pay_params: IWechatPayParams respcd: string chnlsn: string cardcd: string } export interface IWechatPayParams { package: string timestamp: string sign: string partnerid: string appid: string prepayid: string noncestr: string } export interface IOrderStatCategoryResponse { count: number customerCount?: number total: number unpaidTotal?: number shippingFee?: number discountTotal: number originalTotal: number categoryTotals: { [categoryId: string]: ICategoryTotal } orders: { // 該時段內 第一張 跟 最後一張 order的serial start?: string // order serial end?: string // order serial } } export interface ICategoryTotal { count: number customerCount: number total: number unpaidTotal: number shippingFee: number menuTotals: { [menuId: string]: { name: string count: number } } } export interface IOrderStatSummaryRequestParams { from: string // timestamp (seconds) to: string // timestamp (seconds) cancelled: boolean deliveryType?: TDeliveryType takeaway?: boolean } export interface IOrderStatSummaryResponse { count: number // 該時段內總訂單數 customerCount: number // 該時段內總客人數 total: number // 該時段內訂單總額 payments?: IVolumeSummaryMap // 該時段內不同付款方式的 Count CustomerCount Total creditSales?: IVolumeSummaryMap // 該時段內賒數記錄 extraPayments?: IVolumeSummaryMap // 該時段內現金卷類的 Count CustomerCount Total paymentCharges?: IVolumeSummaryMap // 該時段內付款手續費的 Count CustomerCount Total paymentTips?: IVolumeSummaryMap // 該時段內付款小費的 Count CustomerCount Total cancelReasons?: IVolumeSummaryMap // 該時段內訂單取消原因的 Count CustomerCount Total data: IHourlySummary[] // 該時段內 每一小時的stat creditSalesData: ICreditSalesOrderView[] | null // 該時段內 每一筆賒數訂單 orders: { // 該時段內 第一張 跟 最後一張 order的serial start?: string // order serial end?: string // order serial } beforeCloseOrder?: ICountAndTotal // 該時段內 所有付款前取消的item 的 count total afterCloseOrder?: ICountAndTotal // 該時段內 所有付款後取消的item 的 count total unpaidOrder?: ICountAndTotal // 未結帳order count total shippingFee: number // 總運費 promocodes: IPromocodeSummary[] } export interface IVolumeSummaryMap { [paymentMethod: string]: IVolumeSummary } export interface IVolumeSummary { count: number customerCount: number total: number unpaidTotal: number shippingFee: number } export interface IHourlySummary { from: string // 2021-05-04T18:00:00+08:00 to: string // 2021-05-04T18:00:00+08:00 payments: IVolumeSummaryMap creditSales: IVolumeSummaryMap extraPayments: IVolumeSummaryMap paymentCharges: IVolumeSummaryMap paymentTips: IVolumeSummaryMap cancelReasons?: IVolumeSummaryMap } export interface ICreditSalesOrderView { serial: string total: number } export interface ICountAndTotal { count: number total: number } export interface IPromocodeSummary { code: string count: number total: number } export interface IOrderStatUnpaidResponse { count: number // 該時段內總訂單數 customerCount: number // 該時段內總客人數 total: number // 該時段內訂單總額 } export interface IOrderStatCancelRequestParams { from: string // timestamp (seconds) to: string // timestamp (seconds) takeaway?: boolean } export interface ICancelOrder { Serial: string Identifier: string Reason: string } }