# `Sp_Sales_SalesAnalysiseOfMakePerson` (procedure)

> 销售分析表(制单人员)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `tStartDate` | `datetime` |
| 2 | IN | `tEndDate` | `datetime` |
| 3 | IN | `sBrId` | `varchar(100)` |
| 4 | IN | `sSuId` | `varchar(100)` |
| 5 | IN | `sLoginId` | `varchar(100)` |
| 6 | IN | `bFilter` | `varchar(5000)` |
| 7 | IN | `pageNum` | `int` |
| 8 | IN | `pageSize` | `int` |
| 9 | OUT | `totalCount` | `int` |
| 10 | IN | `countCloumn` | `varchar(5000)` |
| 11 | OUT | `countMapJson` | `longtext` |
| 12 | IN | `sFilterOrderBy` | `varchar(5000)` |
| 13 | IN | `sGroupby_select_sql` | `varchar(5000)` |
| 14 | IN | `sGroupby_group_sql` | `varchar(5000)` |

## Body

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

## Narrative

**Business context:** 销售管理 → 销售分析(人员角度) → 销售分析表(制单人员) — paged sales analysis pivoted by 制单人员 (the operator who keyed the 销售订单), one row per active `sftlogininfo` user with that user's aggregate ordered / collected / outstanding totals.

**What it does:** Seeds `SAS` from `sftlogininfo` (login user master) for the current 品牌/分公司, then `UPDATE ... INNER JOIN`s in order counts and money from `viw_salSalesOrder` grouped by `S.sMakePerson` and matched to `A.sName` (i.e. `sftlogininfo.sUserName` ↔ order's `sMakePerson` string) — subject to the seven 销售订单 `sFormId` whitelist and `bCheck=1 AND bInvalid=0`. Joins `cahreceiptmaster` by `sMakePerson` for 收款, computes `dBalanceMoney`, averages and 占比 columns from `tempSAS`, drops zero-money rows, pages via `Sp_Do_UpdateByPageSizeBefore`.

**Invocation:** Bound as the data-source of the 销售分析表(制单人员) form `gfm.sId=192116811110216080102093540` via `gdsconfigformmaster.sSqlStr`; module path 销售管理 → 销售分析(人员角度) → 销售分析表(制单人员). 优化版 ships at `script/标版/optimize/Sp_Sales_SalesAnalysiseOfMakePerson.sql`. Caveat: matching by `sUserName` is fragile if usernames change — verify before relying on per-operator totals.
