# `Sp_Sales_SalesAnalysiseOfDay` (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_SalesAnalysiseOfDay`'`._

## Narrative

**Business context:** 销售管理 → 销售分析(产品角度) → 销售统计日报表 — daily roll-up of sales / instore / delivery 不含税金额 pivoted by `eleproduct.sProductproperty` (`卡盒类`/`坑盒类`/`书刊类`/`胶片盒类`/`精品手工类`/`其他`). Carton/box-printing taxonomy — the form is a customer-line specialization (paper-box industry property bins) reused as the standard 销售统计日报表.

**What it does:** Computes a `Fun_GetLookCustomer(sLoginId,...)` data-permission filter, builds a UNION across `viw_salsalesorder`/`viw_saldelivergoods`/`viw_pitproductinstore` to collect every distinct `tCreateDate` day within the window into `SAS.tReportDay`. Then three `UPDATE ... INNER JOIN` blocks pivot `dProductNoTaxMoney` by `sProductproperty` for each of the three source views into 销售/入库/送货 column groups (suffixes `dSalesAY/SY/RY/SM/ZH/HJG/HJ`, `dInStore*`, `dDelivery*`). Each property-group total is summed into the `HJ` (合计) column. Output is paged via `Sp_Outstanding_Query`.

**Invocation:** Bound as the data-source of the 销售统计日报表 form `gfm.sId=101251240115016215103304510` via `gdsconfigformmaster.sSqlStr`; module path 销售管理 → 销售分析(产品角度) → 销售统计日报表. Install ships at `script/标版/30100101/Sp_Sales_SalesAnalysiseOfDay.sql`; 优化版 at `script/标版/optimize/`.
