# `Sp_Task_doTestMsg` (procedure)

> 定时过程执行(发送消息)


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

## Parameters

| # | Mode | Name | Type |
|---|---|---|---|
| 1 | OUT | `cardTitle` | `varchar(255)` |
| 2 | OUT | `title` | `varchar(255)` |
| 3 | OUT | `sAbstract` | `varchar(255)` |
| 4 | OUT | `cardDate` | `varchar(255)` |
| 5 | OUT | `itemMemo` | `varchar(255)` |
| 6 | OUT | `sCode` | `int` |
| 7 | OUT | `sReturn` | `longtext` |
| 8 | OUT | `sUserList` | `longtext` |
| 9 | OUT | `sUserData` | `longtext` |

## Body

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

## Narrative

**Business context:** 销售业绩统计报表 — scheduled daily-sales-performance digest. Template/reference implementation for the `Sp_Task_*` message family: the temp table name `Sp_Task_doTestMsg` is reused by every sibling procedure as the data-set table that the message template renders.

**What it does:** Defaults `sBrId/sSuId/sCode`, sets `title='销售业绩统计报表'`, then runs a long block of `Select Sum(dProductMoney)/10000 Into p_d*` queries from `viw_salsalesorder` joined to `sissalesman` and `elecustomer` to compute today's, this-week's (four week buckets), this-month's, and YTD sales totals split by 新/老 `sCustomerProperty`. Composes `cardTitle`, `itemMemo`, `cardDate`, and per-bucket rows into `Sp_Task_doTestMsg` for the message template to render. Returns the temp table plus optional `sUserList`/`sUserData` for ad-hoc dynamic recipients (see the leading `--` documentation block).

**Invocation:** Dispatched by the Quartz scheduler — `QuartzTask` (xlyFlow) calls `TaskServiceImpl.doProOne()` which executes the procedure named in the scheduler-job config; `sendMsgDoNew(...)` then pipes the OUT params and result set into the message template referenced by `sMestemplateId`. No `gdsmodule`/form-master binding; bootstrapped by the `script/标版/upgrade/更新WAR脚本/20230210_消息、工作流、定时 模块` upgrade.
