# `Sp_Repair_salsaleschance_Lost` (procedure)

> 商机输单


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProInParam` | `varchar(10000)` |
| 2 | IN | `sMakePerson` | `varchar(100)` |
| 3 | IN | `sUserId` | `varchar(100)` |
| 4 | IN | `sBrId` | `varchar(100)` |
| 5 | IN | `sSuId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(1000)` |
| 7 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 销售管理 → 商机机会 — bulk-mark sales-opportunity rows as 商机输单 (lost bid). The COMMENT `'商机输单'` and write-back to `salsaleschancemaster (sLostMemo, sLossType, dLossAimMoney, dRivalMoney, iFollowUp=3)` identify it as the lost-bid grid action; companion of `Sp_Repair_salsaleschance_sScrap` (废单/scrapped).

**What it does:** Parses `sProInParam` JSON (`$.params[*].value[*].sId`) plus `$.changeValue.{textareaValue, sLostMemo, sLostType, dLossAimMoney, dRivalMoney}`. For each `sId`, runs `UPDATE salsaleschancemaster SET sLostMemo, sLossType, dLossAimMoney, dRivalMoney, iFollowUp=3 WHERE sId=... AND iFollowUp=0` — guards on `iFollowUp=0` so already-followed/lost/scrapped rows are skipped. Aborts with `Sp_Sis_GetConst('paramsErro', ...)` and `sCode=-1` on empty input.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — the 商机机会 grid's 输单 toolbar button names this proc as the action (`Sp_Repair_*` is an alternative naming for the `Sp_BtnEvent_*` slot, sharing the same `sProInParam`/`sMakePerson`/…/`sCode` signature). Not in `gdsmodule`, form-master, or xly-src.
