# `Sp_Calc_sProductChange` (procedure)

> 产品变更申请


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `iFlag` | `int` |
| 2 | IN | `iTmpCheck` | `int` |
| 3 | IN | `sFormGuid` | `varchar(100)` |
| 4 | IN | `sGuid` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | OUT | `sReturn` | `varchar(5000)` |
| 7 | IN | `sBrId` | `varchar(100)` |
| 8 | IN | `sSuId` | `varchar(100)` |
| 9 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 产品管理 → 产品管理单据 → 产品版本变更单 — audit / un-audit of a 产品变更申请 (product-change request) on `mftproductchange`. On approval, the proc commits the change by bumping the linked product's version (`eleproduct.sProductVer`) — i.e. promotes the change request into a new product revision.

**What it does:** Validates `sGuid`, refuses when `bInvalid=1`, then on `iFlag=1` guards on `bCheck` and `UPDATE mftproductchange` to set `bCheck=1`, `sStatus=1`, `sCheckPerson`, `tCheckDate`, plus `UPDATE eleproduct SET sProductVer = CONCAT('V', LPAD(RIGHT(sProductVer,2)+1, 2, '0'))` joined on `mftproductchange.sProductId` — incrementing the product version (V01 → V02 etc.). `iFlag=0` un-checks the request but does NOT roll back the version bump on the product, which is a one-way side effect.

**Invocation:** Bound to `gdsmodule.sProcName` on `产品版本变更单` (sId `12012615914116361726917970`) under 产品管理 → 产品管理单据. Dispatched by Java `BusinessBaseServiceImpl.getPrcName(sFormGuid, …)` on the audit/un-audit button — the standard `Sp_Calc_s<Code>` slot. Install scripts: `script/标版/30100101/Sp_Calc_sProductChange.sql` and `script/标版/upgrade/20211115产品变更/Sp_Calc_sProductChange.sql`.

Caveat: the un-audit branch does not decrement `eleproduct.sProductVer`. After reversing a 产品版本变更单 audit, the product still shows the bumped version — verify whether that is intended.
