# `Sp_Sale_OrderCompleteDoing` (procedure)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | `sBrId` | `varchar(100)` |
| 2 | IN | `sSuId` | `varchar(100)` |
| 3 | IN | `sLoginId` | `varchar(100)` |
| 4 | IN | `bFilter` | `longtext` |
| 5 | IN | `pageNum` | `int` |
| 6 | IN | `pageSize` | `int` |
| 7 | OUT | `totalCount` | `int` |
| 8 | IN | `countCloumn` | `longtext` |
| 9 | OUT | `countMapJson` | `longtext` |
| 10 | IN | `sFilterOrderBy` | `longtext` |
| 11 | IN | `sGroupby_select_sql` | `longtext` |
| 12 | IN | `sGroupby_group_sql` | `longtext` |

## Body

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

## Narrative

**Business context:** 销售管理 → 销售订单 — paged report of orders that are 送货完结 at the master level but still have un-completed slave rows: `bInvalid=0 AND bCheck=1 AND bDeliverComplete=1 AND bSlaveComplete=0`. Used by the "完结处理中" (completion-in-progress) grid — the inverse window of `Sp_Sale_OrderCompleteApply`.

**What it does:** Mirrors `Sp_Sale_OrderCompleteApply` minus the secondary `UPDATE` joins to inventory/delivery views — builds TEMP `p_TmpTb` of order-slave rows with customer/product/sales-rep/qty/money/delivery fields, inserts dynamic SQL `INSERT INTO p_TmpTb … FROM Viw_SalSalesOrder WHERE bInvalid=0 AND bCheck=1 AND bDeliverComplete=1 AND bSlaveComplete=0 AND brand/sub`, applies `Fun_GetLookCustomer(sLoginId, sBrId, sSuId)` row-level customer filter, then hands the SQL to the standard paging helper for `bFilter`, `sFilterOrderBy`, `sGroupby_*`, paging, `totalCount`, `countMapJson`.

**Invocation:** Status: appears orphaned in this DB snapshot. Signature matches the standard form-master report contract; expected to bind via `gdsconfigformmaster.sSqlStr`, but no binding exists here. Install script ships in `script/标版/30100101/Sp_Sale_OrderCompleteDoing.sql`. Candidate for maintainer audit — verify the form that sources this proc in production (likely paired with `Sp_Sale_OrderCompleteApply` on the order-completion dashboard).
