# `Sp_Apply_Flow_QualityaccidentCustomer` (procedure)

> 流程启动前调用-客户索赔单


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sFormGuid` | `varchar(100)` |
| 2 | IN | `sGuid` | `varchar(100)` |
| 3 | IN | `sSrcNo` | `varchar(100)` |
| 4 | IN | `sLoginId` | `varchar(100)` |
| 5 | OUT | `sTableParams` | `longtext` |
| 6 | OUT | `sSrcReportData` | `longtext` |
| 7 | OUT | `sTableParamsValue` | `longtext` |
| 8 | OUT | `sReturn` | `varchar(4000)` |
| 9 | IN | `sBrId` | `varchar(100)` |
| 10 | IN | `sSuId` | `varchar(100)` |
| 11 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** 客户索赔单 (流程启动前调用-客户索赔单) — workflow-apply data builder for the customer-claim approval flow on `saldelivergoodsdedmaster` (negative-delivery / claim-deduction header). Builds a six-tier roster, line summary, and 烟包 routing flag.

**What it does:** Resolves tiers from `eleemployee.iPosition`: 18=品管部, 1=总经理, 27=应收会计, 37=营销经理, 34=营销负责人 国内副总. `p_TwoFlow` (业务员) is resolved via the join `elecustomer→sissalesman→eleemployee` from the claim's customer rather than `iPosition`. Counts `saldelivergoodsdedslave` lines whose product belongs to classify subtree of `'16624527080007919539418229414000'` (烟包产品 root); `p_iOut=1` if any. Computes `p_dTotalMoney` as `0-SUM(dProductMoney)` (claim amounts stored as negative on slave). Emits per-line memo CONCAT-ing `产品名称➜数量+单位➜索赔金额`.

**Invocation:** Dispatched dynamically by Java `CheckExamineFlowDataServiceImpl.doSendCheckFolwData()` via `doProByNameFlow(..., sApplyProName, ...)` from `gdsmoduleflow.sApplyProName` (empty in this DB — workflow configs tenant-provisioned per deployment).

Flag: hardcodes tenant-specific 烟包产品 classify root `16624527080007919539418229414000`.
