feat(gate): support passing stationId to markEntered API

This commit is contained in:
2026-07-17 00:44:37 +08:00
parent 1f5bc1d40d
commit 77b487c326
+7 -7
View File
@@ -1,7 +1,7 @@
local DEFAULT_SERVER_BASE = "https://ticket.fse-media.group"
local DEFAULT_SERVER_PATH = "/api/tickets/check"
local GATE_OPEN_SECONDS = 2
local VERSION = "v1.5.25"
local VERSION = "v1.5.26"
local VERSION_CHECK_INTERVAL = 5
local serverURL = nil
@@ -972,19 +972,19 @@ local function updateDeviceField(dev, key, value)
pcall(dev.updateTicket, key, value)
end
local function callTicketStateMethod(dev, methodName)
local function callTicketStateMethod(dev, methodName, ...)
if type(dev) ~= "table" then return false end
local fn = dev[methodName]
if type(fn) ~= "function" then return false end
local okCall, okRes = pcall(fn)
local okCall, okRes = pcall(fn, ...)
if not okCall then return false end
return okRes ~= false
end
local function applyTicketDeviceState(dev, action, rides)
local function applyTicketDeviceState(dev, action, rides, stationCode)
if type(dev) ~= "table" then return end
if action == "entry" then
if not callTicketStateMethod(dev, "markEntered") then
if not callTicketStateMethod(dev, "markEntered", stationCode) then
updateDeviceField(dev, "entered", true)
updateDeviceField(dev, "exited", false)
end
@@ -1256,7 +1256,7 @@ local function handleICCardScan(scan, side, scanDev)
end
for _, dev in ipairs(inspectionDevs) do
applyTicketDeviceState(dev, usedAction)
applyTicketDeviceState(dev, usedAction, nil, exitStation)
if usedAction == "entry" then
if #entryStation > 0 then updateDeviceField(dev, "entry_station", entryStation) end
else
@@ -1369,7 +1369,7 @@ local function handleScan(scan, side, scanDev)
or tonumber(scan.trips_remaining or scan.rides_remaining)
or tonumber(scan.rides)
for _, dev in ipairs(inspectionDevs) do
applyTicketDeviceState(dev, usedAction, newRides)
applyTicketDeviceState(dev, usedAction, newRides, stationCodeForSide(side))
end
end)