雄獅旅遊

高鐵團票登記

預購系統/技術文件庫/本專案 API 路由與 Server Actions 一覽
架構與維運•internal-api-reference.md
Internal API

本專案 API 路由與 Server Actions 一覽

前後台 /api/* 路由與主要 Server Actions 的參數、回應、錯誤碼、權限與快取設定。

最後更新:2018/10/20•檔案規格:36 KB
本頁章節目錄 (17 個段落)▼

docs/api-1.json 是外部 B2E 系統的 API 規格(對外整合用)。本文件記錄的是本專案自身的介面:app/api/** Route Handler 與 features/**/actions.ts 中的 Server Action。內容依目前程式碼整理;ERP 同步腳本不在本文範圍。


1. 概述 (Overview) #

  • 前台(訂票):以 HttpOnly 簽章 cookie booking_session 識別員工(getBookingSession() / getBookingEmpId()),員工編號一律由伺服器從 session 取得,不信任前端傳入值。
  • 後台(管理):以 admin_session 識別,透過 requireAdmin(role) 檢查角色:
    • "any":任何已登入後台帳號(super_admin / admin / staff)
    • "admin":admin 或 super_admin
    • "super_admin":僅最高管理者
    • 帳號帶有 mustChangePassword 時,除 changeOwnPasswordAction 外一律拒絕。
  • 權限不足的回應
    • Server Action:adminDenied() → 未登入回 { success:false, code:"UNAUTHORIZED" };已登入但權限不足或須先改密碼回 { success:false, code:"FORBIDDEN" }。
    • Route Handler:adminDeniedResponse() → 未登入 401、權限不足 403。
  • 資料庫存取:所有 RPC 已對 anon 撤銷執行權限,一律由伺服器以 secret key(getServerSb())呼叫。資料庫層不區分後台角色,角色由 server action 的 requireAdmin 檢查。
  • Server Action 回傳型別(features/shared/types.ts):
    ts
    interface ActionResult<T = any> {
      success: boolean;
      data?: T;
      error?: string;
      code?: string;
    }
    前台訂票 action 中,error 為業務錯誤代碼、code 為 system_logs 的 Trace ID(或 UNAUTHORIZED);後台 action 中,error 多為可直接顯示的中文訊息、code 為 UNAUTHORIZED / FORBIDDEN / CONFLICT。
  • 日誌:寫入 system_logs 透過 recordLog()(lib/auditLogger.ts),回傳 Trace ID。

2. Route Handlers (`app/api/**`) #

2.1 一覽表 #

方法 路徑 權限 用途 快取 檔案
GET /api/trains 公開 單日單方向車次(含班表) unstable_cache 10s + s-maxage=5 app/api/trains/route.ts
GET /api/seats 公開 席位快照(短輪詢) 直查 DB + s-maxage=1 app/api/seats/route.ts
POST /api/hold/release 前台 session 頁面關閉時 keepalive 釋放保留 無 app/api/hold/release/route.ts
GET /api/export/fares 後台 any 票價表 CSV no-store app/api/export/fares/route.ts
GET /api/export/trains 後台 any 全班次時刻與庫存 CSV no-store app/api/export/trains/route.ts
POST /api/admin/orders/export 後台 admin 訂單 CSV(串流) no-store app/api/admin/orders/export/route.ts
POST /api/admin/released/export 後台 admin 釋放席位 / 候補名單 CSV(串流) no-store app/api/admin/released/export/route.ts

middleware 不涵蓋 /api,各端點自行檢查權限。

2.2 `GET /api/trains` #

  • 檔案:app/api/trains/route.ts(export const dynamic = "force-dynamic")
  • 權限:公開
  • Query:date=YYYY-MM-DD(須為合法日曆日,如 2026-02-30 會被擋)、dir=S|N
  • 資料來源:getCachedTrainsByDateAndDir(date, dir)(features/booking/queries.ts,unstable_cache,revalidate: 10、tag trains)。不提供繞過快取的參數;即時席位請用 /api/seats。
  • Response 200:{ "trains": Train[] },標頭 Cache-Control: public, s-maxage=5, must-revalidate
  • 錯誤:參數錯誤 400 { "error": "INVALID_PARAMS" };查詢失敗 500 { "error": "FETCH_ERROR" }(Cache-Control: no-store)

2.3 `GET /api/seats` #

  • 檔案:app/api/seats/route.ts(force-dynamic)
  • 權限:公開
  • Query:同 /api/trains(date、dir,相同驗證)
  • 資料來源:getSeatSnapshot(date, dir),直查 trains,不經 unstable_cache
  • Response 200:
    json
    {
      "seats": [
        {
          "id": "...",
          "seats_available": 12,
          "total_seats": 200,
          "is_active": true,
          "seat_version": 42
        }
      ]
    }
    標頭 Cache-Control: public, s-maxage=1, must-revalidate(seat_version 未套 migration 時為 null)
  • 錯誤:400 INVALID_PARAMS;500 FETCH_ERROR(no-store)

2.4 `POST /api/hold/release` #

  • 檔案:app/api/hold/release/route.ts
  • 用途:瀏覽器 fetch(..., { keepalive: true }) 於關閉頁面 / 換頁 / 閒置登出時釋放保留(Server Action 不支援 keepalive)。
  • 權限:前台 booking_session(getBookingEmpId())
  • Body:{ "hold_ids": string[] }(1~4 筆字串)
  • 副作用:RPC release_hold(p_hold_ids, p_emp_id),只釋放屬於該員工的保留;不寫日誌。
  • Response:200 { "ok": true };未登入 401 { "ok": false };Body 不合法 400 { "ok": false }

2.5 `GET /api/export/fares` #

  • 檔案:app/api/export/fares/route.ts
  • 權限:requireAdmin("any"),否則 401 純文字 Unauthorized
  • 資料:fares 表(from_st, to_st, adult, concession, override_adult, override_concession);DB 讀取失敗或為空時改讀 public/downloads/thsr_official_fares.csv
  • Response:text/csv; charset=utf-8(UTF-8 BOM + CRLF),Content-Disposition: attachment; filename="thsr_official_fares.csv",Cache-Control: no-store
  • 錯誤:500 純文字;不寫日誌

2.6 `GET /api/export/trains` #

  • 檔案:app/api/export/trains/route.ts
  • 權限:requireAdmin("any"),否則 401
  • 資料:trains 全表分頁讀取(fetchAllPages);失敗時改讀 public/downloads/thsr_train_schedule_2027.csv
  • 欄位:乘車日期、星期、方向、車次、可保留席次、剩餘可用席次、營運狀態、12 站時刻
  • Response:CSV,檔名 thsr_train_schedule_2027.csv,no-store;不寫日誌

2.7 `POST /api/admin/orders/export` #

  • 檔案:app/api/admin/orders/export/route.ts
  • 權限:requireAdmin("admin"),否則 adminDeniedResponse()(401 / 403)
  • Body:form-data 欄位 filters(JSON 篩選條件,經 parseExportFilters + normalizeOrderFilters 驗證);前端只傳條件,訂單一律由伺服器讀取(RPC admin_get_orders,rpcFetchAll 全量)並以 filterOrders 篩選,無 5000 筆截斷。
  • 個資:staff 匯出時證件號碼遮蔽(目前因權限為 admin 以上,實務上為完整資料)。
  • Response:串流 CSV,檔名 thsr_orders_<台北日期>.csv,Cache-Control: no-store, no-cache, must-revalidate
  • 錯誤:篩選條件不合法 400 Invalid export filters;RPC 失敗 500 匯出失敗
  • 日誌:admin_export_orders(筆數、篩選條件、角色、是否遮蔽、前 200 筆訂單號、IP/UA)

2.8 `POST /api/admin/released/export` #

  • 檔案:app/api/admin/released/export/route.ts
  • 權限:requireAdmin("admin")(401 / 403)
  • Body:form-data filters(normalizeReleasedFilters 驗證)
  • 資料:RPC admin_get_released_seats、admin_get_orders 與 trains 表,由伺服器組出車次群組後篩選
  • Response:串流 CSV,檔名 thsr_released_<台北日期>.csv
  • 錯誤:400 Invalid export filters;500 匯出失敗
  • 日誌:admin_export_released(列數、車次數、篩選條件、IP/UA)

3. Server Actions #

3.1 一覽表 #

分組 Action 權限 主要 RPC / 資料表 日誌 action
前台訂票 releaseExpiredHoldsAction() 前台 session _release_expired_holds —
前台訂票 createHoldAction(segments, seats) 前台 session create_hold create_hold_failed(SOLD_OUT 除外)
前台訂票 releaseHoldAction(holdIds) 前台 session release_hold —
前台訂票 submitOrderAction(payload) 前台 session(emp_id 須相符) confirm_order submit_order_success / submit_order_failed / submit_order_exception
前台認證 exchangeHandoffToken(token) 公開 handoff 驗證 重放時 logHandoffReplayed
前台認證 renewBookingSessionAction() 前台 session — —
前台認證 logoutUser() 公開 — —
前台認證 getBookingProfileAction() 前台 session — —
前台認證 verifyAccessPassword(password) 公開(main 停用) — site_password_login_failed
後台 loginAction(account, pwd) 公開 admin_login_attempt_begin、admin_users admin_login_success / admin_login_failed / admin_login_locked
後台 changeOwnPasswordAction(current, next) any(允許待改密) admin_users admin_change_own_password
後台 getSessionAction() 公開 — —
後台 logoutAction() 公開 — admin_logout
後台 releaseExpiredHoldsAdminAction() any _release_expired_holds —
後台 getTrainAllocationsAction(ids) admin admin_train_allocations —
後台 batchTrainAction(ids, active, total) admin admin_batch_train admin_batch_train
後台 updateTrainAction(id, active, total) admin admin_update_train admin_update_train
後台 updateSettingAction(key, value) admin admin_update_setting admin_update_setting
後台 saveBookingWindowAction(start, end) admin admin_save_booking_window admin_save_booking_window
後台 saveDiscountAction(discount) admin 轉呼叫 updateSettingAction admin_update_setting
後台 saveStationsAction(stations) admin 轉呼叫 updateSettingAction admin_update_setting
後台 saveFareAction(from, to, adult, conc) admin admin_set_fare admin_update_fare
後台 getOrdersAction() any admin_get_orders —
後台 getOrdersPageAction(from, batchSize) any admin_get_orders —
後台 updateOrderAction(...) any admin_update_order admin_update_order
後台 updateOrderPickupLocationAction(orderNo, loc) any admin_update_order_pickup_location admin_update_order_pickup_location
後台 adjustOrderAction(orderNo, tickets) any admin_adjust_order admin_adjust_order
後台 cancelOrderAction(orderNo) any cancel_order admin_cancel_order
後台 getReleasedSeatsAction() any admin_get_released_seats —
後台 getAdminUsersAction() super_admin admin_users、admin_login_attempts —
後台 createAdminUserAction(input) super_admin admin_users admin_user_create
後台 updateAdminRoleAction(id, role) super_admin admin_users admin_user_update_role
後台 resetAdminPasswordAction(id) super_admin admin_users、admin_login_attempts admin_user_reset_password
後台 setAdminUserStatusAction(id, status) super_admin admin_users admin_user_disable / admin_user_enable
後台 unlockAdminUserAction(account) super_admin admin_login_attempts admin_user_unlock
後台 getSystemLogsAction(filter) super_admin system_logs —
後台 getSystemLogModuleCountsAction(range) super_admin admin_log_action_counts —
後台 getSystemLogDetailAction(id, reveal) super_admin system_logs admin_reveal_pii(reveal 且含個資時)

3.2 前台訂票 (`features/booking/actions.ts`) #

前置共通:未登入回 { success:false, code:"UNAUTHORIZED", error:"登入已逾期,請重新登入" }。資料庫錯誤訊息只萃取已知業務代碼(SOLD_OUT、NOT_OPEN、CLOSED、BAD_SEATS、BAD_TICKETS、BAD_INPUT、BAD_ID、HOLD_EXPIRED),其餘以 fallback 代碼回傳,不外洩 DB 細節;已知代碼記 warn,未知記 error。

`releaseExpiredHoldsAction(): Promise` #

  • 查詢班次前呼叫,執行 _release_expired_holds() 讓逾期席位回到可售池。回傳 { success:true }。

`createHoldAction(segments: HoldSegmentInput[], seats: number)` #

  • 驗證:segments 1~2 段,train_id 為 UUID、from / to 為字串;seats 須為整數;來回時起訖站須互為反向。不符回 { success:false, error:"BAD_INPUT" }(不寫日誌)。張數範圍 1..max_tickets 由資料庫檢查(BAD_SEATS)。
  • RPC:create_hold(p_emp_id, p_segments, p_seats)
  • 成功:{ success:true, data:{ hold_ids, expires_at, seat_status, trains: SeatSnapshotRow[], server_now } }
  • 失敗:{ success:false, error:<代碼|HOLD_FAILED>, code:<Trace ID> };SOLD_OUT 為高併發預期狀態,不寫日誌、無 Trace ID。

`releaseHoldAction(holdIds: string[])` #

  • 驗證:1~4 筆 UUID,不符回 { success:false }。
  • RPC:release_hold(p_hold_ids, p_emp_id),僅釋放本人保留。回傳 { success:true }。

`submitOrderAction(payload: SubmitOrderPayload)` #

  • 驗證:session 員編須等於 payload.cust.emp_id(否則 UNAUTHORIZED);holdIds 1~4 筆 UUID;證件號碼依 id_type 檢查(BAD_ID);姓名(customerNameError)、手機 ^09\d{8}$、Email 格式且 ≤254、trip 為 oneway|round、票數 parseTickets、取票場區須在 app_settings.pickup_locations 內,任一不符回 BAD_INPUT。
  • RPC:confirm_order(p_hold_ids, p_emp_id, p_trip_type, p_tickets, p_name, p_phone, p_email, p_id_number, p_pickup_location, p_id_type);行程與座位以資料庫中的保留內容為準。
  • 成功:{ success:true, data:{ order_no, seat_status, total_price, ... } },寫 submit_order_success(不含姓名電話等個資)。
  • 失敗:RPC 錯誤 → { success:false, error:<代碼|ORDER_FAILED>, code:<Trace ID> }(submit_order_failed);例外 → error:"server_error"(submit_order_exception,category system)。

3.3 前台認證 (`features/auth/actions.ts`) #

`exchangeHandoffToken(handoffToken: string)` #

  • 驗證並消耗一次性 handoff token(verifyAndConsumeHandoff),成功時簽發 booking_session(kind:"handoff")。
  • 回傳:{ success:true };失敗 { success:false, error:<reason>, traceId? }(reason 如 replayed,重放時寫日誌並帶 Trace ID);例外 error:"server_error"。

`renewBookingSessionAction()` #

  • 有活躍互動時續發 20 分鐘 session。無 session 回 { success:false, error:"expired" }。

`logoutUser()` #

  • 刪除 booking_session 與舊版 site_unlocked cookie,回傳 { success:true }。

`getBookingProfileAction()` #

  • 回傳 { emp_id, name, email } 供訂購人預設資料;無 session 回 null。密碼登入時以 DEV_EMP_ID 等測試值補齊。

`verifyAccessPassword(password: string)` #

  • 測試機共用密碼登入。僅 stage 分支(建置時的 NEXT_PUBLIC_GIT_BRANCH)或本機 next dev 才開放,其餘一律停用;伺服器端另檢查執行期 VERCEL_ENV,production 一律停用(stage build 被 Promote 到正式站也不會開放)。
  • 同 IP 失敗 5 次鎖 15 分鐘(存於 admin_login_attempts,資料庫異常時拒絕登入);密碼來自 SITE_ACCESS_PASSWORD(未設定即停用),以 timing-safe 比對。
  • 成功簽發 booking_session(kind:"password",員編 DEV_EMP_ID)。失敗寫 site_password_login_failed(只記 IP/UA)。回傳 { success:boolean }。

3.4 後台 #

3.4.1 登入與 Session (`features/admin/actions.ts`) #

  • loginAction(account, pwd):帳號須符合 ^[A-Za-z0-9_.-]{3,40}$(不符直接回錯、不寫日誌)。先以 RPC admin_login_attempt_begin 原子預約一次嘗試(同帳號 + IP 失敗 5 次鎖 15 分鐘;DB 異常 fail-closed)。ENV 帳號明碼比對(super_admin 另檢查 IP 白名單),DB 帳號 scrypt 驗證且須 active。成功簽發 admin_session、revalidatePath("/admin","layout"),回傳 { success:true, role, mustChangePassword };失敗回 { success:false, error:"帳號或密碼錯誤" | "登入失敗次數過多,請於 N 分鐘後再試" | "系統暫時無法登入,請稍後再試" }。
  • changeOwnPasswordAction(current, next):requireAdmin("any", { allowMustChange:true })。ENV 帳號不可改;檢查密碼政策、新舊不同、目前密碼正確。更新雜湊、清除 must_change_password、session_version + 1(其他裝置失效)並換發 token。
  • getSessionAction():回傳 { role }(未登入為 undefined)。
  • logoutAction():寫 admin_logout、刪除 admin_session。

3.4.2 車次 / 設定 / 票價(`admin` 以上) #

所有成功寫入後皆 revalidateTag(...) + revalidatePath("/", "layout");RPC 錯誤以 { success:false, error:error.message } 回傳。

  • releaseExpiredHoldsAdminAction()(any):執行 _release_expired_holds。
  • getTrainAllocationsAction(ids)(admin):最多 500 班。RPC admin_train_allocations,回傳 { [train_id]: { confirmed, waitlisted } }(有效訂單中預訂成功 / 候補人數;沒有訂單的車次不在結果內)。班次管理「實際分配」欄使用。
  • batchTrainAction(ids, active|null, total|null):total 須為 ≥0 整數,且不得小於任一車次已售數(列出前 5 班)。RPC admin_batch_train,回傳 data: 異動筆數;revalidateTag("trains")。
  • updateTrainAction(id, active|null, total|null):兩者皆 null 回「未指定更新項目」;總席位不可少於已售。RPC admin_update_train;revalidateTag("trains")。
  • updateSettingAction(key, value):key 限 booking_start、booking_end、global_discount(0.1~1)、stations(≥2 個有效站)、pickup_locations(非空字串陣列)。日期須帶時區且開放 < 截止。RPC admin_update_setting;revalidateTag("settings")。
  • saveBookingWindowAction(start, end):起訖同一交易寫入(RPC admin_save_booking_window;RPC 不存在時降級為 app_settings upsert)。
  • saveDiscountAction / saveStationsAction:包裝 updateSettingAction。
  • saveFareAction(from, to, adult, conc):覆寫票價為 null(清除)或 1~9999 整數,優待票不可高於全票。RPC admin_set_fare;revalidateTag("fares")。

3.4.3 訂單 / 釋出池(`any`,含 staff) #

  • getOrdersAction():rpcFetchAll("admin_get_orders") 全量。
  • getOrdersPageAction(from = 0, batchSize = 1000):分批讀取(每批 1~1000),回傳 data:{ rows, nextFrom, done }。
  • updateOrderAction(orderNo, status, note, paid, pickupLocation?, changed?, base?):status 須為可編輯處理進度(已作廢只能走作廢流程);已作廢訂單不可改。傳入 changed 時只寫入變更欄位;再傳 base 時做欄位層級樂觀鎖,衝突回 { success:false, code:"CONFLICT", error, data:<目前值> }。RPC admin_update_order,成功回傳寫入後的值。
  • updateOrderPickupLocationAction(orderNo, pickupLocation):RPC admin_update_order_pickup_location。
  • adjustOrderAction(orderNo, tickets):parseTickets 清洗;已作廢或已送 ERP 的訂單不可調整。RPC admin_adjust_order(p_order_no, p_tickets, p_operator);DB 錯誤對應 NO_INCREASE、MIN_ONE、「票數與票種未變更」、「找不到成立中的訂單」、「票數格式不正確」、「查無對應區間票價設定」。
  • cancelOrderAction(orderNo):已送 ERP 不可作廢。RPC cancel_order(p_order_no, p_operator);結果為 NOT_FOUND_OR_ALREADY_CANCELLED 時回錯。成功席位釋出至釋出池(data.seats_released)。
  • getReleasedSeatsAction():rpcFetchAll("admin_get_released_seats")。

3.4.4 管理者帳號 (`features/admin/admins/actions.ts`,`super_admin`) #

ENV 帳號僅列出不可修改;回傳不含 password_hash;改角色 / 重設密碼 / 停用皆 session_version + 1 使既有 session 失效;日誌含 before/after 與 IP/UA。

  • getAdminUsersAction():ENV + DB 帳號,附 source、locked。
  • createAdminUserAction({ account, password, role }):帳號格式、不可與 ENV 同名、角色限 admin|staff、密碼政策;新帳號 must_change_password = true;重複回「此帳號已存在」。
  • updateAdminRoleAction(id, role)、setAdminUserStatusAction(id, "active"|"disabled"):值未變直接回成功。
  • resetAdminPasswordAction(id):產生一次性密碼(僅此次回傳 data.password),下次登入須改密,並解除登入鎖定。
  • unlockAdminUserAction(account):刪除 admin_login_attempts 中該帳號所有 IP 的紀錄。

3.4.5 系統日誌 (`features/admin/logs/actions.ts`,`super_admin`) #

一般查詢、換頁、自動刷新不寫日誌。

  • getSystemLogsAction(filter):區間 today|3d|7d|30d、頁大小 20/50;Trace ID / 訂單號精確查詢不受區間限制;可依 level、category、模組篩選。回傳 { rows, total }(列表不含 details)。
  • getSystemLogModuleCountsAction(range):RPC admin_log_action_counts(p_from),依模組彙總筆數與錯誤數。
  • getSystemLogDetailAction(id, reveal = false):預設遮蔽 details 中的個資欄位;reveal = true 且含個資時寫 admin_reveal_pii。回傳含 hasPII。

4. 共用錯誤代碼 #

代碼 來源 意義 前台訊息(features/booking/store/utils.ts)
UNAUTHORIZED AUTH_EXPIRED_CODE(features/auth/authConstants.ts) 未登入或 session 逾期,前端觸發登出(thsr:auth:expired) 登入已逾期,請重新登入
FORBIDDEN FORBIDDEN_CODE 已登入但角色不足或須先改密碼(不觸發登出) 權限不足,無法執行此操作 / 請先變更密碼後再操作
SOLD_OUT create_hold / confirm_order 席位不足或車次已下架 保留:剩餘席位不足,已為您更新最新席位,請重新選擇。送單:您選擇的班次席位不足,請重新選擇班次。
NOT_OPEN DB 尚未到預訂開放時間 預訂尚未開放,開放時間:{range}。/暫時無法送出訂單。
CLOSED DB 預訂期間已截止 預訂期間已截止。/無法送出訂單。
BAD_SEATS DB 張數超出 1..max_tickets 每筆訂單票數超出允許範圍,請調整張數…
BAD_TICKETS DB 票種張數與保留席位不一致 票種張數與保留席位不一致,請重新確認票種張數。
BAD_INPUT Action / DB 行程、聯絡資料或 hold id 不合法 保留:選擇的班次資料有誤,請重新查詢。送單:訂單資料有誤,請重新選擇班次後再送出。
BAD_ID Action / DB 證件號碼格式不符 證件號碼格式不正確,請確認證件類別與號碼。
HOLD_EXPIRED confirm_order 保留已逾時或已被同工號其他分頁取代 不走 ORDER_MSG,改顯示 HoldLostDialog:倒數剩 5 秒以上為「此次選位已失效(可能已在其他分頁重新選位),請重新選擇班次。」,否則「席位保留已逾時,請重新選擇班次。」(features/booking/store/orderSlice.ts)
HOLD_FAILED createHoldAction fallback 保留時非預期錯誤 通用訊息 + 錯誤編號
ORDER_FAILED submitOrderAction fallback 送單時非預期錯誤 訂單送出失敗,請稍後再試。(錯誤編號:…)
server_error Action 例外 系統例外 同上
CONFLICT updateOrderAction 欄位已被他人修改(樂觀鎖) 後台顯示「…已被其他人修改,已載入最新資料,請確認後再儲存」
INVALID_PARAMS / FETCH_ERROR /api/trains、/api/seats 參數錯誤 / 查詢失敗 —

送單失敗訊息由 orderFailMessage(error, traceId) 產生,一律附上「錯誤編號:{Trace ID}」(有的話)。


5. 主要 Postgres RPC #

定義見 supabase/setup_final.sql。

RPC 說明
create_hold 檢查開放期間 / 張數 / 上架狀態後扣席並建立保留(含候補判定)
release_hold 釋放指定員工的保留並歸還席位
_release_expired_holds 清理逾期保留、歸還席位
confirm_order 將保留轉為訂單,依保留內容計價並寫入 orders
cancel_order 作廢訂單,成功段席位移入釋出池
admin_get_orders 後台讀取訂單(分頁)
admin_get_released_seats 後台讀取釋出池
admin_update_order 更新處理進度 / 備註 / 收款 / 取票場區
admin_update_order_pickup_location 單獨更新取票場區
admin_adjust_order 減少訂單張數 / 調整票種並重算金額
admin_train_allocations 每班實際已分配(預訂成功)/ 候補人數,依有效訂單計算
admin_batch_train 批次上下架 / 設定總席位
admin_update_train 單一車次上下架 / 總席位
admin_update_setting 更新 app_settings 單一鍵值
admin_save_booking_window 單一交易更新預訂起訖時間
admin_set_fare 設定 / 清除覆寫票價
admin_login_attempt_begin 後台登入嘗試原子預約與鎖定判斷
admin_log_action_counts 依 action / level 統計日誌筆數