E-commerce flash sale activity uses Alipay / WeChat Pay

at present, there is a demand. Alipay or Wechat can be used to pay for second-kill merchandise activities, but the problem is that the demand must be paid before deducting inventory, and placing an order does not reduce inventory. In other words, when Alipay / WeChat Pay informed me that the payment was successful, but there may be a shortage of inventory.
for example, if there is only one item left, user An and user B place an order at the same time (do not reduce inventory, only after successful payment), and then pop up the Alipay / Wechat password interface. When the payment is completed, Alipay / Wechat will inform me that the payment is successful. At this time, there is only one item in stock, but two people have paid, how can we avoid insufficient inventory

I now have two solutions: 1 is to automatically refund, 2 is to subtract inventory when placing an order (beating the product manager), I wonder if you have a better solution

Mar.03,2021

if the payment is successful and then the inventory is reduced, the user will pay successfully, but it will actually be bought by someone else, resulting in insufficient inventory and affecting the user experience. This is definitely not allowed, and this method is not desirable.

I saw a description in other articles, which makes sense (the following is the original description):




0

I think beating the product manager is the best solution.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eaae4b-2016.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eaae4b-2016.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?