Loading…

Seize the flash sale quota / cope with high concurrency flash sales and rush sales

This method is suitable for high-concurrency flash sales and rush-buying scenarios, such as a few, dozens, or hundreds of goods in stock, but hundreds of thousands of users may participate in rush-buying at the same time. In this scenario, it is not suitable to directly follow the normal purchase process. High concurrency and instantaneous peaks may cause your application to be very stuck or even inaccessible. The correct approach should be as follows: # Set up the flash sale entrance page separately For such activities, a separate event entry page should be set up, and hundreds of thousands of users should not be directed directly to the application homepage or other unrelated applications. It would be a very good choice to create a static landing advertising page (because this page will be visited by hundreds of thousands of users at the same time); This page introduces event information and product information, and then places a "Buy Now" button. After clicking the button, this interface is called: # Interface description/goods/seckill/grab POST Two parameters:goodsId and seconds Here's how to use the SDK directly: ```javascript WXAPI.goodsSeckillGrab(goodsId, seconds) ``` + goodsId is the product id + seconds is the reservation time of the quota. After this time, the system will recalculate the available quota according to the actual remaining inventory of the product; generally setting it to 60 seconds is more suitable; Return example: ```json { "code": 0, "data": 3, "msg": "success" } ``` ```json { "code": 10000, "data": 0, "msg": "Sold out" } ``` ```json { "code": 20000, "msg": "goodsId is incorrect" } ``` ## Return value description If the code returns 0, it means that the user has grabbed the flash sale quota. At this time, the user will be guided to the real order purchase page to place an order; If the code returns 10000, it means that the quota of users who are placing orders at this time is full. At this time, the user can be prompted to try again later; if some users give up the order midway, or cancel the order after placing the order, or have not paid for a long time, the inventory will be released, and the user will still have the opportunity to get the flash sale quota and enter the ordering interface to place the order.