feat(卡片): 新增卡片发行警告提示功能
将版本号更新至v1.5.29。新增cardIssueWarning状态变量以管理卡片发行过程中的警告信息,在重置票务和卡片流程时同步重置该状态。在卡片发行的各逻辑分支中设置对应警告文案,优化完成界面的展示逻辑以显示警告信息并调整提示语,同时在卡片发行快照中新增对应存储字段。
This commit is contained in:
+21
-5
@@ -1,6 +1,6 @@
|
|||||||
local CURRENT_STATION_CODE = 'Ticket-Machine'
|
local CURRENT_STATION_CODE = 'Ticket-Machine'
|
||||||
local API_BASE = 'https://ticket.fse-media.group/api'
|
local API_BASE = 'https://ticket.fse-media.group/api'
|
||||||
local VERSION = 'v1.5.25'
|
local VERSION = 'v1.5.29'
|
||||||
local UPDATE_CHECK_INTERVAL = 5
|
local UPDATE_CHECK_INTERVAL = 5
|
||||||
|
|
||||||
-- ###########################
|
-- ###########################
|
||||||
@@ -1181,7 +1181,7 @@ state = {
|
|||||||
departure = nil, terminal = nil, trainType = nil, trips = 1, cost = 0, paid = 0, doneAudioPlayed = false,
|
departure = nil, terminal = nil, trainType = nil, trips = 1, cost = 0, paid = 0, doneAudioPlayed = false,
|
||||||
productMode = 'ticket', cardMode = nil, cardPaymentMode = 'local',
|
productMode = 'ticket', cardMode = nil, cardPaymentMode = 'local',
|
||||||
holderName = '', cardDeposit = 0, cardTopup = 0, cardBalance = 0, cardOrderValue = 0,
|
holderName = '', cardDeposit = 0, cardTopup = 0, cardBalance = 0, cardOrderValue = 0,
|
||||||
card_id = nil, card_server_data = nil, pendingBlankCardId = nil
|
card_id = nil, card_server_data = nil, pendingBlankCardId = nil, cardIssueWarning = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
local function getCardConfig()
|
local function getCardConfig()
|
||||||
@@ -1216,6 +1216,7 @@ local function resetTicketFlow()
|
|||||||
state.card_id = nil
|
state.card_id = nil
|
||||||
state.card_server_data = nil
|
state.card_server_data = nil
|
||||||
state.pendingBlankCardId = nil
|
state.pendingBlankCardId = nil
|
||||||
|
state.cardIssueWarning = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function resetCardFlow(mode)
|
local function resetCardFlow(mode)
|
||||||
@@ -1235,6 +1236,7 @@ local function resetCardFlow(mode)
|
|||||||
state.card_id = nil
|
state.card_id = nil
|
||||||
state.card_server_data = nil
|
state.card_server_data = nil
|
||||||
state.pendingBlankCardId = nil
|
state.pendingBlankCardId = nil
|
||||||
|
state.cardIssueWarning = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local function isCardOrderLike(data)
|
local function isCardOrderLike(data)
|
||||||
@@ -2256,6 +2258,7 @@ local function showOrderAndAudio()
|
|||||||
end
|
end
|
||||||
if okIssueBlank and #blankCardId > 0 then
|
if okIssueBlank and #blankCardId > 0 then
|
||||||
payload.card_id = blankCardId
|
payload.card_id = blankCardId
|
||||||
|
state.card_id = blankCardId
|
||||||
state.pendingBlankCardId = blankCardId
|
state.pendingBlankCardId = blankCardId
|
||||||
local okReq, code, parsed, err = submitCardOpen(payload)
|
local okReq, code, parsed, err = submitCardOpen(payload)
|
||||||
if okReq then
|
if okReq then
|
||||||
@@ -2267,11 +2270,15 @@ local function showOrderAndAudio()
|
|||||||
state.cardBalance = tonumber(writtenCard.balance) or finalCard.balance
|
state.cardBalance = tonumber(writtenCard.balance) or finalCard.balance
|
||||||
state.card_server_data = respData
|
state.card_server_data = respData
|
||||||
state.pendingBlankCardId = nil
|
state.pendingBlankCardId = nil
|
||||||
|
state.cardIssueWarning = nil
|
||||||
confirmed = true
|
confirmed = true
|
||||||
statusMsg, statusCol = 'Card ready', colors.green
|
statusMsg, statusCol = 'Card ready', colors.green
|
||||||
if not state.doneAudioPlayed then playConfirmTicketMelody(); state.doneAudioPlayed = true end
|
if not state.doneAudioPlayed then playConfirmTicketMelody(); state.doneAudioPlayed = true end
|
||||||
else
|
else
|
||||||
statusMsg, statusCol = 'Write failed: ' .. tostring(writeMethod), colors.red
|
state.card_server_data = respData
|
||||||
|
state.cardIssueWarning = 'Write pending: ' .. tostring(writeMethod)
|
||||||
|
confirmed = true
|
||||||
|
statusMsg, statusCol = 'Card issued, write pending', colors.red
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
local errorMsg = 'Card API Err'
|
local errorMsg = 'Card API Err'
|
||||||
@@ -2282,9 +2289,14 @@ local function showOrderAndAudio()
|
|||||||
elseif code and type(code) == 'number' then
|
elseif code and type(code) == 'number' then
|
||||||
errorMsg = 'HTTP ' .. tostring(code)
|
errorMsg = 'HTTP ' .. tostring(code)
|
||||||
end
|
end
|
||||||
statusMsg, statusCol = 'Issued, retry sync: ' .. errorMsg, colors.red
|
state.cardIssueWarning = 'Sync pending: ' .. errorMsg
|
||||||
|
confirmed = true
|
||||||
|
statusMsg, statusCol = 'Card issued, sync pending', colors.red
|
||||||
end
|
end
|
||||||
elseif okIssueBlank then
|
elseif okIssueBlank then
|
||||||
|
state.card_id = payload.card_id
|
||||||
|
state.cardIssueWarning = 'Issued without readable ID'
|
||||||
|
confirmed = true
|
||||||
statusMsg, statusCol = 'Card issued without ID', colors.red
|
statusMsg, statusCol = 'Card issued without ID', colors.red
|
||||||
else
|
else
|
||||||
local okReq, code, parsed, err = submitCardOpen(payload)
|
local okReq, code, parsed, err = submitCardOpen(payload)
|
||||||
@@ -2297,6 +2309,7 @@ local function showOrderAndAudio()
|
|||||||
state.cardBalance = tonumber(writtenCard.balance) or finalCard.balance
|
state.cardBalance = tonumber(writtenCard.balance) or finalCard.balance
|
||||||
state.card_server_data = respData
|
state.card_server_data = respData
|
||||||
state.pendingBlankCardId = nil
|
state.pendingBlankCardId = nil
|
||||||
|
state.cardIssueWarning = nil
|
||||||
confirmed = true
|
confirmed = true
|
||||||
statusMsg, statusCol = 'Card ready', colors.green
|
statusMsg, statusCol = 'Card ready', colors.green
|
||||||
if not state.doneAudioPlayed then playConfirmTicketMelody(); state.doneAudioPlayed = true end
|
if not state.doneAudioPlayed then playConfirmTicketMelody(); state.doneAudioPlayed = true end
|
||||||
@@ -2429,7 +2442,8 @@ end
|
|||||||
|
|
||||||
local function showDone()
|
local function showDone()
|
||||||
if state.productMode == 'card' then
|
if state.productMode == 'card' then
|
||||||
drawHeader('Card Ready', 'Please take your IC card')
|
local warning = firstString(state.cardIssueWarning)
|
||||||
|
drawHeader(warning ~= '' and 'Card Issued' or 'Card Ready', warning ~= '' and 'Please check issue status' or 'Please take your IC card')
|
||||||
local y = 5
|
local y = 5
|
||||||
local function line(label, value, col)
|
local function line(label, value, col)
|
||||||
termDev.setTextColor(colors.white)
|
termDev.setTextColor(colors.white)
|
||||||
@@ -2444,6 +2458,7 @@ local function showDone()
|
|||||||
line('Balance', tonumber(state.cardBalance) or 0, colors.green)
|
line('Balance', tonumber(state.cardBalance) or 0, colors.green)
|
||||||
line('Card ID', firstString(state.card_id, 'PENDING'), colors.cyan)
|
line('Card ID', firstString(state.card_id, 'PENDING'), colors.cyan)
|
||||||
if state.voucher_code then line('Voucher', state.voucher_code, colors.cyan) end
|
if state.voucher_code then line('Voucher', state.voucher_code, colors.cyan) end
|
||||||
|
if warning ~= '' then line('Status', warning, colors.red) end
|
||||||
saveCardIssueSnapshot({
|
saveCardIssueSnapshot({
|
||||||
card_id = state.card_id,
|
card_id = state.card_id,
|
||||||
holder_name = state.holderName,
|
holder_name = state.holderName,
|
||||||
@@ -2451,6 +2466,7 @@ local function showDone()
|
|||||||
topup = state.cardTopup,
|
topup = state.cardTopup,
|
||||||
balance = state.cardBalance,
|
balance = state.cardBalance,
|
||||||
voucher_code = state.voucher_code,
|
voucher_code = state.voucher_code,
|
||||||
|
issue_warning = warning,
|
||||||
station_code = state.stationCode or CURRENT_STATION_CODE,
|
station_code = state.stationCode or CURRENT_STATION_CODE,
|
||||||
ts = (os.epoch and os.epoch('utc')) or (os.time() * 1000)
|
ts = (os.epoch and os.epoch('utc')) or (os.time() * 1000)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user