# `Sp_Sales_SalesAnalysise` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `sStatiStics` | `varchar(100)` | | 2 | IN | `tStartDate` | `datetime` | | 3 | IN | `tEndDate` | `datetime` | | 4 | IN | `iBillType` | `int` | | 5 | IN | `iClassifyType` | `int` | | 6 | IN | `iSum` | `int` | | 7 | IN | `sBrId` | `varchar(100)` | | 8 | IN | `sSuId` | `varchar(100)` | | 9 | IN | `bFilter` | `varchar(5000)` | | 10 | IN | `pageNum` | `int` | | 11 | IN | `pageSize` | `int` | | 12 | OUT | `totalCount` | `int` | | 13 | IN | `countCloumn` | `varchar(5000)` | | 14 | OUT | `countMapJson` | `longtext` | | 15 | IN | `sFilterOrderBy` | `varchar(5000)` | | 16 | IN | `sGroupby_select_sql` | `varchar(5000)` | | 17 | 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_SalesAnalysise`'`._ ## Narrative **Business context:** 销售管理 → 销售分析 — the multi-dimensional sales-analysis engine. Single proc that backs a dozen form-master views (销售大数据分析, 销售分析表 by 产品/客户/客户分类/客户属性/业务人员/销售部门/产品大类/制单人员, 销售统计日报表, 销售利润分析-按产品/按客户). The dimension is selected by `sStatiStics`, the bill-type by `iBillType`, the classify mode by `iClassifyType`, summary vs. detail by `iSum`. **What it does:** Builds temp `p_TmpInOutStore`, `Insert INTO p_TmpInOutStore` from `viw_salsalesorder`/`viw_saldelivergoods` etc. joined against `EleCustomer` and `eleproduct`. `UPDATE p_TmpInOutStore` folds in derived columns (margin, money, qty by 销售/送货/对账). The dynamic pivot column-set is driven by `sStatiStics` (`salesman`, `customer`, `customerclass`, `customerproperty`, `product`, `productclass`, `makeperson`, `salesdepart`). Final paging via `CALL Sp_Outstanding_Query` with `pageNum/pageSize` slice and `countMapJson` from `countCloumn`; `bFilter`/`sFilterOrderBy`/`sGroupby_*` spliced into the dynamic SQL. **Invocation:** Bound to `gdsconfigformmaster.sSqlStr` on 12 forms across three modules: 销售分析(产品角度) (销售大数据分析, 销售分析表(产品/产品大类), 销售统计日报表, 销售利润分析-按产品), 销售分析(客户角度) (销售分析表(客户/客户分类/客户属性)), 销售分析(人员角度) (销售分析表(业务人员/销售部门/制单人员)), 利润分析 → 成本管理 (销售利润分析-按客户). Install scripts under `script/标版/30100101/` plus optimised variants under `script/标版/optimize/` — the dimension-specific sibling procs (`Sp_Sales_SalesAnalysiseOfProduct`, `OfSalesperson`, etc.) are typically what those forms call now; this base proc is the legacy single-procedure surface.