# `Sp_beforeSave_sSfu` (procedure)

> 商机跟进存前反写数量


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(2000)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | OUT | `sCode` | `int` |
| 5 | OUT | `sReturn` | `varchar(4000)` |

## Body

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

## Narrative

**Business context:** 商机跟进单据 / 销售单据 — before-save dispatcher for the sales-lead follow-up document. Wraps `sGuid` and delegates to `Sp_saveReturn_sSfu` to update the parent `salsaleschancemaster.sFlow` (lead-pipeline phase) from the latest follow-up record before the master save commits. Header comment: `商机跟进存前反写数量`.

**What it does:** Normalises `sGuid` to a quoted-CSV form, then `CALL Sp_saveReturn_sSfu(sGuid, sBrId, sSuId, 1, @sCode, @sReturn)`. The inline `Update salsaleschancemaster` block left commented-out in the body shows the historical equivalent of what `Sp_saveReturn_sSfu` now does.

**Invocation:** Not bound to a module as a save-hook in this DB. Called by both backwriting dispatchers — `Sp_Invalid_backwriting` and `Sp_delete_backwriting` — when `sFormGuid = '101251240115016035948853880'` (商机跟进单据), to replay the writeback on cancel-invalidate and on delete of the linked follow-up record.
