Multi-store inventory management method and system, intelligent terminal and storage medium
By using Redis database and message queues in the multi-store inventory management system and combining the distributed locking mechanism, the problem of inventory record errors in multiple store scenarios is solved, and inventory accuracy and consistency are achieved.
Patent Information
- Application Number
- CN202510525441.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2045-04-25
AI Technical Summary
In multi-store scenarios, when a large number of purchase requests are received in a short period of time, the remaining inventory quantity record of the store may be incorrect, resulting in a decrease in inventory accuracy and consistency.
The inventory quantity is adjusted by using the Redis database and the message queue, and the distributed locking mechanism of the Redis database is used to lock and release the inventory quantity to ensure that other processing operations will not affect the current operation when processing the inventory quantity, and ensure the accuracy and consistency of the inventory.
Through the coordinated work of Redis database and message queue, the inventory quantity in the main database can be changed in an orderly manner. Each inventory update task can be accurately executed by the main database to ensure the accuracy and consistency of inventory.
Smart Images

Figure CN120069762A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data management, and in particular to a multi-store inventory management method, system, intelligent terminal and storage medium. Background Art
[0002] In recent years, with the digitalization of retail and the diversification of consumption scenarios, the multi-store business model has become the mainstream choice for brand expansion. How to manage commodity inventory in a multi-store scenario has become an issue that cannot be ignored.
[0003] When managing the inventory of multiple stores in related technologies, it is necessary to pre-statistically calculate the maximum inventory of each store and record the remaining inventory of the store in real time. After receiving a purchase request from a customer, determine the types and quantities of products purchased by the customer according to the purchase request. Adjust the inventory quantity of the store according to the types and quantities of products.
[0004] Regarding the above related technologies, when a large number of purchase requests are received in a short period of time, errors may occur in recording the remaining inventory quantity of the store, resulting in a decrease in the accuracy and consistency of the inventory. Summary of the Invention
[0005] In order to improve the accuracy and consistency of the inventory, the present application provides a multi-store inventory management method, system, intelligent terminal and storage medium.
[0006] In a first aspect, the present application provides a multi-store inventory management method, adopting the following technical solution: A multi-store inventory management method includes: In response to obtaining a user purchase request sent by a user terminal, obtain the product information in the user purchase request, where the product information includes product types and quantities; Obtain the tradable inventory quantity corresponding to the product type; When the quantity of the product does not exceed the tradable inventory quantity, update the inventory quantity in the main database through a Redis database and a message queue to obtain an updated inventory quantity, and the Redis cluster is used to adjust the inventory quantity through a distributed lock mechanism; Send the updated inventory quantity to the user terminal.
[0007] By adopting the above technical solution, the Redis database and the message queue are used to adjust the inventory quantity. During the adjustment process, the distributed lock mechanism of the Redis database can be used to lock and release the inventory quantity, so that other processing operations will not affect the current operation of the inventory quantity when processing the inventory quantity, ensuring the accuracy and consistency of the inventory.
[0008] Optionally, cache the commodity information in the Redis cluster; Generate an inventory update task corresponding to the user purchase request; Send the inventory update task to the main database through the message queue, and the message queue is used to synchronize the inventory update task to the main database; After the main database completes the inventory update task, receive the updated inventory quantity returned by the main database.
[0009] By adopting the above technical solution, through the collaborative work of the Redis cluster and the message queue, the inventory quantity in the main database can change orderly. Each inventory update task can be accurately executed by the main database, ensuring the accuracy and consistency of the inventory.
[0010] Optionally, in the case where there are at least two user purchase requests, classify the user purchase requests according to the commodity type to obtain a user purchase request combination; According to the commodity quantity, count the total number of purchased commodities in the user purchase request combination; According to the total number of purchased commodities and the commodity type, obtain the inventory update task.
[0011] By adopting the above technical solution, when receiving multiple user purchase requests, the total number of purchased commodities and the commodity type will be counted to obtain an inventory update task, and the data in the main database will be updated through the inventory update task, ensuring the accuracy and consistency of the inventory.
[0012] Optionally, obtain the total inventory quantity corresponding to the commodity type; According to the total inventory quantity, retrieve the tradable inventory quantity in the preset quantity mapping table; Send the tradable inventory quantity to the user terminal.
[0013] By adopting the above technical solution, the tradable inventory quantity can be adjusted according to the total inventory quantity, ensuring that the sold commodities do not exceed the inventory, and providing the tradable inventory quantity to the user in real time, taking into account both the user experience and system stability.
[0014] Optionally, obtain the first geographical information of the user terminal according to the user purchase request; Determine the target store according to the user purchase request, where the target store is the store selling the commodity type; Send commodity quantity query information to the store terminal corresponding to the target store; Receive the inventory quantity feedback information returned by the store terminal; Determine candidate pick-up store terminals in the store terminal according to the inventory quantity feedback information; Obtain the second geographical information of the candidate store terminals; Based on the first geographical location and the second geographical location, determine the target pick-up store terminal among the candidate pick-up store terminals.
[0015] By adopting the above technical solution, the target pick-up store terminal for the user to pick up the goods can be determined by using the first geographical information of the user terminal and the second geographical information of the candidate store terminals, which can not only ensure that the user can get the goods, but also ensure the convenience of the customer to pick up the goods.
[0016] Optionally, if the candidate store terminals are not determined, obtain the third geographical information of the store terminal; According to the first geographical information and the third geographical information, determine candidate goods-collecting store terminals, and obtain the current inventory quantity of goods of the candidate goods-collecting terminals; Calculate the difference in the quantity of goods according to the current inventory quantity of goods and the user purchase request; According to the geographical information of the candidate goods-collecting store terminals, search for nearby store terminals located near the candidate goods-collecting store terminals; According to the difference in the quantity of goods, the inventory of goods in the nearby store terminals, and the goods sales prediction plan, obtain the target nearby store terminals and the corresponding transferred inventory quantity for the target nearby store terminals; Update the main database according to the transferred inventory quantity.
[0017] By adopting the above technical solution, after determining the nearby store terminals located near the candidate goods-collecting store terminals, use the inventory of goods in the nearby store terminals and the goods sales prediction plan to plan the transfer of the inventory of goods, so that the inventory of goods in the candidate goods-collecting store terminals can meet the needs of customers and ensure the transfer efficiency of the goods.
[0018] Optionally, store the inventory quantity feedback information in an inventory message queue; Extract the previous inventory quantity record from the inventory message queue; Calculate the difference in the inventory quantity between the inventory quantity feedback information and the inventory quantity record; In the case where the difference in the inventory quantity is greater than the preset difference, insert the inventory update task corresponding to the user purchase request into the message queue according to the difference in the inventory quantity.
[0019] By adopting the above technical solution, the user purchase requests in the message queue are adjusted according to the difference in the change of inventory quantity, ensuring that the user purchase requests with the difference in the change of inventory quantity greater than the preset difference can be responded to more quickly.
[0020] In a second aspect, the present application provides a multi-store inventory management system, adopting the following technical solution: A multi-store inventory management system includes: An acquisition module for acquiring user purchase requests and tradable inventory quantities; A memory for storing the program of the multi-store inventory management method; A processor, and the program in the memory can be loaded and executed by the processor to implement the multi-store inventory management method.
[0021] By adopting the above technical solution, the inventory quantity is adjusted using the Redis database and the message queue. During the adjustment process, the distributed lock mechanism of the Redis database can be used to lock and release the inventory quantity, ensuring that other processing operations will not affect the current operation on the inventory quantity when processing the inventory quantity, and guaranteeing the accuracy and consistency of the inventory.
[0022] In a third aspect, the present application provides an intelligent terminal, adopting the following technical solution: An intelligent terminal includes: a memory and a processor, and a computer program capable of being loaded and executed by the processor to implement any one of the above methods is stored on the memory.
[0023] By adopting the above technical solution, the inventory quantity is adjusted using the Redis database and the message queue. During the adjustment process, the distributed lock mechanism of the Redis database can be used to lock and release the inventory quantity, ensuring that other processing operations will not affect the current operation on the inventory quantity when processing the inventory quantity, and guaranteeing the accuracy and consistency of the inventory.
[0024] In a fourth aspect, the present application provides a computer storage medium, which can store the corresponding program and has the characteristics of being convenient for realizing the improvement of the accuracy and consistency of the inventory, adopting the following technical solution: A computer-readable storage medium stores a computer program capable of being loaded and executed by the processor to implement any one of the above multi-store inventory management methods.
[0025] By adopting the above technical solution, the inventory quantity is adjusted using the Redis database and the message queue. During the adjustment process, the distributed lock mechanism of the Redis database can be used to lock and release the inventory quantity, ensuring that other processing operations will not affect the current operation on the inventory quantity when processing the inventory quantity, and guaranteeing the accuracy and consistency of the inventory.
[0026] In summary, the present application includes at least one of the following beneficial technical effects: 1. Adjust the inventory quantity using the Redis database and message queue. During the adjustment process, the distributed lock mechanism of the Redis database can be used to lock and release the inventory quantity, ensuring that other processing operations will not affect the current operation on the inventory quantity when processing the inventory quantity, and guaranteeing the accuracy and consistency of the inventory; 2. Utilize the collaborative work of the Redis cluster and message queue to enable the inventory quantity in the main database to change orderly. Each inventory update task can be accurately executed by the main database, ensuring the accuracy and consistency of the inventory; 3. When receiving multiple user purchase requests, count the total number of purchased goods and the types of the goods to obtain an inventory update task, and update the data in the main database through the inventory update task, ensuring the accuracy and consistency of the inventory. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 is a schematic diagram of the system architecture of a multi-store inventory management method provided by an embodiment of the present application.
[0028] Figure 2 is a schematic diagram of a multi-store inventory management method provided by an embodiment of the present application.
[0029] Figure 3 is a schematic flow diagram of a multi-store inventory management method provided by an embodiment of the present application.
[0030] Figure 4 is a schematic flow diagram of a method for adjusting inventory quantity provided by an embodiment of the present application.
[0031] Figure 5 is a schematic flow diagram of a method for displaying tradable inventory quantity provided by an embodiment of the present application.
[0032] Figure 6 is a schematic flow diagram of a method for determining a pick-up store provided by an embodiment of the present application.
[0033] Figure 7 is a schematic flow diagram of a method for updating the main database provided by an embodiment of the present application.
[0034] Figure 8 is a schematic flow diagram of a method for cutting in a user purchase request provided by an embodiment of the present application.
[0035] Figure 9 is a schematic diagram of a multi-store inventory management system provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0036] In order to make the objectives, technical solutions and advantages of this application more clear and understandable, the following further elaborates on this application in conjunction with the appended Figure 1 to the appended Figure 9 and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit this application.
[0037] The embodiment of this application discloses a schematic diagram of the system architecture of a multi-store inventory management method. Referring to Figure 1 , the system architecture includes: a data layer 11, a service layer 12, an application layer 13, and a user layer 14.
[0038] The data layer 11 includes a main database 111 and a Redis cluster 112. Among them, the main database 111 is used to store the inventory data of each store. The inventory data includes the types of goods, the quantity of goods in stock, and the inventory in sub-warehouses. Optionally, the main database 111 uses MySQL. The Redis cluster 112 is used to provide a distributed lock mechanism, enabling the Redis cluster 112 to have the ability to handle high-concurrency requests.
[0039] The service layer 12 includes an inventory synchronization service 23121 and an order verification service 122. Among them, the inventory synchronization service 23121 is used to achieve the consistency between the main database 111 and the Redis cluster 112 through a message queue 22. The order verification service 122 is used to verify whether the quantity of tradable inventory corresponding to the user purchase request 21 meets the requirements. Optionally, the message queue 22 uses RabbitMQ.
[0040] The application layer 13 includes a front-end interface 131 and a management background 132. Among them, the front-end interface 131 is an inventory query and order placement interface for users. The front-end interface 131 includes an application (APP) interface and a web (Web) interface. Optionally, the front-end interface 131 is integrated with a dynamic inventory threshold limit function, that is, the front-end interface 131 can dynamically adjust the quantity of tradable inventory according to the total inventory quantity. The management background 132 is used to adjust inventory allocation, set inventory thresholds, and monitor exception logs.
[0041] The user layer 14 includes a consumer side 141 and a store side 142. Among them, the consumer side 141 refers to the mobile terminal used by consumers. The store side 142 refers to the terminal devices of merchant stores. Exemplarily, the consumer side 141 allows consumers to view the inventory status of goods in real time. Exemplarily, the store side 142 includes POS machines, tablet devices, etc. set by merchant stores.
[0042] Further, referring to Figure 2, after obtaining the user purchase request 21 provided by this application, the multi-store inventory management method will send the user purchase request 21 to the application layer 13, and send the user purchase request 21 to the service layer 12 through the front-end interface 131 and the management background 132 in the application layer 13. The order verification service 122 in the service layer 12 will determine whether the user purchase request 21 can be executed. If so, an inventory update task will be generated according to the user purchase request 21 and sent to the message queue 22. Then, through the inventory synchronization service 23121 in the service layer 12, the inventory update task will be sent to the main database 111 and the Redis cluster 112 of the data layer 11 to update the inventory data. During the process of updating the inventory data, operations of inventory locking and inventory release will be performed through the Redis cluster 112 to ensure the accuracy and consistency of the inventory data during the update process of the inventory data.
[0043] An embodiment of this application discloses a multi-store inventory management method. Refer to Figure 3 , this method includes: Step S301: In response to obtaining a user purchase request sent by a user terminal, obtain the product information in the user purchase request, where the product information includes the product type and the quantity of the product.
[0044] The user terminal refers to the terminal held by the consumer, and the user terminal includes any one or more of a mobile terminal, a desktop computer, and a laptop computer.
[0045] The user purchase request is obtained based on the user's purchase behavior. For example, if the user purchases 1 piece of product A on the application program of the mobile phone, the user purchase request is for the behavior of the user purchasing 1 piece of product A.
[0046] In some other embodiments, the user purchase request can also be sent by a store terminal, and in this case, the user purchase request is sent by the store terminal once every preset duration. For example, the store terminal counts the sold product information in the past 10 minutes every 10 minutes and integrates the foregoing sold product information into the user purchase request.
[0047] Step S302: Obtain the tradable inventory quantity corresponding to the product type.
[0048] The tradable inventory quantity refers to the quantity of products available for trading in the inventory corresponding to the product type.
[0049] Exemplarily, the inventory data of each store is stored in the main database, and the tradable inventory quantity corresponding to the product type can be obtained through the main database.
[0050] In some embodiments, the tradable inventory quantity is determined based on the total inventory quantity of the commodity type, and the tradable inventory quantity is positively correlated with the total inventory quantity. For example, when the total inventory quantity is 2000, the tradable inventory quantity is 1500; when the total inventory quantity is 3000, the tradable inventory quantity is 2500.
[0051] Step S303: When the commodity quantity is not greater than the tradable inventory quantity, update the inventory quantity in the main database through the Redis database and the message queue to obtain the updated inventory quantity. The Redis cluster is used to adjust the inventory quantity through the distributed lock mechanism.
[0052] An embodiment of the present application discloses a method for adjusting the inventory quantity. Refer to Figure 4 , this method includes steps S3031 to S3034, and the specific content is as follows: Step S3031: Generate an inventory update task corresponding to the user purchase request.
[0053] The inventory update task is used to adjust the inventory quantity in the total database.
[0054] Optionally, when there are at least two user purchase requests, classify the user purchase requests according to the commodity type to obtain a user purchase request combination. According to the commodity quantity, count the total number of purchased commodities in the user purchase request combination. According to the total number of purchased commodities and the commodity type, obtain the inventory update task.
[0055] The user purchase request combination is used to record the quantity of the commodity type. Optionally, the classification of the user purchase requests is performed in real time or at intervals of a preset classification duration. For example, for one or more obtained user purchase requests, count and summarize the commodity types in each user purchase request to obtain the user purchase request combination.
[0056] Further, after obtaining the user purchase request combination, determine the commodity quantity of each commodity type in the user purchase request combination to obtain the total number of purchased commodities.
[0057] Further, combine the total number of purchased commodities and the commodity type to obtain the inventory update task.
[0058] Step S3032: Send the inventory update task to the main database through the message queue. The message queue is used to synchronize the inventory update task to the main database.
[0059] A message queue is an asynchronous communication mechanism used to transfer data between distributed systems or services. Exemplarily, an inventory update task is added to the message queue, and the inventory update queue in the message queue is arranged according to the time it enters the message queue. Then, the inventory update tasks in the message queue are sent to the main database in the arranged order. Optionally, the message queue adopts a first-in, first-out manner.
[0060] Step S3033: Cache the inventory update task in the Redis cluster.
[0061] The Redis cluster has a distributed lock mechanism. Among them, the distributed lock mechanism is a key mechanism for coordinating the mutually exclusive access of multiple nodes to shared resources in a distributed system. The distributed lock mechanism can only allow a single inventory update task to lock or unlock the main database at the same time.
[0062] Optionally, after caching the inventory update task in the Redis cluster, the Redis cluster locks the data modification operation of the main database, only allowing the current inventory update task to modify the main database, and unlocks the main database after the main database completes the update.
[0063] Step S3034: After the main database completes the inventory update task, receive the updated inventory quantity returned by the main database.
[0064] Optionally, after the main database completes the inventory update task, the main database generates a task completion identifier, which is used to indicate that the main database has completed the inventory update task. Based on the task completion identifier, the main database is unlocked based on the distributed lock mechanism of the Redis cluster.
[0065] Furthermore, the inventory update task corresponds one-to-one with the task completion identifier. In some scenarios, timestamps can be added to the inventory update task and the task completion identifier, and the timestamp is set based on the moment of the user's purchase request. If the timestamps on the inventory update task and the task completion identifier are the same, there is a corresponding relationship between the inventory update task and the task completion identifier.
[0066] Step S304: Send the updated inventory quantity to the user terminal.
[0067] Optionally, after the user terminal receives the updated inventory quantity, the user terminal displays the updated inventory quantity.
[0068] In other embodiments, according to the relationship between the updated inventory quantity and a preset quantity display threshold, which is a preset empirical value that technicians can adjust according to actual needs, the display method of the updated inventory quantity is adjusted. Exemplarily, assuming the quantity display threshold is 50, when the updated inventory quantity is greater than 50, the user terminal displays the updated inventory quantity in green; when the updated inventory quantity is less than 50, the user terminal displays the updated inventory quantity in red.
[0069] By adopting the above technical solution, the Redis database and the message queue are used to adjust the inventory quantity. During the adjustment process, the distributed lock mechanism of the Redis database can be used to lock and release the inventory quantity, ensuring that other processing operations will not affect the current operation on the inventory quantity when processing the inventory quantity, and guaranteeing the accuracy and consistency of the inventory.
[0070] In the following embodiments, to prevent over-selling of goods in a short period of time, it is necessary to limit the tradable inventory quantity to ensure that it does not exceed the total inventory quantity. Therefore, an embodiment of the present application discloses a method for displaying the tradable inventory quantity. Referring to Figure 5 , the method includes: Step S501: Obtain the total inventory quantity corresponding to the commodity type.
[0071] The total inventory quantity refers to the sum of the commodity inventories of all stores.
[0072] In some embodiments, an inventory query notification is sent to each store terminal. The current inventory information returned by each store terminal is received, and the current inventory information records the inventory quantity of the commodity in the store at the current moment. The sum of the commodity inventories is obtained by statistically analyzing the current inventory information.
[0073] Step S502: Retrieve the tradable inventory quantity according to the total inventory quantity in a preset quantity mapping table.
[0074] The preset quantity mapping table records the corresponding relationship between the total inventory quantity and the tradable inventory quantity, where the total inventory quantity is greater than the tradable inventory quantity.
[0075] The quantity mapping table can be set by technicians according to requirements.
[0076] In some other embodiments, in response to an input operation of the tradable inventory quantity, the tradable inventory quantity is obtained. Therefore, technicians can set the tradable inventory quantity by themselves, and it is ensured that technicians can modify the tradable inventory quantity in real time.
[0077] Step S503: Send the tradable inventory quantity to the user terminal.
[0078] Further, according to the relationship between the tradable inventory quantity and a preset quantity display threshold, adjust the display mode of the updated inventory quantity.
[0079] By adopting the above technical solution, the tradable inventory quantity can be adjusted according to the total inventory quantity, ensuring that the sold goods do not exceed the inventory quantity, and providing the tradable inventory quantity to the user in real time, taking into account both the user experience and system stability.
[0080] In some actual scenarios, customers will purchase goods online and choose to pick up the goods at an offline store. At this time, it is necessary to plan which store the user should pick up the goods at. Therefore, the embodiments of the present application disclose a method for determining a pick-up store. Refer to Figure 6 , the method includes: Step S601: Obtain the first geographical information of the user terminal according to the user purchase request.
[0081] The first geographical information refers to the geographical location corresponding to the user terminal.
[0082] Optionally, when the user terminal generates a user purchase request, the user terminal records its own geographical location. Generate the first geographical information based on the geographical location. Add the first geographical information to the user purchase request.
[0083] Optionally, when the user terminal generates a user purchase request, obtain a preset geographical location. Generate the first geographical information based on the geographical location. Add the first geographical information to the user purchase request. Among them, the preset geographical location can be the preset delivery address in the shopping APP, or the preset geographical location is the home address or work address pre-stored in the user terminal.
[0084] Step S602: Determine the target store according to the user purchase request, where the target store is the store that sells the types of goods.
[0085] Exemplarily, read the types of goods in the user purchase request. Retrieve the candidate target stores that have the types of goods in the main database according to the types of goods, and obtain the inventory quantity of the types of goods in the candidate target stores. Select the stores with an inventory quantity greater than 0 in the candidate target stores as the target stores.
[0086] Step S603: Send a commodity quantity query message to the store terminal corresponding to the target store.
[0087] In an actual scenario, there may be a difference between the data stored in the total database and the actual situation of the offline store. This is because most of the store terminals of the offline store report their inventory data at regular intervals instead of in real time. For example, the store terminal reports the inventory data every 5 minutes. Therefore, to ensure the validity of the data, the inventory data can be obtained in real time once.
[0088] The product quantity query information is used to query the inventory data of the store at the current moment. Further, the product quantity query information at least includes the product types in the user purchase request.
[0089] Step S604: Receive the inventory quantity feedback information returned by the store terminal.
[0090] The inventory quantity feedback information includes the inventory data corresponding to the product types in the store corresponding to the store terminal at the current moment.
[0091] In some embodiments, after the store terminal sends the inventory quantity feedback information, if it detects that the inventory corresponding to the product type has changed within the preset processing duration, it generates inventory quantity update information according to the inventory change and sends the inventory quantity update information to the server.
[0092] Step S605: Determine the candidate pick-up store terminal in the store terminal according to the inventory quantity feedback information.
[0093] Exemplarily, according to the inventory quantity feedback information, determine the store terminal whose inventory data corresponding to the product type is greater than the product quantity to obtain the candidate pick-up store terminal.
[0094] Step S606: Obtain the second geographical information of the candidate store terminal.
[0095] The second geographical information refers to the geographical location of the store corresponding to the candidate store terminal. In some embodiments, the server pre-stores the geographical information of each store terminal, and selects the geographical information of the candidate store terminal therefrom to obtain the second geographical information.
[0096] In some embodiments, send a geographical information request to the candidate store terminal. After receiving the geographical information request, the store terminal generates the second geographical information and sends the second geographical information to the server.
[0097] Step S607: Determine the target pick-up store terminal among the candidate pick-up store terminals based on the first geographical location and the second geographical location.
[0098] Exemplarily, calculate the spatial distance between the first geographical location and the second geographical location. Select the store terminal at the second geographical location corresponding to the minimum value of the spatial distance as the target pick-up store terminal.
[0099] Further, generate pick-up information based on the target pick-up store terminal. The pick-up information includes at least one of the geographical location, name, and business hours of the store corresponding to the target pick-up store terminal.
[0100] By adopting the above technical solution, the target pick-up store terminal for the user to pick up the goods can be determined by using the first geographical information of the user terminal and the second geographical information of the candidate store terminal, which can not only ensure that the user can get the goods, but also ensure the convenience of the customer to pick up the goods.
[0101] In the following embodiments, when a suitable candidate store terminal cannot be found for the goods that the customer wants to purchase, it is necessary to transport the goods from other stores or warehouses to a certain store so that this store can provide the goods that the customer wants. Therefore, an embodiment of the present application discloses a method for updating the main database. Refer to Figure 7 , the method includes: Step S701: If the candidate store terminal is not determined, obtain the third geographical information of the store terminal.
[0102] The third geographical information includes the geographical information of all store terminals. In some embodiments, the server pre-stores the geographical information of each store terminal, and selects the geographical information of all store terminals from it to obtain the third geographical information.
[0103] Step S702: Determine the candidate goods-gathering store terminal according to the first geographical information and the third geographical information, and obtain the current inventory quantity of goods of the candidate goods-gathering terminal.
[0104] Exemplarily, according to the first geographical information and the third geographical information, calculate the spatial distance between the first geographical information and the third geographical information. Take the store terminal corresponding to the minimum value among the foregoing spatial distances as the candidate goods-gathering store terminal. Among them, the distance threshold is an empirical value, and those skilled in the art can adjust the specific value of the distance threshold according to actual needs.
[0105] The current inventory quantity of goods refers to the inventory quantity of the candidate goods-gathering store terminal at the current moment.
[0106] Step S703: Calculate the difference in the quantity of goods according to the current inventory quantity of goods and the user's purchase request.
[0107] Optionally, calculate the difference between the current inventory quantity of goods and the quantity of goods in the user's purchase request to obtain the difference in the quantity of goods. The difference in the quantity of goods refers to the difference between the inventory quantity of the store corresponding to the candidate goods-gathering store terminal and the quantity of goods in the user's purchase request, that is, how much more is needed for the store corresponding to the candidate goods-gathering store terminal to meet the customer's needs.
[0108] Step S704: According to the geographical information of the candidate goods-gathering store terminal, find the nearby store terminal located near the candidate goods-gathering store terminal.
[0109] The distance between the store corresponding to the nearby store terminal and the store corresponding to the candidate goods-gathering store terminal is less than a preset distance, where the preset distance is an empirical value and relevant personnel can adjust the value of the preset distance according to actual needs. For example, the preset distance is set to 2 kilometers.
[0110] Step S705: Obtain the target nearby store terminal and the transferred inventory quantity corresponding to the target nearby store terminal according to the difference in the quantity of goods, the inventory of goods in the nearby store terminal, and the goods sales prediction plan.
[0111] Based on the difference between the inventory of goods in the nearby store terminal and the goods sales prediction plan, obtain the salable inventory of goods in the nearby store terminal. Statistically sum up the salable inventory of goods in the nearby store terminals to obtain the total nearby goods inventory. If the total nearby goods inventory is greater than the difference in the quantity of goods, sort the nearby store terminals in ascending order according to the distance between the nearby store terminals and the candidate goods-gathering store terminal to obtain a sequence of nearby store terminals. Sequentially select nearby store terminals from the sequence of nearby store terminals in order, and calculate the sum of the salable inventory of goods in the selected nearby store terminals until the sum of the salable inventory of goods is greater than the difference in the quantity of goods, obtain the target nearby store terminal at this time, and use the inventory of goods selected from the salable inventory of goods in the target nearby store terminal as the transferred inventory quantity.
[0112] Step S706: Update the main database according to the transferred inventory quantity.
[0113] Exemplarily, adjust the quantity of goods corresponding to the type of goods in the user purchase request in the main database according to the transferred inventory quantity.
[0114] By adopting the above technical solution, after determining the nearby store terminal located near the candidate goods-gathering store terminal, using the inventory of goods in the nearby store terminal and the goods sales prediction plan to make a plan for the transfer of goods inventory, so that the goods inventory of the candidate goods-gathering store terminal can meet the needs of customers and also ensure the transfer efficiency of goods.
[0115] In the following embodiments, when it is detected that a user purchases goods, the queuing order can be adjusted according to the quantity of goods purchased by the user, so as to ensure that customers who purchase a large quantity of goods can successfully purchase the goods. Therefore, the embodiments of the present application disclose a method for jumping the queue of user purchase requests. Refer to Figure 8 , the method includes: Step S801: Store the inventory quantity feedback information into the inventory message queue.
[0116] The inventory message queue is used to store the inventory quantity feedback information of the store terminals. Further, before storing the inventory quantity feedback information into the inventory message queue, a timestamp can also be added to the inventory quantity feedback information, and the timestamp is set according to the generation time of the user purchase request.
[0117] Step S802: Extract the previous inventory quantity record from the inventory message queue.
[0118] The previous inventory quantity record refers to the inventory quantity record that is closest to the current moment in the inventory message queue, and the product type corresponding to the previous inventory quantity record is the same as the product type in the user purchase request.
[0119] Step S803: Calculate the difference in inventory quantity changes between the inventory quantity feedback information and the inventory quantity record.
[0120] Exemplarily, calculate the difference between the inventory quantity feedback information and the previous inventory quantity record to obtain the difference in inventory quantity changes.
[0121] Step S804: When the difference in inventory quantity changes is greater than the preset difference, insert the inventory update task corresponding to the user purchase request into the message queue according to the difference in inventory quantity changes.
[0122] The preset difference is a preset empirical value, and technicians can adjust the specific value of the preset difference according to actual needs.
[0123] When the difference in inventory quantity changes is greater than the preset difference, look up the message queue position corresponding to the difference in inventory quantity changes from the preset position mapping table. According to the message queue position, insert the inventory update task corresponding to the user purchase request into the message queue.
[0124] By adopting the above technical solution, the user purchase request is adjusted in the message queue according to the difference in inventory quantity changes, ensuring that the user purchase requests with the difference in inventory quantity changes greater than the preset difference can obtain faster responses.
[0125] Based on the same inventive concept, an embodiment of the present application provides a multi-store inventory management system. Please refer to Figure 9 , and this system includes: An acquisition module 901, configured to acquire a user purchase request and the tradable inventory quantity; A memory 902, configured to store the program of the multi-store inventory management method; A processor 903, and the program in the memory can be loaded and executed by the processor to implement the multi-store inventory management method.
[0126] By adopting the above technical solution, the Redis database and the message queue are used to adjust the inventory quantity. During the adjustment process, the distributed lock mechanism of the Redis database can be used to lock and release the inventory quantity, so that other processing operations will not affect the current operation on the inventory quantity when processing the inventory quantity, ensuring the accuracy and consistency of the inventory.
[0127] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0128] The embodiment of the present application provides a computer-readable storage medium storing a computer program that can be loaded and executed by a processor to implement the multi-store inventory management method.
[0129] Computer storage media include, for example: cloud servers, USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs, etc., all kinds of media that can store program codes. For example, the cloud server in the embodiment of the present application can be Tencent Cloud or Alibaba Cloud.
[0130] Based on the same inventive concept, the embodiment of the present application provides an intelligent terminal, including a memory and a processor, and a computer program that can be loaded and executed by the processor to implement the multi-store inventory management method is stored on the memory.
[0131] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein.
[0132] The above are all the preferred embodiments of the present application. Without restricting the protection scope of the present application based on this, any feature disclosed in this specification (including the abstract and drawings), unless specifically described, can be replaced by other equivalent or similar-purpose alternative features. That is, unless specifically described, each feature is only an example in a series of equivalent or similar features.
Claims
1. A multi-store inventory management method, characterized in that: The method comprises: In response to obtaining a user purchase request sent by a user terminal, obtaining commodity information in the user purchase request, the commodity information including commodity type and commodity quantity; Obtain the tradable inventory quantity corresponding to the commodity type; When the quantity of the commodity is not greater than the tradable inventory quantity, the inventory quantity in the main database is updated through the Redis database and the message queue to obtain the updated inventory quantity, and the Redis cluster is used to adjust the inventory quantity through a distributed lock mechanism; The updated inventory quantity is sent to the user terminal.
2. The multi-store inventory management method according to claim 1, characterized in that: The method of updating the inventory quantity in the main database through the Redis database and the message queue to obtain the updated inventory quantity includes: generating an inventory update task corresponding to the user purchase request; Sending the inventory update task to a master database via the message queue, wherein the message queue is used to synchronize the inventory update task with the master database; Cache the inventory update task in the Redis cluster; After the main database completes the inventory update task, the updated inventory quantity returned by the main database is received.
3. The multi-store inventory management method according to claim 2, characterized in that: The generating of the inventory update task corresponding to the user purchase request comprises: In the case that there are at least two user purchase requests, classifying the user purchase requests according to the commodity type to obtain a user purchase request combination; According to the quantity of the commodities, counting the total number of purchased commodities in the purchase request combination of the user; The inventory update task is obtained according to the total number of purchased commodities and the commodity type.
4. The multi-store inventory management method according to claim 1, characterized in that: The method further comprises: Get the total inventory quantity corresponding to the product type; According to the total inventory quantity, the tradable inventory quantity is retrieved from a preset quantity mapping table; The tradable inventory quantity is sent to the user terminal.
5. The multi-store inventory management method according to claim 2, characterized in that: The method further comprises: Acquiring first geographic information of the user terminal according to the user purchase request; Determine a target store according to the user's purchase request, where the target store refers to a store that sells the product category; Sending commodity quantity query information to the store terminal corresponding to the target store; Receiving inventory quantity feedback information returned by the store terminal; Determine a candidate pickup store terminal from among the store terminals according to the inventory quantity feedback information; Acquire second geographic information of the candidate store terminal; Based on the first geographical location and the second geographical location, a target pickup store terminal is determined from among the candidate pickup store terminals.
6. The multi-store inventory management method according to claim 5, characterized in that: The method comprises: If the candidate store terminal is not determined, obtaining third geographic information of the store terminal; Determine a candidate collection store terminal according to the first geographic information and the third geographic information, and obtain the current inventory quantity of the candidate collection terminal; Calculate the difference in the quantity of goods according to the current quantity of goods in stock and the purchase request of the user; According to the geographic information of the candidate collection store terminal, searching for a nearby store terminal located near the candidate collection store terminal; Obtaining a target nearby store terminal and a transfer inventory quantity corresponding to the target nearby store terminal according to the commodity quantity difference, the commodity inventory of the nearby store terminal and a commodity sales forecast plan; The master database is updated according to the transferred inventory quantity.
7. The multi-store inventory management method according to claim 5, characterized in that: The receiving of inventory quantity feedback information returned by the store terminal also includes: Storing the inventory quantity feedback information in an inventory message queue; Extract the last inventory quantity record from the inventory message queue; Calculating the inventory quantity change difference between the inventory quantity feedback information and the inventory quantity record; When the inventory quantity change difference is greater than a preset difference, the inventory update task corresponding to the user purchase request is inserted into the message queue according to the inventory quantity change difference.
8. A multi-store inventory management system, characterized in that: The system is used to execute the multi-store inventory management method according to any one of claims 1 to 7, and the system comprises: The acquisition module is used to obtain user purchase requests and the quantity of tradable inventory; A memory, used to store a program of the multi-store inventory management method; The program in the memory can be loaded and executed by the processor to implement the multi-store inventory management method.
9. An intelligent terminal, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and execute the multi-store inventory management method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The device stores a computer program which can be loaded by a processor and execute the multi-store inventory management method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and system for realizing inventory management and storage medium
CN112990823A
Commodity inventory data processing method and device, electronic equipment and medium
CN114202284A
Article inventory updating method and device, storage medium and electronic equipment
CN118195479A
Target inventory determination based on hosted merchants presence
US8732040B1
Order processing method and system based on handheld terminals, computer device, and medium
WO2023245892A1
Cited By
Transaction information announcement method and device, electronic equipment and medium
CN120912287A