Compare commits
4
Commits
f816f57eb0
...
8631100d07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8631100d07 | ||
|
|
c62c8c2cad | ||
|
|
a5727554a4 | ||
|
|
439888631f |
@@ -99,6 +99,7 @@ export async function parkWorkOrderWaitingFriendAddWithClient(
|
||||
actorName?: string | undefined
|
||||
eventType?: string | undefined
|
||||
materialJson?: unknown
|
||||
rewardAmountFen?: number | null | undefined
|
||||
extraPayload?: Record<string, unknown>
|
||||
},
|
||||
): Promise<WorkOrderRow | null> {
|
||||
@@ -121,6 +122,10 @@ export async function parkWorkOrderWaitingFriendAddWithClient(
|
||||
: JSON.stringify(input.materialJson)
|
||||
const materialForInternalCheck =
|
||||
input.materialJson === undefined ? workOrder.material_json : input.materialJson
|
||||
const targetRewardAmountFen =
|
||||
input.rewardAmountFen !== undefined && input.rewardAmountFen !== null
|
||||
? Math.max(0, Math.round(Number(input.rewardAmountFen)))
|
||||
: null
|
||||
await client.query(
|
||||
`
|
||||
UPDATE work_orders
|
||||
@@ -134,10 +139,19 @@ export async function parkWorkOrderWaitingFriendAddWithClient(
|
||||
deadline_at = NULL,
|
||||
accepted_at = CASE WHEN $4 THEN NULL ELSE accepted_at END,
|
||||
material_json = COALESCE($5::jsonb, material_json),
|
||||
reward_amount = COALESCE($7, reward_amount),
|
||||
updated_at = $2::timestamptz
|
||||
WHERE id = $6
|
||||
`,
|
||||
[nextStatus, input.now, cooldownHours, clearAcceptedAt, materialJson, workOrder.id],
|
||||
[
|
||||
nextStatus,
|
||||
input.now,
|
||||
cooldownHours,
|
||||
clearAcceptedAt,
|
||||
materialJson,
|
||||
workOrder.id,
|
||||
targetRewardAmountFen,
|
||||
],
|
||||
)
|
||||
await createWorkOrderEventWithClient(client, {
|
||||
workOrderId: Number(workOrder.id),
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
|
||||
const FULFILLMENT_SERVICE = new URL('./consignment-fulfillment-service.ts', import.meta.url)
|
||||
const GIFT_REPO = new URL(
|
||||
'../../repositories/worker-platform/work-order-gift-repo.ts',
|
||||
import.meta.url,
|
||||
)
|
||||
|
||||
test('内部现货履约必须将工单发单金额更新为寄卖成本价并记录留痕', async () => {
|
||||
const source = await readFile(FULFILLMENT_SERVICE, 'utf8')
|
||||
assert.ok(
|
||||
source.includes('const previousRewardAmountFen = Number(lockedOrder.reward_amount || 0)'),
|
||||
)
|
||||
assert.ok(
|
||||
source.includes(
|
||||
'const costPriceFen = Math.max(0, Math.round(Number(inv.cost_price_fen || 0)))',
|
||||
),
|
||||
)
|
||||
assert.ok(
|
||||
source.includes(
|
||||
'const effectiveRewardAmountFen = costPriceFen > 0 ? costPriceFen : previousRewardAmountFen',
|
||||
),
|
||||
)
|
||||
assert.ok(source.includes('previousRewardAmountFen,'))
|
||||
assert.ok(source.includes('rewardAmountFen: effectiveRewardAmountFen,'))
|
||||
assert.ok(source.includes('updatedRewardAmountFen: effectiveRewardAmountFen,'))
|
||||
assert.ok(source.includes("priceAdjustReason: '寄卖内部现货履约按现货结算成本价更新发单金额'"))
|
||||
})
|
||||
|
||||
test('parkWorkOrderWaitingFriendAddWithClient 支持原子更新 reward_amount', async () => {
|
||||
const source = await readFile(GIFT_REPO, 'utf8')
|
||||
assert.ok(source.includes('rewardAmountFen?: number | null | undefined'))
|
||||
assert.ok(source.includes('reward_amount = COALESCE($7, reward_amount)'))
|
||||
})
|
||||
|
||||
test('指派供货打手履约记录原始发单金额并写入事件留痕', async () => {
|
||||
const source = await readFile(FULFILLMENT_SERVICE, 'utf8')
|
||||
assert.ok(source.includes('const previousRewardAmountFen = Number(workOrder.reward_amount || 0)'))
|
||||
assert.ok(source.includes("priceAdjustReason: '指派供货打手履约按现货结算成本价更新发单金额'"))
|
||||
})
|
||||
|
||||
test('撤销寄售履约退回未分配时必须恢复原始发单金额并记录留痕', async () => {
|
||||
const source = await readFile(FULFILLMENT_SERVICE, 'utf8')
|
||||
assert.ok(source.includes('const previousRewardAmountFen ='))
|
||||
assert.ok(source.includes('const restoreRewardAmount ='))
|
||||
assert.ok(source.includes('reward_amount = CASE WHEN $6::boolean THEN $7 ELSE reward_amount END'))
|
||||
assert.ok(source.includes('restoredRewardAmountFen: previousRewardAmountFen'))
|
||||
assert.ok(source.includes("priceRestoreReason: '撤销寄售履约退回未分配恢复原始发单金额'"))
|
||||
})
|
||||
@@ -446,6 +446,10 @@ export async function fulfillWorkOrderWithConsignment(input: {
|
||||
})
|
||||
}
|
||||
|
||||
const previousRewardAmountFen = Number(lockedOrder.reward_amount || 0)
|
||||
const costPriceFen = Math.max(0, Math.round(Number(inv.cost_price_fen || 0)))
|
||||
const effectiveRewardAmountFen = costPriceFen > 0 ? costPriceFen : previousRewardAmountFen
|
||||
|
||||
const updatedMaterial = {
|
||||
...material,
|
||||
consignment: {
|
||||
@@ -466,6 +470,8 @@ export async function fulfillWorkOrderWithConsignment(input: {
|
||||
fulfillmentType: CONSIGNMENT_FULFILLMENT_TYPE.INTERNAL_STOCK,
|
||||
fulfilledAt: now,
|
||||
fulfilledBy: input.actorName,
|
||||
previousRewardAmountFen,
|
||||
rewardAmountFen: effectiveRewardAmountFen,
|
||||
...(matchNote ? { matchNote } : {}),
|
||||
...(input.allowSpecMismatch === true
|
||||
? {
|
||||
@@ -482,11 +488,15 @@ export async function fulfillWorkOrderWithConsignment(input: {
|
||||
actorName: input.actorName,
|
||||
eventType: 'consignment_fulfilled',
|
||||
materialJson: updatedMaterial,
|
||||
rewardAmountFen: effectiveRewardAmountFen,
|
||||
extraPayload: {
|
||||
inventoryId: inv.id,
|
||||
inventoryNo: inv.inventory_no,
|
||||
itemName: inv.item_name,
|
||||
costPriceFen: inv.cost_price_fen,
|
||||
previousRewardAmountFen,
|
||||
updatedRewardAmountFen: effectiveRewardAmountFen,
|
||||
priceAdjustReason: '寄卖内部现货履约按现货结算成本价更新发单金额',
|
||||
buyerName: inv.buyer_name,
|
||||
shopName,
|
||||
matchType:
|
||||
@@ -662,6 +672,15 @@ export async function assignWorkOrderWithConsignmentWorker(input: {
|
||||
|
||||
const material = orderMaterial
|
||||
|
||||
const previousRewardAmountFen = Number(workOrder.reward_amount || 0)
|
||||
const rewardAmountFen = resolveConsignmentAssignRewardFen({
|
||||
costPriceFen: claimed.cost_price_fen,
|
||||
orderRewardFen: workOrder.reward_amount,
|
||||
// 指派对象是供货卖家本人 → 报酬改写为结算价(货款走工单报酬渠道);
|
||||
// 指派了别的打手 → 报酬保持原值(货款走验收结算的供货货款渠道),两条渠道互斥防双付
|
||||
assigneeIsSupplier: Number(targetWorkerId) === Number(inventory.worker_id || 0),
|
||||
})
|
||||
|
||||
// 3. 将寄售手枪信息写入工单 material
|
||||
const updatedMaterial = {
|
||||
...material,
|
||||
@@ -683,6 +702,8 @@ export async function assignWorkOrderWithConsignmentWorker(input: {
|
||||
fulfillmentType: 'worker_deposit',
|
||||
assignedAt: now,
|
||||
assignedBy: input.actorName,
|
||||
previousRewardAmountFen,
|
||||
rewardAmountFen,
|
||||
...(matchNote ? { matchNote } : {}),
|
||||
...(input.allowSpecMismatch === true
|
||||
? {
|
||||
@@ -694,14 +715,6 @@ export async function assignWorkOrderWithConsignmentWorker(input: {
|
||||
},
|
||||
}
|
||||
|
||||
const rewardAmountFen = resolveConsignmentAssignRewardFen({
|
||||
costPriceFen: claimed.cost_price_fen,
|
||||
orderRewardFen: workOrder.reward_amount,
|
||||
// 指派对象是供货卖家本人 → 报酬改写为结算价(货款走工单报酬渠道);
|
||||
// 指派了别的打手 → 报酬保持原值(货款走验收结算的供货货款渠道),两条渠道互斥防双付
|
||||
assigneeIsSupplier: Number(targetWorkerId) === Number(inventory.worker_id || 0),
|
||||
})
|
||||
|
||||
await updateWorkOrder(workOrder.id, {
|
||||
material_json: updatedMaterial,
|
||||
reward_amount: rewardAmountFen,
|
||||
@@ -724,6 +737,9 @@ export async function assignWorkOrderWithConsignmentWorker(input: {
|
||||
...(matchNote ? { matchNote } : {}),
|
||||
workerId: targetWorkerId,
|
||||
costPriceFen: claimed.cost_price_fen,
|
||||
previousRewardAmountFen,
|
||||
updatedRewardAmountFen: rewardAmountFen,
|
||||
priceAdjustReason: '指派供货打手履约按现货结算成本价更新发单金额',
|
||||
sourceSubmissionId: claimed.source_submission_id
|
||||
? Number(claimed.source_submission_id)
|
||||
: null,
|
||||
@@ -1038,6 +1054,14 @@ export async function revokeWorkOrderConsignmentFulfillment(input: {
|
||||
|
||||
// 工单回到「未指派 / 已取消」前,要把上一次交付留下的指派、时限、验收草稿与
|
||||
// 问题单痕迹一并清干净;否则重新指派时新打手会看到上一手的 deadline 与验收内容。
|
||||
const previousRewardAmountFen =
|
||||
consignmentInfo.previousRewardAmountFen !== undefined &&
|
||||
consignmentInfo.previousRewardAmountFen !== null
|
||||
? Number(consignmentInfo.previousRewardAmountFen)
|
||||
: null
|
||||
const restoreRewardAmount =
|
||||
nextOrderStatus === WORK_ORDER_STATUS.UNASSIGNED && previousRewardAmountFen !== null
|
||||
|
||||
const woSql = `
|
||||
UPDATE work_orders
|
||||
SET
|
||||
@@ -1054,6 +1078,7 @@ export async function revokeWorkOrderConsignmentFulfillment(input: {
|
||||
published_at = NULL,
|
||||
pinned_at = NULL,
|
||||
${RESET_GIFT_FLOW_SQL},
|
||||
reward_amount = CASE WHEN $6::boolean THEN $7 ELSE reward_amount END,
|
||||
updated_at = $3
|
||||
WHERE id = $4 AND status = $5
|
||||
RETURNING *
|
||||
@@ -1064,6 +1089,8 @@ export async function revokeWorkOrderConsignmentFulfillment(input: {
|
||||
now,
|
||||
lockedOrder.id,
|
||||
lockedOrder.status,
|
||||
restoreRewardAmount,
|
||||
restoreRewardAmount ? previousRewardAmountFen : lockedOrder.reward_amount,
|
||||
])
|
||||
const wo = woRes.rows[0]
|
||||
if (!wo) {
|
||||
@@ -1093,6 +1120,14 @@ export async function revokeWorkOrderConsignmentFulfillment(input: {
|
||||
workerDeposit: { mode: workerDepositMode, amount: workerDepositAmount },
|
||||
consignmentDeposit: { action: consignmentDepositAction },
|
||||
inventoryArchived: archiveOnly,
|
||||
...(restoreRewardAmount
|
||||
? {
|
||||
restoredRewardAmountFen: previousRewardAmountFen,
|
||||
previousConsignmentCostFen:
|
||||
consignmentInfo.costPriceFen || inv.cost_price_fen || null,
|
||||
priceRestoreReason: '撤销寄售履约退回未分配恢复原始发单金额',
|
||||
}
|
||||
: {}),
|
||||
}),
|
||||
now,
|
||||
})
|
||||
|
||||
@@ -600,3 +600,45 @@ test('发布寄卖建议价:号主钻级比后台配置高时,按已配置
|
||||
null,
|
||||
)
|
||||
})
|
||||
|
||||
test('品类隔离门禁:苏尔南手枪现货绝不匹配特种兵密钥、爆破型肩炮、专属礼盒等无关商品', () => {
|
||||
const invPistol = buildInventory({
|
||||
item_name: '苹果QQ区怒嚎3钻2璀璨 苏尔南',
|
||||
system: '苹果',
|
||||
server_zone: 'QQ区',
|
||||
series: '怒嚎',
|
||||
diamond_level: 3,
|
||||
brilliance_count: 2,
|
||||
})
|
||||
|
||||
// 1. 特种兵密钥
|
||||
const keyOrder = extractPeacekeeperSpecs('特种兵密钥1个')
|
||||
assert.equal(matchPeacekeeperOrderWithInventory(keyOrder, invPistol), null)
|
||||
assert.equal(
|
||||
matchPeacekeeperOrderWithInventory(keyOrder, invPistol, { allowUnspecifiedSpecs: true }),
|
||||
null,
|
||||
'宽松模式下也必须拒绝跨品类',
|
||||
)
|
||||
|
||||
// 2. 爆破型肩炮
|
||||
const cannonOrder = extractPeacekeeperSpecs('全新版【金色带特效】爆破型肩炮')
|
||||
assert.equal(matchPeacekeeperOrderWithInventory(cannonOrder, invPistol), null)
|
||||
assert.equal(
|
||||
matchPeacekeeperOrderWithInventory(cannonOrder, invPistol, { allowUnspecifiedSpecs: true }),
|
||||
null,
|
||||
)
|
||||
|
||||
// 3. 专属礼盒
|
||||
const boxOrder = extractPeacekeeperSpecs('1个精致荣耀专属礼盒')
|
||||
assert.equal(matchPeacekeeperOrderWithInventory(boxOrder, invPistol), null)
|
||||
assert.equal(
|
||||
matchPeacekeeperOrderWithInventory(boxOrder, invPistol, { allowUnspecifiedSpecs: true }),
|
||||
null,
|
||||
)
|
||||
|
||||
// 4. 正确的苏尔南手枪单子正常命中
|
||||
const pistolOrder = extractPeacekeeperSpecs('苹果QQ区怒嚎3钻 苏尔南手枪')
|
||||
const matched = matchPeacekeeperOrderWithInventory(pistolOrder, invPistol)
|
||||
assert.ok(matched)
|
||||
assert.equal(matched.matchType, 'partial') // 2璀璨充0璀璨
|
||||
})
|
||||
|
||||
@@ -64,6 +64,85 @@ export function normalizePeacekeeperSeries(value: string): string {
|
||||
return extractPeacekeeperSeries(value) || String(value || '').trim()
|
||||
}
|
||||
|
||||
/** 常见商品品类主体定义 */
|
||||
export type ItemCategoryType =
|
||||
| 'pistol_skin' // 手枪/苏尔南/枪皮
|
||||
| 'key_secret' // 特种兵密钥/钥匙
|
||||
| 'cannon' // 爆破型肩炮/肩甲
|
||||
| 'gift_box' // 专属礼盒/宝箱/福袋
|
||||
| 'rename_card' // 改名卡/更名卡
|
||||
| 'diamond_topup' // 钻石/点券/充值
|
||||
| 'other'
|
||||
|
||||
export function detectItemCategory(text: string): ItemCategoryType {
|
||||
const normalized = String(text || '').toLowerCase()
|
||||
if (!normalized) return 'other'
|
||||
|
||||
// 1. 手枪/枪皮/苏尔南系列
|
||||
if (
|
||||
normalized.includes('苏尔南') ||
|
||||
normalized.includes('手枪') ||
|
||||
normalized.includes('暗潮') ||
|
||||
normalized.includes('怒嚎') ||
|
||||
normalized.includes('怒号') ||
|
||||
normalized.includes('血宴') ||
|
||||
normalized.includes('枪皮')
|
||||
) {
|
||||
return 'pistol_skin'
|
||||
}
|
||||
|
||||
// 2. 密钥/特种兵密钥
|
||||
if (
|
||||
normalized.includes('密钥') ||
|
||||
normalized.includes('密匙') ||
|
||||
normalized.includes('特种兵密钥') ||
|
||||
normalized.includes('钥匙')
|
||||
) {
|
||||
return 'key_secret'
|
||||
}
|
||||
|
||||
// 3. 肩炮
|
||||
if (normalized.includes('肩炮') || normalized.includes('爆破型肩炮')) {
|
||||
return 'cannon'
|
||||
}
|
||||
|
||||
// 4. 专属礼盒/宝箱
|
||||
if (normalized.includes('礼盒') || normalized.includes('宝箱') || normalized.includes('福袋')) {
|
||||
return 'gift_box'
|
||||
}
|
||||
|
||||
// 5. 改名卡
|
||||
if (normalized.includes('改名') || normalized.includes('更名')) {
|
||||
return 'rename_card'
|
||||
}
|
||||
|
||||
// 6. 钻石/点券充值
|
||||
if (normalized.includes('点券') || normalized.includes('代充') || normalized.includes('充值')) {
|
||||
return 'diamond_topup'
|
||||
}
|
||||
|
||||
return 'other'
|
||||
}
|
||||
|
||||
export function formatItemCategoryLabel(type: ItemCategoryType): string {
|
||||
switch (type) {
|
||||
case 'pistol_skin':
|
||||
return '苏尔南手枪/枪皮'
|
||||
case 'key_secret':
|
||||
return '特种兵密钥'
|
||||
case 'cannon':
|
||||
return '爆破型肩炮'
|
||||
case 'gift_box':
|
||||
return '专属礼盒'
|
||||
case 'rename_card':
|
||||
return '改名卡'
|
||||
case 'diamond_topup':
|
||||
return '点券/充值'
|
||||
default:
|
||||
return '其它类目'
|
||||
}
|
||||
}
|
||||
|
||||
function parseSpecsFromText(rawText: string): Omit<ParsedOrderSpecs, 'rawText'> {
|
||||
const text = String(rawText || '').trim()
|
||||
|
||||
@@ -167,6 +246,29 @@ export function matchPeacekeeperOrderWithInventory(
|
||||
return null
|
||||
}
|
||||
|
||||
// 1. 品类与物品主体强隔离门禁(防跨品类误判为非精确匹配)
|
||||
const orderCat = detectItemCategory(order.rawText)
|
||||
const invCat = detectItemCategory(
|
||||
`${inventory.item_name} ${inventory.series} ${inventory.category_name || ''}`,
|
||||
)
|
||||
|
||||
// 若两端均能识别出品类且不一致(如订单是密钥/肩炮/礼盒,现货是手枪/枪皮),直接拒绝
|
||||
if (orderCat !== 'other' && invCat !== 'other' && orderCat !== invCat) {
|
||||
return null
|
||||
}
|
||||
|
||||
// 若现货明确为手枪/枪皮类目,订单不能是无任何手枪特征的其他商品
|
||||
if (invCat === 'pistol_skin') {
|
||||
const orderHasPistolSignal =
|
||||
Boolean(order.series) ||
|
||||
order.rawText.includes('苏尔南') ||
|
||||
order.rawText.includes('手枪') ||
|
||||
order.rawText.includes('枪皮')
|
||||
if (!orderHasPistolSignal) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const invSystem = normalizePeacekeeperSystem(inventory.system)
|
||||
const invZone = normalizePeacekeeperServerZone(inventory.server_zone)
|
||||
const invSeries = normalizePeacekeeperSeries(inventory.series)
|
||||
@@ -281,6 +383,26 @@ export function describeConsignmentSpecDifferences(
|
||||
inventory: ConsignmentInventoryRow,
|
||||
): string[] {
|
||||
const diffs: string[] = []
|
||||
|
||||
const orderCat = detectItemCategory(order.rawText)
|
||||
const invCat = detectItemCategory(
|
||||
`${inventory.item_name} ${inventory.series} ${inventory.category_name || ''}`,
|
||||
)
|
||||
if (orderCat !== 'other' && invCat !== 'other' && orderCat !== invCat) {
|
||||
diffs.push(
|
||||
`品类:订单「${formatItemCategoryLabel(orderCat)}」/ 现货「${formatItemCategoryLabel(invCat)}」`,
|
||||
)
|
||||
} else if (invCat === 'pistol_skin') {
|
||||
const orderHasPistolSignal =
|
||||
Boolean(order.series) ||
|
||||
order.rawText.includes('苏尔南') ||
|
||||
order.rawText.includes('手枪') ||
|
||||
order.rawText.includes('枪皮')
|
||||
if (!orderHasPistolSignal) {
|
||||
diffs.push(`品类:订单商品非手枪/枪皮 / 现货「苏尔南手枪/枪皮」`)
|
||||
}
|
||||
}
|
||||
|
||||
const compare = (
|
||||
label: string,
|
||||
orderValue: string,
|
||||
|
||||
@@ -7,20 +7,18 @@ import {
|
||||
Empty,
|
||||
Input,
|
||||
Modal,
|
||||
Radio,
|
||||
Space,
|
||||
Spin,
|
||||
Tag,
|
||||
Typography,
|
||||
message,
|
||||
} from 'antd'
|
||||
import { SearchOutlined } from '@ant-design/icons'
|
||||
import { SearchOutlined, TeamOutlined } from '@ant-design/icons'
|
||||
|
||||
import {
|
||||
assignWorkOrderWithConsignmentWorker,
|
||||
fetchInventoryMatchableOrders,
|
||||
fetchWorkOrderConsignmentMatchOptions,
|
||||
fulfillWorkOrderWithConsignment,
|
||||
} from '@/services/admin/consignment'
|
||||
import type { ConsignmentMatchOptionView, ConsignmentMatchableOrder } from '@/types/consignment'
|
||||
import {
|
||||
@@ -41,7 +39,7 @@ type Selected = {
|
||||
inventoryLabel: string
|
||||
matchType: ManualMatchType
|
||||
conflicts: string[]
|
||||
/** 指派打手线要用的供货卖家(现货的供货打手);内部现货履约不需要 */
|
||||
/** 供货打手(接单平台指派履约对象) */
|
||||
workerId?: number | null
|
||||
workerName?: string
|
||||
}
|
||||
@@ -59,9 +57,7 @@ export type ConsignmentManualMatchModalProps = {
|
||||
/**
|
||||
* 「手动指定现货」弹窗:订单侧与库存侧共用一套交互与落地逻辑。
|
||||
*
|
||||
* 为什么单独做:系统候选只覆盖"规格完全对得上"的现货,客服经常遇到
|
||||
* "订单规格没写全/订单录错/需要高配充低配"的情况,必须能人工指定;
|
||||
* 同时要把"哪里不一致"讲清楚,并把原因留痕,避免变成无痕操作。
|
||||
* 统一走接单平台指派供货打手履约(自动冻结押金、开启交付倒计时与履约监控)。
|
||||
*/
|
||||
export default function ConsignmentManualMatchModal({
|
||||
open,
|
||||
@@ -80,9 +76,6 @@ export default function ConsignmentManualMatchModal({
|
||||
workerName: string
|
||||
} | null>(null)
|
||||
const [selected, setSelected] = useState<Selected | null>(null)
|
||||
const [deliveryKind, setDeliveryKind] = useState<'internal_stock' | 'assign_worker'>(
|
||||
'internal_stock',
|
||||
)
|
||||
const [confirmedPartial, setConfirmedPartial] = useState(false)
|
||||
const [confirmedMismatch, setConfirmedMismatch] = useState(false)
|
||||
const [matchNote, setMatchNote] = useState('')
|
||||
@@ -93,7 +86,6 @@ export default function ConsignmentManualMatchModal({
|
||||
const resetState = () => {
|
||||
setKeyword('')
|
||||
setSelected(null)
|
||||
setDeliveryKind('internal_stock')
|
||||
setConfirmedPartial(false)
|
||||
setConfirmedMismatch(false)
|
||||
setMatchNote('')
|
||||
@@ -167,6 +159,7 @@ export default function ConsignmentManualMatchModal({
|
||||
const requirement = resolveManualMatchRequirement(selected?.matchType || 'exact')
|
||||
const canSubmit =
|
||||
Boolean(selected) &&
|
||||
Boolean(selected?.workerId) &&
|
||||
canSubmitManualMatch({
|
||||
matchType: selected?.matchType || 'exact',
|
||||
confirmedPartial,
|
||||
@@ -176,36 +169,26 @@ export default function ConsignmentManualMatchModal({
|
||||
|
||||
async function handleSubmit() {
|
||||
if (!selected) return
|
||||
if (deliveryKind === 'assign_worker' && !selected.workerId) {
|
||||
message.error('该现货未关联供货打手,不能走指派履约;请改用内部现货履约')
|
||||
if (!selected.workerId) {
|
||||
message.error('该现货未关联供货打手,无法走平台指派履约;请先关联打手')
|
||||
return
|
||||
}
|
||||
setSubmitting(true)
|
||||
try {
|
||||
const payload = {
|
||||
const res = await assignWorkOrderWithConsignmentWorker({
|
||||
workOrderId: selected.workOrderId,
|
||||
inventoryId: selected.inventoryId,
|
||||
workerId: selected.workerId,
|
||||
allowPartial: selected.matchType !== 'exact',
|
||||
allowSpecMismatch: selected.matchType === 'conflict',
|
||||
matchNote: matchNote.trim(),
|
||||
}
|
||||
const res =
|
||||
deliveryKind === 'assign_worker'
|
||||
? await assignWorkOrderWithConsignmentWorker({
|
||||
...payload,
|
||||
workerId: selected.workerId ?? undefined,
|
||||
})
|
||||
: await fulfillWorkOrderWithConsignment(payload)
|
||||
})
|
||||
|
||||
// 核销失败时共享工具会弹警告(状态已变更但凭证没消耗),此时不能再弹"成功"掩盖
|
||||
const voucher = (res.data as any)?.voucherConsume
|
||||
notifyVoucherConsume(voucher)
|
||||
if (!voucher || voucher.ok) {
|
||||
message.success(
|
||||
deliveryKind === 'assign_worker'
|
||||
? '已手动匹配:指派供货打手履约,押金已冻结'
|
||||
: '已手动匹配:使用内部现货履约,工单进入待加好友',
|
||||
)
|
||||
message.success('已手动匹配并指派供货打手履约,履约押金已冻结')
|
||||
}
|
||||
onMatched?.()
|
||||
resetState()
|
||||
@@ -232,7 +215,7 @@ export default function ConsignmentManualMatchModal({
|
||||
void load()
|
||||
return
|
||||
}
|
||||
message.error(err.message || '手动匹配失败')
|
||||
message.error(err.message || '手动匹配指派失败')
|
||||
} finally {
|
||||
setSubmitting(false)
|
||||
}
|
||||
@@ -243,59 +226,53 @@ export default function ConsignmentManualMatchModal({
|
||||
title={mode === 'order' ? `手动指定现货 · ${workOrder?.label || ''}` : '手动匹配订单'}
|
||||
open={open}
|
||||
width={860}
|
||||
okText="确认指派履约"
|
||||
okButtonProps={{
|
||||
disabled: !canSubmit,
|
||||
loading: submitting,
|
||||
}}
|
||||
onOk={() => void handleSubmit()}
|
||||
onCancel={() => {
|
||||
resetState()
|
||||
onClose()
|
||||
}}
|
||||
afterOpenChange={(visible) => {
|
||||
if (visible) void load()
|
||||
if (visible) {
|
||||
void load()
|
||||
} else {
|
||||
resetState()
|
||||
}
|
||||
}}
|
||||
footer={
|
||||
<Space>
|
||||
<Button
|
||||
onClick={() => {
|
||||
resetState()
|
||||
onClose()
|
||||
}}
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<Button type="primary" loading={submitting} disabled={!canSubmit} onClick={handleSubmit}>
|
||||
确认匹配
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
destroyOnHidden
|
||||
>
|
||||
<Space direction="vertical" size={12} style={{ width: '100%' }}>
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="手动匹配会立刻占用现货、冻结相关押金,点错需要用「撤销寄售履约」退回"
|
||||
message="手动匹配将直接占用现货并指派供货打手履约(冻结履约押金并纳入交付监控)。"
|
||||
description={
|
||||
mode === 'inventory'
|
||||
? `当前现货:${inventoryLabel}。选中订单后选择交付方式即可。`
|
||||
: '下面是该订单的全部在库现货(含规格不一致的),请核对差异后再决定。'
|
||||
mode === 'order'
|
||||
? '下面是该订单的全部在库现货(含规格不一致的),请核对差异后再决定。'
|
||||
: `当前现货:${inventoryLabel || inventory?.label || ''}。下面是可匹配的订单列表,请核对规格后指派。`
|
||||
}
|
||||
/>
|
||||
|
||||
<Input
|
||||
allowClear
|
||||
prefix={<SearchOutlined />}
|
||||
placeholder={
|
||||
mode === 'order'
|
||||
? '搜索物品名 / 寄卖单号 / 仓库号 / 规格'
|
||||
: '搜索订单号 / 商品名 / 规格'
|
||||
: '搜索工单号 / 平台单号 / 标题 / 规格'
|
||||
}
|
||||
prefix={<SearchOutlined />}
|
||||
value={keyword}
|
||||
onChange={(e) => setKeyword(e.target.value)}
|
||||
allowClear
|
||||
/>
|
||||
|
||||
<Spin spinning={loading}>
|
||||
<div style={{ maxHeight: 320, overflowY: 'auto' }}>
|
||||
<div style={{ maxHeight: 320, overflowY: 'auto', paddingRight: 4 }}>
|
||||
{mode === 'order' ? (
|
||||
filteredOptions.length === 0 ? (
|
||||
<Empty description="没有可用的在库现货" />
|
||||
<Empty description="没有可匹配的现货" />
|
||||
) : (
|
||||
filteredOptions.map((option) => {
|
||||
const meta = describeManualMatchType(option.matchType)
|
||||
@@ -323,11 +300,16 @@ export default function ConsignmentManualMatchModal({
|
||||
<Tag color={meta.color}>{meta.label}</Tag>
|
||||
</Space>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
寄卖单号 {option.inventory.sourceSubmissionNo || '—'} ·{' '}
|
||||
{option.inventory.system}/{option.inventory.serverZone}/
|
||||
{option.inventory.series} {option.inventory.diamondLevel}钻 · 货源{' '}
|
||||
{option.inventory.workerName || '—'} · 结算价 ¥
|
||||
{(option.inventory.costPriceFen / 100).toFixed(2)}
|
||||
寄卖单号{' '}
|
||||
{option.inventory.sourceSubmissionNo || option.inventory.inventoryNo} ·{' '}
|
||||
{option.inventory.system || '未指定'}/
|
||||
{option.inventory.serverZone || '未指定'}/
|
||||
{option.inventory.series || '未指定'}{' '}
|
||||
{option.inventory.diamondLevel
|
||||
? `${option.inventory.diamondLevel}钻`
|
||||
: ''}{' '}
|
||||
· 货源 {option.inventory.workerName || '未关联打手'} · 结算价 ¥
|
||||
{(Number(option.inventory.costPriceFen || 0) / 100).toFixed(2)}
|
||||
</Text>
|
||||
{option.conflicts.length > 0 ? (
|
||||
<Text style={{ fontSize: 12, color: '#cf1322' }}>
|
||||
@@ -335,7 +317,7 @@ export default function ConsignmentManualMatchModal({
|
||||
</Text>
|
||||
) : (
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
{option.reason || '规格相符'}
|
||||
{option.reason || '规格完全一致'}
|
||||
</Text>
|
||||
)}
|
||||
</Space>
|
||||
@@ -356,10 +338,6 @@ export default function ConsignmentManualMatchModal({
|
||||
setConfirmedPartial(false)
|
||||
setConfirmedMismatch(false)
|
||||
setMatchNote('')
|
||||
// 选了无打手的现货时指派不可用,兜底切回内部履约
|
||||
if (!option.inventory.workerId && deliveryKind === 'assign_worker') {
|
||||
setDeliveryKind('internal_stock')
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isSelected ? '已选' : '选它'}
|
||||
@@ -425,17 +403,12 @@ export default function ConsignmentManualMatchModal({
|
||||
inventoryLabel,
|
||||
matchType: order.matchType,
|
||||
conflicts: order.conflicts,
|
||||
// 指派线要用现货的供货打手:库存侧入口从接口响应的 inventory 里带过来
|
||||
workerId: inventoryWorker?.workerId ?? null,
|
||||
workerName: inventoryWorker?.workerName || '',
|
||||
})
|
||||
setConfirmedPartial(false)
|
||||
setConfirmedMismatch(false)
|
||||
setMatchNote('')
|
||||
// 选了无打手的现货时指派不可用,兜底切回内部履约
|
||||
if (!inventoryWorker?.workerId && deliveryKind === 'assign_worker') {
|
||||
setDeliveryKind('internal_stock')
|
||||
}
|
||||
}}
|
||||
>
|
||||
{isSelected ? '已选' : '选它'}
|
||||
@@ -453,6 +426,20 @@ export default function ConsignmentManualMatchModal({
|
||||
<Descriptions size="small" column={1} style={{ marginBottom: 8 }}>
|
||||
<Descriptions.Item label="订单">{selected.workOrderLabel || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="现货">{selected.inventoryLabel || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="指派打手">
|
||||
{selected.workerId ? (
|
||||
<Space size={6}>
|
||||
<Tag icon={<TeamOutlined />} color="blue">
|
||||
{selected.workerName || `打手 #${selected.workerId}`}
|
||||
</Tag>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
(工单将进入该打手“我的接单”并冻结履约押金)
|
||||
</Text>
|
||||
</Space>
|
||||
) : (
|
||||
<Text type="danger">该现货未关联供货打手,无法指派</Text>
|
||||
)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="匹配判定">
|
||||
<Tag color={describeManualMatchType(selected.matchType).color}>
|
||||
{describeManualMatchType(selected.matchType).label}
|
||||
@@ -466,26 +453,14 @@ export default function ConsignmentManualMatchModal({
|
||||
</Descriptions>
|
||||
|
||||
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
||||
<Radio.Group
|
||||
value={deliveryKind}
|
||||
onChange={(e) => setDeliveryKind(e.target.value)}
|
||||
options={[
|
||||
{
|
||||
value: 'internal_stock',
|
||||
label: '内部现货履约(客服/内部仓代交付,工单停在待加好友)',
|
||||
},
|
||||
{
|
||||
value: 'assign_worker',
|
||||
// 没关联打手的现货走指派必 400 consignment_worker_required,直接禁用并说明,别给死路
|
||||
disabled: !selected.workerId,
|
||||
label: `指派供货打手履约(冻结押金、工单进行中)${
|
||||
selected.workerName
|
||||
? ` · 打手:${selected.workerName}`
|
||||
: ' · 该现货未关联打手,不可指派'
|
||||
}`,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
{!selected.workerId ? (
|
||||
<Alert
|
||||
type="error"
|
||||
showIcon
|
||||
message="无法指派打手"
|
||||
description="该现货未绑定任何供货打手,无法在接单平台中执行指派与押金冻结流程。请先在寄卖管理中关联打手。"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{requirement.needsPartialConfirm ? (
|
||||
<Checkbox
|
||||
|
||||
@@ -3205,9 +3205,6 @@ export default function WorkOrdersPanel() {
|
||||
backgroundColor: '#fff',
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: 11, color: '#8c8c8c', marginBottom: 8 }}>
|
||||
选择履约方式(都会立刻占用该现货)
|
||||
</div>
|
||||
{inv.workerId ? (
|
||||
<>
|
||||
<Button
|
||||
@@ -3235,32 +3232,22 @@ export default function WorkOrdersPanel() {
|
||||
>
|
||||
走接单平台指派打手
|
||||
</Button>
|
||||
<div style={{ fontSize: 11, color: '#8c8c8c', margin: '4px 0 14px' }}>
|
||||
由该供货打手接单,需冻结履约押金
|
||||
<div
|
||||
style={{
|
||||
fontSize: 11,
|
||||
color: '#8c8c8c',
|
||||
marginTop: 6,
|
||||
textAlign: 'center',
|
||||
}}
|
||||
>
|
||||
指派供货打手履约 · 自动冻结履约押金
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
<Button
|
||||
block
|
||||
type={inv.workerId ? 'default' : 'primary'}
|
||||
icon={<PushpinOutlined />}
|
||||
loading={consignmentInterceptModal.submitting}
|
||||
onClick={() =>
|
||||
confirmConsignmentMatchAction({
|
||||
kind: 'internal_stock',
|
||||
matchType: m.matchType,
|
||||
consignmentNo: inv.sourceSubmissionNo || '客服手工入库',
|
||||
onOk: () => {
|
||||
void handleFulfillWithConsignment(inv.id, !isExact)
|
||||
},
|
||||
})
|
||||
}
|
||||
>
|
||||
内部现货履约
|
||||
</Button>
|
||||
<div style={{ fontSize: 11, color: '#8c8c8c', marginTop: 4 }}>
|
||||
不外派打手,直接用库存账号赠送
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ fontSize: 12, color: '#cf1322', textAlign: 'center' }}>
|
||||
该现货未关联供货打手,无法走平台指派;请先关联打手
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -87,12 +87,9 @@ test('手动匹配弹窗:数据过期的 409 要清选择并刷新,无打手
|
||||
assert.ok(source.includes('consignment_inventory_race_condition'), '要处理并发占用错误码')
|
||||
assert.ok(source.includes('consignment_spec_mismatch'), '要处理规格变化错误码')
|
||||
assert.ok(source.includes('setSelected(null)'), '数据过期时要清空已选')
|
||||
// 没关联打手的现货走指派必 400 consignment_worker_required:选项禁用 + 提交前再拦一次
|
||||
assert.ok(source.includes('disabled: !selected.workerId'), '无打手时指派选项必须禁用')
|
||||
assert.ok(
|
||||
source.includes("deliveryKind === 'assign_worker' && !selected.workerId"),
|
||||
'提交前要对无打手的指派再拦一道',
|
||||
)
|
||||
// 统一平台履约:没关联打手的现货禁用提交,提交前严格校验 workerId
|
||||
assert.ok(source.includes('Boolean(selected?.workerId)'), '无打手时必须禁用提交')
|
||||
assert.ok(source.includes('if (!selected.workerId)'), '提交前要对无打手的现货严格拦截')
|
||||
// 凭证核销反馈与关键字搜索:用共享出口 / 透传后端,不内联复制
|
||||
assert.ok(source.includes("from '@/utils/voucher-consume'"), '核销反馈必须用共享出口')
|
||||
assert.ok(source.includes('keyword: keyword.trim() || undefined'), '库存侧关键字要透传后端')
|
||||
|
||||
Reference in New Issue
Block a user