Transaction processing method and apparatus applied to distributed system, device and medium
By acquiring and verifying account status information in a distributed system, the consistency of transaction information is ensured, thus solving the problem of inconsistent transaction results in a distributed system and achieving accuracy and efficiency in account balance changes.
Patent Information
- Application Number
- CN202210019138.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-07
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2042-01-07
AI Technical Summary
In a distributed system, it is difficult to maintain transaction consistency when the payer and payee are not on the same service node, especially during peak transaction periods when remote assistance is conducted over the network.
By obtaining the status information of the first account and the second account, information is sent to the first account after the preset conditions are met, and information is sent to the second account after receiving the transaction success processing result information, so as to ensure the change of account balance and avoid duplicate transaction processing by verifying status information.
This effectively avoids duplicate transaction processing, ensures the final consistency of unilateral transaction information processed by both accounts, and improves the accuracy and efficiency of transaction processing.
Smart Images

Figure CN114372792B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of big data, in particular to a transaction processing method and device applied to a distributed system, equipment, medium and program product. BACKGROUND
[0002] A transfer transaction is generally a unilateral transaction performed by a payer and a payee respectively. With the introduction of a distributed system, an application is split into multiple nodes and services that can be independently deployed, and therefore, in the distributed system, the payer and the payee are not necessarily on the same service node, and different nodes need to assist in completing the transaction operation remotely through the network. In a transaction peak, it is difficult to maintain the same consistency as a monolithic application. SUMMARY
[0003] In view of the above problems, the present disclosure provides a transaction processing method and device applied to a distributed system, equipment, medium and program product.
[0004] According to a first aspect of the present disclosure, a transaction processing method applied to a distributed system is provided, comprising:
[0005] In response to a transaction request instruction initiated by a first account end to a second account end, obtaining first state information of the first account end and second state information of the second account end;
[0006] In the case that the first state information and the second state information satisfy a preset condition, sending first information to the first account end, wherein the first information comprises the first state information and transaction amount information;
[0007] Receiving first processing result information, which is obtained by the first account end according to the transaction amount information in the case that the current state information of the first account end is the same as the first state information, and changing the balance information of the first account end;
[0008] In the case that the first processing result information is a transaction success, sending second information to the second account end, wherein the second information comprises the transaction amount information, so that the second account end changes the balance information of the second account according to the transaction amount information to obtain second processing result information.
[0009] According to an embodiment of the present disclosure, the first information and the second information both comprise transaction identification information, the transaction identification information is used to represent the transaction information in the request instruction, and the above-mentioned transaction processing method applied to the distributed system further comprises:
[0010] Recording the first processing result information and the transaction identification information in a transaction log of the first account end;
[0011] record the second processing result information and the transaction identification information in a transaction log of the second account end.
[0012] According to an embodiment of the present disclosure, the transaction processing method applied to the distributed system further includes:
[0013] In a case where the first processing result information is not received within a preset time, third information is sent to the first account end, wherein the third information includes first state information of the first account end, transaction amount information, transaction identification information, and a repetition mark;
[0014] The third processing result information is received, wherein the third processing result information is obtained by the first account end according to the transaction amount information in a case where the current state information of the first account end is the same as the first state information, and the transaction identification information does not exist in the transaction log of the first account end.
[0015] According to an embodiment of the present disclosure, the transaction processing method applied to the distributed system further includes: in a case where the current state information of the first account end is the same as the first state information, and the transaction identification information exists in the transaction log of the first account end, the first processing result information recorded in the transaction log of the first account end is received.
[0016] According to an embodiment of the present disclosure, the transaction processing method applied to the distributed system further includes:
[0017] In a case where the second processing result information is not received within a preset time, fourth information is sent to the second account end, wherein the fourth information includes transaction amount information, transaction identification information, and a repetition mark;
[0018] The fourth processing result information is received, wherein the fourth processing result information is obtained by the second account end according to the transaction amount information in a case where the transaction identification information does not exist in the transaction log of the second account end.
[0019] According to an embodiment of the present disclosure, the transaction processing method applied to the distributed system further includes:
[0020] In a case where the second processing result information is transaction failure, fifth information is sent to the first account end, wherein the fifth information includes transaction amount information;
[0021] The fifth processing result information is received, wherein the fifth processing result information is obtained by the first account end according to the transaction amount information and the balance information of the first account end.
[0022] According to an embodiment of the present disclosure, the preset condition comprises: the account status of the first account side and the second account side is normal; and the account balance of the first account side is greater than the transaction amount in the transaction request instruction.
[0023] A second aspect of the present disclosure provides a transaction processing device applied to a distributed system, comprising: a first acquisition module, a first sending module, a first receiving module and a second sending module. The first acquisition module is configured to acquire first state information of a first account side and second state information of a second account side in response to a transaction request instruction initiated by the first account side to the second account side. The first sending module is configured to send first information to the first account side in a case where the first state information and the second state information satisfy a preset condition, wherein the first information comprises the first state information and transaction amount information. The first receiving module is configured to receive first processing result information, which is obtained by the first account side according to the transaction amount information in a case where current state information of the first account side is the same as the first state information. The second sending module is configured to send second information to the second account side in a case where the first processing result information is a transaction success, wherein the second information comprises the transaction amount information, so that the second account side changes balance information of the second account according to the transaction amount information to obtain second processing result information.
[0024] According to an embodiment of the present disclosure, the transaction processing device applied to the distributed system further comprises: a first recording module and a second recording module. The first recording module is configured to record the first processing result information and transaction identification information in a transaction log of the first account side. The second recording module is configured to record the second processing result information and the transaction identification information in a transaction log of the second account side.
[0025] According to an embodiment of the present disclosure, the transaction processing device applied to the distributed system further comprises: a third sending module and a second receiving module. The third sending module is configured to send third information to the first account side in a case where the first processing result information is not received within a preset time, wherein the third information comprises the first state information of the first account side, the transaction amount information, the transaction identification information and a repetition mark. The second receiving module is configured to receive third processing result information, which is obtained by the first account side according to the transaction amount information in a case where the current state information of the first account side is the same as the first state information, and the transaction identification information does not exist in the transaction log of the first account side.
[0026] According to an embodiment of the present disclosure, the transaction processing apparatus applied to the distributed system further includes a third receiving module configured to receive the first processing result information recorded in the transaction log of the first account end, in a case that the current state information of the first account end is the same as the first state information, and the transaction identification information exists in the transaction log of the first account end.
[0027] According to an embodiment of the present disclosure, the transaction processing apparatus applied to the distributed system further includes a fourth sending module and a fourth receiving module. The fourth sending module is configured to send fourth information to the second account end in a case that the second processing result information is not received within a preset time, wherein the fourth information includes the transaction amount information, the transaction identification information and a repetition mark. The fourth receiving module is configured to receive the fourth processing result information, wherein the fourth processing result information is obtained by the second account end according to the transaction amount information in a case that the transaction identification information does not exist in the transaction log of the second account end.
[0028] According to an embodiment of the present disclosure, the transaction processing apparatus applied to the distributed system further includes a fifth sending module and a fifth receiving module. The fifth sending module is configured to send fifth information to the first account end in a case that the second processing result information is a transaction failure, wherein the fifth information includes the transaction amount information. The fifth receiving module is configured to receive the fifth processing result information, wherein the fifth processing result information is obtained by the first account end according to the transaction amount information and the balance information of the first account end.
[0029] A third aspect of the present disclosure provides an electronic device, including: one or more processors; a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the transaction processing method applied to the distributed system.
[0030] A fourth aspect of the present disclosure further provides a computer readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the transaction processing method applied to the distributed system.
[0031] A fifth aspect of the present disclosure further provides a computer program product including a computer program that, when executed by a processor, implements the transaction processing method applied to the distributed system.
[0032] According to the embodiment of the present disclosure, by acquiring the first state information of the first account side and the second state information of the second account side, in the case that the first state information and the second state information meet the preset condition, the first information is sent to the first account side, in the case that the transaction success processing result information fed back by the first account side is received, the second information is further sent to the second account side, so that the second account side changes the balance information of the second account according to the transaction amount information, and obtains the second processing result information. Through checking the state information of the first account side, the first information is further sent to the first account side, which can effectively avoid repeated processing of the transaction, and ensure the final consistency of the single transaction information processed by the two account sides. BRIEF DESCRIPTION OF DRAWINGS
[0033] The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure taken in conjunction with the accompanying drawings, in which:
[0034] Figure 1 An application scenario diagram of the transaction processing method, device, equipment, medium and program product applied to the distributed system according to the embodiment of the present disclosure is schematically shown;
[0035] Figure 2 A flowchart of the transaction processing method applied to the distributed system according to the embodiment of the present disclosure is schematically shown;
[0036] Figure 3 A logic block diagram of the transaction processing method applied to the distributed system according to the embodiment of the present disclosure is schematically shown;
[0037] Figure 4 An exemplary architecture of the distributed system applied to the transaction processing method according to the embodiment of the present disclosure is schematically shown;
[0038] Figure 5 An application scenario diagram of the embodiment of the present disclosure implemented in the same institution is schematically shown
[0039] Figure 6 An application scenario diagram of the embodiment of the present disclosure implemented in different institutions is schematically shown
[0040] Figure 7 A structure block diagram of the transaction processing device applied to the distributed system according to the embodiment of the present disclosure is schematically shown; and
[0041] Figure 8 A block diagram of an electronic device suitable for implementing the transaction processing method applied to the distributed system according to the embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0042] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood, however, that the description is merely exemplary and is not intended to limit the scope of the present disclosure. In the following detailed description of the embodiments, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the present disclosure. However, it would be apparent to those skilled in the art that the embodiments, or one or more embodiments, can be practiced without these specific details. In other instances, well-known structures and
[0043] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the present disclosure. As used herein, the term "including" "comprising" and the like are meant to be inclusive, but not limiting to the noted features, steps, operations and / or components.
[0044] All terms used herein, including technical and scientific terms, have the meanings commonly understood by one of ordinary skill in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted as having a meaning that is consistent with the context of the specification, and should not be interpreted in an idealized or overly formal way.
[0045] In the case of using expressions similar to "at least one of A, B, and C, etc.", it should generally be interpreted to include any of them, to include, for example, only A, only B, only C, A and B, A and C, B and C, and A and B and C, etc.
[0046] It should be noted that the transaction processing method and device for distributed systems of the present disclosure can be used in the financial field and the big data technology field, and can also be used in any field other than the financial field, and the application field of the transaction processing method and device for distributed systems of the present disclosure is not limited.
[0047] In the technical solutions of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information comply with relevant laws and regulations, necessary security measures are taken, and the public order and good customs are not violated.
[0048] In the technical solutions of the present disclosure, the authorization or consent of the user is obtained before the user personal information is acquired or collected.
[0049] Embodiments of the present disclosure provide a transaction processing method applied to a distributed system, which comprises the following steps: obtaining first state information of a first account end and second state information of a second account end; sending first information to the first account end when the first state information and the second state information meet preset conditions; sending second information to the second account end when the first account end feeds back transaction success processing result information, so that the second account end changes balance information of the second account according to transaction amount information to obtain second processing result information; and sending the first information to the first account end again by checking the state information of the first account end, so as to effectively avoid repeated processing of the transaction and ensure the final consistency of one-sided transaction information processed by the two account ends.
[0050] Figure 1 An application scenario diagram of the transaction processing method applied to the distributed system according to an embodiment of the present disclosure is schematically shown.
[0051] As shown in Figure 1 The application scenario 100 according to the embodiment can include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is a medium for providing a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0052] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0053] The terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers and desktop computers, etc.
[0054] The server 105 can be a server providing various services, such as a background management server supporting websites browsed by the user using the terminal devices 101, 102, 103 (only as an example). The background management server can analyze and process received user requests and other data, and feed back the processing results (such as web pages, information or data generated according to user requests, etc.) to the terminal devices.
[0055] It should be noted that the transaction processing method applied to the distributed system provided by the embodiments of the present disclosure can be generally executed by the server 105. Accordingly, the transaction processing apparatus applied to the distributed system provided by the embodiments of the present disclosure can be generally arranged in the server 105. The transaction processing method applied to the distributed system provided by the embodiments of the present disclosure can also be executed by a server or a server cluster different from the server 105 and capable of communicating with the terminal device 101, 102, 103 and / or the server 105. Accordingly, the transaction processing apparatus applied to the distributed system provided by the embodiments of the present disclosure can also be arranged in a server or a server cluster different from the server 105 and capable of communicating with the terminal device 101, 102, 103 and / or the server 105.
[0056] It should be understood that Figure 1 The number of terminal devices, networks and servers in the system is only illustrative. According to the needs of implementation, there can be any number of terminal devices, networks and servers.
[0057] The transaction processing method applied to the distributed system of the embodiments of the present disclosure will be described in detail based on the scenario described below. Figure 1 Figures 2-4 The transaction processing method applied to the distributed system of the embodiments of the present disclosure will be described in detail based on the scenario described below.
[0058] Figure 2 The flowchart of the transaction processing method applied to the distributed system according to the embodiments of the present disclosure is schematically shown.
[0059] As shown in Figure 2 The transaction processing method applied to the distributed system of the embodiments includes operations S210-S240.
[0060] In operation S210, in response to the transaction request instruction initiated by the first account end to the second account end, the first state information of the first account end and the second state information of the second account end are obtained.
[0061] In the embodiments of the present disclosure, the consent or authorization of the user can be obtained before the information of the user is obtained. For example, before operation S210, the user can be requested to obtain the user information. In the case where the user agrees or authorizes that the user information can be obtained, the operation S210 is executed.
[0062] According to the embodiments of the present disclosure, for example: the transaction request instruction initiated by the first account end to the second account end can be that the account A transfers 100,000 yuan to the account B. At this time, the first state information of the first account end account A obtained can include whether the account A exists, whether it is in a normal state and the balance state in the account A. The second state information of the second account end account B can include whether the account B exists, whether it is in a normal state and the balance state in the account B, etc.
[0063] In operation S220, the first information is sent to the first account end in a case where the first state information and the second state information satisfy a preset condition, wherein the first information comprises the first state information and the transaction amount information.
[0064] According to an embodiment of the present disclosure, for example: the first state information is that the account A exists and is normal, and the balance of the account A is 500,000 yuan. The second state information is that the account B exists and is normal, and the balance of the account B is 50,000 yuan. At this time, both the account A and the account B exist and are normal, and the balance of the account A is 500,000 yuan, which is greater than the transaction amount of 100,000 yuan. The first information can be sent to the first account end. The first information can include the state information of the account A: the account A exists and is normal, the balance of the account A is 500,000 yuan, and the account A deducts the transaction amount of 100,000 yuan.
[0065] According to an embodiment of the present disclosure, for example: the first state information is that the account A exists and is normal, and the balance of the account A is 50,000 yuan. The second state information is that the account B exists and is normal, and the balance of the account B is 50,000 yuan. At this time, the balance in the account A is less than the transaction balance of 100,000 yuan, which is insufficient to deduct the transaction amount, and the transaction fails.
[0066] In operation S230, the first processing result information is received, which is obtained by the first account end according to the transaction amount information in a case where the current state information of the first account end is the same as the first state information.
[0067] According to an embodiment of the present disclosure, for example: the current state information of the first account end is that the account A exists and is normal, and the balance is 500,000 yuan. Then, the current state information of the first account end is the same as the first state information, and the transaction amount of 100,000 yuan can be deducted from the account A. After the deduction, the balance information of the account A is 400,000 yuan. Then, the first processing result information received can be that the transaction is successful or the balance change is successful.
[0068] According to an embodiment of the present disclosure, for example: the current state information of the first account end is that the account A exists and is normal, and the balance is 300,000 yuan. Then, the current state information of the first account end is different from the first state information, and the balance change operation is not performed. Then, the first account end feeds back the processing result information that the transaction fails or the balance change is failed to the service end.
[0069] In operation S240, the second information is sent to the second account end in a case where the first processing result information is that the transaction is successful, wherein the second information comprises the transaction amount information, so that the second account end changes the balance information of the second account according to the transaction amount information to obtain the second processing result information.
[0070] According to an embodiment of the present disclosure, for example, in the case that the first processing result information is transaction success, the second information is sent to the second account end account B, the second information can be the transaction amount of 100,000 yuan transferred to the account B, and the second account end account B can increase the transaction amount of 100,000 yuan in the account B, and the balance information of the account B is changed to 150,000 yuan.
[0071] According to an embodiment of the present disclosure, by acquiring the first state information of the first account end and the second state information of the second account end, in the case that the first state information and the second state information satisfy the preset condition, the first information is sent to the first account end, and in the case that the transaction success processing result information fed back by the first account end is received, the second information is further sent to the second account end, so that the second account end changes the balance information of the second account according to the transaction amount information, and obtains the second processing result information. The technical means of checking the state information of the first account end and further sending the first information to the first account end can effectively avoid repeated processing of the transaction, and ensure the final consistency of the single transaction information processed by the two account ends.
[0072] According to an embodiment of the present disclosure, the first information and the second information both include transaction identification information, the transaction identification information is used to represent the transaction information in the request instruction, and further includes:
[0073] The first processing result information and the transaction identification information are recorded in the transaction log of the first account end;
[0074] The second processing result information and the transaction identification information are recorded in the transaction log of the second account end.
[0075] According to an embodiment of the present disclosure, for example, the transaction identification information can be identified by the hash value of the transaction information in the request instruction as a key value. In the case that the first processing result information and the second processing result information are both transaction success, the transaction log of the first account end can record <key, timestamp, success>; and the transaction log of the second account end can record <key, timestamp, success>. The transaction log can include time information of the transaction request instruction, which is used to distinguish different transactions with the same transaction information. The transaction identification information can also be used to distinguish different transactions with the same transaction information but different transaction times by using a hash algorithm.
[0076] According to an embodiment of the present disclosure, the processing results of the two account ends and the transaction identification information are recorded in the respective transaction logs, and whether the transaction has been processed can be identified by the transaction identification information, which can effectively avoid repeated processing or missed processing of the transaction.
[0077] According to an embodiment of the present disclosure, the transaction processing method applied to the distributed system further includes:
[0078] In a case where the first processing result information is not received within the preset time, third information is sent to the first account end, wherein the third information comprises first state information of the first account end, transaction amount information, transaction identification information and a repeat mark;
[0079] The third processing result information is received, wherein the third processing result information is obtained by the first account end according to the transaction amount information in a case where the current state information of the first account end is the same as the first state information and the transaction identification information does not exist in the transaction log of the first account end.
[0080] According to the embodiment of the present disclosure, due to communication problems such as network timeout, the service end does not receive the first processing result information fed back by the first account end within the preset time, and the third information can be sent to the first account end again. For example, the third information can comprise the first state information that the account A exists and is normal and the balance is 500,000 yuan, and the transaction amount information that the account A deducts 100,000 yuan, and further comprises the transaction identification information key value and the repeat mark repeat.
[0081] According to the embodiment of the present disclosure, when the first account end receives the third information with the repeat mark repeat, it is necessary to first check whether the current state of the first account end account A is the same as the first state information of the account A in the third information. If they are the same, it is further necessary to check whether the key value representing the transaction identification information exists in the transaction log of the first account end. If the key value does not exist, the transaction is processed, that is, according to the transaction amount information of 100,000 yuan, the balance information of the account A is changed from 500,000 yuan to 400,000 yuan.
[0082] According to the embodiment of the present disclosure, when the first account end receives the third information with the repeat mark repeat, if the current state of the first account end account A is not the same as the first state information in the third information, the transaction is processed as a new transaction.
[0083] According to the embodiment of the present disclosure, in a case where the current state information of the first account end is the same as the first state information, and the transaction identification information exists in the transaction log of the first account end, the first processing result information recorded in the transaction log of the first account end is received.
[0084] According to the embodiment of the present disclosure, for example, when the first account end receives the third information with the repeat mark repeat, if the current state of the first account end account A is the same as the first state information in the third information, and the key value representing the transaction identification information exists in the transaction log of the first account end. The service end is fed back with the transaction success and the processing result information recorded in the transaction log of the first account end, that is, the balance information of the account A is changed to 400,000 yuan.
[0085] According to the embodiments of the present disclosure, by checking the information with the repeat mark and the transaction identification information, the problem that the transaction information repeatedly sent by the server is repeatedly processed due to the network communication timeout feedback processing result to the server can be effectively avoided.
[0086] According to the embodiments of the present disclosure, in the case that the second processing result information is not received within the preset time, the fourth information is sent to the second account end, wherein the fourth information includes transaction amount information, transaction identification information and repeat mark;
[0087] The fourth processing result information is received, wherein the fourth processing result information is obtained by the second account end according to the transaction amount information in the case that the transaction identification information does not exist in the transaction log of the second account end.
[0088] According to the embodiments of the present disclosure, due to the network timeout and other communication problems, the server does not receive the second processing result information fed back by the second account end within the preset time, and the fourth information can be sent to the second account end again, for example: the fourth information can include the transaction amount information of 100,000 yuan transferred to account B, and also include the transaction identification information key value and repeat mark.
[0089] According to the embodiments of the present disclosure, when the second account end receives the fourth information sent by the server, it is necessary to check whether the key value representing the transaction identification information exists in the transaction log of the second account end, if not, continue to change the balance of account B, and change the balance of account B from 50,000 to 150,000.
[0090] According to the embodiments of the present disclosure, if the key value representing the transaction identification information exists in the transaction log of the second account end, it means that the transaction has been processed, and the second processing result information recorded in the transaction log can be fed back to the server.
[0091] According to the embodiments of the present disclosure, by checking the information with the repeat mark and the transaction identification information, the problem that the transaction information repeatedly sent by the server is repeatedly processed due to the network communication timeout feedback processing result to the server can be effectively avoided.
[0092] According to the embodiments of the present disclosure, in the case that the second processing result information is transaction failure, the fifth information is sent to the first account end, wherein the fifth information includes transaction amount information;
[0093] The fifth processing result information is received, wherein the fifth processing result information is obtained by the first account end according to the transaction amount information and the balance information of the first account end.
[0094] According to an embodiment of the present disclosure, for example, the second processing result information is a transaction failure, which generally occurs when the account B is cancelled in a short time, resulting in the failure of the account entry transaction of the second account side. When this occurs, the server sends the fifth information to the first account side to initiate a reverse transaction. The fifth information can include a transaction amount of 100,000 yuan transferred to the account A. The first account side changes the balance of the account A from 400,000 yuan to 500,000 yuan.
[0095] According to an embodiment of the present disclosure, by monitoring the transaction processing result of the second account side by the server, the reverse transaction is performed for the transaction failure of the second account side, and the amount deducted from the corresponding account of the first account side is returned in time, without affecting the performance of other transactions.
[0096] According to an embodiment of the present disclosure, the preset condition includes that the account status of the first account side and the second account side is normal, and the account balance of the first account side is greater than the transaction amount in the transaction request instruction.
[0097] According to an embodiment of the present disclosure, for example, the server receives a transaction request instruction that the account A pays 100,000 yuan to the account B, and determines whether to perform the transaction by obtaining the status information of the first account side and the second account side. If the account A is normal and the account B is cancelled, the preset condition is not met, and the server does not perform the transaction processing operation in the embodiment of the present disclosure. If the account A is normal and the account B is normal, but the account balance of the account A is 50,000 yuan, which is less than 100,000 yuan, the preset condition is not met, and the server does not perform the transaction processing operation in the embodiment of the present disclosure.
[0098] According to an embodiment of the present disclosure, by setting the preset condition, the account status involved in the transaction is queried and judged before the transaction processing is performed, which can effectively reduce the invalid transaction processing information sent by the server to the first account side or the second account side, and improve the timeliness of the transaction processing of the entire distributed system.
[0099] Figure 3 A logic block diagram of a transaction processing method applied to a distributed system according to an embodiment of the present disclosure is schematically shown.
[0100] As shown in Figure 3 , the embodiment includes operations S301-S310.
[0101] In operation S301, in response to the transaction request instruction initiated by the first account side to the second account side, the first status information of the first account side and the second status information of the second account side are obtained.
[0102] In operation S302, it is determined whether the first status information and the second status information meet the preset condition, if yes, operation S303 is performed; if not, operation S304 is performed.
[0103] In operation S303, the first processing result information is received. The first processing result information is obtained by the first account terminal changing the balance information of the first account terminal according to the transaction amount information, when the current status information and the first status information of the first account terminal are the same.
[0104] When operating S304, a transaction failure report is sent to the client.
[0105] In operation S305, the first processing result information is identified; if the first processing result information indicates that the transaction was successful, operation S306 is executed; if the first processing result information indicates that the transaction failed, operation S304 is executed.
[0106] In operation S306, second information is sent to the second account, including transaction amount information, so that the second account can change the balance information of the second account according to the transaction amount information and obtain the second processing result information;
[0107] In operation S307, the second processing result information is received and identified; if the second processing result information indicates a successful transaction, operation S308 is executed; if the second processing result information indicates a failed transaction, operations S304 and S309 are executed.
[0108] When operating S308, a successful transaction notification is sent to the client.
[0109] In operation S309, the fifth information is sent to the first account, which includes transaction amount information;
[0110] During operation S310, the fifth processing result information is received. This fifth processing result information is obtained from the first account based on the transaction amount information and the balance information of the first account.
[0111] Figure 4 The illustration schematically depicts an exemplary architecture of an application distributed system for a transaction processing method according to embodiments of the present disclosure.
[0112] like Figure 4 As shown, the distributed system 400 includes a client 401, a server 402, a first account terminal 403, and a second account terminal 404.
[0113] Client 401 initiates a transaction request from first account 403 to second account 404. After receiving the transaction request, server 402 obtains the status information of first account 403 and second account 404. The status information of first account 403 and second account 404 can be v respectively. a v b .
[0114] When the preset condition is met, the server 402 assembles transaction information according to the transaction request, and records the transaction log, for example: .
[0115] The key in the transaction log is used as the unique transaction identification information for identifying the transaction in the distributed system. The transaction information can be assembled into a transaction package:
[0116] .
[0117] Wherein, P represents the first account end, i.e. the payment account; Q represents the second account end, i.e. the receiving account.
[0118] The server 402 executes the transaction processing method applied to the distributed system of the embodiments of the present disclosure to process the transaction. For example, the first information is sent to the first account end: .
[0119] After receiving the transaction success information fed back by the first account end 403, the server 402 sends the second information to the second account end 404: .
[0120] After receiving the transaction success information fed back by the second account end 404, the server 402 feeds back the transaction success information to the client 401. If the transaction failure information fed back by the second account end 404 is received, the server 402 sends the reverse transaction information (fifth information) to the first account end 403, and feeds back the processing result of the first account end to the client 401.
[0121] According to the embodiments of the present disclosure, the transaction sub-ledger information recorded by the first account end 403 and the second account end 404 is shown in the following table:
[0122] Account Updating account balance Updating transaction log A B
[0123] Figure 5 The application scenario schematic diagram of the embodiments of the present disclosure implemented in the same institution is schematically shown;
[0124] As shown in Figure 5 , in the application scenario 500, the client 501, the server 502, the client group A 503, the client group B 504, and the client group C 505 are included.
[0125] Under the same institution, the clients can be grouped by account information, and a distributed system with node eventual consistency is established, and the accounts of the client group A 503, the client group B 504, and the client group C 505 do not interact.
[0126] Client 501 initiates a transfer transaction request between client group A503, client group B504, and client group C505. Server 502 executes the transaction processing method for distributed systems provided in this embodiment of the disclosure, and is responsible for sending transaction information to client group A503, client group B504, and client group C505 respectively and receiving information from client group A503, client group B504, and client group C505. Based on the final transaction processing result, it sends the transaction processing result information back to client 501.
[0127] Figure 6 The illustrations depict application scenarios of implementing embodiments of the present disclosure in different institutions;
[0128] like Figure 6 As shown, in this application scenario 600, there are server 601, customer A 602, customer B 603 and internal transition user 604.
[0129] Server 601 can process customer A602 and customer B603 respectively according to the transaction processing method for distributed systems provided in this embodiment of the present disclosure. When both customer A602 and customer B603 report successful transactions to server 601, server 601 sends a transaction information packet to internal intermediary 604.
[0130]
[0131] Based on the transaction amount information in the transaction information packet, internal transition account 604 is processed according to the eventual consistency algorithm to obtain the transaction ledger information of internal transition account 604 as shown in the table below:
[0132] Account Balance Debit occurrence Credit occurrence Updating transaction log C Unchanged x x
[0133] If the server does not receive feedback from internal transition user 604 within a preset time, it will resend the transaction packet with a duplicate tag to internal transition user 604. When internal transition user 604 receives the transaction packet with the duplicate tag, it queries the transaction log. If the key value from the transaction packet exists in the transaction log, it feeds back to the server 601 based on the result of the transaction log. If the key value from the transaction packet does not exist in the transaction log, it is processed according to the eventual consistency algorithm.
[0134] According to embodiments of this disclosure, the present invention can provide adaptive processing solutions for "one borrowing and one lending," "one borrowing and multiple lending," and "multiple borrowing and one lending" scenarios in transfer transactions. For example, in the "one borrowing and multiple lending" scenario, a second message can be sent concurrently to the receiving account after the unilateral transaction on the payment account. As for the "multiple borrowing and one lending" scenario, it can be decomposed into multiple "one borrowing and one lending" scenarios for processing.
[0135] Based on the above transaction processing method applied to the distributed system, the present disclosure further provides a transaction processing device applied to the distributed system. The following will be described in detail in combination with Figure 8 The device is described in detail.
[0136] Figure 7 The structure block diagram of the transaction processing device applied to the distributed system according to the embodiment of the present disclosure is schematically shown.
[0137] As Figure 7 shown, the transaction processing device 700 applied to the distributed system of the embodiment includes a first acquisition module 701, a first sending module 702, a first receiving module 703 and a second sending module 704.
[0138] The first acquisition module 701 is configured to acquire the first state information of the first account end and the second state information of the second account end in response to the transaction request instruction initiated by the first account end to the second account end.
[0139] The first sending module 702 is configured to send the first information to the first account end in the case that the first state information and the second state information meet the preset condition, wherein the first information includes the first state information and the transaction amount information.
[0140] The first receiving module 703 is configured to receive the first processing result information, which is obtained by the first account end according to the transaction amount information in the case that the current state information of the first account end is the same as the first state information.
[0141] The second sending module 704 is configured to send the second information to the second account end in the case that the first processing result information is transaction success, wherein the second information includes the transaction amount information, so that the second account end changes the balance information of the second account according to the transaction amount information to obtain the second processing result information.
[0142] According to the embodiment of the present disclosure, the above transaction processing device 700 applied to the distributed system further includes a first recording module and a second recording module. The first recording module is configured to record the first processing result information and the transaction identification information in the transaction log of the first account end, and the second recording module is configured to record the second processing result information and the transaction identification information in the transaction log of the second account end.
[0143] According to an embodiment of the present disclosure, the transaction processing apparatus 700 applied to the distributed system further comprises a third sending module and a second receiving module. The third sending module is configured to send third information to the first account end if the first processing result information is not received within a preset time, wherein the third information comprises first state information of the first account end, transaction amount information, transaction identifier information and a repeat mark. The second receiving module is configured to receive third processing result information, wherein the third processing result information is obtained by the first account end according to the transaction amount information if the current state information of the first account end is the same as the first state information and the transaction identifier information does not exist in the transaction log of the first account end.
[0144] According to an embodiment of the present disclosure, the transaction processing apparatus 700 applied to the distributed system further comprises a third receiving module. The third receiving module is configured to receive the first processing result information recorded in the transaction log of the first account end if the current state information of the first account end is the same as the first state information and the transaction identifier information exists in the transaction log of the first account end.
[0145] According to an embodiment of the present disclosure, the transaction processing apparatus 700 applied to the distributed system further comprises a fourth sending module and a fourth receiving module. The fourth sending module is configured to send fourth information to the second account end if the second processing result information is not received within a preset time, wherein the fourth information comprises transaction amount information, transaction identifier information and a repeat mark. The fourth receiving module is configured to receive fourth processing result information, wherein the fourth processing result information is obtained by the second account end according to the transaction amount information if the transaction identifier information does not exist in the transaction log of the second account end.
[0146] According to an embodiment of the present disclosure, the transaction processing apparatus 700 applied to the distributed system further comprises a fifth sending module and a fifth receiving module. The fifth sending module is configured to send fifth information to the first account end if the second processing result information is a transaction failure, wherein the fifth information comprises transaction amount information. The fifth receiving module is configured to receive fifth processing result information, wherein the fifth processing result information is obtained by the first account end according to the transaction amount information and the balance information of the first account end.
[0147] According to an embodiment of the present disclosure, any of the first obtaining module 701, the first sending module 702, the first receiving module 703 and the second sending module 704 can be combined in one module, or any of them can be split into multiple modules. Alternatively, at least part of the function of one or more of these modules can be combined with at least part of the function of the other modules, and implemented in one module. According to an embodiment of the present disclosure, at least one of the first obtaining module 701, the first sending module 702, the first receiving module 703 and the second sending module 704 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on chip, a system on board, a system on package, an application specific integrated circuit (ASIC), or any other reasonable way of hardware or firmware that can be integrated or packaged with a circuit, or implemented in any one of software, hardware and firmware or in a proper combination of any of them. Alternatively, at least one of the first obtaining module 701, the first sending module 702, the first receiving module 703 and the second sending module 704 can be at least partially implemented as a computer program module that can perform the corresponding function when it is run.
[0148] Figure 8 A block diagram of an electronic device suitable for implementing the transaction processing method applied to a distributed system according to an embodiment of the present disclosure is schematically shown.
[0149] As shown in Figure 8 The electronic device 800 according to an embodiment of the present disclosure includes a processor 801 that can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage portion 808 into a random access memory (RAM) 803. The processor 801 can include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset, and / or a special-purpose microprocessor (such as an application specific integrated circuit (ASIC)), and the like. The processor 801 can also include an on-board memory for cache use. The processor 801 can include a single processing unit or a plurality of processing units for performing different actions of the method processes according to an embodiment of the present disclosure.
[0150] In the RAM 803, various programs and data required for the operation of the electronic device 800 are stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other via the bus 804. The processor 801 performs various operations of the method flow according to the embodiments of the present disclosure by executing the programs in the ROM 802 and / or the RAM 803. It should be noted that the programs can also be stored in one or more memories other than the ROM 802 and the RAM 803. The processor 801 can also perform various operations of the method flow according to the embodiments of the present disclosure by executing the programs stored in the one or more memories.
[0151] According to an embodiment of the present disclosure, the electronic device 800 can further include an input / output (I / O) interface 805, which is also connected to the bus 804. The electronic device 800 can further include one or more of the following components connected to the I / O interface 805: an input part 806 including a keyboard, a mouse, etc.; an output part 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage part 808 including a hard disk, etc.; and a communication part 809 including a network interface card such as a LAN card, a modem, etc. The communication part 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is mounted on the drive 810 as necessary, so that a computer program read out therefrom is installed in the storage part 808 as necessary.
[0152] The present disclosure also provides a computer readable storage medium, which can be included in the device / apparatus / system described in the above embodiments; or can exist separately without being assembled into the device / apparatus / system. The above computer readable storage medium carries one or more programs, when the one or more programs are executed, the method according to the embodiments of the present disclosure is implemented.
[0153] According to an embodiment of the present disclosure, the computer readable storage medium can be a nonvolatile computer readable storage medium, for example, can include, but is not limited to, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this disclosure, a computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, the computer readable storage medium can include the ROM 802 and / or the RAM 803 described above and / or one or more memory other than the ROM 802 and the RAM 803.
[0154] Embodiments of the present disclosure also include a computer program product, which includes a computer program containing program codes for executing the methods shown in the flowcharts. When the computer program product is run in a computer system, the program codes are used to make the computer system implement the item recommendation method provided by the embodiments of the present disclosure.
[0155] The above functions defined in the system / device of the embodiments of the present disclosure are performed when the computer program is executed by the processor 801. According to an embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by computer program modules.
[0156] In one embodiment, the computer program can rely on tangible storage media such as optical storage media, magnetic storage media, etc. In another embodiment, the computer program can also be transmitted, distributed, and downloaded in the form of signals on a network medium, and be downloaded and installed through the communication part 809, and / or installed from the detachable medium 811. The program codes contained in the computer program can be transmitted by any appropriate network medium, including but not limited to wireless, wired, etc., or any suitable combination of the foregoing.
[0157] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the detachable medium 811. When the computer program is executed by the processor 801, the above functions defined in the system of the embodiments of the present disclosure are performed. According to an embodiment of the present disclosure, the system, device, apparatus, module, unit, etc. described above can be implemented by computer program modules.
[0158] According to embodiments of the present disclosure, program code of the computer program for performing the methods provided by the embodiments of the present disclosure can be written in any combination of one or more programming languages, and can be implemented in a computer program product. Specifically, the computer program can be implemented in a high-level procedural and / or object-oriented programming language, and / or in assembly / machine language. The programming language includes, but is not limited to, Java, C++, python, “C” language, or similar programming languages. The program code can execute entirely on the user's computing device, partly on the user's device, and partly on a remote computing device, or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, such as through the Internet using an Internet Service Provider (ISP).
[0159] The computer program product of the present disclosure can be a computer program product, which is a machine-readable medium (or computer readable medium) having stored therein a sequence of instructions readable by a machine (e.g., a computer). The instructions in the machine-readable medium focus on the function of the computer program (e.g., in the form of a computer program product). The instructions can be executed by one or more processors to produce a computer-implemented process, such as the one(s) described herein. The instructions can be stored in a computer memory, which can be a single memory or spread out over multiple memories. The machine-readable medium can be a magnetic or optical disk, a magnetic tape, a semiconductor memory, a computer disk, or any other suitable medium. The machine-readable medium can be loaded into the computer memory, or the computer memory can access the machine-readable medium through a connection, such as a communication network. The machine-readable medium can be a computer readable storage medium.
[0160] Those skilled in the art will understand that features of the various embodiments and / or claims of the present disclosure can be combined or / and integrated with one another, even though such a combination or integration is not expressly disclosed in the present disclosure. In particular, the features of the various embodiments and / or claims of the present disclosure can be combined or / and integrated with one another in any combination, without departing from the spirit and teachings of the present disclosure. All such combinations and / or integrations are within the scope of the present disclosure.
[0161] The above describes embodiments of the present disclosure. However, these embodiments are merely for illustrative purposes, and are not intended to limit the scope of the present disclosure. Although each embodiment is described above separately, this does not mean that the measures in each embodiment cannot be used advantageously in combination. The scope of the present disclosure is defined by the appended claims and their equivalents. Those skilled in the art can make various substitutions and modifications without departing from the scope of the present disclosure, and these substitutions and modifications should all fall within the scope of the present disclosure.
Claims
1. A transaction processing method applied to a distributed system, comprising: obtaining first state information of a first account end and second state information of a second account end in response to a transaction request instruction initiated by the first account end to the second account end; sending first information to the first account end in a case where the first state information and the second state information satisfy a preset condition, wherein the first information comprises the first state information and transaction amount information; receiving first processing result information, which is obtained by the first account end in a case where current state information of the first account end is the same as the first state information, according to the transaction amount information, and the current state information and the first state information both comprise whether an account exists, whether the account is in a normal state, and a current transaction balance state; sending second information to the second account end in a case where the first processing result information is transaction success, wherein the second information comprises the transaction amount information, so that the second account end changes balance information of the second account according to the transaction amount information to obtain second processing result information; sending third information to the first account end in a case where the first processing result information is not received within a preset time, wherein the third information comprises the first state information of the first account end, the transaction amount information, transaction identification information, and a repeat flag, and the transaction identification information is used to represent transaction information in the request instruction; receiving third processing result information, which is obtained by the first account end in a case where the current state information of the first account end is the same as the first state information and the transaction identification information does not exist in a transaction log of the first account end, according to the transaction amount information, and changing balance information of the first account end; sending fifth information to the first account end in a case where the second processing result information is transaction failure, so as to perform reverse transaction on a transaction in which the second account end fails to account, wherein the fifth information comprises the transaction amount information; receiving fifth processing result information, which is obtained by the first account end according to the transaction amount information and balance information of the first account end, so as to return the money deducted from the first account end in time. 2.The method of claim 1, wherein the first information and the second information both comprise transaction identification information, and the method further comprises: recording the first processing result information and the transaction identification information in a transaction log of the first account end; and recording the second processing result information and the transaction identification information in a transaction log of the second account end. 3.The method of claim 1, further comprising: In a case where the current state information of the first account side is the same as the first state information and the transaction identification information exists in the transaction log of the first account side, the first processing result information recorded in the transaction log of the first account side is received.
4. The method of claim 1, further comprising: in a case where the second processing result information is not received within a preset time, sending fourth information to the second account side, wherein the fourth information comprises the transaction amount information, the transaction identification information and the repetition mark; receiving fourth processing result information, wherein the fourth processing result information is obtained by the second account side from the transaction amount information in a case where the transaction identification information does not exist in the transaction log of the second account side.
5. The method of claim 1, wherein, The preset condition comprises: the account states of the first account side and the second account side are normal; the account balance of the first account side is greater than the transaction amount in the transaction request instruction.
6. A transaction processing apparatus applied to a distributed system, comprising: a first acquisition module, configured to acquire first state information of a first account side and second state information of a second account side in response to a transaction request instruction initiated by the first account side to the second account side; a first sending module, configured to send first information to the first account side in a case where the first state information and the second state information satisfy a preset condition, wherein the first information comprises the first state information and transaction amount information; a first receiving module, configured to receive first processing result information, wherein the first processing result information is obtained by the first account side from the transaction amount information in a case where current state information of the first account side is the same as the first state information; the current state information and the first state information both comprise whether an account exists, whether the account is in a normal state and a current transaction balance state; a second sending module, configured to send second information to the second account side in a case where the first processing result information is transaction success, wherein the second information comprises the transaction amount information, so that the second account side obtains second processing result information from the transaction amount information by changing the balance information of the second account; a third sending module, configured to send third information to the first account side in a case where the first processing result information is not received within a preset time, wherein the third information comprises the first state information of the first account side, the transaction amount information, transaction identification information and a repetition mark; the transaction identification information is used to represent transaction information in the request instruction. a second receiving module, configured to receive third processing result information, wherein the third processing result information is obtained by the first account end according to the transaction amount information when the current state information of the first account end is the same as the first state information and the transaction identifier information does not exist in the transaction log of the first account end, and the balance information of the first account end is changed; a fourth sending module, configured to send fifth information to the first account end to perform reverse transaction on the transaction of the second account end failing to be credited in a case that the second processing result information is transaction failure, wherein the fifth information comprises the transaction amount information; a third receiving module, configured to receive fifth processing result information, wherein the fifth processing result information is obtained by the first account end according to the transaction amount information and the balance information of the first account end, so as to return the money deducted from the account corresponding to the first account end in time. 7.An electronic device, comprising: one or more processors; a storage device configured to store one or more programs, wherein the one or more programs, when executed by the one or more processors, enable the one or more processors to perform the method according to any one of claims 1-5. 8.A computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the method according to any one of claims 1-5. 9.A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-5.
Citation Information
Patent Citations
Virtual account transfer method, device, system and storage medium
CN111062723A