喜樂燒臘|訂單資料表欄位檢查

order_schema_check.php|V1.1-B2.3A|只讀檢查,不修改資料庫
返回接單中心 電話接單 今日訂單 系統檔案管理
90
orders 欄位數
必填無預設:1
28
order_items 欄位數
必填無預設:2
33
order_item_options 欄位數
必填無預設:3
檢查到 NOT NULL 且沒有預設值的欄位。B2 建立訂單時必須依照這些欄位規則一次補齊寫入。

下一步推斷

目前 B2/B3 的問題不是單一欄位,而是訂單資料表已有固定規則。下一版 B2.3 應以本頁列出的欄位為準,完整寫入 orders、order_items、order_item_options,尤其是 snapshot 欄位。

orders|實際欄位

欄位型別NullDefaultExtra規則判斷
id bigint unsigned NO NULL auto_increment 必填有預設
store_id varchar(50) NO dawan 必填有預設
store_code varchar(50) NO dawan 必填有預設
store_name varchar(100) NO 大灣喜樂燒臘 必填有預設
order_no varchar(80) NO NULL 必填無預設
external_order_id varchar(120) YES NULL 可空
request_id varchar(120) YES NULL 可空
source_system varchar(80) NO order_center 必填有預設
order_type varchar(50) NO pickup 必填有預設
status varchar(50) NO draft 必填有預設
business_date date YES NULL 可空
scheduled_date date YES NULL 可空
meal_period varchar(50) YES NULL 可空
pickup_time time YES NULL 可空
delivery_time time YES NULL 可空
customer_id bigint unsigned YES NULL 可空
customer_name_snapshot varchar(120) YES NULL 可空
company_name_snapshot varchar(160) YES NULL 可空
phone_snapshot varchar(40) YES NULL 可空
phone_last3 varchar(3) YES NULL 可空
address_snapshot varchar(255) YES NULL 可空
navigation_address_snapshot varchar(255) YES NULL 可空
order_note text YES NULL 可空
delivery_note text YES NULL 可空
subtotal_amount decimal(10,2) NO 0.00 必填有預設
option_amount decimal(10,2) NO 0.00 必填有預設
discount_amount decimal(10,2) NO 0.00 必填有預設
manual_adjust_amount decimal(10,2) NO 0.00 必填有預設
total_amount decimal(10,2) NO 0.00 必填有預設
payment_status varchar(50) NO unpaid 必填有預設
payment_method varchar(50) NO cash 必填有預設
need_collect_money tinyint(1) NO 1 必填有預設
is_monthly_billing tinyint(1) NO 0 必填有預設
billing_type varchar(50) YES NULL 可空
edit_deadline_at datetime YES NULL 可空
revision_no int NO 1 必填有預設
created_by bigint unsigned YES NULL 可空
confirmed_at datetime YES NULL 可空
cancelled_at datetime YES NULL 可空
created_at datetime NO CURRENT_TIMESTAMP DEFAULT_GENERATED 必填有預設
updated_at datetime NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP 必填有預設
source_type varchar(30) NO phone 必填有預設
customer_name varchar(80) YES NULL 可空
customer_phone varchar(40) YES NULL 可空
delivery_address varchar(255) YES NULL 可空
pickup_date date YES NULL 可空
order_status varchar(30) NO new 必填有預設
subtotal decimal(10,2) NO 0.00 必填有預設
need_delivery tinyint(1) NO 0 必填有預設
delivery_notes text YES NULL 可空
notes text YES NULL 可空
navigation_address varchar(255) YES NULL 可空
delivery_date date YES NULL 可空
important_note text YES NULL 可空
bag_count int NO 1 必填有預設
delivery_sync_status varchar(30) NO not_sent 必填有預設
delivery_task_id varchar(120) YES NULL 可空
delivery_sync_message text YES NULL 可空
delivery_synced_at datetime YES NULL 可空
delivery_last_request_id varchar(120) YES NULL 可空
delivery_last_http_status int YES NULL 可空
delivery_last_response_json mediumtext YES NULL 可空
delivery_last_endpoint varchar(255) YES NULL 可空
delivery_last_error_code varchar(80) YES NULL 可空
common_customer_id bigint unsigned YES NULL 可空
customer_uid varchar(160) YES NULL 可空
delivery_order_revision int unsigned NO 1 必填有預設
delivery_last_synced_revision int unsigned YES NULL 可空
delivery_fulfillment_status varchar(30) NO pending 必填有預設
delivery_delivered_at datetime YES NULL 可空
delivery_delivered_by_uid varchar(128) YES NULL 可空
delivery_delivered_by_name varchar(100) YES NULL 可空
delivery_proof_photo_url text YES NULL 可空
delivery_status_event_id varchar(180) YES NULL 可空
delivery_status_callback_at datetime YES NULL 可空
delivery_status_event_json mediumtext YES NULL 可空
service_datetime datetime YES NULL 可空
meal_period_id varchar(120) YES NULL 可空
time_source varchar(40) NO legacy 必填有預設
business_hours_settings_version varchar(40) YES NULL 可空
business_hours_settings_revision varchar(96) YES NULL 可空
business_hours_override tinyint(1) NO 0 必填有預設
business_hours_override_reason varchar(255) YES NULL 可空
business_hours_override_at datetime YES NULL 可空
print_revision int unsigned NO 1 必填有預設
print_revision_hash varchar(64) YES NULL 可空
print_revision_at datetime YES NULL 可空
delivery_test_task_synced tinyint(1) NO 0 必填有預設
bag_names_json text YES NULL 可空
prepaid_amount decimal(12,2) YES NULL 可空

orders|B2/B3 預期欄位對照

欄位狀態用途
id 存在 主鍵
order_no 存在 訂單編號
business_date 存在 營業日;舊表可能必填,B2 寫入時必須補
pickup_date 存在 取餐日期;B3 今日訂單查詢會用
pickup_time 存在 取餐時間
source_type 存在 訂單來源:phone / online / pos
order_type 存在 訂單類型:pickup / delivery
customer_name 存在 顧客姓名
customer_phone 存在 顧客電話
total_amount 存在 訂單總金額
order_status 存在 訂單狀態;若舊表用 status,B2/B3 需相容
status 存在 訂單狀態備援欄位
notes 存在 訂單備註;若舊表用 note,B2/B3 需相容
note 不存在 訂單備註備援欄位
created_at 存在 建立時間
updated_at 存在 更新時間

order_items|實際欄位

欄位型別NullDefaultExtra規則判斷
id bigint unsigned NO NULL auto_increment 必填有預設
store_id varchar(50) NO dawan 必填有預設
order_id bigint unsigned NO NULL 必填無預設
bag_id bigint unsigned YES NULL 可空
product_id bigint unsigned YES NULL 可空
product_code_snapshot varchar(80) YES NULL 可空
product_name_snapshot varchar(120) NO NULL 必填無預設
product_type_snapshot varchar(50) YES NULL 可空
unit_price_snapshot decimal(10,2) NO 0.00 必填有預設
quantity int NO 1 必填有預設
base_subtotal decimal(10,2) NO 0.00 必填有預設
option_subtotal decimal(10,2) NO 0.00 必填有預設
discount_subtotal decimal(10,2) NO 0.00 必填有預設
item_subtotal decimal(10,2) NO 0.00 必填有預設
item_note varchar(255) YES NULL 可空
sort_order int NO 0 必填有預設
created_at datetime NO CURRENT_TIMESTAMP DEFAULT_GENERATED 必填有預設
updated_at datetime NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP 必填有預設
product_code varchar(50) YES NULL 可空
product_name varchar(120) YES NULL 可空
unit_price decimal(10,2) NO 0.00 必填有預設
line_total decimal(10,2) NO 0.00 必填有預設
item_notes text YES NULL 可空
subtotal decimal(10,2) NO 0.00 必填有預設
bag_no int NO 1 必填有預設
bag_name varchar(40) NO 本次訂單 必填有預設
product_short_name_snapshot varchar(120) NO 必填有預設
price_adjustment_json mediumtext YES NULL 可空

order_items|B2/B3 預期欄位對照

欄位狀態用途
id 存在 主鍵
order_id 存在 訂單 ID
product_id 存在 商品 ID
product_code_snapshot 存在 商品代碼快照;建議寫入
product_name_snapshot 存在 商品名稱快照;舊表目前已出現必填錯誤
unit_price_snapshot 存在 商品單價快照;建議寫入
product_code 存在 商品代碼備援欄位
product_name 存在 商品名稱備援欄位
unit_price 存在 單價備援欄位
quantity 存在 數量
subtotal 存在 小計;若舊表用 line_total,B2/B3 需相容
line_total 存在 小計備援欄位
item_note 存在 品項備註;若舊表用 item_notes,B2/B3 需相容
item_notes 存在 品項備註備援欄位
created_at 存在 建立時間
updated_at 存在 更新時間

order_item_options|實際欄位

欄位型別NullDefaultExtra規則判斷
id bigint unsigned NO NULL auto_increment 必填有預設
store_id varchar(50) NO dawan 必填有預設
order_id bigint unsigned NO NULL 必填無預設
order_item_id bigint unsigned NO NULL 必填無預設
option_group_id bigint unsigned YES NULL 可空
option_item_id bigint unsigned YES NULL 可空
option_group_code_snapshot varchar(80) YES NULL 可空
option_group_name_snapshot varchar(120) YES NULL 可空
option_code_snapshot varchar(80) YES NULL 可空
option_name_snapshot varchar(120) NO NULL 必填無預設
option_price_snapshot decimal(10,2) NO 0.00 必填有預設
option_qty int NO 1 必填有預設
option_subtotal decimal(10,2) NO 0.00 必填有預設
sort_order int NO 0 必填有預設
created_at datetime NO CURRENT_TIMESTAMP DEFAULT_GENERATED 必填有預設
updated_at datetime NO CURRENT_TIMESTAMP DEFAULT_GENERATED on update CURRENT_TIMESTAMP 必填有預設
option_group_code varchar(50) YES NULL 可空
option_group_name varchar(120) YES NULL 可空
option_code varchar(50) YES NULL 可空
option_name varchar(120) YES NULL 可空
price_delta decimal(10,2) NO 0.00 必填有預設
base_price_delta decimal(10,2) NO 0.00 必填有預設
option_quantity int NO 1 必填有預設
child_source_type varchar(30) YES NULL 可空
child_source_ids varchar(255) YES NULL 可空
child_source_codes varchar(255) YES NULL 可空
child_source_names varchar(500) YES NULL 可空
child_snapshot_json text YES NULL 可空
unit_price_delta decimal(10,2) NO 0.00 必填有預設
child_source_id int unsigned YES NULL 可空
child_source_code varchar(60) YES NULL 可空
child_source_name varchar(120) YES NULL 可空
child_selection_json mediumtext YES NULL 可空

order_item_options|B2/B3 預期欄位對照

欄位狀態用途
id 存在 主鍵
order_id 存在 訂單 ID
order_item_id 存在 訂單品項 ID
option_group_id 存在 選項群組 ID
option_group_code 存在 選項群組代碼
option_group_name_snapshot 存在 選項群組名稱快照;建議寫入
option_group_name 存在 選項群組名稱備援欄位
option_item_id 存在 選項 ID
option_code 存在 選項代碼
option_name_snapshot 存在 選項名稱快照;建議寫入
option_name 存在 選項名稱備援欄位
price_delta 存在 加價金額
created_at 存在 建立時間

B2.3 修正方向,不在本頁執行

一小步一小步:本頁只負責看清楚資料庫規則。確認畫面後,再製作 B2.3「完整快照寫入版」與 B3.3「讀取 snapshot 版」。