# `Sp_Sales_SalesDelivergoodsAnalysiseOfCustomer` (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` | `text` |
| 7 | IN | `pageNum` | `int` |
| 8 | IN | `pageSize` | `int` |
| 9 | OUT | `totalCount` | `int` |
| 10 | IN | `countCloumn` | `text` |
| 11 | OUT | `countMapJson` | `longtext` |
| 12 | IN | `sFilterOrderBy` | `text` |
| 13 | IN | `sGroupby_select_sql` | `text` |
| 14 | IN | `sGroupby_group_sql` | `text` |

## Body

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

## Narrative

**Business context:** 销售送货分析 — paged customer-level delivery-goods analysis: one row per customer showing aggregate delivered qty / money, collected money and outstanding balance for a single specific 送货单 form (`sFormId='11811781131121915179924491520'`). Distinct from `Sp_Sales_SalesAnalysiseOfCustomer` (which is sales-order-side) — this proc tallies the 送货单 side only. (The `COMMENT '现金日记帐'` is a copy-paste artifact — actual purpose is per-customer delivery analysis.)

**What it does:** Seeds `SAS` from `eleCustomer` for the current 品牌/分公司, carrying each customer's `sSalesManId` and `sGetPayId`. `UPDATE ... INNER JOIN`s in count, qty and money from `viw_saldelivergoods` grouped by `sCustomerId` — restricted to the single `sFormId='11811781131121915179924491520'` (a specific 送货单 form), `bCheck=1 AND bInvalid=0`. Resolves `sSalesManName` from `sisSalesMan` and `sGetPayName` from `sispayment`. Joins `cahreceiptmaster` for `dPayMoney`, computes `dBalanceMoney`, the three 占比 columns from `tempSAS` totals, and pages via `Sp_Do_UpdateByPageSizeBefore`.

**Invocation:** Status: appears orphaned. No `gdsconfigformmaster.sSqlStr` / `sConfigSqlStr` / `sSqlCondition` binding, no `gdsmodule` hook, no other-routine caller. Only reference is the install script `script/标版/30100101/Sp_Sales_SalesDelivergoodsAnalysiseOfCustomer.sql` (and an `optimizeprocedure` registration row). The single hard-coded `sFormId` whitelist suggests this was a customer-specific 送货单 analysis that was never wired to a form. Candidate for maintainer audit.
