Request processing method and device
By receiving and screening virtual product resource transfer requests and utilizing multi-threaded parallel processing, the problem of low efficiency in the prior art is solved, and the effect of efficiently processing multiple resource transfer requests is achieved.
Patent Information
- Application Number
- CN202111440065.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-11-30
AI Technical Summary
When processing virtual product resource transfer requests, the existing technology is limited by the serial processing of database locks, resulting in low efficiency and inability to meet the demand of processing a large number of requests in a short period of time.
By receiving resource transfer requests from multiple users, determining target resource transfer requests that meet preset conditions, obtaining the total number of resource transfers, and setting the virtual resources to be transferred to a locked state, the system then sends resource transfer requests to the virtual product provider using multiple preset threads to achieve parallel processing.
It improves the request processing efficiency, can process multiple requests in a short time, reduces the number of accesses to the virtual resource database, and optimizes the efficiency of resource transfer operations.
Smart Images

Figure CN114090604B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a request processing method and device. Background Art
[0002] When people want to obtain a virtual product, they typically send a virtual resource transfer request to the virtual product provider through the virtual product service provider. However, the virtual product service provider is limited in the number of resource transfers it can process per day. Therefore, upon receiving multiple resource transfer requests scheduled for completion within the same timeframe, the virtual product service provider sequentially obtains database locks, sequentially locks the virtual resources required for each resource transfer request, and serially sends resource transfer requests to the virtual product provider. This ensures that resource transfer operations for multiple virtual resource transfer requests are completed accurately and promptly within the specified quantity. Since each virtual resource transfer request requires waiting for a database lock, this leads to significant efficiency issues and makes it difficult to process a large number of requests in a short period of time. Summary of the Invention
[0003] The embodiments of the present application provide a request processing method and apparatus, which can improve request processing efficiency and meet the need of processing multiple requests in a short period of time.
[0004] In a first aspect, an embodiment of the present application provides a request processing method, which is applied to a virtual product service provider, and the method includes:
[0005] receiving a plurality of first resource transfer requests for virtual products sent by a plurality of users, and determining a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests, each of the first resource transfer requests including a resource transfer quantity;
[0006] Obtaining a total number of resource transfers according to the multiple target resource transfer requests, where the total number of resource transfers is a cumulative value of the resource transfer numbers included in the multiple target resource transfer requests;
[0007] Acquire the virtual resources to be transferred from the resource set corresponding to the virtual product according to the total quantity of resource transfer, and set the virtual resources to be transferred to a locked state;
[0008] sending, through a plurality of preset threads, second resource transfer requests corresponding to the respective target resource transfer requests to the virtual product provider, wherein the second resource transfer request is used to request the virtual product provider to allow a resource transfer operation for the virtual resource to be transferred;
[0009] When a confirmation feedback regarding the second resource transfer request sent by the virtual product provider is received, the virtual resource to be transferred is set to an unlocked state, and a resource transfer operation is performed on the virtual resource to be transferred.
[0010] In a possible implementation, determining a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests includes:
[0011] If a cumulative value of the resource transfer quantities included in the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, determining the multiple first resource transfer requests as the multiple target resource transfer requests;
[0012] If the cumulative value of the number of resource transfers included in the multiple first resource transfer requests is greater than the resource transfer upper limit, determine the arrangement order corresponding to the multiple first resource transfer requests, and determine multiple target resource transfer requests that meet the preset conditions from the multiple first resource transfer requests according to the arrangement order, and the cumulative value of the number of resource transfers included in the multiple target resource transfer requests that meet the preset conditions is less than or equal to the resource transfer upper limit.
[0013] In a possible implementation, the arrangement order is used to indicate that a first resource transfer request including a larger number of resource transfers is processed earlier, and determining, according to the arrangement order, a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests includes:
[0014] sorting the multiple first resource transfer requests according to the arrangement order;
[0015] If it is determined that the cumulative value of the resource transfer quantities included in the first K first resource transfer requests among the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, and the cumulative value of the resource transfer quantities included in the first K+1 first resource transfer requests is greater than the resource transfer upper limit, then the first K first resource transfer requests are determined as the multiple target resource transfer requests, where K is a positive integer. In one possible implementation, before sending the second resource transfer requests corresponding to each of the target resource transfer requests to the virtual product provider through multiple preset threads, the method further includes:
[0016] Obtaining the number of requests for transferring the multiple target resources;
[0017] grouping the multiple target resource transfer requests according to the number of requests;
[0018] The sending, through a plurality of preset threads, second resource transfer requests corresponding to the first resource transfer requests to the virtual product provider respectively includes:
[0019] For each preset thread among the plurality of preset threads, a group corresponding to the preset thread is determined, and second resource transfer requests corresponding to respective target resource transfer requests in the group corresponding to the preset thread are sent to the virtual product provider through the preset thread.
[0020] In a possible implementation, grouping the multiple target resource transfer requests according to the number of requests includes:
[0021] A preconfigured group capacity is acquired, and the multiple target resource transfer requests are grouped according to the group capacity to obtain multiple groups, where the number of target resource transfer requests included in each group is less than or equal to the group capacity.
[0022] In a possible implementation, sending, through the preset thread, to the virtual product provider, the second resource transfer requests corresponding to the respective target resource transfer requests in the group corresponding to the preset thread, includes:
[0023] Obtaining a sequence number corresponding to each target resource transfer request in the group corresponding to the preset thread, wherein the sequence number is used to indicate an arrangement position of the target resource transfer request in the plurality of first resource transfer requests;
[0024] According to the sequence numbers corresponding to the target resource transfer requests, the second resource transfer requests corresponding to the target resource transfer requests are sent to the virtual product provider in sequence through the preset thread.
[0025] In a possible implementation, the first resource transfer request includes a requesting account, and setting the virtual resource to be transferred to an unlocked state and performing a resource transfer operation on the virtual resource to be transferred includes:
[0026] The virtual resources of the resource transfer quantity included in the second resource transfer request are deducted from the virtual resources to be transferred, and the virtual resources of the resource transfer quantity included in the second resource transfer request are transferred to the request account included in the second resource transfer request, and the second resource transfer request includes the request account in the corresponding target resource transfer request.
[0027] In a second aspect, an embodiment of the present application provides a request processing device, including:
[0028] A receiving unit, configured to receive a plurality of first resource transfer requests for virtual products sent by a plurality of users;
[0029] a determining unit, configured to determine a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests, each of the first resource transfer requests including a resource transfer quantity;
[0030] an obtaining unit, configured to obtain a total number of resource transfers according to the multiple target resource transfer requests, where the total number of resource transfers is a cumulative value of the resource transfer numbers included in the multiple target resource transfer requests;
[0031] A first setting unit is configured to obtain virtual resources to be transferred from a resource set corresponding to the virtual product according to the total quantity of resource transfer, and set the virtual resources to be transferred to a locked state;
[0032] a sending unit, configured to send, through a plurality of preset threads, second resource transfer requests corresponding to the respective target resource transfer requests to the virtual product provider, wherein the second resource transfer requests are used to request the virtual product provider to allow a resource transfer operation for the virtual resource to be transferred;
[0033] The second setting unit is configured to set the virtual resource to be transferred to an unlocked state and perform a resource transfer operation on the virtual resource to be transferred upon receiving a confirmation feedback for the second resource transfer request sent by the virtual product provider.
[0034] In one possible design, the determining unit is specifically configured to:
[0035] If a cumulative value of the resource transfer quantities included in the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, determining the multiple first resource transfer requests as the multiple target resource transfer requests;
[0036] If the cumulative value of the number of resource transfers included in the multiple first resource transfer requests is greater than the resource transfer upper limit, determine the arrangement order corresponding to the multiple first resource transfer requests, and determine multiple target resource transfer requests that meet the preset conditions from the multiple first resource transfer requests according to the arrangement order, and the cumulative value of the number of resource transfers included in the multiple target resource transfer requests that meet the preset conditions is less than or equal to the resource transfer upper limit.
[0037] In one possible design, the arrangement order is used to indicate that a first resource transfer request including a larger number of resource transfers is processed earlier, and the determining unit is specifically configured to:
[0038] sorting the multiple first resource transfer requests according to the arrangement order;
[0039] If it is determined that the cumulative value of the resource transfer quantities included in the first K first resource transfer requests among the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, and the cumulative value of the resource transfer quantities included in the first K+1 first resource transfer requests is greater than the resource transfer upper limit, then the first K first resource transfer requests are determined as the multiple target resource transfer requests, where K is a positive integer.
[0040] In one possible design, the device further includes:
[0041] an acquiring unit, configured to acquire the number of requests for the multiple target resource transfer requests;
[0042] a grouping unit, configured to group the plurality of target resource transfer requests according to the number of requests;
[0043] The sending unit is specifically configured to:
[0044] For each preset thread among the plurality of preset threads, a group corresponding to the preset thread is determined, and second resource transfer requests corresponding to respective target resource transfer requests in the group corresponding to the preset thread are sent to the virtual product provider through the preset thread.
[0045] In one possible design, the grouping unit is specifically used to:
[0046] A preconfigured group capacity is acquired, and the multiple target resource transfer requests are grouped according to the group capacity to obtain multiple groups, where the number of target resource transfer requests included in each group is less than or equal to the group capacity.
[0047] In one possible design, the sending unit is specifically configured to:
[0048] Obtaining a sequence number corresponding to each target resource transfer request in the group corresponding to the preset thread, wherein the sequence number is used to indicate an arrangement position of the target resource transfer request in the plurality of first resource transfer requests;
[0049] According to the sequence numbers corresponding to the target resource transfer requests, the second resource transfer requests corresponding to the target resource transfer requests are sent to the virtual product provider in sequence through the preset thread.
[0050] In one possible design, the first resource transfer request includes a requesting account, and the second setting unit is specifically configured to:
[0051] The virtual resources of the resource transfer quantity included in the second resource transfer request are deducted from the virtual resources to be transferred, and the virtual resources of the resource transfer quantity included in the second resource transfer request are transferred to the request account included in the second resource transfer request, and the second resource transfer request includes the request account in the corresponding target resource transfer request.
[0052] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a communication interface, wherein the processor, memory, and communication interface are interconnected, wherein the communication interface is used to receive and send data, the memory is used to store program code, and the processor is used to call the program code to execute the method described in the first aspect.
[0053] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method described in the first aspect above.
[0054] In an embodiment of the present application, after receiving multiple first resource transfer requests, multiple target resource transfer requests that meet preset conditions are determined therefrom, and virtual resources whose cumulative values of the resource transfer quantities included in the multiple target resource transfer requests are used as virtual resources to be transferred, and the virtual resources to be transferred are set to a locked state, and second resource transfer requests corresponding to each target resource transfer request are sent to the virtual product provider through multiple preset threads. After receiving confirmation feedback from the virtual product provider, the resource transfer operation is performed, which reduces the number of accesses to the virtual resource quantity database and realizes parallel processing of multiple requests, thereby improving the request processing efficiency and meeting the needs of processing multiple requests in a short time. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art.
[0056] Figure 1 A flowchart of a request processing method provided in an embodiment of the present application;
[0057] Figure 2 A system diagram of a request processing method provided in an embodiment of the present application;
[0058] Figure 3 A schematic diagram of the structure of a request processing device provided in an embodiment of the present application;
[0059] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The present application is described in further detail below with reference to the accompanying drawings.
[0061] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification and appended claims of this application, the singular expressions "a", "an", "said", "above", "the", and "this" are intended to include plural expressions as well, unless the context clearly indicates otherwise.
[0062] In this application, "at least one (item)" means one or more, "more than one" means two or more, "at least two (items)" means two or three and more than three, and "and / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c".
[0063] An embodiment of the present application provides a request processing method. In order to more clearly describe the solution of the present application, some drawings involved in the present application are further introduced below.
[0064] See Figure 1 , Figure 1 A flowchart of a request processing method provided in an embodiment of the present application. Figure 1 As shown, the method may include the following steps 101 to 105.
[0065] Step 101: receiving multiple first resource transfer requests for virtual products sent by multiple users, and determining multiple target resource transfer requests that meet preset conditions from the multiple first resource transfer requests, each of which includes a resource transfer quantity.
[0066] In the embodiment of the present application, the above virtual products may be financial products, such as funds, stocks, etc. Figure 2As shown, a first resource transfer request is an instruction sent by a user to a virtual product service provider, authorizing the virtual product service provider to request a resource transfer from the virtual product provider. The virtual product service provider can be a securities trading company, i.e., a brokerage, while the virtual product provider can be an exchange, such as the Shanghai Stock Exchange. The resource transfer amount included in each first resource transfer request can refer to the quantity or amount of resources the user wishes to transfer, such as the purchase amount or shares of a fund.
[0067] In some embodiments, determining multiple target resource transfer requests that meet a preset condition from multiple first resource transfer requests may include the following process:
[0068] If a cumulative value of the resource transfer quantities included in the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, determining the multiple first resource transfer requests as the multiple target resource transfer requests;
[0069] If the cumulative value of the number of resource transfers included in the multiple first resource transfer requests is greater than the resource transfer upper limit, determine the arrangement order corresponding to the multiple first resource transfer requests, and determine multiple target resource transfer requests that meet the preset conditions from the multiple first resource transfer requests according to the arrangement order, and the cumulative value of the number of resource transfers included in the multiple target resource transfer requests that meet the preset conditions is less than or equal to the resource transfer upper limit.
[0070] It is understandable that the virtual product service provider may receive multiple first resource transfer requests for the virtual product, and the number of resource transfers that the virtual product service provider can process within a preset time period (e.g., per day) is limited. This limit (which may be referred to as a resource transfer upper limit) may be determined by the virtual product service provider based on a risk assessment. Therefore, if the cumulative value of the resource transfer quantities included in the multiple first resource transfer requests received is less than or equal to the resource transfer upper limit, it indicates that the virtual product service provider is able to process all of these first resource transfer requests within the preset time period, and therefore all of the received multiple first resource transfer requests may be used as the multiple target resource transfer requests. If the cumulative value of the resource transfer quantities included in the multiple first resource transfer requests received is greater than the resource transfer upper limit, it indicates that the virtual product service provider is unable to process all of the received first resource transfer requests within the preset time period, and needs to determine some of the first resource transfer requests that can be processed from them as the multiple target resource transfer requests. Of course, the cumulative value of the resource transfer quantities included in the multiple target resource transfer requests may not exceed the limit. Specifically, the multiple first resource transfer requests may be sorted, and multiple target resource transfer requests may be selected from them according to the sorting order. The arrangement order can be used to distinguish the importance levels of different first resource transfer requests, thereby screening out target resource transfer requests according to the importance levels.
[0071] In one embodiment, the above-mentioned arrangement order can be used to indicate that the first resource transfer request with the larger number of resource transfers included is processed first, that is, the importance of the request is measured by the number of resource transfers included in the first resource transfer request. Furthermore, the specific process of determining multiple target resource transfer requests that meet the preset conditions from multiple first resource transfer requests according to the arrangement order may include: sorting the multiple first resource transfer requests according to the arrangement order; if it is determined that the cumulative value of the number of resource transfers included in the first K first resource transfer requests among the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, and the cumulative value of the number of resource transfers included in the first K+1 first resource transfer requests is greater than the resource transfer upper limit, then determining the first K first resource transfer requests as the multiple target resource transfer requests, wherein K is a positive integer. It can be understood that the cumulative value of the number of resource transfers included in the first resource transfer requests is calculated in sequence according to the above-mentioned arrangement order, and all first resource transfer requests whose cumulative value does not exceed the resource transfer upper limit and include a relatively large number of resource transfers (that is, the first K first resource transfer requests arranged in sequence) are used as the above-mentioned multiple target resource transfer requests. This can achieve the purpose of minimizing the losses caused by unprocessed resource transfer requests.
[0072] Optionally, the above-mentioned sorting order may also be related to other information of the first resource transfer request, for example, the level of the account carried by the first resource transfer request. In this way, the above-mentioned sorting order can be used to indicate that first resource transfer requests with higher account levels are processed earlier. Alternatively, the sorting order may be related to the time when the first resource transfer request was received, etc., and this application does not impose any restrictions on this. In other words, different indicators used to measure the importance of the first resource transfer request may also provide different criteria for sorting the first resource transfer requests.
[0073] Step 102: Obtain a total resource transfer quantity according to the multiple target resource transfer requests. The total resource transfer quantity is a cumulative value of the resource transfer quantities included in the multiple target resource transfer requests.
[0074] In the embodiment of the present application, the total number of resource transfers is the cumulative value of the transfer numbers of the multiple target resources, and the total number of resource transfers is less than or equal to the resource transfer upper limit.
[0075] Step 103 : acquiring the virtual resources to be transferred from the resource set corresponding to the virtual product according to the total quantity of resource transfer, and setting the virtual resources to be transferred to a locked state.
[0076] In an embodiment of the present application, the locked state means that no operations are allowed on the virtual resources to be transferred, that is, the virtual resources to be transferred are locked as the property corresponding to the above-mentioned multiple target resource transfer requests within a certain period of time, ensuring that other requests except the above-mentioned multiple target resource transfer requests cannot obtain the corresponding virtual resources from the virtual resources to be transferred. For example, if the virtual product is a fund, the locking process may refer to the securities company freezing a certain amount of funds in the database to ensure that the certain amount of funds temporarily corresponds only to the corresponding entrustment request, waiting to be deducted and transferred to the account included in the corresponding entrustment request.
[0077] Step 104: Sending second resource transfer requests corresponding to the target resource transfer requests to the virtual product provider through multiple preset threads. The second resource transfer requests are used to request the virtual product provider to allow the resource transfer operation for the virtual resource to be transferred.
[0078] The second resource transfer request includes the resource transfer quantity in the corresponding first resource transfer request
[0079] In some embodiments, before executing the above step 104, the following steps may be performed first: obtaining the request quantity of the multiple target resource transfer requests, and grouping the multiple target resource transfer requests according to the request quantity.
[0080] It is understandable that grouping the above-mentioned multiple target resource transfer requests can facilitate the subsequent execution of step 104, and realize sending requests to the virtual product service provider through multiple threads (i.e., multiple preset threads) in parallel, thereby ensuring that multiple user requests can be processed in parallel in a short time, thereby improving the efficiency of request processing. Specifically, after grouping the multiple target resource transfer requests, the group corresponding to each preset thread in the multiple preset threads is determined, and for each preset thread, the second resource transfer request corresponding to each target resource transfer request in the group corresponding to the preset thread is sent to the virtual product service provider through the preset thread, wherein the first resource transfer request is sent by the user to the virtual product service provider, and its function is to instruct the virtual product service provider to send the second resource transfer request to the virtual product provider; and the second resource transfer request is sent by the virtual product service provider to the virtual product provider in response to the user's first resource transfer request, and the two have a corresponding relationship. In fact, the purpose of the target resource transfer request and the second resource transfer request are both to request the virtual product provider to allow the resource transfer operation for the virtual resource to be transferred, but there are differences in the sender and receiver of the two.
[0081] In some embodiments, the process of grouping the multiple request accounts according to the number of requests may specifically include: obtaining a preconfigured group capacity, and grouping the multiple target resource transfer requests according to the group capacity to obtain multiple groups, each group including a number of target resource transfer requests that is less than or equal to the group capacity.
[0082] It is understandable that the above-mentioned group capacity can refer to the number of requests that a single thread can process within a certain period of time. Specifically, the group capacity can be obtained through stress testing and pre-stored in the configuration data, and can be directly obtained when implementing this application. Based on the number of requests and the group capacity, the number of groups obtained after group processing can be determined, wherein the number of target resource transfer requests included in each group is less than or equal to the above-mentioned group capacity, and the number of target resource transfer requests included in each group is substantially equal. The group processing is completed according to the number of groups; this ensures that the processing speed of multiple preset threads when sending the second resource transfer request in parallel is substantially consistent.
[0083] In some embodiments, each preset thread sends a second resource transfer request corresponding to each target resource transfer request in the group corresponding to the preset thread to the virtual product provider. Multiple second resource transfer requests associated with the same group are not sent simultaneously, but rather serially. For example, a sequence number corresponding to each target resource transfer request in the same group can be obtained. This sequence number is related to the arrangement order in the above steps and can actually indicate the arrangement position of the target resource transfer request among the multiple first resource transfer requests. Based on this sequence number, the preset thread can sequentially send the second resource transfer request corresponding to each target resource transfer request in the group to the virtual product provider. In one possible embodiment, for each group, the group identifier of the group and the maximum and minimum sequence numbers of the target resource requests in the group can be directly obtained. Since each target resource transfer request is arranged in sequence when grouping, after obtaining the group identifier, maximum and minimum sequence numbers, the sequence number corresponding to each target resource transfer request in the group can be derived based on the sequence, thereby generating and sending the second resource transfer request corresponding to each target resource transfer request.
[0084] Step 105: upon receiving a confirmation feedback regarding the second resource transfer request sent by the virtual product provider, setting the virtual resource to be transferred to an unlocked state, and performing a resource transfer operation on the virtual resource to be transferred.
[0085] In an embodiment of the present application, the confirmation feedback is used to indicate that the virtual product provider allows the resource transfer operation of the resource transfer quantity in the second resource transfer request, and setting the virtual resource to be transferred to an unlocked state can refer to operating the virtual resource to be transferred and deducting the virtual resource of the resource transfer quantity included in the second resource transfer request from the virtual resource to be transferred. It can be understood that when the virtual product is a fund, it refers to deducting the target amount (the target amount is equal to the resource transfer quantity in the second resource transfer request) from the previously frozen fund of a certain amount (the certain amount is equal to the total resource transfer quantity), thereby completing part of the fund's entrusted transaction processing process and ensuring that the securities company's transaction amount for the fund does not exceed the limit. The first resource transfer request includes a request account, so the target resource transfer request also includes a request account. Therefore, performing a resource transfer operation on the virtual resource to be transferred can refer to transferring the virtual resource of the resource transfer quantity included in the second resource transfer operation to the request account included in the second resource transfer request, and the second resource transfer request includes the request account in the corresponding target resource transfer request. That is, the virtual resources of the above-mentioned resource transfer quantity are transferred to the user's request account, which can correspond to the account opened by the user with the virtual product service provider, such as a stock account, fund account, etc. Transferring virtual resources to the request account actually means transferring the virtual resources to the user's account. It is understandable that if the user account balance is insufficient, the user withdraws the request, or the request response fails before the resource transfer operation is completed, the corresponding processing will be carried out according to the normal operation, and the virtual resources of the resource transfer quantity may not be transferred to the user's request account.
[0086] The following describes the process of the request processing method provided by the embodiment of the present application in conjunction with a specific application scenario. In this application scenario, multiple users have signed relevant agreements with the virtual product service provider and send a first resource transfer request to the virtual product service provider, requesting the virtual product service provider to send a corresponding second resource transfer request to the virtual product provider when the trigger condition is met. Therefore, the virtual product service provider processes the first resource transfer requests of the multiple users when it determines that the trigger condition has been met. The trigger condition may include a timed trigger condition. The virtual product service provider can process the request through a scheduling module and a business processing module.
[0087] In an embodiment of the present application, after the business processing module sets the virtual resource to be transferred to a locked state, the above-mentioned scheduling module groups the above-mentioned multiple target resource transfer requests and obtains the group identifier of each group and the maximum sequence number and minimum sequence number corresponding to the target resource transfer request in the group. The sequence number corresponding to the target resource transfer request is used to indicate the arrangement position of the target resource transfer request in the above-mentioned multiple first resource transfer requests, and the arrangement position is determined according to the arrangement order of the multiple first resource transfer requests. The scheduling module sends the group identifier of each group and the maximum sequence number and minimum sequence number corresponding to the group's successful resource transfer request to the business processing module through multiple threads, so that the business processing module can process the target resource transfer requests included in the group through multiple preset threads, generate a second resource transfer request corresponding to each target resource transfer request, and send it to the virtual product provider.
[0088] It is understandable that if the present application is not implemented, in a request processing method 1, the business processing module sets the virtual resources of the resource transfer quantity included in each target resource transfer request to a locked state in turn (each setting requires accessing the database and obtaining the database lock), receives the sequential number corresponding to each target resource transfer request sent by the scheduling module, generates a second resource transfer request and sends it to the virtual product provider. Therefore, the number of database accesses is large, and the scheduling module and the business processing module need to interact several times (equal to the number of target resource transfer requests) to generate multiple second resource transfer requests. However, since the database lock needs to be obtained serially, the request processing efficiency is low.
[0089] In the embodiment of the present application, the number of interactions required by the scheduling module and the business processing module to generate multiple second resource transfer requests (equal to the number of groups after the target resource transfer requests are grouped) is greatly reduced compared to method 1, and the virtual resources to be transferred are set to a locked state, and the number of database accesses is also reduced compared to the number of database accesses in method 1. In addition, multiple second resource transfer requests can be sent to the virtual product provider in parallel through multiple threads, thereby improving the request processing efficiency and meeting the need to process multiple requests in a short time.
[0090] In an embodiment of the present application, after receiving multiple first resource transfer requests, multiple target resource transfer requests that meet preset conditions are determined therefrom, and virtual resources whose cumulative values of the resource transfer quantities included in the multiple target resource transfer requests are used as virtual resources to be transferred, and the virtual resources to be transferred are set to a locked state, and second resource transfer requests corresponding to each target resource transfer request are sent to the virtual product provider through multiple preset threads. After receiving confirmation feedback from the virtual product provider, the resource transfer operation is performed, which reduces the number of accesses to the virtual resource quantity database and realizes parallel processing of multiple requests, thereby improving the request processing efficiency and meeting the needs of processing multiple requests in a short time.
[0091] See Figure 3 , Figure 3 This is a schematic diagram of the structure of a request processing device provided in an embodiment of the present application. Figure 3 As shown, the device may include:
[0092] The receiving unit 11 is configured to receive multiple first resource transfer requests for virtual products sent by multiple users;
[0093] A determining unit 12 is configured to determine a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests, each of the first resource transfer requests including a resource transfer quantity;
[0094] an obtaining unit 13, configured to obtain a total number of resource transfers according to the multiple target resource transfer requests, where the total number of resource transfers is a cumulative value of the resource transfer numbers included in the multiple target resource transfer requests;
[0095] A first setting unit 14 is configured to obtain virtual resources to be transferred from a resource set corresponding to the virtual product according to the total resource transfer quantity, and set the virtual resources to be transferred to a locked state;
[0096] A sending unit 15 is configured to send, through a plurality of preset threads, second resource transfer requests corresponding to the respective target resource transfer requests to a virtual product provider, wherein the second resource transfer request is used to request the virtual product provider to allow a resource transfer operation for the virtual resource to be transferred;
[0097] The second setting unit 16 is configured to set the virtual resource to be transferred to an unlocked state and perform a resource transfer operation on the virtual resource to be transferred upon receiving a confirmation feedback for the second resource transfer request sent by the virtual product provider.
[0098] In one possible design, the determining unit 12 is specifically configured to:
[0099] If a cumulative value of the resource transfer quantities included in the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, determining the multiple first resource transfer requests as the multiple target resource transfer requests;
[0100] If the cumulative value of the number of resource transfers included in the multiple first resource transfer requests is greater than the resource transfer upper limit, determine the arrangement order corresponding to the multiple first resource transfer requests, and determine multiple target resource transfer requests that meet the preset conditions from the multiple first resource transfer requests according to the arrangement order, and the cumulative value of the number of resource transfers included in the multiple target resource transfer requests that meet the preset conditions is less than or equal to the resource transfer upper limit.
[0101] In a possible design, the arrangement order is used to indicate that a first resource transfer request including a larger number of resource transfers is processed earlier, and the determining unit 12 is specifically configured to:
[0102] sorting the multiple first resource transfer requests according to the arrangement order;
[0103] If it is determined that the cumulative value of the resource transfer quantities included in the first K first resource transfer requests among the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, and the cumulative value of the resource transfer quantities included in the first K+1 first resource transfer requests is greater than the resource transfer upper limit, then the first K first resource transfer requests are determined as the multiple target resource transfer requests, where K is a positive integer.
[0104] In one possible design, the device further includes:
[0105] an acquiring unit, configured to acquire the number of requests for the multiple target resource transfer requests;
[0106] a grouping unit, configured to group the plurality of target resource transfer requests according to the number of requests;
[0107] The sending unit 15 is specifically configured to:
[0108] For each preset thread among the plurality of preset threads, a group corresponding to the preset thread is determined, and second resource transfer requests corresponding to respective target resource transfer requests in the group corresponding to the preset thread are sent to the virtual product provider through the preset thread.
[0109] In one possible design, the grouping unit is specifically used to:
[0110] A preconfigured group capacity is acquired, and the multiple target resource transfer requests are grouped according to the group capacity to obtain multiple groups, where the number of target resource transfer requests included in each group is less than or equal to the group capacity.
[0111] In one possible design, the sending unit 15 is specifically configured to:
[0112] Obtaining a sequence number corresponding to each target resource transfer request in the group corresponding to the preset thread, wherein the sequence number is used to indicate an arrangement position of the target resource transfer request in the plurality of first resource transfer requests;
[0113] According to the sequence numbers corresponding to the target resource transfer requests, the second resource transfer requests corresponding to the target resource transfer requests are sent to the virtual product provider in sequence through the preset thread.
[0114] In one possible design, the first resource transfer request includes a requesting account, and the second setting unit 16 is specifically configured to:
[0115] The virtual resources of the resource transfer quantity included in the second resource transfer request are deducted from the virtual resources to be transferred, and the virtual resources of the resource transfer quantity included in the second resource transfer request are transferred to the request account included in the second resource transfer request, and the second resource transfer request includes the request account in the corresponding target resource transfer request.
[0116] Please refer to Figure 4 , Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 4 As shown, the device 1000 may include: at least one processor 1001, such as a CPU, at least one communication interface 1003, a memory 1004, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The communication interface 1003 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1004 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1004 may optionally also be at least one storage device located away from the aforementioned processor 1001. As Figure 4 As shown, the memory 1004 as a computer storage medium may include an operating system, a network communication module, and program instructions.
[0117] exist Figure 4In the device 1000 shown, the processor 1001 may be configured to load program instructions stored in the memory 1004 and specifically perform the following operations:
[0118] receiving a plurality of first resource transfer requests for virtual products sent by a plurality of users, and determining a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests, each of the first resource transfer requests including a resource transfer quantity;
[0119] Obtaining a total number of resource transfers according to the multiple target resource transfer requests, where the total number of resource transfers is a cumulative value of the resource transfer numbers included in the multiple target resource transfer requests;
[0120] Acquire the virtual resources to be transferred from the resource set corresponding to the virtual product according to the total quantity of resource transfer, and set the virtual resources to be transferred to a locked state;
[0121] sending, through a plurality of preset threads, second resource transfer requests corresponding to the respective target resource transfer requests to the virtual product provider, wherein the second resource transfer request is used to request the virtual product provider to allow a resource transfer operation for the virtual resource to be transferred;
[0122] When a confirmation feedback regarding the second resource transfer request sent by the virtual product provider is received, the virtual resource to be transferred is set to an unlocked state, and a resource transfer operation is performed on the virtual resource to be transferred.
[0123] The specific execution steps can be found in the description of the above embodiment and will not be repeated here.
[0124] The present application also provides a computer storage medium that can store multiple instructions, which are suitable for being loaded and executed by a processor as described above. Figure 1 The method steps of the embodiment shown, the specific execution process can be found in Figure 1 The detailed description of the illustrated embodiment will not be repeated here.
[0125] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program includes the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
Claims
1. A request processing method, characterized in that: Applied to a virtual product service provider, the method includes: receiving a plurality of first resource transfer requests for virtual products sent by a plurality of users, and determining a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests, each of the first resource transfer requests including a resource transfer quantity; Obtaining a total number of resource transfers according to the multiple target resource transfer requests, where the total number of resource transfers is a cumulative value of the resource transfer numbers included in the multiple target resource transfer requests; Acquire the virtual resources to be transferred from the resource set corresponding to the virtual product according to the total quantity of resource transfer, and set the virtual resources to be transferred to a locked state, wherein the locked state means that no operation is allowed on the virtual resources; sending, through a plurality of preset threads, second resource transfer requests corresponding to the respective target resource transfer requests to the virtual product provider, wherein the second resource transfer request is used to request the virtual product provider to allow a resource transfer operation for the virtual resource to be transferred; When a confirmation feedback regarding the second resource transfer request sent by the virtual product provider is received, the virtual resource to be transferred is set to an unlocked state, and a resource transfer operation is performed on the virtual resource to be transferred.
2. The method according to claim 1, wherein The determining a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests includes: If a cumulative value of the resource transfer quantities included in the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, determining the multiple first resource transfer requests as the multiple target resource transfer requests; If the cumulative value of the number of resource transfers included in the multiple first resource transfer requests is greater than the resource transfer upper limit, determine the arrangement order corresponding to the multiple first resource transfer requests, and determine multiple target resource transfer requests that meet the preset conditions from the multiple first resource transfer requests according to the arrangement order, and the cumulative value of the number of resource transfers included in the multiple target resource transfer requests that meet the preset conditions is less than or equal to the resource transfer upper limit.
3. The method according to claim 2, wherein The arrangement order is used to indicate that a first resource transfer request including a larger number of resource transfers is processed earlier, and determining a plurality of target resource transfer requests that meet a preset condition from the plurality of first resource transfer requests according to the arrangement order includes: sorting the multiple first resource transfer requests according to the arrangement order; If it is determined that the cumulative value of the resource transfer quantities included in the first K first resource transfer requests among the multiple first resource transfer requests is less than or equal to the resource transfer upper limit, and the cumulative value of the resource transfer quantities included in the first K+1 first resource transfer requests is greater than the resource transfer upper limit, then the first K first resource transfer requests are determined as the multiple target resource transfer requests, where K is a positive integer.
4. The method according to claim 2 or 3, wherein: Before sending the second resource transfer requests corresponding to the target resource transfer requests to the virtual product provider through multiple preset threads, the method further includes: Obtaining the number of requests for transferring the multiple target resources; grouping the multiple target resource transfer requests according to the number of requests; The sending, through a plurality of preset threads, second resource transfer requests corresponding to the first resource transfer requests to the virtual product provider respectively includes: For each preset thread among the plurality of preset threads, a group corresponding to the preset thread is determined, and second resource transfer requests corresponding to respective target resource transfer requests in the group corresponding to the preset thread are sent to the virtual product provider through the preset thread.
5. The method according to claim 4, wherein The grouping and processing the multiple target resource transfer requests according to the number of requests includes: A preconfigured group capacity is acquired, and the multiple target resource transfer requests are grouped according to the group capacity to obtain multiple groups, where the number of target resource transfer requests included in each group is less than or equal to the group capacity.
6. The method according to claim 5, wherein The sending, through the preset thread, to the virtual product provider, second resource transfer requests corresponding to respective target resource transfer requests in the group corresponding to the preset thread, includes: Obtaining a sequence number corresponding to each target resource transfer request in the group corresponding to the preset thread, wherein the sequence number is used to indicate an arrangement position of the target resource transfer request in the plurality of first resource transfer requests; According to the sequence numbers corresponding to the target resource transfer requests, the second resource transfer requests corresponding to the target resource transfer requests are sent to the virtual product provider in sequence through the preset thread.
7. The method according to claim 6, wherein The first resource transfer request includes a requesting account number, and the step of setting the virtual resource to be transferred to an unlocked state and performing a resource transfer operation on the virtual resource to be transferred includes: The virtual resources of the resource transfer quantity included in the second resource transfer request are deducted from the virtual resources to be transferred, and the virtual resources of the resource transfer quantity included in the second resource transfer request are transferred to the request account included in the second resource transfer request, and the second resource transfer request includes the request account in the corresponding target resource transfer request.
8. A request processing device, configured to execute the method according to any one of claims 1 to 7, characterized in that: include: A receiving unit, configured to receive a plurality of first resource transfer requests for virtual products sent by a plurality of users; a determining unit, configured to determine a plurality of target resource transfer requests meeting a preset condition from the plurality of first resource transfer requests, each of the first resource transfer requests including a resource transfer quantity; an obtaining unit, configured to obtain a total number of resource transfers according to the multiple target resource transfer requests, where the total number of resource transfers is a cumulative value of the resource transfer numbers included in the multiple target resource transfer requests; A first setting unit is configured to obtain virtual resources to be transferred from a resource set corresponding to the virtual product according to the total quantity of resource transfer, and set the virtual resources to be transferred to a locked state; a sending unit, configured to send, through a plurality of preset threads, second resource transfer requests corresponding to the respective target resource transfer requests to the virtual product provider, wherein the second resource transfer requests are used to request the virtual product provider to allow a resource transfer operation for the virtual resource to be transferred; The second setting unit is configured to set the virtual resource to be transferred to an unlocked state and perform a resource transfer operation on the virtual resource to be transferred upon receiving a confirmation feedback for the second resource transfer request sent by the virtual product provider.
9. An electronic device, characterized in that: The method comprises a processor, a memory and a communication interface, wherein the processor, the memory and the communication interface are connected to each other, wherein the communication interface is used to receive and send data, the memory is used to store program code, and the processor is used to call the program code to execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Resource management method and device
CN110599182A
Resource transfer request thread control method and device and storage medium
CN111158878A
Resource transfer method and device, equipment and storage medium
CN112749958A