feat(consignment): 寄卖配置价格/匹配/超时/收货字段全面改造

- 价格:固定价格改为模板价固定下调,移除绝对固定价;没有模板价时统一阻止发布
- 配置面板:按下拉选项动态显隐,超时与降价提示拆成两张卡片,超时单位改为小时(默认 0.5)
- 匹配:新增关闭匹配并设为默认,移除自动匹配开关;关闭后新单直接进大厅
- 超时:新增重新匹配退/扣押金,回内部匹配池并排除原卖家与原库存(迁移 147)
- 日志:新增 consignment_match_logs,自动/手动匹配成功、失败、跳过统一留痕,后台新增匹配日志抽屉
- 打手端:顶部分类下拉替换多 tab,默认苏尔南手枪;联系方式与游戏凭据改为动态字段(默认 7 项,手机号必填)
- 降价提示默认开启、默认 24 小时
This commit is contained in:
2026-11-06 13:32:24 +08:00
parent e0a85359b6
commit 3aa01136a5
31 changed files with 2311 additions and 568 deletions
@@ -0,0 +1,196 @@
import { ReloadOutlined } from '@ant-design/icons'
import { useQuery } from '@tanstack/react-query'
import { Input, Modal, Select, Space, Tag, Typography } from 'antd'
import { useState } from 'react'
import PercentTable from '@/components/common/PercentTable'
import { fetchAdminConsignmentMatchLogs } from '@/services/admin/consignment'
import type { ConsignmentMatchLogItem } from '@/types/consignment-match-log'
import { formatDateTime } from '@/utils/date-time'
const { Text } = Typography
const TRIGGER_LABELS: Record<string, string> = {
auto: '自动匹配',
manual: '手动匹配',
rematch: '重新匹配',
}
const RESULT_LABELS: Record<string, { label: string; color: string }> = {
matched: { label: '已匹配', color: 'green' },
failed: { label: '失败', color: 'red' },
skipped: { label: '跳过', color: 'default' },
}
const PAGE_SIZE = 20
export default function ConsignmentMatchLogsModal({
open,
onClose,
}: {
open: boolean
onClose: () => void
}) {
const [page, setPage] = useState(1)
const [triggerType, setTriggerType] = useState<string | undefined>()
const [result, setResult] = useState<string | undefined>()
const [keyword, setKeyword] = useState('')
const [keywordInput, setKeywordInput] = useState('')
const logsQuery = useQuery({
queryKey: ['admin-consignment-match-logs', page, triggerType, result, keyword],
queryFn: () =>
fetchAdminConsignmentMatchLogs({
page,
pageSize: PAGE_SIZE,
triggerType,
result,
keyword: keyword || undefined,
}),
enabled: open,
})
const data = logsQuery.data?.data
const items = data?.items || []
const total = Number(data?.total || 0)
const columns = [
{
title: '时间',
dataIndex: 'createdAt',
width: 160,
render: (value: string) => (value ? formatDateTime(value) : '-'),
},
{
title: '工单',
dataIndex: 'workOrderNo',
width: 150,
render: (_: string, record: ConsignmentMatchLogItem) =>
record.workOrderNo || (record.workOrderId ? `#${record.workOrderId}` : '-'),
},
{
title: '触发',
dataIndex: 'triggerType',
width: 100,
render: (value: string) => (
<Tag color={value === 'manual' ? 'blue' : value === 'rematch' ? 'orange' : 'purple'}>
{TRIGGER_LABELS[value] || value}
</Tag>
),
},
{
title: '结果',
dataIndex: 'result',
width: 90,
render: (value: string) => {
const config = RESULT_LABELS[value] || { label: value, color: 'default' }
return <Tag color={config.color}>{config.label}</Tag>
},
},
{
title: '候选 / 成功',
width: 100,
render: (_: unknown, record: ConsignmentMatchLogItem) =>
`${record.candidateCount} / ${record.matchedCount}`,
},
{
title: '原因',
dataIndex: 'reasonText',
render: (value: string, record: ConsignmentMatchLogItem) => (
<div style={{ display: 'grid', gap: 2 }}>
<Text>{value || '-'}</Text>
{record.reasonCode ? (
<Text type="secondary" style={{ fontSize: 12 }}>
{record.reasonCode}
</Text>
) : null}
</div>
),
},
{
title: '操作人',
dataIndex: 'actorId',
width: 120,
render: (value: string, record: ConsignmentMatchLogItem) =>
record.actorType === 'system' ? '系统' : value || '-',
},
{
title: '耗时',
dataIndex: 'durationMs',
width: 80,
render: (value: number) => `${Number(value || 0)} ms`,
},
]
return (
<Modal
title="寄卖匹配日志"
open={open}
onCancel={onClose}
footer={null}
width={1080}
destroyOnClose
>
<Space wrap style={{ marginBottom: 12 }}>
<Select
allowClear
placeholder="触发方式"
style={{ width: 130 }}
value={triggerType}
onChange={(value) => {
setTriggerType(value)
setPage(1)
}}
options={[
{ value: 'auto', label: '自动匹配' },
{ value: 'manual', label: '手动匹配' },
{ value: 'rematch', label: '重新匹配' },
]}
/>
<Select
allowClear
placeholder="结果"
style={{ width: 120 }}
value={result}
onChange={(value) => {
setResult(value)
setPage(1)
}}
options={[
{ value: 'matched', label: '已匹配' },
{ value: 'failed', label: '失败' },
{ value: 'skipped', label: '跳过' },
]}
/>
<Input.Search
allowClear
placeholder="搜索工单号"
style={{ width: 220 }}
value={keywordInput}
onChange={(event) => setKeywordInput(event.target.value)}
onSearch={(value) => {
setKeyword(value.trim())
setPage(1)
}}
/>
<Text type="secondary">共 {total} 条</Text>
<ReloadOutlined style={{ cursor: 'pointer' }} onClick={() => void logsQuery.refetch()} />
</Space>
<PercentTable<ConsignmentMatchLogItem>
size="small"
rowKey="logId"
loading={logsQuery.isFetching}
dataSource={items}
columns={columns}
scroll={{ x: 820 }}
pagination={{
current: page,
pageSize: PAGE_SIZE,
total,
showSizeChanger: false,
onChange: (nextPage) => setPage(nextPage),
}}
/>
</Modal>
)
}