Limit processing method and device, computer equipment and storage medium
By clustering and processing quota consumption requests in batches, the problem of low information writing efficiency caused by the reduction of friend adding quota is solved, and more efficient information writing and processing is achieved.
Patent Information
- Application Number
- CN202410339761.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-22
- Publication Date
- 2025-09-23
AI Technical Summary
In the prior art, every time a user successfully adds a friend, the friend adding quota will be reduced, causing the entire table to be locked each time information is written, resulting in low information writing efficiency.
By obtaining the quota consumption request, determining the batch to which it belongs, clustering it, generating clusters, and using different processing threads to write the consumption information in batches into the corresponding batch consumption record table.
The processing efficiency of quota consumption requests and information writing efficiency have been improved, writing conflicts have been reduced, and processing speed has been increased.
Smart Images

Figure CN120692246A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a credit processing method, apparatus, computer equipment, and storage medium. Background Art
[0002] With the development of science and technology, users can add friends through instant messaging applications. To prevent users from adding friends without limit, users can obtain a friend addition quota. After that, each time the user adds a friend through the instant messaging application, the friend addition quota can be reduced accordingly.
[0003] Since the friend adding quota of the user will be reduced every time the user successfully adds a friend, the consumption of the friend adding quota can be recorded through the quota usage details table. The usage details of the friend adding quota can be recorded in the quota usage details table. When writing information to the quota usage details table, the entire table needs to be locked. Locking the entire table every time will result in low efficiency in information writing. Summary of the Invention
[0004] Based on this, it is necessary to provide a quota processing method, device, computer equipment, computer-readable storage medium and computer program product that can improve the efficiency of information writing in response to the above technical problems.
[0005] In a first aspect, the present application provides a credit processing method, the method comprising:
[0006] Obtaining at least one credit consumption request; the credit consumption request is a request for consuming a friend addition credit generated when adding a friend;
[0007] Determining the batch to which the friend adding credit requested to be consumed by each of the at least one credit consumption requests belongs; the friend adding credits obtained based on different credit acquisition orders belong to different batches;
[0008] Clustering the at least one credit consumption request according to the batch to which the friend added credit requested to be consumed belongs to obtain at least one cluster;
[0009] Determining a batch consumption record table corresponding to each of the at least one cluster;
[0010] Based on different processing threads, the consumption information of the quota consumption requests in different clusters is batch-written into the corresponding batch consumption record table.
[0011] In a second aspect, the present application further provides a credit processing device, the device comprising:
[0012] The acquisition module is used to acquire at least one credit consumption request; the credit consumption request is a request for consuming the friend addition credit generated when adding a friend.
[0013] A clustering module is used to determine the batch to which the friend-added credit requested by each of the at least one credit consumption requests belongs; the batches to which the friend-added credit obtained based on different credit acquisition orders belong are different; and according to the batch to which the friend-added credit requested by each of the at least one credit consumption requests belongs, the at least one credit consumption request is clustered to obtain at least one cluster cluster.
[0014] The batch writing module is used to determine the batch consumption record table corresponding to each of the at least one cluster; based on different processing threads, the consumption information of the quota consumption requests in different clusters is batch written into the corresponding batch consumption record table.
[0015] In one embodiment, the credit consumption request is a request for consuming the friend adding credit generated when adding a friend based on an organization account; the credit processing method is executed by a node in a server cluster, and credit consumption requests generated based on different organization accounts are routed to different nodes.
[0016] In one embodiment, the credit consumption request is a request for consuming the friend adding credit generated after the friend adding link is clicked; the friend adding link refers to a link generated based on the organizational account for jumping to the friend adding page of the instant messaging application; the friend adding page displays the communication application account to be added and the friend adding control specified based on the organizational account, and the friend adding control is used to add the communication application account to be added as a friend.
[0017] In one embodiment, the batch write module is also used to filter out the processing thread corresponding to the targeted cluster from the processing thread pool for each cluster in the at least one cluster; trigger the processing thread corresponding to the targeted cluster to determine the available amount under the batch corresponding to the targeted cluster according to the number of consumption information in the corresponding batch consumption record table, and determine the target amount consumption request in the targeted cluster based on the available amount under the batch corresponding to the targeted cluster, and write the consumption information of each target amount consumption request in batches into the batch consumption record table corresponding to the targeted cluster.
[0018] In one embodiment, the batch write module is also used to determine the total amount under the batch corresponding to the targeted cluster; read the total amount of consumption information from the batch consumption record table corresponding to the targeted cluster; subtract the total amount of consumption information from the total amount under the batch corresponding to the targeted cluster to obtain the available amount under the batch corresponding to the targeted cluster.
[0019] In one embodiment, the batch write module is also used to determine the number of credit consumption requests in the targeted cluster; when the number of requests is greater than the available credit, the available credit target credit consumption requests are filtered out from the targeted cluster; when the number of requests is less than or equal to the available credit, each credit consumption request in the targeted cluster is used as a target credit consumption request.
[0020] In one embodiment, the batch write module is also used to add a new transaction line in the batch consumption record table corresponding to the targeted cluster for each target quota consumption request, and record the consumption information and the preset first status character of the targeted target quota consumption request in the newly added transaction line; when it is determined that the friend adding behavior corresponding to the targeted target quota consumption request is successful, the first status character in the newly added transaction line is changed to a preset second status character; wherein, the second status character is used to trigger the writing of the consumption information of the targeted target quota consumption request into the quota consumption summary table.
[0021] In one embodiment, the batch consumption record table corresponding to the targeted cluster cluster records the total amount of consumption information, and the batch write module is also used to delete the consumption information of the targeted target quota consumption request from the batch consumption record table corresponding to the targeted cluster cluster when it is determined that the friend adding behavior corresponding to the targeted target quota consumption request fails; and update the total amount of consumption information in the batch consumption record table corresponding to the targeted cluster cluster.
[0022] In one embodiment, the batch write module is also used to add a version lock to the batch consumption record table corresponding to the targeted cluster cluster when the version lock is not added to the batch consumption record table corresponding to the targeted cluster cluster; batch write the consumption information of each target amount consumption request into the batch consumption record table corresponding to the targeted cluster cluster to which the version lock is added; after writing the consumption information into the batch consumption record table, release the version lock of the batch consumption record table corresponding to the targeted cluster cluster, and update the version number of the batch consumption record table corresponding to the targeted cluster cluster a preset number of times.
[0023] In one embodiment, the credit processing device also includes a credit acquisition module, which is used to obtain a credit account object when a credit acquisition order is received; the credit account object includes an available batch table and a total credit table; a new batch row is added to the available batch table, and a batch corresponding to the credit acquisition order is generated; in the newly added batch row, the order information and batch corresponding to the credit acquisition order are written; and the information in the total credit table is updated according to the order information in the newly added batch row.
[0024] In one embodiment, the credit processing device also includes a credit acquisition module, which is used to add a version lock to the credit account object when the version lock is not added to the credit account object, and add a new batch row to the available batch table of the credit account object with the version lock added; after the order information and batch corresponding to the credit acquisition order are written into the available batch table, the version lock of the credit account object is released, and the version number of the credit account object is updated.
[0025] In one embodiment, the credit limit processing device also includes an expiration determination module for obtaining a credit limit account object; the credit limit account object includes an available batch table and a total credit limit table; for each batch in the available batch table, when it is determined that the targeted batch has expired based on the credit limit expiration time of the targeted batch, the status of the targeted batch is set to an expired state, the available credit limit in the total credit limit table is updated, and the version number of the credit limit account object is updated.
[0026] In a third aspect, the present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of any one of the credit limit processing methods provided in the embodiments of the present application are implemented.
[0027] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps in any one of the credit limit processing methods provided in the embodiments of the present application are implemented.
[0028] In a fifth aspect, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the steps of any credit processing method provided in the embodiments of the present application.
[0029] The above-mentioned credit processing method, device, computer equipment, storage medium and computer program product, by obtaining at least one credit consumption request, can cluster each credit consumption request according to the batch to which the credit consumed by each credit consumption request belongs, and obtain at least one cluster cluster. By determining the processing thread corresponding to each cluster cluster, different cluster clusters can be distributed to different processing threads, so that different processing threads can process different cluster clusters synchronously, thereby improving the processing efficiency of credit consumption requests and further improving the efficiency of information writing. For each processing thread, since the credit consumption requests in the cluster cluster correspond to the same batch, the processing thread can batch process the credit consumption requests in the cluster cluster to batch write the consumption information of the credit consumption requests in the cluster cluster into the batch consumption record table. Compared with processing each credit consumption request separately, batch processing can further improve the efficiency of information writing. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A diagram showing an application environment of a credit limit processing method in one embodiment;
[0031] Figure 2 1. A flowchart of a method for processing a credit limit in one embodiment;
[0032] Figure 3 A schematic diagram of obtaining a friend's credit limit in one embodiment;
[0033] Figure 4 A schematic diagram of generating clusters in one embodiment;
[0034] Figure 5 A schematic diagram of a quota consumption related table in one embodiment;
[0035] Figure 6 A schematic diagram of cluster distribution in one embodiment;
[0036] Figure 7 This is an overall schematic diagram of batch writing of consumption information in one embodiment;
[0037] Figure 8 A schematic diagram of the overall process of adding a friend in one embodiment;
[0038] Figure 9 A schematic diagram of the overall process of adding a friend in one embodiment;
[0039] Figure 10 A schematic diagram of a friend adding details page in one embodiment;
[0040] Figure 11 A schematic diagram of writing a batch consumption record table in one embodiment;
[0041] Figure 12 A schematic diagram of writing a total flow meter for quota consumption in one embodiment;
[0042] Figure 13 A flowchart of a credit limit processing method in a specific embodiment is shown;
[0043] Figure 14 This is a structural block diagram of a credit limit processing device in one embodiment;
[0044] Figure 15 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0046] The credit processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other servers. Both the terminal 102 and the server 104 can be used separately to execute the credit processing method provided in the embodiment of the present application. The terminal 102 and the server 104 can also be used together to execute the credit processing method provided in the embodiment of the present application. Taking the example that the terminal 102 and the server 104 can be used together to execute the credit processing method provided in the embodiment of the present application, an instant messaging application is running in the terminal 102. Users can share a friend adding link through the instant messaging application. When others click on the friend adding link to add friends, the server 104 can receive a credit consumption request. The server 104 processes the credit consumption request to write the consumption information of the credit consumption request into the batch consumption record table.
[0047] Among them, the terminal 102 can be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers. For example, the server 104 can be specifically a server cluster, which includes multiple servers, each server is a node, and each node can be used to receive credit consumption requests associated with the same organizational account and batch process the received credit consumption requests.
[0048] It should be noted that the terms "first", "second" and similar terms used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. Unless the context clearly indicates otherwise, the singular form "a", "an" or "the" and similar terms do not indicate a quantity limitation, but rather indicate the presence of at least one. The quantities of "multiple" or "multiple copies" mentioned in the various embodiments of this application refer to the quantity of "at least two", for example, "multiple" refers to "at least two" and "multiple copies" refers to "at least two copies".
[0049] In one embodiment, Figure 2 As shown, a quota processing method is provided, which is applied to Figure 1 The following steps are used as an example to illustrate the nodes in the server cluster:
[0050] Step 202: Obtain at least one credit consumption request. A credit consumption request is a request generated when adding a friend and used to consume the friend adding credit.
[0051] Step 204 , determining the batch to which the friend adding quota consumed by each of the at least one quota consumption requests belongs; the friend adding quotas obtained based on different quota acquisition orders belong to different batches.
[0052] Here, a quota refers to a restricted or specified quantity, range, or limit. For example, when the quota is 100, the specified quantity can be considered to be 100. A friend-adding quota refers to a limit or regulation on the number of friend additions. The friend-adding quota can be obtained through a quota acquisition order. For example, when a node in a server cluster obtains a quota acquisition order, and the quota acquisition order indicates that User A's friend-adding quota should be increased by 100, the node may grant User A a friend-adding quota of 100. A quota consumption request refers to a request to consume the friend-adding quota. Quota consumption refers to an operation that reduces the available quota. For example, a quota consumption request can be used to reduce User A's available quota from 100 to 99. It is easy to understand that the friend-adding quota obtained through a quota acquisition order can be the total quota for a particular batch. After a period of friend addition, the consumed friend-adding quota is generated. The total quota for a particular batch minus the consumed friend-adding quota is the available quota for that batch.
[0053] The credits obtained through different credit acquisition orders belong to different batches. For example, the 100 friend-adding credits obtained through credit acquisition order 1 belong to the first batch, while the 100 friend-adding credits obtained through credit acquisition order 2 belong to the second batch.
[0054] Specifically, when a node in a server cluster obtains at least one credit consumption request within a preset time period, for each credit consumption request in the at least one credit consumption request, the current node can determine the batch to which the credit consumed by each credit consumption request belongs. For example, for the credit consumption request in question, the credit consumption request in question may carry batch information, so that the current node can determine the batch to which the friend adding credit consumed by the credit consumption request in question belongs based on the batch information. Exemplarily, when the credit consumption request in question carries the batch information "first batch", it is determined that the batch to which the friend adding credit consumed by the credit consumption request in question belongs is "first batch".
[0055] In one embodiment, the credit consumption request is a request to consume the friend adding credit owned by the user. In order to avoid unlimited friend adding, a friend adding credit can be set. Before consuming the friend adding credit owned by the user, the user can obtain the friend adding credit through the credit acquisition application. When the user obtains the friend adding credit, the credit acquisition application can set a batch for the friend adding credit obtained by the user. For example, refer to Figure 3 When user A wishes to obtain a friend credit, they trigger the credit acquisition application to generate a credit order. The credit acquisition application then sends the credit order to a node in the server cluster. After the node receives the credit order, it parses it to obtain the friend credit that user A can obtain (for example, credit: 100) and their account ID (for example, an organization account).
[0056] Furthermore, the current node can obtain a credit account object corresponding to user A's account ID. The credit account object includes an available batch table. The current node can record the credit acquisition order information and the batch corresponding to the credit acquisition order in the available batch order. For example, the current node can generate batch information based on the credit acquisition order creation time and user A's account ID, add a new batch row to the available batch table, and write the batch information (e.g., Batch: 102) and the friend-adding credit that user A can obtain as recorded in the credit acquisition order (e.g., Friend-adding Credit: 100) into the newly added batch row in the available batch table. The credit account object also includes a total credit table, which records the total credit, available credit, expired credit, and consumed credit. The total credit refers to the total friend-adding credit obtained by the current user up to that point (i.e., the sum of the credits in each batch). The available credit refers to the total friend-adding credit available to the current user. The expired credit refers to the friend-adding credit that has expired (i.e., cannot be used) up to that point. The total consumed credit refers to the credit that the current user has consumed up to that point. Furthermore, when the current node writes information to the newly added batch row, it can also update the information recorded in the total credit table. For example, based on the total credit recorded in the total credit table, it can increase the credit that user A can obtain by adding friends as recorded in the credit acquisition order; and based on the total available credit recorded in the total credit table, it can increase the credit that user A can obtain by adding friends as recorded in the credit acquisition order. Figure 3 A schematic diagram illustrating obtaining a friend add credit limit in one embodiment is shown. It is easy to understand that after the order information of the credit limit acquisition order and the batch to which the credit limit acquisition order applies are added to the available batch table corresponding to user A's account ID, and the total credit limit table corresponding to user A's account ID is updated based on the credit limit acquisition order, it can be considered that user A has obtained the friend add credit limit based on the credit limit acquisition order.
[0057] In one embodiment, once a user has obtained a friend-adding quota, they can use the obtained friend-adding quota. For example, if user A has 100 friend-adding quota from the first batch, user A can create a friend-adding link and add friends through the friend-adding link. Each time user A adds a friend through the friend-adding link, the available quota decreases by one. For example, the available quota of 100 from the first batch can be reduced to 99. The decrease in available quota is considered to be the user's consumption of the friend-adding quota.
[0058] In one embodiment, when a user shares a friend-adding link and others add friends through the friend-adding link, the nodes in the server cluster can obtain the credit consumption request corresponding to the friend-adding behavior, and then the current node can process the credit consumption request to consume the available credit of the user.
[0059] In one embodiment, the created friend adding link may include batch information, and then, the batch to which the friend adding quota to be consumed belongs may be determined based on the batch information in the friend adding link. For example, when user A has 100 friend adding quotas belonging to the first batch, and expects to consume the friend adding quota of the first batch, the friend adding link created by user A through the quota acquisition application may include batch information: "first batch", and then, when others add friends through the friend link shared by user A, the friend adding quota that is consumed is the friend adding quota belonging to the first batch. When user A also has 200 friend adding quotas belonging to the second batch, and the friend adding link created by user A through the quota acquisition application includes batch information: "second batch", if others add friends through the friend link, the friend adding quota belonging to the second batch is consumed.
[0060] In one embodiment, the credit consumption request is a request for consuming the friend adding credit generated when adding a friend based on an organizational account; the credit processing method is executed by a node in a server cluster, and credit consumption requests generated based on different organizational accounts are routed to different nodes.
[0061] Specifically, when others add friends through the friend-adding link, the terminals of other people can generate a credit consumption request based on the batch information in the friend-adding link and the identifier of the user who created the friend-adding link. The identifier of the user who created the friend-adding link can specifically be an organizational account. An organizational account refers to an account created by an organization. For example, an organizational account can be an instant messaging account of an enterprise. Enterprise managers can create a friend-adding link through the organizational account, so that the credit consumption request generated based on the friend-adding link is related to the organizational account. For example, when an enterprise manager creates a friend-adding link through an organizational account A, and another person clicks on the friend-adding link shared by the enterprise manager, the terminal of the other person can generate a credit consumption request A based on the organizational account A. Therefore, the credit consumption request A is related to the organizational account A.
[0062] Furthermore, other users' terminals can route credit consumption requests to corresponding nodes in the server cluster based on the organizational account. For example, in the example above, another user's terminal can send credit consumption request A to the node corresponding to organizational account A in the server cluster. As a result, all credit consumption requests received by the node corresponding to organizational account A are credit consumption requests generated based on organizational account A. In other words, credit consumption requests generated by the same organizational account are routed to the same node.
[0063] By routing quota consumption requests generated based on the same organizational account to the same node, the node can batch process the quota consumption requests with the same characteristics, thereby improving the processing efficiency of the quota consumption requests.
[0064] Step 206: Cluster the at least one credit consumption request according to the batch to which the friend added credit requested by each credit consumption request belongs, to obtain at least one cluster.
[0065] Specifically, when the current node obtains at least one credit consumption request and determines the batch to which the friend adding credit consumed by each credit consumption request belongs, the current node can cluster the at least one credit consumption request according to the batch to which the friend adding credit consumed by each credit consumption request belongs, and obtain at least one cluster. For example, referring to Figure 4 , when at least one credit consumption request includes credit consumption request 1, credit consumption request 2, credit consumption request 3 and credit consumption request 4, and it is determined that the friend adding credit requested to be consumed by credit consumption request 1 belongs to the first batch, the friend adding credit requested to be consumed by credit consumption request 2 belongs to the second batch, the friend adding credit requested to be consumed by credit consumption request 3 belongs to the first batch, and the friend adding credit requested to be consumed by credit consumption request 4 belongs to the second batch, then credit consumption request 1 and credit consumption request 3 are clustered as one, and credit consumption request 2 and credit consumption request 4 are clustered as another. Figure 4 A schematic diagram of generating clusters in one embodiment is shown.
[0066] In one embodiment, since the credit consumption request carries batch information, each credit consumption request can be clustered according to the batch information carried by the credit consumption request, and the credit consumption requests carrying the same batch information can be grouped as a cluster.
[0067] Step 208: Determine a batch consumption record table corresponding to at least one cluster.
[0068] Specifically, for each cluster in at least one cluster, the current node determines the batch consumption record table corresponding to the targeted cluster based on the batch corresponding to the targeted cluster. For example, because the batch information carried by the quota consumption requests in the targeted clusters is the same, the batch consumption record table corresponding to any quota consumption request in the targeted cluster can be determined based on the batch information carried by that batch.
[0069] The batch consumption record table refers to a table used to record the consumption information of the friend added quota in the corresponding batch. For example, Figure 5 , Figure 5 A schematic diagram of a credit consumption related table in an embodiment is shown. Figure 5 501 and 502 are two batch consumption record tables, and the batches corresponding to these two batch consumption record tables are different. Each row in the batch consumption record table corresponds to a credit consumption request, which records the consumption information of the credit consumption request, such as the follow-up object identifier, the consumption document identifier, and the status corresponding to the credit consumption request. Among them, the follow-up object identifier refers to the identifier of the user who shared the friend addition link; the consumption document identifier refers to the identifier of the consumption document. Whenever someone adds a friend through the friend addition link, a consumption document will be generated, and a credit consumption request can be generated based on the consumption document. When it is not determined that the friend addition behavior corresponding to the credit consumption request is successful, the status corresponding to the credit consumption request is determined to be the first status (for example, "pre-deducting"). When it is determined that the friend addition behavior corresponding to the credit consumption request is successful, the status corresponding to the credit consumption request is determined to be the second status (for example, "submitted").
[0070] In one embodiment, since the quota consumption request is routed to the corresponding node through the organizational account, the node corresponds to the organizational account. Therefore, the current node can store the batch consumption record table corresponding to each batch obtained based on the corresponding organizational account. For example, when the enterprise administrator generates quota acquisition order 1, quota acquisition order 2, and quota acquisition order 3 through organizational account A, obtains 100 friend addition quotas belonging to the first batch through quota acquisition order 1, obtains 200 friend addition quotas belonging to the second batch through quota acquisition order 2, and obtains 100 friend addition quotas belonging to the third batch through quota acquisition order 3, then the node A corresponding to the organizational account A can store the batch consumption record table corresponding to the first batch, the batch consumption record table corresponding to the second batch, and the batch consumption record table corresponding to the third batch. Therefore, when processing a certain cluster, the batch consumption record table corresponding to the cluster can be filtered out from the multiple batch consumption record tables pre-selected and stored by node A.
[0071] Step 210 : Based on different processing threads, the consumption information of the quota consumption requests in different clusters is batch-written into the corresponding batch consumption record table.
[0072] Specifically, multiple threads may be set in the current node, so that the current node can call different threads to process different clusters. For the sake of convenience, the thread used to process the cluster will be referred to as the processing thread below. For example, for each cluster in at least one cluster, the current node can determine the processing thread corresponding to the targeted cluster, and through the processing thread corresponding to the targeted cluster, batch write the consumption information of the quota consumption request in the targeted cluster into the batch consumption record table corresponding to the targeted cluster.
[0073] For example, the current node can create multiple processing threads, and for each cluster in at least one cluster, different processing threads can be used to process different clusters. Figure 6 When there are clusters 1, 2, and 3, processing thread 1 can be triggered to process cluster 1, processing thread 2 can be triggered to process cluster 2, and processing thread 3 can be triggered to process cluster 3. Figure 6 A schematic diagram of cluster distribution in one embodiment is shown.
[0074] In one embodiment, reference Figure 7 , Figure 7 This figure shows an overall schematic diagram of batch writing consumption information in one embodiment. Enterprise managers may add a large number of friends in a short period of time through the friend-adding link. In traditional technology, when multiple consumption information items are written to a table simultaneously, a lock is added to the table, which can easily cause write conflicts and lead to failure in writing the consumption information.
[0075] This application merges the consumption information of quota consumption requests generated based on the same organizational account and writes them in batches into the batch consumption record table, which can improve the success rate of writing consumption information.
[0076] like Figure 7 As shown, when multiple request consumption quotas are generated simultaneously based on an organization account, the process is as follows:
[0077] The caller can aggregate and route quota consumption requests generated based on different organizational accounts, and route quota consumption requests generated based on the same organizational account to the same node (that is, the same host).
[0078] The current node aggregates received quota consumption requests into batches, generating at least one cluster. Each cluster selects a processing thread to perform write operations. The processing thread writes the consumption information for the quota consumption requests in the cluster to the batch consumption record table.
[0079] After the processing thread is completed, the execution result of each quota consumption request will be distributed to return the execution result of the quota consumption request to the caller.
[0080] In the above-mentioned credit processing method, by obtaining at least one credit consumption request, each credit consumption request can be clustered according to the batch to which the credit consumed by each credit consumption request belongs, and at least one cluster cluster is obtained. By determining the processing thread corresponding to each cluster cluster, different cluster clusters can be distributed to different processing threads, so that different processing threads can process different cluster clusters synchronously. In this way, the processing efficiency of credit consumption requests can be improved, and the efficiency of information writing can be improved. For each processing thread, since the credit consumption requests in the cluster cluster correspond to the same batch, the processing thread can batch process the credit consumption requests in the cluster cluster to batch write the consumption information of the credit consumption requests in the cluster cluster into the batch consumption record table. Compared with processing each credit consumption request separately, batch processing can further improve the efficiency of information writing.
[0081] In one embodiment, the credit consumption request is a request for consuming the friend adding credit generated when adding a friend based on an organizational account, including: the credit consumption request is a request for consuming the friend adding credit generated after the friend adding link is clicked; the friend adding link refers to a link generated based on the organizational account for jumping to the friend adding page of the instant messaging application; the friend adding page displays the communication application account to be added and the friend adding control specified based on the organizational account, and the friend adding control is used to add the communication application account to be added as a friend.
[0082] Specifically, in traditional technology, the method of adding friends can be as follows: Figure 8, a friend adding invitation page 801 can be displayed, and a friend adding entrance 802 can be displayed on the friend adding invitation page. When someone else clicks on the friend adding entrance, the terminal can jump to the QR code page 803, and the QR code of the communication application account to be added can be displayed on the QR code page. When someone else long presses the QR code, the other person's terminal can display a QR code recognition page 804, and display a jump entrance on the QR code recognition page, such as "Open the other person's business card" 805. When someone else clicks on the jump entrance, the terminal can display a friend adding page 806, and display a friend adding control on the friend adding page, such as "Add to Address Book" 807. When someone else clicks on the friend adding control, the communication application account to be added can be added as a friend. Figure 8 A schematic diagram of the overall process of adding friends in one embodiment is shown.
[0083] Depend on Figure 8 It can be seen that in traditional technology, the link length for adding friends is long, and multiple steps are required to successfully add friends, which leads to waste of human resources, computer resources and power resources. In order to reduce the link length for adding friends, in the embodiment of the present application, Figure 9 Add friends in the manner shown. Users (for example, enterprise administrators) can create a friend add link through the credit acquisition application, and share the friend add link through instant messaging applications, short video applications, or mini programs. For example, a friend add card can be created through the friend add link, and the friend add card can be displayed through instant messaging applications, short video applications, or mini programs. When others click on the friend add card 901, their terminals can directly jump to the friend add page 902, which displays the communication application account to be added 903 and the friend add control specified by the user when creating the friend add link. Among them, the friend add control can be Figure 9 The user specifies the communication application account to be added when creating the friend add link. This can be an instant messaging application account specified by the enterprise administrator through the organization account. When someone clicks the add friend control, they can add the communication application account to be added as a friend. The communication application account is an instant messaging application account, and the communicating parties can use the instant messaging application account to communicate in the instant messaging application. Figure 9 A schematic diagram of the overall process of adding friends in another embodiment is shown.
[0084] After a user (e.g., an enterprise administrator) successfully adds a friend, he or she can view the friend addition details, for example, Figure 10 , which can be found in Figure 10 Check the friend adding details in the friend adding details page shown. Figure 10A schematic diagram of the details of adding friends in an implementation is shown. Since each time a friend is successfully added based on a friend adding link, a friend adding quota is consumed, the user (for example, an enterprise administrator) can also view the details of the quota consumption. For example, refer to Figure 5 , you can Figure 5 The quota consumption summary table 503 is displayed so that the enterprise administrator can understand the consumption of the friend addition quota in each batch.
[0085] In this embodiment, by generating a friend adding link, the purpose of adding friends with one click can be achieved based on the friend adding link, thereby reducing the length of the friend adding link, not only saving resources consumed when adding friends, but also improving the user experience.
[0086] In one embodiment, based on different processing threads, the consumption information of the quota consumption requests in different clusters is written in batches into the corresponding batch consumption record table, including: for each cluster in at least one cluster, filtering out the processing thread corresponding to the targeted cluster from the processing thread pool; triggering the processing thread corresponding to the targeted cluster to determine the available quota under the batch corresponding to the targeted cluster according to the number of consumption information in the corresponding batch consumption record table, and determining the target quota consumption request in the targeted cluster according to the available quota under the batch corresponding to the targeted cluster, and writing the consumption information of each target quota consumption request in batches into the batch consumption record table corresponding to the targeted cluster.
[0087] Specifically, after the batch consumption record table corresponding to the targeted cluster is determined, that is, after the target batch consumption record table is determined, the processing thread corresponding to the targeted cluster can determine the available amount under the batch corresponding to the targeted cluster based on the amount of consumption information in the target batch consumption record table. For example, when the batch corresponding to the targeted cluster is the "second batch", the processing thread can determine the available amount under the "second batch" based on the total amount of consumption information recorded in the target batch consumption record table. The total amount of consumption information is the amount of consumption information recorded in the batch consumption record table. For example, refer to Figure 5 , Figure 5 The 504 in the figure represents the total number of consumed messages. The available quota in a batch refers to the available friend-adding quota for that batch. Once a user obtains the friend-adding quota for a batch and consumes part of it, the remaining friend-adding quota (i.e., the unused friend-adding quota) is considered the available quota for that batch. For ease of description, the batch corresponding to the targeted cluster is referred to as the target batch.
[0088] After the available credit is determined, the processing thread corresponding to the targeted cluster can determine the target credit consumption request in the targeted cluster based on the available credit, and write the consumption information of each target credit consumption request into the target batch consumption record table in batches, and update the total amount of consumption information in the target batch consumption record table. For example, when the available credit under the "second batch" is less than the credit consumption request in the targeted cluster, the current node can use the available credit consumption requests in the targeted cluster as target credit consumption requests, and write the consumption information of the target credit consumption requests into the batch consumption record table corresponding to the "second batch". When the available credit under the "second batch" is greater than or equal to the credit consumption request in the targeted cluster, the current node can use all credit consumption requests in the targeted cluster as target credit consumption requests, and write the consumption information of the target credit consumption requests into the batch consumption record table corresponding to the "second batch". When the available quota under the "second batch" is zero, the batch writing of the consumption information of the target quota consumption request into the batch consumption record table corresponding to the "second batch" is suspended, and a quota consumption failure message is returned.
[0089] Furthermore, after the consumption information of the quota consumption requests in the targeted cluster is written in batches into the target batch consumption record table, the processing thread corresponding to the targeted cluster can update the total amount of consumption information in the target batch consumption record table. For example, after the consumption information of three quota consumption requests is written in batches into the batch consumption record table corresponding to the "second batch", the processing thread can add three to the total amount of consumption information in the batch consumption record table corresponding to the "second batch". By updating the total amount of consumption information in the batch consumption record table, when the subsequent processing thread processes a new cluster, it can determine the new available quota based on the new total amount of consumption information, determine whether to write the consumption information in the new cluster into the batch consumption record table in batches based on the new available quota, and determine whether to write the consumption information of all quota consumption requests in the new cluster into the batch consumption record table, or to write the consumption information of some quota consumption requests into the batch consumption record table.
[0090] In one embodiment, before writing the consumption information in batches into the target batch consumption record table, the target batch consumption record table can be determined by the processing thread corresponding to the targeted cluster. More specifically, since the quota consumption requests in the targeted cluster all carry the same batch information, the processing thread can determine the batch corresponding to the cluster based on the batch information carried by the quota consumption request in the targeted cluster. For example, when the quota consumption request in the targeted cluster carries the batch information "second batch", the processing thread determines that the batch corresponding to the targeted cluster is "second batch". Furthermore, since each batch has a corresponding batch consumption record table, the processing thread can filter out the batch consumption record table corresponding to the batch corresponding to the targeted cluster from multiple batch consumption record tables to obtain the target batch consumption record table.
[0091] In the above embodiment, by setting up different batch consumption record tables for different batches, the consumption details of the quota belonging to the corresponding batch can be recorded based on the set batch consumption record table. Compared to writing the consumption details of the quota for all batches into the same table, splitting the table by batch can reduce the amount of data in a single table. By reducing the amount of data in a single table, the reading, writing, and viewing speed of the single table can be improved.
[0092] In one embodiment, the available amount under the batch corresponding to the targeted cluster is determined based on the amount of consumption information in the corresponding batch consumption record table, including: determining the total amount under the batch corresponding to the targeted cluster; reading the total amount of consumption information from the batch consumption record table corresponding to the targeted cluster; subtracting the total amount of consumption information from the total amount under the batch corresponding to the targeted cluster to obtain the available amount under the batch corresponding to the targeted cluster.
[0093] Specifically, after the processing thread corresponding to the targeted cluster has determined the target batch and the target batch consumption record table, the processing thread corresponding to the targeted cluster can also determine the total amount under the target batch. For example, when the targeted cluster corresponds to the "second batch", when a total of 100 friend addition amounts belonging to the second batch are obtained based on a certain amount of order, it can be determined that the total amount under the target batch is 100. Furthermore, the processing thread can read the total amount of consumption information from the target batch consumption record table. For example, in the above example, the total amount of consumption information can be read from the batch consumption record table corresponding to the "second batch". Furthermore, the processing thread subtracts the total amount of consumption information from the total amount under the target batch to obtain the available amount under the target batch.
[0094] In this embodiment, each time a friend's added credit is consumed, the number of credits consumed is recorded, and the available credit is updated based on the recorded number of credits consumed. Due to network delays, the available credit obtained based on the updated number of credits consumed may be less than the actual available balance due to untimely recording of the credit consumption number. This embodiment of the application determines the available credit based on the total amount of consumption information in the batch consumption record table and the total credit limit under the batch, which can reduce the probability of inaccurate available credit due to delays.
[0095] In addition, whenever consumption information in the batch consumption record table is added or deleted, the total amount of consumption information in the batch consumption record table will be updated, so that when the available amount needs to be determined, the latest available amount can be determined directly based on the updated total amount of consumption information, without the need to count the number of consumption information in the batch consumption record table and determine the available amount based on the statistical results. This is because the number of consumption information recorded in a batch consumption record table may be in the millions. If the number of consumption information in the batch consumption record table is counted, it will take more time and reduce the efficiency of determining the available amount.
[0096] In one embodiment, the target credit consumption request in the targeted cluster is determined based on the available credit under the batch corresponding to the targeted cluster, including: determining the number of credit consumption requests in the targeted cluster; when the number of requests is greater than the available credit, filtering out the available credit target credit consumption requests from the targeted cluster; when the number of requests is less than or equal to the available credit, treating each credit consumption request in the targeted cluster as a target credit consumption request.
[0097] Specifically, when the number of requests is greater than the available credit limit under the target batch, it can be considered that if all credit limit consumption requests in the targeted cluster are processed, the consumed credit limit will be greater than the available credit limit. Therefore, the corresponding processing thread filters out the available credit limit consumption requests from the targeted cluster, and uses the filtered credit limit consumption requests as the target credit limit consumption requests. For example, when the available credit limit under the target batch is 50, and there are 60 credit limit consumption requests in the targeted cluster, 50 credit limit consumption requests are filtered out from the targeted cluster, and the 50 filtered credit limit consumption requests are all used as target credit limit consumption requests. When the number of requests is less than or equal to the available credit limit under the target batch, it can be considered that if all credit limit consumption requests in the targeted cluster are processed, the consumed credit limit will not exceed the available credit limit. At this time, the corresponding processing thread uses each credit limit consumption request in the targeted cluster as the target credit limit consumption request.
[0098] In this embodiment, the actual credit consumption request to be processed is determined based on the available credit, which can avoid the situation where insufficient available credit is found after the consumption information of the credit consumption request is written into the batch consumption record table.
[0099] In one of the embodiments, the consumption information of each target quota consumption request is written into a batch consumption record table in batches, including: for each target quota consumption request, determining the consumption document identifier corresponding to the target quota consumption request; if the consumption document identifier corresponding to the target quota consumption request already exists in the batch consumption record table, suspending writing the consumption information of the target quota consumption request into the batch consumption record table corresponding to the targeted cluster.
[0100] Specifically, for each target credit consumption request, the processing thread corresponding to the targeted cluster can determine the consumption document identifier corresponding to the targeted credit consumption request. For example, when generating a credit consumption request through a consumption document, the consumption document identifier can be embedded in the consumption information of the credit consumption request, so that the processing thread can read the consumption document identifier from the consumption information carried by the targeted credit consumption request. Furthermore, the processing thread can check whether the consumption document identifier corresponding to the targeted credit consumption request already exists in the target batch consumption record table. If the consumption document identifier exists, it can be considered that the consumption information of the targeted credit consumption request has been written into the target batch consumption record table. Therefore, the processing thread suspends writing the consumption information of the targeted credit consumption request into the target batch consumption record table.
[0101] Furthermore, if the consumption document identifier exists, the processing thread may also generate a credit consumption success message corresponding to the target credit consumption request, and return the credit consumption success message to the user's terminal, for example, to the enterprise administrator's terminal. The credit consumption success message is used to indicate that the credit consumption requested has been consumed.
[0102] In one embodiment, when the consumption document identifier does not exist, it can be considered that the consumption information of the targeted quota consumption request has not been written into the target batch consumption record table. Therefore, the processing thread writes the consumption information of the targeted quota consumption request into the target batch consumption record table.
[0103] In the above embodiment, before writing the consumption information into the batch consumption record table, it is possible to avoid repeatedly writing the consumption information into the batch consumption record table by checking whether the consumption information has been written into the batch consumption record table at a historical moment.
[0104] In one embodiment, the consumption information of each target quota consumption request is written in batches into the batch consumption record table corresponding to the targeted cluster, including: for each target quota consumption request, a new transaction line is added to the batch consumption record table corresponding to the targeted cluster, and the consumption information and the first status character of the targeted target quota consumption request are recorded in the newly added transaction line; the above method also includes: when it is determined that the friend adding behavior corresponding to the targeted target quota consumption request is successful, the first status character in the newly added transaction line is changed to a second status character; wherein the second status character is used to trigger the writing of the consumption information of the targeted target quota consumption request into the quota consumption summary table.
[0105] The first status character indicates that the credit limit is being withheld, specifically "withholding." The second status character indicates that the credit limit has been officially consumed, specifically "submitted." For ease of description, the rows in the batch consumption record table are referred to as flow rows.
[0106] Specifically, for each target quota consumption request, the processing thread corresponding to the targeted cluster can add a new flow line in the target batch consumption record table, and write the consumption information and the first status character of the targeted target quota request into the newly added flow line. Figure 11 The consumption information of the target quota request includes: "Follow-up object identifier: 113", "Consumption document identifier: 345", so that the processing thread can write "Follow-up object identifier: 113", "Consumption document identifier: 345" and the first status character "withholding" into the newly added flow line 1101. Figure 11 A schematic diagram of writing into a batch consumption record table in one embodiment is shown.
[0107] The processing thread can determine whether the friend adding behavior corresponding to the target quota consumption request is successful, and if it is determined to be successful, change the first status character recorded in the newly added transaction line to the second status character, for example, change "withholding" in the newly added transaction line 1101 to "submitted".
[0108] Furthermore, when the first status character recorded in the newly added flow line is changed to the second status character, the current node can write the consumption information of the target quota consumption request into the quota consumption summary table. For example, the processing thread corresponding to the targeted cluster in the current node can write the consumption information of the targeted target quota consumption request into the quota consumption summary table; or, a summary table writing thread is provided in the current node, and the consumption information of the targeted target quota consumption request can be written into the quota consumption summary table through the summary table writing thread. Among them, the quota consumption summary table records the details of the total amount consumed up to the present. Different organizational accounts can correspond to different quota consumption summary tables, so that different enterprise administrators can view the details of the total amount consumed up to the present through the corresponding quota consumption summary table.
[0109] In one embodiment, for the target credit consumption request, when the target credit consumption request corresponds to the first status character, the processing thread corresponding to the targeted cluster can determine the corresponding consumption document based on the consumption document identifier in the target credit consumption request, and determine whether the friend adding behavior that generates the consumption document is successful based on the consumption document. For example, when the consumption document may include a communication account to be added and a target communication account for adding the communication account to be added, the current node can check whether the communication account to be added and the target communication account have a friend relationship. If they do have a friend relationship, it is determined that the friend adding behavior that generates the consumption document is successful, thereby determining that the friend adding behavior corresponding to the target credit consumption request is successful. At this time, the target credit consumption request is changed from corresponding to the first status character to corresponding to the second status character.
[0110] If the communication account to be added and the target communication account do not have a friend relationship, for example, when the friend is not added successfully due to a system crash, then the communication account to be added and the target communication account do not have a friend relationship. At this time, the processing thread corresponding to the targeted cluster can determine that the friend adding behavior corresponding to the targeted target credit consumption request has failed, and suspend changing the targeted target credit consumption request from corresponding to the first state character to corresponding to the second state character.
[0111] In one embodiment, the transaction can be used to ensure that the consumption information of the credit consumption request with the second status character is successfully written into the credit consumption summary table. Figure 12A credit consumption summary table may exist in the current node. In the above example, after changing "withholding" in the newly added transaction line 1101 to "submitted," the current node may determine the credit consumption summary table, add a new row 1201 to the credit consumption summary table, and write the consumption information in the newly added transaction line 1101 to the newly added row 1201 in the credit consumption summary table. After writing the consumption information in the newly added transaction line 1101 to the newly added row in the credit consumption summary table, it may be determined whether the consumption document identifier in the newly added transaction line 1101 exists in the credit consumption summary table. If so, it is determined that the credit consumption summary table has been successfully written. If not, the consumption information is written again to the account total loss table until the consumption information is successfully written to the credit consumption summary table. Figure 12 A schematic diagram of writing a total flow table of quota consumption in one embodiment is shown.
[0112] In one embodiment, since the quota consumption summary table corresponds one-to-one to the organizational account, the enterprise manager can query the corresponding quota consumption summary table through the organizational account, and determine the consumption details of the friend addition quota for each batch obtained through the queried quota consumption summary table.
[0113] In the above embodiment, since it takes some time from clicking the friend adding link to successfully adding friends, and the friend adding quota will only be actually consumed after the friend is successfully added, therefore, by setting the first status character and the second status character, the first status character can be used to indicate that the friend adding process is in progress, at which time the quota is in a frozen state; the second status character can be used to indicate that the friend adding is completed, at which time the friend adding quota is officially consumed.
[0114] In one embodiment, the batch consumption record table corresponding to the targeted cluster cluster records the total amount of consumption information, and the above method also includes: when it is determined that the friend adding behavior corresponding to the targeted target quota consumption request fails, deleting the consumption information of the targeted target quota consumption request from the batch consumption record table corresponding to the targeted cluster cluster; and updating the total amount of consumption information in the batch consumption record table corresponding to the targeted cluster cluster.
[0115] Specifically, when it is determined that the friend adding behavior corresponding to the target quota consumption request has failed, the processing thread corresponding to the targeted cluster can delete the consumption information of the target quota consumption request from the target batch consumption record table, and update the total amount of consumption information in the target batch consumption record table, for example, reduce the total amount of consumption information in the target batch consumption record table by one.
[0116] In this embodiment, by timely updating the total amount of consumption information, the available credit determined based on the total amount of consumption information can also be updated in a timely manner, thereby improving the accuracy of the available credit. In addition, by reducing the total amount of consumption information when a friend addition attempt fails, the frozen friend addition credit can be released based on the reduced total amount of consumption information, allowing the released friend addition credit to be used again later.
[0117] In one embodiment, the consumption information of each target quota consumption request is written in batches into the batch consumption record table corresponding to the targeted cluster cluster, including: when the batch consumption record table corresponding to the targeted cluster cluster has not been added with a version lock, adding a version lock to the batch consumption record table corresponding to the targeted cluster cluster; the consumption information of each target quota consumption request is written in batches into the batch consumption record table corresponding to the targeted cluster cluster to which the version lock is added; the above method also includes: after the consumption information is successfully written into the batch consumption record table, the version lock of the batch consumption record table corresponding to the targeted cluster cluster is released, and the version number of the batch consumption record table corresponding to the targeted cluster cluster is updated a preset number of times.
[0118] Specifically, a version number can be set for the batch consumption record table. For example, the version number of the most original batch consumption record table is V1. After that, each time the batch consumption record table is modified, the version number is updated. Due to the existence of the version number, a version lock can be set based on the version number, and the version lock can be used to solve the conflict problem of different threads modifying the same batch consumption record table at the same time. More specifically, the processing thread corresponding to the targeted cluster can determine whether a version lock is added to the target batch consumption record table. If a version lock is not added, a version lock can be added to the target batch consumption record table, and the consumption information of each target quota consumption request in the targeted cluster can be batch-written into the target batch consumption record table with a version lock added.
[0119] After the consumption information is successfully written into the batch consumption record table in batches, the processing thread corresponding to the targeted cluster can release the version lock of the target batch consumption record table and update the version number of the target batch consumption record table a preset number of times. For example, the preset number of times can be 1, thereby updating the version number of the target batch consumption record table once. For example, if there are 100 pieces of consumption information to be written into the target batch consumption record table, if the 100 pieces of consumption information are written into the target batch consumption record table one by one, then the version number in the target batch consumption record table needs to be updated 100 times, for example, from V0 to V1, from V1 to V2... until it becomes V10, which makes the update of the version number more cumbersome; if the 100 pieces of consumption information are written into the target batch consumption record table in batches, then the version number of the target batch consumption record table only needs to be updated once, for example, from V0 to V1, which makes the update of the version number more concise, thereby saving computer, electricity and other resources consumed by the version number update.
[0120] In one embodiment, if a version lock has been added to the target batch consumption record table, it can be considered that other processing threads are modifying the target batch consumption record table, so that the processing thread corresponding to the targeted cluster cluster suspends writing the consumption information of each target quota consumption request into the target batch consumption record table, and after determining to release the version lock of the target batch consumption record table, the target quota consumption request in the targeted cluster cluster is re-determined based on the number of consumption information in the target batch consumption record table, and the consumption information of the re-determined target quota consumption request is written into the target batch consumption record table.
[0121] In the above embodiment, if the quota consumption request received by the current node is randomly sent to the processing thread for processing, then the batch consumption record table processed by each processing thread is uncertain, and the probability of different processing threads writing consumption information to the same batch consumption record table at the same time will be very high, thereby causing a write conflict in the batch consumption record table, thereby increasing the probability of finding that the available quota is insufficient after the consumption information is written to the batch consumption record table. For example, A and B write to the target batch consumption record table at the same time. The total amount of consumption information read by A and B is Q1. At this time, the available quota determined by A based on Q1 is Q2, and the available quota determined by B based on Q1 is also Q2. If there is no version control here, then A and B will both consume the available quota Q2, so that the available quota is consumed repeatedly. In this way, it is found that the available quota is insufficient after the consumption information is written to the batch consumption record table.
[0122] The embodiment of the present application distributes the credit consumption requests corresponding to the same batch consumption record table to the same processing thread for at least one credit consumption request, so that different processing threads can process different batch consumption record tables, thereby reducing the writing conflict of the batch consumption record table, and further reducing the probability of finding that the available credit is insufficient after the consumption information is written to the batch consumption record table. In this way, the probability of successful credit consumption is increased, and the probability of successful friend addition is increased.
[0123] In addition, the embodiment of the present application can further reduce the problem of batch consumption record table write conflicts by setting a version lock, thereby increasing the probability of successful consumption of the quota, and further increasing the probability of successful friend addition. For example, by setting the version number, it can be ensured that when A and B write to the target batch consumption record table, A can write consumption information in the target batch consumption record table based on the current version number V1 of the target batch consumption record table, and change the total amount of consumption information in the target batch consumption record table from Q1 to Q2, and change the target batch consumption record table from V1 to V2. Alternatively, B can write consumption information in the target batch consumption record table based on the current version number V1 of the target batch consumption record table, and change the total amount of consumption information in the target batch consumption record table from Q1 to Q3, and change the target batch consumption record table from V1 to V2. Only one of A and B can successfully write to the target batch consumption record table, and the other returns failure. For example, A succeeds and B fails. When B retries, it writes to the V2 version of the target batch consumption record table, thus increasing the probability of successful consumption of the quota.
[0124] In one embodiment, in order to better understand the above embodiment, the overall processing flow of a single quota consumption request is described below:
[0125] After purchasing credit, the company will create a friend-adding link and share it on the instant messaging app. The company's customers can click on the friend-adding link to directly add the company's sales representative as a friend. Each time a friend is added, one credit is deducted from the company's credit.
[0126] If you use up your friend-adding quota before adding a friend, the friend-adding operation may not always succeed. This may result in the friend-adding quota being used up but the friend-adding operation failing. If you add a friend first and then use up your friend-adding quota, you may find that the available quota is 0 after successfully adding the friend, and the friend-adding quota will not be used, causing service anomalies.
[0127] Since each friend addition consumes one credit, a flood read approach is used to solve the above problem. Each time a friend addition request consumes credit, only the credit consumption request information is written to the batch consumption record table, without changing the credit consumption summary table. When the friend addition is confirmed to be successful, the credit consumption summary table is updated. When the friend addition is confirmed to be unsuccessful, the credit consumption information recorded in the batch consumption record table is rolled back.
[0128] The process for adding a friend's credit consumption is as follows: The current node registers the credit consumption transaction and withholds the friend's credit. The current node uses the consumption document ID carried in the credit consumption request to query whether the consumption document ID already exists in the batch consumption record table. If so, it directly returns a successful consumption.
[0129] If there is no consumption document ID, the consumption information for the quota consumption request is added to the batch consumption record table and the status is set to Withholding. When writing to the batch consumption record table, the version number and total consumption quantity of the batch consumption record table are also updated.
[0130] If the withholding logic fails, for example, if the available credit is 0 when adding a friend's credit, the withholding logic is determined to have failed. In this case, the user will directly return a message indicating that the friend's credit consumption has failed. If the withholding system fails, for example, when a write storage timeout occurs, the withholding system is determined to have failed. In this case, the transaction will be pulled up and retried.
[0131] When the friend adding credit is successfully deducted, the add friend operation is executed. When the friend adding is successful, the friend adding credit is actually deducted, and the credit consumption transaction ends.
[0132] If the friend addition logic / system fails, the transaction reverse check logic is activated. The transaction reverse check logic is as follows: If the reverse check confirms that the friend addition was successful, the friend addition credit is deducted and the transaction reverse check logic ends. If the reverse check confirms that the friend addition was unsuccessful, the credit is rolled back and the transaction reverse check logic ends.
[0133] In one embodiment, the above method also includes: upon receiving a credit limit acquisition order, obtaining a credit limit account object; the credit limit account object includes an available batch table and a total credit limit table; adding a batch row to the available batch table, and generating a batch corresponding to the credit limit acquisition order; writing the order information corresponding to the credit limit acquisition order and the batch corresponding to the credit limit acquisition order in the newly added batch row; and updating the information in the total credit limit table based on the friend addition credit limit obtained based on the credit limit acquisition order.
[0134] Specifically, a user (for example, an enterprise administrator) can create a credit acquisition order through the credit acquisition application, so that the credit acquisition application can send the credit acquisition order to the nodes in the server cluster. When the current node receives the credit acquisition order, the current node can determine the credit account object corresponding to the organization account according to the organization account carried in the credit acquisition order. The credit account object is a logical business object, which includes an available batch table and a total credit table in storage. For example, refer to Figure 5 , Figure 5 The available batch table in the table may be 505, and the total amount table may be 506. Furthermore, the current node may add a new row in the available batch table. For the convenience of description, the row in the available batch table is referred to as a batch row below.
[0135] The current node writes the order information and batch corresponding to the credit acquisition order into the newly added batch row. For example, the current node may generate a batch corresponding to the credit acquisition order and write information such as the batch, the credit acquisition order number, and the friend credit that can be obtained based on the credit acquisition order into the newly added batch row.
[0136] After the order information and batch are written to the newly added batch row, the current node can also update the information in the total limit table in the limit account object, for example, update the total limit, available total limit and other information in the total limit table.
[0137] In one embodiment, when the available batch table is updated and / or the total amount table is updated, the version number of the credit account object needs to be updated. For example, when information is written to the available batch table and the information in the total amount table is updated based on the written information, the version number of the credit account object is updated.
[0138] In one embodiment, the friend-adding credit obtained through a credit acquisition order has a time limit, for example, one year. Once the friend-adding credit expires, it can no longer be used. Therefore, the credit acquisition time and credit expiration time can also be written into the newly added batch row in the available batch table. For example, if a credit of 100 belonging to the second batch is obtained through a credit acquisition order on January 1, 20X2, the credit acquisition time "January 1, 20X2" and the expiration time "January 1, 20X3" can be written into the batch row corresponding to the second batch in the available batch list.
[0139] In one embodiment, the newly added batch row may have a key value (Key), and the information written in the newly added batch row may be the value (Value) corresponding to the Key.
[0140] In the above embodiment, by setting up an available batch table, information about each batch obtained by the user, such as the time the credit limit was obtained and the time the credit limit expired, can be recorded in the available batch table, so that subsequent users can view the available batch table and quickly understand the information about each batch. By setting up a total quota table, summary information about each batch can be recorded in the total quota table, so that subsequent users can view the total quota table and quickly understand the summary information about the batches.
[0141] In one embodiment, adding a new batch row to the available batch table includes: if the version lock is not added to the credit account object, adding a version lock to the credit account object, and adding a new batch row to the available batch table in the credit account object; the above method also includes: after the order information and batch corresponding to the credit acquisition order are successfully written into the available batch table, releasing the version lock of the credit account object and updating the version number of the credit account object.
[0142] Specifically, a version number can be set for the credit account object. For example, the version number of the original credit account object is V1. After that, each time the credit account object is modified, the version number is updated. Due to the existence of the version number, a version lock can be set based on the version number, and the version lock can be used to solve the concurrency conflict problem of two credit acquisition orders at the same time. More specifically, when the current node receives a credit acquisition order, it can determine whether a version lock has been added to the credit account object. If a version lock has not been added, a version lock can be added to the credit account object, and a new batch row can be added to the available batch table in the credit account object, and the order information of the credit acquisition order can be written into the newly added batch row. After writing the order information into the newly added batch row and updating the total credit table based on the credit order information, the current node can release the version lock of the credit account object and update the version number of the credit account object. For example, from V0 to V1.
[0143] In one embodiment, if a version lock has been added to the credit account object, it can be considered that the credit account object is being modified based on other credit acquisition orders, so the current node suspends modification of the credit account object and modifies the credit account object again after confirming the release of the version lock.
[0144] In the above embodiment, by setting a version lock, the problem of credit account object modification conflicts can be reduced and the accuracy of credit acquisition can be improved. For example, by setting a version number, it can be ensured that when two credit acquisition orders initiated by A and B through a unified organization account are received, the total available amount read by A and B is Q1. At this time, based on the credit acquisition order A, the total available amount will be changed to Q1+QA, and the credit acquisition order B will be changed to Q1+QB. If there is no version control, then after the credit acquisition order A and credit acquisition order B operations are completed, the total available amount will be Q1+QA or Q1+QB, which is not in line with expectations, because the expected amount is Q1+QA+QB.
[0145] However, this application uses version control, and the credit line acquisition order A can change the total available amount to Q1+QA and the credit line account object from V1 to V2 based on the current version number V1 of the credit line account object. Alternatively, the credit line acquisition order B can change the total available amount to Q1+QA and the credit line account object from V1 to V2 based on the current version number V1 of the credit line account object. For credit line acquisition order A and credit line acquisition order B, only one credit line account object is modified successfully, and the other returns failure. For example, credit line acquisition order A succeeds, and credit line acquisition order B fails. When credit line acquisition order B tries again, it modifies the credit line account object of version V2, so that the total available amount becomes Q1+QA+QB. In this way, the credit line account object modification conflict problem is reduced and the accuracy of credit line acquisition is improved.
[0146] To better understand the above embodiment, the following describes the overall process for obtaining friend credit limits: An enterprise's friend credit limit acquisition behavior generates a batch, writes it to the available batch table, and updates the total credit limit table based on the friend credit limit acquired this time. However, due to network fluctuations, system anomalies, and other issues, it is not possible to guarantee that a single credit limit increase can be written reliably and accurately. Furthermore, retries in upper-layer services may result in multiple friend credit limits being added to the credit account object during a single credit limit acquisition behavior.
[0147] To ensure the reliability of credit limit increase, the available batch list and version number are recorded in the credit limit account object. The process of adding a friend to increase the credit limit is as follows:
[0148] The total amount read out is Q1 and the available batch list, version number V1. If the order number of the quota acquisition order already appears in the available batch list, the current node considers that the friend adding amount based on the quota acquisition order has been successfully increased, and directly returns that the amount has been successfully added.
[0149] If the order number of the quota acquisition order does not appear in the available batch list, the current node changes the total quota to Q2, adds the order information of the quota acquisition order to the available batch list, and then upgrades the version number from V1 to V2.
[0150] If there is another credit limit acquisition order also increasing the credit limit at this time, then only one of the two credit limit acquisition orders can upgrade the version number of the credit account object to V2, and the other credit limit acquisition order will be retried in the upper-level business.
[0151] In one embodiment, the above method also includes: obtaining a credit limit account object; the credit limit account object includes an available batch table and a total credit limit table; for each batch in the available batch table, when it is determined that the targeted batch has expired based on the expiration time of the targeted batch, the status of the targeted batch is set to an expired state; the available credit limit in the total credit limit table is updated, and the version number of the credit limit account object is updated.
[0152] Specifically, when a friend addition quota expires, it's possible to pull a list of available batches and calculate the expired friend addition quota in real time. However, this approach relies on pull behavior and can't notify users even when they haven't pulled. Therefore, a subscription-publish model can be used to perform expiration liquidations on businesses. For example, when a business receives a new batch of friend addition quotas, it can subscribe to the expiration information for that batch, allowing the node to perform expiration liquidations on the subscribing business.
[0153] More specifically, the current node can perform overdue liquidation on subscribed companies at a preset time frequency. For example, it can perform overdue liquidation on subscribed companies at a fixed time every day. The overdue liquidation logic is as follows: obtain the credit account object; the credit account object includes an available batch table and a total credit table; for each batch in the available batch table, it can be determined whether the friend adding credit under the targeted batch has expired based on the credit expiration time recorded in the available batch table. In the case that the targeted batch is determined to have expired based on the credit expiration time of the targeted batch, the current node can modify the targeted batch status to an expired status, and generate an expiration reminder notification corresponding to the targeted batch, and send the expiration reminder notification to the terminal of the corresponding organization account.
[0154] Friend credits added in expired batches cannot be consumed by upper-layer services. When the current node sets the targeted batch status to expired, the current node can query the current available total credit, expired total credit, and credit account object version number, increase the expired total credit by the total credit in the targeted batch, decrease the available total credit by the total credit in the targeted batch, and update the credit account object version number.
[0155] In one embodiment, in the batch rollback logic, if it is determined that the batch has expired, the transaction flow needs to be rolled back and the total expired amount increased. For example, after the friend adding amount is successfully withheld, the friend adding process is executed. If it is found that the user account is restricted, resulting in the friend adding failure, the withheld friend adding amount must be rolled back. If it is found that the rolled back friend adding amount is in the expired batch, the total expired amount must be increased. Alternatively, after the withholding is successful, the friend adding fails due to a system crash when adding a friend. At this time, when the transaction is reversed, it is found that the friend adding amount was withheld, but the relationship is not a friend relationship. In this case, the withheld friend adding amount must be rolled back. If it is found that the rolled back friend adding amount is in the expired batch, the total expired amount must also be increased.
[0156] In the above embodiment, by actively determining expired batches and sending expiration reminder notifications of expired batches to corresponding users, users can be notified even when they have no pull behavior, thereby improving the immediacy of notifications and further improving user experience.
[0157] In one embodiment, the present application embodiment can ensure that the friend added credit limit is consistent with the transaction history. Because an enterprise needs to view its credit limit consumption summary table when using credit limits, it is necessary to write the credit limit consumption summary table after confirming that the friend added credit limit has been successfully consumed. Furthermore, it is necessary to ensure that the credit limit consumption summary table matches the information in the total credit limit table.
[0158] In one embodiment, reference Figure 13 , the quota processing methods include:
[0159] Step 1302: When the current node receives a credit line acquisition order, the current node obtains a credit line account object; the credit line account object includes an available batch table and a total credit line table; if a version lock is not added to the credit line account object, a version lock is added to the credit line account object, and a new batch row is added to the available batch table in the credit line account object with the version lock added.
[0160] In step 1304, the current node generates a batch corresponding to the quota acquisition order; in the newly added batch row, the order information and batch corresponding to the quota acquisition order are written, and according to the order information in the newly added batch row, the information in the total quota table is updated; the version lock of the quota account object is released, and the version number of the quota account object is updated.
[0161] Step 1306: The current node obtains at least one credit consumption request; determines the batch to which the credit added by the friend requested to be consumed by each of the at least one credit consumption request belongs; and determines a batch consumption record table corresponding to each of the at least one clusters.
[0162] Step 1308: For each cluster in at least one cluster, the current node selects a processing thread corresponding to the targeted cluster from the processing thread pool; triggers the processing thread corresponding to the targeted cluster, and determines the total amount under the batch corresponding to the targeted cluster.
[0163] In step 1310, the processing thread corresponding to the targeted cluster reads the total amount of consumption information from the batch consumption record table corresponding to the targeted cluster; subtracts the total amount of consumption information from the total amount under the batch corresponding to the targeted cluster to obtain the available amount under the batch corresponding to the targeted cluster.
[0164] In step 1312, the processing thread corresponding to the targeted cluster determines the number of credit consumption requests in the targeted cluster; if the number of requests is greater than the available credit, the available credit target credit consumption requests are filtered out from the targeted cluster; if the number of requests is less than or equal to the available credit, each credit consumption request in the targeted cluster is treated as a target credit consumption request.
[0165] Step 1314: If a version lock is not added to the batch consumption record table corresponding to the targeted cluster, the processing thread corresponding to the targeted cluster adds a version lock to the batch consumption record table corresponding to the targeted cluster; for each target quota consumption request, the consumption information of the targeted target quota consumption request is written into the batch consumption record table corresponding to the targeted cluster to which a version lock is added.
[0166] Step 1316: When it is determined that the friend adding behavior corresponding to the target credit consumption request is successful, the processing thread corresponding to the target cluster changes the first state character in the newly added flow line to the preset second state character; and writes the consumption information of the target credit consumption request into the credit consumption summary table.
[0167] Step 1318: After writing each consumption information into the batch consumption record table, the processing thread corresponding to the targeted cluster releases the version lock of the batch consumption record table corresponding to the targeted cluster, and updates the version number of the batch consumption record table corresponding to the targeted cluster a preset number of times.
[0168] Step 1320: When it is determined that the friend adding behavior corresponding to the target quota consumption request fails, the processing thread corresponding to the targeted cluster deletes the consumption information of the targeted target quota consumption request from the batch consumption record table corresponding to the targeted cluster; and updates the total amount of consumption information in the batch consumption record table corresponding to the targeted cluster.
[0169] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0170] This application improves the performance of credit consumption by introducing a merged consumption strategy and ensures the correctness and consistency of consumption through the introduction of transactions and idempotence. This application implements a universal credit management process that flexibly expands access to upper-layer services. Furthermore, this credit processing method shortens the process for enterprise users to add friends, saving resources consumed by adding friends.
[0171] This application also provides an application scenario, which applies the above-mentioned credit limit processing method. Specifically, the application of the credit limit processing method in this application scenario is as follows:
[0172] To avoid unlimited friend additions, a friend addition quota can be set. Each time a friend is successfully added, one friend addition quota is consumed. When the friend addition quota reaches zero, no more friends can be added, and the friend addition quota needs to be obtained again. Whenever a friend is added based on a friend addition link, a quota consumption request is generated. The terminal can then route the quota consumption request to the corresponding node, which can then process the quota consumption request according to the quota processing method described above.
[0173] The above application scenarios are merely illustrative. It is understood that the application of the credit limit processing methods provided in the various embodiments of the present application is not limited to the above scenarios.
[0174] Based on the same inventive concept, the embodiments of the present application further provide a credit limit processing device for implementing the credit limit processing method involved above. The implementation solution provided by this device is similar to the implementation solution described in the above method. Therefore, the specific limitations of one or more credit limit processing device embodiments provided below can be referred to the limitations of the credit limit processing method above and will not be repeated here.
[0175] In one embodiment, Figure 14As shown, a quota processing device 1400 is provided, comprising: a request acquisition module 1402, a clustering module 1404 and a batch writing module 1406, wherein:
[0176] The acquisition module 1402 is used to acquire at least one credit consumption request; a credit consumption request is a request generated when adding a friend and used to consume the friend adding credit.
[0177] Clustering module 1404 is used to determine the batch to which the friend-adding credit requested by each of at least one credit consumption requests belongs; the batches to which the friend-adding credit obtained based on different credit acquisition orders belong are different; and clustering the at least one credit consumption request according to the batch to which the friend-adding credit requested by each of at least one credit consumption requests belongs to obtain at least one cluster cluster.
[0178] The batch writing module 1406 is configured to determine a batch consumption record table corresponding to at least one cluster; and based on different processing threads, batch write the consumption information of the quota consumption requests in different clusters into the corresponding batch consumption record table.
[0179] In one embodiment, the credit consumption request is a request for consuming the friend adding credit generated when adding a friend based on an organizational account; the credit processing method is executed by a node in a server cluster, and credit consumption requests generated based on different organizational accounts are routed to different nodes.
[0180] In one embodiment, the credit consumption request is a request for consuming the friend adding credit generated after the friend adding link is clicked; the friend adding link refers to a link generated based on the organizational account for jumping to the friend adding page of the instant messaging application; the friend adding page displays the communication application account to be added and the friend adding control specified based on the organizational account, and the friend adding control is used to add the communication application account to be added as a friend.
[0181] In one embodiment, the batch write module 1406 is also used to filter out the processing thread corresponding to the targeted cluster from the processing thread pool for each cluster in at least one cluster; trigger the processing thread corresponding to the targeted cluster to determine the available amount under the batch corresponding to the targeted cluster based on the amount of consumption information in the corresponding batch consumption record table, determine the target amount consumption request in the targeted cluster based on the available amount under the batch corresponding to the targeted cluster, and write the consumption information of each target amount consumption request in batches into the batch consumption record table corresponding to the targeted cluster.
[0182] In one embodiment, the batch write module 1406 is also used to determine the total amount under the batch corresponding to the targeted cluster; read the total amount of consumption information from the batch consumption record table corresponding to the targeted cluster; subtract the total amount of consumption information from the total amount under the batch corresponding to the targeted cluster to obtain the available amount under the batch corresponding to the targeted cluster.
[0183] In one embodiment, the batch write module 1406 is also used to determine the number of credit consumption requests in the targeted cluster; when the number of requests is greater than the available credit, the available credit target credit consumption requests are filtered out from the targeted cluster; when the number of requests is less than or equal to the available credit, each credit consumption request in the targeted cluster is treated as a target credit consumption request.
[0184] In one embodiment, the batch write module 1406 is also used to add a new transaction line in the batch consumption record table corresponding to the targeted cluster for each target quota consumption request, and record the consumption information and the preset first status character of the targeted target quota consumption request in the newly added transaction line; when it is determined that the friend adding behavior corresponding to the targeted target quota consumption request is successful, the first status character in the newly added transaction line is changed to the preset second status character; wherein the second status character is used to trigger the writing of the consumption information of the targeted target quota consumption request into the quota consumption summary table.
[0185] In one embodiment, the batch consumption record table corresponding to the targeted cluster cluster records the total amount of consumption information, and the batch write module 1406 is also used to delete the consumption information of the targeted target quota consumption request from the batch consumption record table corresponding to the targeted cluster cluster when it is determined that the friend adding behavior corresponding to the targeted target quota consumption request fails; and update the total amount of consumption information in the batch consumption record table corresponding to the targeted cluster cluster.
[0186] In one embodiment, the batch write module 1406 is also used to add a version lock to the batch consumption record table corresponding to the targeted cluster cluster when no version lock is added to the batch consumption record table corresponding to the targeted cluster cluster; batch write the consumption information of each target quota consumption request into the batch consumption record table corresponding to the targeted cluster cluster to which the version lock is added; after writing the consumption information into the batch consumption record table, release the version lock of the batch consumption record table corresponding to the targeted cluster cluster, and update the version number of the batch consumption record table corresponding to the targeted cluster cluster a preset number of times.
[0187] In one embodiment, the credit processing device 1400 also includes a credit acquisition module, which is used to obtain a credit account object when a credit acquisition order is received; the credit account object includes an available batch table and a total credit table; a new batch row is added to the available batch table, and a batch corresponding to the credit acquisition order is generated; in the new batch row, the order information and batch corresponding to the credit acquisition order are written; and the information in the total credit table is updated according to the order information in the new batch row.
[0188] In one embodiment, the credit processing device 1400 also includes a credit acquisition module, which is used to add a version lock to the credit account object when the version lock is not added to the credit account object, and add a new batch row to the available batch table of the credit account object with the version lock added; after the order information and batch corresponding to the credit acquisition order are written into the available batch table, the version lock of the credit account object is released and the version number of the credit account object is updated.
[0189] In one embodiment, the credit processing device 1400 also includes an expiration determination module for obtaining a credit account object; the credit account object includes an available batch table and a total credit table; for each batch in the available batch table, when it is determined that the targeted batch has expired based on the credit expiration time of the targeted batch, the status of the targeted batch is set to an expired state, the available credit in the total credit table is updated, and the version number of the credit account object is updated.
[0190] Each module in the aforementioned credit limit processing device may be implemented in whole or in part through software, hardware, or a combination thereof. Each module may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0191] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 15As shown. The computer device includes a processor, a memory, an input / output interface (I / O) and a communication interface. The processor, memory and I / O interface are connected via a system bus, and the communication interface is connected to the system bus via the I / O interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store quota processing data. The I / O interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a quota processing method is implemented.
[0192] Those skilled in the art will understand that Figure 15 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0193] In one embodiment, a computer device is further provided, including a memory and a processor. The memory stores a computer program, and the processor implements the steps in the above method embodiments when executing the computer program.
[0194] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above-mentioned method embodiments when executed by a processor.
[0195] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps of each of the above-described method embodiments.
[0196] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions.
[0197] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments. In particular, any reference to memory, database, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), data processing logic devices based on quantum computing, and the like.
[0198] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0199] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A credit processing method, characterized in that: The method comprises: Obtaining at least one credit consumption request; the credit consumption request is a request for consuming a friend addition credit generated when adding a friend; Determining the batch to which the friend adding credit requested to be consumed by each of the at least one credit consumption requests belongs; the friend adding credits obtained based on different credit acquisition orders belong to different batches; Clustering the at least one credit consumption request according to the batch to which the friend added credit requested to be consumed belongs to obtain at least one cluster; Determining a batch consumption record table corresponding to each of the at least one cluster; Based on different processing threads, the consumption information of the quota consumption requests in different clusters is batch-written into the corresponding batch consumption record table.
2. The method according to claim 1, characterized in that The credit consumption request is a request for consuming the credit for adding friends generated when adding friends based on the organization account; The credit processing method is executed by nodes in the server cluster, and credit consumption requests generated based on different organizational accounts are routed to different nodes.
3. The method according to claim 2, characterized in that The credit consumption request is a request for consuming the credit for adding friends based on the organization account when adding friends, and includes: The credit consumption request is a request for consuming the friend adding credit generated after the friend adding link is clicked; the friend adding link refers to a link generated based on the organizational account for jumping to the friend adding page of the instant messaging application; the friend adding page displays the communication application account to be added and the friend adding control specified based on the organizational account, and the friend adding control is used to add the communication application account to be added as a friend.
4. The method according to claim 1, wherein The process of batch-writing the consumption information of the quota consumption requests in different clusters into the corresponding batch consumption record table based on different processing threads includes: For each cluster in the at least one cluster, filtering out a processing thread corresponding to the targeted cluster from a processing thread pool; The processing thread corresponding to the targeted cluster is triggered to determine the available quota under the batch corresponding to the targeted cluster according to the number of consumption information in the corresponding batch consumption record table, and determine the target quota consumption request in the targeted cluster according to the available quota under the batch corresponding to the targeted cluster, and write the consumption information of each target quota consumption request into the batch consumption record table corresponding to the targeted cluster in batches.
5. The method according to claim 4, characterized in that The step of determining the available quota for the batch corresponding to the targeted cluster according to the amount of consumption information in the corresponding batch consumption record table includes: Determine the total amount of the batch corresponding to the targeted cluster; Read the total quantity of consumption information from the batch consumption record table corresponding to the targeted cluster; The total amount of consumption information is subtracted from the total amount of the batch corresponding to the targeted cluster to obtain the available amount of the batch corresponding to the targeted cluster.
6. The method according to claim 4, characterized in that The step of determining a target quota consumption request in the targeted cluster according to the available quota in the batch corresponding to the targeted cluster includes: Determine the number of quota consumption requests in the targeted cluster; In the case that the number of requests is greater than the available credit, filtering out the available credit target credit consumption requests from the targeted cluster; In a case where the number of requests is less than or equal to the available credit, each credit consumption request in the targeted cluster is used as a target credit consumption request.
7. The method according to claim 4, characterized in that Writing the consumption information of each target quota consumption request in batches into the batch consumption record table corresponding to the targeted cluster includes: For each of the target quota consumption requests, a new transaction line is added in the batch consumption record table corresponding to the targeted cluster, and the consumption information of the targeted quota consumption request and the preset first status character are recorded in the newly added transaction line; The method further comprises: If it is determined that the friend adding behavior corresponding to the target credit consumption request is successful, the first status character in the newly added flow line is changed to a preset second status character; The second status character is used to trigger writing the consumption information of the target quota consumption request into the quota consumption summary table.
8. The method according to claim 7, characterized in that The batch consumption record table corresponding to the targeted cluster records the total quantity of consumption information, and the method further includes: In the case where it is determined that the friend adding behavior corresponding to the targeted target quota consumption request fails, deleting the consumption information of the targeted target quota consumption request from the batch consumption record table corresponding to the targeted cluster; The total quantity of consumption information in the batch consumption record table corresponding to the targeted cluster is updated.
9. The method according to claim 4, characterized in that Writing the consumption information of each target quota consumption request in batches into the batch consumption record table corresponding to the targeted cluster includes: If a version lock is not added to the batch consumption record table corresponding to the targeted cluster, a version lock is added to the batch consumption record table corresponding to the targeted cluster; Writing the consumption information of each target quota consumption request in batches into a batch consumption record table corresponding to the targeted cluster with a version lock added; The method further comprises: After the consumption information is written into the batch consumption record table, the version lock of the batch consumption record table corresponding to the targeted cluster is released, and the version number of the batch consumption record table corresponding to the targeted cluster is updated a preset number of times.
10. The method according to any one of claims 1 to 9, characterized in that The method further comprises: When a credit acquisition order is received, a credit account object is obtained; the credit account object includes an available batch table and a total credit table; Add a new batch row in the available batch table and generate the batch corresponding to the quota acquisition order; In the newly added batch row, enter the order information and batch corresponding to the order amount. The information in the total amount table is updated according to the order information in the newly added batch row.
11. The method according to claim 10, characterized in that The newly added batch row in the available batch table includes: If the credit account object has not been added with a version lock, add a version lock to the credit account object, and add a new batch row to the available batch table in the credit account object with the version lock added; The method further comprises: After the order information and batch corresponding to the credit acquisition order are written into the available batch table, the version lock of the credit account object is released, and the version number of the credit account object is updated.
12. The method according to any one of claims 1 to 9, characterized in that The method further comprises: Get the credit account object; the credit account object includes an available batch table and a total credit table; For each batch in the available batch table, if it is determined that the batch has expired according to the quota expiration time of the batch, the status of the batch is set to expired, the available quota in the total quota table is updated, and the version number of the quota account object is updated.
13. A credit processing device, characterized in that: The device comprises: An acquisition module, configured to acquire at least one credit consumption request; the credit consumption request is a request for consuming a credit for adding a friend when adding a friend; a clustering module configured to determine a batch to which the friend-added credit requested by each of the at least one credit consumption requests belongs; the friend-added credits obtained based on different credit acquisition orders belong to different batches; and cluster the at least one credit consumption request based on the batch to which the friend-added credit requested by each of the at least one credit consumption requests belongs to obtain at least one cluster; The batch writing module is used to determine the batch consumption record table corresponding to each of the at least one cluster; based on different processing threads, the consumption information of the quota consumption requests in different clusters is batch written into the corresponding batch consumption record table.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 12 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 12 are implemented.