Data consistency verification method of reservation panic buying system
By obtaining the initial and uninvented quotas in parallel verification in the reservation and purchase system, the delay problem of data consistency verification is solved, and efficient data abnormality detection and system reliability are achieved.
Patent Information
- Application Number
- CN202510563700.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2025-08-19
AI Technical Summary
The prior art lacks the ability to quickly and effectively verify the data of the appointment-based rushing system, which leads to the inability to detect problems in time when data is abnormal.
By obtaining the initial sales quota and reservation quota of each sub-institution in the reservation rush system, the remaining sales quota and reservation quota are obtained in parallel by using threads of the asynchronous waiting mechanism, and data consistency verification is performed based on the queue storage of the reservation quota.
It improves the processing capability of data consistency verification, promptly detects data abnormalities, reduces the impact of the performance bottleneck of database table insertion performance on the peak period of appointment purchases, and improves the high reliability of the system and customer appointment experience.
Smart Images

Figure CN120508563A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data verification, and in particular to a data consistency verification method for a reservation-based rush purchase system. Background Art
[0002] To ensure smooth booking and a positive customer experience, reservation systems require warehousing order data. However, during this process, data anomalies may occur. Existing technologies lack the ability to quickly and effectively verify data consistency, making it difficult to identify data anomalies in a timely manner. Summary of the Invention
[0003] This application provides a data consistency verification method for a reservation and rush purchase system to solve the problem of being unable to perform consistency verification on data.
[0004] According to one aspect of the present application, a data consistency verification method for a reservation-based purchase system is provided, comprising:
[0005] Obtain the initial available sales quota and reserved inventory quota of each sub-organization in the reservation purchase system;
[0006] The remaining saleable quota and reserved but undeposited quota of each of the sub-institutions are obtained in parallel through threads of an asynchronous waiting mechanism, wherein the reserved but undeposited quota is obtained based on a queue;
[0007] For each subsidiary, a data consistency check is performed based on the initial saleable quota, the reserved warehousing quota, the remaining saleable quota and the reserved but unwarehousing quota.
[0008] The technical solution of the embodiment of the present application is to obtain the initial saleable amount and the reserved inventory amount of each sub-institution in the reservation rush purchase system; obtain the remaining saleable amount and the reserved but unstocked amount of each sub-institution in parallel through the thread of the asynchronous waiting mechanism, and the reserved but unstocked amount is obtained based on the queue; for each sub-institution, data consistency verification is performed based on the initial saleable amount, the reserved inventory amount, the remaining saleable amount and the reserved but unstocked amount, which solves the problem of being unable to perform consistency verification on data, obtains the initial saleable amount and the reserved inventory amount of the sub-institution, and then obtains the remaining saleable amount and the reserved but unstocked amount of each sub-institution in parallel through the thread of the asynchronous waiting mechanism, and the data of multiple sub-institutions are verified. The data can be obtained concurrently, which saves time, improves the verification and processing capabilities, and timely detects data anomalies; among them, the reserved but unstocked quota is obtained based on the queue. In the embodiment of the present application, the reserved quota of the subsidiary organization is not directly stored in the database table, but is first stored through the queue and then stored. By storing the reserved but unstocked quota in the queue, the database performance is improved, and the impact of the database table insertion performance bottleneck on the customer reservation experience during the peak period of reservation rush purchase is reduced; data consistency verification is performed based on the initial saleable quota, the reserved and stored quota, the remaining saleable quota and the reserved but unstocked quota, data anomalies are discovered in time, data operation anomalies are effectively detected, and reservation quota anomalies are discovered in time, thereby improving the high reliability of the system.
[0009] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0011] Figure 1 This is a flow chart of a data consistency verification method for a reservation purchase system provided in accordance with the first embodiment of the present application;
[0012] Figure 2 This is a flow chart of a data consistency verification method for a reservation purchase system provided in accordance with the second embodiment of the present application;
[0013] Figure 3 This is an example diagram of an implementation of consistency check provided in accordance with the second embodiment of the present application;
[0014] Figure 4This is a structural diagram of a data consistency verification device for a reservation purchase system provided in accordance with the third embodiment of the present application;
[0015] Figure 5 It is a structural diagram of an electronic device that implements the data consistency verification method of the reservation purchase system of the embodiment of the present application. DETAILED DESCRIPTION
[0016] In order to enable those skilled in the art to better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this application.
[0017] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in a sequence other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0018] Example 1
[0019] Figure 1 This is a flow chart of a data consistency verification method for a reservation-based rush purchase system provided in Example 1 of the present application. This embodiment is applicable to situations where data consistency verification of a reservation-based rush purchase system is required. This method can be executed by a data consistency verification device for a reservation-based rush purchase system. The data consistency verification device for a reservation-based rush purchase system can be implemented in the form of hardware and / or software. The data consistency verification device for a reservation-based rush purchase system can be configured in an electronic device. Figure 1 As shown, the method includes:
[0020] S101. Obtain the initial saleable amount and reserved inventory amount of each sub-institution in the reservation and rush purchase system.
[0021] In this embodiment, the reservation purchase system can be understood as a data processing system for reservation purchase of products. The products can be physical products, virtual electronic products, etc. The reservation purchase system can include one or more sub-institutions. Sub-institutions can be specific organizations in different fields, for example, head offices, branches and sub-branches at the company level, etc. Users can choose to purchase products from designated sub-institutions. The initial saleable amount can be understood as the amount of products that can be reserved for purchase that is allocated in advance to the sub-institution before the purchase. For example, the initial saleable amount of sub-institution 1 is 10,000, which means that the maximum number of products that can be reserved for purchase by sub-institution 1 is 10,000. The reserved warehousing amount can be understood as the amount that has been reserved for purchase and stored in the database.
[0022] Before a pre-order is made, quotas can be pre-set for all sub-organizations that are scheduled to make pre-orders. This means that an initial sales quota can be set for each sub-organization and stored. The pre-order system may include multiple sub-organizations. When making a pre-order, pre-order permissions can be granted to all sub-organizations, allowing users to make pre-orders through any sub-organization. Alternatively, permissions can be granted to only some sub-organizations, allowing users to make pre-orders only through sub-organizations with pre-order permissions. For example, when releasing a product, pre-order permissions can be set for sub-organizations based on information such as product type, quantity, and target user demographics. An initial sales quota is allocated to each sub-system with pre-order permissions. The size of a sub-organization's initial sales quota can be determined based on one or more factors, such as product type, quantity, sub-organization location, customer traffic, and processing capacity. After pre-orders are opened, different users can select a corresponding sub-organization to make pre-orders. Upon receiving a user's pre-order request through a sub-organization, the user's pre-order quota is determined based on the user's pre-order request and stored. The user's reservation quota is stored in the database table through a queue. The reservation quota stored in the database table is counted to obtain the reserved inventory quota. The initial saleable quota allocated to the sub-organization is directly obtained.
[0023] S102. The remaining saleable quota and reserved but undeposited quota of each subsidiary are obtained in parallel through the thread of the asynchronous waiting mechanism. The reserved but undeposited quota is obtained based on the queue.
[0024] In this embodiment, the remaining available quota can be understood as the remaining available quota after the sub-organization has made a purchase reservation. For example, if the initial available quota is 100 units and User 1 makes a purchase reservation for 1 unit, the remaining available quota is 99 units. The reserved but unstocked quota can be understood as the quota that has been reserved for purchase but has not yet been stored in the database.
[0025] After the user makes a reservation for a purchase through a sub-institution, the remaining saleable amount of the corresponding sub-institution is updated and stored according to the user's reservation amount; the user's reservation amount is stored in a queue, for example, the reservation amount is directly stored in the queue, or the identification information of the reservation amount is stored, and the corresponding reservation amount is obtained according to the identification information query, etc. The reservation amount stored in the queue is further stored in the database table to complete the storage. What is stored in the queue is the reservation amount that has not been stored in the warehouse or the relevant information of the reservation amount; based on the queue, the reserved but not stored amount can be obtained. The asynchronous waiting mechanism can realize the concurrent execution of multiple tasks and finally obtain all processing results; when performing data consistency verification, the embodiment of the present application obtains the remaining saleable amount and the reserved but not stored amount of each sub-institution in parallel through the thread of the asynchronous waiting mechanism, reducing the time consumption of consistency verification and quickly completing data consistency verification.
[0026] S103. For each subsidiary, perform data consistency verification based on the initial saleable quota, the reserved inventory quota, the remaining saleable quota, and the reserved but un-inventory quota.
[0027] For each subsidiary, a data consistency check is performed separately. The check method is as follows: the initial available sale quota, reserved inventory quota, remaining sale quota, and reserved but uncollected quota are analyzed to determine whether the quota values of the subsidiary are consistent. For example, the sum of the reserved inventory quota, remaining sale quota, and reserved but uncollected quota is determined to be consistent with the initial available sale quota. The data consistency check results can be normal / abnormal, consistent / inconsistent, etc.
[0028] The embodiment of the present application provides a data consistency verification method for a reservation and rush purchase system, which solves the problem of being unable to perform consistency verification on data, obtains the initial saleable amount and the reserved inventory amount of the sub-institution, and then obtains the remaining saleable amount and the reserved but unstocked amount of each sub-institution in parallel through the thread of the asynchronous waiting mechanism. The data of multiple sub-institutions can be obtained concurrently, saving time, improving the verification processing capability, and timely discovering data anomalies; wherein, the reserved but unstocked amount is obtained based on a queue. In the embodiment of the present application, the reserved amount of the sub-institution is not directly stored in the database table, but is first stored through a queue and then stored. The reserved but unstocked amount is stored in the queue, which improves database performance and reduces the impact of the database table insertion performance bottleneck on the customer reservation experience during the reservation rush purchase peak period; data consistency verification is performed based on the initial saleable amount, the reserved inventory amount, the remaining saleable amount and the reserved but unstocked amount, data anomalies are discovered in a timely manner, data operation anomalies are effectively detected, reservation amount anomalies are discovered in a timely manner, and the high reliability of the system is improved.
[0029] Example 2
[0030] Figure 2This is a flow chart of a data consistency verification method for a reservation purchase system provided in Example 2 of this application. This embodiment is refined based on the above embodiment. Figure 2 As shown, the method includes:
[0031] S201. Obtain the initial saleable quota of each subsidiary from the product quota table.
[0032] In this embodiment, the product quota table can be understood as storing the sales quotas of different sub-organizations for products. It can store the sales quotas of the same product corresponding to multiple sub-organizations, or it can store the sales quotas of multiple sub-organizations for multiple products. The sales quota of each product corresponding to each sub-organization is determined in advance based on the allocation of products, recorded as the initial sales quota, and stored in the product quota table. Exemplarily, the product quota table stores the initial sales quotas of the same product corresponding to multiple sub-organizations. The product quota table can be identified by the type or number of the product. When obtaining the initial sales quota of a sub-organization, the corresponding product quota table is queried based on the product to obtain the initial sales quota of each sub-organization; alternatively, the product quota table stores the initial sales quotas of multiple products corresponding to multiple sub-organizations, and also stores the products corresponding to the initial sales quotas. When obtaining the initial sales quota of a sub-organization, the product quota table is queried to obtain the initial sales quota of each sub-organization for the product, and so on.
[0033] For example, the quota of pre-sale products is allocated before the appointment for rush purchase, and the product quota table is designed as a relational database table to store the initial saleable quota of each sub-institution for the product. In the product quota table, quota allocation is carried out according to actual business needs. The quota allocated to each sub-institution can be the same or different. Based on the system's need for high concurrency capabilities to achieve rapid deduction of saleable quotas, the initial available quotas of all pre-sale products in the product quota table are imported into the Key-Value distributed cache before the appointment for rush purchase. The product quota information stored in the distributed cache uses the sub-institution number as the key and the initial saleable quota and other information as the value.
[0034] S202: For each sub-organization, obtain all order information that the sub-organization has reserved from the product order table and count the product quotas to determine the sub-organization's reserved warehousing quota.
[0035] In this embodiment, the product order table can be understood as a data table that stores product order information. The data stored in the product order table can be considered as data that has been stored in the warehouse. The order information can be understood as the relevant information of the order formed by the user's reservation for a rush purchase, and can include relevant information about the reservation, such as the time of the reservation, the reservation amount, the sub-institution number, user information, and one or more other information. The product order table is analyzed to determine all order information that has been reserved by each sub-institution. The product amount is calculated based on the order information, that is, the product amount in each order information is calculated to determine the total amount, and the total amount is used as the sub-institution's reserved inventory amount.
[0036] S203. The remaining saleable quota and reserved but undeposited quota of each sub-institution are obtained in parallel through the thread of the asynchronous waiting mechanism. The reserved but undeposited quota is obtained based on the queue.
[0037] Optionally, the remaining saleable quota of each sub-institution is obtained from the distributed cache; the reserved but unstocked quota of each sub-institution is obtained from the order information in the distributed cache according to the order number in the queue.
[0038] Each subsidiary's remaining available quota and order information are stored in a distributed cache. Order numbers are stored in a queue, uniquely identifying the order information. The distributed cache is then queried based on the order number to determine the corresponding order information. The reserved quotas in the order information are then counted to determine the reserved but undelivered quotas. When obtaining the remaining available quota and reserved but undelivered quotas, threads using an asynchronous wait mechanism can concurrently retrieve the remaining available quota and order information for each subsidiary from the distributed cache.
[0039] When performing data consistency checks, simply sequentially retrieving each subsidiary's remaining available sales quota and reserved but undelivered quota in the queue from the distributed cache, and given the large number of subsidiaries (tens of thousands), order data consistency checks can be quite time-consuming. This time consumption primarily stems from sequentially retrieving available sales quota and undelivered quota in the queue from the distributed cache. Because this requires retrieving these quotas for each subsidiary one by one, the primary time consumption is in accessing the distributed cache and queue, as well as network latency. The added time of multiple subsidiaries significantly increases the overall time consumption.
[0040] The embodiment of the present application can greatly improve the processing capacity of verification through the asynchronous waiting mechanism; the asynchronous waiting mechanism can realize the acquisition of the results of asynchronous calculation, provide a capability to check whether the asynchronous calculation is completed, wait for completion and obtain the results of the asynchronous calculation; the calculation results can only be obtained after the asynchronous calculation is completed. The asynchronous waiting mechanism is used to perform data consistency verification, wait for the sub-institution to calculate the remaining saleable amount in the distributed cache and the reserved but unstocked amount in the queue, and obtain the calculation results after the calculation is completed. The amounts of multiple sub-institutions can be obtained concurrently.
[0041] S204: Calculate the sum of the remaining saleable quota, the reserved inventory quota, and the reserved but un-inventory quota to obtain the total quota.
[0042] The sum of the reserved warehousing quota and the reserved but unwarehousing quota is the reserved quota, and the remaining saleable quota plus it is the total quota of the sub-institution.
[0043] S205. Compare the initial saleable amount and the total amount to see if they are consistent. If they are consistent, determine that the result of the data consistency check is data consistency; otherwise, determine that the result of the data consistency check is data inconsistency.
[0044] As an optional embodiment, this optional embodiment further optimizes the steps of forming the product order table, including A1-A3:
[0045] A1. Obtain the order number from the queue through data synchronization service polling and add a distributed global lock to the order number.
[0046] The queue stores different order numbers. The data synchronization service polls the queue to obtain an order number. This can be obtained sequentially, for example, by first-in-first-out, or by randomly selecting an order number from the queue. A distributed global lock is added to this order number to prevent it from being processed repeatedly by other data synchronization services or threads.
[0047] A2. Get the order information from the distributed cache based on the order number and insert it into the product order table.
[0048] Store order information in the distributed cache in advance, including the order number, or uniquely identify the order information by the order number; query and obtain matching order information from the distributed cache based on the order number, insert the obtained order information into the product order table, and complete the storage of the reservation amount.
[0049] A3. Delete the order number from the queue and release the distributed global lock.
[0050] After the order information is inserted into the product order table, the order number is deleted from the queue and the distributed global lock is released.
[0051] As an optional embodiment, this optional embodiment further optimizes and includes B1-B2:
[0052] B1. After obtaining the sub-institution reservation and rush purchase information, generate order information based on the user information corresponding to the sub-institution reservation and rush purchase information and the sub-institution reservation and rush purchase information, wherein the sub-institution reservation and rush purchase information at least includes the sub-institution number and the reservation amount, and the order information at least includes the user information, the sub-institution number, the reservation amount and the order number.
[0053] In this embodiment, the sub-institution reservation purchase information can be understood as the information describing the reservation purchase when the user makes a reservation purchase through the sub-institution. The sub-institution reservation purchase information includes at least the sub-institution number and the reservation amount. The sub-institution number uniquely identifies the sub-institution, and the reservation amount is the amount reserved by the user when making a reservation purchase through the sub-institution this time.
[0054] When a user makes a reservation for a purchase through a sub-institution, sub-institution reservation for a purchase information is generated; after obtaining the sub-institution reservation for a purchase information, the user information corresponding to the sub-institution reservation for a purchase information is determined. The user information is relevant information about the user who made the reservation for a purchase, and can be the user's account number, email address, etc. Order information is generated based on the user information and the sub-institution reservation for a purchase information. The user information and the sub-institution reservation for a purchase information can be directly used as order information, and an order number can be generated as the order information. The order number can be generated according to set rules, for example, according to one or more information such as time and sequence; wherein the order information at least includes user information, sub-institution number, reservation amount, and order number.
[0055] B2. Add the order number corresponding to the order information to the queue.
[0056] Add the order number corresponding to the order information to the queue so that the reserved amount can be put into storage through the queue.
[0057] As an optional embodiment, this optional embodiment is further optimized to include: storing the order information in the form of a key-value pair in a distributed cache, wherein the order number serves as the key in the key-value pair and the order information serves as the value in the key-value pair.
[0058] The order information is stored in a distributed cache using key-value pairs, with the order number serving as the key and the order information as the value. During consistency checks, the distributed cache can be queried using the order number to determine the corresponding order information.
[0059] As an optional embodiment, this optional embodiment is further optimized to include updating the remaining saleable amount in the distributed cache according to the reserved amount, and the initial value of the remaining saleable amount is the initial saleable amount, which is obtained from the product amount table.
[0060] After a user makes a reservation for a purchase through a subsidiary, the reservation amount is determined, the remaining saleable amount in the distributed cache is subtracted from the reservation amount, and the difference is used as the new remaining saleable amount to update the remaining saleable amount. The initial value of the remaining saleable amount is the initial saleable amount, which can be obtained from the product quota table. That is, the distributed cache initially stores the initial saleable amount obtained from the product quota table, and the initial saleable amount is used as the initial remaining saleable amount. After the user makes a reservation for a purchase, the user's reservation amount is determined, and the initial saleable amount is subtracted from the reservation amount to obtain the updated remaining saleable amount. Every time a user makes a reservation for a purchase, the remaining saleable amount is updated according to the user's reservation amount.
[0061] As an optional embodiment, this optional embodiment is further optimized to include: if the result of the data consistency check is data inconsistency, query all order numbers in the distributed cache; determine whether the order number is in the product order table, and add the order number that is not in the product order table back to the queue.
[0062] If the result of the data consistency check is data inconsistency, it can be considered as a storage anomaly, and the order number needs to be re-queued; query all order numbers in the distributed cache and match this order number with the order number stored in the product order table. If it matches, it means that the order information corresponding to this order number has been stored in the warehouse and there is no need to re-queue this order number; if it does not match, it means that the order information corresponding to this order number has not been successfully stored in the warehouse, and this order number needs to be added to the queue again.
[0063] As an optional embodiment, this optional embodiment is further optimized to include: monitoring the lock-off time of the distributed global lock; if the lock-off time exceeds a set time threshold, releasing the distributed global lock.
[0064] In this embodiment, the time threshold can be pre-set; for example, it can be set based on the system's data processing volume and processing capacity. Alternatively, historical data can be analyzed to determine the duration of processing an order number, calculate the average duration, and set the time threshold based on the average duration. The lock time of the distributed global lock can be understood as the duration of the distributed global lock after the order number is locked. For example, the timer starts counting after the distributed global lock is applied to an order number, and the counted time is the lock time.
[0065] After adding a distributed global lock to the order number, monitor the lock time of the distributed global lock; compare the lock time with the pre-set time threshold. If the lock time exceeds the time threshold, release the distributed global lock.
[0066] During the warehousing process of order information, if an warehousing exception occurs, the distributed cache lock cannot be released, and other threads cannot synchronize the orders in the queue to the database. Therefore, this application automatically unlocks the distributed global lock by setting a time threshold. This application implements a batch by design, uniformly polling all distributed global locks, and automatically releases the distributed global lock when it is found that the distributed global lock exceeds a certain time threshold. In order to ensure that all queue data is synchronized to the database normally, a queue lock will be set for each thread during synchronization, and the lock will be automatically released after the synchronization is completed. However, the lock cannot be released when a data synchronization exception occurs. It is necessary to check all existing locks and release all unlocked locks. After unlocking, other warehousing threads can consume and store normally. If there is an warehousing exception and the queue order information is deleted, the order data needs to be re-queued.
[0067] For example, the present embodiment provides a method for implementing a consistency check of credit limit data, and the implementation process is as follows:
[0068] During the pre-order rush period, the user selects a designated sub-institution to make a pre-order rush. For example, the user makes a pre-order rush for a product with a unit of 10 in the sub-institution numbered 000001. The sub-institution 000001 has an initial saleable amount of 50,000 configured in the distributed cache. The system first deducts the amount of the sub-institution 000001 in the distributed cache, that is, the unit is 50,000-10=49,990. After the deduction, the user-related information, the pre-order amount, the pre-order institution number, and other information need to be registered as order information. If it is directly registered in the product order table of the relational database, the customer pre-order process during the pre-order rush period will be affected by the performance bottleneck of the relational database table insertion. Therefore, the embodiment of the present application stores the order information after the reservation amount is deducted in the form of key-value in the distributed cache, and stores the order number in the queue, obtains the order number from the queue through polling by the data synchronization service, and obtains the order information from the distributed cache through the order number and then inserts it into the product order table. The data synchronization service is a multi-threaded order that puts the order information corresponding to the order number in the queue into the warehouse. In this way, it is necessary to add a distributed global lock to an order change in the queue before obtaining the order number from the queue each time, delete the order number in the queue after the storage is completed, and then release the distributed global lock to prevent multiple threads of multiple data synchronization services from obtaining the same order data at the same time.
[0069] Because the relevant data of the reservation is in the distributed cache, the queue and the database respectively, in order to prevent abnormalities when the system accesses the distributed cache, queue and database, improve the reliability of the system operation, prevent quota data deviation and foresee over-issuance of reservation quota, etc., it is necessary to perform a quota data consistency check to verify the initial saleable quota and the remaining saleable quota in the distributed cache, and whether the reserved but unstocked quota in the queue and the reserved and stocked quota in the product order table are equal.
[0070] The steps for the consistency check of the credit limit data in this embodiment of the application are as follows:
[0071] Step 1. Get the initial saleable quota of all available sub-institutions from the product quota table and return a Map where the key is the sub-institution number and the value is the initial saleable quota.
[0072] Step 2: Count the reserved product quotas from the product order table and return a Map, where the key is the sub-institution number and the value is the reserved inventory quota.
[0073] Step 3. Each thread of the asynchronous waiting mechanism obtains information including the sub-institution number, the remaining saleable amount, and the reserved but unstocked amount in parallel; the reserved but unstocked amount can be determined by querying the distributed cache through the order number stored in the queue.
[0074] The remaining available quota is the amount of the initial available quota stored in the distributed cache, which is then deducted from the amount after reservations are made. For reserved but unstored quotas, the information stored in the queue only needs to include the order number. Order information can be stored in the distributed cache using the order number as the key and the order information as the value. Therefore, the actual quota in the queue is determined by retrieving the reserved quota from the distributed cache based on the order number in the queue.
[0075] Step 4: Compare the initial saleable amount of each sub-institution to see if it is equal to the sum of the remaining saleable amount + the reserved inventory amount + the reserved but unreceived inventory amount. If not, mark the sub-institution.
[0076] Step 5: Return the data consistency verification results of all sub-institutions in the form of a linked list.
[0077] For example, Figure 3An example diagram for implementing consistency verification is provided, comprising the following steps: obtaining the remaining saleable quota and reserved but unstocked quota of different sub-institutions, where each obtaining of the remaining saleable quota and reserved but unstocked quota in the diagram may be obtaining the remaining saleable quota and reserved but unstocked quota of a sub-institution; obtaining the initial saleable quota in the product quota table, from which the initial saleable quota of each sub-institution may be obtained; obtaining the reserved stocked quota in the product order table, from which the reserved stocked quota of all sub-institutions may be obtained; performing data consistency verification and returning verification results to all sub-institutions.
[0078] The reserved but unstocked quota in the embodiment of the present application can also be referred to as the queue reserved quota.
[0079] The initial saleable amount of all sub-institutions is obtained from the product quota table of the database, and the reserved warehousing amount of all sub-institutions is obtained from the product order table. Then, according to the sub-institution number, the remaining saleable amount of all sub-institutions in the distributed cache and the reserved but not warehousing amount in the queue are obtained respectively. Then, each sub-institution in all sub-institutions is verified: whether the sum of the initial saleable amount and the remaining saleable amount in the distributed cache, the reserved but not warehousing amount in the queue and the reserved warehousing amount is consistent is verified. If the remaining saleable amount in the distributed cache and the unwarehousing amount in the queue of each sub-institution are simply obtained in sequence, and the number of sub-institutions is large (tens of thousands), the order data consistency verification is quite time-consuming. The embodiment of the present application also provides a high-performance verification method while performing the consistency verification of the quota data. After analysis, the time consumption is mainly in obtaining the saleable amount and the unwarehousing amount in the queue from the distributed cache in turn. Because it is necessary to obtain them one by one according to the sub-institution, the time consumption is mainly in accessing the distributed cache and the queue, as well as the network time consumption. The multi-time consumption of the sub-institution is very obvious when the overall time consumption is superimposed. The data consistency verification method provided in the embodiment of the present application greatly improves the processing capability of the verification through an asynchronous waiting mechanism. The asynchronous waiting mechanism can realize the acquisition of the results of asynchronous calculations, provide a capability to check whether the asynchronous calculation is completed, wait for completion and obtain the results of the asynchronous calculations. The calculation results can only be obtained after the asynchronous calculation is completed. The asynchronous waiting mechanism is very suitable for order data consistency verification, waiting for the sub-institution to calculate the remaining saleable amount in the distributed cache and the reserved but unstocked amount in the queue, and obtains the calculation results after the calculation is completed. The amounts of multiple sub-institutions can be obtained concurrently.
[0080] The embodiment of the present application provides a data consistency verification method for a reservation and rush purchase system, which solves the problem of being unable to perform consistency verification on data. The remaining saleable amount and the reserved but unstocked amount of each sub-institution are obtained in parallel through the threads of the asynchronous waiting mechanism. The data of multiple sub-institutions can be obtained concurrently, saving time, improving the verification processing capability, and timely discovering data anomalies; wherein, the reserved but unstocked amount is obtained based on a queue. In the embodiment of the present application, the reserved amount of the sub-institution is not directly stored in the database table, but is first stored through a queue and then stored. The reserved but unstocked amount is stored in the queue, which improves database performance and reduces the impact of the database table insertion performance bottleneck on the customer reservation experience during the reservation rush purchase peak period; data consistency verification is performed based on the initial saleable amount, the reserved stocked amount, the remaining saleable amount and the reserved but unstocked amount, so as to timely discover data anomalies, effectively detect data operation anomalies, and timely discover abnormalities in the reservation amount, thereby improving the high reliability of the system. The method provided in the embodiment of the present application can effectively detect abnormalities in distributed cache, queue and data operations, foresee the over-issuance of reservation quotas, and improve the high reliability of the system; when there is inconsistency in the quota, the final warehousing is achieved by re-entering the queue through the order number, ensuring that the data can be saved in the database, thereby improving data reliability.
[0081] Example 3
[0082] Figure 4 This is a structural diagram of a data consistency verification device for a reservation purchase system provided in Example 3 of this application. Figure 4 As shown, the device includes: a first credit limit obtaining module 31, a second credit limit obtaining module 32 and a credit limit verification module 33.
[0083] The first quota acquisition module 31 is used to obtain the initial saleable quota and the reserved warehousing quota of each sub-organization in the reservation purchase system;
[0084] The second quota acquisition module 32 is used to acquire the remaining saleable quota and reserved but undeposited quota of each sub-institution in parallel through the thread of the asynchronous waiting mechanism, and the reserved but undeposited quota is acquired based on the queue;
[0085] The quota verification module 33 is used to perform data consistency verification for each subsidiary based on the initial saleable quota, the reserved inventory quota, the remaining saleable quota and the reserved but un-inventory quota.
[0086] The embodiment of the present application provides a data consistency verification device for a reservation and rush purchase system, which solves the problem of being unable to perform consistency verification on data. The remaining saleable amount and the reserved but unstocked amount of each sub-institution are obtained in parallel through the threads of the asynchronous waiting mechanism. The data of multiple sub-institutions can be obtained concurrently, saving time, improving the verification processing capability, and timely discovering data anomalies; wherein, the reserved but unstocked amount is obtained based on a queue. In the embodiment of the present application, the reserved amount of the sub-institution is not directly stored in the database table, but is first stored through a queue and then stored. The reserved but unstocked amount is stored in the queue, which improves database performance and reduces the impact of the database table insertion performance bottleneck on the customer reservation experience during the reservation rush purchase peak period; data consistency verification is performed based on the initial saleable amount, the reserved and stored amount, the remaining saleable amount and the reserved but unstocked amount, data anomalies are discovered in a timely manner, data operation anomalies are effectively detected, reservation amount anomalies are discovered in a timely manner, and the high reliability of the system is improved.
[0087] Optionally, the first credit limit obtaining module 31 includes:
[0088] The initial quota acquisition unit is used to obtain the initial saleable quota of each sub-institution from the product quota table;
[0089] The warehousing quota acquisition unit is used to obtain all order information that the sub-institution has reserved from the product order table and count the product quotas for each sub-institution, so as to determine the reserved warehousing quota of the sub-institution.
[0090] Optionally, the device further includes:
[0091] An order number acquisition module, configured to obtain the order number from the queue through data synchronization service polling and add a distributed global lock to the order number;
[0092] An order information adding module, used to obtain order information from the distributed cache according to the order number and insert it into the product order table;
[0093] An order number deletion module is used to delete the order number from the queue and release the distributed global lock.
[0094] Optionally, the remaining saleable amount of each of the sub-institutions is obtained from a distributed cache;
[0095] The reserved but unstocked quota of each sub-institution is obtained from the order information in the distributed cache according to the order number in the queue.
[0096] Optionally, the device further includes:
[0097] An order information generation module is configured to, upon obtaining the sub-institution pre-order purchase information, generate order information based on the user information corresponding to the sub-institution pre-order purchase information and the sub-institution pre-order purchase information, wherein the sub-institution pre-order purchase information includes at least the sub-institution number and the pre-order amount, and the order information includes at least the user information, the sub-institution number, the pre-order amount, and the order number;
[0098] The queue adding module is used to add the order number corresponding to the order information to the queue.
[0099] Optionally, the device further includes:
[0100] The order information storage module is used to store the order information in the form of a key-value pair in a distributed cache, wherein the order number serves as the key in the key-value pair and the order information serves as the value in the key-value pair.
[0101] Optionally, the device further includes:
[0102] The remaining quota updating module is used to update the remaining saleable quota in the distributed cache according to the reserved quota, the initial value of the remaining saleable quota is the initial saleable quota, and the initial saleable quota is obtained from the product quota table.
[0103] Optionally, the quota verification module 33 is specifically used to: calculate the sum of the remaining saleable quota, the reserved inventory quota and the reserved but unstocked quota to obtain the total quota; compare whether the initial saleable quota and the total quota are consistent. If they are consistent, determine that the result of the data consistency verification is data consistency; otherwise, determine that the result of the data consistency verification is data inconsistency.
[0104] Optionally, the device further includes:
[0105] The order number query module is used to query all order numbers in the distributed cache if the result of the data consistency check is inconsistent;
[0106] The order number re-adding module is used to determine whether the order number is in the product order table and re-add the order number that is not in the product order table to the queue.
[0107] Optionally, the device further includes:
[0108] A lock time monitoring module, used to monitor the lock time of the distributed global lock;
[0109] The lock release module is used to release the distributed global lock if the lock time exceeds a set time threshold.
[0110] The data consistency verification device of the reservation and rush purchase system provided in the embodiment of the present application can execute the data consistency verification method of the reservation and rush purchase system provided in any embodiment of the present application, and has the corresponding functional modules and beneficial effects of the execution method.
[0111] Example 4
[0112] Figure 5 A schematic diagram of the structure of an electronic device 40 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0113] like Figure 5 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., which is communicatively connected to the at least one processor 41. The memory stores a computer program that can be executed by the at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 into the random access memory (RAM) 43. Various programs and data required for the operation of the electronic device 40 can also be stored in the RAM 43. The processor 41, ROM 42, and RAM 43 are connected to each other via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0114] Multiple components in the electronic device 40 are connected to the I / O interface 45, including an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a magnetic disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0115] Processor 41 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any other suitable processors, controllers, microcontrollers, etc. Processor 41 executes the various methods and processes described above, such as the data consistency verification method for the pre-order system.
[0116] In some embodiments, the data consistency verification method of the reservation purchase system may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the data consistency verification method of the reservation purchase system described above may be performed. Alternatively, in other embodiments, the processor 41 may be configured to execute the data consistency verification method of the reservation purchase system in any other appropriate manner (for example, by means of firmware).
[0117] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0118] Computer programs for implementing the methods of the present application may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0119] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the data consistency verification method of the reservation purchase system described in any embodiment of the present application.
[0120] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable storage medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0121] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0122] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0123] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within a cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0124] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this application can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of this application can be achieved. This is not limited herein.
[0125] The above specific embodiments do not constitute a limitation on the scope of protection of this application. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application shall be included within the scope of protection of this application.
Claims
1. A data consistency verification method for a reservation purchase system, characterized in that: include: Obtain the initial available sales quota and reserved inventory quota of each sub-organization in the reservation purchase system; The remaining saleable quota and reserved but undeposited quota of each of the sub-institutions are obtained in parallel through threads of an asynchronous waiting mechanism, wherein the reserved but undeposited quota is obtained based on a queue; For each subsidiary, a data consistency check is performed based on the initial saleable quota, the reserved warehousing quota, the remaining saleable quota and the reserved but unwarehousing quota.
2. The method according to claim 1, characterized in that The acquisition of the initial saleable amount and reserved inventory amount of each sub-organization in the reservation rush purchase system includes: Obtain the initial saleable quota for each subsidiary from the product quota table; For each sub-organization, all order information reserved by the sub-organization is obtained from the product order table and the product quota is counted to determine the reserved warehousing quota of the sub-organization.
3. The method according to claim 2, characterized in that The steps of forming the product order table include: Obtain the order number from the queue through data synchronization service polling and add a distributed global lock to the order number; Obtain order information from the distributed cache according to the order number and insert it into the product order table; The order number is deleted from the queue and the distributed global lock is released.
4. The method according to claim 1, wherein The remaining saleable amount of each of the sub-institutions is obtained from the distributed cache; The reserved but unstocked quota of each sub-institution is obtained from the order information in the distributed cache according to the order number in the queue.
5. The method according to any one of claims 3 to 4, characterized in that: Also includes: After obtaining the sub-institution pre-order purchase information, generating order information based on the user information corresponding to the sub-institution pre-order purchase information and the sub-institution pre-order purchase information, wherein the sub-institution pre-order purchase information at least includes the sub-institution number and the pre-order amount, and the order information at least includes the user information, the sub-institution number, the pre-order amount, and the order number; Add the order number corresponding to the order information to the queue.
6. The method according to claim 5, characterized in that Also includes: The order information is stored in a distributed cache in the form of a key-value pair, wherein the order number serves as the key in the key-value pair and the order information serves as the value in the key-value pair.
7. The method according to claim 5, characterized in that Also includes: The remaining saleable amount in the distributed cache is updated according to the reserved amount, the initial value of the remaining saleable amount is the initial saleable amount, and the initial saleable amount is obtained from the product amount table.
8. The method according to claim 1, characterized in that The data consistency check based on the initial saleable amount, the reserved inventory amount, the remaining saleable amount and the reserved but un-inventory amount includes: Calculating the sum of the remaining saleable quota, the reserved warehousing quota, and the reserved but unwarehousing quota to obtain a total quota; The initial saleable amount and the total amount are compared to determine whether they are consistent. If they are consistent, the result of the data consistency check is determined to be data consistent; otherwise, the result of the data consistency check is determined to be data inconsistent.
9. The method according to any one of claims 1 or 8, characterized in that Also includes: If the result of the data consistency check is inconsistent, query all order numbers in the distributed cache; Determine whether the order number is in the product order table, and add the order number that is not in the product order table back to the queue.
10. The method according to claim 3, characterized in that Also includes: Monitoring the lock time of the distributed global lock; If the lock time exceeds the set time threshold, the distributed global lock is released.