## Overview
stock_query.php reads SKU-level stock in WDT Enterprise ERP, returning on-hand, available and locked quantities per warehouse and item. It is the key extraction point for unified-inventory setups where WDT is the stock ledger and sellable quantities are written back to each sales channel by shop/platform quota.
### Request essentials
1. Build common parameters per the signing rules; submit business parameters as form fields.
2. Paginate with pageno + pagesize; iterate per warehouse (warehouse_no) so a single warehouse's full scan cannot time out.
3. spec_no pins the query to one SKU — handy for stock-calibration jobs.
4. On status = 0, data.stocks carries warehouse_no, spec_no, goods_no, stock_num (on hand), available_num (available) and lock_num (locked).
### Semantics and pitfalls
- The sellable figure is available_num, not stock_num; also subtract an occupancy buffer for unpaid in-flight orders before pushing to marketplaces.
- Stock is a snapshot; incremental sync needs snapshot diffing or the stock-change companion APIs. Qeasy's "scheduled snapshot + delta push" strategy cuts write volume to sales channels by an order of magnitude.
- In multi-warehouse setups, watch transfer-in-transit to avoid double counting.
### Relationship to stock-sync APIs
stock_query reads stock. A self-owned mall loop also needs the stock-change query (api_goods_stock_change_query.php) and the stock-sync acknowledgment endpoints to carry ERP changes into platform sellable quantities. Define the semantic gap between ERP book stock and platform sellable stock explicitly during solution design — otherwise the first week online will be spent explaining inventory mismatches to the business.