来自 Shopee 官方资料快照 ·
- 当前资料结构化阅读页
- 固定快照已留存,可追溯
- 官方原文可核对
资料正文
§1 The calculation logic of the "stock_info_v2" field returned by the "v2.product.get_item_base_info" API
The calculation logic of the "stock_info_v2" field returned by the "v2.product.get_item_base_info" API
- Item stock info before being added to the promotion(s)
("stock_info" section) "normal_stock": 100
("stock_info_v2" section) "total_reserved_stock": 0, "total_available_stock": 100. "seller_stock": 100, "shopee_stock": 0
Then the seller sets the promotion stock to 20, and the promotion status is upcoming. The stock info will be:
("stock_info" section) "normal_stock": 80
("stock_info_v2" section) "total_reserved_stock": 20, "total_available_stock": 80, "seller_stock": 100, "shopee_stock": 0
If the promotion status is upcoming, when a buyer places an order, the stock info will be:
("stock_info" section) "normal_stock": 79
("stock_info_v2" section) "total_reserved_stock": 20, "total_available_stock": 79, "seller_stock": 99, "shopee_stock": 0
If the seller wants to modify the stock to 19 before the promotion starts, the modification will be successful if the change is made to "normal_stock". The stock info will be:
("stock_info" section) "normal_stock": 19
("stock_info_v2" section) "total_reserved_stock": 20, "total_available_stock":19, "seller_stock": 39, "shopee_stock": 0
If the seller wants to modify the stock to 19 before the promotion starts, the modification will fail if the change is made to stock under "seller_stock" because the value of stock under "seller_stock" must be greater or equal to the value of "total_reserved_stock" - "stock under shopee_stock".
If the seller has multiple warehouses, there will be multiple stock under "seller_stock" with different "location_id". It is necessary to ensure that the sum of the value of stock under "seller_stock" with different "location_id" is greater or equal to "total_reserved_stock" - the sum of stock under "shopee_stock" with different "location_id".
- Item stock info before being added to the promotion(s)
("stock_info" section) "normal_stock": 100
("stock_info_v2" section) "total_reserved_stock": 0, "total_available_stock": 100, "seller_stock": 100, "shopee_stock": 0
Then the seller sets the promotion stock to 20, and the promotion status is ongoing. The stock info will be:
("stock_info" section) "normal_stock": 80
("stock_info_v2" section) "total_reserved_stock": 20, "total_available_stock": 20, "seller_stock": 100, "shopee_stock": 0
If the promotion status is ongoing, when a buyer places an order, the stock info will be:
("stock_info" section) "normal_stock": 80
("stock_info_v2" section) "total_reserved_stock": 19, "total_available_stock": 19, "seller_stock": 99, "shopee_stock": 0
If the seller wants to modify the stock to 18 when the promotion is ongoing, the modification will be successful if the change is made to "normal_stock". The stock info will be:
("stock_info" section) "normal_stock": 18
("stock_info_v2" section) "total_reserved_stock": 19, "total_available_stock": 19, "seller_stock": 37, "shopee_stock": 0
If the seller wants to modify the stock to 18 when the promotion is ongoing, the modification will fail if the change is made to stock under "seller_stock" because the value of stock under "seller_stock" must be greater or equal to the value of "total_reserved_stock" - stock under "shopee_stock".
- The seller has both "seller_stock" and "shopee_stock". At this time, the data of the "stock_info" may be inaccurate, and only the "stock_info_v2" can be used.
Before the item added into the promotion, the stock info: "shopee_stock": 300, "seller_stock": 90, "total_available_stock": 390
Then seller sets the promotion stock to 350 and the promotion status is upcoming. The stock info will be:
"total_reserved_stock": 350, "shopee_stock": 300, "seller_stock": 90, "total_available_stock": 300 + 90 - 350 = 40
If the buyer places an order (which consumes 1 stock) while the promotion status is still upcoming, the stock info will be: (because it may consume both "shopee_stock" and "seller_stock", taking "shopee_stock" as an example)
"total_reserved_stock": 350, "shopee_stock": 299, "seller_stock": 90, "total_available_stock" = 299 + 90 - 350 = 39
When the promotion status changes to ongoing, the stock info will be:
"total_reserved_stock": 350, "shopee_stock": 299, "seller_stock": 90, "total_available_stock": 350
Case 1: When the buyer place an order while promotion status is ongoing, and 1 stock is consumed (it may consume both "shopee_stock" and "seller_stock", taking "shopee_stock" as an example)
"total_reserved_stock": 349, "shopee_stock": 298, "seller_stock": 90, "total_available_stock": 349
(The modifiable new field "seller_stock" needs to be greater than or equal to 349 - 298 = 51, because "seller_stock" >= "total_reserved_stock" - "shopee_stock")
Case 2: When the buyer place an order while promotion status is ongoing, the order consumes all "shopee_stock": 299 and consumes 1 of "seller_stock"
"total_reserved_stock": 50, "shopee_stock": 0, "seller_stock" = 90 - 1 = 89, "total_available_stock": 50
(The modifiable new field "seller_stock" needs to be greater than or equal to 50 - 0 = 50, because "seller_stock" >= "total_reserved_stock" - "shopee_stock")
Case 3: When the buyer place an order while promotion status is ongoing, the order consumes all "seller_stock": 90 and consumes 1 of "shopee_stock"
"total_reserved_stock": 259, "shopee_stock": 299 - 1 = 298, "seller_stock": 0, "total_available_stock": 259
(The modifiable new field "seller_stock" needs to be greater than or equal to 259 - 298 = -39, that is, any value greater than 0 is fine, because "seller_stock" >= "total_reserved_stock" - "shopee_stock")
In Summary
- The user uses the old field "normal_stock" and the new field "seller_stock" to modify the stock to the same value, the result will be different because the meaning has changed.
- When the user uses the new field "seller_stock" to modify the stock value, it is necessary to ensure that "seller_stock" >= "total_reserved_stock" - "shopee_stock"
