Detailed Description
As described in the background art, in order to ensure that the electronic ticket sent to the user each time in a sending period is unique, the existing method for sending the electronic ticket employs a method of marking each electronic ticket, for example, an electronic ticket that is not sent is marked as T, and an electronic ticket that has been sent is marked as F, so that the electronic ticket marked as F is not sent again.
However, the adoption of such a marking method can result in excessive consumption of server resources. For example, if 100 electronic tickets are sent by the server in the first sending period and the labels of the 100 electronic tickets are all modified from T to F, the 100 electronic tickets marked as F cannot be sent in the next sending period because the server only selects the electronic ticket marked as T to send. Therefore, in the conventional method for sending the electronic tickets, after each sending cycle is finished, the marks of the electronic tickets need to be reset or the electronic tickets marked as T need to be regenerated, which consumes excessive server resources and affects the efficiency of sending the electronic tickets by the server.
The core idea of one or more embodiments of the present specification is to set, for each sending period, an available identifier corresponding to the sending period, and in each sending period, a label of an electronic ticket that is not sent is the available identifier corresponding to the current sending period, but a label of the sent electronic ticket is modified, and the modified label is not the available identifier corresponding to the current sending period but is an available identifier corresponding to a subsequent sending period. By executing the sending rule, the server does not need to reset the marks of the electronic coupons after each sending period is finished, and does not need to regenerate the electronic coupons marked as T.
In order to make the technical solutions in the present application better understood, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in one or more embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any inventive step based on the embodiments of the present disclosure, shall fall within the scope of protection of the present application.
The technical solutions provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method for setting a step value according to an embodiment of the present disclosure, including the following steps:
s100: and receiving a pickup request sent by a user.
In the embodiment, the server can receive a pickup request for the electronic ticket sent by a user through a communication device (a computer, a mobile phone and the like capable of surfing the Internet), so as to trigger the operation of sending the electronic ticket to the user. Wherein each electronic ticket is generated and stored by the server. The electronic ticket may be specifically an electronic lottery ticket, an electronic password, and the like.
S102: and determining a sending period corresponding to the pickup request according to the pickup request, and determining an available identifier corresponding to the sending period.
In this embodiment, the server may determine, according to the time for the user to send the pickup request included in the pickup request, a sending period corresponding to the pickup request, that is, determine a current sending period. In the context of one or more embodiments of the present disclosure, the server periodically transmits electronic tickets, and the electronic tickets retrieved by each user are different during a transmission period.
In this case, the transmission cycle corresponding to the pickup request specified by the server may not necessarily be the current transmission cycle, but may be another transmission cycle specified by the user, and the server may start execution of the subsequent steps S104 to S106 after starting another transmission cycle specified by the user. In short, the server may determine, according to a pickup request sent by a user, a timing at which the user wants to pick up an electronic ticket, thereby sending the electronic ticket to the user in a corresponding sending period.
After determining the sending period corresponding to the pickup request, the server may continue to determine the available identifier corresponding to the sending period. It should be noted here that the server may set, in advance, an available identifier corresponding to each transmission period for each transmission period. The available identification corresponding to one transmission period can be more than one, and the available identification can be a numerical value, or can be a character or other symbols. The available identifiers corresponding to the sending periods are different.
S104: and determining the electronic ticket marked as the available identifier from the stored electronic tickets.
In this embodiment of the present specification, the server determines, among the stored electronic tickets, an electronic ticket marked as an available identifier corresponding to the sending period. As can be seen, only electronic tickets marked with available identifications corresponding to the current transmission period can be transmitted within the current transmission period.
It should be noted here that before the first sending period starts, i.e. at the time of initialization, the server may set the flag of each electronic ticket to the available flag corresponding to the first sending period.
S106: and selecting the electronic ticket from the determined electronic tickets, sending the electronic ticket to the user, and modifying the mark of the selected electronic ticket.
In this embodiment, the server may select at least one electronic ticket from the electronic tickets marked as the available identifier corresponding to the sending period to send to the user, and modify the mark of the sent electronic ticket so that the modified mark is not the available identifier corresponding to the sending period (i.e., the current sending period) and is the available identifier corresponding to a subsequent sending period.
As shown in fig. 1, in the method for sending electronic tickets, on one hand, because the mark of each sent electronic ticket is modified in the current sending period, the modified mark is not the available mark corresponding to the current sending period, and only the electronic ticket marked as the available mark corresponding to the current sending period can be sent in the current sending period, the same electronic ticket is not repeatedly sent in the current sending period. On the other hand, in the current sending period, the modified mark of each sent electronic ticket is the available mark corresponding to the subsequent sending period, so the server can multiplex each electronic ticket in each sending period without resetting the mark of each electronic ticket or regenerating each electronic ticket after each sending period is finished.
The following describes available identifiers corresponding to the transmission period in detail.
Example one
Setting an available identifier corresponding to a first sending period as T aiming at two adjacent sending periods, wherein in the first sending period, the electronic ticket which is not sent is marked as T, and the mark of the sent electronic ticket is modified to be F; and setting the available identifier corresponding to the second sending period as F, marking the electronic ticket which is not sent as F in the second sending period, and modifying the mark of the sent electronic ticket as T. Of course, the available flag corresponding to the first transmission period may also be set to 1, and the available flag corresponding to the second transmission period may also be set to 0. In summary, for two adjacent sending periods, the electronic ticket sent in the first sending period can be marked as the available identifier corresponding to the second sending period, as shown in fig. 2.
Example two
Generally, the sending periods have a sequential order, and the server numbers each sending period. In this case, if the number of each transmission cycle is sequentially increased according to the sequence of each transmission cycle, the server may determine each value smaller than the number of the transmission cycle as the available identifier corresponding to the transmission cycle. In this way, in step S106, any value that is not less than the number of the current transmission cycle and less than the number of the next transmission cycle can be used as the modified mark of the electronic ticket for each electronic ticket selected for transmission.
For example, if the number of the sending cycle is 20170720, the available id corresponding to the sending cycle number 20170720 can be each value less than 20170720, such as-10000, 0.5, 30, etc. Therefore, as long as the flag of a certain electronic ticket is less than the value of 20170720, it can be transmitted within the transmission period numbered 20170720. After the electronic ticket is sent, if the number of the next sending period is 20170820, the label X of the electronic ticket is modified to satisfy the condition 20170820> X ≧ 20170720.
Electronic ticket ID
|
Electronic ticket marking
|
Electronic ticket 1
|
-1
|
Electronic ticket 2
|
3.2
|
Electronic ticket 3
|
50
|
Electronic ticket 4
|
0 |
TABLE 1
Assuming that the current transmission cycle number is 20170720 and the next transmission cycle number is 20170820, the labels of the electronic tickets are listed in table 1, it can be seen that, in the current transmission cycle, the electronic tickets can be selected to be transmitted, the labels of the electronic tickets are modified once the electronic tickets are transmitted, and after the electronic tickets are transmitted, the labels of the electronic tickets can be as shown in table 2, and the label of each electronic ticket is a value not less than 20170720 and less than 20170820.
Electronic ticket ID
|
Electronic ticket marking
|
Electronic ticket 1
|
20170720
|
Electronic ticket 2
|
20170819
|
Electronic ticket 3
|
20170811
|
Electronic ticket 4
|
20170817.8 |
TABLE 2
In addition, it should be noted that, in one sending cycle, there may be a case where all electronic tickets are not issued, that is, some electronic tickets are not sent. In this case, the mark of the electronic ticket that is not sent is not modified, and in this example, since the number of each sending period is sequentially incremented, and the available identifier corresponding to each sending period is any value smaller than the number of the sending period, the available identifier corresponding to the previous sending period is necessarily the available identifiers corresponding to all the following sending periods. That is, even if a certain electronic ticket is not transmitted in the last transmission period and the label of the electronic ticket is not modified, the label of the electronic ticket is an available identifier corresponding to the next transmission period.
In addition, in this embodiment of the present specification, after determining the electronic tickets marked as the available identifiers corresponding to the current transmission period, the server may randomly select the electronic tickets from the determined electronic tickets to transmit to the user. Specifically, the server may generate a random number corresponding to each stored electronic ticket in advance, and in step S106, the determined electronic tickets may be sorted according to a magnitude order of the random numbers corresponding to the determined electronic tickets; and selecting the first N electronic coupons from the sorted electronic coupons to send to the user, wherein N is a natural number larger than 0.
It should be noted here that the random number corresponding to each electronic ticket may be newly generated after each transmission cycle is completed, or the random number corresponding to each electronic ticket may be newly generated for each electronic ticket when the electronic ticket is issued in one transmission cycle. Therefore, the electronic ticket can be randomly selected to be sent to the user in each sending period.
In addition, in practical applications, in step S100, the server may receive the pickup requests sent by multiple users at the same time. In particular, the server may treat multiple pick-up requests received within a short time interval (e.g., 200 milliseconds) as pick-up requests received simultaneously. In step S102, the server determines, according to any pickup request, a transmission cycle corresponding to the pickup request as a transmission cycle corresponding to the plurality of pickup requests, and determines an available identifier corresponding to the transmission cycle. In step S104, the electronic ticket marked as the available identifier is determined.
In step S106, when the electronic tickets are sequentially selected from small to large according to the determined size sequence of the random numbers corresponding to the electronic tickets, if the server receives the picking requests sent by the M users at the same time, the server may sequentially select the M electronic tickets and send the M electronic tickets to the M users respectively. In this way, the server can avoid creating M threads according to the pick-up requests sent by the M users, and simultaneously attempting to lock the electronic ticket with the smallest random number in the determined electronic tickets, thereby causing thread blocking.
Taking each electronic ticket in table 3 as an example, assume that there are 3 users that simultaneously send pick-up requests to the server, and the server determines the number of the current sending cycle from the 3 pick-up requests to be 20170720. Obviously, the token of each electronic ticket in table 3 is a value less than 20170720, i.e. is an available identifier corresponding to the current transmission cycle. The server can determine 3 electronic tickets (namely, the electronic ticket 2, the electronic ticket 4 and the electronic ticket 3) from the table 3 according to the sizes of the random numbers corresponding to the electronic tickets respectively from small to large, and lock the 3 electronic tickets respectively through 3 threads corresponding to the 3 pick-up requests one by one, as shown in fig. 3, so that thread blocking is avoided.
Electronic ticket ID
|
Electronic ticket marking
|
Random number
|
Electronic ticket 1
|
-1
|
255
|
Electronic ticket 2
|
3.2
|
-0.5
|
Electronic ticket 3
|
50
|
23
|
Electronic ticket 4
|
0
|
8 |
TABLE 3
Based on the method for sending the electronic ticket shown in fig. 1, the embodiment of the present specification further provides an apparatus for sending the electronic ticket, as shown in fig. 4, including:
a receiving module 401, configured to receive a pickup request sent by a user;
a first determining module 402, configured to determine, according to the pickup request, a sending period corresponding to the pickup request, and determine an available identifier corresponding to the sending period;
a second determining module 403, configured to determine, from the stored electronic tickets, the electronic ticket marked as the available identifier;
a transmission modification module 404, which selects an electronic ticket from the determined electronic tickets to be transmitted to the user, and modifies the mark of the selected electronic ticket; the modified mark is not an available mark corresponding to the sending period and is an available mark corresponding to a subsequent sending period.
The first determining module 402 determines each value smaller than the number of the sending period as the available identifier corresponding to the sending period.
The transmission modification module 404 randomly selects an electronic ticket from the determined electronic tickets and transmits the selected electronic ticket to the user.
The device further comprises: a preprocessing module 405, which generates a random number corresponding to each stored electronic ticket in advance;
the sending modification module 404 is configured to sort the determined electronic tickets according to the order of the random numbers corresponding to the determined electronic tickets; and selecting the first N electronic coupons from the sorted electronic coupons and sending the electronic coupons to the user, wherein N is a natural number larger than 0.
The serial numbers of all the sending periods are sequentially increased according to the sequence of all the sending periods;
the sending modification module 404 uses, as the modified mark of each electronic ticket, any value that is not less than the number of the current sending period and less than the number of the next sending period for each selected electronic ticket.
The electronic ticket is an electronic lottery ticket.
Based on the method for sending the electronic ticket shown in fig. 1, the present specification embodiment further provides an electronic ticket sending apparatus, as shown in fig. 5, which includes one or more processors and a memory, where the memory stores programs and is configured to be executed by the one or more processors to perform the following steps:
receiving a pickup request sent by a user;
determining a sending period corresponding to the picking request according to the picking request, and determining an available identifier corresponding to the sending period;
determining the electronic ticket marked as the available identification from the stored electronic tickets;
selecting electronic coupons from the determined electronic coupons to send to the user, and modifying marks of the selected electronic coupons; the modified mark is not an available mark corresponding to the sending period and is an available mark corresponding to a subsequent sending period.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the electronic ticket sending device shown in fig. 5, since it is basically similar to the method embodiment, the description is simple, and the relevant points can be referred to the partial description of the method embodiment.
In the 90 s of the 20 th century, improvements in a technology could clearly distinguish between improvements in hardware (e.g., improvements in circuit structures such as diodes, transistors, switches, etc.) and improvements in software (improvements in process flow). However, as technology advances, many of today's process flow improvements have been seen as direct improvements in hardware circuit architecture. Designers almost always obtain the corresponding hardware circuit structure by programming an improved method flow into the hardware circuit. Thus, it cannot be said that an improvement in the process flow cannot be realized by hardware physical modules. For example, a Programmable Logic Device (PLD), such as a Field Programmable Gate Array (FPGA), is an integrated circuit whose Logic functions are determined by programming the Device by a user. A digital character system is "integrated" on a PLD by the designer's own programming without requiring the chip manufacturer to design and fabricate a dedicated integrated circuit chip. Furthermore, nowadays, instead of manually making an integrated Circuit chip, such Programming is often implemented by "logic compiler" software, which is similar to a software compiler used in program development and writing, but the original code before compiling is also written by a specific Programming Language, which is called Hardware Description Language (HDL), and HDL is not only one but many, such as abel (advanced Boolean Expression Language), ahdl (alternate Language Description Language), traffic, pl (core unified Programming Language), HDCal, JHDL (Java Hardware Description Language), langue, Lola, HDL, laspam, hardsradware (Hardware Description Language), vhjhd (Hardware Description Language), and vhigh-Language, which are currently used in most common. It will also be apparent to those skilled in the art that hardware circuitry that implements the logical method flows can be readily obtained by merely slightly programming the method flows into an integrated circuit using the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, an Application Specific Integrated Circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic for the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller as pure computer readable program code, the same functionality can be implemented by logically programming method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers and the like. Such a controller may thus be considered a hardware component, and the means included therein for performing the various functions may also be considered as a structure within the hardware component. Or even means for performing the functions may be regarded as being both a software module for performing the method and a structure within a hardware component.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functionality of the units may be implemented in one or more software and/or hardware when implementing the present application.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
The above description is only an example of the present application and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.