Real-time balance processing method, device, storage medium and program product

By obtaining transaction data from message queues in the banking system and updating user account balances, the negative balance problem caused by data disorder is solved, and more reasonable balance statistics and higher data throughput are achieved.

CN114202424BActive Publication Date: 2025-05-30AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111574429.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-21
Publication Date
2025-05-30
Estimated Expiration
2041-12-21

AI Technical Summary

Technical Problem

In the banking system, due to the disorder of transaction data in the message queue, negative balance problems arise when stating user balances. The existing technology requires modification of extensive system configuration, increasing the workload of the data production system and limiting the data processing speed.

Method used

By obtaining transaction data to be counted from the message queue, obtaining the current user account balance and accumulated balance, and updating the account balance in the message queue that is not guaranteed to be sequential, ensuring that the balance is always greater than or equal to 0.

Benefits of technology

It realizes user balance statistics in message queues that do not guarantee sequence, makes the statistical results more reasonable, avoids outliers and system errors, reduces the scope of system modification and the complexity of data processing, and ensures data throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114202424B_ABST
    Figure CN114202424B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, storage medium and program product for real-time balance processing, which includes obtaining the transaction data to be counted of the target user from the message queue; obtaining the account balance and the cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each transaction data of the target user after receiving it, and the account balance is used for display and the account balance needs to be maintained greater than or equal to 0; updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, and outputting the updated account balance for display. When performing balance statistics on users based on a message queue that does not guarantee order, the statistical results are more reasonable, and there is no need to modify the data production system or message queue configuration to make the data order effective, which can avoid increasing the workload of the upstream data production system and also avoid restricting the downstream data processing speed, ensuring data throughput.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a method, device, storage medium, and program product for real-time balance processing. Background Art

[0002] In the banking system, in order to ensure the stability and timeliness of the core transaction system, large-scale transaction information statistics are generally not carried out in the core system. Instead, relevant transaction information is generally sent to the peripheral system through a message queue for real-time data processing. The message queue can send the real-time data of the upstream system to the consumer. However, due to network latency and other situations, the data cannot reach the consumption system in the order of the actual occurrence time, and the consumption system cannot determine the actual business occurrence time and can only perform data statistical processing according to the order of receiving the transaction data.

[0003] The disorder of transaction data often causes many problems. For example, in balance statistics, if a customer actually deposits money first and then transfers money, but the order of data consumption may be to transfer money first and then deposit money. This will cause the customer's deposit balance to be negative for a period of time when counting the customer's deposit, which should not exist in actual business. In the prior art, the data production system, message queue configuration, and data consumption system are usually modified to try to achieve effective data order.

[0004] However, the prior art has a wide range of modifications to the data production system, message queue configuration, and data consumption system, which is not conducive to the wide use of the message queue, increases the workload of the upstream data production system, and limits the downstream data processing speed and reduces the data throughput due to single-threaded data consumption. Summary of the Invention

[0005] This application provides a method, device, storage medium, and program product for real-time balance processing to perform balance statistics on users in a message queue without ensuring order, making the statistical results more reasonable.

[0006] In a first aspect, this application provides a method for real-time balance processing, including:

[0007] Obtaining the transaction data to be statistically processed of the target user from the message queue, where the transaction data to be statistically processed is sent to the message queue by the transaction system after the transaction data is generated;

[0008] Obtaining the account balance and cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data of the target user after receiving it, the account balance is used for display, and the account balance needs to be kept greater than or equal to 0;

[0009] Update the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, and output the updated account balance for display.

[0010] In an alternative design, the updating of the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted includes:

[0011] Cumulatively add or subtract the transaction amount of the transaction data to be counted based on the currently stored cumulative balance to obtain a temporary account balance;

[0012] Determine whether the temporary account balance is greater than or equal to 0;

[0013] If the temporary account balance is greater than or equal to 0, determine that the updated account balance is equal to the temporary account balance, and set the latest cumulative balance equal to the temporary account balance; or

[0014] If the temporary account balance is less than 0, determine that the updated account balance is equal to 0, and set the latest cumulative balance equal to the temporary account balance.

[0015] In an alternative design, the updating of the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted includes:

[0016] Cumulatively add or subtract the transaction amount of the transaction data to be counted based on the currently stored cumulative balance to obtain the latest cumulative balance;

[0017] Determine whether the latest cumulative balance is greater than or equal to 0;

[0018] If the latest cumulative balance is greater than or equal to 0, determine that the updated account balance is equal to the latest cumulative balance; or

[0019] If the latest cumulative balance is less than 0, determine that the updated account balance is equal to 0.

[0020] Based on any of the above designs, the cumulatively adding or subtracting the transaction amount of the transaction data to be counted based on the currently stored cumulative balance includes:

[0021] If the transaction data to be counted is transfer transaction data, add the transaction amount of the transaction data to be counted based on the currently stored cumulative balance; or

[0022] If the transaction data to be counted is withdrawal transaction data, subtract the transaction amount of the transaction data to be counted from the currently stored cumulative balance.

[0023] Based on any of the above designs, obtaining the account balance and cumulative balance of the target user currently stored in the acquisition system includes:

[0024] If the account balance and cumulative balance of the target user are not stored in the system, set the account balance and cumulative balance of the target user to 0.

[0025] Based on any of the above designs, obtaining the transaction data to be counted of the target user from the message queue includes:

[0026] Receiving the transaction data to be counted of the target user sent by the message queue according to the preset message subscription information.

[0027] In a second aspect, the present application provides a real-time balance processing device, including:

[0028] A communication module, configured to obtain the transaction data to be counted of the target user from the message queue, where the transaction data to be counted is sent to the message queue by the transaction system after the transaction data is generated;

[0029] A query module, configured to obtain the account balance and cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data of the target user after receiving it, the account balance is used for display, and the account balance needs to be maintained greater than or equal to 0;

[0030] A processing module, configured to update the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, and output the updated account balance for display.

[0031] In an alternative design, when the processing module updates the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, it is configured to:

[0032] Cumulatively add or subtract the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance to obtain a temporary account balance;

[0033] Judge whether the temporary account balance is greater than or equal to 0;

[0034] If the temporary account balance is greater than or equal to 0, determine that the updated account balance is equal to the temporary account balance, and set the latest cumulative balance equal to the temporary account balance; or

[0035] If the temporary account balance is less than 0, determine that the updated account balance is equal to 0, and set the latest cumulative balance equal to the temporary account balance.

[0036] In an alternative design, when updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, the processing module is configured to:

[0037] Cumulatively add or subtract the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance to obtain the latest cumulative balance;

[0038] Determine whether the latest cumulative balance is greater than or equal to 0;

[0039] If the latest cumulative balance is greater than or equal to 0, determine that the updated account balance is equal to the latest cumulative balance; or

[0040] If the latest cumulative balance is less than 0, determine that the updated account balance is equal to 0.

[0041] Based on any of the above designs, when cumulatively adding or subtracting the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance, the processing module is configured to:

[0042] If the transaction data to be counted is transfer transaction data, add the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance; or

[0043] If the transaction data to be counted is withdrawal transaction data, subtract the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance.

[0044] Based on any of the above designs, when the query module obtains the account balance and cumulative balance of the target user currently stored in the system, it is configured to:

[0045] If the account balance and cumulative balance of the target user are not stored in the system, set the account balance and cumulative balance of the target user to 0.

[0046] Based on any of the above designs, when the communication module obtains the transaction data to be counted of the target user from the message queue, it is configured to:

[0047] Receive the transaction data to be counted of the target user sent by the message queue according to the preset message subscription information.

[0048] In a third aspect, the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0049] The memory stores computer-executable instructions;

[0050] The processor executes the computer-executable instructions stored in the memory to implement the method as described in the first aspect.

[0051] Fourthly, the present application provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method as described in the first aspect when executed by a processor.

[0052] Fifthly, the present application provides a computer program product including a computer program, which implements the method as described in the first aspect when executed by a processor.

[0053] The real-time balance processing method, device, storage medium and program product provided by the present application obtain the to-be-statistic transaction data of the target user from the message queue, where the to-be-statistic transaction data is sent to the message queue by the transaction system after the transaction data is generated; obtain the account balance and the cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each transaction data received for the target user, and the account balance is used for display and needs to be kept greater than or equal to 0; update the account balance according to the currently stored cumulative balance and the transaction amount of the to-be-statistic transaction data, and output the updated account balance for display. This embodiment can perform the balance statistics of users based on a message queue that does not guarantee order, making the balance statistics result more reasonable, avoiding outliers caused by the order of receiving transaction data, avoiding system errors, not requiring modification of the data production system and message queue configuration to make the data order effective, avoiding increasing the workload of the upstream data production system, and also avoiding single-threaded data consumption and restricting the downstream data processing speed, thus ensuring the data throughput. Description of the Drawings

[0054] The drawings here are incorporated into the description and form a part of this description, showing embodiments consistent with the present application and used together with the description to explain the principles of the present application.

[0055] Figure 1 It is a schematic diagram of the application scenario of the real-time balance processing method provided by an embodiment of the present application;

[0056] Figure 2 It is a flowchart of the real-time balance processing method provided by an embodiment of the present application;

[0057] Figure 3 It is a flowchart of the real-time balance processing method provided by another embodiment of the present application;

[0058] Figure 4 It is a flowchart of the real-time balance processing method provided by another embodiment of the present application;

[0059] Figure 5 It is a structural diagram of the real-time balance processing device provided by an embodiment of the present application;

[0060] Figure 6 Structural diagram of an electronic device provided by an embodiment of the present application.

[0061] Through the above-mentioned drawings, specific embodiments of the present application have been shown, and more detailed descriptions will be provided hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed implementation manners

[0062] Here, exemplary embodiments will be described in detail, and examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0063] In the banking system, in order to ensure the stability and timeliness of the core transaction system, large-scale transaction information statistics are generally not performed in the core system. Generally, relevant transaction information is sent to the peripheral system through a message queue for real-time data processing. The message queue can send real-time data from the upstream system to the consumer. However, due to network latency and other situations, the data cannot reach the consumption system in the order of actual occurrence time. The consumption system cannot determine the actual business occurrence time and can only perform data statistical processing in the order of receiving transaction data.

[0064] The disorder of transaction data often causes many problems. For example, in balance statistics, if a customer actually deposits money first and then transfers money, but the order of data consumption may be to transfer money first and then deposit money. This will cause the customer's deposit balance to be negative for a period of time when counting the customer's deposit, which should not exist in actual business. For example, in deposit balance statistics, if a customer's deposit balance is 0, then the customer deposits money first and then transfers money, but the order in which the data reaches the statistical system may be to transfer money first and then deposit money. This will cause the customer's deposit balance to be negative for a period of time when counting the customer's deposit. Since overdrawing of the deposit balance is not allowed in some cases, it is not allowed for the deposit balance to be negative, and an error will occur.

[0065] Therefore, in the prior art, the data production system, message queue configuration, and data consumption system are usually modified to try to make the data order effective. By ensuring the effectiveness of the data order, the balance is prevented from being negative, so that the statistical result is accurate.

[0066] However, in the prior art, the modification ranges of the data production system, message queue configuration, and data consumption system are relatively wide, which is not conducive to the wide use of message queues, increases the workload of the upstream data production system, and limits the downstream data processing speed and reduces the data throughput due to single-threaded data consumption.

[0067] To solve the above technical problems, the present application performs the balance statistics of users based on a message queue that does not guarantee the order, making the balance statistics result more reasonable, avoiding outliers caused by the order of receiving transaction data, avoiding system errors, not requiring modification of the data production system and message queue configuration to make the data order effective, avoiding increasing the workload of the upstream data production system, and also avoiding single-threaded data consumption and limiting the downstream data processing speed, thus ensuring the data throughput. Specifically, obtain the transaction data to be statistically analyzed of the target user from the message queue, where the transaction data to be statistically analyzed is sent to the message queue by the transaction system after the transaction data is generated; obtain the account balance and cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each transaction data received for the target user, and the account balance is used for display and the account balance needs to be maintained greater than or equal to 0; update the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be statistically analyzed, and output the updated account balance for display.

[0068] The specific application scenario of the present application is as Figure 1 shown, including: a transaction system server 101, a message queue 102, and a statistical system server 103. The transaction system server 101 sends the transaction data to the message queue 102 immediately after the transaction data of the target user is generated, where the transaction data includes transfer-in transaction data or transfer-out transaction data. The statistical system server 103 obtains the transaction data to be statistically analyzed of the target user from the message queue 102, obtains the account balance and cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each transaction data received for the target user, and the account balance is used for display and the account balance needs to be maintained greater than or equal to 0; updates the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be statistically analyzed, and outputs the updated account balance for display.

[0069] Among them, a message queue is a way of inter - process communication or communication between different threads of the same process. The queue of software is used to process a series of inputs, usually from users. The message queue provides an asynchronous communication protocol. Each record in the queue contains detailed information, including the time of occurrence, the type of input device, and specific input parameters. That is to say, the sender and receiver of the message do not need to interact with the message queue simultaneously. The message will be saved in the queue until the receiver retrieves it.

[0070] The following uses specific embodiments to elaborate in detail on the technical solution of this application and how the technical solution of this application solves the above - mentioned technical problems. These several specific embodiments can be combined with each other. For the same or similar concepts or processes, they may not be repeated in some embodiments. The embodiments of this application will be described below in conjunction with the accompanying drawings.

[0071] Figure 2 It is a flowchart of the real - time balance processing method provided by the embodiment of this application. This embodiment provides a real - time balance processing method, and its execution entity is a statistical system server. The specific steps of this real - time balance processing method are as follows:

[0072] S201. Obtain the transaction data to be statistically processed of the target user from the message queue, where the transaction data to be statistically processed is sent to the message queue by the transaction system after the transaction data is generated.

[0073] In this embodiment, the transaction system sends the transaction data to the message queue immediately after the transaction data of the target user is generated. The transaction data includes incoming transaction data or outgoing transaction data. The incoming transaction data specifically includes, but is not limited to, deposit or transfer transaction data, and the outgoing transaction data includes, but is not limited to, withdrawal, transfer, or consumption transaction data.

[0074] The statistical system server can obtain the transaction data to be statistically processed of the target user from the transaction system. Optionally, the message queue can push data to the statistical system server through the publish - subscribe mode, that is, after receiving the transaction data to be statistically processed of the target user, the message queue sends the transaction data to be statistically processed of the target user to the statistical system server according to the preset message subscription information; or, the statistical system server can continuously read the transaction data to be statistically processed of the target user from the message queue.

[0075] In this embodiment, there is no mandatory requirement for the order of transaction data, and there is no restriction on the upstream data production system, the message queue, and the downstream data consumption system. Even in the case of network latency and other situations, resulting in the data not arriving at the message queue in the chronological order of actual occurrence, or not arriving at the statistical system server in the chronological order of actual occurrence, it does not affect the execution of the following steps of this embodiment.

[0076] S202. Obtain the account balance and cumulative balance of the target user currently stored in the system. The cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data received from the target user. The account balance is used for display and must be greater than or equal to 0.

[0077] In this embodiment, the system of the statistical system server stores the account balance and cumulative balance of the target user. The account balance of the target user is the account balance for display, which needs to be greater than or equal to 0, that is, there cannot be a negative number; while the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data received from the target user, and negative numbers are allowed. The change in the balance can be recorded based on the order of the transaction data.

[0078] In this embodiment, after receiving the transaction data to be statistically analyzed of the target user and before the transaction data to be statistically analyzed of the target user, the account balance and cumulative balance of the target user currently stored in the system can be obtained from the system of the statistical system server.

[0079] Specifically, in the system of the statistical system server, the account balance of the target user is associated and stored with the first identifier of the target user. For example, the first identifier is the user ID, and the cumulative balance is associated and stored with the second identifier of the target user. For example, the second identifier is the user ID + specific characters (such as user ID + 00). Therefore, the account balance and cumulative balance of the target user currently stored in the system can be queried respectively through the first identifier and the second identifier of the target user.

[0080] It should be noted that if the target user is a new user, the system of the statistical system server may not have the account balance and cumulative balance of the target user. Therefore, if the account balance and cumulative balance of the target user are not stored in the system, the account balance and cumulative balance of the target user can be set to 0.

[0081] S203. Update the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be statistically analyzed, and output the updated account balance for display.

[0082] In this embodiment, the transaction amount can be obtained from the transaction data to be statistically analyzed, and then the account balance can be updated based on the currently stored cumulative balance and the transaction amount of the transaction data to be statistically analyzed. Specifically, on the basis of the currently stored cumulative balance, the transaction amount of the transaction data to be statistically analyzed is cumulatively added or subtracted, and then the account balance is updated based on the result, and the updated account balance is made to be greater than or equal to 0. Finally, the updated account balance is output for display.

[0083] In an alternative embodiment, such as Figure 3As shown, updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted in S203 may specifically include:

[0084] S301. Cumulatively add or subtract the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance to obtain a temporary account balance;

[0085] S302. Determine whether the temporary account balance is greater than or equal to 0;

[0086] If it is greater than or equal to 0, execute S303; if it is less than 0, execute S304;

[0087] S303. If the temporary account balance is greater than or equal to 0, determine that the updated account balance is equal to the temporary account balance, and set the latest cumulative balance equal to the temporary account balance; or

[0088] S304. If the temporary account balance is less than 0, determine that the updated account balance is equal to 0, and set the latest cumulative balance equal to the temporary account balance.

[0089] In this embodiment, it is set that the account balance of the target user stored currently is S, the cumulative balance is X, and the transaction amount of the transaction data to be counted is T, where the transaction data to be counted can be transfer transaction data or withdrawal transaction data;

[0090] First, obtain the temporary account balance S' through the following formula:

[0091] For the transaction data to be counted being transfer transaction data, S' = X + T;

[0092] For the transaction data to be counted being withdrawal transaction data, S' = X - T;

[0093] Furthermore, determine whether the temporary account balance S' is greater than or equal to 0;

[0094] If S' ≥ 0, let the account balance be S = S', and the cumulative balance X = S';

[0095] If S' < 0, let the account balance be S = 0, and the cumulative balance X = S'.

[0096] In this embodiment, the cumulative balance X can record the change of the balance based on the order of the transaction data. When all the transaction data has been counted, the cumulative balance X can be equal to the real balance of the target user, and the account balance S is either equal to 0 or equal to the cumulative balance.

[0097] For example, for a new user, the account balance S = 0 and the cumulative balance X = 0. Suppose the user first transfers in 200, then transfers out 100, then transfers in 300, and then transfers out 200. The real change in the account balance is: 0 → 200 → 100 → 400 → 200; However, the statistical system server first receives the transaction data of transferring out 100, then receives the transaction data of transferring in 200, then receives the transaction data of transferring out 200, and then receives the transaction data of transferring in 300 again. Then, through the above process, it can be determined that the change in the cumulative balance X is: 0 → -100 → 100 → -100 → 200, and the change in the account balance S is: 0 → 0 → 100 → 0 → 200. Although the account balance S becomes 0 after processing the transaction data, the final balance after all data processing is equal to the real balance, and at the same time, it is ensured that the account balance S is always greater than or equal to 0 during the processing. When the account balance S is equal to 0, it can continue to wait for the processing of subsequent transaction data until all transaction data is finally processed.

[0098] In another alternative embodiment, as Figure 4 shown, updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted in S203 includes:

[0099] S401. Cumulatively add or subtract the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance to obtain the latest cumulative balance;

[0100] S402. Determine whether the latest cumulative balance is greater than or equal to 0;

[0101] S403. If the latest cumulative balance is greater than or equal to 0, determine that the updated account balance is equal to the latest cumulative balance; or

[0102] S404. If the latest cumulative balance is less than 0, determine that the updated account balance is equal to 0.

[0103] In this embodiment, it is set that the account balance of the target user currently stored is S, the cumulative balance is X, and the transaction amount of the transaction data to be counted is T. The transaction data to be counted can be transfer-in transaction data or transfer-out transaction data;

[0104] First, the latest cumulative balance X is obtained through the following formula:

[0105] For the transaction data to be counted being transfer-in transaction data, X = X + T;

[0106] For the transaction data to be counted being transfer-out transaction data, X = X – T;

[0107] Furthermore, determine whether the latest cumulative balance X is greater than or equal to 0;

[0108] If the latest cumulative balance X≥0, then set the account balance as S = S'.

[0109] If the latest cumulative balance X<0, then set the account balance as S = 0.

[0110] In this embodiment, the cumulative balance X can record the change of the balance based on the order of transaction data. When all transaction data are counted, the cumulative balance X can be equal to the real balance of the target user. The account balance S is either equal to 0 or equal to the cumulative balance. The change process of the cumulative balance X and the account balance S is the same as the example in the above embodiment, which will not be elaborated here. The difference from the above embodiment is that in this embodiment, it is not necessary to assign a value to the latest cumulative balance X additionally.

[0111] The real-time balance processing method provided in this embodiment obtains the transaction data to be counted of the target user from the message queue, where the transaction data to be counted is sent to the message queue by the transaction system after the transaction data is generated; obtains the account balance and the cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data received for the target user, and the account balance is used for display and the account balance needs to be kept greater than or equal to 0; updates the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, and outputs the updated account balance for display. This embodiment can perform the balance statistics of users based on the message queue that does not guarantee the order, making the balance statistics result more reasonable, avoiding the outliers caused by the order of receiving transaction data, avoiding system errors, not requiring modifying the data production system and the message queue configuration to make the data order effective, avoiding increasing the workload of the upstream data production system, and also avoiding single-threaded data consumption and restricting the downstream data processing speed, so as to ensure the data throughput.

[0112] Figure 5 This is the structural diagram of the real-time balance processing device provided in the embodiment of the present application. The real-time balance processing device provided in this embodiment can be set in the statistical system server and can execute the processing flow provided in the embodiment of the real-time balance processing method, such as Figure 5 As shown, the real-time balance processing device 500 includes: a communication module 501, a query module 502, and a processing module 503.

[0113] The communication module is used to obtain the transaction data to be counted of the target user from the message queue, where the transaction data to be counted is sent to the message queue by the transaction system after the transaction data is generated;

[0114] A query module for obtaining the account balance and the cumulative balance of the target user currently stored in the system, where the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data of the target user received, and the account balance is used for display and the account balance needs to be maintained greater than or equal to 0;

[0115] A processing module for updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, and outputting the updated account balance for display.

[0116] In an alternative embodiment, when the processing module updates the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, it is configured to:

[0117] Cumulatively add or subtract the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance to obtain a temporary account balance;

[0118] Determine whether the temporary account balance is greater than or equal to 0;

[0119] If the temporary account balance is greater than or equal to 0, determine that the updated account balance is equal to the temporary account balance, and set the latest cumulative balance equal to the temporary account balance; or

[0120] If the temporary account balance is less than 0, determine that the updated account balance is equal to 0, and set the latest cumulative balance equal to the temporary account balance.

[0121] In an alternative embodiment, when the processing module updates the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, it is configured to:

[0122] Cumulatively add or subtract the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance to obtain the latest cumulative balance;

[0123] Determine whether the latest cumulative balance is greater than or equal to 0;

[0124] If the latest cumulative balance is greater than or equal to 0, determine that the updated account balance is equal to the latest cumulative balance; or

[0125] If the latest cumulative balance is less than 0, determine that the updated account balance is equal to 0.

[0126] On the basis of any of the above embodiments, when the processing module cumulatively adds or subtracts the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance, it is configured to:

[0127] If the transaction data to be counted is incoming transaction data, add the transaction amount of the transaction data to be counted to the currently stored cumulative balance; or

[0128] If the transaction data to be counted is outgoing transaction data, subtract the transaction amount of the transaction data to be counted from the currently stored cumulative balance.

[0129] Based on any of the above embodiments, when the query module obtains the account balance and cumulative balance of the target user currently stored in the system, it is used for:

[0130] If the account balance and cumulative balance of the target user are not stored in the system, set the account balance and cumulative balance of the target user to 0.

[0131] Based on any of the above embodiments, when the communication module obtains the transaction data to be counted of the target user from the message queue, it is used for:

[0132] Receive the transaction data to be counted of the target user sent by the message queue according to the preset message subscription information.

[0133] The balance real-time processing device of the embodiments of the present application can be used to execute the technical solutions of the above method embodiments, and its implementation principles and technical effects are similar, which will not be elaborated here.

[0134] Figure 6 The hardware structure diagram of an electronic device provided by the embodiments of the present application is shown. As Figure 6 shown, the electronic device 600 is used to implement the operations corresponding to the electronic device in any of the above method embodiments. The electronic device 600 of this embodiment may include: a memory 601, a processor 602, and a communication interface 603.

[0135] The memory 601 is used to store computer programs. The memory 601 may include a high-speed random access memory (Random Access Memory, RAM), and may also include non-volatile storage (Non-Volatile Memory, NVM), such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk, or an optical disc, etc.

[0136] A processor 602 is configured to execute the computer programs stored in the memory to implement the methods in the above embodiments. For specific details, reference may be made to the relevant descriptions in the foregoing method embodiments. The processor 602 may be a Central Processing Unit (CPU), or may also be other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in combination with the present invention may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0137] Optionally, the memory 601 may be either independent or integrated with the processor 602. When the memory 601 is a device independent of the processor 602, the electronic device 600 may further include a bus. The bus is used to connect the memory 601 and the processor 602. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience in representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0138] A communication interface 603 is configured to transmit transaction data and output the account balance.

[0139] The electronic device provided in this embodiment can be used to execute the real-time balance processing method in the above embodiments. The implementation manners and technical effects are similar, and will not be elaborated herein.

[0140] In addition, this embodiment also provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the method described in the above embodiments.

[0141] In addition, this embodiment also provides a computer program product, including a computer program, and the computer program is executed by a processor to implement the method described in the above embodiments.

[0142] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the devices or units can be in electrical, mechanical or other forms.

[0143] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0144] In addition, in each embodiment of the embodiments of the present application, each functional unit can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware, or in the form of a combination of hardware and software functional units.

[0145] The above integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above software functional unit stored in a storage medium includes several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute some steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

[0146] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the device described above can refer to the corresponding process in the foregoing method embodiments and will not be elaborated here.

[0147] The above embodiments are only used to illustrate the technical solutions of the embodiments of the present application, and are not intended to limit them; although the embodiments of the present application have been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

[0148] Other embodiments of the present application will be readily apparent to those skilled in the art after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the present application are pointed out by the following claims.

[0149] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.

Claims

1. A real-time balance processing method for a statistical server, Characterized in that, It includes: Obtaining the transaction data to be statistically counted of the target user from the message queue, wherein the transaction data to be statistically counted is sent to the message queue by the transaction system after the transaction data is generated; the transaction data includes incoming transaction data or outgoing transaction data, the incoming transaction data includes deposit or transfer transaction data, and the outgoing transaction data includes withdrawal, transfer, or consumption transaction data; the message queue provides an asynchronous communication protocol, and the sender and receiver of the message do not need to interact with the message queue simultaneously, and the message will be saved in the queue until the receiver retrieves it; Obtaining the account balance and the cumulative balance of the target user currently stored in the system, wherein the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data of the target user after receiving it, the account balance is used for display, and the account balance needs to be maintained greater than or equal to 0; Updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be statistically counted, and outputting the updated account balance for display; The transaction data to be statistically counted includes first transaction data to be statistically counted and second transaction data to be statistically counted, the first transaction data to be statistically counted is generated before the second transaction data to be statistically counted, and the time when the statistical server receives the second transaction data to be statistically counted is before the time when it receives the first transaction data to be statistically counted; The step of updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be statistically counted includes: Updating the cumulative balance according to the currently stored cumulative balance and the second transaction data to be statistically counted; Updating the cumulative balance according to the updated cumulative balance and the first transaction data to be statistically counted; Determining the updated account balance according to the latest cumulative balance; The step of updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be statistically counted includes: Cumulatively adding or subtracting the transaction amount of the transaction data to be statistically counted on the basis of the currently stored cumulative balance to obtain a temporary account balance; Judging whether the temporary account balance is greater than or equal to 0; If the temporary account balance is greater than or equal to 0, determining that the updated account balance is equal to the temporary account balance, and setting the latest cumulative balance equal to the temporary account balance; or If the temporary account balance is less than 0, determining that the updated account balance is equal to 0, and setting the latest cumulative balance equal to the temporary account balance.

2. The method according to claim 1, Characterized in that, The step of cumulatively adding or subtracting the transaction amount of the transaction data to be statistically counted on the basis of the currently stored cumulative balance includes: If the transaction data to be statistically counted is incoming transaction data, adding the transaction amount of the transaction data to be statistically counted on the basis of the currently stored cumulative balance; or If the transaction data to be statistically counted is outgoing transaction data, subtracting the transaction amount of the transaction data to be statistically counted on the basis of the currently stored cumulative balance.

3. The method according to claim 1, Characterized in that, The obtaining of the account balance and the cumulative balance of the target user currently stored in the system includes: If the account balance and the cumulative balance of the target user are not stored in the system, set the account balance and the cumulative balance of the target user to 0.

4. The method according to claim 1, wherein, The obtaining of the transaction data to be counted of the target user from the message queue includes: Receiving the transaction data to be counted of the target user sent by the message queue according to the preset message subscription information.

5. A real-time balance processing device for a statistical server, wherein, It includes: A communication module for obtaining the transaction data to be counted of the target user from the message queue, wherein the transaction data to be counted is sent to the message queue by the transaction system after the transaction data is generated; the transaction data includes incoming transaction data or outgoing transaction data, the incoming transaction data includes deposit or transfer transaction data, and the outgoing transaction data includes withdrawal, transfer, or consumption transaction data; the message queue provides an asynchronous communication protocol, and the sender and receiver of the message do not need to interact with the message queue at the same time, and the message will be saved in the queue until the receiver retrieves it; A query module for obtaining the account balance and the cumulative balance of the target user currently stored in the system, wherein the cumulative balance is obtained by cumulatively adding or subtracting the transaction amount of each piece of transaction data of the target user; the account balance is used for display, and the account balance needs to be kept greater than or equal to 0; A processing module for updating the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, and outputting the updated account balance for display; The transaction data to be counted includes first transaction data to be counted and second transaction data to be counted, the first transaction data to be counted is generated before the second transaction data to be counted, and the time when the statistical server receives the second transaction data to be counted is earlier than the time when it receives the first transaction data to be counted; When the processing module updates the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, specifically: Updating the cumulative balance according to the currently stored cumulative balance and the second transaction data to be counted; Updating the cumulative balance according to the updated cumulative balance and the first data to be counted; Determining the updated account balance according to the latest cumulative balance; When the processing module updates the account balance according to the currently stored cumulative balance and the transaction amount of the transaction data to be counted, specifically: Cumulatively adding or subtracting the transaction amount of the transaction data to be counted on the basis of the currently stored cumulative balance to obtain a temporary account balance; Judging whether the temporary account balance is greater than or equal to 0; If the temporary account balance is greater than or equal to 0, determine that the updated account balance is equal to the temporary account balance, and set the latest cumulative balance to the temporary account balance; or If the temporary account balance is less than 0, determine that the updated account balance is equal to 0 and set the latest cumulative balance equal to the temporary account balance.

6. An electronic device, characterized in that, comprising: a processor and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1-4.

7. A computer-readable storage medium, characterized in that, the computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of claims 1-4.

8. A computer program product, characterized in that, comprising a computer program, and when the computer program is executed by a processor, it implements the method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Account checking method, device, equipment and system and computer readable storage medium

    CN110264328A

  • Transaction information processing method, apparatus and device, and storage medium

    CN111768293A