Sp_salsalesorderVirtual.md 1.82 KB

Sp_salsalesorderVirtual (procedure)

订单-虚拟库存明细

  • Type: PROCEDURE
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN sGuids longtext
2 IN sBrId varchar(100)
3 IN sSuId varchar(100)

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpsalsalesorderVirtual'._

Narrative

Business context: 销售管理 → 销售订单 → 订单-虚拟库存明细 — rebuilds the order-side "virtual stock reservation" rows (salsalesproductionordervirtual) for a given set of 销售订单从表 ids. The virtual-stock table is the soft reservation that lets downstream warehouse views show "qty already promised but not yet 送货" against each order line.

What it does: Parses sGuids (comma-separated 从表 ids) into temp table p_t_sId. Deletes existing salsalesproductionordervirtual rows whose sBillSlaveId matches the input set, then re-inserts one row per slave: INSERT INTO salsalesproductionordervirtual (sId, sBrandsId, sSubsidiaryId, iOrder, sMakePerson, sProductId, dProductQty=a.dUseStockQty, sFormId, sBillId, sBillSlaveId, sBillNo, tCreateDate=NOW()) joining salsalesorderslave a + salsalesordermaster b for rows with dUseStockQty>0. Finally deletes any rows where dProductQty<=0.

Invocation: Called by Sp_Calc_sDgd, Sp_Calc_sDgdCL, Sp_Calc_sDgd_1226, Sp_Calc_sDgd_20250612 (the 送货单 audit-time recalculators) and Sp_ProductionOrder_Rransmit — these are the procedures that decide a 销售订单 line's stock-promise has changed and re-seed the virtual table. No direct form binding (the page heading 订单-虚拟库存明细 comes from a report form that queries salsalesproductionordervirtual directly).