# `Sp_Ai_AddCommonAfter` (procedure)

> AI_调用下单 插入订单


- **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 | `sToolId` | `varchar(100)` |
| 5 | IN | `sSrcFormId` | `varchar(100)` |
| 6 | IN | `sControlName` | `varchar(100)` |
| 7 | IN | `iActionType` | `varchar(100)` |
| 8 | IN | `sData` | `longtext` |
| 9 | OUT | `sReturn` | `longtext` |
| 10 | OUT | `sCode` | `int` |

## Body

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

## Narrative

**Business context:** AI-assistant order-insertion handler — header says `AI_调用下单 插入订单`. Intended to be invoked by the AI/chatbot path: receives a `sControlName` (Chinese button label e.g. `送货下单`) plus a JSON `sData` payload, validates the source-form / control config, hardcodes `p_sTableName='saldelivergoodsmaster'`, generates a bill number by `DATE_FORMAT(NOW(),'...')`, and inserts a delivery-goods header row tied to seed-tenant `'1111111111'`.

**What it does:** Validates `sSrcFormId` and `sControlName` non-empty (returns localized error otherwise). Hardcodes target table = `saldelivergoodsmaster` and form sId `11811781131121915179924491520`. Most of the per-form-derived lookups (`gdsconfigformslave` join, `Sp_Sis_GetMaxNo` call, dynamic `p_sTableName`/`p_sFormId`) are commented out — the live path only generates a date-string bill number, builds a single-row INSERT skeleton, and returns.

**Invocation:** Status: appears orphaned. No `gdsconfigformslave.sControlName`/`sActiveId` binding, no `gdsmodule` hook, no other routine references it, and `grep` finds zero call sites anywhere in `xly-src` (no Java handler dispatches `Sp_Ai_*`). Candidate for maintainer audit — AI-assistant scaffolding apparently never wired into a live control. Hardcodes seed-tenant `sBrandsId='1111111111'`.
