# `Sp_QuotationStatistics` (procedure) - **Type:** PROCEDURE - **Deterministic:** NO - **SQL data access:** CONTAINS SQL ## Parameters | # | Mode | Name | Type | |---|---|---|---| | 1 | IN | `tStartDate` | `datetime` | | 2 | IN | `tEndDate` | `datetime` | | 3 | IN | `sLoginId` | `varchar(100)` | | 4 | IN | `sBrId` | `varchar(100)` | | 5 | IN | `sSuId` | `varchar(100)` | | 6 | IN | `bFilter` | `longtext` | | 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_QuotationStatistics`'`._ ## Narrative **Business context:** 销售管理 → 报价&估计管理 → 估价丢单原因统计 — paged "lost-quote reason" pivot. Groups approved quotations into reason buckets: every `sType` lost-reason that didn't become a sales order, plus a fixed bucket "已成交订单" (turned into a sales order) and the unconfigured "未走客户确认流程直接下单" (booked without customer confirmation). **What it does:** Builds temp table `Tmp_EleProduct` from `quoquotationmaster` (filter: `bCheck=1` and date range). First pass counts/sums quotes not in `viw_salsalesorder.sSrcId` grouped by `sType`; empty `sType` rows get re-labelled via `Fun_Sis_GetConstNew('sNotCustomerConfirm', …)`. Second pass inserts the "已成交订单" row from quotes that *do* match `viw_salsalesorder`. Computes `dPercentageQty = dQuotationMoney / sum * 100`. Hands the result to `Sp_Outstanding_Query` for paging/`bFilter` splicing/total-count. **Invocation:** Bound as data-source of form `gfm.sId=15936608930005133957219822193000` via `gdsconfigformmaster.sSqlStr` — module 估价丢单原因统计 (`sId 101251240115015878880530950`). Install/optimize script `script/标版/optimize/Sp_QuotationStatistics.sql`.