# `Sp_Apply_Flow_Order` (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_Order`'`._

## Narrative

**Business context:** 销售订单 — workflow-apply data builder for the 销售订单 approval flow. Returns the JSON payload (`sTableParams` schema + `sTableParamsValue`) that the BACK approval UI renders on the order before routing it.

**What it does:** Reads `salsalesordermaster`/`salsalesorderslave` for `sGuid`, joining `elecustomer`+`eleproduct`. Two branches: when the slave's `sProductInfo` JSON is populated, it extracts `sProductName`/`sProductUnit` from that JSON; otherwise it falls back to the joined `eleproduct` row. Sums `dProductQty` and takes MAX(`dProductMoney`) across all slaves of the order.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` where `sApplyProName` is read from `gdsmoduleflow.sApplyProName`. Table is empty in this DB — workflow configs are tenant-provisioned per deployment.
