Solutions for e-commerce inventory deduction

 

table of Contents

Order to lock inventory    

Payment minus inventory

Adopt virtual inventory and actual inventory, redis+mysql (recommended)

Why withholding?

How to detect inconsistent inventory?


The problem of inventory deduction is very common in e-commerce. So what are the solutions and their respective advantages and disadvantages? There are several ways to summarize

Order to lock inventory    

   Advantages: It can solve the problem of inventory deduction, and there will be no oversold problems

    Disadvantages: Poor experience. If you only place an order without payment, the inventory is locked, so that users who are willing to buy cannot place an order, which has a great impact on the sales business;

 

Payment minus inventory

Advantages: Prevent malicious buyers from running out of inventory when placing a large number of orders, and avoid the shortcomings of order reduction

Disadvantages: You need to actively call the operation of deducting inventory when making payment

The inventory number displayed on the order page may not be the latest inventory number, but more than the actual inventory. After the inventory number is used up, the inventory number on the order page is not refreshed, and the number of orders exceeds the inventory number; if the number of orders is paid If the inventory is exceeded, payment failure will occur. Or oversold phenomenon

 

Adopt virtual inventory and actual inventory, redis+mysql (recommended)

The use of virtual sales inventory and actual inventory can not only increase sales of in-transit inventory and scheduled goods, but also ensure effective management of warehouse commodity inventory.

A. Unpaid orders are given 20-40 minutes of waiting time for payment. Unpaid orders will automatically release virtual sales inventory to minimize inventory occupation and avoid affecting sales.

B. The virtual sales inventory is deducted by placing an order. At the same time, the marketing staff and the product department can increase the virtual sales inventory in advance according to the arrival of the goods and the production situation, so that sales can be realized in advance.

C. Commodities are deducted according to the actual delivery of the product by scanning the code, so as to ensure that business data and warehouse operation data can be effectively synchronized and managed, inventory accuracy, and inventory management in a timely manner;

Advantages: deduct redis inventory = lock inventory, but does not affect the actual inventory of mysql, the operation can see the actual inventory for management

Disadvantages: Need to have a synchronization of different inventory

In order to prevent malicious consumption of inventory, limit the amount of orders placed by userid but not paid

 

Why withholding?

If you directly deduct mysql inventory, it’s not easy to manage. I don’t know how much inventory is actually left. Withholding can first deduct redis. If successful, mysql will be deducted. If it is unsuccessful, the inventory will be deducted. Accuracy of data

If redis>mysql, you can place an order, but you can’t get out of the library, and you will have to refund in the future, which is rare.

If redis<mysql, no order can be placed, but there is actual inventory, which will affect sales performance. You can set the inventory synchronization time point, and synchronize when the redis inventory <mysql

Ensure that there will be no problems with the final inventory

 

How to detect inconsistent inventory?

If they are inconsistent, you can check whether you need to synchronize when the redis inventory is 0. Note that the ones that are not yet in stock should be filtered out. You can query the number of unpaid orders based on the product, and the number of remaining stocks = database inventory-unpaid orders

What if an unpaid order is paid when an order is placed when the inventory is returned in an extreme situation? It doesn't matter, because the database inventory and the unpaid number of orders are synchronized -1

 

 

 

Reference: https://my.oschina.net/xiaominmin/blog/3060358

 

 

Guess you like

Origin blog.csdn.net/Goligory/article/details/104935782