Yuruicamp

inventory_locations

代表一個可存放庫存的地點 * rental_stock_reservations  
預約訂單的數量提前管控表 * product_stock_reservations
商品訂單的數量提前管控表

關聯與資料流

order_items
└─ 1:N product_stock_reservations
     └─ N:1 inventory_locations(inventory_domain = store)

booking_selected_rentals
└─ 1:N rental_stock_reservations
     └─ N:1 inventory_locations(inventory_domain = rental)

inventory_locations
├─ 1:N product_stock_reservations
└─ 1:N rental_stock_reservations

關聯

資料流程

商城訂單保留:

  1. 建立 order_items 後,依選取規格與出貨地點建立 product_stock_reservations
  2. status = active 時,數量仍被暫時保留;可設定 expires_at 供逾時釋放。
  3. 取消、付款失敗或逾時時,狀態改為 releasedexpired,並填入 released_at
  4. 訂單履約時,狀態改為 fulfilled,並填入 fulfilled_at

租借預約保留:

  1. 建立 booking_selected_rentals 後,依租借 SKU 規格、取用地點與入住區間建立 rental_stock_reservations
  2. status = active 時,[check_in, check_out) 區間內的可用數量必須扣除該保留數量。
  3. 取消時改為 released 並填入 released_at;完成租借時改為 fulfilled 並填入 fulfilled_at
  4. 租借保留沒有 expired 狀態;其有效性依預約業務流程決定。

欄位說明

product_stock_reservations

idx_product_stock_reservations_active_lookup ON (variant_id、location_id),條件:status = active idx_product_stock_reservations_expiry ON (expires_at),條件:status = active AND expires_at IS NOT NULL

rental_stock_reservations

idx_rental_stock_reservations_active_range ON (rental_sku_variant_id、location_id、check_in、check_out),條件:status = active

inventory_locations

CHECK:庫存領域、地點類型,以及門市類型與 branch_id 的相容性。 idx_inventory_locations_domain_type_active ON (inventory_domain、type、active)

運作模式

保留帳終態

程式碼追蹤

pages/checkout.htmljs/pages/checkout.jswindow.API.orders.create(orderData)js/api-mock.jslocalStorage.mockOrders

可能的問題