diff --git a/gate.lua b/gate.lua index 74131d6..507baa4 100644 --- a/gate.lua +++ b/gate.lua @@ -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.23" +local VERSION = "v1.5.24" local VERSION_CHECK_INTERVAL = 5 local serverURL = nil @@ -1010,6 +1010,24 @@ local function updateICCardField(dev, key, value) return true end +local function updateICCardFieldWithFallback(dev, keys, value) + if type(keys) == "string" then + return updateICCardField(dev, keys, value) + end + local firstErr = nil + if type(keys) ~= "table" then return false, "invalid_keys" end + for _, key in ipairs(keys) do + local okField, errField = updateICCardField(dev, key, value) + if okField then + return true, key + end + if not firstErr then + firstErr = tostring(key) .. ": " .. tostring(errField or "update_failed") + end + end + return false, firstErr or "update_failed" +end + local function updateICCardFields(dev, patch) local allOk = true local firstErr = nil @@ -1157,9 +1175,11 @@ local function handleICCardScan(scan, side, scanDev) local okWrite = true local writeErr = nil for _, dev in ipairs(inspectionDevs) do - local okPatch, errPatch = updateICCardFields(dev, { - entry = exitStation, - }) + local okPatch, errPatch = updateICCardFieldWithFallback(dev, { + "entry_station", + "entry", + "start_station" + }, exitStation) okWrite = okPatch and okWrite if not okPatch and not writeErr then writeErr = errPatch end end @@ -1203,7 +1223,11 @@ local function handleICCardScan(scan, side, scanDev) local okDeduct, newBalanceOrErr = deductICCardBalance(dev, fare) if okDeduct then balance = toMoney(newBalanceOrErr or (balance - fare)) or 0 - local okClear, clearErr = updateICCardField(dev, "entry", nil) + local okClear, clearErr = updateICCardFieldWithFallback(dev, { + "entry_station", + "entry", + "start_station" + }, nil) local okFare, fareErr = updateICCardField(dev, "last_fare", fare) if not okClear or not okFare then okWrite = false diff --git a/install_ticketmachine.lua b/install_ticketmachine.lua index 0012259..12f3541 100644 --- a/install_ticketmachine.lua +++ b/install_ticketmachine.lua @@ -1,11 +1,4 @@ ---[[ -Author: HenryDu8133 813367384@qq.com -Date: 2026-06-28 12:58:42 -LastEditors: HenryDu8133 813367384@qq.com -LastEditTime: 2026-07-11 00:02:33 -FilePath: \TicketMachine\install_ticketmachine.lua -Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE ---]] + local URL_MACHINE_HTTP = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/ticketmachine.lua" local URL_UPDATE_MACHINE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/update_machine.lua"