# `Sp_Apply_Flow_OrderChange` (procedure)

> 流程启动前调用-订单变更单


- **Type:** PROCEDURE
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sFormGuid` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sSrcNo` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | OUT | `sTableParams` | `longtext` |
| 6 | OUT | `sSrcReportData` | `longtext` |
| 7 | OUT | `sTableParamsValue` | `longtext` |
| 8 | OUT | `sReturn` | `varchar(4000)` |
| 9 | IN | `sBrId` | `varchar(100)` |
| 10 | IN | `sSuId` | `varchar(100)` |
| 11 | OUT | `sCode` | `int` |

## Body

_Body is not pre-cached. To inspect: `mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDURE `Sp_Apply_Flow_OrderChange`'`._

## Narrative

**Business context:** 订单变更单 — workflow-apply data builder for the 销售订单变更 approval flow. Builds the approver-tier roster and the change-detail summary that the BACK approval UI shows before routing.

**What it does:** From `salsalesorderbecomemaster`/`salsalesorderbecomeslave` for `sGuid`, builds change-line memo (`sProductName`+`dProductQty`+`dProductMoney`+`sEvaluateNo`) and returns JSON with `iBecome`/`iCancel` mapped to display strings (订单取消/数量变更/数量单价同时变更/单价变更). Resolves seven approver tiers from `eleemployee.iPosition` (6=物控经理, 23=销售管理, 19=技术部经理, 21=生产计划部经理 OR `iPosition1=21`, 3=营销部长, 11=财务经理, 15=报价主管). Sets `iOut`/`iOut1` flags for "已下采购单" and "已下工单" by joining `purpurchaseorderdetail` and `mftworkorderslave` to the becomemaster.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` where `sApplyProName` is read from `gdsmoduleflow.sApplyProName`. Table empty in this DB — workflow configs tenant-provisioned per deployment. Superseded variant `Sp_Apply_Flow_OrderChangeNew` exists with extra dept-based tier logic.
