CN110738507A - exchange code acquisition method and device - Google Patents

exchange code acquisition method and device Download PDF

Info

Publication number
CN110738507A
CN110738507A CN201810790916.XA CN201810790916A CN110738507A CN 110738507 A CN110738507 A CN 110738507A CN 201810790916 A CN201810790916 A CN 201810790916A CN 110738507 A CN110738507 A CN 110738507A
Authority
CN
China
Prior art keywords
code
redemption
exchange
exchange code
pointer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201810790916.XA
Other languages
Chinese (zh)
Inventor
许吉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Financial Technology Holding Co Ltd
Original Assignee
Beijing Jingdong Financial Technology Holding Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Financial Technology Holding Co Ltd filed Critical Beijing Jingdong Financial Technology Holding Co Ltd
Priority to CN201810790916.XA priority Critical patent/CN110738507A/en
Publication of CN110738507A publication Critical patent/CN110738507A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/02Marketing; Price estimation or determination; Fundraising
    • G06Q30/0207Discounts or incentives, e.g. coupons or rebates
    • G06Q30/0208Trade or exchange of goods or services in exchange for incentives or rewards

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Engineering & Computer Science (AREA)
  • Development Economics (AREA)
  • Strategic Management (AREA)
  • Game Theory and Decision Science (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention discloses a method and a device for receiving exchange codes, which relate to the technical field of computers.A specific implementation mode of the method comprises the steps of checking the issuing amount according to the issuing amount and the total inventory amount of the exchange codes, acquiring a pointer of the exchange codes when the checking is passed, finding a corresponding storage queue for storing the exchange codes through a current pointer, acquiring the exchange codes from the storage queue by adopting a pop-up command, and returning the exchange codes when the acquired exchange codes are not empty.

Description

exchange code acquisition method and device
Technical Field
The invention relates to the field of computers, in particular to a method and a device for obtaining exchange codes.
Background
In order to promote article marketing, a merchant can issue exchange codes of physical articles or virtual articles to a user, wherein the exchange codes are numbers consisting of numbers and letters, before the exchange codes are issued, the merchant uploads the exchange codes to a relational database for storage, when the user receives the exchange codes, the user checks whether uncollected exchange codes exist in the database, the receiving state of the uncollected exchange codes is set as 'exchanging', if the receiving of the exchange codes is successful, the receiving state of the exchange codes is set as 'received', and if the receiving of the exchange codes is unsuccessful, the receiving state of the exchange codes is set as 'uncollected'.
In carrying out the present invention, the inventors have discovered that at least the storage and retrieval of redemption codes based on a relational database is susceptible to being retrieved by multiple users at high concurrent requests with redemption codes, thereby rendering the retrieved redemption codes unusable by some users.
Disclosure of Invention
In view of this, embodiments of the present invention provide redemption code picking methods and apparatuses, which locate a storage queue through a pointer and use a pop command to pick a redemption code from the storage queue, so that repeated picking of the redemption code can be effectively prevented when the redemption code is picked and sent.
To achieve the above objects, according to aspects of embodiments of the present invention, a method of getting redemption codes is provided.
The redemption code receiving method comprises the steps of checking issuing amount and total inventory according to the issuing amount of redemption codes, obtaining pointers of the redemption codes when the checking is passed, finding corresponding storage queues used for storing the redemption codes through the current pointers, obtaining the redemption codes from the storage queues by adopting a pop command, and returning the redemption codes when the obtained redemption codes are not empty.
Optionally, the method further comprises: if the exchange code returns success, updating the getting state of the exchange code; and if the exchange code return fails, pushing the exchange code to a storage queue corresponding to the current pointer by adopting a push command.
Optionally, the step of obtaining the pointer to the redemption code further comprises taking a lower pointer as the current pointer if the obtained redemption code is empty and the current pointer is less than the number of the storage queues.
Optionally, before the step of verifying the release amount, the method further includes: self-increment the issuing amount of the exchange code; the checking the issuing amount according to the issuing amount and the total inventory amount of the redemption code comprises the following steps: and comparing the self-increased release amount with the total inventory amount, and judging whether the verification passes according to the comparison result.
Optionally, the method further comprises storing the redemption codes in at least of the storage queues of a Redis database based on the total number of redemption codes and the stored number of the storage queues.
To achieve the above object, according to another aspect of the embodiment of the present invention, a device for getting redemption codes is provided.
The redemption code receiving device comprises a checking module, a searching module and a returning module, wherein the checking module is used for checking the issuing amount according to the issuing amount and the total inventory amount of redemption codes, the searching module is used for acquiring pointers of the redemption codes when the checking is passed and searching corresponding storage queues for storing the redemption codes through the current pointers, and the returning module is used for acquiring the redemption codes from the storage queues by adopting a pop-up command and returning the redemption codes when the acquired redemption codes are not empty.
Optionally, the apparatus further comprises: the updating and pushing module is used for updating the getting state of the exchange code if the exchange code returns to success; and if the exchange code return fails, pushing the exchange code to a storage queue corresponding to the current pointer by adopting a push command.
Optionally, the apparatus further comprises a pointer updating module, configured to take a lower pointer as the current pointer if the obtained redemption code is empty and the current pointer is smaller than the number of the storage queues.
Optionally, the apparatus further comprises: the self-increment module is used for self-incrementing the issuing amount of the exchange code; the verification module is further configured to: and comparing the self-increased release amount with the total inventory amount, and judging whether the verification passes according to the comparison result.
Optionally, the apparatus further comprises a storage module for storing the redemption codes in at least storage queues of a Redis database based on the total number of redemption codes and the number of stores in the storage queue.
To achieve the above object, according to a further aspect of an embodiment of the present invention, kinds of electronic devices are provided.
The electronic devices of the embodiment of the invention comprise or multiple processors and a storage device, wherein the storage device is used for storing or multiple programs, and when the or multiple programs are executed by the or multiple processors, the or multiple processors realize the method for getting redemption codes of the embodiment of the invention.
To achieve the above object, according to a further aspect of an embodiment of the present invention, computer-readable media are provided.
computer readable media of embodiments of the invention have stored thereon computer programs that, when executed by a processor, implement methods of claiming redemption codes of embodiments of the invention.
embodiments of the invention have the advantages or beneficial effects that the storage queue is positioned through the pointer, the exchange code is obtained from the storage queue through the pop command, repeated picking of the exchange code is when the exchange code is obtained in a parallel mode can be effectively prevented, the exchange code which fails to return is pushed to the storage queue corresponding to the current pointer through the push command again, the exchange code can be picked again, the issuing amount of the exchange code is increased automatically before verification, the exchange code can be occupied in advance, the final issuing amount of the exchange code is prevented from being larger than the total inventory amount when the parallel request is sent, when the exchange code in the storage queue is empty, the exchange code can be automatically switched to the next storage queues through the pointer, the exchange code is stored in the multiple storage queues of the Redis database, normal picking of the exchange code is guaranteed in a high parallel scene, efficiency is high, and stability is good.
The effect of step of the above non-conventional alternative is described below in conjunction with the detailed description.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a redemption code acquisition method according to an embodiment of the present invention;
FIG. 2 is a schematic flow diagram of a primary flow of a redemption code acquisition method according to an embodiment of the invention;
FIG. 3 is a schematic diagram of the major modules of a redemption code capture device according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
FIG. 5 is a schematic diagram of a computer apparatus suitable for use in an electronic device to implement an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of the main steps of a redemption code acquisition method according to an embodiment of the present invention. As shown in fig. 1, the method for obtaining a redemption code according to the embodiment of the present invention mainly includes the following steps:
step S101: and checking the issuing amount according to the issuing amount and the total inventory of the exchange code. Comparing the issuing amount of the exchange code with the total inventory amount, and if the issuing amount is less than or equal to the total inventory amount, indicating that the verification is passed; and if the release amount is larger than the total inventory amount, indicating that the verification is failed. In the real-time example, in order to prevent the final issued quantity of the exchange code from being more than the total inventory quantity when the concurrent requests are sent, the issued quantity of the exchange code is increased by 1 in advance, and if the issued quantity after the increase is less than or equal to the total inventory quantity, the verification is passed; and if the self-increased issuing amount is larger than the total inventory amount, the verification is failed, and the issuing amount of the redemption code is reduced by 1.
The method comprises the steps of S102, obtaining a pointer of the exchange code when the verification is passed, and finding a corresponding storage queue for storing the exchange code through a current pointer, wherein the pointer is a serial number (List _ count) of the storage queue, a database where the storage queue is located is a K-V (Key-Value pair) database, such as a Redis database and a Memcached database, Redis is high-performance Key-Value storage systems, and supports stored Value types including String, List, Set and Zset, Memcached is high-performance distributed memory object cache systems for dynamic Web application to reduce database load, if the exchange code is stored in a plurality of storage queues, the pointer of the step is the serial number of the plurality of storage queues, the initial Value of the current pointer is the smallest serial number, then each time of searching, increasing by 1, such as 2, and the current pointer is found as 2.
Step S103, acquiring a redemption code from the storage queue by adopting a pop command, and returning the redemption code when the acquired redemption code is not empty, in the embodiment, acquiring the redemption code from the storage queue by adopting an LPOP command of a Redis database, wherein the LPOP command is used for popping elements from the left side of the storage queue, judging whether the acquired redemption code is empty or not after acquiring the redemption code, if the acquired redemption code is empty and the current pointer is less than the number of the storage queue, taking a lower pointer as the current pointer, and if the acquired redemption code is not empty, returning the redemption code to a user.
Fig. 2 is a main flow diagram of a redemption code acquisition method according to an embodiment of the present invention. As shown in fig. 2, the method for obtaining a redemption code according to the embodiment of the present invention mainly includes the following steps:
step S201, storing the redemption codes into at least storage queues according to the total number of the redemption codes and the storage number of the storage queues, wherein the total number of the redemption codes is the number of the redemption codes uploaded to a Redis database by a merchant, and the storage number of the storage queues is the number of the redemption codes which can be stored in the storage queues at the maximum.
Figure BDA0001734895280000061
In the formula (I), the compound is shown in the specification,
Figure BDA0001734895280000062
is rounded up.
Each store queue may be distinguished by an activity identification of the list _ count _ redemption-code-issuing activity, such as list _2_ 1902.
For example, if the activity Identification (ID) of the redemption code issuing activities is 1902, the total number of redemption codes uploaded to the database by the merchant is 103, the number of stores in each storage queue is 10, and the redemption code issuing activity with the activity ID of 1902 requires
Figure BDA0001734895280000063
Figure BDA0001734895280000064
Step S202, receiving a redemption code acquisition request, and increasing the issuing amount of the redemption code by itself, wherein the user sends the redemption code acquisition request to a server through a client, the redemption code acquisition request comprises an activity ID. server which receives the redemption code acquisition request and then analyzes the redemption code acquisition request, and then increases the issuing amount of the redemption code belonging to the activity ID by itself by 1, the issuing amount of the redemption code is increased by itself by 1 every time redemption code acquisition requests are received, so that redemption codes can be occupied in advance, and the final issuing amount of the redemption code is prevented from being more than the total stock amount when the requests are sent in parallel.
Step S203: judging whether the self-increased release amount is larger than the total inventory amount, and if the self-increased release amount is larger than the total inventory amount, executing the step S204; if the self-increased dispensing amount is less than or equal to the total inventory amount, step S205 is executed. The total inventory refers to the total quantity of the exchange codes which are expected to be issued in the exchange code issuing activity.
Step S204: the issuance amount of the redemption code is reduced by itself, and step S214 is executed. In an embodiment, the issuance amount of the redemption code is reduced by 1. If the self-increased issue amount is larger than the total inventory amount, it indicates that the redemption code has been completely received, and the user cannot receive the redemption code, and since the issue amount of the redemption code has been increased by 1 in advance in step S202, it is necessary to decrease by 1 again to meet the actual issue amount of the redemption code.
Step S205: and acquiring the pointer of the exchange code, and finding out the corresponding storage queue for storing the exchange code through the current pointer. The pointer is list _ count and is stored in a Redis database. For example, if the obtained pointers are 2, 3, and 4, the current pointer is 2, and the storage queue list _2 corresponding to the pointer 2 is searched.
In the embodiment, the exchange code is acquired from the storage queue by adopting an LPOP command, the command is atomic and thread-safe, namely, only threads are allowed to acquire the exchange code at the same time of , other threads are queued for waiting, and the acquisition of exchange codes at the same time of by a plurality of threads is avoided.
Step S207: judging whether the obtained exchange code is empty, if so, executing step S208; if not, step S210 is performed.
Step S208: judging whether the current pointer is smaller than the number of the storage queues or not, and if the current pointer is smaller than the number of the storage queues, executing the step S209; if the current pointer is greater than or equal to the number of the storage queues, step S214 is performed. If the current pointer is greater than or equal to the number of the storage queues, the redemption code is fully received.
And S209, taking the lower pointer as the current pointer, finding the corresponding storage queue for storing the redemption code through the current pointer, and executing S206. assuming that the current pointer is 2, increasing the current pointer by 1, namely, finding the storage queue corresponding to the pointer 3 as list _ 3.
Step S210: returning the redemption code. And the server returns the acquired exchange code to the client.
Step S211: judging whether the redemption code returns success, if so, executing step S212; if the return fails, step S213 is executed.
Step S212: updating a pickup status of the redemption code. If the redemption code is successfully returned to the client, indicating that the redemption code was successfully received, the receipt status of the redemption code is updated to "successful receipt". The steps are executed asynchronously, so that time consumption is greatly reduced, and database pressure is relieved.
And S213, pushing the exchange code into a storage queue corresponding to the current pointer by adopting a push command, in the embodiment, acquiring the exchange code from the storage queue by adopting an RPUSH command, wherein the RPUSH command is operation commands of a Redis database and is used for enqueuing elements or a plurality of elements from the right side of the storage queue.
Step S214: and returning prompt information and ending the process. In an embodiment, a prompt message of "light robbed" may be returned to the client.
In the preferred embodiment, multiple storage queues may be scattered among different Redis nodes to ensure load balancing among each node and relieve pressure on the Redis database.
The method for receiving the exchange code can be seen that the storage queue is positioned through the pointer, the exchange code is obtained from the storage queue through the pop command, repeated receiving of the exchange code is carried out at the same time when the exchange code is obtained in a parallel mode can be effectively prevented, the exchange code which fails to return is pushed to the storage queue corresponding to the current pointer through the push command again, the exchange code can be received again, the issuing amount of the exchange code is increased automatically before verification, the exchange code can be occupied in advance, the final issuing amount of the exchange code is prevented from being larger than the total inventory amount when the parallel request is carried out, when the exchange code in the storage queue is empty, the exchange code can be automatically switched to next storage queues through the pointer, the exchange code is stored in the plurality of storage queues of the Redis database, normal receiving of the exchange code under a high parallel scene is guaranteed, efficiency is high, and stability is good.
Figure 3 is a schematic diagram of the main modules of a redemption code capture device according to an embodiment of the present invention. As shown in fig. 3, the redemption code receiving apparatus 300 according to the embodiment of the present invention mainly includes:
the verification module 301 is configured to verify the issuing amount according to the issuing amount and the total inventory amount of the redemption code. Comparing the issuing amount of the exchange code with the total inventory amount, and if the issuing amount is less than or equal to the total inventory amount, indicating that the verification is passed; and if the release amount is larger than the total inventory amount, indicating that the verification is failed. In the real-time example, in order to prevent the final issued quantity of the exchange code from being more than the total inventory quantity when the concurrent requests are sent, the issued quantity of the exchange code is increased by 1 in advance, and if the issued quantity after the increase is less than or equal to the total inventory quantity, the verification is passed; and if the self-increased issuing amount is larger than the total inventory amount, the verification is failed, and the issuing amount of the redemption code is reduced by 1.
The searching module 302 is configured to obtain the pointer of the redemption code when the verification is passed, and search the corresponding storage queue for storing the redemption code through the current pointer. Wherein, the pointer is a sequence number (list _ count) of the storage queue. The database where the storage queue is located is a K-V database, such as a Redis database and a Memcached database. If the redemption code is stored in multiple storage queues, the pointer obtained in this step is the serial number of the multiple storage queues, the initial value of the current pointer is the minimum serial number, and then the pointer is incremented by 1 each time the pointer is searched. For example, if the current pointer is 2, the found storage queue is list _ 2.
The return module 303 is used for acquiring the exchange code from the storage queue by adopting a pop command, and returning the exchange code when the acquired exchange code is not empty, in the embodiment, the exchange code is acquired from the storage queue by adopting an LPOP command of a Redis database, the LPOP command is used for dequeuing elements from the left side of the storage queue, after the exchange code is acquired, whether the acquired exchange code is empty is judged, if the acquired exchange code is empty and the current pointer is less than the number of the storage queue, a lower pointer is used as the current pointer, and if the acquired exchange code is not empty, the exchange code is returned to a user.
In addition, the redemption code getting device 300 of the embodiment of the invention may further include an update pushing module, a pointer updating module, a self-adding module and a storage module (not shown in fig. 3), wherein the update pushing module is configured to update the getting status of the redemption code if the redemption code returns successfully, and push the redemption code to a storage queue corresponding to the current pointer if the redemption code returns failed by using a push command, the pointer updating module is configured to take a lower pointer as the current pointer if the obtained redemption code is empty and the current pointer is smaller than the number of the storage queues, the self-adding module is configured to self-add the issuing amount of the redemption code, and the storage module is configured to store the redemption code in at least storage queues of a Redis database according to the total number of the redemption codes and the storage number of the storage queues.
From the above description, the storage queue is positioned through the pointer, the exchange code is obtained from the storage queue through the pop command, repeated picking of the exchange code can be effectively prevented when the exchange code is obtained in a concurrent mode, the exchange code which fails to return is pushed to the storage queue corresponding to the current pointer through the pop command again, the exchange code can be picked again, the issuing amount of the exchange code is increased automatically before verification, the exchange code can be occupied in advance, the final issuing amount of the exchange code is larger than the total storage amount when the request is made in a concurrent mode, when the exchange code in the storage queue is empty, the exchange code can be automatically switched to next storage queues through the pointer, the exchange code is stored in the plurality of storage queues of the Redis database, normal picking of the exchange code is guaranteed in a high concurrent scene, efficiency is high, and stability is good.
Figure 4 illustrates an exemplary system architecture 400 of a method of redemption code acquisition or an apparatus for redemption code acquisition to which embodiments of the invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have various communication client applications installed thereon, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like.
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server that provides various services, such as a background management server that supports a redemption code acquisition request transmitted by a user using the terminal device 401, 402, 403. The background management server may analyze and otherwise process the received redemption code acquisition request and feed back the processing result (e.g., redemption code) to the terminal device.
The redemption code acquisition method provided in the embodiments of the present application is typically executed by the server 405, and accordingly, the redemption code acquisition device is typically provided in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The invention also provides electronic devices and computer-readable media according to embodiments of the invention.
The electronic equipment comprises processors or a plurality of processors, and a storage device for storing programs or a plurality of programs, wherein when the programs or the plurality of programs are executed by the processors or the plurality of processors, the processors or the plurality of processors realize the redemption code getting method of the embodiment of the invention.
The computer readable medium of the present invention has stored thereon a computer program which, when executed by a processor, implements the method of retrieving redemption codes of embodiments of the present invention.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use in implementing an electronic device of an embodiment of the present invention, the electronic device shown in FIG. 5 is merely an example and should not be taken to limit the scope of use or functionality of an embodiment of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the computer system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
For example, embodiments of the present disclosure include computer program products comprising a computer program embodied on a computer readable medium, the computer program containing program code for performing the method illustrated in the main step diagram.
A more specific example of a computer readable storage medium may include, but is not limited to, an electrical connection having or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures, for example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved, and it may also be noted that each block of the block diagrams or flowchart illustrations, and combinations of blocks in the block diagrams or flowchart illustrations, may be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware, and the described modules may be provided in a processor, for example, it may be described that kinds of processors include a check module, a search module, and a return module, wherein names of the modules do not constitute a limitation of the module itself in some cases, for example, the check module may also be described as a "module for checking a dispensing amount according to a dispensing amount and a total stock amount of a redemption code".
As another aspect, the present invention also provides computer readable media, which may be included in the apparatus described in the above embodiments, or may be separately present and not installed in the apparatus, wherein the computer readable media carries or more programs, and when the or more programs are executed by apparatuses, the apparatus comprises checking the dispensing amount and the total stock amount of a redemption code, acquiring a pointer of the redemption code when the checking is passed, finding a corresponding storage queue for storing the redemption code through a current pointer, and acquiring the redemption code from the storage queue using a pop command to return the redemption code when the acquired redemption code is not empty.
From the above description, the storage queue is positioned through the pointer, the exchange code is obtained from the storage queue through the pop command, repeated picking of the exchange code can be effectively prevented when the exchange code is obtained in a concurrent mode, the exchange code which fails to return is pushed to the storage queue corresponding to the current pointer through the pop command again, the exchange code can be picked again, the issuing amount of the exchange code is increased automatically before verification, the exchange code can be occupied in advance, the final issuing amount of the exchange code is larger than the total storage amount when the request is made in a concurrent mode, when the exchange code in the storage queue is empty, the exchange code can be automatically switched to next storage queues through the pointer, the exchange code is stored in the plurality of storage queues of the Redis database, normal picking of the exchange code is guaranteed in a high concurrent scene, efficiency is high, and stability is good.
The product can execute the method provided by the embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the method provided by the embodiment of the present invention.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1, A method for obtaining a redemption code, comprising:
checking the issuing amount according to the issuing amount and the total stock of the exchange code;
when the verification is passed, acquiring a pointer of the exchange code, and searching a corresponding storage queue for storing the exchange code through the current pointer;
and acquiring the redemption code from the storage queue by adopting a pop command, and returning the redemption code when the acquired redemption code is not empty.
2. The method of claim 1, further comprising:
if the exchange code returns success, updating the getting state of the exchange code;
and if the exchange code return fails, pushing the exchange code to a storage queue corresponding to the current pointer by adopting a push command.
3. The method of claim 1, wherein the step of obtaining the pointer to the redemption code is followed by:
and if the obtained redemption code is empty and the current pointer is less than the number of the storage queues, taking the lower pointer as the current pointer.
4. The method of claim 1, wherein the step of verifying the delivery amount is preceded by the step of: self-increment the issuing amount of the exchange code;
the checking the issuing amount according to the issuing amount and the total inventory amount of the redemption code comprises the following steps:
and comparing the self-increased release amount with the total inventory amount, and judging whether the verification passes according to the comparison result.
5. The method of any of claims 1-4, further comprising:
storing the redemption codes into at least of the storage queues of a Redis database based on the total number of redemption codes and the stored number of the storage queues.
The device for getting the exchange codes of kinds is characterized by comprising:
the verification module is used for verifying the issuing amount according to the issuing amount and the total inventory of the exchange code;
the searching module is used for acquiring the pointer of the exchange code when the verification is passed, and searching the corresponding storage queue for storing the exchange code through the current pointer;
and the return module is used for acquiring the exchange code from the storage queue by adopting a pop command, and returning the exchange code when the acquired exchange code is not empty.
7. The apparatus of claim 6, further comprising: update push module for
If the exchange code returns success, updating the getting state of the exchange code; and
and if the exchange code return fails, pushing the exchange code to a storage queue corresponding to the current pointer by adopting a push command.
8. The apparatus of claim 6, further comprising: pointer update module for
And if the obtained redemption code is empty and the current pointer is less than the number of the storage queues, taking the lower pointer as the current pointer.
9. The apparatus of claim 6, further comprising: the self-increment module is used for self-incrementing the issuing amount of the exchange code;
the verification module is further configured to:
and comparing the self-increased release amount with the total inventory amount, and judging whether the verification passes according to the comparison result.
10. The apparatus according to any of the preceding claims 6 to 9, wherein the apparatus further comprises a storage module for storing the data according to any of the preceding claims
Storing the redemption codes into at least of the storage queues of a Redis database based on the total number of redemption codes and the stored number of the storage queues.
An electronic device of the kind 11, , comprising:
or more processors;
a storage device for storing or more programs,
when the or more programs are executed by the or more processors, cause the or more processors to implement the method of any of claims 1-5.
12, computer readable medium, having stored thereon a computer program, characterized in that the program, when being executed by a processor, carries out the method according to any of claims 1-5 .
CN201810790916.XA 2018-07-18 2018-07-18 exchange code acquisition method and device Pending CN110738507A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810790916.XA CN110738507A (en) 2018-07-18 2018-07-18 exchange code acquisition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810790916.XA CN110738507A (en) 2018-07-18 2018-07-18 exchange code acquisition method and device

Publications (1)

Publication Number Publication Date
CN110738507A true CN110738507A (en) 2020-01-31

Family

ID=69235015

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810790916.XA Pending CN110738507A (en) 2018-07-18 2018-07-18 exchange code acquisition method and device

Country Status (1)

Country Link
CN (1) CN110738507A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112308599A (en) * 2020-08-31 2021-02-02 北京沃东天骏信息技术有限公司 Redemption code issuing method, system and device

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110145125A1 (en) * 2009-12-15 2011-06-16 Trading Technologies International, Inc. System and Methods for Risk-Based Prioritized Transaction Message Flow
CN103838753A (en) * 2012-11-23 2014-06-04 腾讯科技(北京)有限公司 Storage and verification method and device for exchange codes
CN104123649A (en) * 2013-04-24 2014-10-29 深圳富泰宏精密工业有限公司 Electronic ticket exchange system and method
HK1198301A1 (en) * 2014-11-21 2015-03-27 Storage and verification method and device for exchange codes
CN104851031A (en) * 2015-03-31 2015-08-19 深圳市中润四方信息技术有限公司 Electronic bill coding method and system
CN105913288A (en) * 2016-05-31 2016-08-31 知而行(上海)营销咨询有限公司 O2O closed-loop marketing system based on discount enjoyed by code scanning
US20160321568A1 (en) * 2013-12-20 2016-11-03 Smartseats Ip Bvba Systems and methods for redistributing tickets to an event
CN106156309A (en) * 2016-07-01 2016-11-23 五八同城信息技术有限公司 Method for reading data and device
CN106815338A (en) * 2016-12-25 2017-06-09 北京中海投资管理有限公司 A kind of real-time storage of big data, treatment and inquiry system
CN107302488A (en) * 2016-04-14 2017-10-27 阿里巴巴集团控股有限公司 Distribution method, system and the server of virtual objects
CN108133399A (en) * 2016-11-30 2018-06-08 北京京东尚科信息技术有限公司 The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110145125A1 (en) * 2009-12-15 2011-06-16 Trading Technologies International, Inc. System and Methods for Risk-Based Prioritized Transaction Message Flow
CN103838753A (en) * 2012-11-23 2014-06-04 腾讯科技(北京)有限公司 Storage and verification method and device for exchange codes
CN104123649A (en) * 2013-04-24 2014-10-29 深圳富泰宏精密工业有限公司 Electronic ticket exchange system and method
US20160321568A1 (en) * 2013-12-20 2016-11-03 Smartseats Ip Bvba Systems and methods for redistributing tickets to an event
HK1198301A1 (en) * 2014-11-21 2015-03-27 Storage and verification method and device for exchange codes
CN104851031A (en) * 2015-03-31 2015-08-19 深圳市中润四方信息技术有限公司 Electronic bill coding method and system
CN107302488A (en) * 2016-04-14 2017-10-27 阿里巴巴集团控股有限公司 Distribution method, system and the server of virtual objects
CN105913288A (en) * 2016-05-31 2016-08-31 知而行(上海)营销咨询有限公司 O2O closed-loop marketing system based on discount enjoyed by code scanning
CN106156309A (en) * 2016-07-01 2016-11-23 五八同城信息技术有限公司 Method for reading data and device
CN108133399A (en) * 2016-11-30 2018-06-08 北京京东尚科信息技术有限公司 The second of high concurrent fast-response kills the method, apparatus and system that inventory precisely reduces
CN106815338A (en) * 2016-12-25 2017-06-09 北京中海投资管理有限公司 A kind of real-time storage of big data, treatment and inquiry system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ADA多一多: "构架稳定与可扩展的优惠券系统", HTTPS://WWW.CNBLOGS.COM/ADA-OPENMIND/P/8757794.HTML *
懵懂AND无知: "php+redis消息队列抢购实现", HTTPS://BLOG.CSDN.NET/LINLIN_XIA/ARTICLE/DETAILS/68944907 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112308599A (en) * 2020-08-31 2021-02-02 北京沃东天骏信息技术有限公司 Redemption code issuing method, system and device
CN112308599B (en) * 2020-08-31 2024-08-20 北京沃东天骏信息技术有限公司 Redemption code issuing method, redemption code issuing system and redemption code issuing device

Similar Documents

Publication Publication Date Title
CN108629029B (en) Data processing method and device applied to data warehouse
CN106716335B (en) Asynchronous processing of mapping information
CN107451853B (en) Method, device and system for real-time red packet distribution and storage medium
CN109947668A (en) The method and apparatus of storing data
CN111865970A (en) Method and apparatus for implementing interface idempotency
CN107480205B (en) Method and device for partitioning data
CN110135925B (en) Order processing system, method and device
CN110599277A (en) Inventory deduction method and device
CN110909022A (en) Data query method and device
CN110928905A (en) Data processing method and device
CN110738507A (en) exchange code acquisition method and device
CN112699116A (en) Data processing method and system
CN107665241B (en) Real-time data multi-dimensional duplicate removal method and device
CN114064803A (en) Data synchronization method and device
CN113590322A (en) Data processing method and device
CN113703933A (en) Task processing method and device
CN112115165B (en) Data processing method and device
CN112015565A (en) Method and device for determining task downloading queue
CN112667627B (en) Data processing method and device
CN111651475B (en) Information generation method and device, electronic equipment and computer readable medium
CN113760965B (en) Data query method and device
US10565044B2 (en) Message handling related to non-parallelizable functionality
CN118520004A (en) Data processing method and device
CN115599828A (en) Information processing method, device, equipment and storage medium
CN114782121A (en) Method and device for identifying target user

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Applicant before: Jingdong Digital Technology Holding Co.,Ltd.

Address after: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Applicant after: Jingdong Digital Technology Holding Co.,Ltd.

Address before: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Applicant before: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.

Address after: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Applicant after: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.

Address before: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Applicant before: BEIJING JINGDONG FINANCIAL TECHNOLOGY HOLDING Co.,Ltd.

CB02 Change of applicant information