修复(寄卖): 恢复待抢单手枪简单匹配看板
This commit is contained in:
@@ -1,76 +1,40 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { ReloadOutlined } from '@ant-design/icons'
|
||||
import { Alert, Button, Empty, Input, Modal, Space, Tag, Typography } from 'antd'
|
||||
import { Alert, Button, Checkbox, Empty, Input, Modal, Space, Tag, Typography } from 'antd'
|
||||
import type { TableColumnsType } from 'antd'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
|
||||
import PercentTable from '@/components/common/PercentTable'
|
||||
import { fetchPendingPistolMatches } from '@/services/admin/consignment'
|
||||
import type { PendingPistolMatchPair } from '@/types/consignment'
|
||||
import { formatFenMoney } from '@/utils/consignment-payment-price-diff'
|
||||
import { fetchPendingSuernanPistolMatches } from '@/services/admin/consignment'
|
||||
import type { PendingSuernanPistolMatchPair } from '@/types/consignment'
|
||||
import { formatDateTime } from '@/utils/date-time'
|
||||
import { resolveConsignmentPriorityTagColor } from '@/utils/consignment-match-priority'
|
||||
|
||||
import ConsignmentPriceWithDiff from './ConsignmentPriceWithDiff'
|
||||
import ConsignmentWorkOrderMatchModal from './ConsignmentWorkOrderMatchModal'
|
||||
|
||||
const { Text } = Typography
|
||||
|
||||
function resolveScoreTag(pair: PendingPistolMatchPair) {
|
||||
if (pair.quantitySufficient === false) return { color: 'orange', label: '数量不足' }
|
||||
if (pair.matchType === 'exact') {
|
||||
return pair.autoMatchable === false
|
||||
? { color: 'gold', label: '需人工' }
|
||||
: { color: 'green', label: '精确' }
|
||||
}
|
||||
function resolveScoreTag(pair: PendingSuernanPistolMatchPair) {
|
||||
if (pair.matchType === 'exact') return { color: 'green', label: '精确' }
|
||||
if (pair.matchType === 'conflict') return { color: 'default', label: '不匹配' }
|
||||
if (pair.autoMatchable) return { color: 'blue', label: '可自动' }
|
||||
if (pair.score >= 90) return { color: 'blue', label: '非精确' }
|
||||
if (pair.score >= 70) return { color: 'orange', label: '非精确' }
|
||||
return { color: 'gold', label: '需核对' }
|
||||
}
|
||||
|
||||
function resolveOrderStatusTag(status?: string) {
|
||||
if (status === 'internal_matching') return { color: 'purple', label: '内部匹配中' }
|
||||
if (status === 'unassigned') return { color: 'default', label: '待分配' }
|
||||
return { color: 'blue', label: '待抢单' }
|
||||
}
|
||||
|
||||
export default function ConsignmentPendingMatchModal({
|
||||
open,
|
||||
onClose,
|
||||
categoryId,
|
||||
categoryName,
|
||||
categoryParentName,
|
||||
canMatch = false,
|
||||
onMatched,
|
||||
}: {
|
||||
open: boolean
|
||||
onClose: () => void
|
||||
/** 只统计该寄卖分类;不传 = 全部 */
|
||||
categoryId?: number | null
|
||||
categoryName?: string
|
||||
/** 二级分类的上级分类名:用于说明「会带上上级同系列库存」 */
|
||||
categoryParentName?: string
|
||||
/** 有 consignment.fulfill 权限时才显示「选择」列 */
|
||||
canMatch?: boolean
|
||||
/** 快速匹配成功后通知外层刷新库存 */
|
||||
onMatched?: () => void
|
||||
}) {
|
||||
const [keyword, setKeyword] = useState('')
|
||||
const [selectTarget, setSelectTarget] = useState<{
|
||||
workOrderId: number
|
||||
inventoryId: number
|
||||
} | null>(null)
|
||||
const [includeConflicts, setIncludeConflicts] = useState(false)
|
||||
|
||||
const query = useQuery({
|
||||
queryKey: ['admin-pending-pistol-matches', categoryId ?? null, keyword],
|
||||
queryKey: ['admin-pending-suernan-pistol-matches', keyword, includeConflicts],
|
||||
queryFn: () =>
|
||||
fetchPendingPistolMatches({
|
||||
categoryId: categoryId ?? undefined,
|
||||
fetchPendingSuernanPistolMatches({
|
||||
keyword,
|
||||
// 默认展示全部配对:冲突项(0 分)也要能看到,便于人工核对。
|
||||
includeConflicts: true,
|
||||
includeConflicts,
|
||||
limit: 300,
|
||||
}),
|
||||
enabled: open,
|
||||
@@ -78,11 +42,9 @@ export default function ConsignmentPendingMatchModal({
|
||||
retry: false,
|
||||
})
|
||||
const data = query.data?.data
|
||||
// 后端已按「分数 + 系列/钻石/璀璨优先级」排好序;这里必须保持原顺序,
|
||||
// 否则同分项会被重排回默认序,枪型匹配的候选反而沉底。
|
||||
const pairs = useMemo(() => data?.pairs || [], [data?.pairs])
|
||||
const pairs = data?.pairs || []
|
||||
|
||||
const columns: TableColumnsType<PendingPistolMatchPair> = [
|
||||
const columns: TableColumnsType<PendingSuernanPistolMatchPair> = [
|
||||
{
|
||||
title: '匹配打分',
|
||||
key: 'score',
|
||||
@@ -138,30 +100,6 @@ export default function ConsignmentPendingMatchModal({
|
||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||
录单 {record.workOrderCreatedAt ? formatDateTime(record.workOrderCreatedAt) : '-'}
|
||||
</Text>
|
||||
<Space size={4} wrap>
|
||||
<Tag
|
||||
color={resolveOrderStatusTag(record.workOrderStatus).color}
|
||||
style={{ marginInlineEnd: 0 }}
|
||||
>
|
||||
{resolveOrderStatusTag(record.workOrderStatus).label}
|
||||
</Tag>
|
||||
{Number(record.totalQuantity || 1) > 1 ? (
|
||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||
拼单剩余 {record.remainingQuantity ?? 0} / {record.totalQuantity} 份
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
{Number(record.requiredQuantity || 0) > 0 ? (
|
||||
<Text
|
||||
type={record.quantitySufficient === false ? 'danger' : 'secondary'}
|
||||
style={{ fontSize: 11 }}
|
||||
>
|
||||
{record.sharingEnabled
|
||||
? `拼单还需 ${record.requiredQuantity} 份 / 该库存剩 ${record.availableQuantity ?? '-'} 件`
|
||||
: `需求 ${record.requiredQuantity} 件 / 该库存剩 ${record.availableQuantity ?? '-'} 件`}
|
||||
{record.quantitySufficient === false ? '(整单汇总不足)' : ''}
|
||||
</Text>
|
||||
) : null}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -221,93 +159,28 @@ export default function ConsignmentPendingMatchModal({
|
||||
</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '工单用户付款金额',
|
||||
key: 'userPayment',
|
||||
width: 140,
|
||||
render: (_, record) => (
|
||||
<Text style={{ fontSize: 13 }}>{formatFenMoney(record.userPaymentFen)}</Text>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '售价',
|
||||
key: 'salePrice',
|
||||
width: 180,
|
||||
render: (_, record) => (
|
||||
<ConsignmentPriceWithDiff
|
||||
userPaymentFen={record.userPaymentFen}
|
||||
salePriceFen={record.salePriceFen}
|
||||
sharingEnabled={record.sharingEnabled}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '匹配说明',
|
||||
key: 'reason',
|
||||
width: 300,
|
||||
render: (_, record) => (
|
||||
<Space direction="vertical" size={2}>
|
||||
{record.priorityLabel ? (
|
||||
<Tag
|
||||
color={resolveConsignmentPriorityTagColor(record.priorityLabel)}
|
||||
style={{ marginInlineEnd: 0, fontSize: 11 }}
|
||||
>
|
||||
{record.priorityLabel}
|
||||
</Tag>
|
||||
) : null}
|
||||
<Text style={{ fontSize: 12 }}>{record.reason || '-'}</Text>
|
||||
{record.conflicts.length > 0 ? (
|
||||
<Text type="danger" style={{ fontSize: 11 }}>
|
||||
{record.conflicts.join(';')}
|
||||
</Text>
|
||||
) : null}
|
||||
{(record.matchDetails || [])
|
||||
.filter((detail) => detail.status !== 'match' && detail.status !== 'ignored')
|
||||
.slice(0, 4)
|
||||
.map((detail) => (
|
||||
<Text key={detail.key} type="secondary" style={{ fontSize: 11 }}>
|
||||
{detail.label}:订单「{detail.orderValue || '-'}」/ 库存「
|
||||
{detail.inventoryValue || '-'}」
|
||||
</Text>
|
||||
))}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
...(canMatch
|
||||
? [
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 100,
|
||||
render: (_: unknown, record: PendingPistolMatchPair) => (
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
ghost
|
||||
onClick={() =>
|
||||
setSelectTarget({
|
||||
workOrderId: record.workOrderId,
|
||||
inventoryId: record.inventoryId,
|
||||
})
|
||||
}
|
||||
>
|
||||
选择
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
]
|
||||
: []),
|
||||
]
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={
|
||||
categoryName
|
||||
? `匹配 · ${categoryName} 待匹配订单 × 在库现货`
|
||||
: '匹配 · 待匹配订单 × 在库现货'
|
||||
}
|
||||
title="匹配 · 待抢单手枪 × 在库现货"
|
||||
open={open}
|
||||
width="min(1480px, 96vw)"
|
||||
width="min(1320px, 94vw)"
|
||||
footer={null}
|
||||
destroyOnHidden
|
||||
onCancel={onClose}
|
||||
@@ -316,34 +189,17 @@ export default function ConsignmentPendingMatchModal({
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message={
|
||||
categoryName
|
||||
? `只统计「${categoryName}」分类下的待匹配订单 × 在库待匹配现货。`
|
||||
: '按寄卖配置匹配全部待匹配订单 × 在库待匹配现货。'
|
||||
}
|
||||
description={
|
||||
categoryParentName
|
||||
? `「${categoryName}」是二级分类:会连同上级「${categoryParentName}」中同系列的库存一起匹配(跨枪型不参与)。同规格同分时按录单时间先后排序,录单越早越靠前。${
|
||||
canMatch
|
||||
? '点「选择」会打开手动匹配并预选该库存,确认后直接占用库存。'
|
||||
: '当前账号没有履约权限,只能查看。'
|
||||
}`
|
||||
: canMatch
|
||||
? '默认展示全部配对,按 枪型 → 钻石 → 璀璨 排序:完美匹配在前,同钻高璀/高钻同璀/高钻高璀次之;跨枪型不展示;同规格同分时按录单时间先后排序,录单越早越靠前。点「选择」会打开手动匹配并预选该库存,确认后直接占用库存。数量不足或规格不匹配时需要人工补选。'
|
||||
: '默认展示全部配对,按 枪型 → 钻石 → 璀璨 排序,同规格同分时录单越早越靠前;当前账号没有履约权限,只能查看。'
|
||||
}
|
||||
message="只查询非拼单的待抢单手枪单 × 在库待匹配手枪现货,不直接改单。"
|
||||
description="分数 0-100:系统 20 / 区服 20 / 系列 20 / 钻级 25 / 璀璨 15。同分时录单更早的订单优先。"
|
||||
/>
|
||||
|
||||
<Space wrap size={12}>
|
||||
{categoryName ? <Tag color="blue">分类:{categoryName}</Tag> : null}
|
||||
<Tag>待匹配 {data?.pendingOrderCount ?? 0} 单</Tag>
|
||||
<Tag>待抢单 {data?.pendingOrderCount ?? 0} 单</Tag>
|
||||
<Tag>在库待匹配 {data?.inStockInventoryCount ?? 0} 件</Tag>
|
||||
<Tag color="blue">匹配组合 {data?.pairCount ?? 0} 条</Tag>
|
||||
<Tag color="green">精确 {data?.exactCount ?? 0}</Tag>
|
||||
<Tag color="orange">非精确 {data?.partialCount ?? 0}</Tag>
|
||||
<Tag color="purple">数量不足 {data?.quantityShortCount ?? 0}</Tag>
|
||||
<Tag color="cyan">可自动 {data?.autoMatchableCount ?? 0}</Tag>
|
||||
<Tag>不匹配 {data?.conflictCount ?? 0}</Tag>
|
||||
{includeConflicts ? <Tag>不匹配 {data?.conflictCount ?? 0}</Tag> : null}
|
||||
</Space>
|
||||
|
||||
<Space wrap size={12}>
|
||||
@@ -353,6 +209,12 @@ export default function ConsignmentPendingMatchModal({
|
||||
style={{ width: 420 }}
|
||||
onSearch={(value) => setKeyword(value.trim())}
|
||||
/>
|
||||
<Checkbox
|
||||
checked={includeConflicts}
|
||||
onChange={(event) => setIncludeConflicts(event.target.checked)}
|
||||
>
|
||||
显示 0 分不匹配项
|
||||
</Checkbox>
|
||||
<Button
|
||||
icon={<ReloadOutlined />}
|
||||
loading={query.isFetching}
|
||||
@@ -379,36 +241,31 @@ export default function ConsignmentPendingMatchModal({
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<PercentTable<PendingPistolMatchPair>
|
||||
<PercentTable<PendingSuernanPistolMatchPair>
|
||||
rowKey={(record) => `${record.workOrderId}-${record.inventoryId}`}
|
||||
size="small"
|
||||
loading={query.isFetching}
|
||||
dataSource={pairs}
|
||||
columns={columns}
|
||||
scroll={{ x: 1680, y: 460 }}
|
||||
scroll={{ y: 460 }}
|
||||
pagination={{
|
||||
pageSize: 20,
|
||||
showSizeChanger: false,
|
||||
showTotal: (total) => `共 ${total} 条`,
|
||||
}}
|
||||
locale={{
|
||||
emptyText: <Empty description="当前分类下没有可匹配组合" />,
|
||||
emptyText: (
|
||||
<Empty
|
||||
description={
|
||||
includeConflicts
|
||||
? '没有可展示的配对'
|
||||
: '没有有效匹配;可勾选「显示 0 分不匹配项」查看冲突'
|
||||
}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</Space>
|
||||
<ConsignmentWorkOrderMatchModal
|
||||
key={
|
||||
selectTarget ? `${selectTarget.workOrderId}-${selectTarget.inventoryId}` : 'pending-match'
|
||||
}
|
||||
open={Boolean(selectTarget)}
|
||||
workOrderId={selectTarget?.workOrderId ?? null}
|
||||
initialInventoryIds={selectTarget ? [selectTarget.inventoryId] : undefined}
|
||||
onClose={() => setSelectTarget(null)}
|
||||
onMatched={() => {
|
||||
void query.refetch()
|
||||
onMatched?.()
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1641,17 +1641,10 @@ export default function ConsignmentInventoryPanel() {
|
||||
onMatched={() => void inventoriesQuery.refetch()}
|
||||
/>
|
||||
|
||||
{/* 全局匹配看板:按当前寄卖分类统计待抢单 × 在库待匹配现货 */}
|
||||
{/* 一键查询待匹配订单:简单只读的待抢单手枪 × 在库手枪看板 */}
|
||||
<ConsignmentPendingMatchModal
|
||||
open={pendingMatchOpen}
|
||||
categoryId={categoryId}
|
||||
categoryName={activeFilterCategory?.name}
|
||||
categoryParentName={
|
||||
activeFilterCategory?.parentId ? activeFilterCategory.parentName : undefined
|
||||
}
|
||||
canMatch={canFulfillConsignment}
|
||||
onClose={() => setPendingMatchOpen(false)}
|
||||
onMatched={() => void inventoriesQuery.refetch()}
|
||||
/>
|
||||
|
||||
<ConsignmentMatchLogsModal open={matchLogsOpen} onClose={() => setMatchLogsOpen(false)} />
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
ConsignmentStatsSummary,
|
||||
ConsignmentSubmission,
|
||||
InventoryMatchableOrders,
|
||||
PendingSuernanPistolMatchResult,
|
||||
PendingPistolMatchResult,
|
||||
WorkOrderInventoryMatchCheck,
|
||||
WorkOrderInventoryMatchOptions,
|
||||
@@ -268,7 +269,23 @@ export function fetchInventoryMatchableOrders(
|
||||
)
|
||||
}
|
||||
|
||||
/** 全局匹配看板:待匹配订单 × 在库待匹配现货,按细粒度评分排序。 */
|
||||
/** 一键查询待匹配订单:简单只读的待抢单苏尔南手枪 × 在库手枪。 */
|
||||
export function fetchPendingSuernanPistolMatches(params?: {
|
||||
keyword?: string
|
||||
includeConflicts?: boolean
|
||||
limit?: number
|
||||
}) {
|
||||
return apiGet<PendingSuernanPistolMatchResult>(
|
||||
'/api/v1/admin/worker-platform/consignment/pending-suernan-pistol-matches',
|
||||
{
|
||||
keyword: params?.keyword?.trim() || undefined,
|
||||
includeConflicts: params?.includeConflicts ? 'true' : undefined,
|
||||
limit: params?.limit,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/** 库存侧手动匹配:待匹配订单 × 在库待匹配现货,按完整匹配引擎评分。 */
|
||||
export function fetchPendingPistolMatches(params?: {
|
||||
/** 只统计该寄卖分类;不传 = 全部 */
|
||||
categoryId?: number
|
||||
|
||||
@@ -333,6 +333,35 @@ export type WorkOrderInventoryMatchCheck = {
|
||||
matches: ConsignmentMatchResult[]
|
||||
}
|
||||
|
||||
/** 后台「一键查询待匹配订单」:恢复为简单只读的待抢单手枪配对。 */
|
||||
export type PendingSuernanPistolMatchPair = {
|
||||
workOrderId: number
|
||||
workOrderNo: string
|
||||
platformOrderId: string
|
||||
productName: string
|
||||
workOrderCreatedAt: string | null
|
||||
inventoryId: number
|
||||
consignmentNo: string
|
||||
inventoryNo: string
|
||||
itemName: string
|
||||
inventoryInboundAt: string | null
|
||||
matchType: 'exact' | 'partial' | 'conflict'
|
||||
score: number
|
||||
reason: string
|
||||
conflicts: string[]
|
||||
}
|
||||
|
||||
export type PendingSuernanPistolMatchResult = {
|
||||
pendingOrderCount: number
|
||||
inStockInventoryCount: number
|
||||
pairCount: number
|
||||
exactCount: number
|
||||
partialCount: number
|
||||
conflictCount: number
|
||||
truncated: boolean
|
||||
pairs: PendingSuernanPistolMatchPair[]
|
||||
}
|
||||
|
||||
/** 后台「寄售仓库 → 匹配」:待抢单 × 在库待匹配现货的配对明细 */
|
||||
export type PendingPistolMatchPair = {
|
||||
workOrderId: number
|
||||
|
||||
Reference in New Issue
Block a user