# `Fun_Cashier_GetProductPrice` (function)

> 获取最近采购价(产品)


- **Type:** FUNCTION
- **Returns:** `varchar(100)`
- **Deterministic:** NO
- **SQL data access:** CONTAINS SQL

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sProductGuid` | `varchar(100)` |
| 2 | IN | `sBrId` | `varchar(100)` |
| 3 | IN | `sSuId` | `varchar(100)` |

## Body

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

## Narrative

**Business context:** Sales-side — "most recent sale price" for a finished product, used to default product-line prices on sales documents. Despite the header comment `获取最近采购价(产品)` ("most-recent purchase price for product"), the body reads sales views, not purchasing views; the comment is a copy-paste leftover from the materials sibling.

**What it does:** reads `dProductPrice` from `Viw_SalSalesChecking` first (settled sales rows, `dLossMoney = 0`), then falls back through `Viw_SalDeliverGoods` and `Viw_SalSalesOrder`, all `bCheck = 1`, tenant-scoped, latest by `tCreateDate`. Returns `'0'` if nothing matches.

**Invocation:** referenced from form-master `sId 101251240115016087911499840` ("选择材料(销售)" — material selector on sales forms) and called by `Sp_Save_CheckSaveAfter` for the after-save sales validations.
