A method, system, device and medium for processing transaction data
By using a combination of in-memory and persistent databases during the transaction process, the latency problem during transaction data synchronization was solved, enabling real-time data processing between databases and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies suffer from latency issues during data synchronization between the source and target databases during transactions. The latency is even longer when fields are added to the source and target databases, which affects the user experience.
The system uses an in-memory database and a first persistent database to store transaction data. Based on the time difference between the reverse transaction request and the forward transaction request, it selectively retrieves transaction data from the in-memory database, the first persistent database, or the second persistent database, executes the reverse transaction, and updates the second persistent database.
It enables real-time data processing between databases, solves the data latency problem, and improves the user experience.
Smart Images

Figure CN116069857B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and specifically to a transaction data processing method, system, device, and medium. Background Technology
[0002] Currently, the OGG database technology is used during the transaction process to synchronize data from the source to the target system, ensuring that both systems have identical data. After the application system writes the data to the source database, the target database needs to access that data promptly.
[0003] In the payment industry, there are positive transactions (consumptions) and negative transactions (refunds). Correspondingly, positive transaction data is usually stored in one database (i.e., the source database), while negative transaction data is stored in another database (i.e., the target database). The two are separate and do not interfere with each other. To implement a negative transaction, the data in the source database needs to be synchronized to the target database.
[0004] The implementation principle is that the positive transaction application writes to the source database, extracts the source end's log file (redo log), and then delivers it to the target end via TCP / IP. Finally, it parses and restores the application to the target end, enabling the target end to achieve data synchronization with the source end. The reverse transaction reads data by accessing the target database and then performs business logic processing.
[0005] While OGG technology can capture, transform, and deliver large amounts of transaction data and synchronize data between the source and target databases, it often has a data latency of 6-10 seconds. In addition, if fields need to be added to the source and target databases, OGG needs to be deactivated for an even longer period, which will further increase the latency and affect the user experience.
[0006] Accordingly, a new technical solution is needed in this field to solve the above problems. Summary of the Invention
[0007] To overcome the above-mentioned defects, this invention is proposed to provide a transaction data processing method, system, device, and medium that solves or at least partially solves the technical problem of data latency during data synchronization between a source database and a target database.
[0008] In a first aspect, a transaction data processing method is provided, the method comprising:
[0009] In response to the positive transaction request, the transaction data is stored in the in-memory database and the first persistent database respectively;
[0010] Synchronize the transaction data in the first persistent database to the second persistent database;
[0011] In response to a reverse transaction request, determine whether the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time.
[0012] Based on the judgment result, the transaction data may be selectively obtained from either the in-memory database and the first persistent database or from the second persistent database;
[0013] Execute a reverse transaction based on the acquired transaction data; and,
[0014] The second persistent database is updated based on the result of the reverse transaction.
[0015] In one technical solution of the above-mentioned transaction data processing method, the step of selectively retrieving the transaction data from one of the in-memory database and the first persistent database or from the second persistent database based on the judgment result includes:
[0016] If the difference between the time of the reverse transaction request and the time of the positive transaction request is less than the preset time, the transaction data is obtained from one of the in-memory database and the first persistent database;
[0017] And / or,
[0018] If the difference between the time of the reverse transaction request and the time of the positive transaction request is not less than the preset time, the transaction data is retrieved from the second persistent database.
[0019] In one technical solution of the above-mentioned transaction data processing method, obtaining the transaction data from one of the in-memory database and the first persistent database includes:
[0020] The transaction data is retrieved from the memory database based on the transaction order number;
[0021] If the transaction data is still retained in the memory database, then the transaction data is retrieved from the memory database; otherwise, the transaction data is retrieved from the first persistent database.
[0022] In one technical solution of the above-mentioned transaction data processing method, the first persistent database includes multiple sub-persistent databases, wherein the multiple sub-persistent databases are distinguished by using different channels;
[0023] The step of storing transaction data in the first persistent database includes: selecting a sub-persistent database from the plurality of sub-persistent databases using Nginx to store the transaction data;
[0024] The step of querying the transaction data from the first persistent database to obtain the transaction data includes:
[0025] Traverse all sub-persistent databases to obtain tunnel information;
[0026] The transaction data is obtained by obtaining the sub-persistent database in which the transaction data is stored based on the channel information.
[0027] In one technical solution of the above transaction data processing method, the step of performing a reverse transaction based on the acquired transaction data includes: calling the UnionPay or NetsUnion interface to perform the reverse transaction.
[0028] In one technical solution of the above transaction data processing method, updating the second persistent database based on the result of the reverse transaction includes:
[0029] If the second persistent database has already synchronized the transaction data, then after the UnionPay or NetsUnion interface responds, the transaction data in the second persistent database will be updated.
[0030] In one technical solution of the above transaction data processing method, updating the second persistent database based on the result of the reverse transaction includes:
[0031] If the second persistent database still fails to synchronize the transaction data, the transaction status and amount corresponding to the reverse transaction will be stored in a temporary table after the UnionPay or NetsUnion interface responds.
[0032] After detecting that the transaction data has been synchronized in the second persistent database, the transaction status and amount are retrieved from the temporary table based on the time and order number of the reverse transaction request, so as to update the transaction data in the second persistent database.
[0033] In a second aspect, a transaction data processing system is provided, the system comprising:
[0034] The system comprises a positive transaction unit, a negative transaction unit, an in-memory database, a synchronization component, a first persistent database, and a second persistent database.
[0035] In response to a positive transaction request, the positive transaction unit stores the transaction data in the memory database and the first persistent database, respectively;
[0036] The synchronization component synchronizes the transaction data in the first persistent database to the second persistent database;
[0037] In response to a reverse transaction request, the reverse transaction unit determines whether the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time.
[0038] Based on the judgment result, the anti-transaction unit selectively obtains the transaction data from one of the in-memory database and the first persistent database, or from the second persistent database;
[0039] The anti-transaction unit performs an anti-transaction based on the acquired transaction data; and,
[0040] The anti-transaction unit updates the second persistent database based on the result of the anti-transaction.
[0041] In one technical solution of the aforementioned transaction data processing system, the system further includes a gateway, wherein,
[0042] If the difference between the time of the reverse transaction request and the time of the positive transaction request is less than the preset time, the reverse transaction unit accesses the gateway;
[0043] The gateway queries the transaction data from the memory database based on the transaction order number;
[0044] If the transaction data is still retained in the memory database, the gateway retrieves the transaction data from the memory database and returns it to the anti-transaction unit; otherwise, the gateway queries the transaction data from the first persistent database to obtain the transaction data and returns it to the anti-transaction unit.
[0045] In one technical solution of the aforementioned transaction data processing system, the system further includes Nginx;
[0046] The first persistent database includes multiple sub-persistent databases, wherein the multiple sub-persistent databases are distinguished by using different channels;
[0047] In response to a positive transaction request, Nginx selects one of the plurality of sub-persistent databases to store the transaction data;
[0048] The gateway traverses all sub-persistent databases to obtain channel information;
[0049] The gateway obtains the transaction data by finding the sub-persistent database where the transaction data is stored based on the channel information.
[0050] In a third aspect, an electronic device is provided, comprising a processor and a storage device, the storage device being adapted to store a plurality of program codes, the program codes being adapted to be loaded and run by the processor to perform the transaction data processing method described in any of the above-described technical solutions.
[0051] In a fourth aspect, a computer-readable storage medium is provided, wherein a plurality of program codes are stored therein, the program codes being adapted to be loaded and run by a processor to perform the transaction data processing method described in any of the above-described technical solutions.
[0052] The present invention comprises one or more of the following technical solutions:
[0053] Beneficial effects:
[0054] In implementing the technical solution of this invention, in response to a positive transaction request, transaction data is stored in a memory database and a first persistent database respectively; the transaction data in the first persistent database is synchronized to a second persistent database; in response to a negative transaction request, it is determined whether the difference between the time of the negative transaction request and the time of the positive transaction request is less than a preset time; based on the determination result, transaction data is selectively retrieved from either the memory database or the first persistent database, or from the second persistent database; a negative transaction is executed based on the retrieved transaction data, and the second persistent database is updated based on the result of the negative transaction. Through the above implementation method, real-time processing of transaction data between databases can be achieved, solving the problem of data latency at the business level, thereby avoiding the business impact caused by data latency and improving the user experience. Attached Figure Description
[0055] The disclosure of this invention will become more readily understood with reference to the accompanying drawings. It will be readily understood by those skilled in the art that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. Furthermore, similar numbers in the drawings are used to denote similar components, wherein:
[0056] Figure 1 This is a main structural block diagram of a transaction data processing system according to an embodiment of the present invention;
[0057] Figure 2 This is a schematic flowchart of the main steps of a transaction data processing method according to an embodiment of the present invention;
[0058] Figure 3 This is a schematic diagram of the main structure of an electronic device according to an embodiment of the present invention.
[0059] List of reference numerals in the attached diagram:
[0060] 101: Positive transaction unit; 102: Negative transaction unit; 103: In-memory database; 104: Synchronization component; 105: First persistent database; 106: Second persistent database; 107: Gateway; 108: Nginx; 301: Processor; 302: Storage device. Detailed Implementation
[0061] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0062] In the description of this invention, "module" and "processor" can include hardware, software, or a combination of both. A module can include hardware circuitry, various suitable sensors, communication ports, memory, and may also include software components, such as program code, or a combination of software and hardware. A processor can be a central processing unit, microprocessor, image processor, digital signal processor, or any other suitable processor. The processor has data and / or signal processing capabilities. The processor can be implemented in software, in hardware, or a combination of both. Non-transitory computer-readable storage media includes any suitable medium capable of storing program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The terms "at least one A or B" or "at least one of A and B" have a similar meaning to "A and / or B" and can include only A, only B, or A and B. The singular terms "a" or "this" can also include plural forms.
[0063] Here we will first explain some of the terms involved in this invention.
[0064] Nginx, also known as enginex, is an open-source web service and proxy service software that supports high performance and high concurrency.
[0065] OGG: Oracle GoldenGate is a log-based structured data replication and backup software. It obtains incremental changes to the data by parsing the online or archived logs of the source database, and then applies these changes to the target database, thereby achieving synchronization between the source and target databases.
[0066] API: Application Program Interface, is a calling interface provided by the operating system for applications. Applications call the operating system's API to make the operating system execute the application's commands.
[0067] Redis: RemoteDictionaryServer, is an open-source, network-enabled, in-memory or persistent, log-structured, key-value database written in ANSI C, and provides APIs for multiple languages.
[0068] Batch processing: This refers to the batch processing of data by an application. It is characterized by large data volume, automation, and high performance. Large data volume means that batch tasks are usually accompanied by a large amount of data processing; automation means that it is required to run automatically at a specified time or frequency; and high performance means that batch processing tasks are required to be completed within a specified time.
[0069] Currently, OGG (Optical Data Generation) technology is used in the transaction process to synchronize data from the source to the target system, ensuring that both systems have identical data. While OGG technology can capture, transform, and deliver large amounts of transaction data, achieving data synchronization between the source and target databases, it often suffers from a data latency of 6-10 seconds. Furthermore, if fields need to be added to the source and target databases, OGG needs to be disabled for an even longer period, further increasing the latency and impacting user experience. To address the data latency issue during source and target database synchronization, this invention provides a transaction data processing method, system, device, and medium.
[0070] See appendix Figure 1 , Figure 1 This is a main structural block diagram of a transaction data processing system according to an embodiment of the present invention. Figure 1 As shown, the transaction data processing system in this embodiment of the invention mainly includes a positive transaction unit 101, a negative transaction unit 102, a memory database 103, a synchronization component 104, a first persistent database 105, a second persistent database 106, a gateway 107, and an Nginx 108.
[0071] In some implementations, the positive transaction unit 101, the negative transaction unit 102, the in-memory database 103, the synchronization component 104, the first persistent database 105, the second persistent database 106, the gateway 107, and the Nginx 108 can be software functional modules in a software system.
[0072] In other implementations, such as in a distributed system, the positive transaction unit 101, the negative transaction unit 102, the in-memory database 103, the synchronization component 104, the first persistent database 105, the second persistent database 106, the gateway 107, and the Nginx 108 can be microservices deployed on different servers.
[0073] See appendix Figure 2 , Figure 2 This is a schematic flowchart illustrating the main steps of a transaction data processing method according to an embodiment of the present invention. Figure 2 As shown, the transaction data processing method in this embodiment of the invention mainly includes the following steps S201 to S206.
[0074] Step S201: In response to the positive transaction request, store the transaction data in the in-memory database and the first persistent database respectively.
[0075] Step S202: Synchronize the transaction data in the first persistent database to the second persistent database.
[0076] Step S203: In response to the reverse transaction request, determine whether the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time.
[0077] Step S204: Based on the judgment result, selectively retrieve transaction data from one of the in-memory database and the first persistent database, or retrieve transaction data from the second persistent database.
[0078] Step S205: Execute the reverse transaction based on the obtained transaction data.
[0079] Step S206: Update the second persistent database based on the result of the reverse transaction.
[0080] Based on the methods described in steps S201 to S206 above, by setting up an in-memory database and querying the in-memory database or the first persistent database (source database) under preset conditions, instead of directly querying the second persistent database (target database), real-time processing of transaction data between databases can be achieved. This solves the problem of data latency at the business level (due to technical reasons, there is a data latency problem in the synchronization component, such as the 6-10 second data latency problem of OGG mentioned in the background technology; or due to technical needs (such as the need to add fields to the source and target databases mentioned in the background technology), the synchronization component needs to be disabled for a longer period of time, making it impossible for data to be synchronized from the source database to the target database). This avoids the business impact caused by data latency and improves the user experience.
[0081] The following provides further explanation of steps S201 to S206.
[0082] In one example of step S201 above, Figure 1 The positive transaction unit 101 shown responds to a positive transaction request by storing transaction data in an in-memory database 103 and a first persistent database 105, respectively. The in-memory database 103 can be Redis; the positive transaction is the payment; and the first persistent database 105 is the source database.
[0083] For example, when a user scans a QR code to pay at a shopping mall, the mall's POS system calls the transaction API to write the transaction data to both Redis and the source database. This transaction data includes transaction logs, such as transaction time, transaction amount, and transaction order number.
[0084] In another example, the first persistent database includes multiple sub-persistent databases, which are distinguished by different channels.
[0085] For example, channel 1 corresponds to sub-persistent database 1; channel 2 corresponds to sub-persistent database 2, and so on. Channels are used to transmit data to their respective databases. Therefore, the first persistent database at this time also includes channel information.
[0086] Furthermore, in one specific embodiment, storing transaction data in a first persistent database includes:
[0087] Nginx allows you to select one of several sub-persistent databases to store transaction data.
[0088] For example, transaction data can be stored by randomly selecting a sub-persistent database or by selecting sub-persistent databases in turn; no restrictions are imposed here.
[0089] The above is a further explanation of step S201. The following is a further explanation of step S202.
[0090] In one example of step S202 above, it can be achieved through... Figure 1 The synchronization component 104 shown synchronizes transaction data from the first persistent database 105 to the second persistent database 106. The synchronization component 104 can be an OGG database, the first persistent database 105 is the source database, and the second persistent database 106 is the target database.
[0091] For example, after a user scans a QR code to pay in a shopping mall, the source library synchronizes the transaction data to the target library via OGG.
[0092] The above is a further explanation of step S202. The following is a further explanation of step S203.
[0093] In one example of step S203 above, Figure 1 The reverse transaction unit 102 shown responds to the reverse transaction request by determining whether the difference between the time of the reverse transaction request and the time of the forward transaction request is less than a preset time. Here, the reverse transaction is a refund.
[0094] For example, when a shopping mall's POS terminal sends a reverse transaction request to the reverse transaction API, the reverse transaction unit 102 determines whether the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time, such as two days. The two-day setting takes into full account the fact that, for example, the source and target libraries need to add fields, which would cause the synchronization component to be idle for a long time (in practice, it usually takes two days to complete the work of adding fields to the source and target libraries). Those skilled in the art can set the preset time in specific scenarios according to the actual situation, and there is no limitation here.
[0095] The above is a further explanation of step S203. The following is a further explanation of step S204.
[0096] In one example of step S204 above, if the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time, then from Figure 1 Transaction data is retrieved from one of the in-memory database 103 and the first persistent database 105 shown.
[0097] Specifically, including:
[0098] Retrieve transaction data from memory database 103 based on the transaction order number;
[0099] If the transaction data is still retained in the in-memory database 103, the transaction data is retrieved from the in-memory database 103; otherwise, the transaction data is retrieved from the first persistent database 105.
[0100] For example, the gateway first queries Redis based on the original transaction order number. If the transaction information is still stored in Redis, the gateway returns the result to the anti-transaction unit. Upon receiving this result, the anti-transaction unit continues the process, accessing the UnionPay or NetsUnion interface to request a refund. However, since the Redis in-memory database is cleared of data after a certain period, if the query fails, it queries the source database and returns the result to the anti-transaction unit via the gateway. Upon receiving this result, the anti-transaction unit continues the process, accessing the UnionPay or NetsUnion interface to request a refund.
[0101] Furthermore, since the first persistent database includes multiple sub-persistent databases, in one specific embodiment, querying transaction data from the first persistent database to obtain transaction data includes:
[0102] Traverse all sub-persistent databases to obtain tunnel information;
[0103] The transaction data is obtained by storing the transaction data in the sub-persistent database based on the channel information.
[0104] For example, when the source database contains multiple sub-databases, Nginx selects one sub-database for storing transaction data. When retrieving transaction data, if the query fails, it first retrieves the channel information from the source database—that is, it iterates through all source databases to obtain the channel information. Then, it retrieves the transaction data from the corresponding sub-database. For instance, if the transaction data is transmitted to sub-database 2 via channel 2, then the transaction data will be retrieved from sub-database 2.
[0105] In another example of step S204 above, if the difference between the time of the reverse transaction request and the time of the positive transaction request is not less than a preset time, then from Figure 1 Transaction data is obtained from the second persistent database 106 shown. 。
[0106] That is, the anti-transaction unit directly queries and obtains transaction data based on OGG synchronization from the second persistent database.
[0107] The above is a further explanation of step S204. The following is a further explanation of step S205.
[0108] In one example of step S205 above, performing a reverse transaction based on the acquired transaction data includes:
[0109] Call the UnionPay or NetsUnion interface to execute the reverse transaction.
[0110] For example, Figure 1 After receiving the transaction data, the anti-transaction unit 102 shown accesses the UnionPay or NetsUnion interface and executes an anti-transaction request for a refund.
[0111] The above is a further explanation of step S205. The following is a further explanation of step S206.
[0112] In one example of step S206 above, if the second persistent database has already synchronized the transaction data, then the transaction data in the second persistent database is updated after the UnionPay or NetsUnion interface responds.
[0113] In another example, if the second persistent database has not yet synchronized the transaction data, the transaction status and amount corresponding to the reverse transaction will be stored in a temporary table after the UnionPay or NetsUnion interface responds.
[0114] For example, when a refund request is made within 6 seconds as described in the background technology, after UnionPay or NetsUnion responds, it returns the transaction status and amount to the reverse transaction unit, which stores the transaction status and amount information in a temporary table. The transaction status includes "refunded" and "cancelled," among others.
[0115] Furthermore, after detecting that the transaction data has been synchronized in the second persistent database, the transaction status and amount are retrieved from the temporary table based on the time and order number of the reverse transaction request, so as to update the transaction data in the second persistent database.
[0116] For example, the reverse transaction process can be stored in the batch processing system. After detecting that the target database has synchronized the transaction data, the batch processing system can retrieve the transaction status and amount information from the temporary table based on the time and order number, and update the data in the target database.
[0117] The above is a further explanation of step S206.
[0118] It should be noted that although the steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not necessarily have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are all within the scope of protection of the present invention.
[0119] Further, please refer to the appendix. Figure 1 The present invention also provides a transaction data processing system.
[0120] like Figure 1 As shown, in one embodiment, the transaction data processing system mainly includes a positive transaction unit 101, a negative transaction unit 102, a memory database 103, a synchronization component 104, a first persistent database 105, and a second persistent database 106.
[0121] In response to a positive transaction request, the positive transaction unit 101 stores the transaction data in the memory database 103 and the first persistent database 105, respectively.
[0122] Synchronization component 104 synchronizes transaction data in the first persistent database 105 to the second persistent database 106;
[0123] In response to the reverse transaction request, the reverse transaction unit 102 determines whether the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time;
[0124] Based on the judgment result, the anti-transaction unit 102 selectively obtains transaction data from one of the memory database 103 and the first persistent database 105, or obtains transaction data from the second persistent database 106;
[0125] The anti-transaction unit 102 performs anti-transactions based on the acquired transaction data; and the anti-transaction unit 102 updates the second persistent database 106 based on the result of the anti-transactions.
[0126] In one embodiment, the transaction data processing system further includes a gateway 107.
[0127] If the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time, the reverse transaction unit 102 accesses the gateway 107;
[0128] Gateway 107 retrieves transaction data from memory database 103 based on the transaction order number;
[0129] If the transaction data is still retained in the memory database 103, the gateway 107 retrieves the transaction data from the memory database 103 and returns it to the anti-transaction unit 102; otherwise, the gateway 107 queries the transaction data from the first persistent database 105 to obtain the transaction data and returns it to the anti-transaction unit 102.
[0130] In one embodiment, the transaction data processing system further includes Nginx108.
[0131] The first persistent database 105 includes multiple sub-persistent databases, which are distinguished by using different channels;
[0132] In response to a transaction request, Nginx108 selects one of several sub-persistent databases to store the transaction data.
[0133] Gateway 107 traverses all sub-persistent databases to obtain tunnel information;
[0134] Gateway 107 obtains the transaction data by acquiring the sub-persistent database where the transaction data is stored based on the channel information.
[0135] The aforementioned transaction data processing system is used for execution Figure 2 The transaction data processing method embodiments shown are similar in technical principle, the technical problems they solve, and the technical effects they produce. Those skilled in the art can clearly understand that, for the sake of convenience and brevity, the specific working process and related descriptions of the transaction data processing system can be referred to the content described in the embodiments of the transaction data processing method, and will not be repeated here.
[0136] Those skilled in the art will understand that all or part of the processes in the method of the above embodiment of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable file, or some intermediate form. The computer-readable storage medium can include any entity or device capable of carrying the computer program code, a medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory, a random access memory, an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0137] Furthermore, the present invention also provides an electronic device. (See appendix.) Figure 3 , Figure 3 This is a schematic diagram of the main structure of an electronic device according to an embodiment of the present invention. Figure 3 As shown, the electronic device in this embodiment of the invention mainly includes a processor 301 and a storage device 302. The storage device 302 can be configured to store a program for executing the transaction data processing method of the above-described method embodiment. The processor 301 can be configured to execute the program in the storage device 302, which includes, but is not limited to, a program for executing the transaction data processing method of the above-described method embodiment. For ease of explanation, only the parts related to the embodiments of the present invention are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of the present invention.
[0138] In some possible embodiments of the present invention, the electronic device may include multiple processors 301 and multiple storage devices 302. The program for processing transaction data according to the above method embodiments can be divided into multiple subroutines, each of which can be loaded and run by a processor 301 to perform different steps of the transaction data processing method of the above method embodiments. Specifically, each subroutine can be stored in different storage devices 302, and each processor 301 can be configured to execute programs in one or more storage devices 302 to jointly implement the transaction data processing method of the above method embodiments; that is, each processor 301 executes different steps of the transaction data processing method of the above method embodiments to jointly implement the transaction data processing method of the above method embodiments.
[0139] The aforementioned multiple processors 301 can be processors deployed on the same device. For example, the aforementioned electronic device can be a high-performance device composed of multiple processors, and the aforementioned multiple processors 301 can be processors configured on that high-performance device. Alternatively, the aforementioned multiple processors 301 can also be processors deployed on different devices. For example, the aforementioned electronic device can be a server cluster, and the aforementioned multiple processors 301 can be processors on different servers within the server cluster.
[0140] Furthermore, the present invention also provides a computer-readable storage medium. In one embodiment of the computer-readable storage medium according to the present invention, the computer-readable storage medium can be configured to store a program for performing the transaction data processing method of the above-described method embodiments. This program can be loaded and run by a processor to implement the above-described transaction data processing method. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention. The computer-readable storage medium can be a storage device device comprising various electronic devices. Optionally, in the embodiments of the present invention, the computer-readable storage medium is a non-transitory computer-readable storage medium.
[0141] The technical solution of the present invention has been described above with reference to one embodiment shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions resulting from such changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. A method for processing transaction data, characterized in that, The method includes: In response to the positive transaction request, the transaction data is stored in the in-memory database and the first persistent database respectively; Synchronize the transaction data in the first persistent database to the second persistent database; In response to a reverse transaction request, determine whether the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time. Based on the judgment result, the transaction data may be selectively obtained from either the in-memory database and the first persistent database or from the second persistent database; Execute a reverse transaction based on the acquired transaction data; and, Update the second persistent database based on the result of the reverse transaction; The step of selectively retrieving the transaction data from either the in-memory database or the first persistent database, or from the second persistent database, based on the determination result, includes: If the difference between the time of the reverse transaction request and the time of the positive transaction request is less than the preset time, the transaction data is obtained from one of the in-memory database and the first persistent database; And / or, If the difference between the time of the reverse transaction request and the time of the positive transaction request is not less than the preset time, the transaction data is retrieved from the second persistent database.
2. The method according to claim 1, characterized in that, The step of obtaining the transaction data from one of the in-memory database and the first persistent database includes: The transaction data is retrieved from the memory database based on the transaction order number; If the transaction data is still retained in the memory database, then the transaction data is retrieved from the memory database; otherwise, the transaction data is retrieved from the first persistent database.
3. The method according to claim 2, characterized in that, The first persistent database includes multiple sub-persistent databases, wherein the multiple sub-persistent databases are distinguished by using different channels; The step of storing transaction data in the first persistent database includes: selecting a sub-persistent database from the plurality of sub-persistent databases using Nginx to store the transaction data; The step of querying the transaction data from the first persistent database to obtain the transaction data includes: Traverse all sub-persistent databases to obtain tunnel information; The transaction data is obtained by obtaining the sub-persistent database in which the transaction data is stored based on the channel information.
4. The method according to claim 1, characterized in that, The step of executing the reverse transaction based on the obtained transaction data includes: calling the UnionPay or NetsUnion interface to execute the reverse transaction.
5. The method according to claim 4, characterized in that, The step of updating the second persistent database based on the result of the reverse transaction includes: If the second persistent database has already synchronized the transaction data, then after the UnionPay or NetsUnion interface responds, the transaction data in the second persistent database will be updated.
6. The method according to claim 4, characterized in that, The step of updating the second persistent database based on the result of the reverse transaction includes: If the second persistent database still fails to synchronize the transaction data, the transaction status and amount corresponding to the reverse transaction will be stored in a temporary table after the UnionPay or NetsUnion interface responds. After detecting that the transaction data has been synchronized in the second persistent database, the transaction status and amount are retrieved from the temporary table based on the time and order number of the reverse transaction request, so as to update the transaction data in the second persistent database.
7. A transaction data processing system, characterized in that, The system includes: The system comprises a positive transaction unit, a negative transaction unit, an in-memory database, a synchronization component, a first persistent database, and a second persistent database. In response to a positive transaction request, the positive transaction unit stores the transaction data in the memory database and the first persistent database, respectively; The synchronization component synchronizes the transaction data in the first persistent database to the second persistent database; In response to a reverse transaction request, the reverse transaction unit determines whether the difference between the time of the reverse transaction request and the time of the positive transaction request is less than a preset time. Based on the judgment result, the anti-transaction unit selectively obtains the transaction data from one of the in-memory database and the first persistent database, or from the second persistent database; The anti-transaction unit performs an anti-transaction based on the acquired transaction data; and, The anti-transaction unit updates the second persistent database based on the result of the anti-transaction; The step of selectively retrieving the transaction data from either the in-memory database or the first persistent database, or from the second persistent database, based on the judgment result, includes: If the difference between the time of the reverse transaction request and the time of the positive transaction request is less than the preset time, the transaction data is obtained from one of the in-memory database and the first persistent database; And / or, If the difference between the time of the reverse transaction request and the time of the positive transaction request is not less than the preset time, the transaction data is retrieved from the second persistent database.
8. The system according to claim 7, characterized in that, The system also includes a gateway, wherein, If the difference between the time of the reverse transaction request and the time of the positive transaction request is less than the preset time, the reverse transaction unit accesses the gateway; The gateway queries the transaction data from the memory database based on the transaction order number; If the transaction data is still retained in the memory database, the gateway retrieves the transaction data from the memory database and returns it to the anti-transaction unit; otherwise, the gateway queries the transaction data from the first persistent database to obtain the transaction data and returns it to the anti-transaction unit.
9. The system according to claim 8, characterized in that, The system also includes Nginx; The first persistent database includes multiple sub-persistent databases, wherein the multiple sub-persistent databases are distinguished by using different channels; In response to a positive transaction request, Nginx selects one of the plurality of sub-persistent databases to store the transaction data; The gateway traverses all sub-persistent databases to obtain channel information; The gateway obtains the transaction data by finding the sub-persistent database where the transaction data is stored based on the channel information.
10. An electronic device comprising a processor and a storage device, the storage device being adapted to store a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by the processor to perform the method of any one of claims 1 to 6.
11. A computer-readable storage medium storing a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by a processor to perform the method of any one of claims 1 to 6.
Citation Information
Patent Citations
Universal anti-transaction device, method and system for banks
CN110599330A
Transaction request processing system and method based on micro-service architecture
CN114881779A