合并(寄卖): 合入待抢单手枪简单匹配看板
This commit is contained in:
@@ -43,7 +43,10 @@ import {
|
|||||||
listInventoryMatchableOrders,
|
listInventoryMatchableOrders,
|
||||||
listWorkOrderInventoryMatchOptions,
|
listWorkOrderInventoryMatchOptions,
|
||||||
} from '../../../services/worker-platform/consignment-fulfillment-service.js'
|
} from '../../../services/worker-platform/consignment-fulfillment-service.js'
|
||||||
import { listPendingConsignmentMatches } from '../../../services/worker-platform/consignment-pending-match-service.js'
|
import {
|
||||||
|
listPendingConsignmentMatches,
|
||||||
|
listPendingSuernanPistolMatches,
|
||||||
|
} from '../../../services/worker-platform/consignment-pending-match-service.js'
|
||||||
import { listConsignmentMatchLogs } from '../../../services/worker-platform/consignment-match-log-service.js'
|
import { listConsignmentMatchLogs } from '../../../services/worker-platform/consignment-match-log-service.js'
|
||||||
import { buildTemplateSpecProposalForCategory } from '../../../services/worker-platform/consignment-template-spec-service.js'
|
import { buildTemplateSpecProposalForCategory } from '../../../services/worker-platform/consignment-template-spec-service.js'
|
||||||
import {
|
import {
|
||||||
@@ -405,7 +408,26 @@ router.post(
|
|||||||
|
|
||||||
// ---------------- 匹配与履约 ----------------
|
// ---------------- 匹配与履约 ----------------
|
||||||
|
|
||||||
// 全局待抢单匹配看板:按寄卖配置匹配待抢单工单 × 在库待匹配现货,只读。
|
// 一键查询待匹配订单:恢复为简单只读的待抢单苏尔南手枪看板。
|
||||||
|
router.get(
|
||||||
|
'/worker-platform/consignment/pending-suernan-pistol-matches',
|
||||||
|
requireAdminPermission('consignment.view'),
|
||||||
|
createJsonHandler(
|
||||||
|
(req) =>
|
||||||
|
listPendingSuernanPistolMatches({
|
||||||
|
keyword: String(req.query.keyword || ''),
|
||||||
|
includeConflicts: String(req.query.includeConflicts || '') === 'true',
|
||||||
|
limit: Number(req.query.limit || 0) || undefined,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
successMessage: 'ok',
|
||||||
|
errorMessage: '读取待匹配手枪订单失败',
|
||||||
|
scope: '[admin/consignment/pending-suernan-pistol-matches]',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// 库存侧手动匹配候选:按完整寄卖配置匹配待抢单工单 × 在库待匹配现货,只读。
|
||||||
router.get(
|
router.get(
|
||||||
'/worker-platform/consignment/pending-pistol-matches',
|
'/worker-platform/consignment/pending-pistol-matches',
|
||||||
requireAdminPermission('consignment.view'),
|
requireAdminPermission('consignment.view'),
|
||||||
|
|||||||
@@ -245,6 +245,18 @@ test('匹配看板:按分数降序,同分录单时间早的优先', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('匹配看板:在库待匹配件数按剩余数量统计,不按库存行数统计', () => {
|
||||||
|
const result = buildPendingPistolMatchPairs({
|
||||||
|
orders: [buildOrder()],
|
||||||
|
inventories: [
|
||||||
|
buildInventory({ id: 10, quantity: 3, remaining_quantity: 2 }),
|
||||||
|
buildInventory({ id: 11, quantity: 5, remaining_quantity: 4 }),
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
assert.equal(result.inStockInventoryCount, 6)
|
||||||
|
})
|
||||||
|
|
||||||
const BUILT_IN_SPECS = [
|
const BUILT_IN_SPECS = [
|
||||||
['system', '操作系统', 10],
|
['system', '操作系统', 10],
|
||||||
['serverZone', '游戏区服', 20],
|
['serverZone', '游戏区服', 20],
|
||||||
|
|||||||
@@ -49,25 +49,15 @@ export type PendingPistolMatchPair = {
|
|||||||
platformOrderId: string
|
platformOrderId: string
|
||||||
productName: string
|
productName: string
|
||||||
workOrderCreatedAt: string | null
|
workOrderCreatedAt: string | null
|
||||||
/** 工单用户付款金额(分);未知为 null */
|
|
||||||
userPaymentFen: number | null
|
|
||||||
inventoryId: number
|
inventoryId: number
|
||||||
consignmentNo: string
|
consignmentNo: string
|
||||||
inventoryNo: string
|
inventoryNo: string
|
||||||
itemName: string
|
itemName: string
|
||||||
/** 该库存售价(分):sale_price_fen 优先,缺失回退 cost_price_fen */
|
|
||||||
salePriceFen: number
|
|
||||||
inventoryInboundAt: string | null
|
inventoryInboundAt: string | null
|
||||||
matchType: 'exact' | 'partial' | 'conflict'
|
matchType: 'exact' | 'partial' | 'conflict'
|
||||||
score: number
|
score: number
|
||||||
reason: string
|
reason: string
|
||||||
conflicts: string[]
|
conflicts: string[]
|
||||||
/** 枪型 → 钻石 → 璀璨 的排序层级文案 */
|
|
||||||
priorityLabel: string
|
|
||||||
seriesMatched: boolean
|
|
||||||
seriesSpecified: boolean
|
|
||||||
diamondGap: number
|
|
||||||
brillianceGap: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PendingPistolMatchResult = {
|
export type PendingPistolMatchResult = {
|
||||||
@@ -147,7 +137,7 @@ export function buildPendingPistolMatchPairs(input: {
|
|||||||
serverZone: fields.serverZone,
|
serverZone: fields.serverZone,
|
||||||
series: fields.series,
|
series: fields.series,
|
||||||
})
|
})
|
||||||
return { order, specs, userPaymentFen: resolveUserPaymentAmountFenForDisplay(order) }
|
return { order, specs }
|
||||||
})
|
})
|
||||||
.filter(({ order, specs }) => {
|
.filter(({ order, specs }) => {
|
||||||
const text = [
|
const text = [
|
||||||
@@ -161,6 +151,7 @@ export function buildPendingPistolMatchPairs(input: {
|
|||||||
|
|
||||||
const preparedInventories = input.inventories.filter((inventory) => {
|
const preparedInventories = input.inventories.filter((inventory) => {
|
||||||
if (inventory.status !== 'in_stock' || inventory.allow_matching !== true) return false
|
if (inventory.status !== 'in_stock' || inventory.allow_matching !== true) return false
|
||||||
|
if (Number(inventory.remaining_quantity ?? 1) <= 0) return false
|
||||||
return (
|
return (
|
||||||
detectItemCategory(
|
detectItemCategory(
|
||||||
`${inventory.item_name} ${inventory.series || ''} ${inventory.category_name || ''}`,
|
`${inventory.item_name} ${inventory.series || ''} ${inventory.category_name || ''}`,
|
||||||
@@ -178,30 +169,10 @@ export function buildPendingPistolMatchPairs(input: {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const pairs: PendingPistolMatchPair[] = []
|
const pairs: PendingPistolMatchPair[] = []
|
||||||
for (const { order, specs, userPaymentFen } of preparedOrders) {
|
for (const { order, specs } of preparedOrders) {
|
||||||
const orderSeriesInfo = resolveOrderSeriesInfo({
|
|
||||||
categoryId: order.category_id,
|
|
||||||
productName: order.product_name,
|
|
||||||
parsedSeries: String(specs.series || ''),
|
|
||||||
})
|
|
||||||
for (const inventory of preparedInventories) {
|
for (const inventory of preparedInventories) {
|
||||||
const inventorySpecValues = resolveConsignmentInventorySpecValues(inventory)
|
|
||||||
if (isCrossSeriesInventory(orderSeriesInfo, String(inventorySpecValues.series || ''))) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
const scored = scoreConsignmentMatchDetails(specs, inventory)
|
const scored = scoreConsignmentMatchDetails(specs, inventory)
|
||||||
if (scored.matchType === 'conflict' && !includeConflicts) continue
|
if (scored.matchType === 'conflict' && !includeConflicts) continue
|
||||||
const priority = resolveConsignmentMatchPriorityFromSpecs({
|
|
||||||
orderValues: {
|
|
||||||
series: orderSeriesInfo.series,
|
|
||||||
diamondLevel: specs.diamondLevel,
|
|
||||||
brillianceCount: specs.brillianceCount,
|
|
||||||
},
|
|
||||||
inventoryValues: inventorySpecValues,
|
|
||||||
orderSeriesInfo,
|
|
||||||
exact: scored.matchType === 'exact',
|
|
||||||
fallbackConflict: scored.matchType === 'conflict',
|
|
||||||
})
|
|
||||||
|
|
||||||
const pair: PendingPistolMatchPair = {
|
const pair: PendingPistolMatchPair = {
|
||||||
workOrderId: Number(order.id),
|
workOrderId: Number(order.id),
|
||||||
@@ -209,12 +180,10 @@ export function buildPendingPistolMatchPairs(input: {
|
|||||||
platformOrderId: String(order.platform_order_id || ''),
|
platformOrderId: String(order.platform_order_id || ''),
|
||||||
productName: String(order.product_name || ''),
|
productName: String(order.product_name || ''),
|
||||||
workOrderCreatedAt: order.created_at ? String(order.created_at) : null,
|
workOrderCreatedAt: order.created_at ? String(order.created_at) : null,
|
||||||
userPaymentFen,
|
|
||||||
inventoryId: Number(inventory.id),
|
inventoryId: Number(inventory.id),
|
||||||
consignmentNo: String(inventory.source_submission_no || inventory.inventory_no || ''),
|
consignmentNo: String(inventory.source_submission_no || inventory.inventory_no || ''),
|
||||||
inventoryNo: String(inventory.inventory_no || ''),
|
inventoryNo: String(inventory.inventory_no || ''),
|
||||||
itemName: String(inventory.item_name || ''),
|
itemName: String(inventory.item_name || ''),
|
||||||
salePriceFen: inventorySalePriceFen(inventory),
|
|
||||||
inventoryInboundAt: inventory.inbound_at
|
inventoryInboundAt: inventory.inbound_at
|
||||||
? String(inventory.inbound_at)
|
? String(inventory.inbound_at)
|
||||||
: inventory.created_at
|
: inventory.created_at
|
||||||
@@ -224,11 +193,6 @@ export function buildPendingPistolMatchPairs(input: {
|
|||||||
score: scored.score,
|
score: scored.score,
|
||||||
reason: scored.reason,
|
reason: scored.reason,
|
||||||
conflicts: scored.conflicts,
|
conflicts: scored.conflicts,
|
||||||
priorityLabel: priority.priorityLabel,
|
|
||||||
seriesMatched: priority.seriesMatched,
|
|
||||||
seriesSpecified: priority.seriesSpecified,
|
|
||||||
diamondGap: priority.diamondGap,
|
|
||||||
brillianceGap: priority.brillianceGap,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyword && !buildPairHaystack(pair).includes(keyword)) continue
|
if (keyword && !buildPairHaystack(pair).includes(keyword)) continue
|
||||||
@@ -253,7 +217,10 @@ export function buildPendingPistolMatchPairs(input: {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
pendingOrderCount: preparedOrders.length,
|
pendingOrderCount: preparedOrders.length,
|
||||||
inStockInventoryCount: preparedInventories.length,
|
inStockInventoryCount: preparedInventories.reduce(
|
||||||
|
(sum, inventory) => sum + Math.max(0, Number(inventory.remaining_quantity ?? 1)),
|
||||||
|
0,
|
||||||
|
),
|
||||||
pairCount: pairs.length,
|
pairCount: pairs.length,
|
||||||
exactCount,
|
exactCount,
|
||||||
partialCount,
|
partialCount,
|
||||||
@@ -263,6 +230,64 @@ export function buildPendingPistolMatchPairs(input: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 旧版「待抢单手枪匹配」查询:完整读取全部 open 工单,不再只取最近 500 单。
|
||||||
|
* 看板本身仍是只读工具,不参与自动匹配或工单状态修改。
|
||||||
|
*/
|
||||||
|
async function listAllOpenWorkOrdersForPistolBoard(): Promise<WorkOrderRow[]> {
|
||||||
|
const pageSize = OPEN_ORDER_FETCH_LIMIT
|
||||||
|
const items: WorkOrderRow[] = []
|
||||||
|
let page = 1
|
||||||
|
let total = 0
|
||||||
|
|
||||||
|
do {
|
||||||
|
const result = await listWorkOrders({
|
||||||
|
statuses: [WORK_ORDER_STATUS.OPEN],
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
includeTotal: true,
|
||||||
|
sort: 'id_desc',
|
||||||
|
})
|
||||||
|
total = result.total
|
||||||
|
items.push(...result.items)
|
||||||
|
if (result.items.length === 0) break
|
||||||
|
page += 1
|
||||||
|
} while (items.length < total)
|
||||||
|
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台「寄售仓库 → 一键查询待匹配订单」的简单版。
|
||||||
|
*
|
||||||
|
* 固定口径:
|
||||||
|
* - 只查非拼单 open 工单;
|
||||||
|
* - 只查苏尔南手枪 × 在库手枪;
|
||||||
|
* - 使用内置五字段固定权重评分;
|
||||||
|
* - 默认隐藏冲突,允许操作者显式查看;
|
||||||
|
* - 查询全部 open 工单后再过滤,避免关键字只能命中最近一页。
|
||||||
|
*/
|
||||||
|
export async function listPendingSuernanPistolMatches(
|
||||||
|
input: {
|
||||||
|
keyword?: string | undefined
|
||||||
|
includeConflicts?: boolean | undefined
|
||||||
|
limit?: number | undefined
|
||||||
|
} = {},
|
||||||
|
): Promise<PendingPistolMatchResult> {
|
||||||
|
const [orders, inventories] = await Promise.all([
|
||||||
|
listAllOpenWorkOrdersForPistolBoard(),
|
||||||
|
listActiveConsignmentInventoriesForMatching(),
|
||||||
|
])
|
||||||
|
|
||||||
|
return buildPendingPistolMatchPairs({
|
||||||
|
orders,
|
||||||
|
inventories,
|
||||||
|
keyword: input.keyword,
|
||||||
|
includeConflicts: input.includeConflicts,
|
||||||
|
limit: input.limit,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export type PendingConsignmentMatchDetail = {
|
export type PendingConsignmentMatchDetail = {
|
||||||
key: string
|
key: string
|
||||||
label: string
|
label: string
|
||||||
@@ -273,6 +298,16 @@ export type PendingConsignmentMatchDetail = {
|
|||||||
|
|
||||||
/** 看板配对:在旧字段基础上补充规格明细、订单剩余数量与命中的寄卖配置。 */
|
/** 看板配对:在旧字段基础上补充规格明细、订单剩余数量与命中的寄卖配置。 */
|
||||||
export type PendingConsignmentMatchPair = PendingPistolMatchPair & {
|
export type PendingConsignmentMatchPair = PendingPistolMatchPair & {
|
||||||
|
/** 工单用户付款金额(分);未知为 null */
|
||||||
|
userPaymentFen: number | null
|
||||||
|
/** 该库存售价(分):sale_price_fen 优先,缺失回退 cost_price_fen */
|
||||||
|
salePriceFen: number
|
||||||
|
/** 枪型 → 钻石 → 璀璨的排序层级文案 */
|
||||||
|
priorityLabel: string
|
||||||
|
seriesMatched: boolean
|
||||||
|
seriesSpecified: boolean
|
||||||
|
diamondGap: number
|
||||||
|
brillianceGap: number
|
||||||
matchDetails: PendingConsignmentMatchDetail[]
|
matchDetails: PendingConsignmentMatchDetail[]
|
||||||
remainingQuantity: number
|
remainingQuantity: number
|
||||||
totalQuantity: number
|
totalQuantity: number
|
||||||
|
|||||||
@@ -1,76 +1,40 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { ReloadOutlined } from '@ant-design/icons'
|
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 type { TableColumnsType } from 'antd'
|
||||||
import { useMemo, useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
|
||||||
import PercentTable from '@/components/common/PercentTable'
|
import PercentTable from '@/components/common/PercentTable'
|
||||||
import { fetchPendingPistolMatches } from '@/services/admin/consignment'
|
import { fetchPendingSuernanPistolMatches } from '@/services/admin/consignment'
|
||||||
import type { PendingPistolMatchPair } from '@/types/consignment'
|
import type { PendingSuernanPistolMatchPair } from '@/types/consignment'
|
||||||
import { formatFenMoney } from '@/utils/consignment-payment-price-diff'
|
|
||||||
import { formatDateTime } from '@/utils/date-time'
|
import { formatDateTime } from '@/utils/date-time'
|
||||||
import { resolveConsignmentPriorityTagColor } from '@/utils/consignment-match-priority'
|
|
||||||
|
|
||||||
import ConsignmentPriceWithDiff from './ConsignmentPriceWithDiff'
|
|
||||||
import ConsignmentWorkOrderMatchModal from './ConsignmentWorkOrderMatchModal'
|
|
||||||
|
|
||||||
const { Text } = Typography
|
const { Text } = Typography
|
||||||
|
|
||||||
function resolveScoreTag(pair: PendingPistolMatchPair) {
|
function resolveScoreTag(pair: PendingSuernanPistolMatchPair) {
|
||||||
if (pair.quantitySufficient === false) return { color: 'orange', label: '数量不足' }
|
if (pair.matchType === 'exact') return { color: 'green', label: '精确' }
|
||||||
if (pair.matchType === 'exact') {
|
|
||||||
return pair.autoMatchable === false
|
|
||||||
? { color: 'gold', label: '需人工' }
|
|
||||||
: { color: 'green', label: '精确' }
|
|
||||||
}
|
|
||||||
if (pair.matchType === 'conflict') return { color: 'default', 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 >= 90) return { color: 'blue', label: '非精确' }
|
||||||
if (pair.score >= 70) return { color: 'orange', label: '非精确' }
|
if (pair.score >= 70) return { color: 'orange', label: '非精确' }
|
||||||
return { color: 'gold', 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({
|
export default function ConsignmentPendingMatchModal({
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
categoryId,
|
|
||||||
categoryName,
|
|
||||||
categoryParentName,
|
|
||||||
canMatch = false,
|
|
||||||
onMatched,
|
|
||||||
}: {
|
}: {
|
||||||
open: boolean
|
open: boolean
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
/** 只统计该寄卖分类;不传 = 全部 */
|
|
||||||
categoryId?: number | null
|
|
||||||
categoryName?: string
|
|
||||||
/** 二级分类的上级分类名:用于说明「会带上上级同系列库存」 */
|
|
||||||
categoryParentName?: string
|
|
||||||
/** 有 consignment.fulfill 权限时才显示「选择」列 */
|
|
||||||
canMatch?: boolean
|
|
||||||
/** 快速匹配成功后通知外层刷新库存 */
|
|
||||||
onMatched?: () => void
|
|
||||||
}) {
|
}) {
|
||||||
const [keyword, setKeyword] = useState('')
|
const [keyword, setKeyword] = useState('')
|
||||||
const [selectTarget, setSelectTarget] = useState<{
|
const [includeConflicts, setIncludeConflicts] = useState(false)
|
||||||
workOrderId: number
|
|
||||||
inventoryId: number
|
|
||||||
} | null>(null)
|
|
||||||
|
|
||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['admin-pending-pistol-matches', categoryId ?? null, keyword],
|
queryKey: ['admin-pending-suernan-pistol-matches', keyword, includeConflicts],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
fetchPendingPistolMatches({
|
fetchPendingSuernanPistolMatches({
|
||||||
categoryId: categoryId ?? undefined,
|
|
||||||
keyword,
|
keyword,
|
||||||
// 默认展示全部配对:冲突项(0 分)也要能看到,便于人工核对。
|
includeConflicts,
|
||||||
includeConflicts: true,
|
|
||||||
limit: 300,
|
limit: 300,
|
||||||
}),
|
}),
|
||||||
enabled: open,
|
enabled: open,
|
||||||
@@ -78,11 +42,9 @@ export default function ConsignmentPendingMatchModal({
|
|||||||
retry: false,
|
retry: false,
|
||||||
})
|
})
|
||||||
const data = query.data?.data
|
const data = query.data?.data
|
||||||
// 后端已按「分数 + 系列/钻石/璀璨优先级」排好序;这里必须保持原顺序,
|
const pairs = data?.pairs || []
|
||||||
// 否则同分项会被重排回默认序,枪型匹配的候选反而沉底。
|
|
||||||
const pairs = useMemo(() => data?.pairs || [], [data?.pairs])
|
|
||||||
|
|
||||||
const columns: TableColumnsType<PendingPistolMatchPair> = [
|
const columns: TableColumnsType<PendingSuernanPistolMatchPair> = [
|
||||||
{
|
{
|
||||||
title: '匹配打分',
|
title: '匹配打分',
|
||||||
key: 'score',
|
key: 'score',
|
||||||
@@ -138,30 +100,6 @@ export default function ConsignmentPendingMatchModal({
|
|||||||
<Text type="secondary" style={{ fontSize: 11 }}>
|
<Text type="secondary" style={{ fontSize: 11 }}>
|
||||||
录单 {record.workOrderCreatedAt ? formatDateTime(record.workOrderCreatedAt) : '-'}
|
录单 {record.workOrderCreatedAt ? formatDateTime(record.workOrderCreatedAt) : '-'}
|
||||||
</Text>
|
</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>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@@ -221,93 +159,28 @@ export default function ConsignmentPendingMatchModal({
|
|||||||
</Text>
|
</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: '匹配说明',
|
title: '匹配说明',
|
||||||
key: 'reason',
|
key: 'reason',
|
||||||
width: 300,
|
width: 300,
|
||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<Space direction="vertical" size={2}>
|
<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>
|
<Text style={{ fontSize: 12 }}>{record.reason || '-'}</Text>
|
||||||
{record.conflicts.length > 0 ? (
|
{record.conflicts.length > 0 ? (
|
||||||
<Text type="danger" style={{ fontSize: 11 }}>
|
<Text type="danger" style={{ fontSize: 11 }}>
|
||||||
{record.conflicts.join(';')}
|
{record.conflicts.join(';')}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : 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>
|
</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 (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={
|
title="匹配 · 待抢单手枪 × 在库现货"
|
||||||
categoryName
|
|
||||||
? `匹配 · ${categoryName} 待匹配订单 × 在库现货`
|
|
||||||
: '匹配 · 待匹配订单 × 在库现货'
|
|
||||||
}
|
|
||||||
open={open}
|
open={open}
|
||||||
width="min(1480px, 96vw)"
|
width="min(1320px, 94vw)"
|
||||||
footer={null}
|
footer={null}
|
||||||
destroyOnHidden
|
destroyOnHidden
|
||||||
onCancel={onClose}
|
onCancel={onClose}
|
||||||
@@ -316,34 +189,17 @@ export default function ConsignmentPendingMatchModal({
|
|||||||
<Alert
|
<Alert
|
||||||
type="info"
|
type="info"
|
||||||
showIcon
|
showIcon
|
||||||
message={
|
message="只查询非拼单的待抢单手枪单 × 在库待匹配手枪现货,不直接改单。"
|
||||||
categoryName
|
description="分数 0-100:系统 20 / 区服 20 / 系列 20 / 钻级 25 / 璀璨 15。同分时录单更早的订单优先。"
|
||||||
? `只统计「${categoryName}」分类下的待匹配订单 × 在库待匹配现货。`
|
|
||||||
: '按寄卖配置匹配全部待匹配订单 × 在库待匹配现货。'
|
|
||||||
}
|
|
||||||
description={
|
|
||||||
categoryParentName
|
|
||||||
? `「${categoryName}」是二级分类:会连同上级「${categoryParentName}」中同系列的库存一起匹配(跨枪型不参与)。同规格同分时按录单时间先后排序,录单越早越靠前。${
|
|
||||||
canMatch
|
|
||||||
? '点「选择」会打开手动匹配并预选该库存,确认后直接占用库存。'
|
|
||||||
: '当前账号没有履约权限,只能查看。'
|
|
||||||
}`
|
|
||||||
: canMatch
|
|
||||||
? '默认展示全部配对,按 枪型 → 钻石 → 璀璨 排序:完美匹配在前,同钻高璀/高钻同璀/高钻高璀次之;跨枪型不展示;同规格同分时按录单时间先后排序,录单越早越靠前。点「选择」会打开手动匹配并预选该库存,确认后直接占用库存。数量不足或规格不匹配时需要人工补选。'
|
|
||||||
: '默认展示全部配对,按 枪型 → 钻石 → 璀璨 排序,同规格同分时录单越早越靠前;当前账号没有履约权限,只能查看。'
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Space wrap size={12}>
|
<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>在库待匹配 {data?.inStockInventoryCount ?? 0} 件</Tag>
|
||||||
<Tag color="blue">匹配组合 {data?.pairCount ?? 0} 条</Tag>
|
<Tag color="blue">匹配组合 {data?.pairCount ?? 0} 条</Tag>
|
||||||
<Tag color="green">精确 {data?.exactCount ?? 0}</Tag>
|
<Tag color="green">精确 {data?.exactCount ?? 0}</Tag>
|
||||||
<Tag color="orange">非精确 {data?.partialCount ?? 0}</Tag>
|
<Tag color="orange">非精确 {data?.partialCount ?? 0}</Tag>
|
||||||
<Tag color="purple">数量不足 {data?.quantityShortCount ?? 0}</Tag>
|
{includeConflicts ? <Tag>不匹配 {data?.conflictCount ?? 0}</Tag> : null}
|
||||||
<Tag color="cyan">可自动 {data?.autoMatchableCount ?? 0}</Tag>
|
|
||||||
<Tag>不匹配 {data?.conflictCount ?? 0}</Tag>
|
|
||||||
</Space>
|
</Space>
|
||||||
|
|
||||||
<Space wrap size={12}>
|
<Space wrap size={12}>
|
||||||
@@ -353,6 +209,12 @@ export default function ConsignmentPendingMatchModal({
|
|||||||
style={{ width: 420 }}
|
style={{ width: 420 }}
|
||||||
onSearch={(value) => setKeyword(value.trim())}
|
onSearch={(value) => setKeyword(value.trim())}
|
||||||
/>
|
/>
|
||||||
|
<Checkbox
|
||||||
|
checked={includeConflicts}
|
||||||
|
onChange={(event) => setIncludeConflicts(event.target.checked)}
|
||||||
|
>
|
||||||
|
显示 0 分不匹配项
|
||||||
|
</Checkbox>
|
||||||
<Button
|
<Button
|
||||||
icon={<ReloadOutlined />}
|
icon={<ReloadOutlined />}
|
||||||
loading={query.isFetching}
|
loading={query.isFetching}
|
||||||
@@ -379,36 +241,31 @@ export default function ConsignmentPendingMatchModal({
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<PercentTable<PendingPistolMatchPair>
|
<PercentTable<PendingSuernanPistolMatchPair>
|
||||||
rowKey={(record) => `${record.workOrderId}-${record.inventoryId}`}
|
rowKey={(record) => `${record.workOrderId}-${record.inventoryId}`}
|
||||||
size="small"
|
size="small"
|
||||||
loading={query.isFetching}
|
loading={query.isFetching}
|
||||||
dataSource={pairs}
|
dataSource={pairs}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
scroll={{ x: 1680, y: 460 }}
|
scroll={{ y: 460 }}
|
||||||
pagination={{
|
pagination={{
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
showSizeChanger: false,
|
showSizeChanger: false,
|
||||||
showTotal: (total) => `共 ${total} 条`,
|
showTotal: (total) => `共 ${total} 条`,
|
||||||
}}
|
}}
|
||||||
locale={{
|
locale={{
|
||||||
emptyText: <Empty description="当前分类下没有可匹配组合" />,
|
emptyText: (
|
||||||
|
<Empty
|
||||||
|
description={
|
||||||
|
includeConflicts
|
||||||
|
? '没有可展示的配对'
|
||||||
|
: '没有有效匹配;可勾选「显示 0 分不匹配项」查看冲突'
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Space>
|
</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>
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1641,17 +1641,10 @@ export default function ConsignmentInventoryPanel() {
|
|||||||
onMatched={() => void inventoriesQuery.refetch()}
|
onMatched={() => void inventoriesQuery.refetch()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* 全局匹配看板:按当前寄卖分类统计待抢单 × 在库待匹配现货 */}
|
{/* 一键查询待匹配订单:简单只读的待抢单手枪 × 在库手枪看板 */}
|
||||||
<ConsignmentPendingMatchModal
|
<ConsignmentPendingMatchModal
|
||||||
open={pendingMatchOpen}
|
open={pendingMatchOpen}
|
||||||
categoryId={categoryId}
|
|
||||||
categoryName={activeFilterCategory?.name}
|
|
||||||
categoryParentName={
|
|
||||||
activeFilterCategory?.parentId ? activeFilterCategory.parentName : undefined
|
|
||||||
}
|
|
||||||
canMatch={canFulfillConsignment}
|
|
||||||
onClose={() => setPendingMatchOpen(false)}
|
onClose={() => setPendingMatchOpen(false)}
|
||||||
onMatched={() => void inventoriesQuery.refetch()}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ConsignmentMatchLogsModal open={matchLogsOpen} onClose={() => setMatchLogsOpen(false)} />
|
<ConsignmentMatchLogsModal open={matchLogsOpen} onClose={() => setMatchLogsOpen(false)} />
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import type {
|
|||||||
ConsignmentStatsSummary,
|
ConsignmentStatsSummary,
|
||||||
ConsignmentSubmission,
|
ConsignmentSubmission,
|
||||||
InventoryMatchableOrders,
|
InventoryMatchableOrders,
|
||||||
|
PendingSuernanPistolMatchResult,
|
||||||
PendingPistolMatchResult,
|
PendingPistolMatchResult,
|
||||||
WorkOrderInventoryMatchCheck,
|
WorkOrderInventoryMatchCheck,
|
||||||
WorkOrderInventoryMatchOptions,
|
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?: {
|
export function fetchPendingPistolMatches(params?: {
|
||||||
/** 只统计该寄卖分类;不传 = 全部 */
|
/** 只统计该寄卖分类;不传 = 全部 */
|
||||||
categoryId?: number
|
categoryId?: number
|
||||||
|
|||||||
@@ -333,6 +333,35 @@ export type WorkOrderInventoryMatchCheck = {
|
|||||||
matches: ConsignmentMatchResult[]
|
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 = {
|
export type PendingPistolMatchPair = {
|
||||||
workOrderId: number
|
workOrderId: number
|
||||||
|
|||||||
@@ -94,10 +94,12 @@ test('筛选选项接口:按已开启寄卖的分类返回', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('一键查询待匹配订单:按当前寄卖分类查询', () => {
|
test('一键查询待匹配订单:恢复为全局手枪查询,不继承当前寄卖分类', () => {
|
||||||
const modalSource = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
const modalSource = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
||||||
|
const panelCall = panelSource.slice(panelSource.indexOf('<ConsignmentPendingMatchModal'))
|
||||||
|
|
||||||
assert.ok(modalSource.includes('categoryId: categoryId ?? undefined'), '必须把分类传给待匹配接口')
|
assert.ok(modalSource.includes('fetchPendingSuernanPistolMatches'), '必须调用简单手枪查询接口')
|
||||||
assert.ok(modalSource.includes('分类:{categoryName}'), '弹窗要标明当前分类')
|
assert.ok(!modalSource.includes('categoryId: categoryId'), '简单手枪看板不得继承库存分类')
|
||||||
assert.ok(panelSource.includes('categoryId={categoryId}'), '仓库面板必须把当前分类传给弹窗')
|
assert.ok(!panelCall.includes('categoryId={categoryId}'), '仓库面板不得向手枪看板传当前分类')
|
||||||
|
assert.ok(!panelCall.includes('categoryName='), '仓库面板不得向手枪看板传当前分类名称')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,65 +7,54 @@ function readSource(relativePath: string): string {
|
|||||||
return readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), 'utf8')
|
return readFileSync(fileURLToPath(new URL(relativePath, import.meta.url)), 'utf8')
|
||||||
}
|
}
|
||||||
|
|
||||||
test('一键查询待匹配订单:每行提供「选择」,打开手动匹配并预选该库存', () => {
|
test('一键查询待匹配订单:恢复为独立只读的手枪匹配看板', () => {
|
||||||
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
|
||||||
|
|
||||||
assert.ok(source.includes("title: '操作'"), '必须新增操作列')
|
|
||||||
assert.ok(source.includes('选择'), '操作列按钮文案必须是「选择」')
|
|
||||||
assert.ok(source.includes('setSelectTarget({'), '点击选择必须记录订单与库存')
|
|
||||||
assert.ok(source.includes('<ConsignmentWorkOrderMatchModal'), '必须挂载手动匹配弹窗')
|
|
||||||
assert.ok(source.includes('initialInventoryIds'), '必须把选中的库存传给手动匹配弹窗')
|
|
||||||
assert.ok(source.includes('workOrderId={selectTarget?.workOrderId ?? null}'))
|
|
||||||
})
|
|
||||||
|
|
||||||
test('一键查询待匹配订单:快速匹配按履约权限门控,成功后刷新看板与库存', () => {
|
|
||||||
const modal = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
const modal = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
||||||
const panel = readSource('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx')
|
const panel = readSource('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx')
|
||||||
|
|
||||||
assert.ok(modal.includes('canMatch = false'), '默认无权限时不给操作入口')
|
assert.ok(modal.includes('fetchPendingSuernanPistolMatches'), '必须调用简单手枪匹配接口')
|
||||||
assert.ok(modal.includes('void query.refetch()'), '匹配成功后必须刷新看板')
|
assert.ok(modal.includes('不直接改单'), '一键查询必须是只读看板')
|
||||||
assert.ok(modal.includes('onMatched?.()'), '匹配成功后必须通知外层刷新库存')
|
assert.ok(!modal.includes('<ConsignmentWorkOrderMatchModal'), '不得再嵌套手动匹配弹窗')
|
||||||
|
assert.ok(!modal.includes('setSelectTarget('), '不得恢复二级选择流程')
|
||||||
|
assert.ok(!modal.includes('ConsignmentPriceWithDiff'), '简单看板不展示付款差价')
|
||||||
assert.ok(
|
assert.ok(
|
||||||
panel.includes('canMatch={canFulfillConsignment}'),
|
panel.includes('<ConsignmentPendingMatchModal\n open={pendingMatchOpen}'),
|
||||||
'仓库面板必须按 consignment.fulfill 权限传入 canMatch',
|
'仓库面板只传入开关状态',
|
||||||
)
|
)
|
||||||
assert.ok(
|
assert.ok(
|
||||||
panel.includes('onMatched={() => void inventoriesQuery.refetch()}'),
|
!panel.includes('categoryId={categoryId}\n categoryName='),
|
||||||
'仓库面板必须刷新库存列表',
|
'不得隐式继承库存分类',
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('一键查询待匹配订单:说明文案不再声称「不直接改单」', () => {
|
test('一键查询待匹配订单:默认隐藏冲突,可显式查看', () => {
|
||||||
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
||||||
|
|
||||||
assert.ok(!source.includes('不直接改单'), '新增选择匹配后必须去掉只读文案')
|
assert.ok(source.includes('useState(false)'), '冲突项默认关闭')
|
||||||
assert.ok(source.includes('「手动匹配方式」') || source.includes('手动匹配'))
|
assert.ok(source.includes('includeConflicts,'), '查询必须透传冲突开关')
|
||||||
|
assert.ok(source.includes('显示 0 分不匹配项'), '必须保留冲突查看开关')
|
||||||
|
assert.ok(source.includes('系统 20 / 区服 20 / 系列 20 / 钻级 25 / 璀璨 15'), '必须说明固定权重')
|
||||||
|
assert.ok(source.includes('同分时录单更早的订单优先'), '积压订单必须优先')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('一键查询待匹配订单:默认展示全部配对并按枪型/钻石/璀璨排序', () => {
|
test('一键查询待匹配订单:后端读取全部 open 工单并按剩余数量统计库存', () => {
|
||||||
const source = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
const source = readSource(
|
||||||
|
'../../backend/src/services/worker-platform/consignment-pending-match-service.ts',
|
||||||
assert.ok(source.includes('includeConflicts: true'), '默认必须包含冲突(0 分)配对')
|
|
||||||
assert.ok(!source.includes('显示 0 分不匹配项'), '旧的勾选框必须删除')
|
|
||||||
assert.ok(
|
|
||||||
!source.includes('right.score - left.score'),
|
|
||||||
'不得在前端只按分数重排,否则会覆盖后端的「枪型/钻石/璀璨」优先级',
|
|
||||||
)
|
)
|
||||||
assert.ok(source.includes('不匹配 {data?.conflictCount ?? 0}'), '必须展示不匹配数量')
|
|
||||||
assert.ok(source.includes('默认展示全部配对,按 枪型 → 钻石 → 璀璨 排序'), '界面必须说明默认口径')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('一键查询 / 手动匹配:展示工单用户付款金额与售价差价', () => {
|
assert.ok(source.includes('listAllOpenWorkOrdersForPistolBoard'), '必须提供简单手枪查询入口')
|
||||||
const pending = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
|
assert.ok(source.includes('while (items.length < total)'), '不得只读取最近 500 单')
|
||||||
const manual = readSource('../src/components/admin/ConsignmentWorkOrderMatchModal.tsx')
|
|
||||||
|
|
||||||
for (const source of [pending, manual]) {
|
|
||||||
assert.ok(source.includes("title: '工单用户付款金额'"), '两个弹窗都必须有用户付款金额列')
|
|
||||||
assert.ok(source.includes('ConsignmentPriceWithDiff'), '售价列必须带差价展示')
|
|
||||||
}
|
|
||||||
assert.ok(pending.includes('sharingEnabled={record.sharingEnabled}'), '拼单不展示差价')
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
manual.includes('sharingEnabled={sharingEnabled && totalQuantity > 1}'),
|
source.includes('sum + Math.max(0, Number(inventory.remaining_quantity ?? 1))'),
|
||||||
'拼单不展示差价',
|
'在库件数必须按 remaining_quantity 汇总',
|
||||||
)
|
)
|
||||||
|
assert.ok(source.includes('listPendingSuernanPistolMatches'), '必须导出简单手枪查询服务')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('一键查询待匹配订单:不得影响库存侧完整匹配引擎', () => {
|
||||||
|
const service = readSource('../src/services/admin/consignment.ts')
|
||||||
|
const inventoryModal = readSource('../src/components/admin/ConsignmentInventoryMatchModal.tsx')
|
||||||
|
|
||||||
|
assert.ok(service.includes('fetchPendingPistolMatches'), '库存侧完整匹配接口必须保留')
|
||||||
|
assert.ok(service.includes('/consignment/pending-pistol-matches'), '库存侧继续使用原完整匹配接口')
|
||||||
|
assert.ok(inventoryModal.includes('fetchPendingPistolMatches'), '库存侧弹窗不得改用简单看板接口')
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user