# `Sp_saleschanceToSop_BtnEventDistribution` (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 | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | OUT | `sReturn` | `varchar(1000)` |
| 6 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 销售单据 / 商机机会 → 开发跟进 — toolbar-button handler that bulk-assigns a 业务类型 (`sBussinessType`) to selected 商机机会产品 lines. Used when the operator distributes/categorises opportunity products into business-type buckets ahead of further routing.

**What it does:** Validates `sProInParam` (rejects with `paramsErro` via `Sp_Sis_GetConst` if too short). Parses `$.changeValue.sBussinessType` and the `$.params[*].value[*].sSlaveId` JSON array. For each slave id, `UPDATE salsaleschanceproduct SET sBussinessType=<value> WHERE sId=<sSlaveId> AND sBrandsId=sBrId AND sSubsidiaryId=sSuId`. The proc emits a debug `select p_changeValue,p_sBussinessType;` mid-flight — harmless, but visible to callers tailing the result set.

**Invocation:** Dispatched dynamically by `GenericProcedureCallServiceImpl.doGenericProcedureCall()` (POST `/procedureCall/doGenericProcedureCall`) — the 分配业务类型 toolbar button on the 商机机会 / 开发跟进 grid names `Sp_saleschanceToSop_BtnEventDistribution` as the action. Companion procs: `Sp_saleschanceToSop_BtnEventTodevelop`, `Sp_saleschanceToSop_BtnEventDevelopBack`. Install script: `script/标版/30100101/Sp_saleschanceToSop_BtnEventDistribution.sql`.
