yanhui 983fee0d8a fix(wst): 起算点改为「审核时间 / 订单 modified 取较晚者」,修 13:00 轮 65 单假超时
## 业务问题

业务举证:13:00 轮不该有那么多单 —— 「9 点前的单 13:00 前已经发完了」。
线上实测 65 单,逐单核对全部不该在 13:00 轮。

## 根因(两个,都指向「起算点取错」)

### ① 状态表的审核时间会严重滞后

业务给的举证单 9978643:

| 字段 | 值 |
|---|---|
| `qmcust.modified` | **2026-10-28 14:52:29** |
| 聚水潭页面真实审核时间 | **2026-10-28 14:52:28**(秒级吻合) |
| 状态表 `last_oa_confirm_time` | 2026-10-27 17:08:43(旧了一天) |
| 状态表 `query_time` | 2026-10-28 10:29:11(10:29 后没再抓) |

只信状态表 → 这单被当成「10-27 就审核了」,混进 13:00 轮超时,冤枉仓库。

### ② 审核时间为空的单回退 created,把今天的单按历史单算

65 单里 57 单状态表审核时间为 NULL。回退 `created` 后:

| o_id | created | modified | 回退后算成 | 真实 |
|---|---|---|---|---|
| 9964841 | 10-26 17:22 | **10-28 13:40** | 10-26 审核 → 进 13:00 轮 | 今天下午才审核 |
| 9949424 | 10-25 17:03 | **10-28 13:50** | 同上 | 同上 |
| 9983773 | 10-27 23:23 | **10-28 13:59** | 同上 | 同上 |

57 单的 `modified` 全部落在今天 13:40~15:03 —— 都是今天下午批量审核的。

## 改动

- **起算点** = `max(状态表 last_oa_confirm_time, 订单表 modified, 订单表 created)`
  - 取较晚者:修状态表滞后
  - 纳入 created:个别单 `modified` 早于 `created`(脏数据),起算点不该早于下单时刻
  - `benchmarkSource` 透出 `oa_confirm` / `modified` / `created`,页面 tooltip 说明来源
- **新增 `laterOf()`**:同格式 `YYYY-MM-DD HH:mm:ss` 直接字典序比较,不转 Date(避开时区坑)
- **主查询 SQL 增加 `x.modified`** 列(订单两表都有,无需额外查询)

## 性能修复(同批,线上 /list 曾 300s 超时)

上版状态表查询**串行 9 批实测 135s**,叠加主查询 63~105s 直接把接口顶过 300s,
页面打不开(实测 curl `--max-time 300` 超时)。改为**并发 6**:

| 方式 | 耗时 |
|---|---|
| 串行 9 批 | 135s |
| 并发 3 | 28.8s |
| **并发 6(本版)** | **10~15s** |

并发 6 是生产实测的安全值(单批约 15s,不至于把 402 万行视图的连接池打爆)。

## 改后效果(10-28 17:00 真实库)

| 轮次 | 改前 | 改后 |
|---|---|---|
| 13:00 轮 | 65 单 | **0 单** |
| 18:00 轮 | — | 927 单(全部今天 07:59~16:00 审核,无历史单) |

- `fallbackToCreated` 从 57 → **0**(不再有回退单)
- 9978643 ✅ 已剔除
- 两个轮次都验证「今天窗口上界之后起算的 = 0」

## 验证

- 后端 `npm run check`:**493/495**(2 个失败是既有环境问题:TTL 计时、Windows 权限,改动前同样失败)
- 新增 2 个测试锁定该口径:
  - `modified` 晚于窗口 → 必须剔除(9978643 那类单)
  - 状态表审核时间晚于 `modified` → 以状态表为准
  - `modified` 早于 `created` → 取 `created`,不倒退
- 前端 lint + build 通过(35.2s)
- 真实库双轮验证通过

## 风险与回退

- **`modified` 被客服改单/改备注刷新**时起算点会推后 → 少报超时(放行方向,不冤枉仓库)。
  业务已知悉并接受;这是当前唯一能拿到「今天真实审核时间」的可靠字段。
- 回退方式:`git revert <merge commit>` 即回到只认状态表审核时间的版本。
2026-10-28 17:02:54 +08:00

1131 lines
51 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useCallback, useEffect, useMemo, useState } from 'react';
import {
Alert, Button, Card, Collapse, Dropdown, Empty, Input, InputNumber, Modal, Space, Spin,
Statistic, Switch, Table, Tag, TimePicker, Tooltip, Typography, message,
} from 'antd';
import { BellOutlined, DownloadOutlined, ReloadOutlined } from '@ant-design/icons';
import dayjs from 'dayjs';
import { SycmPage } from '../../components/Common';
import {
getShipTimelinessNotifySettings,
getWarehouseShipTimeliness,
getWarehouseShipTimelinessExportRows,
runShipTimelinessNotify,
saveShipTimelinessNotifySettings,
} from '../../api/warehouseShipTimeliness';
import { exportTableFile } from '../../utils/tableExport';
import './style.css';
const { Title, Text } = Typography;
// 核验点只有 13:00 / 18:00 两个,10 分钟刷新一次足够。
// 接口要扫两张订单表 + 出库表(rpt 下全是视图),冷启动 40~60 秒,别跟着其它页面的轮询节奏跑。
const AUTO_REFRESH_MS = 10 * 60 * 1000;
// 「钉钉通知」表单初始值。两个轮次各一个推送时刻(默认核验点 + 5 分钟)。
// 加签密钥永远不回显明文:留空 = 沿用服务端已存的那份
const EMPTY_NOTIFY_FORM = {
enabled: false,
noonSendTime: '13:05',
afternoonSendTime: '18:05',
webhookUrl: '',
webhookSecret: '',
maxDetailRows: 30,
atAll: false,
pageUrl: '',
};
// 后端「没推」的原因 → 人话(后端 reason 是给日志用的英文标识)
const NOTIFY_REASON_TEXT = {
disabled: '推送开关没打开',
not_configured: 'Webhook 地址还没填',
already_sent: '这一轮今天已经推过了(同一天同一轮只推一次)',
not_started: '这一轮还没到核验时刻,没有结论可推',
before_deadline: '还没到本轮核验时刻,推到群里会是半成品',
dry_run: '仅预览,未发送',
error: '执行出错',
};
// 钉钉群机器人 webhook 怎么拿 —— 业务自己配,写清楚省得来问
const NOTIFY_HELP_ITEMS = [
{
key: 'webhook',
label: '① 拿群机器人 Webhook 地址',
children: (
<div className="wst-notify__help">
电脑版钉钉 → 打开目标群 → 右上角 <b>群设置</b> → <b>机器人</b> → <b>添加机器人</b> →
选 <b>自定义</b> → 起个名字(如「发货时效通知」)→ 复制 <b>Webhook 地址</b>。
<br />
地址形如 <code>https://oapi.dingtalk.com/robot/send?access_token=xxxx</code>,
整串(含 access_token)直接贴到下面。
</div>
),
},
{
key: 'security',
label: '② 安全设置:加签密钥(可选)',
children: (
<div className="wst-notify__help">
添加机器人时如果安全设置选了 <b>加签</b>,把以 <code>SEC</code> 开头的密钥填到「加签密钥」里。
<br />
如果选的是 <b>自定义关键词</b>,密钥留空即可 —— 但关键词必须包含 <b>超时</b>
(本模块消息抬头固定是「【仓储中心发货时效】」,正文里有「超时未发货 N 单」,天然命中)。
<br />
如果选的是 <b>IP 地址(段)</b>,需要把生产服务器 IP 加进白名单,密钥同样留空。
</div>
),
},
{
key: 'round',
label: '③ 为什么一天推两次、时间怎么定',
children: (
<div className="wst-notify__help">
业务口径:<b>13:00 核验 7 点前审核的超时单</b>、<b>18:00 核验 16 点前审核的单</b>,
各自<b>核验完成后</b>推一次,所以是两个独立时刻,互不影响。
<br />
默认给到 <b>13:05 / 18:05</b>(核验点 + 5 分钟):订单表的 updateTime 要晚几分钟才覆盖到核验时刻,
整点推容易报「数据没覆盖核验点、超时数偏大」。想改成整点也可以,消息里会带这句提醒。
<br />
同一轮次同一天只推一次(服务重启不会重复轰炸);要重发点「立即推送」。
</div>
),
},
{
key: 'why',
label: '④ 为什么群里只有文字,没有 Excel 附件',
children: (
<div className="wst-notify__help">
钉钉的<b>自定义机器人 webhook</b> 只支持 text / markdown / link / actionCard,
<b>不支持发文件</b>。所以这里推的是<b>文本消息</b>:汇总数字 + 前 N 条明细 + 页面链接。
<br />
要全量明细或 Excel,点消息末尾的链接进页面查看 / 导出(口径与消息完全一致)。
</div>
),
},
];
const number = (value, digits = 0) => (
value === null || value === undefined || value === ''
? '0'
: Number(value).toLocaleString('zh-CN', {
minimumFractionDigits: digits,
maximumFractionDigits: digits,
})
);
// 超时时长(分钟)→「3 小时 20 分」/「12 天 4 小时」。
// ⚠️ 口径放开后(含历史未发单)会出现跨天的超时,必须给「天」,否则显示成「8640 小时」。
const formatOverdue = (minutes) => {
const m = Number(minutes);
if (!Number.isFinite(m) || m <= 0) return '—';
if (m < 60) return `${m} 分钟`;
const h = Math.floor(m / 60);
const rest = m % 60;
if (h < 24) return rest ? `${h} 小时 ${rest} 分` : `${h} 小时`;
const d = Math.floor(h / 24);
const hr = h % 24;
return hr ? `${d} 天 ${hr} 小时` : `${d} 天`;
};
/**
* 「不计考核」清单的列(待审核 / 订单异常)。
* 业务反馈(2026-10-20):贴进来的一批单号在聚水潭查不到,实测真实状态是
* 「已取消(发货前售后)」或「异常」—— 这类单不该算仓库超时。
* 这里把它们单列出来,回答「为什么这些单没进超时列表」。
*/
const HELD_COLUMNS = [
{ title: '内部单号', dataIndex: 'oId', width: 100 },
{ title: '线上订单号', dataIndex: 'soId', width: 170, ellipsis: true },
{ title: '店铺', dataIndex: 'shopName', width: 170, ellipsis: true },
{ title: '发货仓', dataIndex: 'warehouseName', width: 160, ellipsis: true },
{
title: '挂起原因',
dataIndex: 'holdReason',
width: 110,
render: (v) => (
<Tag bordered={false} color={v === '订单异常' ? 'red' : 'default'}>{v || '—'}</Tag>
),
},
{
title: '发货时间',
dataIndex: 'sendTime',
width: 178,
ellipsis: true,
render: (v, row) => {
if (v) return v;
const no = row?.logisticId;
if (no) {
return (
<Tooltip title={`已打单:${row.logisticCompany || ''} ${no}(${row.logisticStatus || '未揽收'})`}>
<Tag bordered={false} color="blue">已打单 · {row.logisticStatus || '未揽收'}</Tag>
</Tooltip>
);
}
return <Tag bordered={false} color="default">未发货</Tag>;
},
},
{
title: (
<Tooltip title="聚水潭「审核时间」= 状态表 last_oa_confirm_time 与订单表 modified 的较晚者(状态表会滞后,9978643 旧值比真实审核早一天)。两者都没有才回退订单创建时间,标 *">
<span>审核时间</span>
</Tooltip>
),
dataIndex: 'auditTime',
width: 152,
ellipsis: true,
render: (v, row) => {
if (!v) return <span className="wst-detail__fallback">无审核时间</span>;
return row?.benchmarkSource === 'created' ? `${v} *` : v;
},
},
{ title: '下单时间', dataIndex: 'createdAt', width: 152, ellipsis: true, render: (v) => v || '—' },
{ title: '付款时间', dataIndex: 'payTime', width: 152, ellipsis: true, render: (v) => v || '—' },
{ title: '已挂起', dataIndex: 'heldDays', width: 88, render: (v) => (v > 0 ? `${v} 天` : '—') },
];
const DETAIL_COLUMNS = [
// 内部单号 = 聚水潭 o_id(系统内部编号,仓管在系统里按它查单)
{ title: '内部单号', dataIndex: 'oId', width: 110 },
// 线上订单号 = 平台 so_id(京东/抖音/天猫等平台单号,客服按它对接客户)
{
title: '线上订单号',
dataIndex: 'soId',
width: 178,
ellipsis: true,
render: (v) => (v ? <span className="wst-detail__soid">{v}</span> : '—'),
},
{
title: '店铺',
dataIndex: 'shopName',
width: 180,
ellipsis: true,
render: (v) => (v || '—'),
},
{
title: '发货仓',
dataIndex: 'warehouseName',
width: 170,
ellipsis: true,
render: (v) => (v || '—'),
},
{
// 发货时间 = 聚水潭回传的发货时间(业务 2026-10-20:明细里不要创建时间,要发货时间)
title: (
<Tooltip title="订单表 jst_Orders.send_date(聚水潭回传的发货时间)。为空但有运单号的,说明仓库已打单、还没揽收/回传发货时间,会显示成「已打单」">
<span>发货时间</span>
</Tooltip>
),
dataIndex: 'sendTime',
width: 178,
ellipsis: true,
render: (v, row) => {
if (v) return v;
const no = row?.logisticId;
if (no) {
return (
<Tooltip title={`已打单:${row.logisticCompany || ''} ${no}(${row.logisticStatus || '未揽收'})。聚水潭还没回传发货时间,所以还没从超时列表里消失`}>
<Tag bordered={false} color="blue">已打单 · {row.logisticStatus || '未揽收'}</Tag>
</Tooltip>
);
}
return <Tag bordered={false} color="default">未发货</Tag>;
},
},
{
// 审核时间 = 本页的**考核起算点**(业务 2026-10-28 下午三次定版)
// = max(状态表 last_oa_confirm_time, 订单表 modified),都没有才回退创建时间并打 `*`
title: (
<Tooltip title="聚水潭「审核时间」= 状态表 last_oa_confirm_time 与订单表 modified 的较晚者。状态表会滞后(9978643 状态表是 10-27 17:08,真实审核 10-28 14:52),所以取较晚的那个。今天 7:00 前审核的 13:00 核验;截止 16:00 前审核的(含历史未发单)18:00 核验。带 * 表示两者都没有,回退订单创建时间">
<span>审核时间</span>
</Tooltip>
),
dataIndex: 'auditTime',
width: 152,
ellipsis: true,
render: (v, row) => {
if (!v) return <span className="wst-detail__fallback">—</span>;
if (row?.benchmarkSource === 'created') {
return (
<Tooltip title="状态表审核时间和订单表 modified 都取不到,已回退订单创建时间参与分轮与计时(`*` 为标记)">
<span>{v} *</span>
</Tooltip>
);
}
return v;
},
},
// 下单时间 = 客户在平台下单那一刻(只做参考对账,不参与计时)
{
title: (
<Tooltip title="聚水潭订单创建时间(jst_Orders.created),即客户下单时刻。只做参考,不参与分轮与计时">
<span>下单时间</span>
</Tooltip>
),
dataIndex: 'createdAt',
width: 152,
ellipsis: true,
render: (v) => v || '—',
},
// 付款时间 = 客户付款那一刻(并列展示,方便对账)
{ title: '付款时间', dataIndex: 'payTime', width: 152, ellipsis: true, render: (v) => v || '—' },
{
// 发货状态:订单表 status(翻译成中文)
title: (
<Tooltip title="订单表 jst_Orders.status 的实时状态。发货中 = 仓库还没发货,即考核对象">
<span>发货状态</span>
</Tooltip>
),
dataIndex: 'state',
width: 104,
render: (v) => (
<Tag bordered={false} color={v === '发货中' ? 'orange' : 'default'}>{v || '—'}</Tag>
),
},
{
title: '物流状态',
dataIndex: 'logisticStatus',
width: 100,
render: (v) => (v ? <Tag bordered={false}>{v}</Tag> : '—'),
},
{
title: (
<Tooltip title="从审核时间(仓库接到单的时刻)到本轮核验时刻(13:00 / 18:00)等了多久">
<span>已等时长</span>
</Tooltip>
),
dataIndex: 'overdueMinutes',
width: 112,
render: (v) => <span className="wst-detail__overdue">{formatOverdue(v)}</span>,
},
];
/**
* 导出列(「超时未发」明细)。
*
* ⚠️ 必须**单独一份**,不能直接复用 DETAIL_COLUMNS:
* ① 那里的 title 是 JSX(带 Tooltip),导出时会变成 "[object Object]" 当表头;
* ② 页面上没有「快递公司 / 运单号」两列,而业务追单恰恰要这两列
* (有运单号 = 已打单未揽收,能一眼看出卡在哪一步)。
* 标题一律纯字符串,格式化统一走 exportValue(null 值别导出裸空/裸 0)。
*/
const EXPORT_COLUMNS = [
{ title: '内部单号', dataIndex: 'oId' },
{ title: '线上订单号', dataIndex: 'soId' },
{ title: '店铺', dataIndex: 'shopName' },
{ title: '仓储中心', dataIndex: 'centerName' },
{ title: '发货仓', dataIndex: 'warehouseName' },
{ title: '快递公司', dataIndex: 'logisticCompany', exportValue: (v) => v || '未指定' },
{ title: '运单号', dataIndex: 'logisticId', exportValue: (v) => v || '未打单' },
{ title: '物流状态', dataIndex: 'logisticStatus' },
{ title: '发货状态', dataIndex: 'state' },
{ title: '发货时间', dataIndex: 'sendTime', exportValue: (v) => v || '未发货' },
{
title: '审核时间',
dataIndex: 'auditTime',
// 起算点 = 审核时间;没取到时回退订单创建时间,导出用 `*` 标出来,否则对账对不上
exportValue: (v, row) => {
const t = v || row?.benchmarkTime || '';
if (!t) return '无审核时间';
return row?.benchmarkSource === 'created' ? `${t} *` : t;
},
},
{ title: '下单时间', dataIndex: 'createdAt', exportValue: (v) => v || '—' },
{ title: '付款时间', dataIndex: 'payTime' },
// 分钟数给一列原始值,业务在 Excel 里能直接排序/筛选;人读的那列再格式化
{ title: '已等(分钟)', dataIndex: 'overdueMinutes' },
{ title: '已等时长', dataIndex: 'overdueMinutes', exportValue: (v) => formatOverdue(v) },
];
// key = 导出格式(tableExport 只支持这两种)
const EXPORT_MENU_ITEMS = [
{ key: 'xlsx', label: '导出 Excel(.xlsx)' },
{ key: 'csv', label: '导出 CSV(.csv)' },
];
// 文件名里不能出现 : \ / * ? " < > |,轮次用「13点轮」这种写法避开冒号
const roundFileText = (roundInfo) => (
Number.isFinite(Number(roundInfo?.verifyHour))
? `${String(Number(roundInfo.verifyHour)).padStart(2, '0')}点轮`
: '本轮'
);
/**
* 仓储中心发货时效(独立页面)
* ────────────────────────────────────────────────────────────────
* 业务口径(yanhui 2026-10-20 定轮次;2026-10-28 定起算点):
* · 11 个主仓,子仓并入主仓一起算;
* · 数据源 = 订单表 jst_Orders + jst_qmcust_orderlist(两张表店铺互斥,都要读);
* · 今天 07:00 前**审核**的订单 13:00 核验,截止今天 16:00 前审核的单 18:00 核验
* (含 7 点前审核未发出的、含今天之前审核至今未发的历史单;山东两仓 15:00、河南洛宁 13:00);
* 今天之前仍未发的(历史未发)两个轮次都算;
* **到核验时刻未发即超时**,没有「满 24 小时」门槛(业务纠偏点);
* 轮次归属和「已等时长」都按**审核时间**算 ——
* 业务 2026-10-28 下午三次定版:审核时间 = max(状态表 last_oa_confirm_time, 订单表 modified)。
* 只取状态表会漏 —— 状态表会滞后(9978643 状态表写的是 10-27 17:08,聚水潭真实审核 10-28 14:52,
* 整整早一天),导致「今天下午才审核的单」被算进 13:00 轮,冤枉仓库;
* 两者都没有才回退订单创建时间,页面上带 `*` 标记;
* · **13:00 之前不核验**,直接显示「未到核验时间」,不拿昨天的结果冒充今天;
* · 已出库 / 待出库以订单表 **send_date** 为准(SQL 直接 `send_date IS NULL` 才进候选);
* · 只显示超时未出库(发完的仓显示「—」),点仓库可筛右侧明细。
*
* 数据来自 /api/warehouse-ship-timeliness/list(service 层见
* backend/src/services/warehouseShipTimelinessService.js)。
*/
function WarehouseShipTimeliness() {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
// 选中的主仓:为空时右侧展示全部仓的超时明细
const [activeCenter, setActiveCenter] = useState('');
// 「业务挂起(疑问单)」明细弹窗
const [heldOpen, setHeldOpen] = useState(false);
// 「导出明细」按钮 loading(全量导出可能要走一次冷启动查询,必须给反馈)
const [exporting, setExporting] = useState(false);
// ── 钉钉通知(两轮核验完成后各推一次)──────────────────────────────────
const [notifyOpen, setNotifyOpen] = useState(false);
const [notifyLoading, setNotifyLoading] = useState(false);
const [notifySaving, setNotifySaving] = useState(false);
const [notifyRunning, setNotifyRunning] = useState(false);
const [notifyConfig, setNotifyConfig] = useState(null);
const [notifyForm, setNotifyForm] = useState(EMPTY_NOTIFY_FORM);
// 预览正文:放在弹窗内受控渲染(React 19 下 Modal.info 静态方法弹不出来)
const [notifyPreview, setNotifyPreview] = useState(null);
// force=true 时带 force=1 让后端绕过 5 分钟结果缓存重查库;
// 定时轮询走缓存(这张视图单次要几十秒,每轮都重查会把库压死)
const load = useCallback(async (force = false) => {
setLoading(true);
setError('');
try {
const result = await getWarehouseShipTimeliness({ limit: 1000, force: force ? 1 : 0 });
if (!result || result.success === false) {
setError(result?.error || '加载发货时效失败');
return;
}
setData(result.data || null);
} catch (loadError) {
setError(loadError?.response?.data?.error || loadError?.message || '加载发货时效失败');
} finally {
setLoading(false);
}
}, []);
useEffect(() => {
load();
const timer = window.setInterval(() => load(), AUTO_REFRESH_MS);
return () => window.clearInterval(timer);
}, [load]);
const centers = useMemo(() => (Array.isArray(data?.centers) ? data.centers : []), [data]);
const orders = useMemo(() => (Array.isArray(data?.orders) ? data.orders : []), [data]);
// 业务挂起(疑问单)—— 与 orders 互斥,两者相加才是待出库池
const heldOrders = useMemo(
() => (Array.isArray(data?.heldOrders) ? data.heldOrders : []),
[data]
);
const summary = data?.summary || {};
const round = data?.round || null;
const freshness = data?.freshness || null;
// 13:00 之前后端返回 round=null + notStarted=true:此时**不展示任何超时数字**
const notStarted = Boolean(data?.notStarted);
const hasRound = Boolean(round);
const cutoffText = String(round?.windowEnd || '').slice(11, 16);
const windowEndText = String(data?.window?.end || '').slice(11, 16);
// 仓级例外窗口:18:00 轮里 山东两仓 15:00、河南洛宁 13:00(业务 2026-10-20 指定)
const windowOverrides = Array.isArray(data?.window?.overrides) ? data.window.overrides : [];
const overrideText = windowOverrides
.map((o) => `${o.name} ${String(o.hour).padStart(2, '0')}:00`)
.join('、');
// 未到核验时间时的提示文案,全部由后端给,前端不写死时刻
const nextRoundText = String(data?.nextRoundAt || '').slice(11, 16) || '13:00';
const nextWindowEndText = String(data?.nextWindowEnd || '').slice(11, 16) || '07:00';
const activeCenterName = useMemo(() => {
if (!activeCenter) return '';
const hit = centers.find((c) => c.key === activeCenter);
return hit ? hit.name : activeCenter;
}, [activeCenter, centers]);
// 选中仓时,该仓的超时单数以 centers 里的统计为准(明细可能被截断)
const activeCenterRow = useMemo(
() => (activeCenter ? centers.find((c) => c.key === activeCenter) || null : null),
[activeCenter, centers]
);
const detailOrders = useMemo(() => (
activeCenter ? orders.filter((o) => o.centerKey === activeCenter) : orders
), [activeCenter, orders]);
// 明细真实总数(后端截断前):页面的「共 N 单」必须用它,
// 用 detailOrders.length 会把「已截断只显示前 1000 条」写成「一共就这么点」
const detailTotal = Number.isFinite(Number(data?.detailTotal))
? Number(data.detailTotal)
: detailOrders.length;
const heldTotal = Number.isFinite(Number(data?.heldTotal))
? Number(data.heldTotal)
: heldOrders.length;
// 不考核快递清单跟随后端(加/减快递只改服务层一处,别在前端写死)
const excludedCarrierText = (
Array.isArray(data?.excludedCarriers) && data.excludedCarriers.length
? data.excludedCarriers
: ['自提', '中铁', '壹米滴答', '武进安能']
).join(' / ');
// ── 导出「超时未发」明细 ─────────────────────────────────────────────────
/**
* 导出口径必须和页面明细一致,所以:
* · 数据源走 `/export`(后端同一个 getShipTimeliness,只是不按 limit 截断);
* · 选中仓时在前端按 centerKey 过滤,和后端算超时用的主仓归属是同一套。
* 🔥 不能直接导出页面上的 `orders` —— 它被 limit=1000 截断过,导出会少行,
* 而业务拿它去考核,少行比报错更危险。
*/
const handleExport = async (format) => {
setExporting(true);
try {
const result = await getWarehouseShipTimelinessExportRows({
round: round?.key || undefined,
});
if (!result || result.success === false) {
message.error(result?.error || '导出失败');
return;
}
const payload = result.data || {};
if (payload.notStarted) {
message.warning('本轮还没到核验时间,没有可导出的数据');
return;
}
const allRows = Array.isArray(payload.rows) ? payload.rows : [];
if (!allRows.length) {
message.warning('本轮没有超时未发订单,无需导出');
return;
}
const rows = activeCenter
? allRows.filter((row) => row.centerKey === activeCenter)
: allRows;
if (!rows.length) {
message.warning(`${activeCenterName || '该仓'}本轮没有超时未发订单`);
return;
}
const fileName = [
'仓储中心发货时效_超时未发',
activeCenter ? activeCenterName : '全部仓库',
roundFileText(payload.round || round),
payload.date || data?.date || dayjs().format('YYYY-MM-DD'),
].filter(Boolean).join('_');
await exportTableFile(format, fileName, EXPORT_COLUMNS, rows, '超时未发');
message.success(`已导出 ${rows.length} 单(${String(format).toUpperCase()})`);
} catch (exportError) {
message.error(exportError?.response?.data?.error || exportError?.message || '导出失败');
} finally {
setExporting(false);
}
};
// ── 钉钉通知:配置读写 / 预览 / 立即推送 ─────────────────────────────────
// 后端只回加签密钥掩码,所以表单里的 webhookSecret 永远是空的 —— 留空 = 沿用已存的
const applyNotifyConfig = useCallback((config) => {
setNotifyConfig(config || null);
setNotifyForm({
enabled: config?.enabled === true,
noonSendTime: config?.noonSendTime || '13:05',
afternoonSendTime: config?.afternoonSendTime || '18:05',
webhookUrl: config?.webhookUrl || '',
webhookSecret: '',
maxDetailRows: Number.isFinite(Number(config?.maxDetailRows))
? Number(config.maxDetailRows)
: 30,
atAll: config?.atAll === true,
pageUrl: config?.pageUrl || '',
});
}, []);
const openNotifySettings = useCallback(async () => {
setNotifyOpen(true);
setNotifyPreview(null);
setNotifyLoading(true);
try {
const result = await getShipTimelinessNotifySettings();
if (!result || result.success === false) {
message.error(result?.error || '读取发货时效通知配置失败');
return;
}
applyNotifyConfig(result.data);
} catch (loadError) {
message.error(loadError?.response?.data?.error || loadError?.message || '读取发货时效通知配置失败');
} finally {
setNotifyLoading(false);
}
}, [applyNotifyConfig]);
const buildNotifyPayload = useCallback(() => ({
enabled: notifyForm.enabled,
noonSendTime: notifyForm.noonSendTime,
afternoonSendTime: notifyForm.afternoonSendTime,
webhookUrl: String(notifyForm.webhookUrl || '').trim(),
webhookSecret: String(notifyForm.webhookSecret || '').trim(),
maxDetailRows: Number(notifyForm.maxDetailRows) || 0,
atAll: notifyForm.atAll === true,
pageUrl: String(notifyForm.pageUrl || '').trim(),
}), [notifyForm]);
const handleSaveNotify = async ({ silent = false } = {}) => {
setNotifySaving(true);
try {
const result = await saveShipTimelinessNotifySettings(buildNotifyPayload());
if (!result || result.success === false) {
message.error(result?.error || '保存发货时效通知配置失败');
return null;
}
applyNotifyConfig(result.data);
if (!silent) message.success('发货时效通知配置已保存');
return result.data;
} catch (saveError) {
message.error(saveError?.response?.data?.error || saveError?.message || '保存发货时效通知配置失败');
return null;
} finally {
setNotifySaving(false);
}
};
/**
* mode: 'dry' 预览正文(不发送)| 'probe' 只发一句通道测试 | 'send' 立即推送当前轮
* 都要先保存:否则「改完 webhook 直接点测试」会拿旧地址发,排错时会很迷惑。
*
* ⚠️ 预览**不能**用 `Modal.info` 静态方法:本项目跑 React 19,antd v5 的静态方法
* 拿不到 ConfigProvider context(控制台只给一行 warning),弹窗**静默不渲染**。
* 所以预览改成弹窗内的受控区块(notifyPreview)。
*/
const handleRunNotify = async (mode) => {
const saved = await handleSaveNotify({ silent: true });
if (!saved) return;
setNotifyRunning(true);
try {
const payload = mode === 'dry'
? { dryRun: true, force: true }
: { probe: mode === 'probe', force: true };
const result = await runShipTimelinessNotify(payload);
if (!result || result.success === false) {
message.error(result?.error || '推送到钉钉群失败');
return;
}
const info = result.data || {};
if (mode === 'dry') {
setNotifyPreview({
text: info.text || '',
rowCount: info.rowCount ?? 0,
listedCount: info.listedCount ?? 0,
bytes: info.bytes || 0,
truncated: info.truncated === true,
roundLabel: info.roundLabel || '',
});
message.success('已生成预览(未发送),正文见下方');
} else if (mode === 'probe') {
message.success('通道测试已发出,去钉钉群看有没有收到那条测试消息');
} else if (info.sent) {
setNotifyPreview(null);
message.success(`已推送到钉钉群(${info.roundLabel || info.round},超时 ${info.rowCount ?? 0} 单,列出 ${info.listedCount ?? 0} 条)`);
} else {
message.warning(`未推送:${NOTIFY_REASON_TEXT[info.reason] || info.reason || '未知原因'}`);
}
const latest = await getShipTimelinessNotifySettings();
if (latest?.data) applyNotifyConfig(latest.data);
} catch (runError) {
message.error(runError?.response?.data?.error || runError?.message || '推送到钉钉群失败');
} finally {
setNotifyRunning(false);
}
};
const notifyLastState = notifyConfig?.lastState || {};
const notifyNoonValue = useMemo(
() => (notifyForm.noonSendTime ? dayjs(notifyForm.noonSendTime, 'HH:mm') : null),
[notifyForm.noonSendTime]
);
const notifyAfternoonValue = useMemo(
() => (notifyForm.afternoonSendTime ? dayjs(notifyForm.afternoonSendTime, 'HH:mm') : null),
[notifyForm.afternoonSendTime]
);
return (
<SycmPage className="wst-page">
<header className="wst-header">
<Title level={3}>仓储中心发货时效(到点未发即超时)</Title>
<Text type="secondary">
按聚水潭订单表实时状态核验 11 个主仓是否在承诺时效内完成发货,只列超时未发货的单量。
{/* 2026-10-28 业务定:名字里不再出现「24 小时」—— 规则本身没有 24h 门槛,
原名会让 10-27 16:00 创建(只等了 21 小时)的单看着像「没到时限也被判超时」。*/}
</Text>
<Text type="secondary" className="wst-note">
每天 <b>13:00</b> 核验「<b>今天 07:00 前审核</b>」、<b>18:00</b> 核验「<b>截止 16:00 前审核</b>」、
到核验时刻仍未发货的订单;两个轮次都<b>包含今天之前审核、至今未发的历史未发单</b>
(18:00 轮也会带上 7 点前审核、13:00 还没发出的那批)—— 滚动待发池,不按自然日切。
13:00 之前不核验,显示「未到核验时间」。
<b>到点还没发就算超时 —— 不设「满 24 小时」门槛</b>(早上 7 点前那份单,13:00 还没走就是超时)。
<b>仓级例外</b>:18:00 轮里 <b>山东青岗集仓 / 山东品牌仓</b> 只看 <b>15:00 前审核</b>的单、
<b>河南洛宁仓</b> 只看 <b>13:00 前审核</b>的单(核验时刻仍是 18:00)。
<b>轮次与「已等时长」都按审核时间算</b>(= 状态表 last_oa_confirm_time 与订单表 modified 的较晚者:
审核才是仓库接到单的时刻,按下单时间算会把客服审核积压算到仓库头上;
状态表的审核时间会滞后,所以要和订单 modified 取较晚的那个);
明细并列「审核时间 / 下单时间 / 发货时间」,方便直接和聚水潭对账。
<b>已发 / 未发以订单表 send_date 为准</b>(有值即已发,SQL 侧直接过滤不进候选);
订单表 send_date 没回写、但状态表 send_time 有值的,也按已发剔除(不漏冤仓库)。
<b>已打单但还没揽收的</b>(聚水潭已生成运单号、发货时间还空着)会标成「已打单 · 未揽收」,
鼠标悬停能看到运单号 —— 这类单还留在列表里,等聚水潭回传发货时间才消失。
<b>{excludedCarrierText} 不考核</b>(客户自提、专线大件或加盟快运网点,揽收与在途仓库控制不了),
已按物流公司自动剔除。
<b>「待审核」和「异常」的单不计考核</b>(仓库还没接到或订单本身有问题),单独归入「不计考核」并给出明细;
<b>作废单(已取消,含发货前售后)不考核也不展示</b> —— 客户付款后取消的单仓库本就不该发。
</Text>
</header>
<Card className="wst-status" bordered={false}>
<div className="wst-status__row">
<div className="wst-status__round">
{hasRound ? (
<>
<span className="wst-status__badge">{round.label}</span>
<span className="wst-status__label">
核验今天 {cutoffText} 前审核的订单
</span>
<span className="wst-status__window">
含历史未发 · 到点未发即超时
{overrideText ? `(${overrideText} 为仓级例外)` : ''}
</span>
</>
) : (
<>
<span className="wst-status__badge wst-status__badge--idle">未到核验时间</span>
<span className="wst-status__label">
{nextRoundText} 开始首轮核验
(核验今天 {nextWindowEndText} 前审核的订单)
</span>
</>
)}
</div>
<Space size={8}>
{data?.generatedAt ? (
<Text type="secondary" className="wst-status__time">
数据更新于 {String(data.generatedAt).slice(11, 19)}
{data?.cached ? `(缓存 ${data.cacheAgeSec || 0}s,点刷新重查)` : ''}
</Text>
) : null}
<Button icon={<BellOutlined />} onClick={openNotifySettings}>钉钉通知</Button>
<Button icon={<ReloadOutlined />} onClick={() => load(true)} loading={loading}>刷新</Button>
</Space>
</div>
</Card>
{error ? (
<Alert
type="error"
showIcon
className="wst-alert"
message={error}
action={<Button size="small" onClick={load}>重试</Button>}
/>
) : null}
{freshness && (freshness.stale || freshness.coversDeadline === false) ? (
<Alert
// 快照没覆盖到核验时刻 → 数字必然偏大,用红色;只是滞后用黄色
type={freshness.coversDeadline === false ? 'error' : 'warning'}
showIcon
className="wst-alert"
message={freshness.coversDeadline === false ? '数据未覆盖本轮核验时刻,超时单量偏大' : '发货数据可能滞后'}
description={freshness.hint}
/>
) : null}
<div className="wst-stats">
<Card bordered={false} className="wst-stat">
<Statistic
title={(
<Tooltip title="到 13:00 / 18:00 核验时刻仍未发货的订单(按审核时间分轮),不设满 24 小时门槛">
<span>超时未发货</span>
</Tooltip>
)}
value={notStarted ? 0 : (summary.overdueUnshipped ?? 0)}
suffix="单"
formatter={(v) => (notStarted ? '—' : number(v))}
valueStyle={{ color: (summary.overdueUnshipped || 0) > 0 ? '#cf1322' : undefined }}
/>
</Card>
<Card
bordered={false}
className="wst-stat wst-stat--held"
onClick={() => setHeldOpen(true)}
>
<Statistic
title={(
<Tooltip title="待审核(订单状态 WaitConfirm,还没审单,仓库没接到)和订单异常(Question)的单。这类单不进仓库考核,点开看明细。">
<span>不计考核 <span className="wst-stat__more">明细</span></span>
</Tooltip>
)}
value={notStarted ? 0 : (summary.heldCount ?? 0)}
suffix="单"
formatter={(v) => (notStarted ? '—' : number(v))}
valueStyle={{ color: (summary.heldCount || 0) > 0 ? '#8c8c8c' : undefined }}
/>
</Card>
<Card bordered={false} className="wst-stat">
<Statistic
title="涉及仓库"
value={notStarted ? 0 : (summary.overdueCenterCount ?? 0)}
suffix="个"
formatter={(v) => (notStarted ? '—' : number(v))}
/>
</Card>
<Card bordered={false} className="wst-stat">
<Statistic
title="最久未发货"
value={notStarted ? 0 : (summary.oldestDays ?? 0)}
suffix="天"
formatter={(v) => (notStarted ? '—' : number(v))}
valueStyle={{ color: (summary.oldestDays || 0) >= 7 ? '#d46b08' : undefined }}
/>
</Card>
</div>
<div className="wst-body">
<Card
bordered={false}
className="wst-centers"
title="仓储中心"
extra={<Text type="secondary" className="wst-centers__hint">点仓库看明细</Text>}
>
<Spin spinning={loading && !data} size="small">
<ul className="wst-centers__list">
{centers.map((c) => {
const isActive = activeCenter === c.key;
const disabled = c.placeholder || notStarted;
return (
<li key={c.key}>
<Tooltip
placement="right"
title={c.placeholder
? '系统仓库表中暂无同名仓,待上游建仓后自动接入'
: notStarted
? `今日 ${nextRoundText} 首轮核验开始后才展示超时数据`
: `${c.name}:本轮核验 ${String(c.windowEnd || '').slice(11, 16) || windowEndText} 前审核的单,`
+ `超时未发货 ${c.overdueUnshipped} 单`
+ `${c.oldestDays > 0 ? `(最久已等 ${c.oldestDays} 天)` : ''}`
+ `${c.heldCount > 0 ? `\n另有不计考核(待审核/异常)${c.heldCount} 单` : ''}`
+ (c.warehouseCount > 1 ? `\n含子仓 ${c.warehouseCount} 个` : '')}
>
<button
type="button"
className={[
'wst-center',
isActive ? 'is-active' : '',
!c.overdueUnshipped ? 'is-empty' : '',
disabled ? 'is-disabled' : '',
].filter(Boolean).join(' ')}
onClick={() => {
if (disabled) return;
setActiveCenter(isActive ? '' : c.key);
}}
>
<span className="wst-center__name">{c.name}</span>
{c.placeholder ? (
<span className="wst-center__badge wst-center__badge--none">未接入</span>
) : (
<span className={`wst-center__badge${c.overdueUnshipped > 0 ? ' is-warn' : ''}`}>
{notStarted ? '—' : (c.overdueUnshipped > 0 ? c.overdueUnshipped : '—')}
</span>
)}
</button>
</Tooltip>
</li>
);
})}
</ul>
</Spin>
</Card>
<Card
bordered={false}
className="wst-detail"
title={(
<span>
超时未发货订单
<span className="wst-detail__scope">
{activeCenterName || '全部仓库'} · {activeCenter
? (activeCenterRow?.overdueUnshipped ?? detailOrders.length)
: detailTotal} 单
{!activeCenter && data?.truncated
? `(页面只显示前 ${data.detailLimit} 条,导出可拿全部 ${detailTotal} 条)`
: ''}
</span>
</span>
)}
extra={(
<Space size={8}>
{activeCenter ? (
<button type="button" className="wst-detail__clear" onClick={() => setActiveCenter('')}>
查看全部
</button>
) : null}
<Dropdown
trigger={['click']}
disabled={exporting || notStarted}
menu={{ items: EXPORT_MENU_ITEMS, onClick: ({ key }) => handleExport(key) }}
>
<Button size="small" icon={<DownloadOutlined />} loading={exporting}>
导出明细
</Button>
</Dropdown>
</Space>
)}
>
<Spin spinning={loading && !data}>
{notStarted ? (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={`未到核验时间,今日 ${nextRoundText} 开始首轮核验`}
/>
) : detailOrders.length ? (
<Table
rowKey={(r) => `${r.source}-${r.oId}`}
size="small"
pagination={{ pageSize: 20, size: 'small', showSizeChanger: false, showTotal: (t) => `共 ${t} 单` }}
dataSource={detailOrders}
columns={DETAIL_COLUMNS}
scroll={{ x: 1642 }}
/>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="本轮没有超时未发货的订单" />
)}
</Spin>
</Card>
</div>
<Modal
title={`不计考核(待审核 / 异常)· ${heldTotal} 单`}
open={heldOpen}
onCancel={() => setHeldOpen(false)}
footer={null}
width={1080}
destroyOnHidden
>
<Alert
type="info"
showIcon
className="wst-alert"
message="「待审核」= 订单状态还没审单(WaitConfirm),仓库根本没接到;「订单异常」= 聚水潭标记 Question(缺货/地址/风控等)。两类都不该算仓库超时,故单列于此。"
/>
{heldOrders.length ? (
<Table
rowKey={(r) => `${r.oId}`}
size="small"
pagination={{ pageSize: 10, size: 'small', showSizeChanger: false, showTotal: (t) => `共 ${t} 单` }}
dataSource={heldOrders}
columns={HELD_COLUMNS}
scroll={{ x: 1280 }}
/>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="本轮没有待审核 / 异常的单" />
)}
</Modal>
<Modal
title="发货时效通知 · 两轮核验完成后各推一次到钉钉群"
open={notifyOpen}
onCancel={() => setNotifyOpen(false)}
width={760}
destroyOnHidden
maskClosable={false}
styles={{ body: { maxHeight: '62vh', overflowY: 'auto' } }}
footer={[
<Button key="close" onClick={() => setNotifyOpen(false)}>关闭</Button>,
<Button key="probe" onClick={() => handleRunNotify('probe')} loading={notifyRunning} disabled={notifySaving}>
测试通道
</Button>,
<Button key="preview" onClick={() => handleRunNotify('dry')} loading={notifyRunning} disabled={notifySaving}>
预览正文
</Button>,
<Button key="save" onClick={() => handleSaveNotify()} loading={notifySaving}>保存</Button>,
<Button key="run" type="primary" onClick={() => handleRunNotify('send')} loading={notifyRunning} disabled={notifySaving}>
立即推送到群
</Button>,
]}
>
<Spin spinning={notifyLoading}>
<Space direction="vertical" size={12} style={{ width: '100%' }}>
<Alert
type={notifyConfig?.ready ? 'success' : 'warning'}
showIcon
message={notifyConfig?.ready
? `通道已配好:13:00 轮 → ${notifyForm.noonSendTime} 推、18:00 轮 → ${notifyForm.afternoonSendTime} 推(0 单超时也推,用来确认任务在跑)`
: 'Webhook 地址还没配,填好保存后点「测试通道」验一下'}
description={notifyConfig?.ready ? null : (
<span>
缺:<b>{(notifyConfig?.missingFields || []).join(' / ') || '(尚未读取)'}</b>
</span>
)}
/>
<div className="wst-notify__row">
<span className="wst-notify__label">开启推送</span>
<Switch
checked={notifyForm.enabled}
onChange={(checked) => setNotifyForm((old) => ({ ...old, enabled: checked }))}
checkedChildren="开"
unCheckedChildren="关"
/>
<Text type="secondary">关掉后定时任务不推,但「立即推送」仍可用(方便先试口径)</Text>
</div>
<div className="wst-notify__row">
<span className="wst-notify__label">13:00 轮</span>
<TimePicker
format="HH:mm"
value={notifyNoonValue}
allowClear={false}
minuteStep={5}
style={{ width: 96 }}
onChange={(value) => {
if (!value) return;
setNotifyForm((old) => ({ ...old, noonSendTime: value.format('HH:mm') }));
}}
/>
<Text type="secondary">核验「今天 07:00 前审核」的超时单,默认核验点 + 5 分钟</Text>
</div>
<div className="wst-notify__row">
<span className="wst-notify__label">18:00 轮</span>
<TimePicker
format="HH:mm"
value={notifyAfternoonValue}
allowClear={false}
minuteStep={5}
style={{ width: 96 }}
onChange={(value) => {
if (!value) return;
setNotifyForm((old) => ({ ...old, afternoonSendTime: value.format('HH:mm') }));
}}
/>
<Text type="secondary">核验「截止 16:00 前审核」的超时单(含历史未发),默认核验点 + 5 分钟</Text>
</div>
<div className="wst-notify__row">
<span className="wst-notify__label">Webhook</span>
<Input
value={notifyForm.webhookUrl}
placeholder="https://oapi.dingtalk.com/robot/send?access_token=xxxx"
onChange={(e) => setNotifyForm((old) => ({ ...old, webhookUrl: e.target.value }))}
style={{ flex: 1, minWidth: 380 }}
/>
</div>
<div className="wst-notify__row">
<span className="wst-notify__label">加签密钥</span>
<Input.Password
value={notifyForm.webhookSecret}
placeholder={notifyConfig?.webhookSecretConfigured
? `已保存 ${notifyConfig.webhookSecretPreview || ''},留空表示不修改`
: 'SEC 开头;安全设置选「关键词 / IP」时留空'}
onChange={(e) => setNotifyForm((old) => ({ ...old, webhookSecret: e.target.value }))}
style={{ flex: 1, minWidth: 320 }}
/>
</div>
<div className="wst-notify__row">
<span className="wst-notify__label">明细条数</span>
<InputNumber
min={0}
max={notifyConfig?.maxDetailRowsLimit || 50}
precision={0}
value={notifyForm.maxDetailRows}
onChange={(value) => setNotifyForm((old) => ({ ...old, maxDetailRows: value ?? 0 }))}
style={{ width: 96 }}
/>
<Text type="secondary">
消息里最多列几条明细(0 = 只发汇总,每仓保底 1 条);钉钉文本上限 20000 字节,超了会自动精简
</Text>
</div>
<div className="wst-notify__row">
<span className="wst-notify__label">@所有人</span>
<Switch
checked={notifyForm.atAll}
onChange={(checked) => setNotifyForm((old) => ({ ...old, atAll: checked }))}
checkedChildren="开"
unCheckedChildren="关"
/>
<Text type="secondary">打开后每轮超时都会 @所有人(0 单超时也会推一条平安消息)</Text>
</div>
<div className="wst-notify__row">
<span className="wst-notify__label">页面链接</span>
<Input
value={notifyForm.pageUrl}
placeholder="消息末尾「查看全部」用的地址(留空用默认生产地址)"
onChange={(e) => setNotifyForm((old) => ({ ...old, pageUrl: e.target.value }))}
style={{ flex: 1, minWidth: 380 }}
/>
</div>
{notifyPreview ? (
<div className="wst-notify__preview">
<div className="wst-notify__preview-head">
<Text type="secondary">
{notifyPreview.roundLabel || '预览'}
{' '}| 超时 <b>{notifyPreview.rowCount}</b> 单
{' '}| 消息里列出 <b>{notifyPreview.listedCount}</b> 条
{' '}| {Math.round((notifyPreview.bytes / 1024) * 10) / 10} KB
{notifyPreview.truncated ? '(超长已精简)' : ''}
</Text>
<Button type="link" size="small" onClick={() => setNotifyPreview(null)}>收起</Button>
</div>
<pre>{notifyPreview.text || '(消息正文为空)'}</pre>
</div>
) : null}
<div className="wst-notify__last">
<Text type="secondary">
上次推送:
{notifyLastState.lastSentAt
? <> {String(notifyLastState.lastSentAt).slice(0, 10)} {String(notifyLastState.lastSentAt).slice(11, 19)}
{' '}· {notifyLastState.lastRoundLabel || notifyLastState.lastRound || '—'}
{' '}· 超时 {notifyLastState.rowCount ?? 0} 单
{' '}· 列出 {notifyLastState.listedCount ?? '—'} 条
{notifyLastState.truncated ? '(超长已精简)' : ''}</>
: ' 还没有成功推送记录'}
</Text>
{notifyLastState.lastError ? (
<div className="wst-notify__error">
<Text type="danger">最近一次失败:{String(notifyLastState.lastError).slice(0, 300)}</Text>
</div>
) : null}
</div>
<Collapse size="small" items={NOTIFY_HELP_ITEMS} />
</Space>
</Spin>
</Modal>
<Text type="secondary" className="wst-foot">
说明:数据源 = 聚水潭<b>订单表 jst_Orders + jst_qmcust_orderlist</b>(两张表店铺互斥,按 o_id 去重)。
<b>今天 7:00 前审核</b>的订单 13:00 核验;<b>截止 16:00 前审核</b>的单 18:00 核验
(含 7 点前审核、13:00 还没发出的,也含今天之前审核至今未发的历史单)。
<b>到点仍未发货即超时</b>(不设「满 24 小时」门槛);
轮次与「已等时长」都按<b>审核时间</b>算(= 状态表 last_oa_confirm_time 与订单表 modified 的较晚者,
审核才是仓库接到单的时刻;状态表会滞后,故取较晚者)。两者都取不到才回退订单创建时间,列上带 <b>*</b>。
发货 = 订单表 send_date(为空才算未发,但状态表 send_time 有值的也判已发);状态只取「发货中」。
<b>作废单不考核</b>(labels 含「发货前售后」= 客户发货前取消)
{summary.voidCount > 0 ? ` —— 本轮已自动剔除 ${summary.voidCount} 单` : ''};
<b>{excludedCarrierText}不考核</b>
{summary.carrierSkipped > 0 ? ` —— 本轮已剔除 ${summary.carrierSkipped} 单` : ''};
待审核、订单异常的单归入「不计考核」,避免冤枉仓库。
</Text>
</SycmPage>
);
}
export default WarehouseShipTimeliness;