Sp_Check_sSodbecome (procedure)
订单变更保存校验
- Type: PROCEDURE
- Deterministic: NO
- SQL data access: CONTAINS SQL
Parameters
| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | sTableName |
varchar(100) |
| 2 | IN | sGuid |
varchar(100) |
| 3 | IN | sFormGuid |
varchar(100) |
| 4 | IN | sLoginId |
varchar(100) |
| 5 | IN | sBrId |
varchar(100) |
| 6 | IN | sSuId |
varchar(100) |
| 7 | IN | iFlag |
int |
| 8 | OUT | sCode |
int |
| 9 | OUT | sReturn |
varchar(4000) |
Body
Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURESpCheck_sSodbecome'._
Narrative
Business context: 订单变更单据 (sales-order change) post-save validator on salsalesorderbecomemaster/salsalesorderbecomeslave. Cross-checks the chosen 变更类型 (iBecome: 0=订单取消, 1=数量变更, 2=数量单价同时变更, 3=单价变更) and 取消子类型 (iCancel: 0/1/2/3/4 — controls cost responsibility) against what has already happened on the original order — purchases, work orders, outsourced ops, deliveries, material applications — and refuses combinations that would orphan downstream documents.
What it does: Reads iBecome/iCancel from salsalesorderbecomemaster. Aborts with sTypeNeedCancel when both are non-zero. For iBecome=0 (order cancel) + iCancel=1 (取消-无成本), counts existing rows in purpurchaseorderdetail, mftworkorderslave, opsoutsideprocessmaster (both 192116810113315234963208090 外购 and 101801153119616594919790770 工序发外 forms), and mitproductionapplymaster joined back via salsalesorderbecomeslave.sOrderSlaveId; any hit triggers sOrderAlreadyPurchased/sOrderHaveWorkOrder/sOrderHaveWg/sOrderHaveFw/sOrderHaveLl. iCancel=2 checks saldelivergoodsslave (sOrderHaveDelivery). iCancel=3 (半成品收费) requires non-zero price and matching qty (sCancelCost). iCancel=4 (质量事故) requires sSlaveAccidentNo set (sCanelNeedQualityNo). iBecome=1 requires non-zero qty and untouched price (sChangeQtyNotZero). iBecome=2 requires both non-zero (sChangePriceNotZero). iBecome=3 requires non-zero price and untouched qty (sChangeProductPriceNotZero).
Invocation: Status: appears orphaned. The module 订单变更单据 (sId 101251240115016233151134120) is bound to Sp_Calc_sOrderBgd for audit but has no sSaveProName/sSaveProNameBefore hook in the current DB snapshot. No form-master or other-routine caller found. xly-src ships no Sp_Check_sSodbecome.sql either. Candidate for maintainer audit on whether the validator was deprecated when the 订单变更 workflow moved to Sp_Calc_sOrderBgd.