Electronic red envelope processing method and related device

By obtaining the sub-red envelope parameters and historical random numbers of the red envelope opening request for playback calculation, the sub-resource value of the i-th sub-red envelope is determined, which solves the serial processing waiting problem caused by the lock mechanism during high concurrent red envelope opening requests and realizes parallel processing. Improved response speed and system resource utilization.

CN118628102APending Publication Date: 2024-09-10TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310258847.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-09
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In high-concurrency red packet opening requests, the serial processing wait caused by the lock mechanism results in low system resource utilization, slow response speed, and poor user experience.

Method used

By obtaining the sub-red envelope parameters of the red envelope opening request, the historical random numbers of the previous i-1 sub-red envelopes are obtained, and the playback calculation is performed based on the total resource value to determine the sub-resource value of the i-th sub-red envelope, achieving parallel processing and avoiding the problems caused by the lock mechanism. Serial wait.

Benefits of technology

It greatly improves the response speed of red envelope opening requests, improves the utilization of system resources, avoids serial processing waiting caused by the lock mechanism, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628102A
    Figure CN118628102A
Patent Text Reader

Abstract

The invention discloses an electronic red envelope processing method and a related device, aiming at an electronic red envelope with N sub-red envelopes, when a corresponding red envelope splitting request is processed, sub-red envelope parameters of the red envelope splitting request are acquired, so that the association between the red envelope splitting request and the ith sub-red envelope in the N sub-red envelopes is established. In order to respond to a concurrent red envelope dismantling request for the electronic red envelope without pausing, after the association between the red envelope dismantling request and the ith sub-red envelope is established, historical random numbers corresponding to the first i-1 sub-red envelopes can be obtained, and the first i-1 sub-red envelopes can be replayed in a playback calculation mode. And determining the sub-resource value of the ith sub-red envelope by combining the residual resource value of the electronic red envelope after the sub-resource values corresponding to the first i-1 sub-red envelopes are received and the target random number of the ith sub-red envelope. According to the invention, the method does not need to wait for the completion of the processing of the red envelope dismounting requests corresponding to the first i-1 sub red envelopes, achieves the parallel processing of the red envelope dismounting requests, greatly improves the response speed of the red envelope dismounting requests, and improves the utilization rate of system resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to an electronic red envelope processing method and related devices. Background Art

[0002] With the development of Internet technology, electronic red envelopes have become an effective means of social interaction. For example, an electronic red envelope with multiple sub-red envelopes can be sent in a social group. The electronic red envelope has corresponding resources set in it. Users in the social group can obtain the sub-resources corresponding to one of the sub-red envelopes by clicking on the electronic red envelope (which can also be remembered as opening the red envelope).

[0003] For this type of electronic red envelope with sub-red envelopes, in order to ensure that each sub-red envelope can be allocated sub-resources, a locking mechanism is adopted in the relevant technology, that is, while processing a user's request to open the electronic red envelope, the response to other users' requests to open the red envelope will be suspended.

[0004] When an electronic red envelope has a large number of sub-red envelopes, high-concurrency requests to open the red envelopes will be severely stuck due to the locking mechanism, and the system resource utilization rate will be low. Summary of the invention

[0005] In order to solve the above-mentioned technical problems, the present application provides an electronic red envelope processing method and related devices, which avoids the serial processing wait caused by the locking mechanism during high-concurrency red envelope opening requests, realizes parallel processing of red envelope opening requests, greatly improves the response speed of red envelope opening requests, and improves the utilization rate of system resources.

[0006] The embodiments of the present application disclose the following technical solutions:

[0007] On the one hand, an embodiment of the present application provides an electronic red envelope processing method, the method comprising:

[0008] In response to a red envelope splitting request for an electronic red envelope, obtaining a sub-red envelope parameter corresponding to the red envelope splitting request, wherein the electronic red envelope is configured with a total resource value, the electronic red envelope includes N sub-red envelopes, and the sub-red envelope parameter is used to identify that the red envelope splitting request is associated with an i-th sub-red envelope among the N sub-red envelopes, where N>1;

[0009] Obtaining historical random numbers corresponding to the first i-1 sub-red packets according to the sub-red packet parameters, wherein the historical random numbers are used to determine the sub-resource values ​​of the first i-1 sub-red packets;

[0010] Determine, based on the historical random number and the total resource value, the remaining resource value of the electronic red envelope after the sub-resource values ​​corresponding to the first i-1 sub-red envelopes are received;

[0011] The sub-resource value of the i-th sub-red envelope is determined by the target random number of the i-th sub-red envelope and the remaining resource value.

[0012] On the other hand, an embodiment of the present application provides an electronic red envelope processing device, the device comprising an acquisition unit and a determination unit:

[0013] The acquisition unit is used to, in response to a red envelope splitting request for an electronic red envelope, acquire a sub-red envelope parameter corresponding to the red envelope splitting request, wherein the electronic red envelope is configured with a total resource value, the electronic red envelope includes N sub-red envelopes, and the sub-red envelope parameter is used to identify that the red envelope splitting request is associated with an i-th sub-red envelope among the N sub-red envelopes, where N>1;

[0014] The acquisition unit is further used to acquire the historical random numbers corresponding to the first i-1 sub-red packets according to the sub-red packet parameters, and the historical random numbers are used to determine the sub-resource values ​​of the first i-1 sub-red packets;

[0015] The determining unit is used to determine the remaining resource value of the electronic red packet after the sub-resource values ​​corresponding to the first i-1 sub-red packets are received according to the historical random number and the total resource value;

[0016] The determination unit is also used to determine the sub-resource value of the i-th sub-red envelope through the target random number of the i-th sub-red envelope and the remaining resource value.

[0017] Optionally, the device further comprises a generating unit:

[0018] The generating unit is used to generate the target random number corresponding to the i-th sub-red packet after obtaining the sub-red packet parameters corresponding to the red packet splitting request, and the target random number is used to determine the sub-resource value of the i-th sub-red packet.

[0019] Optionally, the device further includes an updating unit:

[0020] The updating unit is used to associate the sub-red envelope sequence number of the i-th sub-red envelope with the target random number and update it into the sub-red envelope record corresponding to the electronic red envelope;

[0021] The acquisition unit is also used to acquire the historical random numbers corresponding to the first i-1 sub-red packets from the sub-red packet records according to the sub-red packet parameters.

[0022] Optionally, the determining unit is further configured to:

[0023] According to the historical random numbers and collection order of the first i-1 sub-red packets, the sub-resource values ​​corresponding to the sub-red packets are calculated starting from the first sub-red packet;

[0024] Determine the remaining resource value of the e-red envelope according to the total resource value and the sub-resource values of the previous i-1 sub-red envelopes.

[0025] Optionally, for the k-th sub-red envelope among the previous i-1 sub-red envelopes, where k < i-1, the determining unit is further configured to:

[0026] Determine the sub-resource value range corresponding to the k-th sub-red envelope according to the historical remaining resource value of the e-red envelope after the sub-resource values corresponding to the previous k-1 sub-red envelopes are received;

[0027] Determine the sub-resource value corresponding to the k-th sub-red envelope through the historical random number of the k-th sub-red envelope and the sub-resource value range.

[0028] Optionally, the sub-resource value range is used to identify the resource value range between the sub-resource lower limit value and the sub-resource upper limit value, and the determining unit is further configured to:

[0029] Determine the sub-resource mean value of the remaining sub-red envelopes according to the historical remaining resource value, where the remaining sub-red envelopes are the k-th to the N-th sub-red envelopes among the N sub-red envelopes;

[0030] Taking the sub-resource mean value as the center of the range, determine the sub-resource value range corresponding to the k-th sub-red envelope, where the sub-resource lower limit value is greater than zero, and the sub-resource upper limit value is less than or equal to the maximum limit value of the sub-resource value.

[0031] Optionally, the obtaining unit is further configured to:

[0032] In response to a red envelope opening request for the e-red envelope, obtain the counter value for the e-red envelope;

[0033] Increment the counter value to obtain the sub-red envelope serial number i corresponding to the red envelope opening request;

[0034] Generate the sub-red envelope parameters according to the sub-red envelope serial number i.

[0035] Optionally, the obtaining unit is further configured to:

[0036] Obtain the summary update parameters for the sub-red envelopes in the e-red envelope through the summary service process, where the summary update parameters include the sub-red envelope serial numbers and sub-resource values of the sub-red envelopes that have been received in the e-red envelope;

[0037] Update the sub-red envelope record corresponding to the e-red envelope according to the summary update parameters.

[0038] Optionally, the obtaining unit is further configured to:

[0039] Acquire a red envelope opening queue for the electronic red envelope, wherein the red envelope opening queue includes a plurality of to-be-processed red envelope opening requests;

[0040] The pending red envelope opening request is extracted from the red envelope opening queue as the red envelope opening request.

[0041] Optionally, the electronic red envelope includes a group red envelope in a social group, or a live broadcast room red envelope in a live broadcast room.

[0042] Optionally, the device further includes a returning unit, configured to return the sub-resource value of the i-th sub-red envelope in response to the red envelope splitting request.

[0043] On the other hand, an embodiment of the present application provides a computer device, the computer device comprising a processor and a memory:

[0044] The memory is used to store a computer program and transmit the computer program to the processor;

[0045] The processor is configured to execute the method described above according to the computer program.

[0046] On the other hand, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method described in the above aspects.

[0047] On the other hand, an embodiment of the present application provides a computer program product including a computer program, which, when executed on a computer device, enables the computer device to execute the method described in the above aspects.

[0048] It can be seen from the above technical solution that for an electronic red packet with N sub-red packets, when processing the corresponding red packet splitting request, the sub-red packet parameters associated with the red packet splitting request are obtained, so as to establish an association between the red packet splitting request and the ith sub-red packet among the N sub-red packets. In order to be able to respond to concurrent red packet splitting requests for electronic red packets without pausing, after establishing an association between the red packet splitting request and the ith sub-red packet, the historical random numbers corresponding to the first i-1 sub-red packets can be obtained, and the remaining resource value of the electronic red packet after the sub-resource values ​​corresponding to the first i-1 sub-red packets are received is determined by replaying the calculation and combining the total resource value of the electronic red packet, and then the sub-resource value of the ith sub-red packet is determined based on the remaining resource value and the target random number of the ith sub-red packet. Through the above playback calculation, it is possible to determine the accurate remaining resource value of the electronic red envelope before the i-th sub-red envelope is actually received without waiting for the red envelope opening requests corresponding to the first i-1 sub-red envelopes to be processed, thereby achieving the correct determination of the sub-resource value of the i-th sub-red envelope. Therefore, there is no need to use a lock mechanism in the scenario of multiple sub-red envelopes, avoiding the serial processing wait caused by the lock mechanism during high-concurrency red envelope opening requests, and achieving parallel processing of red envelope opening requests, greatly improving the response speed of red envelope opening requests and improving the utilization rate of system resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0050] Figure 1 It is a schematic diagram of a method for opening red envelopes based on a lock mechanism;

[0051] Figure 2 A schematic diagram of an electronic red envelope processing scenario provided in an embodiment of the present application;

[0052] Figure 3 A method flow chart of an electronic red envelope processing method provided in an embodiment of the present application;

[0053] Figure 4a-4b Schematic diagram of the electronic red envelope provided in the embodiment of the present application in different social scenarios;

[0054] Figure 5 A schematic diagram of processing a red envelope opening request;

[0055] Figure 6 A schematic diagram of a process for determining a sub-resource value when sending a red packet;

[0056] Figure 7 A schematic diagram of a playback calculation for the i-th sub-red packet provided in an embodiment of the present application;

[0057] Figure 8 A sub-resource value range comparison diagram based on double mean provided in an embodiment of the present application;

[0058] Fig. 9 A signaling interaction diagram for electronic red envelope processing provided in an embodiment of the present application;

[0059] Fig.10 A schematic diagram of a red envelope opening queue provided in an embodiment of the present application;

[0060] Fig.11 A comparison chart of the opening sequence numbers and average values ​​of random amounts of different electronic red envelopes provided in an embodiment of the present application;

[0061] Fig.12 A comparison chart of red envelope splitting request response rates in an electronic red envelope scenario with a large number of sub-red envelopes provided in an embodiment of the present application;

[0062] Fig.13 A device structure diagram of an electronic red envelope processing device provided in an embodiment of the present application;

[0063] Fig.14 A structural diagram of a terminal device provided in an embodiment of the present application;

[0064] Fig.15 A structural diagram of a server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0065] The embodiments of the present application are described below in conjunction with the accompanying drawings.

[0066] For electronic red packets that include N sub-red packets, the relevant technology mainly uses a lock mechanism (also known as a pessimistic lock) to process red packet splitting requests, so that the sub-resource value corresponding to each sub-red packet can be correctly determined.

[0067] However, the locking mechanism will cause other red envelope opening requests to wait while processing one red envelope opening request. The processing time of a single red envelope opening request is generally 10 to 20 ms. When the electronic red envelope has a large number of sub-red envelopes, for example, hundreds of sub-red envelopes, if the computer device centrally obtains a large number of red envelope opening requests, the computer device can only process the red envelope opening requests serially one by one, resulting in significant lag. From the user's perspective, after clicking on the red envelope to receive it, there is no result for a long time, resulting in a bad experience.

[0068] For example, if an electronic red envelope contains 100 sub-red envelopes, the total time it takes for a computer device to process all red envelope opening requests is about 1 to 2 seconds (calculation: 100*20ms=2s). If the electronic red envelope contains 500 sub-red envelopes, the total time it takes for a computer device to process all red envelope opening requests is about 5 to 10 seconds (calculation: 500*20ms=10s).

[0069] The locking mechanism in the related art can be as follows Figure 1 As shown, the red envelope opening service and order storage engine shown therein are different processes of the computer device for the electronic red envelope. When the computer device processes a red envelope opening request of the electronic red envelope, it first queries the order storage engine for the red envelope order record through the red envelope opening service and locks it. In this way, before the red envelope opening request is processed, the red envelope opening request processing transaction corresponding to the electronic red envelope is locked.

[0070] The red envelope splitting service obtains the remaining resource value of the electronic red envelope and the sub-red envelope associated with the current red envelope splitting request through the information queried from the order storage engine. After calculating the sub-resource value corresponding to the sub-red envelope, the computer device inserts the sub-red envelope record of this time into the order storage engine through the red envelope splitting service, updates the red envelope order record, and unlocks it. Thus, the computer device can continue to process the next red envelope splitting request for the electronic red envelope.

[0071] Under this locking mechanism, when an electronic red envelope has a large number of sub-red envelopes, high-concurrency requests to open the red envelopes will experience severe lag due to the locking mechanism, and the system resource utilization rate will be low.

[0072] To this end, an embodiment of the present application provides an electronic red envelope processing method, which avoids serial processing waiting caused by the locking mechanism during high-concurrency red envelope opening requests, realizes parallel processing of red envelope opening requests, greatly improves the response speed of red envelope opening requests, and improves the utilization rate of system resources.

[0073] The electronic red envelope processing method provided in the embodiment of the present application can be implemented by a computer device, which can be a terminal device or a server, wherein the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Terminal devices include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. The terminal device and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.

[0074] It is understandable that in the specific implementation of the present application, the request to open a red envelope may involve relevant data such as user information. When the above embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0075] Figure 2 This is a schematic diagram of an electronic red envelope processing scenario provided in an embodiment of the present application. In this embodiment, the server 100 is used as the aforementioned computer device for exemplary illustration.

[0076] Server 100 is used to process red envelope splitting requests for an electronic red envelope having N sub-red envelopes. Under high concurrency of red envelope splitting requests, for any red envelope splitting request, the server 100 obtains the sub-red envelope parameters related to the red envelope splitting request, thereby establishing an association between the red envelope splitting request and the i-th sub-red envelope among the N sub-red envelopes.

[0077] In order to be able to respond to concurrent red envelope opening requests for the electronic red envelope without pausing, after establishing an association between the red envelope opening request and the i-th sub-red envelope, the server 100 can obtain the historical random numbers corresponding to the first i-1 sub-red envelopes, and determine the remaining resource value of the electronic red envelope after the sub-resource values ​​corresponding to the first i-1 sub-red envelopes are received through playback calculation combined with the total resource value of the electronic red envelope, and then determine the sub-resource value of the i-th sub-red envelope based on the remaining resource value and the target random number of the i-th sub-red envelope.

[0078] Through the above playback calculation, the server 100 can determine the accurate remaining resource value of the electronic red packet before the i-th sub-red packet is actually received without waiting for the red packet splitting requests corresponding to the first i-1 sub-red packets to be processed, thereby realizing the correct determination of the sub-resource value of the i-th sub-red packet. Thus, the effect of parallel processing of red packet splitting requests is achieved.

[0079] Server 100 does not need to adopt a locking mechanism in the scenario of multiple sub-red envelopes, thus avoiding serial processing waits caused by the locking mechanism during high-concurrency red envelope opening requests, and realizing parallel processing of red envelope opening requests, greatly improving the response speed of red envelope opening requests and improving the utilization rate of system resources.

[0080] Figure 3 This is a method flow chart of an electronic red envelope processing method provided in an embodiment of the present application. The method can be executed by a computer device. In this embodiment, the computer device is a server as an example for explanation. The method includes:

[0081] S301: In response to a request to open an electronic red envelope, obtain sub-red envelope parameters corresponding to the request to open the red envelope.

[0082] The electronic red envelope is a virtual item configured with a certain resource value. In this embodiment, the total resource value configured by the electronic red envelope is recorded as the total resource value. The N sub-red envelopes included in the electronic red envelope can be provided to multiple users, such as N users, for collection through terminal devices. By collecting the sub-red envelopes in the electronic red envelope, the sub-resource values ​​corresponding to the sub-red envelopes can be obtained. For different electronic red envelope push scenarios, the electronic red envelope can have different types. Here, N is an integer greater than 1.

[0083] For example, in one possible implementation, the electronic red envelope includes a group red envelope in a social group, or a live broadcast room red envelope in a live broadcast room.

[0084] Group red envelopes can be exemplified as follows Figure 4a As shown in the figure, in a group chat including 103 users, a user sent an electronic red envelope in the group chat. Figure 4a It shows a user in the group chat clicking on the electronic red envelope. When the virtual button "Open" in the touch interface is further pressed, a request to open the electronic red envelope corresponding to the electronic red envelope can be sent to the server.

[0085] The red envelopes in the live broadcast room can be exemplified as follows Figure 4b As shown in the figure, in a live broadcast room a, the anchor sent an electronic red envelope to the audience in the live broadcast room. Figure 4b It shows a diagram of a viewer in the live broadcast room a clicking on the electronic red envelope. When the virtual button "Open" in the touch interface is further pressed, a request to open the electronic red envelope corresponding to the electronic red envelope can be sent to the server.

[0086] By applying electronic red envelopes to the above-mentioned different social scenarios, electronic red envelopes can be effectively used as a social dimension of the social scenario, thereby enhancing the user's social experience.

[0087] The sub-resource value corresponding to the sub-red envelope in the electronic red envelope may have different possible values, such as a fixed value or a random value. Regardless of whether it is a fixed value or a random value, the sum of the sub-resource values ​​of all sub-red envelopes in the electronic red envelope should be equal to the total resource value of the electronic red envelope.

[0088] In the embodiments of the present application, the main discussion is on the processing method when the sub-resource value is a random value.

[0089] The above-mentioned total resource value and sub-resource value are both numerical values ​​that identify virtual resources. The type of virtual resources is not limited in the embodiment of the present application. For example, it can be virtual gold coins such as diamonds and gems in the game, or it can be digital assets used to exchange physical objects or services.

[0090] The red envelope opening request is obtained by the server from the terminal device. When the user sees the electronic red envelope through the terminal device, by clicking the electronic red envelope or clicking the virtual button such as receiving the red envelope, the terminal device can generate a red envelope opening request based on this interactive behavior and send it to the server for processing. The red envelope opening request is used to instruct the server that the terminal device wants to receive a sub-red envelope from the electronic red envelope.

[0091] In response to the red envelope splitting request, the server will determine which sub-red envelope of the N sub-red envelopes of the electronic red envelope the red envelope splitting request is associated with. That is, the server will obtain the corresponding sub-red envelope parameters through the red envelope splitting request, thereby establishing an association between the red envelope splitting request and the i-th sub-red envelope of the N sub-red envelopes.

[0092] The value of i is within N, that is, i is a positive integer less than or equal to N. The specific determination of the sub-red envelope is related to the timing of the server receiving the red envelope splitting request. For example, when the red envelope splitting request in this step is the 5th red envelope splitting request obtained by the server for the electronic red envelope, when N is greater than 5, the server can determine through the sub-red envelope parameters that the red envelope splitting request is associated with the 5th sub-red envelope in the electronic red envelope, that is, through the red envelope splitting request, the 5th sub-red envelope in the electronic red envelope can be collected.

[0093] S302: Obtain the historical random numbers corresponding to the first i-1 sub-red packets respectively according to the sub-red packet parameters.

[0094] Through S301, the server determines that the currently processed red envelope splitting request is associated with the i-th sub-red envelope, that is, it determines that before the currently processed red envelope splitting request, the sub-resource values ​​corresponding to i-1 sub-red envelopes have been received or are about to be received.

[0095] Since one basis for determining how many sub-resource values ​​a sub-red envelope corresponds to is the remaining resource value of the current electronic red envelope, in order to ensure that the currently processed red envelope splitting request can determine the correct sub-resource value of the i-th sub-red envelope, the server needs to clarify how much resource value is left in the electronic red envelope after the sub-resource values ​​of the current i-1 sub-red envelopes have been claimed.

[0096] As mentioned above, this application mainly discusses the scenario where the sub-resource value is a non-fixed value. In this scenario, in addition to the current remaining resource value of the electronic red envelope, the determination of the sub-resource value of the sub-red envelope also requires a historical random number for determining the sub-resource values ​​of the previous i-1 sub-red envelopes.

[0097] Therefore, when the server obtains the historical random numbers corresponding to the first i-1 sub-red packets, it can determine how many sub-resource values ​​the first i-1 sub-red packets correspond to.

[0098] S303: Determine the remaining resource value of the electronic red envelope after the sub-resource values ​​corresponding to the first i-1 sub-red envelopes are received based on the historical random number and the total resource value.

[0099] The above S302-S303 can be regarded as a playback calculation method provided by this application. Through playback calculation, the remaining resource value of the electronic red envelope can be accurately determined after the sub-resource values ​​corresponding to the first i-1 sub-red envelopes are collected and before the i-th sub-red envelope is collected.

[0100] For example, when i=3, the virtual resources are game coins, and the total resource value of the electronic red envelope is 10 virtual gold coins, the server determines that the sub-resource value of the first sub-red envelope is 3 virtual gold coins, and the sub-resource value of the second sub-red envelope is 0.3 virtual gold coins through the random numbers of the first two sub-red envelopes. After the virtual gold coins corresponding to the first two sub-red envelopes are collected, the remaining resource value of the electronic red envelope is 6.7 virtual gold coins.

[0101] Through this playback calculation, the server does not need to wait for the red envelope opening requests corresponding to the first i-1 sub-red envelopes to be processed before it can start processing the red envelope opening request for the i-th sub-red envelope, thus achieving the effect of parallel processing. No matter how many sub-red envelopes the electronic red envelope includes, and no matter how many high-concurrency red envelope opening requests are obtained in a short period of time, the server's response efficiency to each sub-red envelope will not be significantly delayed.

[0102] In the related technologies, such as Figure 5 As shown, when the server is processing a red envelope opening request, when it processes the current red envelope opening request, it will query the red envelope record and lock it, calculate the sub-resource value of this receipt, write the sub-red envelope record, and then update the red envelope record and release the lock. During the entire locking period, the server will not respond to other red envelope opening requests for the electronic red envelope, which leads to obvious lag in scenarios with high concurrency of red envelope opening requests, such as when grabbing red envelopes in chat groups and live broadcast rooms.

[0103] S304: Determine the sub-resource value of the i-th sub-red envelope through the target random number of the i-th sub-red envelope and the remaining resource value.

[0104] After the server obtains the remaining resource value for the current red packet splitting request through the aforementioned playback calculation, the sub-resource value of the i-th sub-red packet can be accurately determined based on the target random number of the i-th sub-red packet. The sub-resource value can indicate the virtual resource value that can be claimed by the terminal device that initiated the red packet splitting request.

[0105] For example, continuing with the example of virtual gold coins in the previous step, the server determines that the sub-resource value of the third sub-red envelope is 1.5 virtual gold coins based on the target random number of the third sub-red envelope and the remaining resource value of 6.7 virtual gold coins.

[0106] The target random number and historical random number mentioned in this application are both random numbers, which are used to generate the sub-resource value of the corresponding sub-red envelope. This application does not limit the form of the random number, for example, it can be a value between 0-1, etc.

[0107] In a possible implementation, the method further includes:

[0108] In response to the red envelope splitting request, the sub-resource value of the i-th sub-red envelope is returned.

[0109] By returning the sub-resource value of the i-th sub-red envelope to the terminal device that sends the red envelope opening request, the terminal device can be instructed to display the virtual resource value received for the electronic red envelope to the user, thereby improving the user experience of receiving the electronic red envelope.

[0110] It can be seen that through the above playback calculation, it is possible to determine the accurate remaining resource value of the electronic red envelope before the i-th sub-red envelope is actually received without waiting for the red envelope opening requests corresponding to the first i-1 sub-red envelopes to be processed, thereby achieving the correct determination of the sub-resource value of the i-th sub-red envelope. Therefore, there is no need to use a lock mechanism in the scenario of multiple sub-red envelopes, avoiding the serial processing wait caused by the lock mechanism during high-concurrency red envelope opening requests, and achieving parallel processing of red envelope opening requests, greatly improving the response speed of red envelope opening requests, and improving the utilization rate of system resources.

[0111] In some related technologies, the sub-resource value corresponding to each sub-red envelope is determined when the electronic red envelope is generated, rather than determining the sub-resource value when the red envelope is opened. For example Figure 6 As shown, when sending an electronic red envelope, the sub-resource value of each sub-red envelope is randomly generated and written into the red envelope record. When the server processes the electronic red envelope in response to the red envelope opening request, it first queries the red envelope record and locks it, then queries the sub-resource value of this collection based on the associated sub-red envelope sequence number, writes the sub-red envelope record, updates the red envelope record, and then releases the lock.

[0112] The whole process not only involves a locking mechanism, but also because the sub-resource values ​​of all sub-red envelopes are determined when the electronic red envelope is generated, there is a possibility of pre-acquisition for unfair behavior. Therefore, the attacker can use the pre-acquired sub-resource value information to choose the appropriate time to receive the sub-red envelope with the largest sub-resource value.

[0113] To this end, in order to avoid unfair behavior in receiving red envelopes, this application adopts a mechanism to regenerate corresponding random numbers when responding to a request to open a red envelope, so that the sub-resource value corresponding to the associated sub-red envelope can only be determined when the red envelope is opened, effectively avoiding the above-mentioned possibility of unfairness.

[0114] In a possible implementation, after S301: obtaining the sub-red envelope parameters corresponding to the red envelope splitting request, the method further includes:

[0115] Generate the target random number corresponding to the i-th sub-red envelope, and the target random number is used to determine the sub-resource value of the i-th sub-red envelope.

[0116] That is to say, after each sub-red envelope is determined to be associated with the red envelope opening request, the server will generate a random number for the sub-red envelope and use it to determine the corresponding sub-resource value, avoiding the information of the sub-resource value from being pre-acquired before the red envelope is opened, effectively improving the interactive fairness of electronic red envelopes.

[0117] In this application, playback calculation is mainly used to correctly determine the sub-resource value of the sub-red envelope, thereby avoiding the processing restrictions brought by the lock mechanism. In order to better improve the accuracy of the playback calculation, in a possible implementation, before S302: obtaining the historical random numbers corresponding to the first i-1 sub-red envelopes according to the sub-red envelope parameters, the method also includes:

[0118] Update the sub-red envelope sequence number of the i-th sub-red envelope and the target random number in association with each other into the sub-red envelope record corresponding to the electronic red envelope;

[0119] Correspondingly, S302 includes: according to the sub-red envelope parameters, obtaining the historical random numbers corresponding to the first i-1 sub-red envelopes from the sub-red envelope records.

[0120] That is to say, after the server generates the target random number for the i-th sub-red packet, it can be updated to the sub-red packet record corresponding to the electronic red packet, and the association between the sub-red packet serial number i and the target random number is reflected in the sub-red packet record. For each sub-red packet, the server can update its corresponding sub-red packet record based on the above method.

[0121] The sub-red envelope record can be updated in the database (DB) corresponding to the server. When the sub-red envelope record is updated through the order storage engine, the order storage engine can be MySQL InnoDB (one of the database engines of MySQL).

[0122] Since the random number generated by the server for each sub-red envelope will be updated to the sub-red envelope record corresponding to the electronic red envelope before the historical random number is obtained, this method of updating the random number corresponding to the sub-red envelope as soon as possible can effectively improve the synchronization accuracy.

[0123] In the high-concurrency red envelope opening scenario, for each sub-red envelope associated with a red envelope opening request, the server can obtain the historical random numbers corresponding to the previous i-1 sub-red envelopes in real time, reducing the possible waiting time for random number synchronization and further improving the response efficiency of the present application for the high-concurrency red envelope opening scenario.

[0124] Next, the determination of the remaining resource value will be described.

[0125] In a possible implementation manner, S303: Determine the remaining resource value of the electronic red envelope after the sub-resource values corresponding to the previous i-1 sub-red envelopes are received, according to the historical random numbers and the total resource value, including:

[0126] S3031: Calculate the sub-resource values corresponding to the sub-red envelopes in sequence starting from the first sub-red envelope according to the historical random numbers and receiving order of the previous i-1 sub-red envelopes;

[0127] S3032: Determine the remaining resource value of the electronic red envelope according to the total resource value and the sub-resource values of the previous i-1 sub-red envelopes.

[0128] In some scenarios, the sub-red envelopes have a sequential receiving order, and the determination of the sub-resource value of each sub-red envelope needs to be based on the sub-resource values of all the sub-red envelopes with earlier sub-red envelope numbers. Therefore, the server can calculate the sub-resource values corresponding to each sub-red envelope in sequence starting from the beginning according to the receiving order of the sub-red envelopes and the corresponding historical random numbers. Then, according to the total resource value and the sub-resource values of the previous i-1 sub-red envelopes, determine the remaining resource value of the electronic red envelope when the i-th sub-red envelope is to be received.

[0129] Calculating the sub-resource values of the previous sub-red envelopes in sequence through the receiving order can ensure the determination accuracy of the remaining resource value, thereby improving the determination accuracy of the sub-resource value of the i-th sub-red envelope.

[0130] To further illustrate the above sequential calculation method, take the k-th sub-red envelope (k < i-1) among the previous i-1 sub-red envelopes as an example for description.

[0131] In a possible implementation manner, S3031 includes:

[0132] S30311: Determine the range of the sub-resource value corresponding to the k-th sub-red envelope according to the historical remaining resource value of the electronic red envelope after the sub-resource values corresponding to the previous k-1 sub-red envelopes are received;

[0133] S30312: Determine the sub-resource value corresponding to the k-th sub-red envelope through the historical random number of the k-th sub-red envelope and the range of the sub-resource value.

[0134] In the case where the sub-resource value of a sub-red envelope is a random value, such as a lucky red envelope sent in a social group, in order to ensure a certain fairness, that is, the difference between different sub-resource values ​​should not be too large, it is necessary to constrain the range of the sub-resource value of each sub-red envelope by means of an expected value. The sub-resource value range can be understood as a quantitative representation of the expected value.

[0135] Since the remaining resource values ​​involved are different when determining the corresponding sub-resource value for each sub-red packet, the corresponding sub-resource value ranges will also be different. The sub-resource value range is used to constrain the possible random range of the corresponding sub-resource value, that is, the specific value of the sub-resource value is within the corresponding sub-resource value range.

[0136] like Figure 7 As shown in the figure, the total resource value of the electronic red packet is A, which includes N sub-red packets. The sub-resource value of each sub-red packet is calculated, and the corresponding remaining resource value is A', and the remaining number of sub-red packets is N'. When the server determines the sub-resource value of a sub-red packet, it first calculates the sub-resource value range based on A' and N'. Figure 7 The sub-resource value range is identified by the two endpoint values ​​a and b of the range.

[0137] Then, the server obtains the random number Rk of the sub-red packet, that is, the aforementioned historical random number, and the aforementioned sub-resource value range to calculate the corresponding sub-resource value Ak. Specifically, Figure 7 It is determined by the formula Ak=[Rk%(ba)]+a shown in .

[0138] After the determination is completed, the remaining resource value becomes A'=A'-Ak, and the remaining number of sub-red packets becomes N'=N'-1. The server determines whether the current sub-red packet number k is equal to i. If not, the sub-red packet number is increased by 1, and the sub-resource value of the next sub-red packet is calculated. When k=i-1, the A' determined at this time is the remaining resource value for the i-th sub-red packet. When k=i, the Rk determined at this time is the target random number of the i-th sub-red packet, and the determined Ak is the sub-resource value of the i-th sub-red packet.

[0139] The sub-resource value range of a sub-red envelope is used to constrain the value variation range of the sub-resource value of the sub-red envelope, and can be used to identify the resource value range between the sub-resource lower limit and the sub-resource upper limit. If the sub-resource value range is improperly constrained, it may cause the sub-resource values ​​of some sub-red envelopes to be much larger than the sub-resource values ​​of some sub-red envelopes, thus causing unfairness.

[0140] Next, taking the k-th sub-red packet as an example, the sub-resource value range of each sub-red packet can refer to the sub-resource value range determination method of the k-th sub-red packet.

[0141] In a possible implementation, S30311: determining the sub-resource value range corresponding to the kth sub-red envelope according to the historical remaining resource value of the electronic red envelope after the sub-resource values ​​corresponding to the first k-1 sub-red envelopes are received, including:

[0142] Determine the sub-resource mean of the remaining sub-red packets according to the historical remaining resource value, and the remaining sub-red packets are the kth to Nth sub-red packets among the N sub-red packets;

[0143] Taking the sub-resource mean as the range center, determine the sub-resource value range corresponding to the kth sub-red envelope, wherein the sub-resource lower limit value is greater than zero, and the sub-resource upper limit value is less than or equal to the maximum limit value of the sub-resource value.

[0144] The sub-resource average of the remaining sub-red envelopes is the current remaining resource value for the electronic red envelope. For all the remaining sub-red envelopes that have not been associated with the red envelope requests, the average resource value that can be configured for each sub-red envelope.

[0145] The sub-resource mean can be understood as an expected value. The range of the sub-resource value of the kth sub-red envelope should be centered on the sub-resource mean to reflect fairness to the remaining sub-red envelopes. Therefore, in this application, the server uses the sub-resource mean as the range center to determine the sub-resource value range, that is, the distance between the sub-resource upper limit value and the sub-resource lower limit value and the sub-resource mean is approximate. Further, from the perspective of reasonable compliance, the sub-resource lower limit value cannot be equal to zero, and the sub-resource upper limit value cannot exceed the maximum limit of the electronic red envelope for the sub-resource value, such as 200 gold coins.

[0146] When determining the sub-resource value range based on the sub-resource mean, the double mean method can be used, that is, the sub-resource value of each sub-red envelope is no more than twice the sub-resource mean of the remaining sub-red envelopes. However, the traditional double mean calculation method will be unfair when the sub-resource mean is greater than 100, because the sub-resource value range [a, b] is not symmetrical relative to the sub-resource mean.

[0147] Sub-resource value range formula in related technology:

[0148] A i =ξ[a,b],1<=i<=N

[0149]

[0150]

[0151] Note: Restrictions on the sub-resource value range:

[0152] Subresource lower limit

[0153] Sub-resource upper limit

[0154] Moreover, it is necessary to ensure that after the sub-red envelope is collected, the remaining amount of the sub-red envelope must theoretically meet the "sub-resource value rules of the sub-red envelope", for example, it must be greater than zero and not exceed the maximum limit.

[0155] consider Final value There are very few cases, and the random range in these cases is very limited, so this situation can be ignored.

[0156] Under the relevant technology, for the i-th sub-red packet:

[0157] The remaining amount of the red envelope

[0158] The remaining number of sub-red envelopes N' = N-i + 1 (assuming the remaining number of red envelopes N' ≥ 3)

[0159] Then, the random range of the i-th red envelope is:

[0160] A' / (N'-1)>200 A’ / (N’-1)<200 Expected Value A’ / N’<100 / [0.01,(A' / N')*2] A' / N' A' / N'>100 [A'–(N'-1)*200,200] [0.01,200] Not equal to A' / N'

[0161] It can be seen that when the sub-resource mean is greater than 100 relative to the i-th sub-red envelope, the expected value will deviate from the sub-resource mean. Figure 8 As shown in the lower left corner, when the sub-resource mean is 120 (greater than 100), the sub-resource lower limit value of the determined sub-resource value range is too far from the sub-resource mean, while when the sub-resource mean is 65, there is no such problem.

[0162] To this end, this application proposes an optimized double mean processing method.

[0163] Optimized sub-resource value range formula:

[0164] A i =ξ[a,b],1≤i≤N

[0165]

[0166]

[0167] Change description:

[0168] 1. The original "twice the mean" sub-resource value range will be unfair when the red envelope mean is greater than 100, because the sub-resource value range [a, b] is asymmetric.

[0169] 2. After optimization, the "double mean" means that the range of sub-resource values ​​is symmetrical with the "mean" as the midpoint in all cases. Therefore, the expected value of the random value of the sub-resource value will not deviate.

[0170] After calculation:

[0171]

[0172]

[0173] So the simplified random range formula is:

[0174] A i =ξ[a,b],1<=i<=N

[0175]

[0176]

[0177] Description of the value of the sub-resource lower limit a:

[0178] 0.01: The sub-resource value received, with a minimum limit of 0.01.

[0179] The sub-resource value range is centered on the sub-resource mean, with the left and right intervals of equal length, that is, the random expected value is the sub-resource mean.

[0180] Sub-resource upper limit b value description:

[0181] 200: The sub-resource value received, with a maximum limit of 200.

[0182] The sub-resource value range is centered on the sub-resource mean, with the left and right intervals of equal length, that is, the random expected value is the sub-resource mean.

[0183] The basic idea is to use the sub-resource mean as the center of the sub-resource value range, and the shorter of the distances from the sub-resource value range to the minimum limit and the maximum limit (0.01 and 200) as the interval radius to determine the sub-resource value range.

[0184] In this application, for the i-th sub-red packet:

[0185] The remaining amount of the red envelope

[0186] The remaining number of sub-red envelopes N' = N-i + 1 (assuming the remaining number of red envelopes N' ≥ 3)

[0187] Then, the random range of the i-th red envelope is:

[0188] Random Range Expected Value A’ / N’<100 [0.01,(A' / N')*2] A' / N' A' / N'>100 [(A' / N')*2-200,200] A' / N'

[0189] It can also be determined through experiments that this application has better fairness than related technologies. The experimental method is:

[0190] 1. There are 10 sub-red envelopes, and the total amount of the red envelopes is 200, 500, 1000, 1500, and 1800 virtual gold coins respectively

[0191] 2. For each red envelope amount, simulate 20,000 electronic red envelope opening requests

[0192] 3. Calculate the average amount of each sub-red packet (1 to 10)

[0193] The specific experimental parameters can be as follows Fig.11 As shown, the darker one is the curve of the present application, and the lighter one is the curve of the related art.

[0194] Next, a possible implementation method for obtaining sub-red envelope parameters is described. S301: In response to a red envelope splitting request for an electronic red envelope, obtaining sub-red envelope parameters corresponding to the red envelope splitting request includes:

[0195] S3011: In response to a request to open an electronic red envelope, obtaining a counter value for the electronic red envelope;

[0196] S3012: Increment the counter value to obtain the sub-red packet sequence number i corresponding to the red packet splitting request;

[0197] S3013: Generate the sub-red envelope parameters according to the sub-red envelope serial number i.

[0198] That is to say, the server can maintain the sub-red envelope serial numbers of the electronic red envelope through a counter, and increment the counter value each time it responds to a red envelope splitting request for the electronic red envelope, thereby obtaining the sub-red envelope serial number i corresponding to the red envelope splitting request, and establishing an association between the red envelope splitting request and the i-th sub-red envelope based on the sub-red envelope serial number i.

[0199] This counter can be implemented through redis (a database) with higher performance benchmarks.

[0200] Maintaining the sub-red envelope serial numbers of electronic red envelopes through counter values ​​can effectively improve the maintenance accuracy of the sub-red envelope serial numbers and save system resources.

[0201] In general, the server will process red envelope opening requests based on some processes, such as Fig. 9As shown, the red envelope opening service, order storage engine and counter shown therein are all different processes maintained by the server for electronic red envelopes. Since the server will process a large number of red envelope opening requests, and there will be many electronic red envelopes involved, in order to reduce the computational complexity of the above processes and ensure the correctness of the sub-red envelope records for each electronic red envelope, the embodiment of the present application additionally introduces a summary service process to summarize the opening of each electronic red envelope. It should be noted that Fig. 9 The various processes are only examples and may be replaced by other processes or components that can achieve similar functions.

[0202] In a possible implementation, the method further includes:

[0203] S11: obtaining, through a summary service process, summary update parameters for the sub-red packets in the electronic red packet, the summary update parameters including the sub-red packet sequence numbers and sub-resource values ​​of the sub-red packets that have been received in the electronic red packet;

[0204] S12: Update the sub-red envelope record corresponding to the electronic red envelope according to the summary update parameters.

[0205] The summary service process can be run through the same hardware device (such as a server) as the above-mentioned red envelope opening service, order storage engine and counter, or through different hardware devices.

[0206] In this embodiment, after determining the sub-resource value of the i-th sub-red envelope, the red envelope splitting service will send the sub-red envelope serial number and the associated sub-resource value to the aggregation service process. The aggregation service process will classify and aggregate the electronic red envelopes, and aggregate the sub-red envelope serial numbers and sub-resource values ​​belonging to different electronic red envelopes into the aggregation update parameters of the corresponding electronic red envelopes.

[0207] The summary service process can send summary update parameters periodically or based on conditions such as the number of sub-red envelopes received.

[0208] After obtaining the summary update parameter, the server uses it as a basis to update the sub-red envelope record of the corresponding electronic red envelope. Through this update, the correctness of the current red envelope opening information of the electronic red envelope in the server can be improved. The current red envelope opening information includes, for example, the remaining resource value of the electronic red envelope, the sub-red envelope sequence number and sub-resource value of the sub-red envelope that has been received or is about to be received. It can also include the total resource value of the sub-red envelope that has been received, the total number of sub-red envelopes that have been received, the sequence number of the sub-red envelope that is about to be received, etc.

[0209] Although in this application, the server can process the electronic red envelope unpacking requests in parallel, there is still a possibility of slight waiting in the case of high concurrency.

[0210] Therefore, in a possible implementation manner, the method further includes:

[0211] S21: obtaining a red envelope opening queue for the electronic red envelope, wherein the red envelope opening queue includes a plurality of red envelope opening requests to be processed;

[0212] S22: Extract the pending red envelope opening request from the red envelope opening queue as the red envelope opening request.

[0213] The server caches the red envelope opening requests obtained from the terminal device through the red envelope opening queue. The red envelope opening requests corresponding to different electronic red envelopes can be cached in one red envelope opening queue, and the red envelope opening requests for the same electronic red envelope can also be cached in one red envelope opening queue. Before the server processes these red envelope opening requests through the red envelope opening service, they can be recorded as pending red envelope opening requests in this application.

[0214] According to the processing mechanism, the server extracts the pending red envelope opening requests from the red envelope opening queue in the order of entry as red envelope opening requests to perform the processing of the aforementioned embodiment.

[0215] For example Fig.10 As shown, after the server extracts a red packet splitting request from the red packet splitting queue, it obtains the sub-red packet sequence number i to establish an association between the i-th sub-red packet and the red packet splitting request. After determining the target random number of the i-th sub-red packet, the target random number is inserted into the order storage engine, and then the historical random numbers of the previous i-1 sub-red packets are queried and replayed. After determining the sub-resource value of the i-th sub-red packet, the server writes the sub-red packet record and summarizes and updates it through the summary service process.

[0216] The red envelope opening queue can effectively store temporarily accumulated red envelope opening requests, and based on the performance of the queue, can clearly sort out the timing of obtaining red envelope opening requests, thereby improving the efficiency of subsequent processing of red envelope opening requests.

[0217] Next, combine Fig. 9 The technical solution of the present application is described. When the server processes a red envelope splitting request for an electronic red envelope through the red envelope splitting service, it first queries the order storage engine for the red envelope order record, and obtains the sub-red envelope serial number through the counter. Through the returned sub-red envelope serial number i, the server determines that the red envelope splitting request is associated with the i-th sub-red envelope of the electronic red envelope, and generates a target random number corresponding to the i-th sub-red envelope. After generation, the server inserts the target random number into the order storage engine through the red envelope splitting service, so that when other red envelope splitting requests are processed in parallel subsequently, for example, when determining the sub-resource value of the i+1-th sub-red envelope, the target random number corresponding to the i-th sub-red envelope can be synchronized in time.

[0218] After inserting the target random number, the server queries the order storage engine for the historical random numbers of the previous i-1 sub-red packets through the red packet splitting service, and performs the aforementioned playback calculation based on the historical random numbers to obtain the sub-resource value of the i-th sub-red packet.

[0219] The server uses the sub-resource value of the i-th sub-red envelope as the sub-red envelope record of this time, and updates the sub-red envelope record of this time to the order storage engine and the summary service processes through the red envelope splitting service.

[0220] The aggregation service process aggregates the sub-red envelope records from the same electronic red envelope, generates aggregate update parameters, and updates the aggregate update parameters to the order storage engine when the update conditions are met.

[0221] The performance of the present application solution is stable when processing the same electronic red envelope in the same network, server hardware, and storage engine version environment. The time consumption for responding to the red envelope splitting request does not increase with the increase in the number of sub-red envelopes or the increase in the number of concurrent red envelope splitting requests. In the related art, since the red envelope splitting request is processed serially, the time consumption for responding to the red envelope splitting request will increase with the increase in the number of sub-red envelopes or the increase in the number of concurrent red envelope splitting requests. For example Fig.13 As shown, the dark concurrent solution corresponds to the solution of the present application, and the light transaction solution corresponds to the solution of the related art. The horizontal axis in the figure is the number of sub-red envelopes, and the vertical axis is the response time for the red envelope splitting request.

[0222] In the aforementioned Figure 2-4b , Figure 7-Figure 12 Based on the corresponding embodiment, Fig.13 The structure diagram of an electronic red envelope processing device provided in an embodiment of the present application is as follows. The electronic red envelope processing device 1300 includes an acquisition unit 1301 and a determination unit 1302:

[0223] The acquisition unit 1301 is used to, in response to a red envelope splitting request for an electronic red envelope, acquire a sub-red envelope parameter corresponding to the red envelope splitting request, the electronic red envelope being configured with a total resource value, the electronic red envelope including N sub-red envelopes, and the sub-red envelope parameter being used to identify that the red envelope splitting request is associated with an i-th sub-red envelope among the N sub-red envelopes, where N>1;

[0224] The acquisition unit 1301 is further used to acquire the historical random numbers corresponding to the first i-1 sub-red packets according to the sub-red packet parameters, and the historical random numbers are used to determine the sub-resource values ​​of the first i-1 sub-red packets;

[0225] The determining unit 1302 is used to determine the remaining resource value of the electronic red packet after the sub-resource values ​​corresponding to the first i-1 sub-red packets are received according to the historical random number and the total resource value;

[0226] The determining unit 1302 is further configured to determine the sub-resource value of the i-th sub-red envelope based on the target random number of the i-th sub-red envelope and the remaining resource value.

[0227] In a possible implementation, the apparatus further includes a generating unit:

[0228] The generating unit is configured to generate the target random number corresponding to the i-th sub-red envelope after obtaining the sub-red envelope parameters corresponding to the red envelope opening request, where the target random number is used to determine the sub-resource value of the i-th sub-red envelope.

[0229] In a possible implementation, the apparatus further includes an updating unit:

[0230] The updating unit is configured to associatively update the sub-red envelope serial number and the target random number of the i-th sub-red envelope to the sub-red envelope record corresponding to the electronic red envelope;

[0231] The obtaining unit is further configured to obtain the historical random numbers corresponding to the first i - 1 sub-red envelopes respectively from the sub-red envelope record according to the sub-red envelope parameters.

[0232] In a possible implementation, the determining unit is further configured to:

[0233] Calculate the sub-resource values corresponding to the sub-red envelopes in sequence starting from the first sub-red envelope according to the historical random numbers and receiving orders of the first i - 1 sub-red envelopes;

[0234] Determine the remaining resource value of the electronic red envelope according to the total resource value and the sub-resource values of the first i - 1 sub-red envelopes.

[0235] In a possible implementation, for the k-th sub-red envelope among the first i - 1 sub-red envelopes, where k < i - 1, the determining unit is further configured to:

[0236] Determine the range of the sub-resource value corresponding to the k-th sub-red envelope according to the historical remaining resource value of the electronic red envelope after the sub-resource values corresponding to the first k - 1 sub-red envelopes are received;

[0237] Determine the sub-resource value corresponding to the k-th sub-red envelope through the historical random number of the k-th sub-red envelope and the range of the sub-resource value.

[0238] In a possible implementation, the range of the sub-resource value is used to identify the range of resource values between the lower limit value of the sub-resource and the upper limit value of the sub-resource, and the determining unit is further configured to:

[0239] Determine the average sub-resource value of the remaining sub-red envelopes according to the historical remaining resource value, where the remaining sub-red envelopes are the sub-red envelopes from the k-th to the N-th among the N sub-red envelopes;

[0240] Taking the sub-resource mean as the range center, determine the sub-resource value range corresponding to the kth sub-red envelope, wherein the sub-resource lower limit value is greater than zero, and the sub-resource upper limit value is less than or equal to the maximum limit value of the sub-resource value.

[0241] In a possible implementation manner, the acquiring unit is further configured to:

[0242] In response to a red envelope opening request for the electronic red envelope, obtaining a counter value for the electronic red envelope;

[0243] Incrementing the counter value to obtain the sub-red envelope sequence number i corresponding to the red envelope splitting request;

[0244] Generate the sub-red envelope parameters according to the sub-red envelope serial number i.

[0245] In a possible implementation manner, the acquiring unit is further configured to:

[0246] Obtaining, through the aggregation service process, aggregation update parameters for the sub-red packets in the electronic red packet, the aggregation update parameters including the sub-red packet sequence numbers and sub-resource values ​​of the sub-red packets that have been received in the electronic red packet;

[0247] According to the summary update parameters, the sub-red envelope record corresponding to the electronic red envelope is updated.

[0248] In a possible implementation manner, the acquiring unit is further configured to:

[0249] Acquire a red envelope opening queue for the electronic red envelope, wherein the red envelope opening queue includes a plurality of to-be-processed red envelope opening requests;

[0250] The pending red envelope opening request is extracted from the red envelope opening queue as the red envelope opening request.

[0251] In a possible implementation, the electronic red envelope includes a group red envelope in a social group, or a live broadcast room red envelope in a live broadcast room.

[0252] In a possible implementation, the device further includes a returning unit, and the returning unit is configured to return the sub-resource value of the i-th sub-red packet in response to the red packet splitting request.

[0253] It can be seen that for an electronic red packet with N sub-red packets, when processing the corresponding red packet splitting request, the sub-red packet parameters associated with the red packet splitting request are obtained, thereby establishing an association between the red packet splitting request and the ith sub-red packet among the N sub-red packets. In order to be able to respond to concurrent red packet splitting requests for electronic red packets without pausing, after establishing an association between the red packet splitting request and the ith sub-red packet, the historical random numbers corresponding to the first i-1 sub-red packets can be obtained, and the remaining resource value of the electronic red packet after the sub-resource values ​​corresponding to the first i-1 sub-red packets are received is determined by replaying the calculation and combining the total resource value of the electronic red packet, and then the sub-resource value of the ith sub-red packet is determined based on the remaining resource value and the target random number of the ith sub-red packet. Through the above playback calculation, it is possible to determine the accurate remaining resource value of the electronic red envelope before the i-th sub-red envelope is actually received without waiting for the red envelope opening requests corresponding to the first i-1 sub-red envelopes to be processed, thereby achieving the correct determination of the sub-resource value of the i-th sub-red envelope. Therefore, there is no need to use a lock mechanism in the scenario of multiple sub-red envelopes, avoiding the serial processing wait caused by the lock mechanism during high-concurrency red envelope opening requests, and achieving parallel processing of red envelope opening requests, greatly improving the response speed of red envelope opening requests and improving the utilization rate of system resources.

[0254] The embodiment of the present application further provides a computer device, which is the computer device described above and may include a terminal device or a server, and the electronic red envelope processing device described above may be configured in the computer device. The computer device is described below in conjunction with the accompanying drawings.

[0255] If the computer device is a terminal device, see Fig.14 As shown, the embodiment of the present application provides a terminal device, taking the terminal device as a mobile phone as an example:

[0256] Fig.14 FIG. 1 is a block diagram showing a partial structure of a mobile phone related to a terminal device provided in an embodiment of the present application. Fig.14 The mobile phone includes: a radio frequency (RF) circuit 1410, a memory 1420, an input unit 1430, a display unit 1440, a sensor 1450, an audio circuit 1460, a wireless fidelity (WiFi) module 1470, a processor 1480, and a power supply 1490. Those skilled in the art can understand that Fig.14 The mobile phone structure shown in the figure does not constitute a limitation on the mobile phone, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0257] Combine the following Fig.14 A detailed introduction to the various components of the mobile phone:

[0258] The RF circuit 1410 may be used for receiving and sending signals during information transmission or communication or during a call. In particular, after receiving downlink information from a base station, the information is sent to the processor 1480 for processing. In addition, the uplink data is sent to the base station.

[0259] The memory 1420 can be used to store software programs and modules. The processor 1480 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1420. The memory 1420 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1420 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0260] The input unit 1430 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the mobile phone. Specifically, the input unit 1430 may include a touch panel 1431 and other input devices 1432 .

[0261] The display unit 1440 may be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 1440 may include a display panel 1441.

[0262] The mobile phone may also include at least one sensor 1450, such as a light sensor, a motion sensor, and other sensors.

[0263] The audio circuit 1460 , the speaker 1461 , and the microphone 1462 can provide an audio interface between the user and the mobile phone.

[0264] WiFi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the WiFi module 1470. It provides users with wireless broadband Internet access.

[0265] Processor 1480 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. It executes various functions of the mobile phone and processes data by running or executing software programs and / or modules stored in memory 1420 and calling data stored in memory 1420.

[0266] The mobile phone also includes a power source 1490 (such as a battery) for supplying power to various components.

[0267] In this embodiment, the processor 1480 included in the terminal device also has the following functions:

[0268] In response to a red envelope splitting request for an electronic red envelope, obtaining a sub-red envelope parameter corresponding to the red envelope splitting request, wherein the electronic red envelope is configured with a total resource value, the electronic red envelope includes N sub-red envelopes, and the sub-red envelope parameter is used to identify that the red envelope splitting request is associated with an i-th sub-red envelope among the N sub-red envelopes, where N>1;

[0269] Obtaining historical random numbers corresponding to the first i-1 sub-red packets respectively according to the sub-red packet parameters, wherein the historical random numbers are used to determine the sub-resource values ​​of the first i-1 sub-red packets;

[0270] Determine, based on the historical random number and the total resource value, the remaining resource value of the electronic red envelope after the sub-resource values ​​corresponding to the first i-1 sub-red envelopes are received;

[0271] The sub-resource value of the i-th sub-red envelope is determined by the target random number of the i-th sub-red envelope and the remaining resource value.

[0272] If the computer device is a server, the present application embodiment also provides a server, see Fig.15 As shown, Fig.15 The structural diagram of the server 1500 provided in the embodiment of the present application, the server 1500 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) 1522 (for example, one or more processors) and a memory 1532, and one or more storage media 1530 (for example, one or more mass storage devices) storing application programs 1542 or data 1544. Among them, the memory 1532 and the storage medium 1530 can be short-term storage or permanent storage. The program stored in the storage medium 1530 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the server. Furthermore, the central processing unit 1522 can be configured to communicate with the storage medium 1530 and execute a series of instruction operations in the storage medium 1530 on the server 1500.

[0273] The server 1500 may also include one or more power supplies 1526, one or more wired or wireless network interfaces 1550, one or more input and output interfaces 1558, and / or one or more operating systems 1541, such as Windows Server 2003 or Windows Server 2008. TM , Mac OS X TM , Unix TM ,Linux TM, FreeBSD TM etc.

[0274] The steps performed by the server in the above embodiment can be based on Fig.15 The server structure shown.

[0275] In addition, an embodiment of the present application further provides a storage medium, wherein the storage medium is used to store a computer program, and the computer program is used to execute the method provided in the above embodiment.

[0276] The embodiments of the present application also provide a computer program product including a computer program, which, when executed on a computer device, enables the computer device to execute the method provided in the above embodiments.

[0277] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the above program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the above storage medium can be at least one of the following media: read-only memory (English: Read-only Memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store computer programs.

[0278] It should be noted that each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can refer to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, in which the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative work.

[0279] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a technician familiar with the technical field within the technical scope disclosed in the present application should be included in the protection scope of the present application. Moreover, based on the implementation methods provided in the above aspects, the present application can also be further combined to provide more implementation methods. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. An electronic red envelope processing method, characterized in that: The method includes: In response to a red packet opening request for an electronic red packet, obtaining sub - red packet parameters corresponding to the red packet opening request. The electronic red packet is configured with a total resource value, and the electronic red packet includes N sub - red packets. The sub - red packet parameters are used to identify that the red packet opening request is associated with the i - th sub - red packet among the N sub - red packets, where N>1; Obtaining historical random numbers corresponding to the first i - 1 sub - red packets respectively according to the sub - red packet parameters. The historical random numbers are used to determine the sub - resource values of the first i - 1 sub - red packets; Determining the remaining resource value of the electronic red packet after the sub - resource values corresponding to the first i - 1 sub - red packets are received according to the historical random numbers and the total resource value; Determining the sub - resource value of the i - th sub - red packet through the target random number of the i - th sub - red packet and the remaining resource value.

2. The method according to claim 1, characterized in that After obtaining the sub - red packet parameters corresponding to the red packet opening request, the method further includes: Generating the target random number corresponding to the i - th sub - red packet. The target random number is used to determine the sub - resource value of the i - th sub - red packet.

3. The method according to claim 2, characterized in that Before obtaining the historical random numbers corresponding to the first i - 1 sub - red packets respectively according to the sub - red packet parameters, the method further includes: Associating and updating the sub - red packet serial number of the i - th sub - red packet and the target random number to the sub - red packet record corresponding to the electronic red packet; The obtaining the historical random numbers corresponding to the first i - 1 sub - red packets respectively according to the sub - red packet parameters includes: Obtaining the historical random numbers corresponding to the first i - 1 sub - red packets respectively from the sub - red packet record according to the sub - red packet parameters.

4. The method according to claim 1, characterized in that The determining the remaining resource value of the electronic red packet after the sub - resource values corresponding to the first i - 1 sub - red packets are received according to the historical random numbers and the total resource value includes: Calculating the sub - resource values corresponding to the sub - red packets in sequence starting from the first sub - red packet according to the historical random numbers and the receiving order of the first i - 1 sub - red packets; Determining the remaining resource value of the electronic red packet according to the total resource value and the sub - resource values of the first i - 1 sub - red packets.

5. The method according to claim 4, characterized in that For the k - th sub - red packet among the first i - 1 sub - red packets, where k < i - 1, the calculating the sub - resource values corresponding to the sub - red packets in sequence starting from the first sub - red packet according to the historical random numbers and the receiving order of the first i - 1 sub - red packets includes: Determining the range of the sub - resource value corresponding to the k - th sub - red packet according to the historical remaining resource value of the electronic red packet after the sub - resource values corresponding to the first k - 1 sub - red packets are received; Determining the sub - resource value corresponding to the k - th sub - red packet through the historical random number of the k - th sub - red packet and the range of the sub - resource value.

6. The method according to claim 5, characterized in that The range of the sub - resource value is used to identify the resource value range between the sub - resource lower limit value and the sub - resource upper limit value. The determining the range of the sub - resource value corresponding to the k - th sub - red packet according to the historical remaining resource value of the electronic red packet after the sub - resource values corresponding to the first k - 1 sub - red packets are received includes: Determining the average sub - resource value of the remaining sub - red packets according to the historical remaining resource value. The remaining sub - red packets are the sub - red packets from the k - th to the N - th sub - red packets among the N sub - red packets; Taking the sub-resource mean as the range center, determine the sub-resource value range corresponding to the kth sub-red envelope, wherein the sub-resource lower limit value is greater than zero, and the sub-resource upper limit value is less than or equal to the maximum limit value of the sub-resource value.

7. The method according to claim 1, characterized in that The step of obtaining, in response to a red envelope splitting request for an electronic red envelope, sub-red envelope parameters corresponding to the red envelope splitting request includes: In response to a red envelope opening request for the electronic red envelope, obtaining a counter value for the electronic red envelope; Incrementing the counter value to obtain the sub-red envelope sequence number i corresponding to the red envelope splitting request; Generate the sub-red envelope parameters according to the sub-red envelope serial number i.

8. The method according to claim 1, characterized in that The method further comprises: Obtaining, through the aggregation service process, aggregation update parameters for the sub-red packets in the electronic red packet, the aggregation update parameters including the sub-red packet sequence numbers and sub-resource values ​​of the sub-red packets that have been received in the electronic red packet; According to the summary update parameters, the sub-red envelope record corresponding to the electronic red envelope is updated.

9. The method according to claim 1, characterized in that: The method further comprises: Acquire a red envelope opening queue for the electronic red envelope, wherein the red envelope opening queue includes a plurality of to-be-processed red envelope opening requests; The pending red envelope opening request is extracted from the red envelope opening queue as the red envelope opening request.

10. The method according to any one of claims 1 to 9, characterized in that: The electronic red envelopes include group red envelopes in a social group, or live broadcast room red envelopes in a live broadcast room.

11. The method according to any one of claims 1 to 9, characterized in that: The method further comprises: In response to the red envelope splitting request, the sub-resource value of the i-th sub-red envelope is returned.

12. An electronic red envelope processing device, characterized in that: The device comprises an acquisition unit and a determination unit: The acquisition unit is used to, in response to a red envelope splitting request for an electronic red envelope, acquire a sub-red envelope parameter corresponding to the red envelope splitting request, wherein the electronic red envelope is configured with a total resource value, the electronic red envelope includes N sub-red envelopes, and the sub-red envelope parameter is used to identify that the red envelope splitting request is associated with an i-th sub-red envelope among the N sub-red envelopes, where N>1; The acquisition unit is further used to acquire the historical random numbers corresponding to the first i-1 sub-red packets according to the sub-red packet parameters, and the historical random numbers are used to determine the sub-resource values ​​of the first i-1 sub-red packets; The determining unit is used to determine the remaining resource value of the electronic red packet after the sub-resource values ​​corresponding to the first i-1 sub-red packets are received according to the historical random number and the total resource value; The determination unit is also used to determine the sub-resource value of the i-th sub-red envelope through the target random number of the i-th sub-red envelope and the remaining resource value.

13. A computer device, characterized in that: The computer device comprises a processor and a memory: The memory is used to store a computer program and transmit the computer program to the processor; The processor is configured to execute the method according to any one of claims 1 to 11 according to the computer program.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 11.

15. A computer program product comprising a computer program, which, when executed on a computer device, causes the computer device to execute the method according to any one of claims 1 to 11.