feat(consignment): 匹配成功短信通知并支持模板配置

This commit is contained in:
2026-11-06 14:58:29 +08:00
parent 8b7bcca36a
commit 1044948c99
10 changed files with 539 additions and 15 deletions
@@ -1,5 +1,5 @@
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { App, Alert, Button, Card, Space, Switch, Typography } from 'antd'
import { App, Alert, Button, Card, Input, Space, Switch, Typography } from 'antd'
import PercentTable from '@/components/common/PercentTable'
import type { TableColumnsType } from 'antd'
import { useEffect, useState } from 'react'
@@ -74,6 +74,19 @@ export default function NotificationsPanel() {
})
}
function updateConsignmentSms(
patch: Partial<WorkerPlatformNotificationConfig['consignmentMatchSms']>,
) {
setDraft((current) =>
current
? {
...current,
consignmentMatchSms: { ...current.consignmentMatchSms, ...patch },
}
: current,
)
}
async function saveConfig() {
if (!draft) return
setSaving(true)
@@ -157,6 +170,53 @@ export default function NotificationsPanel() {
loading={configQuery.isLoading}
scroll={{ x: 660 }}
/>
<Card size="small" title="寄卖匹配成功短信">
<Space direction="vertical" size={12} style={{ width: '100%' }}>
<Alert
type="info"
showIcon
message="匹配成功后向寄卖人发送短信"
description="自动匹配、后台手动匹配与拼单份额匹配都会触发;同一工单同一库存只发送一次,短信失败不影响匹配结果。"
/>
<Space align="center" size={12}>
<Switch
checked={draft?.consignmentMatchSms?.enabled || false}
disabled={!draft || saving}
onChange={(checked) => updateConsignmentSms({ enabled: checked })}
/>
<Typography.Text>启用寄卖匹配成功短信</Typography.Text>
</Space>
<div>
<Typography.Text strong>短信模板</Typography.Text>
<Input.TextArea
value={draft?.consignmentMatchSms?.template || ''}
disabled={!draft || saving}
rows={3}
maxLength={300}
showCount
onChange={(event) => updateConsignmentSms({ template: event.target.value })}
style={{ marginTop: 6 }}
/>
<Typography.Text type="secondary">
可用变量:{'{itemName}'} 商品名、{'{quantity}'} 数量、{'{price}'} 成交价(元)、
{'{workOrderNo}'} 工单号、{'{inventoryNo}'} 寄卖单号、{'{sellerName}'} 卖家名。
</Typography.Text>
</div>
<div>
<Typography.Text strong>阿里云模板 Code(可选)</Typography.Text>
<Input
value={draft?.consignmentMatchSms?.templateCode || ''}
disabled={!draft || saving}
placeholder="如 SMS_123456789"
onChange={(event) => updateConsignmentSms({ templateCode: event.target.value })}
style={{ marginTop: 6 }}
/>
<Typography.Text type="secondary">
Mock 模式可留空;真实短信需填写阿里云审核通过的模板 Code,变量名需与模板一致。
</Typography.Text>
</div>
</Space>
</Card>
<Space>
<Button
type="primary"
@@ -313,6 +313,12 @@ export type WorkerPlatformNotificationEventKey =
| 'cancel_requested'
| 'feedback_submitted'
export type WorkerPlatformConsignmentMatchSmsConfig = {
enabled: boolean
template: string
templateCode: string
}
export type WorkerPlatformNotificationConfig = {
events: Record<
WorkerPlatformNotificationEventKey,
@@ -322,6 +328,7 @@ export type WorkerPlatformNotificationConfig = {
externalPushEnabled: boolean
}
>
consignmentMatchSms: WorkerPlatformConsignmentMatchSmsConfig
}
export type WorkerProductMatchConfig = {