Object distribution method and device, electronic equipment and medium
The method and device address over-issuance in object distribution by recording issued objects and using random shuffling to maintain preset ratios, ensuring accurate and efficient distribution.
Patent Information
- Application Number
- CN202411189900.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-28
- Publication Date
- 2024-12-06
AI Technical Summary
Existing object distribution methods often result in over-issuance due to the actual distribution ratio exceeding the preset ratio, particularly when multiple types of objects are distributed with specific ratios, leading to errors in scenarios like prize distributions.
A method and device that manage object distribution by maintaining a record of issued objects, ensuring they are not re-issued, and using a random shuffle algorithm to maintain preset ratios, with status modifications and locking mechanisms to handle concurrency.
Ensures accurate distribution adhering to preset ratios, preventing over-issuance and duplication, while maintaining timeliness and efficiency in high-concurrency scenarios.
Smart Images

Figure CN119090556A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an object distribution method, device, electronic device and medium. Background Art
[0002] In the limited object distribution scenario, the total number of objects that can be distributed is preset, there are multiple types of objects that can be distributed, and various objects need to be distributed according to a certain ratio. For example, in a shopping platform promotion, a total of 1,000 coupons need to be distributed, of which 10% are 100 yuan coupons, 30% are 50 yuan coupons, and 60% are 10 yuan coupons. For another example, in a card distribution event held by a merchant, a total of 500 cards need to be distributed, of which 5% are premium cards, 10% are mid-level cards, and 85% are ordinary cards.
[0003] In this distribution scenario, when the server receives a request from a terminal, it usually randomly selects a category according to the preset distribution ratio of various objects, and sends an object of that category to the terminal. However, this method is prone to the situation where the actual distribution ratio of a certain object exceeds the preset distribution ratio of that object. For example, in a prize distribution event held by a certain group, a total of 4 prizes are set, of which there is 1 first prize with a distribution ratio of 25%, and 3 second prizes with a distribution ratio of 75%. In this case, if the server receives a user request again after the first prize has been distributed, the server will still determine to distribute the first prize to the user with a probability of 25%, resulting in an error of over-distribution of prizes in this method. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide an object distribution method, device, electronic device and medium to avoid the problem of over-issuance in object distribution scenarios. The specific technical solution is as follows:
[0005] In a first aspect of an embodiment of the present application, a method for distributing an object is provided, the method comprising:
[0006] Receiving a request sent by a terminal;
[0007] Acquire a preset number of unissued objects from the inventory list as objects to be issued, the inventory list including multiple objects, and the proportion of the quantity of each object in the total quantity of objects included in the inventory list is a preset issuance proportion of the object;
[0008] Recording in the inventory list that the object to be issued has been issued;
[0009] The object to be distributed is sent to the terminal.
[0010] Optionally, recording in the inventory list that the object to be issued has been issued includes:
[0011] The issuing status of the to-be-issued object in the inventory list is modified to already issued.
[0012] Optionally, before recording in the inventory list that the to-be-issued object has been issued, the method further includes:
[0013] When the object to be issued is obtained, the issuing status of the object to be issued in the inventory list is changed to to be issued;
[0014] If a distribution instruction is received, the step of recording in the inventory list that the object to be distributed has been distributed is performed.
[0015] Optionally, after the object to be issued is acquired and the issuing status of the object to be issued in the inventory list is changed to to be issued, the method further includes:
[0016] If a cancel issuance instruction is received, the issuance status of the to-be-issued object in the inventory list is modified to not issued;
[0017] A prompt message is sent to the terminal, wherein the prompt message indicates that the current object distribution is cancelled.
[0018] Optionally, the method further includes:
[0019] If the issuing status of the to-be-issued object in the inventory list is modified to failed to be issued, the process returns to the step of obtaining a preset number of unissued objects from the inventory list as the to-be-issued objects.
[0020] Optionally, before receiving the acquisition request sent by the terminal, the method further includes:
[0021] According to the preset distribution ratio of each object, a total number of objects is generated;
[0022] The generated arrangement order of the objects is determined according to a random shuffling algorithm, and the objects are stored in the inventory list according to the determined arrangement order.
[0023] Optionally, obtaining a preset number of unissued objects from the inventory list as objects to be issued includes:
[0024] According to the arrangement order of the objects included in the inventory list, a preset number of objects whose issuance status is not issued are selected as the objects to be issued.
[0025] According to a second aspect of an embodiment of the present application, an object distribution device is provided, the device comprising:
[0026] A receiving module, used for receiving an acquisition request sent by a terminal;
[0027] An acquisition module is used to acquire a preset number of unissued objects from a stock list as objects to be issued, wherein the stock list includes multiple objects, and the proportion of the quantity of each object in the total quantity of objects included in the stock list is a preset issuance proportion of the object;
[0028] A recording module, used for recording in the inventory list that the to-be-issued object acquired by the acquisition module has been issued;
[0029] A sending module is used to send the object to be distributed obtained by the obtaining module to the terminal.
[0030] Optionally, the recording module is specifically used to:
[0031] The issuing status of the to-be-issued object in the inventory list is modified to already issued.
[0032] Optionally, the device further comprises:
[0033] A modification module, configured to modify the issuance status of the object to be issued in the inventory list to "to be issued" when the object to be issued is acquired before recording that the object to be issued has been issued in the inventory list;
[0034] The calling module is used for calling the recording module to execute the step of recording in the inventory list that the object to be issued has been issued if a issuing instruction is received.
[0035] Optionally, the modification module is further configured to, after the object to be issued is acquired, modify the issuance status of the object to be issued in the inventory list to be issued, and if a cancel issuance instruction is received, modify the issuance status of the object to be issued in the inventory list to not issued;
[0036] The sending module is further used to send a prompt message to the terminal, wherein the prompt message indicates that the object distribution is cancelled.
[0037] Optionally, the calling module is further used to:
[0038] If the issuing status of the to-be-issued object in the inventory list is modified to failed to be issued, the acquisition module is called to execute the step of acquiring a preset number of unissued objects from the inventory list as the to-be-issued objects.
[0039] Optionally, the device further comprises:
[0040] A generating module, used for generating the total number of objects, i.e., objects, according to a preset distribution ratio of each object before the acquisition request sent by the receiving terminal;
[0041] The storage module is used to determine the arrangement order of the objects generated by the generation module according to the random shuffle algorithm, and store the objects in the inventory list according to the determined arrangement order.
[0042] Optionally, the acquisition module is specifically used to:
[0043] According to the arrangement order of the objects included in the inventory list, a preset number of objects whose issuance status is not issued are selected as the objects to be issued.
[0044] According to a third aspect of an embodiment of the present application, an electronic device is provided, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0045] Memory, used to store computer programs;
[0046] The processor is used to implement the object distribution method described in any one of the first aspects above when executing the program stored in the memory.
[0047] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the object distribution method described in any one of the first aspects is implemented.
[0048] In a fifth aspect of the embodiments of the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the object distribution methods described above.
[0049] The object distribution method, device, electronic device and medium provided in the embodiments of the present application can obtain a preset number of unissued objects from the inventory list as objects to be issued after receiving an acquisition request sent by a terminal, and then record in the inventory list that the objects to be issued have been issued, and send the objects to be issued to the terminal, thereby ensuring that the objects sent to the terminal have not been issued, and the objects will not be issued again after being sent to the terminal. Moreover, the inventory list includes multiple objects, and the proportion of the number of each object in the total number of objects included in the inventory list is the preset issuance ratio of the object, that is, the number of each object that can be issued is controlled to be the product of the preset issuance ratio of the object and the total number of objects, so that the actual number of each object issued will not exceed the product, thereby avoiding the problem of over-issuance. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] 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 are briefly introduced below.
[0051] Figure 1 A flowchart of an object distribution method provided in an embodiment of the present application;
[0052] Figure 2 A flow chart of a method for building an inventory list provided in an embodiment of the present application;
[0053] Figure 3 A flowchart of another object distribution method provided in an embodiment of the present application;
[0054] Figure 4 A schematic diagram of the structure of an object distribution device provided in an embodiment of the present application;
[0055] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0056] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0057] In order to avoid the problem of over-issuance in object distribution scenarios, the present application embodiment provides an object distribution method, which is applied to electronic devices, which can be devices with communication and data processing capabilities such as servers, desktop computers or laptops. The following embodiments are described by taking the electronic device as a server as an example. Figure 1 As shown, the object distribution method provided in the embodiment of the present application includes the following steps:
[0058] S101: receiving an acquisition request sent by a terminal.
[0059] Optionally, the terminal may display the distribution webpage through a browser, then receive the acquisition instruction triggered by the user in the distribution webpage, and send an acquisition request to the server. Alternatively, the terminal may display the distribution page through an application (APPlication, APP), then receive the acquisition instruction triggered by the user in the distribution page, and send an acquisition request to the server. Alternatively, the terminal may send the acquisition request to the server in other ways, which is not specifically limited in the embodiments of the present application.
[0060] S102: Obtain a preset number of unissued objects from the inventory list as objects to be issued. The inventory list includes multiple objects, and the proportion of the quantity of each object in the total quantity of objects included in the inventory list is the preset issuance ratio of the object. The preset number can be set according to actual needs, for example, the preset number is 1.
[0061] The embodiments of the present application can be applied to various object distribution scenarios. In different object distribution scenarios, the various objects in the inventory list are different, and the various objects can be set according to the actual scenario.
[0062] For example, in a promotion scenario, the various objects in the inventory list are: 5-yuan coupons, 10-yuan coupons, and 20-yuan coupons, among which the preset distribution ratio of the 5-yuan coupon is 85%, the preset distribution ratio of the 10-yuan coupon is 10%, and the preset distribution ratio of the 20-yuan coupon is 5%. Assuming that the total number of objects in the inventory list is 1,000, it includes 850 5-yuan coupons, 100 10-yuan coupons, and 50 20-yuan coupons.
[0063] For another example, in a card distribution scenario, the various objects in the inventory list are: premium cards, intermediate cards, and ordinary cards, where the preset distribution ratio of premium cards is 5%, the preset distribution ratio of intermediate cards is 10%, and the preset distribution ratio of ordinary cards is 85%. Assuming that the total number of objects in the inventory list is 1000, it includes 850 ordinary cards, 100 intermediate cards, and 50 premium cards. Among them, the cards in the inventory list are virtual cards, such as digital card collections.
[0064] S103. Record in the inventory list that the object to be issued has been issued.
[0065] By recording in the inventory list that the object to be issued has been issued, it can be ensured that the next time a request is received and the object is obtained from the inventory list, the object to be issued this time will not be obtained, thereby avoiding the situation where the same object is issued repeatedly.
[0066] S104: Send the object to be distributed to the terminal.
[0067] Optionally, S103 and S104 may be executed simultaneously. Alternatively, S103 and S104 may be executed sequentially, that is, S103 is executed first and then S104, or S104 is executed first and then S103. The present embodiment of the application does not specifically limit the execution order of S103 and S104.
[0068] The object distribution method provided in the embodiment of the present application can obtain a preset number of unissued objects from the inventory list as objects to be issued after receiving an acquisition request sent by a terminal, and then record in the inventory list that the objects to be issued have been issued, and send the objects to be issued to the terminal, thereby ensuring that the objects sent to the terminal have not been issued, and the objects will not be issued again after being sent to the terminal. In addition, the inventory list includes multiple objects, and the proportion of the number of each object in the total number of objects included in the inventory list is the preset issuance ratio of the object, that is, the number of each object that can be issued is controlled to be the product of the preset issuance ratio of the object and the total number of objects, so that the number of each object actually issued will not exceed the product, thereby avoiding the problem of over-issuance.
[0069] The object distribution method provided in the embodiment of the present application is described in detail below:
[0070] In the embodiment of the present application, Figure 1 Before the object distribution process shown, the server can also pre-build the inventory list, such as Figure 2 As shown, the construction method includes the following steps:
[0071] S201. Generate a total number of objects according to a preset distribution ratio for each object.
[0072] The server may calculate, for each object, a product N of a preset distribution ratio of the object and a total number of objects, and generate N objects of the object.
[0073] The preset distribution ratio of each object and the total number of objects can be set according to actual needs. For example, a company prepares a total of 100 cards for a card distribution activity, including 50 premium cards and 50 mid-level cards. At this time, the total number of objects is 100, and the preset distribution ratio of premium cards and mid-level cards is 50%.
[0074] S202: Determine the arrangement order of each object generated according to the random shuffle algorithm, and store each object in the inventory list according to the determined arrangement order.
[0075] Optionally, the random shuffle algorithm may be: Fisher-Yates Shuffle or Knuth-Durstenfeld Shuffle, etc.
[0076] pass Figure 2In the process shown, the embodiment of the present application can pre-generate the total number of objects that need to be issued, randomly shuffle the order of all objects, and store all objects in the inventory list in the shuffled order. Since the order of all objects in the inventory list is randomly shuffled, the position of each object in the inventory list is randomly distributed, which not only ensures the randomness of the type of objects distributed each time when the objects are subsequently issued according to the inventory list, but also ensures that at each stage of issuing objects, the proportion of the number of various objects issued in the total amount issued at that stage can be close to the preset issuance ratio of the object. In addition, using the inventory list to issue objects can also ensure that there will be no over-issuance problem for each object.
[0077] In an embodiment of the present application, the above-mentioned S102 server obtains a preset number of unissued objects from the inventory list as objects to be issued, which can be implemented as follows: according to the arrangement order of the objects included in the inventory list, a preset number of objects with an issuance status of unissued are selected as objects to be issued.
[0078] After building the inventory list, the server can store the inventory list in a database, where the database supports an optimistic locking mechanism that allows each object in the inventory list to have a release status, and the release status can be modified. Therefore, when searching for objects to be released, the server can search the database for a preset number of objects in the inventory list with a release status of not released based on the optimistic locking mechanism as objects to be released.
[0079] Alternatively, after building the inventory list, the server can store the inventory list in the cache middleware, thereby improving the efficiency of obtaining the objects to be issued from the inventory list and modifying the issuance status of the objects. The cache middleware supports a distributed lock mechanism, which allows each object in the inventory list to have an issuance status, and the issuance status can be modified. Therefore, when the server searches for objects to be issued, it can search the cache middleware for a preset number of objects in the inventory list with an issuance status of not being issued based on the distributed lock mechanism as the objects to be issued.
[0080] Exemplarily, assuming that the issuance status is 0, indicating that the object has not been issued, and the preset quantity is 1, the server can select the first object with the issuance status of 0 as the object to be issued according to the arrangement order of the objects included in the inventory list.
[0081] Since the order of the various objects stored in the inventory list has been randomly disrupted, the objects are distributed in the order of the objects in the inventory list, which not only ensures the randomness of the types of objects distributed each time, but also ensures that the number of various objects distributed in each stage and the total amount distributed in that stage are close to the preset distribution ratio of the objects. In addition, only the objects to be distributed whose distribution status is not distributed can be obtained, which can avoid the duplication of the distributed objects and avoid the problem of over-distribution.
[0082] In the embodiment of the present application, the above-mentioned S103 server records in the inventory list that the object to be issued has been issued, which can be implemented as: modifying the issuance status of the object to be issued in the inventory list to already issued.
[0083] For example, the issuing status of 2 indicates that the object has been issued. In this case, the server may modify the issuing status of the object to be issued in the inventory list to 2.
[0084] The inventory list can be stored in a database or cache middleware, so the server can modify the issuance status of the objects to be issued in the inventory list in the database to have been issued based on the optimistic locking mechanism, or modify the issuance status of the objects to be issued in the inventory list in the cache middleware to have been issued based on the distributed locking mechanism.
[0085] Because the server only takes the unissued objects as the objects to be issued when acquiring the objects to be issued, after acquiring the objects to be issued, the issuance status of the objects to be issued in the inventory list is changed to issued, so that when the subsequent server receives other acquisition requests, it will not repeatedly acquire and issue the object again, thus avoiding repeated issuance of the same object and avoiding the problem of over-issuance.
[0086] In the embodiment of the present application, before the server records in the inventory list that the object to be issued has been issued in S103, it can also modify the issuance status of the object to be issued in the inventory list to pending issuance when the object to be issued is obtained in S102, wherein pending issuance indicates that the object has been determined as an object to be issued and is waiting to be issued to the terminal. If the server receives the issuance instruction, it executes the step of recording in the inventory list that the object to be issued has been issued in S103.
[0087] For example, a release status of 1 indicates that the object is to be released. When the server obtains the object to be released, the release status of the object to be released in the inventory list may be modified to 1.
[0088] The inventory list can be stored in a database or cache middleware, so the server can modify the issuance status of the objects to be issued in the inventory list in the database to be issued based on the optimistic locking mechanism, or modify the issuance status of the objects to be issued in the inventory list in the cache middleware to be issued based on the distributed locking mechanism.
[0089] The issuing instruction is used to indicate that the object to be issued is allowed to be issued to the terminal. The specific meaning of the issuing instruction is different in different scenarios, and the sender of the issuing instruction is different, which can be set according to actual needs.
[0090] For example, in a shopping scenario, when a user needs to purchase an object, the terminal sends a request to the server, and the server sends a payment request to the third-party payment platform. The third-party payment platform sends a payment page to the server, and the server sends a payment page to the terminal. After the third-party payment platform detects that the terminal has successfully paid on the payment page, it sends a release instruction to the server, which indicates that the terminal has successfully paid.
[0091] For another example, in an object distribution scenario for a specific user, the terminal sends a request to the server, wherein the request carries identity verification parameters, such as the identity verification parameters including: the terminal's device identifier (ID) and / or user ID. Afterwards, the server sends the identity verification parameters in the request to the verification device, so that the verification device verifies whether the terminal is qualified to obtain the object to be issued based on the identity verification parameters. If the verification is successful, the issuing instruction is sent to the server, and the issuing instruction indicates that the terminal is qualified to obtain the object to be issued.
[0092] Through the above method, the embodiment of the present application can modify the issuing status of the object to be issued to pending issuance after obtaining the object to be issued, so as to prevent the object to be issued from being repeatedly obtained. When the issuing instruction is received, that is, it is confirmed that the object to be issued can be issued to the terminal, the step S103 is executed to record in the inventory list that the object to be issued has been issued, so as to ensure the accuracy of issuing the object to be issued.
[0093] In an embodiment of the present application, before the above-mentioned S103 server records in the inventory list that the object to be issued has been issued, if the issuance status of the object to be issued selected in the inventory list is changed to failure to issue, it can return to S102 to obtain a preset number of unissued objects from the inventory list as the step of objects to be issued.
[0094] In the embodiment of the present application, it is allowed that there are multiple servers to which the object distribution method is applied, and the multiple servers share the same inventory list. Or it is allowed that there are multiple threads in the server that execute the object distribution method, and the multiple threads share the same inventory list. Therefore, in a high concurrency scenario, there are multiple servers that receive the acquisition request at the same time, and simultaneously obtain the same object to be issued with a release status of not being issued, or there are multiple threads that receive the acquisition request at the same time, and simultaneously obtain the same object to be issued with a release status of not being issued. However, if one of the servers or one of the threads successfully changes the release status of the object to be issued to to be issued, then other servers or threads cannot change the release status of the object to be issued to to be issued again, that is, the modification fails. Therefore, if the server fails to change the release status of the object to be issued selected in the inventory list to to be issued, it can return to S102 to re-acquire the object to be issued.
[0095] When the issuing status of the object to be issued in the inventory list is changed to issuing failure, it means that the object to be issued has been acquired. Therefore, the server may return to S102 to acquire the object to be issued again, thereby avoiding repeated issuance of the same object.
[0096] In the embodiment of the present application, when the server obtains the object to be issued, after changing the issuing status of the object to be issued in the inventory list to to be issued, there may be a situation where the issuing of the object to be issued needs to be canceled. At this time, if the server receives the cancel issuing instruction, it changes the issuing status of the object to be issued in the inventory list to not issued, and sends a prompt message to the terminal, wherein the prompt message indicates that the issuing of this object is canceled.
[0097] The cancelling issuing instruction is used to indicate that the issuing object to the terminal is not allowed. The issuing instruction has different specific meanings in different scenarios, and the sender of the issuing instruction is different, which can be set according to actual needs.
[0098] For example, in a shopping scenario, when a user needs to purchase an object, the terminal sends a request to the server, and the server sends a payment request to the third-party payment platform. The third-party payment platform sends a payment page to the server, and the server sends the payment page to the terminal. After the third-party payment platform detects that the terminal cancels the payment on the payment page, it sends a cancel issuance instruction to the server, and the cancel issuance instruction indicates that the terminal cancels the payment.
[0099] For another example, in an object distribution scenario for a specific user, the terminal sends a request to the server, wherein the request carries identity verification parameters. Afterwards, the server sends the identity verification parameters in the request to the verification device, so that the verification device verifies whether the terminal is qualified to obtain the object to be distributed based on the identity verification parameters. If the verification fails, a cancellation instruction is sent to the server, and the cancellation instruction indicates that the terminal is not qualified to obtain the object to be distributed.
[0100] The inventory list can be stored in a database or cache middleware, so the server can modify the issuance status of the objects to be issued in the inventory list in the database to not issued based on the optimistic locking mechanism, or modify the issuance status of the objects to be issued in the inventory list in the cache middleware to not issued based on the distributed locking mechanism.
[0101] Since receiving the cancel issuance instruction indicates that the object to be issued cannot be issued to the terminal, the server can modify the issuance status of the object to be issued in the inventory list to not issued, so that the object can be obtained again and then issued, thereby avoiding the object from being missed by mistake. In addition, the server also sends a prompt message to the terminal so that the terminal can know that the issuance of the object is canceled, so as to resend the acquisition request to the server later.
[0102] See also Figure 3 The following is an example of the overall process of the object distribution method provided in the embodiment of the present application, combined with actual application scenarios:
[0103] S301. Generate a total number of objects according to a preset distribution ratio for each object.
[0104] S302: Determine the arrangement order of each object generated according to the random shuffle algorithm, and store each object in the inventory list according to the determined arrangement order.
[0105] S303: Receive an acquisition request sent by the terminal.
[0106] S304. According to the arrangement order of the objects included in the inventory list, select the first object whose release status is 0 as the object to be released.
[0107] S305: Determine whether the change of the release status of the object to be released in the inventory list to 1 is successful. If successful, execute S306; if unsuccessful, return to S304.
[0108] S306: Determine whether a distribution instruction or a cancellation distribution instruction is received. If a distribution instruction is received, execute S307; if a cancellation distribution instruction is received, execute S309.
[0109] S307. Change the issuance status of the object to be issued in the inventory list to 2, and execute S308.
[0110] S308: Send the object to be distributed to the terminal.
[0111] S309: Change the issuance status of the objects to be issued in the inventory list to 0, and send a prompt message to the terminal.
[0112] In conventional object distribution methods, a category is generally randomly selected according to the preset distribution ratio of various objects to be distributed, and an object of this category is sent to the terminal. In this distribution scenario, when the server receives the acquisition request from the terminal, it generally first determines whether the current distribution total amount of each object exceeds the preset total number of objects. If not, a category is randomly selected according to the preset distribution ratio of various objects, an object of this category is sent to the terminal, and the current distribution total amount is increased by 1. However, in a high-concurrency scenario, there is a situation where multiple threads in the server read the current distribution total amount at the same time. If the current distribution total amount does not exceed the preset total number of objects, these multiple threads will each send an object to the terminal. After that, when these multiple threads each increase the current distribution total amount by 1, it may cause the current distribution total amount to exceed the preset total number of objects, that is, there is an over-distribution problem.
[0113] The embodiment of the present application can set the issuance status for each object separately, so that each object is controlled to be issued only once, and the total quantity of various objects is preset, thus avoiding the problem of over-issuance.
[0114] Moreover, the random selection algorithm used in the conventional object distribution method can only make the actual distribution quantity of each object in the total distribution close to the preset distribution ratio of the object when the total distribution quantity of objects is large enough. However, when the total distribution quantity of various objects is small, the actual distribution ratio of each object may be greatly different from the preset distribution ratio of the object.
[0115] In the embodiment of the present application, all objects that need to be distributed are generated in advance according to the preset distribution ratio of each object. Therefore, after all objects are distributed, the actual distribution ratio of each object is the preset distribution ratio of the object, ensuring that each object is distributed according to the actual required ratio. In addition, when distributing objects, the embodiment of the present application does not need to calculate the type of objects that need to be distributed every time, thereby improving the distribution timeliness.
[0116] Based on the same inventive concept, corresponding to the above method embodiment, the present application embodiment also provides an object distribution device, such as Figure 4 As shown, the device includes: a receiving module 401, an acquiring module 402, a recording module 403 and a sending module 404;
[0117] The receiving module 401 is used to receive an acquisition request sent by a terminal;
[0118] The acquisition module 402 is used to acquire a preset number of unissued objects from the inventory list as objects to be issued. The inventory list includes multiple objects, and the proportion of the quantity of each object in the total quantity of objects included in the inventory list is the preset issuance proportion of the object;
[0119] A recording module 403, used for recording in the inventory list that the to-be-issued object acquired by the acquisition module 402 has been issued;
[0120] The sending module 404 is used to send the object to be distributed obtained by the obtaining module 402 to the terminal.
[0121] Optionally, the recording module 403 is specifically used for:
[0122] Change the release status of the objects to be released in the inventory list to released.
[0123] Optionally, the device further comprises:
[0124] A modification module is used for, before recording in the inventory list that the object to be issued has been issued, when the object to be issued is obtained, modifying the issuance status of the object to be issued in the inventory list to to be issued;
[0125] The calling module is used for, if receiving the issuing instruction, calling the recording module 403 to execute the step of recording in the inventory list that the object to be issued has been issued.
[0126] Optionally, the modification module is further configured to, when the to-be-issued object is acquired, modify the issuance status of the to-be-issued object in the inventory list to to-be-issued, and if a cancel issuance instruction is received, modify the issuance status of the to-be-issued object in the inventory list to not issued;
[0127] The sending module 404 is further used to send a prompt message to the terminal, where the prompt message indicates that the current object distribution is cancelled.
[0128] Optionally, the calling module is also used to:
[0129] If the issuing status of the to-be-issued object in the inventory list is modified to failed to be issued, the acquisition module 402 is called to execute the step of acquiring a preset number of unissued objects from the inventory list as the to-be-issued objects.
[0130] Optionally, the device further comprises:
[0131] A generating module, used for generating a total number of objects according to a preset distribution ratio of each object before receiving an acquisition request sent by a terminal;
[0132] The storage module is used to determine the arrangement order of each object generated by the generation module according to the random shuffle algorithm, and store each object in the inventory list according to the determined arrangement order.
[0133] Optionally, the acquisition module 402 is specifically used to:
[0134] According to the arrangement order of the objects included in the inventory list, a preset number of objects whose issuance status is not issued are selected as objects to be issued.
[0135] The present application also provides an electronic device, such as Figure 5 As shown, it includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0136] Memory 503, used for storing computer programs;
[0137] The processor 501 is used to implement the method executed by the electronic device in the above method embodiment when executing the program stored in the memory 503.
[0138] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0139] The communication interface is used for communication between the above electronic device and other devices.
[0140] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0141] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0142] In another embodiment provided in the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the object distribution method described in any one of the above embodiments is implemented.
[0143] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the object distribution method described in any one of the above embodiments.
[0144] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0145] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0146] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0147] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. An object distribution method, characterized in that: The method comprises: Receiving a request sent by a terminal; Acquire a preset number of unissued objects from the inventory list as objects to be issued, the inventory list including multiple objects, and the proportion of the quantity of each object in the total quantity of objects included in the inventory list is a preset issuance proportion of the object; Recording in the inventory list that the object to be issued has been issued; The object to be distributed is sent to the terminal.
2. The method according to claim 1, characterized in that: The recording in the inventory list that the object to be issued has been issued includes: The issuing status of the to-be-issued object in the inventory list is modified to already issued.
3. The method according to claim 1, characterized in that Before recording in the inventory list that the object to be issued has been issued, the method further includes: When the object to be issued is obtained, the issuing status of the object to be issued in the inventory list is changed to to be issued; If a distribution instruction is received, the step of recording in the inventory list that the object to be distributed has been distributed is performed.
4. The method according to claim 3, characterized in that After the object to be issued is acquired and the issuing status of the object to be issued in the inventory list is changed to to be issued, the method further includes: If a cancel issuance instruction is received, the issuance status of the to-be-issued object in the inventory list is modified to not issued; A prompt message is sent to the terminal, wherein the prompt message indicates that the current object distribution is cancelled.
5. The method according to claim 3, characterized in that: The method further comprises: If the issuing status of the to-be-issued object in the inventory list is modified to failed to be issued, the process returns to the step of obtaining a preset number of unissued objects from the inventory list as the to-be-issued objects.
6. The method according to any one of claims 1 to 5, characterized in that: Before receiving the acquisition request sent by the terminal, the method further includes: According to the preset distribution ratio of each object, a total number of objects is generated; The generated arrangement order of the objects is determined according to a random shuffling algorithm, and the objects are stored in the inventory list according to the determined arrangement order.
7. The method according to claim 6, characterized in that The step of obtaining a preset number of unissued objects from the inventory list as objects to be issued includes: According to the arrangement order of the objects included in the inventory list, a preset number of objects whose issuance status is not issued are selected as the objects to be issued.
8. An object distribution device, characterized in that: The device comprises: A receiving module, used for receiving an acquisition request sent by a terminal; An acquisition module is used to acquire a preset number of unissued objects from a stock list as objects to be issued, wherein the stock list includes multiple objects, and the proportion of the quantity of each object in the total quantity of objects included in the stock list is a preset issuance proportion of the object; A recording module, used for recording in the inventory list that the to-be-issued object acquired by the acquisition module has been issued; A sending module is used to send the object to be distributed obtained by the obtaining module to the terminal.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method according to any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
