Coupon inventory management method and device, storage medium and processor
By caching coupon information and event inventory information in Redis, the problems of frequent database access and inconsistent inventory information in existing technologies are solved, achieving efficient coupon management and supporting the smooth operation of large-scale events and multiple events.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-10-10
- Publication Date
- 2026-06-05
AI Technical Summary
Existing coupon management methods suffer from frequent database access and inconsistent inventory information in cluster mode, resulting in low efficiency in acquiring inventory data and an inability to support large-scale events and multiple events.
By caching coupon information and activity inventory information in Redis, the reliance on database queries is reduced. Redis is used to quickly retrieve coupon information to be claimed in cluster concurrency mode, and coupon information is updated from the database when inventory is insufficient, ensuring inventory consistency.
It improves the efficiency of coupon redemption, avoids inconsistent inventory information obtained by different service nodes, supports the smooth operation of large-scale events and multiple events, and prevents inventory data loss caused by service restarts.
Smart Images

Figure CN117290395B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a coupon inventory management method, a coupon inventory management device, a machine-readable storage medium, a computer program product, and a processor. Background Technology
[0002] With rapid economic development, businesses hold various activities to attract customers. Among these, electronic coupons are an important means for businesses to attract customers and increase customer retention. By providing coupons to customers, they can use them to offset part of the cash cost in transactions, thereby attracting customers to spend.
[0003] Existing methods for managing coupons fall into two categories: one is based on defining an inventory table in a database to store inventory information. This requires querying the database table each time to retrieve current inventory data and updating the inventory quantity promptly. However, in a clustered environment, frequent concurrent database access leads to low efficiency in retrieving inventory data. The other method is based on a custom Java cache for inventory information, which can improve efficiency. However, in a clustered environment, inventory information is inconsistent across different service nodes, making unified inventory management impossible. Furthermore, the custom Java cache is limited by system hardware (memory), which is unfavorable for large-scale events or multiple events.
[0004] Therefore, existing coupon management methods suffer from problems such as frequent database access, inability to uniformly manage inventory information, and are not conducive to the implementation of large-scale events and multiple events. Summary of the Invention
[0005] The purpose of this application is to provide a coupon inventory management method, a coupon inventory management device, a machine-readable storage medium, a computer program product, and a processor. This coupon inventory management method, by retrieving coupon information from Redis, significantly reduces reliance on database queries in a clustered concurrent mode, thus improving coupon retrieval efficiency. It avoids the problem of inconsistent inventory information obtained by different service nodes, facilitating unified inventory management and benefiting large-scale events and multiple events.
[0006] To achieve the above objectives, the first aspect of this application provides a coupon inventory management method, comprising:
[0007] In response to an activity creation request, create a new activity and generate the corresponding activity inventory information;
[0008] The activity inventory information is stored in a database and Redis respectively;
[0009] Based on the new activity, generate multiple coupon information and select a predetermined number of coupon information from the multiple coupon information;
[0010] The multiple coupon information items are stored in the database, and the predetermined number of coupon information items are cached in the Redis.
[0011] When claiming coupons, obtain coupon claiming activity information, and based on the coupon claiming activity information, obtain the coupon information to be claimed from the coupon information in Redis, and update the coupon information and activity inventory information in Redis.
[0012] In this embodiment of the application, obtaining the coupon information to be claimed from the coupon information in Redis based on the coupon activity information includes:
[0013] Based on the coupon redemption activity information, the current activity inventory information is retrieved from the Redis database.
[0014] Determine whether the current activity inventory information is greater than 0;
[0015] If the current activity inventory information is greater than 0, the coupon information to be claimed is obtained from the coupon information in Redis based on the coupon claiming activity information;
[0016] If the current active inventory information is not greater than 0, a prompt message will be generated.
[0017] In this embodiment of the application, the coupon inventory management method further includes:
[0018] Based on the coupon redemption activity information, the current coupon quantity information can be retrieved from the Redis;
[0019] Determine whether the current number of coupons is less than a preset warning value;
[0020] If the current number of coupons is less than a preset warning value, new coupon information is selected from the database and cached in Redis to update the coupon information in Redis.
[0021] In this embodiment of the application, when the current coupon quantity information is less than a preset warning value, the method further includes:
[0022] Based on the new activity, a new batch of coupon information is generated and stored in the database.
[0023] A second aspect of this application provides a coupon inventory management device, the coupon inventory management device comprising:
[0024] The inventory generation module is used to respond to an activity creation request, create a new activity, and generate the corresponding activity inventory information;
[0025] An inventory storage module is used to store the active inventory information in a database and Redis, respectively;
[0026] The coupon generation module is used to generate multiple coupon information based on the new activity, and select a predetermined number of coupon information from the multiple coupon information;
[0027] The coupon storage module is used to store the multiple coupon information into the database and cache the predetermined number of coupon information into the Redis;
[0028] The coupon management module is used to obtain coupon activity information when claiming coupons, and to retrieve coupon information to be claimed from the coupon information in Redis based on the coupon activity information, while updating the coupon information and activity inventory information in Redis.
[0029] In this embodiment of the application, the coupon management module includes:
[0030] The first query unit is used to query the current activity inventory information in Redis based on the coupon activity information;
[0031] The first judgment unit is used to determine whether the current active inventory information is greater than 0;
[0032] The claiming unit is used to obtain the coupon information to be claimed from the coupon information in Redis based on the coupon claiming activity information when the current activity inventory information is greater than 0.
[0033] The prompting unit is used to generate a prompt message when the current active inventory information is not greater than 0.
[0034] In this embodiment of the application, the coupon inventory management device further includes:
[0035] The coupon query module is used to query the current number of coupons in Redis based on the coupon redemption activity information;
[0036] The judgment module is used to determine whether the current coupon quantity information is less than a preset warning value;
[0037] The coupon update module is used to select new coupon information from the database and cache the new coupon information in Redis when the current number of coupons is less than a preset warning value, so as to update the coupon information in Redis.
[0038] A third aspect of this application provides a processor configured to perform the aforementioned coupon inventory management method.
[0039] A fourth aspect of this application provides a machine-readable storage medium storing instructions that, when executed by a processor, configure the processor to perform the aforementioned coupon inventory management method.
[0040] The fifth aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the aforementioned coupon inventory management method.
[0041] The above technical solution involves creating a new activity and generating corresponding activity inventory information; storing this inventory information in both a database and Redis; generating multiple coupon information entries based on the new activity, and selecting a predetermined number of coupon entries from these entries; storing these coupon entries in the database and caching the predetermined number of coupon entries in Redis; and retrieving coupons by obtaining coupon activity information and retrieving coupons from Redis based on this information, while simultaneously updating the coupon information and activity inventory information in Redis. When a coupon activity is created, activity inventory information and coupon information are generated. The initial activity inventory information and coupon information are recorded in the database, while Redis caches and stores the activity inventory information and a portion of the coupon information. Retrieving coupon information from Redis significantly reduces the reliance on database queries in a clustered concurrent mode, improving coupon retrieval efficiency. By using a database and Redis to record the initial activity inventory information and coupon information, the problem of inconsistent inventory information obtained by different service nodes can be avoided, facilitating unified inventory management. This is beneficial for large-scale activities and multiple activities, and also avoids the problem of inventory data loss due to service restarts.
[0042] Other features and advantages of the embodiments of this application will be described in detail in the following detailed description section. Attached Figure Description
[0043] The accompanying drawings are provided to further illustrate the embodiments of this application and form part of the specification. They are used together with the following detailed description to explain the embodiments of this application, but do not constitute a limitation on the embodiments of this application. In the drawings:
[0044] Figure 1 This illustration schematically shows an application environment diagram of the coupon inventory management method according to an embodiment of this application;
[0045] Figure 2 The illustration shows a flowchart of a coupon inventory management method according to an embodiment of this application;
[0046] Figure 3 This illustration shows a schematic diagram of the coupon redemption process according to an embodiment of this application;
[0047] Figure 4 This schematic diagram illustrates a structural block diagram of a coupon inventory management device according to an embodiment of the present application;
[0048] Figure 5 The diagram illustrates the internal structure of a computer device according to an embodiment of this application.
[0049] Explanation of reference numerals in the attached figures
[0050] 102-Terminal; 104-Server; 410-Inventory Generation Module; 420-Inventory Storage Module; 430-Coupon Generation Module; 440-Coupon Storage Module; 450-Coupon Management Module; A01-Processor; A02-Network Interface; A03-Internal Memory; A04-Display Screen; A05-Input Device; A06-Non-Volatile Storage Media; B01-Operating System; B02-Computer Program. Detailed Implementation
[0051] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only for illustration and explanation of the embodiments of this application and are not intended to limit the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0052] It should be noted that if the embodiments of this application involve directional indicators (such as up, down, left, right, front, back, etc.), the directional indicators are only used to explain the relative positional relationship and movement of the components in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indicators will also change accordingly.
[0053] Furthermore, if the embodiments of this application involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" or "second" may explicitly or implicitly include at least one of those features. Additionally, the technical solutions of various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. If the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed in this application.
[0054] It should be noted that the acquisition, storage, use, and processing of data in this application's technical solution all comply with the relevant provisions of national laws and regulations.
[0055] The coupon inventory management method provided in this application can be applied to, for example... Figure 1 The application environment shown is illustrated. Terminal 102 communicates with server 104 via a network. A coupon inventory management method is provided. When a coupon activity is created, activity inventory information and coupon information are generated. The initial activity inventory information and coupon information are recorded in a database, and the activity inventory information and partial coupon information are cached in Redis. Coupon information is retrieved from Redis, significantly reducing the reliance on database queries in a clustered concurrent mode and improving coupon retrieval efficiency. This avoids the problem of inconsistent inventory information obtained by different service nodes, facilitating unified inventory information management, which is beneficial for large-scale activities and multiple activities. It also avoids the problem of inventory data loss due to service restarts. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0056] Figure 2 A schematic flowchart illustrating a coupon inventory management method according to an embodiment of this application is shown. Figure 2 As shown, in one embodiment of this application, a coupon inventory management method is provided. This embodiment mainly applies this method to the above-mentioned... Figure 1 Taking terminal 102 (or server 104) as an example, the following steps are included:
[0057] Step 210: In response to the activity creation request, create a new activity and generate the corresponding activity inventory information;
[0058] In this embodiment, the coupon inventory management method can be executed by an inventory management service. The aforementioned "create activity request" refers to creating a coupon activity. After receiving the user's request to create a coupon activity, the inventory management service creates a new activity. The new activity includes information such as the coupon activity's identity document (ID), the coupon activity's address, and the coupon activity's inventory, thereby generating activity inventory information. Activity inventory information refers to the remaining quantity of coupons to be distributed in this activity.
[0059] Step 220: Store the activity inventory information in the database and Redis respectively;
[0060] In this embodiment, the activity inventory information is stored in both the database and Redis. During storage, "KC" (inventory) plus the ID of the coupon activity can be used as the primary key, and the inventory quantity of the coupon activity can be used as the value, cached in Redis in a key-value pair manner.
[0061] The database can be an enterprise-grade distributed database (Tencent Distributed Database, TDSQL). TDSQL is Tencent Cloud's enterprise-grade distributed database, encompassing a complete database product system with multiple engines including financial-grade distributed, cloud-native, and analytical databases. It provides industry-leading capabilities such as financial-grade high availability, compute-storage separation, data warehousing, and enterprise-grade security, while also offering a comprehensive product service system including an intelligent operation and maintenance platform and a serverless version. The Remote Dictionary Server (Redis) is an open-source, ANSI C-written, network-enabled, in-memory or persistent log-structured key-value database with a read speed of 110,000 times / s and a write speed of 81,000 times / s. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperlog, geospatial indexes, and streams. Redis features built-in replication, Lua scripting, LRU eviction, transactions, and different levels of disk persistence, and provides high availability through Redis Sentinel and Redis Cluster automatic partitioning.
[0062] Step 230: Based on the new activity, generate multiple coupon information and select a predetermined number of coupon information from the multiple coupon information;
[0063] Step 240: Store the multiple coupon information in the database, and cache the predetermined number of coupon information in the Redis;
[0064] In this embodiment, after storing the activity inventory information, the inventory management server begins generating a batch of coupon information. Since generating coupon information is time-consuming, it can be done in batches. For example, 10,000 coupons can be generated initially, then 5,000 coupons can be selected and stored in Redis, while the remaining 10,000 coupons can be stored in the database. Similar to the method of storing activity inventory information, "YHQ" (coupon) plus the activity ID can be used as the key, and the coupon information as the value, cached in Redis in a key-value manner.
[0065] Step 250: When claiming coupons, obtain coupon claiming activity information, and based on the coupon claiming activity information, obtain the coupon information to be claimed from the coupon information in Redis, and update the coupon information and activity inventory information in Redis.
[0066] In this embodiment, since Redis caches the activity inventory information and the predetermined number of coupons, participants can retrieve coupons from Redis without accessing the database. The coupon activity information includes the activity ID and the number of coupons to be claimed. For example, when claiming a coupon for the first time, a coupon can be retrieved from Redis based on the activity ID, and the coupon information can be returned. Simultaneously, the activity inventory information is decremented by 1, and the corresponding coupon information is deleted from Redis.
[0067] In the above implementation process, a new activity is created, and corresponding activity inventory information is generated. This activity inventory information is stored in both a database and Redis. Based on the new activity, multiple coupon information items are generated, and a predetermined number of coupons are selected from these items. These coupons are stored in the database, and the predetermined number of coupons are cached in Redis. When claiming coupons, coupon claiming activity information is obtained, and based on this information, the coupons to be claimed are retrieved from the coupon information in Redis. Simultaneously, the coupon information and activity inventory information in Redis are updated. When a coupon activity is created, activity inventory information and coupon information are generated. The initial activity inventory information and coupon information are recorded in the database, while Redis caches and stores the activity inventory information and a portion of the coupon information. Claiming coupon information from Redis significantly reduces the reliance on database queries in a clustered concurrent mode, improving coupon claiming efficiency. By using a database and Redis to record the initial activity inventory information and coupon information, the problem of inconsistent inventory information obtained by different service nodes can be avoided, facilitating unified inventory management. This is beneficial for large-scale activities and multiple activities, and also avoids the problem of inventory data loss due to service restarts.
[0068] In some embodiments, after multiple coupon redemptions, to ensure the availability of coupon information to be redeemed, the step of retrieving the coupon information from Redis based on the coupon redemption activity information includes the following steps:
[0069] First, based on the coupon redemption activity information, the current activity inventory information is retrieved from the Redis database;
[0070] Then, determine whether the current active inventory information is greater than 0;
[0071] Then, if the current activity inventory information is greater than 0, the coupon information to be claimed is obtained from the coupon information in Redis based on the coupon claiming activity information;
[0072] Finally, if the current active inventory information is not greater than 0, a prompt message is generated.
[0073] In this embodiment, after multiple coupon claims, when an activity participant claims another coupon, the inventory management service can query the current inventory information in Redis based on "KC" + activity ID. If the current inventory information is greater than 0, a coupon is retrieved from the coupon information based on "YHQ" + activity ID and returned. At the same time, the coupon is deleted from Redis, and the activity inventory information is decremented by 1.
[0074] By checking if the current activity inventory is greater than 0, it determines whether there are still coupons available. Coupons are only claimed if the current inventory is greater than 0, ensuring that users can access available coupons. If the current inventory is 0, it means there are no coupons remaining, and an insufficient inventory alert is generated and returned to notify the user that the claim has failed. This allows users to stay informed about the activity's inventory status.
[0075] In some embodiments, after multiple coupon redemptions, to ensure that the number of coupons cached in Redis meets the redemption demand, the coupon inventory management method further includes the following steps:
[0076] First, based on the coupon redemption activity information, the current number of coupons is retrieved from the Redis database;
[0077] Then, it is determined whether the current coupon quantity information is less than a preset warning value;
[0078] Then, if the current number of coupons is less than a preset warning value, new coupon information is selected from the database and cached in Redis to update the coupon information in Redis.
[0079] In this embodiment, considering the large number of coupons required for large-scale events and the time-consuming nature of generating coupon information, it is advisable to generate coupon information in batches. Specifically, the number of coupons generated in step 230 is less than the number of coupons generated in step 210. For example, if the event inventory is 20,000, the number of coupons generated is 10,000. The preset warning value can be pre-set according to actual needs. When the number of coupons cached in Redis is less than the warning value, the inventory management service retrieves new coupon information from the database and stores it in Redis; when the number of coupons cached in Redis is not less than the warning value, no operation is performed. For example, initially, 10,000 coupons are generated, then 5,000 are synchronized to Redis. A warning value of 1,000 is set; when the number of coupons in Redis falls below 1,000, another 5,000 coupons are synchronized from the database to Redis.
[0080] It should be noted that the above steps can be performed before, after, or at other times, obtaining the coupon information to be claimed from the coupon information in Redis. This embodiment does not limit the specific timeframe.
[0081] By determining whether the current number of coupons is less than a preset warning value, the system can promptly understand the number of coupons in Redis. If the current number of coupons is less than the preset warning value, new coupon information is selected from the database and cached in Redis to update the coupon information in Redis. This ensures that coupon information can be replenished in a timely manner when the current number of coupons is lower than the preset warning value, thus ensuring that the number of coupons cached in Redis meets the redemption requirements.
[0082] In some embodiments, when generating coupon information in batches, if the current number of coupons is less than a preset warning value, the method further includes: generating a new batch of coupon information according to the new activity, and storing the new batch of coupon information in the database.
[0083] In this embodiment, when the number of coupons cached in Redis is less than the warning value, the inventory management service retrieves new coupon information from the database and stores it in Redis. At the same time, it starts generating the next batch of coupon information and saves it to the database to wait for the next time to be cached in Redis.
[0084] Generating coupon information is a time-consuming and resource-intensive task. By pre-generating a portion of coupon information and then requesting the next batch from the inventory management server when the number of coupons in Redis falls below a preset warning threshold, multiple campaigns can be launched within a shorter timeframe. This avoids situations where prolonged campaign durations, large coupon generation, and prolonged resource consumption can negatively impact other campaigns. By asynchronously and in batches generating coupon information, the system bottleneck issue of being unable to support large-scale campaigns or multiple campaigns running simultaneously is resolved.
[0085] The following example illustrates the solution; please refer to it. Figure 3 , Figure 3 The illustration shows a schematic diagram of the coupon redemption process according to an embodiment of this application.
[0086] When a user sends a request to create an activity, the inventory management service creates the new activity, generates activity inventory information, and saves this information to TDSQL and caches it in Redis. Then, it generates coupon information based on the activity, saves it to TDSQL, and stores a portion of the coupon information in Redis. Upon first claiming a coupon, the inventory management service retrieves a coupon from Redis based on the activity ID, returns the coupon information, and decrements the inventory by 1. After participating in the activity multiple times following these steps, upon claiming a coupon again, the inventory management service retrieves a coupon from Redis based on the activity ID. It then checks if the number of coupons in Redis has reached a warning threshold. If so, Redis returns the coupon information, decrements the inventory by 1, sends a warning message, and retrieves the next batch of coupon information from TDSQL and caches it in Redis. If not, Redis returns the coupon information, decrements the inventory by 1, and the coupon claim is successful. Upon receiving the warning message, the inventory management service generates a new batch of coupons and saves them to TDSQL.
[0087] Figure 2 This is a flowchart illustrating a coupon inventory management method in one embodiment. It should be understood that, although... Figure 2 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 2 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0088] Based on the same inventive concept, this embodiment provides a coupon inventory management device, please refer to... Figure 4 , Figure 4 A schematic structural block diagram of a coupon inventory management device according to an embodiment of this application is shown. The coupon inventory management device includes an inventory generation module 410, an inventory storage module 420, a coupon generation module 430, a coupon storage module 440, and a coupon management module 450, wherein:
[0089] The inventory generation module 410 is used to respond to an activity creation request, create a new activity, and generate the corresponding activity inventory information;
[0090] The inventory storage module 420 is used to store the active inventory information in a database and Redis respectively;
[0091] The coupon generation module 430 is used to generate multiple coupon information based on the new activity, and select a predetermined number of coupon information from the multiple coupon information;
[0092] The coupon storage module 440 is used to store the multiple coupon information into the database and cache the predetermined number of coupon information into the Redis;
[0093] The coupon management module 450 is used to obtain coupon activity information when claiming coupons, and to obtain coupon information to be claimed from coupon information in Redis based on the coupon activity information, while updating the coupon information and activity inventory information in Redis.
[0094] The coupon management module 450 includes:
[0095] The first query unit is used to query the current activity inventory information in Redis based on the coupon activity information;
[0096] The first judgment unit is used to determine whether the current active inventory information is greater than 0;
[0097] The claiming unit is used to obtain the coupon information to be claimed from the coupon information in Redis based on the coupon claiming activity information when the current activity inventory information is greater than 0.
[0098] The prompting unit is used to generate a prompt message when the current active inventory information is not greater than 0.
[0099] The coupon inventory management device further includes:
[0100] The coupon query module is used to query the current number of coupons in Redis based on the coupon redemption activity information;
[0101] The judgment module is used to determine whether the current coupon quantity information is less than a preset warning value;
[0102] The coupon update module is used to select new coupon information from the database and cache the new coupon information in Redis when the current number of coupons is less than a preset warning value, so as to update the coupon information in Redis.
[0103] Wherein, if the current coupon quantity information is less than a preset warning value, the coupon update module includes:
[0104] The regeneration unit is used to regenerate a new batch of coupon information based on the new activity, and store the new batch of coupon information in the database.
[0105] The coupon inventory management device includes a processor and a memory. The aforementioned inventory generation module 410, inventory storage module 420, coupon generation module 430, coupon storage module 440, and coupon management module 450 are all stored in the memory as program units. The processor executes the aforementioned program modules stored in the memory to implement the corresponding functions.
[0106] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and the coupon inventory management method can be implemented by adjusting kernel parameters.
[0107] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0108] This application provides a machine-readable storage medium storing a program that, when executed by a processor, implements the aforementioned coupon inventory management method.
[0109] This application provides a processor for running a program, wherein the program executes the above-described coupon inventory management method during runtime.
[0110] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown in the figure, the computer device includes a processor A01, a network interface A02, a display screen A04, an input device A05, and a memory (not shown) connected via a system bus. The processor A01 provides computing and control capabilities. The memory includes internal memory A03 and a non-volatile storage medium A06. The non-volatile storage medium A06 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 stored in the non-volatile storage medium A06. The network interface A02 is used for communication with external terminals via a network connection. When the computer program is executed by the processor A01, it implements a coupon inventory management method. The display screen A04 can be a liquid crystal display (LCD) or an e-ink display. The input device A05 can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0111] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0112] In one embodiment, the coupon inventory management device provided in this application can be implemented as a computer program, which can be configured as follows: Figure 5 It runs on the computer device shown. The computer device's memory can store the various program modules that make up the coupon inventory management device, for example, Figure 4 The diagram shows an inventory generation module 410, an inventory storage module 420, a coupon generation module 430, a coupon storage module 440, and a coupon management module 450. The computer program comprised of these modules causes a processor to execute the steps of the coupon inventory management methods described in the various embodiments of this application.
[0113] Figure 5 The computer equipment shown can be used as follows Figure 4 The inventory generation module 410 in the coupon inventory management device shown executes step 210. The computer equipment can execute step 220 through the inventory storage module 420, step 230 through the coupon generation module 430, step 240 through the coupon storage module 440, and step 250 through the coupon management module 450.
[0114] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the following method steps:
[0115] In response to an activity creation request, create a new activity and generate the corresponding activity inventory information;
[0116] The activity inventory information is stored in a database and Redis respectively;
[0117] Based on the new activity, generate multiple coupon information and select a predetermined number of coupon information from the multiple coupon information;
[0118] The multiple coupon information items are stored in the database, and the predetermined number of coupon information items are cached in the Redis.
[0119] When claiming coupons, obtain coupon claiming activity information, and based on the coupon claiming activity information, obtain the coupon information to be claimed from the coupon information in Redis, and update the coupon information and activity inventory information in Redis.
[0120] In one embodiment, obtaining the coupon information to be claimed from the coupon information in Redis based on the coupon activity information includes:
[0121] Based on the coupon redemption activity information, the current activity inventory information is retrieved from the Redis database.
[0122] Determine whether the current activity inventory information is greater than 0;
[0123] If the current activity inventory information is greater than 0, the coupon information to be claimed is obtained from the coupon information in Redis based on the coupon claiming activity information;
[0124] If the current active inventory information is not greater than 0, a prompt message will be generated.
[0125] In one embodiment, the coupon inventory management method further includes:
[0126] Based on the coupon redemption activity information, the current coupon quantity information can be retrieved from the Redis;
[0127] Determine whether the current number of coupons is less than a preset warning value;
[0128] If the current number of coupons is less than a preset warning value, new coupon information is selected from the database and cached in Redis to update the coupon information in Redis.
[0129] In one embodiment, if the current coupon quantity information is less than a preset warning value, the method further includes:
[0130] Based on the new activity, a new batch of coupon information is generated and stored in the database.
[0131] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can 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, etc.) containing computer-usable program code.
[0132] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can 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, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0133] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0134] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0135] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0136] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0137] Computer-readable media include both permanent and non-permanent, removable and non-removable media, which can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0138] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0139] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for managing coupon inventory, characterized in that, The coupon inventory management method includes: In response to the activity creation request, a new activity is created and corresponding activity inventory information is generated; the activity inventory information refers to the remaining quantity of coupons to be distributed in this activity; the new activity includes the coupon activity's identification number, the coupon activity's address, and the coupon activity's inventory; The activity inventory information is stored in a database and Redis respectively; Based on the new activity, generate multiple coupon information and select a predetermined number of coupon information from the multiple coupon information; The multiple coupon information items are stored in the database, and the predetermined number of coupon information items are cached in the Redis. When claiming coupons, obtain coupon claiming activity information, and based on the coupon claiming activity information, obtain the coupon information to be claimed from the coupon information in Redis, and update the coupon information and activity inventory information in Redis at the same time; The coupon inventory management method also includes: Based on the coupon redemption activity information, the current coupon quantity information can be retrieved from the Redis; Determine whether the current number of coupons is less than a preset warning value; If the current number of coupons is less than a preset warning value, new coupon information is selected from the database and cached in Redis to update the coupon information in Redis.
2. The method according to claim 1, characterized in that, The step of retrieving the coupon information to be claimed from the coupon information in Redis based on the coupon activity information includes: Based on the coupon redemption activity information, the current activity inventory information is retrieved from the Redis database. Determine whether the current activity inventory information is greater than 0; If the current activity inventory information is greater than 0, the coupon information to be claimed is obtained from the coupon information in Redis based on the coupon claiming activity information; If the current active inventory information is not greater than 0, a prompt message will be generated.
3. The method according to claim 1, characterized in that, If the current number of coupons is less than a preset warning value, the following additional steps are also included: Based on the new activity, a new batch of coupon information is generated and stored in the database.
4. A coupon inventory management device, characterized in that, The coupon inventory management device includes: The inventory generation module is used to respond to an activity creation request, create a new activity, and generate corresponding activity inventory information; the activity inventory information refers to the remaining quantity of coupons to be distributed in this activity; the new activity includes the coupon activity's identification number, the coupon activity's address, and the coupon activity's inventory; An inventory storage module is used to store the active inventory information in a database and Redis, respectively; The coupon generation module is used to generate multiple coupon information based on the new activity, and select a predetermined number of coupon information from the multiple coupon information; The coupon storage module is used to store the multiple coupon information into the database and cache the predetermined number of coupon information into the Redis; The coupon management module is used to obtain coupon activity information when claiming coupons, and to obtain coupon information to be claimed from the coupon information in Redis based on the coupon activity information, while updating the coupon information and activity inventory information in Redis; The coupon inventory management device further includes: The coupon query module is used to query the current number of coupons in Redis based on the coupon redemption activity information; The judgment module is used to determine whether the current coupon quantity information is less than a preset warning value; The coupon update module is used to select new coupon information from the database and cache the new coupon information in Redis when the current number of coupons is less than a preset warning value, so as to update the coupon information in Redis.
5. The apparatus according to claim 4, characterized in that, The coupon management module includes: The first query unit is used to query the current activity inventory information in Redis based on the coupon activity information; The first judgment unit is used to determine whether the current active inventory information is greater than 0; The claiming unit is used to obtain the coupon information to be claimed from the coupon information in Redis based on the coupon claiming activity information when the current activity inventory information is greater than 0. The prompting unit is used to generate a prompt message when the current active inventory information is not greater than 0.
6. A processor, characterized in that, It is configured to perform the coupon inventory management method according to any one of claims 1 to 3.
7. A machine-readable storage medium storing instructions thereon, characterized in that, When executed by a processor, this instruction causes the processor to be configured to perform the coupon inventory management method according to any one of claims 1 to 3.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the coupon inventory management method according to any one of claims 1 to 3.