Data control method and system for IC card
Patent Information
- Application Number
- CN202611517107.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-29
- Publication Date
- 2026-10-30
AI Technical Summary
[0007]因此,本申请提供了一种IC卡的数据控制方法及系统,能够解决IC卡分段写入被拔卡中断后余额区域已写入而流水区域未写入时重新办理造成重复扣款的问题
本申请提供了一种IC卡的数据控制方法及系统,本申请在写入指令发出前留存写前快照,写入中断后重新读取余额当前值与流水号当前值并与写前快照比对,能够识别余额区域已写入而流水区域未写入的部分写入状态,在部分写入状态下仅向流水区域补充写入缴费流水记录,不再向余额区域写入,避免了重新办理缴费业务时以已扣减余额为基础再次扣款,防止患者被重复扣款,缴费流水记录补写完成后卡内余额数据与流水数据前后一致,患者持卡前往后续环节刷卡核查时不再出现卡内数据不一致而被拦下的情形,结算系统的业务记录与卡内数据对应,后台对账时能够核销本笔缴费业务,缴费悬账不再产生,收费窗口重复办理与反复核查的次数减少,排队等待时间缩短。
Smart Images

Figure CN123015013A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data control method and system for IC cards. Background Technology
[0002] During routine payments at hospital payment windows, after collecting cash, the cashier needs to write the deduction result and payment record back to the patient's IC card. The IC card is divided into a balance area (for storing the remaining balance) and a transaction area (for storing payment records). After the settlement system sends a write command to the IC card, it waits for the card reader to return a write completion receipt. Receiving the receipt indicates a successful write; not receiving it indicates a write failure and prompts the cashier to re-process the transaction. The write operation is performed in segments, first writing to the balance area and then to the transaction area. Due to the high volume of people at the payment window, patients are often in a hurry to leave after completing their examinations or rushing to finish. While the write is in progress, patients see the screen refresh the amount and assume the payment is complete, then immediately remove the IC card. The card reader contacts separate from the IC card's metal contacts, interrupting the write process and preventing the return of the write completion receipt.
[0003] The settlement system records this transaction as a failure pending reprocessing based on a single point of judgment based on whether a receipt has been received. However, the balance area in the IC card has already been written with the deducted value, but the transaction record area still does not have any record of this payment. The balance data in the card and the transaction data are inconsistent. When the cashier swipes the card again, the balance shows that the payment has been deducted, but the transaction record shows that no payment has been made, making it impossible to determine whether this payment has been completed.
[0004] When the cashier reprocessed the payment according to the "failed and pending reprocessing" prompt, the system incorrectly recorded the deduction based on the already deducted balance on the card, resulting in the patient being charged twice. When the cashier chose not to reprocess, the patient, carrying the IC card with the changed balance and missing transaction history, proceeded to the next step. The subsequent card verification revealed inconsistencies in the card data, forcing the patient to return to the window for repeated checks. During the reconciliation process, the settlement system recorded this transaction as "failed and pending reprocessing," indicating that the card balance had already been deducted, but there was no payment record on the card. The backend records and card data did not match, making this payment a long-term unresolved outstanding payment. This led to continuously lengthening queues at the payment window, causing patients to make numerous trips back and forth, and significantly reducing payment efficiency.
[0005] Existing technologies lack methods to determine the new and old states of each data area in the card after a write interruption, lack methods to identify the actual write state in the card after an interruption, and lack methods to supplement missing transaction records when the card balance has already been deducted. As a result, the problems of duplicate deductions and outstanding payments caused by write interruptions have remained unresolved in payment window scenarios for a long time. Summary of the Invention
[0006] In view of the aforementioned problems, this application is hereby filed.
[0007] Therefore, this application provides a data control method and system for IC cards, which can solve the problem of duplicate deductions caused when the balance area is written but the transaction area is not written after the IC card segment writing is interrupted by card removal.
[0008] To solve the above-mentioned technical problems, this application provides the following technical solution: Firstly, this application provides a data control method for an IC card, including: Obtain the payment amount, read the old balance value from the balance area of the IC card, read the last serial number from the transaction area of the IC card, and generate a pre-write snapshot containing the card number, the old balance value, and the last serial number; The balance area is the data area in the IC card that stores the balance value, and the transaction area is the data area in the IC card that stores the payment transaction records; Send a write command to the IC card and execute the write operation in the order of writing to the balance area first and then to the transaction history area; In response to a write interruption and the IC card being reinserted into the card reader, the current balance value and the current serial number value are read, the current balance value is compared with the old balance value, and the current serial number value is compared with the last serial number to determine the write status identifier; The IC card is written according to the write status identifier. When the write status identifier is a partial write identifier, only the payment record is written to the transaction area, and no record is written to the balance area.
[0009] Preferably, the step of obtaining the payment amount involves reading the old balance from the balance area of the IC card, reading the last transaction number from the transaction history area of the IC card, and generating a pre-write snapshot containing the card number, the old balance, and the last transaction number, including: Read the card number, the old balance, and the last serial number from the IC card; Determine whether the card number, the old balance, and the last transaction number have been read completely, and determine whether the old balance meets the payment conditions for paying the payment amount; In response to the complete reading and satisfaction of the payment conditions, the card number, the old balance value, and the last transaction number are associated with the payment amount, and the pre-write snapshot is generated. In response to an incomplete read, a re-insertion prompt is sent to the charging terminal screen, and the read is re-executed based on the re-inserted IC card until the read is complete, after which the pre-write snapshot is generated.
[0010] Preferably, the step of comparing the current value of the balance with the old value of the balance and comparing the current value of the serial number with the last serial number to determine the write status identifier includes: In response to the fact that the deduction amount of the current balance value relative to the old balance value is equal to the payment amount, and the current value of the serial number is equal to the last serial number, the write status identifier is determined to be a partial write identifier; In response to the current value of the balance being equal to the old value of the balance and the current value of the serial number being equal to the last serial number, the write status identifier is determined to be an unwritten identifier; In response to the current value of the balance being equal to the old value of the balance, and the current value of the serial number being the next serial number after the last serial number, the write status identifier is determined to be a completed identifier.
[0011] Preferably, the step of performing the write process on the IC card according to the write status identifier, wherein when the write status identifier is a partial write identifier, only the payment transaction record is written to the transaction area, includes: Generate a pre-generated transaction record containing the payment amount and a transaction number identifying this payment transaction. The transaction number of the pre-generated transaction record is the next transaction number after the last transaction number. Before writing, read the first verification serial number from the serial area; In response to the first verification serial number being equal to the last serial number, the pre-generated serial record is written to the serial area, but not to the balance area; In response to the first verification serial number not being equal to the last serial number, no writing is performed to the serial number area, and a manual verification prompt is generated and sent to the toll terminal screen.
[0012] Preferably, the step of reading the current balance value and the current serial number value in response to a write interrupt and the IC card being reinserted into the card reader includes: During the writing process in the prescribed writing order, a contact disconnection signal between the card reader and the IC card is detected. In response to the detection of the contact disconnection signal, a first prompt is sent to the payment terminal screen and a second prompt is sent to the speaker associated with the card reader. The first prompt is used to indicate that the writing was interrupted and the second prompt is used to indicate that the IC card should be inserted again. In response to the IC card being reinserted into the card reader within a preset waiting time, the current balance value and the current serial number value are read. If the IC card is not reinserted within the preset waiting time, the second prompt is sent again through the speaker, and if the IC card is subsequently reinserted into the card reader, the current balance value and the current serial number value are read.
[0013] Preferably, the step of performing the write process on the IC card according to the write status identifier includes: In response to the write status flag being a write-not flag, a cash processing selection request is sent to the payment terminal screen; The cashier receives a first or second selection response in response to the cash processing selection request. The first selection response indicates that the cash has been received and the payment transaction is being processed again, while the second selection response indicates that the cash is being refunded and the payment transaction is being cancelled. In response to the first selection response, based on the old balance value in the pre-write snapshot, the balance value after deducting the payment amount is written to the balance area, and the payment transaction record is written to the transaction area to complete the writing process; In response to the second selection response, the writing to the IC card is cancelled, a refund voucher is printed, and the writing process is completed.
[0014] Preferably, the method further includes: If the IC card is not reinserted into the card reader within a preset waiting time, a write-out order for this payment transaction is generated and written to the write-out queue. The write-out order includes the card number, the payment amount, the transaction number identifying this payment transaction, and the snapshot taken before writing. In response to the insertion of the IC card into the hospital's card reader terminal, the card number is read through the hospital's card reader terminal, and a card number query request is sent to the settlement system. In response to a query request based on the card number, if a replacement order matching the card number is found in the replacement queue, a replacement confirmation request is sent to the in-hospital card reader terminal, and an immediate replacement response or a later replacement response is received in response to the replacement confirmation request. In response to the immediate write response, the steps of reading the current balance value and the current serial number value and determining the write status identifier are triggered. In response to the later write response, the write-to-be-written form is retained in the write-to-be-written queue.
[0015] Preferably, writing the pre-generated flow record into the flow area includes: After writing is complete, the first readback value is read from the balance area, and the second readback value and readback transaction record are read from the transaction area. Determine whether the deduction amount of the first read value relative to the old value of the balance is equal to the payment amount, determine whether the second read value is the next transaction number after the last transaction number, and determine whether the amount and business order number in the read transaction record are consistent with the pre-generated transaction record; If the judgment results are consistent, a consistency identifier is generated, and the payment transaction is cancelled. In response to the inconsistency in the judgment result, the process of writing the pre-generated transaction record into the transaction area is repeated. If the inconsistency still exists after reaching the preset retry limit, a manual verification prompt is generated and sent to the toll terminal screen.
[0016] Preferably, the method further includes: While the order to be rewritten exists in the order to be rewritten queue, in response to the IC card initiating a new payment settlement at any card reader terminal, a payment lock prompt is sent to the card reader terminal that initiated the new payment settlement. The payment lock prompt is used to prompt the rewriting of the order to be rewritten to be completed first. In response to the completion and cancellation of the supplementary order, the payment lock status corresponding to the payment lock prompt is released, and the new payment settlement is executed. The generation, completion, and cancellation events of the orders to be rewritten are written to the associated log according to time and causal relationship; In response to receiving a reconciliation query request, the system returns a sequence of events from the associated log, arranged by time.
[0017] Secondly, this application also provides a data control system for IC cards, including: The module includes a snapshot generation module, a write execution module, a reread comparison module, and a write processing module. The snapshot generation module is used to obtain the payment amount, read the old balance value from the balance area of the IC card, read the last transaction number from the transaction area of the IC card, and generate a pre-write snapshot containing the card number, the old balance value and the last transaction number. The balance area is the data area in the IC card that stores the balance value, and the transaction area is the data area in the IC card that stores the payment transaction record. The write execution module is used to send write instructions to the IC card and execute the write operation in the order of writing to the balance area first and then writing to the transaction area. The reread comparison module is used to respond to a write interruption and the IC card being reinserted into the card reader, read the current balance value and the current serial number value, compare the current balance value with the old balance value, and compare the current serial number value with the last serial number to determine the write status identifier; The write processing module is used to perform write processing on the IC card according to the write status identifier. When the write status identifier is a partial write identifier, only the payment transaction record is written to the transaction area, and no record is written to the balance area.
[0018] Implementing this application will have the following beneficial effects: This application provides a data control method and system for IC cards. Before issuing a write command, a pre-write snapshot is stored. After a write interruption, the current balance value and transaction number value are reread and compared with the pre-write snapshot. This allows identification of partial write states where the balance area has been written but the transaction area has not. In these partial write states, only the transaction area is supplemented with payment transaction records, and no further writing is done to the balance area. This avoids deducting money again based on the already deducted balance when processing a new payment, preventing patients from being charged repeatedly. After the payment transaction records are supplemented, the card balance data and transaction data are consistent. When patients use their cards for subsequent verification, they are no longer stopped due to inconsistent card data. The settlement system's business records correspond to the card data, and the payment transaction can be cleared during back-end reconciliation. Payment outstandings are eliminated, the number of repeated processing and verifications at the payment window is reduced, and waiting time is shortened. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart of a data control method for an IC card involved in this application; Figure 2 This is a schematic diagram illustrating the logic for determining the data status identifier in the card after a write interruption in a data control method for an IC card, as described in this application. Figure 3 This is a schematic diagram of the process for rewriting and rereading verification of transaction records in a partially written state, which is a data control method for IC cards involved in this application. Figure 4 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0021] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0022] Example 1, referring to Figures 1-3 This is the first embodiment of the present application, which provides a data control method for an IC card, including: This application provides a method that can effectively solve the problems mentioned above. The following will describe in detail how to implement the data control method of the IC card with reference to several embodiments. Figure 1 A flowchart of a data control method for an IC card is shown, including: Step S1: Obtain the payment amount, read the old balance value from the balance area of the IC card, read the last transaction number from the transaction area of the IC card, and generate a pre-write snapshot containing the card number, the old balance value, and the last transaction number; the balance area is the data area in the IC card that stores the balance value, and the transaction area is the data area in the IC card that stores the payment transaction record.
[0023] It should be noted that step S1 occurs before any data is written to the IC card, and the pre-write snapshot generated in step S1 serves as a data benchmark for determining the actual write status of the card after a write interruption. The payment amount originates from the payment window's settlement interface. Specifically, the cashier selects the corresponding payment item on the settlement interface of the payment terminal. The terminal determines the amount of each payment item based on pre-stored fee standard data and sums them up to obtain the payment amount. After verifying that the collected cash amount matches the payment amount, the cashier confirms the payment on the settlement interface. The payment amount is then used as data input for subsequent deductions and comparisons. The fee standard data is a pre-stored list of correspondences between payment items and amounts in the settlement system's memory. Each entry in the list records a payment item name and its corresponding amount.
[0024] Specifically, the IC card is a contact smart card. After the metal plate on the card surface contacts the reader's contacts, the IC card obtains operating power from the contacts and exchanges read and write commands with the reader. The reader, payment terminal screen, payment terminal buttons, and speaker are all existing components of the payment window. The balance area and the transaction record area each occupy a fixed storage location within the IC card. The balance value in the balance area is updated with each payment deduction, and the balance area uses a fixed number of storage bits to store the balance value. The payment transaction records in the transaction record area are arranged sequentially in ascending order of transaction number. Each payment transaction record includes three fields: transaction number, payment amount, and transaction number identifying the payment transaction. Each field occupies a fixed number of storage bits. Since the write operation is performed in segments, first writing to the balance area and then writing to the transaction area, a write interruption may occur between the two segments. Therefore, before the write instruction is issued, the old balance value and the last transaction number are stored together in the pre-write snapshot. The pre-write snapshot is stored in the memory of the settlement system and remains unchanged during the write execution and subsequent comparison. It is not deleted when the write instruction is issued. Only after the write interruption can the reread card value be compared with the stored value one by one.
[0025] Furthermore, the card number is an identification number stored in the IC card. The card number is stored in a fixed location within the IC card, independent of the balance area and the transaction history area. The card number remains unchanged when the contents of the balance area and the transaction history area change. Therefore, the card number is suitable as the basis for associating multiple transactions on the same IC card. The data structure of the pre-write snapshot is a data entry containing four fields: card number, old balance, last transaction number, and payment amount. After the entire write process is completed and the transaction is verified, the pre-write snapshot is archived to the historical record along with the transaction number. After archiving, it is no longer used for any comparison. When the transaction is transferred to the pending write queue, the pre-write snapshot continues to exist with the pending write order until the pending write order is verified and archived.
[0026] For example, in the scenario of this application, after the cashier collects cash, the IC card is inserted into the card reader. The card reader reads the card number, the old balance, and the last serial number from a fixed storage location. These three data items, along with the payment amount, are written into a single data entry. A snapshot is generated and stored in the memory before the write operation, and only then is the write command issued.
[0027] In some embodiments, obtaining the payment amount, reading the old balance from the balance area of the IC card, reading the last transaction number from the transaction history area of the IC card, and generating a pre-write snapshot containing the card number, the old balance, and the last transaction number may further include the following steps: S1.1 Read the card number, the old balance, and the last serial number from the IC card; S1.2 Determine whether the card number, the old balance, and the last serial number have been read completely, and determine whether the old balance meets the payment conditions for paying the payment amount; S1.3 In response to the complete reading and the payment conditions being met, associate the card number, the old balance, and the last serial number with the payment amount, and generate the pre-write snapshot; S1.4 In response to the incomplete reading, send a re-insertion prompt to the payment terminal screen, and re-execute the reading according to the re-inserted IC card until the reading is complete and the pre-write snapshot is generated.
[0028] For example, in this embodiment, after cash is collected at the payment window and before the data is written to the IC card, a read command is sent to the IC card via a card reader. The IC card receives working power after the contacts of the card reader come into contact with the metal plate on the card. The old balance value and the last serial number are read out according to the fixed storage locations of the balance area and the transaction area, respectively. At the same time, the card number is read out from the fixed storage location storing the card number. The three data items read out, along with their respective verification data, are returned by the card reader as the original input for generating the pre-write snapshot.
[0029] The method for generating the verification data includes the following steps: the sending end divides the data to be sent into bytes, performs a bitwise XOR operation on each byte to obtain a verification byte, returns the verification byte along with the data, the receiving end performs the same bitwise XOR operation on the returned data to obtain a check byte, compares the check byte with the returned verification byte, and if the two are consistent, it indicates that the data has not been damaged during transmission.
[0030] Specifically, the integrity of the read is determined by the three data items: the returned card number, the old balance, and the last serial number. The determination method includes comparing the verification bytes of each of the three data items with the returned verification bytes, and checking whether the number of bits of the three data items is consistent with the fixed storage number of bits in the balance area, the serial number area, and the card number storage location. When all three data items pass the verification comparison and the number of bits is consistent, the read is determined to be complete. When the verification bytes and verification bytes of any data item are inconsistent or the number of bits is inconsistent with the fixed storage number of bits, the read is determined to be incomplete. Inconsistent number of bits or verification mismatch is usually caused by unstable contact of the contact point. The determination result determines whether the process proceeds to generate the pre-write snapshot or to prompt for re-insertion.
[0031] Furthermore, the payment condition is determined by comparing the old balance with the payment amount. When the old balance is not less than the payment amount, the old balance is deemed to meet the payment condition. When the old balance is less than the payment amount, the payment condition is deemed not met. In this case, the payment terminal screen displays an insufficient balance prompt, and the cashier switches to another payment method to collect the fee. The purpose of the payment condition is to confirm that there is a sufficient balance before the deduction is written, so as to avoid the inability to complete the writing process after issuing the write command in the case of insufficient balance.
[0032] It should be noted that, under the condition that the complete data is read and the payment conditions are met, the method of associating the card number, the old balance value, and the last serial number with the payment amount includes storing the four data items as four fields of a data entry in the memory of the settlement system. The data entry is the pre-write snapshot. The pre-write snapshot keeps its content unchanged before the writing is completed, serving as the source of values for rereading and comparison after the writing is interrupted, and also as the judgment criterion for subsequent cash processing selection.
[0033] In this embodiment, in the case of incomplete reading, the re-insertion prompt sent to the payment terminal screen includes the name of the incomplete data item and instructions to insert the card securely. The re-insertion prompt is displayed on the payment terminal screen and remains displayed. After the IC card is re-inserted securely, the reading is re-executed and the reading integrity judgment is performed again. The above process is repeated until the reading is complete. After the reading is complete, the pre-write snapshot is generated in the aforementioned manner. The re-insertion and re-reading cycle does not write any data to the IC card, avoiding the introduction of new data changes when the reading status is unclear.
[0034] For example, during the actual payment process at the payment window, after receiving 120.50 yuan in cash, the IC card is inserted into the card reader. The card reader reads the card number, the old balance of 500.00 yuan, and the last serial number 00215. All three data items pass the verification and comparison and the number of digits is consistent. A snapshot is then generated and saved before writing. If the IC card is not properly inserted, resulting in missing bits of the old balance value read, the payment terminal screen will display a re-insertion prompt containing the name of the old balance value data item. After the IC card is properly reinserted, it will be read again. After the reading is complete, a snapshot will be generated before writing. The entire reading and snapshot generation process is completed before the write command is issued.
[0035] Step S2: Send a write command to the IC card and execute the write operation in the order of writing to the balance area first and then to the transaction area.
[0036] Understandably, after the pre-write snapshot is generated, the write instruction is assembled. The write instruction includes a balance area write sub-instruction and a transaction area write sub-instruction. The two sub-instructions are organized in a fixed order, with the balance area write sub-instruction placed first and the transaction area write sub-instruction placed second. The write content carried by the balance area write sub-instruction is the balance value after deducting the payment amount from the old balance value. The write content carried by the transaction area write sub-instruction is the payment transaction record for this payment transaction. The transaction number of the payment transaction record is the next transaction number after the last transaction number.
[0037] The writing order is a pre-configured execution order in the settlement system. The configuration is that the sub-instructions for writing the balance area are arranged first, and the sub-instructions for writing the transaction history area are arranged later. The writing order is obtained based on the business order of deducting the balance first and then recording the transaction history in the IC card payment business. When writing is executed, the sub-instructions are sent in sequence according to their arrangement.
[0038] Specifically, during the writing process, the card reader first sends a balance area write sub-instruction to the IC card. This sub-instruction includes the instruction type, target storage location, write data, and verification data. Upon receiving the balance area write sub-instruction, the IC card performs the same verification check as described above. If the verification passes, the balance value in the fixed-digit storage area is updated to the deducted balance value carried by the sub-instruction, and a balance area write completion receipt is returned via the card reader. Then, the card reader... The card reader sends a sub-instruction to the IC card to write the transaction area. After the IC card passes the verification, it appends the payment transaction record to the position after the last transaction record in the transaction area. The card reader then returns a transaction area writing completion receipt. When both writing completion receipts are returned, the entire writing process is complete, the payment transaction is cancelled, and the payment terminal screen displays a payment completion prompt. The card retrieval prompt is enabled after cancellation is complete. At the same time, a payment receipt is printed, showing the transaction number, payment amount, and updated balance value. The significance of the writing order is that if the balance area comes first and the transaction area comes later, and the writing interruption happens to fall between the two segments, the card will retain a state combination where the balance value has been updated but the payment transaction record has not been appended. The reread comparison in step S3 is based on the state combination left by the writing order to determine the interruption position.
[0039] Furthermore, during the period of waiting for the card reader to return the write completion receipt after the write command is issued, the contact connection status between the card reader and the IC card is continuously monitored. When the IC card is removed during the write process, the contact connection status becomes disconnected, and the write completion receipt that has not yet been returned cannot be sent back by the card reader, and the write process is stopped. At this time, the current service is neither directly judged as a write failure and redone as a whole, nor is the write continued when the status is unclear. Instead, the process of rereading and comparing after the write interruption is entered, and the actual value status of the two areas in the card is used as the basis for subsequent judgment.
[0040] For example, in the scenario of this application, when the balance area write completion receipt has been returned and the transaction area write sub-instruction is being executed, the IC card is removed from the card reader, the contact connection state becomes disconnected, the transaction area write completion receipt fails to be sent back, and the card is left with a state where the balance value has been deducted but there is no trace of this payment in the transaction area. This state combination is determined by the writing order and the interruption time, and is the direct physical source for subsequently determining the partial write identifier.
[0041] Step S3: In response to a write interruption and the IC card being reinserted into the card reader, read the current balance value and the current serial number value, compare the current balance value with the old balance value, and compare the current serial number value with the last serial number to determine the write status identifier.
[0042] It should be noted that the triggering conditions for step S3 include the sequential occurrence of two events: a write interruption and the reinsertion of the IC card into the card reader. The write interruption is determined by the detection of a contact disconnection signal during the write execution process and the absence of a write completion receipt. After the IC card is reinserted into the card reader, no write operation is initiated directly. Instead, a reread is performed first. The reread method includes reading the current balance value from the balance area through the card reader and reading the transaction number of the last payment transaction record from the transaction area as the current value of the transaction number. The reread process only reads data without modifying any values in the card. The values obtained from the reread are verified and compared before being entered into subsequent comparisons.
[0043] In this embodiment, the comparison method includes comparing the current balance value with the old balance value retained in the pre-write snapshot, and comparing the current serial number value with the last serial number retained in the pre-write snapshot. The comparison is completed within the settlement system as a numerical comparison action. The write status identifier is stored in the business record of this payment transaction as a status field value, and the value includes three types: partially written, not written, and completed. The business record is passed to the write processing step along with the processing flow.
[0044] Specifically, the correspondence between the combination of the two comparison results and the write status identifier is retrieved through a pre-stored write status correspondence table. This table is stored in the settlement system's memory. Each entry in the table records the correspondence between the balance comparison result, the serial number comparison result, and the write status identifier. The balance comparison result is either the deduction amount equals the payment amount or the current balance equals the old balance. The serial number comparison result is either the current serial number equals the last serial number or the current serial number is the next serial number after the last serial number. The table lookup method involves using the two actual comparison results as query conditions, searching the table for entries that match both query conditions, and reading the write status identifier from the matching entries as the lookup result. This replaces the single-point judgment based solely on the presence or absence of a receipt with a table lookup judgment based on the combination of numerical states in two areas of the card, making the judgment independent of the receipt.
[0045] In this application, the step of comparing the current value of the balance with the old value of the balance and comparing the current value of the serial number with the last serial number to determine the write status identifier may further include the following steps: S3.1, in response to the current balance value being equal to the old balance value and the payment amount being equal to the current transaction number being equal to the last transaction number, the write status identifier is determined to be a partial write identifier; S3.2, in response to the current balance value being equal to the old balance value and the current transaction number being equal to the last transaction number, the write status identifier is determined to be a non-write identifier; S3.3, in response to the current balance value being equal to the old balance value and the payment amount being equal to the current transaction number being equal to the next transaction number after the last transaction number, the write status identifier is determined to be a completed identifier.
[0046] For example, in this embodiment, after rereading to obtain the current value of the balance and the current value of the serial number, the current value of the balance is first subtracted from the old value of the balance in the pre-write snapshot to obtain the deduction amount of the current value of the balance relative to the old value of the balance. The numerical subtraction is completed by conventional subtraction operation. When the subtraction result is a non-negative value, it is compared with the value of the payment amount. Then, the deduction amount is compared with the payment amount. At the same time, the current value of the serial number is compared with the last serial number, and it is determined whether the current value of the serial number is the next serial number immediately following the last serial number in ascending order.
[0047] Wherein, the serial number is a consecutive number arranged in ascending order in the serial area, and the next serial number after the last serial number is a number obtained by incrementing the last serial number by a fixed step size of one.
[0048] Specifically, when the deducted amount equals the payment amount and the current value of the transaction number equals the last transaction number, it indicates that the balance area write sub-instruction has been executed and effective, but the transaction area write sub-instruction has not yet been executed. The write interruption falls exactly between the completion of the balance area write and the start of the transaction area write. The card shows an inconsistent state where the balance has been deducted but the transaction has not been added. At this time, the write status identifier is determined to be a partial write identifier. The partial write identifier is recorded in the business record and transmitted to the write processing step as the triggering basis for only writing data to the transaction area.
[0049] Furthermore, if the current balance value is equal to the old balance value and the current serial number is equal to the last serial number, it indicates that the balance area write sub-instruction has not yet been executed and the write interruption occurred before the balance area write took effect. Both areas in the card remain in the pre-write state. At this time, the write status identifier is determined to be the non-write identifier. The non-write identifier indicates that the data in the card is complete but the payment has not yet occurred, providing a clear status basis for subsequent cash processing selection.
[0050] It is understandable that when the deduction amount equals the payment amount and the current value of the serial number is the next serial number after the last serial number, it indicates that the writing of both the balance area and the serial number area has been executed and effective, and the data in the two areas of the card is consistent. The writing interruption only causes the writing completion receipt to fail to be sent back. At this time, the writing status is determined to be a completed receipt. The completed receipt indicates that the writing has actually been completed, avoiding the mistaken judgment of this payment as a failure and reprocessing in the case of missing receipt. The completed receipt is passed to the writing process and then goes to the branch of not writing but only cancellation.
[0051] Specifically, the judgment conditions of the above three branches are mutually exclusive and complete because the writing order is fixed as the balance area first and then the transaction area. The transaction area write sub-instruction will only be executed after the balance area write sub-instruction has taken effect. Therefore, the possible combinations of numerical states in the card only include three types: balance changed and transaction unchanged, balance unchanged and transaction unchanged, and balance changed and transaction changed. These correspond to the partial write flag, the non-write flag, and the completed flag, respectively. There will be no combination of balance unchanged and transaction changed. The three branches cover all card states that may be generated by the write interruption. The three branches are executed mutually exclusively, and each determination only obtains one write state flag.
[0052] For example, in the scenario of this application, the old value of the balance is 500.00 yuan, the payment amount is 120.50 yuan, and after the IC card is reinserted into the card reader, the current value of the balance obtained by rereading is 379.50 yuan, while the current value of the transaction number is still 00215. The deduction amount of 120.50 yuan is equal to the payment amount and the transaction number has not changed. The combination of the two comparison results falls into the partial write branch, and the write status identifier is determined to be the partial write identifier. The contradictory data that the cashier's screen shows as deducted balance but unpaid transaction number is thus transformed into a clear status judgment result.
[0053] Figure 2 This demonstrates the logic for determining the data status of the card after a write interruption. After rereading the card data, the actual write progress of each data area on the card is accurately identified by comparing the balance deduction amount with the payment amount and combining the update status of the serial number. When the balance has been deducted and the serial number has completed incrementing, the write operation is confirmed to be complete; when the balance has been deducted but the serial number has not changed, it is determined to be a partial write state; when both data remain unchanged, it is confirmed to be an unwritten state. This determination mechanism is independent of the write receipt, effectively avoiding misjudgments caused by missing receipts and providing a reliable status benchmark for subsequent differentiated write operations.
[0054] In some embodiments, the step of reading the current balance value and the current serial number value in response to a write interrupt and the IC card being reinserted into the card reader may further include the following steps: S3.4 During the writing process according to the writing order, a contact disconnection signal between the card reader and the IC card is detected; S3.5 In response to the detection of the contact disconnection signal, a first prompt is sent to the payment terminal screen, and a second prompt is sent to the speaker associated with the card reader. The first prompt is used to indicate that the writing has been interrupted, and the second prompt is used to indicate that the IC card should be reinserted; S3.6 In response to the IC card being reinserted into the card reader within a preset waiting time, the current balance value and the current serial number value are read; S3.7 In response to the IC card not being reinserted within the preset waiting time, the second prompt is sent again through the speaker, and in response to the IC card being reinserted into the card reader thereafter, the current balance value and the current serial number value are read.
[0055] In this application, the detection method of the contact disconnection signal includes continuously detecting the contact level between the contact and the metal plate of the IC card surface through an existing level detection circuit set at the card reader contact throughout the entire writing process according to the writing sequence. The detection method is to sample the output of the level detection circuit according to a preset detection cycle. When a valid level is obtained by sampling, it indicates that the contact connection is normal. When a disconnection level is obtained by sampling, it indicates that the IC card has been removed. The contact disconnection signal is then generated. The contact disconnection signal is also recorded at the time of occurrence, which serves as the basis for subsequent waiting time and the time of generating the write-to-be-rewritten order.
[0056] The preset detection period is obtained by statistically analyzing the response time of level reversal after contact separation. The preferred setting range is 5 milliseconds to 20 milliseconds. In the specific operation of this application, 10 milliseconds is taken as the sampling interval.
[0057] Specifically, after detecting the contact disconnection signal, the first prompt sent to the payment terminal screen indicates that the writing has been interrupted and the payment transaction has not yet been completed, allowing the cashier to verify the collected cash and monitor the card status. The first prompt is displayed on the payment terminal screen and remains on display. At the same time, the second prompt sent to the speaker associated with the card reader indicates that the IC card should be inserted again. This is conveyed to the cardholder through a complete voice broadcast. The reason for sending two prompts simultaneously is that the cashier and the cardholder are located at the payment terminal screen and the card reader, respectively, and a single prompt cannot cover both types of people at the same time.
[0058] Furthermore, after detecting the contact disconnection signal, a timer is started from the moment the contact disconnection signal occurs. The timer is calculated by accumulating the number of samples taken according to the preset detection cycle, multiplying the accumulated count by the sampling interval to obtain the waiting time, comparing the waiting time with the preset waiting time, and when the waiting time does not exceed the preset waiting time and the IC card is detected to be reinserted into the card reader, the current balance value and the current serial number value are read, and the reread comparison process is initiated.
[0059] The preset waiting time is obtained by statistical analysis of historical time intervals from the occurrence of the contact disconnection signal at the payment window to the re-insertion of the IC card into the card reader. The preferred setting range is 10 to 60 seconds. In the specific operation of this application, the passage distance between the payment window and the waiting area is obtained. When the passage distance is short, the preset waiting time is set to 30 seconds, and when the passage distance is long, the preset waiting time is set to 60 seconds.
[0060] For example, if the waiting time exceeds the preset waiting time and the IC card is not detected to be reinserted, the second prompt is sent again through the speaker. The insertion prompt is repeatedly conveyed to the cardholder who may still be in the vicinity of hearing the card in a complete voice broadcast. When the IC card is reinserted into the card reader after the second prompt is sent again, the current balance value and the current serial number value are read, and the rereading comparison process is entered. The resent prompt and the reinsertion detection together constitute a round-trip process of prompting, detection, and prompting again, rather than giving up waiting after a single prompt.
[0061] On the other hand, if no re-insertion is detected after the second prompt is sent again, the payment transaction will be transferred to the process of generating a pending order. The pre-write snapshot retained during the waiting period and the cash receipt status together constitute the data source of the pending order. The prompt and detection results determine whether the process will proceed to reread comparison or to the pending queue. The judgment branch and the prompt interaction drive each other.
[0062] Step S4: Perform a write process on the IC card according to the write status identifier. When the write status identifier is a partial write identifier, only the payment transaction record is written to the transaction area, and no record is written to the balance area.
[0063] It should be noted that step S4 is a general step for selecting the execution path according to the write status identifier. When the write status identifier is a partial write identifier, the process of only writing the payment transaction record to the transaction area is executed. When the write status identifier is a non-write identifier, the process of reprocessing or canceling selected by the cashier is executed. When the write status identifier is a completed identifier, no data is written to the balance area and transaction area of the IC card, and the payment transaction is directly cancelled. The cancellation method is to update the transaction status in the transaction record from pending to completed, and to register the receipt record in the settlement system. The content of the receipt record includes the transaction number, payment amount and write status identifier, which is used to explain the situation where the write completion receipt is missing but the write is actually completed in the card during reconciliation. The payment terminal screen displays a prompt that the payment has been completed and no reprocessing is required. The three branches are executed mutually exclusively. Each write process only enters one branch. Different identifiers correspond to different write objects and write content. The write process no longer adopts the method of overall redo.
[0064] Specifically, under the partial write flag, the card balance is already the value after deducting the payment amount, while the transaction record area lacks the payment record for this payment. In this case, only the payment record is written to the transaction record area and not to the balance area, so that the data in the two areas of the card is restored to be consistent before and after. At the same time, it avoids deducting again based on the already deducted balance value. The verification of the transaction record area before the write and the readback verification after the write are carried out in subsequent steps, which together form a write closed loop in the partial write state.
[0065] Furthermore, under the "not written" flag, both areas of the card remain in the pre-write state. Cash has been received but no deduction has occurred from the card. The cashier can choose one of the two processing methods and then perform the corresponding write or cancel action. The selection and execution will be carried out in subsequent steps. Under the "completed" flag, the data in both areas of the card has been updated. Any further writing is redundant. Only the cancellation and supplementary registration need to be completed to close the transaction. The three processing methods together cover all card states that may remain due to the write interruption.
[0066] It is understandable that step S4 uses the write status identifier as the sole basis for branching. The write status identifier comes from the lookup result of step S3. Branch selection no longer depends on the write completion receipt. The case where the receipt is missing but the write is actually completed is correctly handled by the completed branch. The case where the receipt is missing but the write has not occurred is correctly handled by the non-written branch. The case where the receipt is missing but the write is half completed is correctly handled by the partially written branch. A closed loop relationship of sequential dependency is formed between write processing and reread comparison.
[0067] In this embodiment of the application, the step of performing writing processing on the IC card according to the writing status identifier, wherein when the writing status identifier is a partial writing identifier, only the payment transaction record is written to the transaction area, may further include the following steps: S4.1 Generate a pre-generated transaction record containing the payment amount and a transaction number identifying this payment transaction, wherein the transaction number of the pre-generated transaction record is the next transaction number after the last transaction number; S4.2 Read the first verification transaction number from the transaction area before writing; S4.3 In response to the first verification transaction number being equal to the last transaction number, write the pre-generated transaction record into the transaction area, without writing to the balance area; S4.4 In response to the first verification transaction number not being equal to the last transaction number, do not write to the transaction area, generate a manual verification prompt and send it to the payment terminal screen.
[0068] In this embodiment, the pre-generated transaction record is generated after the write status identifier is determined to be the partial write identifier and before writing to the transaction area. The pre-generated transaction record consists of a transaction number, a payment amount, and a transaction order number. The transaction number is the next transaction number in ascending order of the last transaction number, the payment amount is the payment amount of this payment transaction, and the transaction order number is the number that identifies this payment transaction. The pre-generated transaction record is stored in the memory of the settlement system and remains unchanged until the writing is completed, serving as a comparison benchmark for readback verification after writing.
[0069] Specifically, the first verification serial number is read before the rewrite action is sent to the serial area. The reading method is to read the serial number of the last payment record in the serial area in real time through the card reader. The function of the first verification serial number is to confirm that the payment record does not yet exist in the card. There is a time interval between the reread comparison and the rewrite execution. During the time interval, the IC card may be reinserted or operated on other card readers. The first verification serial number read in real time reflects the true state of the serial area in the card at the time of rewrite, making the rewrite a conditionally triggered action rather than an unconditional action.
[0070] Furthermore, if the first verification serial number is equal to the last serial number, it indicates that the transaction area in the card is still in a partially written state at the time of the rewrite. The pre-generated transaction record is written into the transaction area. The rewrite is completed by sending a transaction area write sub-instruction to the IC card through the card reader. The target storage location of the sub-instruction is the write position after the last transaction record. The written data is the three fields of the pre-generated transaction record. During the writing process, the value of the balance area remains unchanged after the deduction at the time of interruption. No data is written to the balance area, and no deduction is performed again. After the rewrite is completed, the balance value in the card corresponds to the payment transaction record before and after restoration.
[0071] Specifically, if the first verification serial number is not equal to the last serial number, it indicates that the transaction area in the card has changed after rereading and comparison or that there is a deviation in the status judgment. In this case, no writing is performed to the transaction area to avoid superimposing new writing on the card data with an unclear status. The generated manual verification prompt includes the card number, the first verification serial number, and the last serial number. After the manual verification prompt is sent to the payment terminal screen, the cashier checks the card transaction data with the cash already collected. The cashier's processing result after verification is recorded in the business record. Automatic writing will not be performed on this payment business before the verification is completed.
[0072] For example, in the scenario of this application, the payment amount is 120.50 yuan, the last transaction number is 00215, and the transaction number of the pre-generated transaction record is 00216. After the IC card is reinserted into the card reader and the partial write identifier is confirmed, the first verification transaction number read before the rewrite is the same as the last transaction number 00215. The pre-generated transaction record is appended to the position after the last transaction record in the transaction area. The value of the balance area does not change, the cash already collected does not need to be collected again, and duplicate deductions are avoided.
[0073] It is understandable that the verification of the first serial number and the writing of the pre-generated serial record are dependent on each other. The verification result determines whether the writing is performed. When the verification passes, the object written is only the serial area. When the verification fails, the writing is blocked and the process is redirected to manual verification. The sending of the manual verification prompt constitutes the information exchange between the cashier and the cashier. The cashier's subsequent verification result determines the final outcome of this transaction. The entire rewriting process is jointly promoted by condition judgment and interactive communication.
[0074] In some embodiments, the specific implementation of writing the pre-generated serial number into the serial area in response to the first verification serial number being equal to the last serial number includes: A1. Read the first verification serial number from the serial area, compare the first verification serial number with the last serial number in the pre-write snapshot, and proceed to step A2 if the first verification serial number is the same as the last serial number, and proceed to step A5 if the first verification serial number is different from the last serial number.
[0075] A2, determine the position after the last serial number in the serial area as the write position, and proceed to step A3.
[0076] A3. Write the transaction number, payment amount, and business order number from the pre-generated transaction record into the writing position in the order of the payment transaction records in the transaction area, and proceed to step A4.
[0077] A4. After the pre-generated transaction record is written, the process switches to the readback verification of the transaction area and the balance area, and then ends.
[0078] A5, generate the manual verification prompt containing the card number, the first verification serial number and the last serial number, and proceed to step A6.
[0079] A6. The manual verification prompt is sent to the payment terminal screen so that the cashier can verify the transaction data of the IC card with the cash already collected, and the process ends.
[0080] The process of writing the pre-generated serial number to the write location in step A3 includes: B1, write the serial number of the pre-generated serial record into the serial number field of the write position.
[0081] B2, write the payment amount of the pre-generated transaction record into the amount field of the write location.
[0082] B3. Write the business order number of the pre-generated transaction record into the order number field of the writing position. After all three fields are written, proceed to step A4.
[0083] Figure 3 This demonstrates the process for rewriting and verifying transaction records in a partially written state. After confirming that the card is in a partially written state, the rewriting conditions are verified by reading the first verification transaction number. If the conditions are met, only the pre-generated payment record is appended to the transaction area. After the write is completed, the actual values in the balance area and transaction area are read back and compared with the pre-generated record from multiple dimensions. If the comparison is consistent, an identifier is generated and the transaction is cancelled; if there are discrepancies and the retry limit has not been reached, the rewrite mechanism is automatically triggered until the data is completely matched or the process is transferred to manual verification, ensuring the accuracy of the rewrite operation and the consistency of the data.
[0084] In some embodiments, performing the write process on the IC card according to the write status identifier may further include the following steps: S4.5, In response to the write status identifier being "not written", a cash processing selection request is sent to the payment terminal screen; S4.6, a first selection response or a second selection response is received from the cashier in response to the cash processing selection request. The first selection response indicates that the cash has been received and the payment transaction is being processed again, while the second selection response indicates that the cash is being refunded and the payment transaction is being cancelled; S4.7, In response to the first selection response, based on the old balance value in the pre-write snapshot, the balance value after deducting the payment amount is written to the balance area, and the payment transaction record is written to the transaction area, completing the write process; S4.8, In response to the second selection response, the writing to the IC card is cancelled, a refund voucher is printed, and the write process is completed.
[0085] Specifically, the trigger condition for the cash processing selection request is that the write status identifier is set to "not written". At this time, both the card balance area and the transaction history area remain in the pre-write state. Cash has been collected, but the deduction from the card has not yet occurred. The cash processing selection request is displayed on the payment terminal screen as two option buttons. The request allows the cashier to choose between two processing methods: one is to accept the cash and reprocess the payment transaction, and the other is to refund the cash and cancel the payment transaction. The cash processing selection request continues to be displayed until a selection response is received. The reason for giving the selection right to the cashier is that only the cashier knows whether the cash has actually been collected. Allowing the cashier to input the selection response can avoid automatically deciding to reprocess or cancel when the cash status is unknown. The selection request and selection response constitute a two-way information exchange between the device and the cashier.
[0086] Furthermore, upon receiving the first selection response, the write operation is performed based on the old balance value in the pre-write snapshot. The premise of using the old balance value as the basis is that the current balance value in the card is equal to the old balance value in the unwritten state. Using the pre-write value after read integrity verification as the basis avoids using intermediate values with unclear verification status. The write content includes two parts: one part is writing the old balance value minus the payment amount to the balance area; the other part is writing the payment transaction record of this payment transaction to the transaction record area. The payment transaction record includes a transaction number, payment amount, and transaction number. The transaction number is the next transaction number after the last transaction number. The two parts are written sequentially in the same writing order as in step S2. After writing is completed, a readback verification is performed in the same way as in the rewrite case. After the verification passes, the payment transaction is cancelled, and the write process is completed. Both the first and second selection responses are input by the cashier through the buttons on the payment terminal.
[0087] For example, upon receiving the second selection response, the writing to the IC card is cancelled, and the two areas on the card remain unchanged from their pre-writing state. The printed refund voucher specifies the transaction number, payment amount, refund amount, and printing time of this payment transaction. After the cashier completes the cash refund based on the refund voucher, this payment transaction is terminated. The writing process is completed by cancelling the writing and printing the voucher. Both selection response processes ultimately end with the completion of the writing process.
[0088] Understandably, the write operation re-processed under the first selected response path will not initiate settlement deduction. The deduction value will be the value obtained by subtracting the payment amount from the old balance value, which is completely consistent with the value of the first write operation. The cash already collected by the cashier will neither be refunded nor collected again. The re-processing action and the cash status will correspond to each other through the pre-write snapshot and the cashier's selected response.
[0089] Preferably, after the write operation for this payment transaction is completed, the readback verification of the balance area and the transaction history area is also performed. After the verification is successful, the payment transaction is cancelled, the payment terminal screen displays a payment completion prompt and allows card retrieval. The card retrieval prompt is enabled after the write and verification are completed, so that the card retrieval signal seen by the cardholder is aligned with the data in the card in time.
[0090] In this application, writing the pre-generated flow record into the flow area may further include the following steps: S4.31, After writing is completed, read the first read-back value from the balance area, and read the second read-back value and the read-back transaction record from the transaction area; S4.32, determine whether the deduction amount of the first read-back value relative to the old balance value is equal to the payment amount, determine whether the second read-back value is the next transaction number after the last transaction number, and determine whether the amount and transaction number in the read-back transaction record are consistent with the pre-generated transaction record; S4.33, in response to the consistent judgment results, generate a consistency identifier and cancel the payment transaction; S4.34, in response to the inconsistent judgment results, re-execute the step of writing the pre-generated transaction record into the transaction area. If the inconsistency still exists after reaching the preset retry limit, generate a manual verification prompt and send it to the payment terminal screen.
[0091] Specifically, the timing of the readback is after the pre-generated transaction record is written. The readback method is to read the first readback value from the balance area through the card reader, read the transaction number of the last payment transaction record in the transaction area as the second readback value, and read the content of the last payment transaction record as the readback transaction record. The readback process does not rely on the write completion receipt and directly uses the actual values and record content of the two areas in the card as the verification objects.
[0092] Furthermore, the verification includes three parallel judgments. The judgment on the first read value includes subtracting the first read value from the old balance value in the pre-write snapshot to obtain the deduction amount, and judging whether the deduction amount is equal to the payment amount, to confirm that the balance area has not been mistakenly modified during the rewriting process and remains in the deduction state. The judgment on the second read value includes judging whether the second read value is the next serial number after the last serial number, to confirm that the serial number has been updated. The judgment on the read-back serial record includes comparing the amount field in the read-back serial record with the payment amount in the pre-generated serial record, and comparing the order number field in the read-back serial record with the business order number in the pre-generated serial record, to confirm that the writing position and the written content are correct.
[0093] For example, if the results of the three judgments are consistent, a consistency identifier is generated. The consistency identifier is written into the business record of this payment transaction as the basis for the cancellation judgment. The specific cancellation action includes updating the business status field in the business record of this payment transaction from pending to completed, archiving the pre-write snapshot and the pre-generated transaction record along with the transaction number to the history record, and instructing the payment terminal screen to display a payment completion prompt and print a payment receipt. The payment receipt contains the transaction number, payment amount and updated balance value. After cancellation, the business record of the settlement system corresponds to the card balance value and the card payment transaction record. During the background reconciliation, this payment can be directly verified and closed.
[0094] It should be noted that if there is an inconsistency in the judgment results, the process of writing the pre-generated transaction record into the transaction area will be re-executed. Before re-execution, the first verification transaction number will be reread and the verification branch will be executed according to the process of steps A1 to A6. The above writing and judgment process will be repeated. If there is still an inconsistency after reaching the preset retry limit, the manual verification prompt will be generated and sent to the payment terminal screen for the cashier to intervene and verify. Before the verification is completed, the payment transaction will remain in the pending state.
[0095] The preset retry limit is obtained by statistical analysis of the number of rewrite failures under the influence of the stability of the contact between the reader contact and the metal plate on the card. The preferred setting range is two to four times. In the specific operation of this application, the wear degree of the reader contact is obtained. When the wear degree is not less than 50%, the preset retry limit is set to four times. When the wear degree is less than 50%, the preset retry limit is set to two times.
[0096] For example, in the scenario of this application, after the rewriting is completed, the first readout value is equal to the amount of the deduction from the old balance value, and the second readout value is the next serial number after the last serial number. The amount and business order number in the readout record are consistent with the pre-generated serial record. All three judgments are passed, the payment transaction is cancelled, the payment slip is consistent with the data in the card and the background record, and the outstanding account is no longer generated.
[0097] In some preferred embodiments, the method may further include the following steps: S5, in response to the IC card not being reinserted into the card reader within a preset waiting time, a pending write order for this payment transaction is generated and written to the pending write queue. The pending write order includes the card number, the payment amount, the transaction number identifying this payment transaction, and the pre-write snapshot. S6, in response to the IC card being inserted into the hospital's card reader terminal, the card number is read through the hospital's card reader terminal, and a card number query request is sent to the settlement system. S7, in response to the card number query request finding a pending write order matching the card number in the pending write queue, a write confirmation request is sent to the hospital's card reader terminal, and an immediate write response or a later write response is received in response to the write confirmation request. S8, in response to the immediate write response, the steps of reading the current balance value and the current transaction number value and determining the write status identifier are triggered. S9, in response to the later write response, the pending write order is retained in the pending write queue.
[0098] Specifically, the condition for generating the pending order is that the IC card is not detected being reinserted into the card reader within the preset waiting time, indicating that the cardholder has left the payment window with the IC card. The fields of the pending order are the card number, the payment amount, the transaction number identifying this payment transaction, and the snapshot before writing. The pending queue is a list of records in the settlement system's memory. Each entry in the queue contains all the fields of a pending order and the generation time. The entries are arranged in order of generation time. Multiple pending orders are allowed to coexist in the queue. Each pending order corresponds to a payment transaction where cash has been received but the card transaction record is missing. Queue entries continue to exist until the order is completed and cleared. After clearing, the corresponding entry is removed from the queue.
[0099] Furthermore, the in-hospital card reader terminal is a card reader device located outside the payment window, such as a payment terminal in the self-service payment area or a card reader device located at the reception area. The in-hospital card reader terminal is connected to the settlement system via the in-hospital network. The card number query request and the rewriting confirmation request are transmitted via the in-hospital network, and the connection method is an existing wired or wireless communication connection. After the IC card is inserted into the in-hospital card reader terminal, the card number is read by the in-hospital card reader terminal in the same way as the card number is read by the card reader at the payment window. After the reading is completed, a card number query request carrying the card number is immediately sent to the settlement system. The timing of the card number query request is before the in-hospital card reader terminal initiates any payment business. After receiving the card number query request, the settlement system compares the card number carried in the request with the card number field of each entry in the rewriting queue one by one. The retrieval action occurs before the new business occurs.
[0100] For example, if a replacement order matching the card number is found, a replacement confirmation request is sent to the hospital's card reader terminal. The replacement confirmation request is displayed on the screen of the hospital's card reader terminal, showing that there is an incomplete payment record on the card and requesting a choice of processing method. The response to the replacement confirmation request can be either an immediate replacement response or a later replacement response. Both responses are entered through the option buttons on the screen of the hospital's card reader terminal. At self-service payment terminals, the cardholder can directly enter the response by pressing the buttons. At the card reader device at the reception area, the receptionist can ask the cardholder and enter the response by pressing the buttons on their behalf. The entered response is returned to the settlement system via the hospital's card reader terminal and the hospital's network.
[0101] Understandably, upon receiving the immediate write response, the steps of reading the current balance value and the current transaction number value, and determining the write status identifier are triggered. The reading and comparison are completed at the hospital's card reader terminal. When the write status identifier is a partial write identifier, verification and write are performed according to steps A1 to A6. After the write is completed, a readback verification and cancellation are performed. After cancellation, the corresponding write order is removed from the write queue, ensuring that the write process at the hospital's card reader terminal fully reuses the reread comparison and identifier-based write processing path at the payment window. Before write, the first verification branch for the transaction number is also executed, preventing blind write-through without verification. Upon receiving the later write response, the write order is retained in the write queue, allowing the cardholder to complete the current examination or medical visit before writing.
[0102] On the other hand, when there are multiple matching entries, they are processed one by one from earliest to latest according to their generation time. After each entry is rewritten, verified, and removed from the queue, the next entry is processed, thus maintaining the correct order of the serial numbers. After the order to be rewritten is generated, if the IC card is reinserted into the card reader at the original payment window, the process of reading the current balance value, the current serial number value, and subsequent rewriting is performed. After rewriting and verification, the corresponding order to be rewritten is removed from the queue. Queue entries can be eliminated at both the original card reader and the in-hospital card reader terminal. While the order to be rewritten exists in the queue, the cash already collected and the missing transaction records on the card constitute a pending correspondence between the background records and the data on the card. After the rewriting is completed and verified, the cash record, the card payment transaction record, and the background business record of this payment transaction form a closed correspondence. The patient does not need to return to the original payment window, and the outstanding amount can be eliminated at any card reader terminal in the hospital.
[0103] Preferably, the method may further include the following steps: S10, while the order to be rewritten exists in the order to be rewritten queue, in response to the IC card initiating a new payment settlement at any card reader terminal, a payment lock prompt is sent to the card reader terminal that initiated the new payment settlement. The payment lock prompt is used to prompt that the rewriting of the order to be rewritten be completed first. S11, in response to the completion and cancellation of the order to be rewritten, the payment lock status corresponding to the payment lock prompt is released, and the new payment settlement continues to be executed. S12, the generation, rewriting, and cancellation events of the order to be rewritten are written to the association log according to time and causal relationship. S13, in response to receiving a reconciliation query request, the event sequence arranged by time in the association log is returned.
[0104] Specifically, the new payment settlement is initiated by the card reader terminal sending a settlement request to the settlement system. The settlement request carries the card number. The trigger condition for the payment lock prompt is that the pending transaction record exists in the pending transaction record queue and the settlement request arrives. The trigger determination method includes comparing the card number carried in the settlement request with the card number field of each entry in the pending transaction record queue before processing the settlement request. When an existing entry is found, the payment lock prompt is sent to the card reader terminal that initiated the settlement request and the settlement processing is suspended. The prompt content is to complete the pending transaction record first. The purpose of locking is to prevent new payment settlements from being executed directly when there is a balance deducted but no transaction record in the card, so as to avoid new payment transaction records being superimposed on the card data with missing transaction records and causing further confusion in the account relationship.
[0105] Furthermore, after the pending order is completed and verified, the payment lock status corresponding to the payment lock prompt is released. The specific action of release is to remove the corresponding pending order from the queue and resume the processing of the suspended settlement request, and continue to execute the new payment settlement. The cardholder does not need to re-initiate the settlement. Both locking and unlocking are conditional on the existence status of the queue entry. When the queue entry exists, the new payment is guided to first fill the old account. After the queue entry is verified, the new payment continues normally. The change of the lock status and the result of the filling and verification form a sequential and interdependent linkage relationship.
[0106] For example, the associated log is an event list in the storage, recording the generation, writing, and cancellation events of the order to be rewritten. Each entry's fields include event type, event time, associated business order number, judgment result, and interaction result. The recording method is to write each event into the associated log according to the order of time and cause and effect, generate an event-associated pre-write snapshot and cash collection status, a reread comparison result and verification branch result during the writing of the rewritten event, and a judgment result and consistency identifier during the readback verification of the cancellation event. The event sequence completely presents the entire processing path of a payment business from writing interruption to rewriting and cancellation.
[0107] It should be noted that the reconciliation query request is sent from the reconciliation terminal at the billing office to the settlement system. The query conditions can be combined by card number, by transaction number, or by date. Upon receiving the reconciliation query request, the system retrieves matching event entries from the associated log according to the query conditions and returns an event sequence arranged by time. The reconciliation terminal displays the event sequence for the reconciliation party to verify. The reconciliation party verifies the correspondence between cash collection records, card payment transaction records, and back-end business records based on the event sequence. When the cardholder raises a transaction dispute based on the payment voucher, the processing result can be located based on the supplementary and cancellation events in the associated log, without requiring the cardholder to return to the original billing window for repeated verification. The query request and the return of the event sequence constitute the query and response exchange between the device and the reconciliation party. The query result and the queue cancellation status together constitute the final closing basis for this payment transaction.
[0108] Example 2: This example also provides an IC card data control system, including: The module includes a snapshot generation module, a write execution module, a reread comparison module, and a write processing module. The snapshot generation module is used to obtain the payment amount, read the old balance value from the balance area of the IC card, read the last transaction number from the transaction area of the IC card, and generate a pre-write snapshot containing the card number, the old balance value and the last transaction number. The balance area is the data area in the IC card that stores the balance value, and the transaction area is the data area in the IC card that stores the payment transaction record. The write execution module is used to send write instructions to the IC card and execute the write operation in the order of writing to the balance area first and then writing to the transaction area. The reread comparison module is used to respond to a write interruption and the IC card being reinserted into the card reader, read the current balance value and the current serial number value, compare the current balance value with the old balance value, and compare the current serial number value with the last serial number to determine the write status identifier; The write processing module is used to perform write processing on the IC card according to the write status identifier. When the write status identifier is a partial write identifier, only the payment transaction record is written to the transaction area, and no record is written to the balance area.
[0109] The above-mentioned unit modules can be embedded in the processor of the electronic device in hardware form or independent of it, or they can be stored in the memory of the electronic device in software form, so that the processor can call and execute the corresponding operations of the above modules.
[0110] See Figure 4 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application. The electronic device 40 includes: Processor 41, memory 42, and computer program; in, The memory 42 is used to store the computer program, and the memory may also be flash memory. The computer program is, for example, an application program or functional module that implements the above method.
[0111] The processor 41 is configured to execute the computer program stored in the memory to implement the various steps performed by the device in the above method.
[0112] For details, please refer to the relevant descriptions in the preceding method embodiments.
[0113] Alternatively, the memory 42 can be either standalone or integrated with the processor 41.
[0114] When the memory 42 is a device independent of the processor 41, the device may further include: Bus 43 is used to connect the memory 42 and the processor 41.
[0115] Finally, it should be noted that: The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them; Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: It is still possible to modify the technical solutions described in the foregoing embodiments, or to make equivalent substitutions for some or all of the technical features therein; These modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions in the embodiments of this application.
Claims
1. A data control method for an IC card, characterized in that, include: Obtain the payment amount, read the old balance value from the balance area of the IC card, read the last serial number from the transaction area of the IC card, and generate a pre-write snapshot containing the card number, the old balance value, and the last serial number; The balance area is the data area in the IC card that stores the balance value, and the transaction area is the data area in the IC card that stores the payment transaction records; Send a write command to the IC card and execute the write operation in the order of writing to the balance area first and then to the transaction history area; In response to a write interruption and the IC card being reinserted into the card reader, the current balance value and the current serial number value are read, the current balance value is compared with the old balance value, and the current serial number value is compared with the last serial number to determine the write status identifier; Write processing is performed on the IC card according to the write status identifier. When the write status identifier is a partial write identifier, only the payment transaction record is written to the transaction area, and no record is written to the balance area, including: Generate a pre-generated transaction record containing the payment amount and a transaction number identifying this payment transaction. The transaction number of the pre-generated transaction record is the next transaction number after the last transaction number. Before writing, read the first verification serial number from the serial area; In response to the first verification serial number being equal to the last serial number, the pre-generated serial record is written to the serial area, but not to the balance area; In response to the first verification serial number not being equal to the last serial number, no writing is performed to the serial area, a manual verification prompt is generated and sent to the charging terminal screen; The step of comparing the current value of the balance with the old value of the balance, and comparing the current value of the serial number with the last serial number to determine the write status identifier includes: In response to the fact that the deduction amount of the current balance value relative to the old balance value is equal to the payment amount, and the current value of the serial number is equal to the last serial number, the write status identifier is determined to be a partial write identifier; In response to the current value of the balance being equal to the old value of the balance and the current value of the serial number being equal to the last serial number, the write status identifier is determined to be an unwritten identifier; In response to the current value of the balance being equal to the old value of the balance, and the current value of the serial number being the next serial number after the last serial number, the write status identifier is determined to be a completed identifier.
2. The data control method for an IC card according to claim 1, characterized in that, The process of obtaining the payment amount involves reading the old balance from the balance area of the IC card, reading the last transaction number from the transaction history area of the IC card, and generating a pre-write snapshot containing the card number, the old balance, and the last transaction number, including: Read the card number, the old balance, and the last serial number from the IC card; Determine whether the card number, the old balance, and the last transaction number have been read completely, and determine whether the old balance meets the payment conditions for paying the payment amount; In response to the complete reading and satisfaction of the payment conditions, the card number, the old balance value, and the last transaction number are associated with the payment amount, and the pre-write snapshot is generated. In response to an incomplete read, a re-insertion prompt is sent to the charging terminal screen, and the read is re-executed based on the re-inserted IC card until the read is complete, after which the pre-write snapshot is generated.
3. The data control method for an IC card according to claim 1, characterized in that, The step of responding to a write interrupt and having the IC card reinserted into the card reader, reading the current balance value and the current serial number value, includes: During the writing process in the prescribed writing order, a contact disconnection signal between the card reader and the IC card is detected. In response to the detection of the contact disconnection signal, a first prompt is sent to the payment terminal screen and a second prompt is sent to the speaker associated with the card reader. The first prompt is used to indicate that the writing was interrupted and the second prompt is used to indicate that the IC card should be inserted again. In response to the IC card being reinserted into the card reader within a preset waiting time, the current balance value and the current serial number value are read. If the IC card is not reinserted within the preset waiting time, the second prompt is sent again through the speaker, and if the IC card is subsequently reinserted into the card reader, the current balance value and the current serial number value are read.
4. The data control method for an IC card according to claim 1, characterized in that, The step of performing a write process on the IC card according to the write status identifier includes: In response to the write status flag being a write-not flag, a cash processing selection request is sent to the payment terminal screen; The cashier receives a first or second selection response in response to the cash processing selection request. The first selection response indicates that the cash has been received and the payment transaction is being processed again, while the second selection response indicates that the cash is being refunded and the payment transaction is being cancelled. In response to the first selection response, based on the old balance value in the pre-write snapshot, the balance value after deducting the payment amount is written to the balance area, and the payment transaction record is written to the transaction area to complete the writing process; In response to the second selection response, the writing to the IC card is cancelled, a refund voucher is printed, and the writing process is completed.
5. The data control method for an IC card according to claim 1, characterized in that, The method further includes: If the IC card is not reinserted into the card reader within a preset waiting time, a write-out order for this payment transaction is generated and written to the write-out queue. The write-out order includes the card number, the payment amount, the transaction number identifying this payment transaction, and the snapshot taken before writing. In response to the insertion of the IC card into the hospital's card reader terminal, the card number is read through the hospital's card reader terminal, and a card number query request is sent to the settlement system. In response to a query request based on the card number, if a replacement order matching the card number is found in the replacement queue, a replacement confirmation request is sent to the in-hospital card reader terminal, and an immediate replacement response or a later replacement response is received in response to the replacement confirmation request. In response to the immediate write response, the steps of reading the current balance value and the current serial number value and determining the write status identifier are triggered. In response to the later write response, the write-to-be-written form is retained in the write-to-be-written queue.
6. The data control method for an IC card according to claim 1, characterized in that, The step of writing the pre-generated stream record into the stream area includes: After writing is complete, the first readback value is read from the balance area, and the second readback value and readback transaction record are read from the transaction area. Determine whether the deduction amount of the first read value relative to the old value of the balance is equal to the payment amount, determine whether the second read value is the next transaction number after the last transaction number, and determine whether the amount and business order number in the read transaction record are consistent with the pre-generated transaction record; If the judgment results are consistent, a consistency identifier is generated, and the payment transaction is cancelled. In response to the inconsistency in the judgment result, the process of writing the pre-generated transaction record into the transaction area is repeated. If the inconsistency still exists after reaching the preset retry limit, a manual verification prompt is generated and sent to the toll terminal screen.
7. The data control method for an IC card according to claim 5, characterized in that, The method further includes: While the order to be rewritten exists in the order to be rewritten queue, in response to the IC card initiating a new payment settlement at any card reader terminal, a payment lock prompt is sent to the card reader terminal that initiated the new payment settlement. The payment lock prompt is used to prompt the rewriting of the order to be rewritten to be completed first. In response to the completion and cancellation of the supplementary order, the payment lock status corresponding to the payment lock prompt is released, and the new payment settlement is executed. The generation, completion, and cancellation events of the orders to be rewritten are written to the associated log according to time and causal relationship; In response to receiving a reconciliation query request, the system returns a sequence of events from the associated log, arranged by time.
8. A data control system for IC cards, characterized in that, It includes a snapshot generation module, a write execution module, a reread comparison module, and a write processing module; The snapshot generation module is used to obtain the payment amount, read the old balance value from the balance area of the IC card, read the last transaction number from the transaction area of the IC card, and generate a pre-write snapshot containing the card number, the old balance value and the last transaction number. The balance area is the data area in the IC card that stores the balance value, and the transaction area is the data area in the IC card that stores the payment transaction record. The write execution module is used to send write instructions to the IC card and execute the write operation in the order of writing to the balance area first and then writing to the transaction area. The reread comparison module is used to respond to a write interruption and the IC card being reinserted into the card reader, read the current balance value and the current serial number value, compare the current balance value with the old balance value, and compare the current serial number value with the last serial number to determine the write status identifier; The write processing module is used to perform write processing on the IC card according to the write status identifier. When the write status identifier is a partial write identifier, only the payment transaction record is written to the transaction area, and no record is written to the balance area.
