# `Sp_afterSave_sDgda_phone` (procedure)

> 材料送货单单据（PDA）保存后反写数量


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sGuid` | `varchar(2000)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |
| 4 | OUT | `sCode` | `int` |
| 5 | OUT | `sReturn` | `varchar(4000)` |

## Body

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

## Narrative

**Business context:** 材料送货单 PDA-side variant. Distinct from the rest of the `Sp_afterSave_s<Code>` family: instead of reverse-writing into upstream rows, this proc CREATES the `saldelivergoodsslave` detail rows from the scanner barcode rows after a 材料送货 master is saved from the mobile/PDA scan-flow.

**What it does:** Runs a single `INSERT INTO saldelivergoodsslave(...) SELECT … FROM saldelivergoodsmaster B INNER JOIN mitmaterialsstorebarcode A ON A.sParentId=B.sId LEFT JOIN elecustomer E ON B.sCustomerId=E.sId WHERE A.sParentId=sGuid GROUP BY A.sProductId, A.sWarehouseId, A.sLocationId, A.sWarehouseLocationId, A.sDefineNo, A.sDefineNo2` — collapses N scanned barcodes per product/location/define into one detail row carrying SUM(`dProductQty`), SUM(`dProductMoney`), SUM(`dGiveQty`) and a CONVERT-derived per-unit price. The customer contact/phone/sales-man/tax fields are pulled from `elecustomer` so the new detail row is self-contained without referencing the master.

**Invocation:** Status: appears orphaned. No caller found in any channel (`gdsmodule.sSaveProName`/`sCalcProName`/`sProcName`, form-master, other routines, xly-src grep) — candidate for maintainer audit. The mobile-scan delivery flow today commits detail rows directly via the front-end's addBusinessData call, so this server-side aggregator no longer has a hook.
