fix(consignment): 复核修复——占库撞 080 CHECK 必 500、指派非卖家双付货款、手动匹配权限门控
- 占库默认 allocation_status 从自由文本改为「已安排」,不再撞 080 的
CHECK ('待安排','已安排');加静态守卫测试(剥注释断言枚举内默认值)
- resolveConsignmentAssignRewardFen 加 assigneeIsSupplier:指派供货卖家本人
→ 报酬=结算价(货款走报酬渠道);指派别的打手 → 报酬保持原值(货款走
供货货款渠道),两条渠道互斥,封住平台双付;补行为级测试 + 调用点钉住
- 手动匹配两处入口(库存面板行内按钮、拦截弹窗 footer)统一按
consignment.fulfill 门控,编辑/作废仍为 manage,与后端权限一一对应
- docs/寄卖系统优化方案.md 记录批次 U
后端 473(+3)/ 前端 49(+1)测试全绿,typecheck / lint / format / check:sql / build 通过
This commit is contained in:
@@ -158,6 +158,7 @@ export default function ConsignmentInventoryPanel() {
|
||||
})
|
||||
const sessionPermissions = adminSessionQuery.data?.data.user.permissions
|
||||
const canManageConsignment = resolveAdminPermission(sessionPermissions, 'consignment.manage')
|
||||
const canFulfillConsignment = resolveAdminPermission(sessionPermissions, 'consignment.fulfill')
|
||||
|
||||
// 查询活跃打手列表用于指派与关联
|
||||
const workersQuery = useQuery({
|
||||
@@ -552,24 +553,28 @@ export default function ConsignmentInventoryPanel() {
|
||||
>
|
||||
详情
|
||||
</Button>
|
||||
{record.status === 'in_stock' && canFulfillConsignment ? (
|
||||
// 手动匹配是履约动作:提交打到要求 consignment.fulfill 的 /fulfill、/assign-worker。
|
||||
// 以前挂在 manage 门下,只有 manage 的人能点进去但提交必 403(本面板注释自己要求避免的口径)
|
||||
<Tooltip
|
||||
title={
|
||||
record.allowMatching
|
||||
? '从待匹配订单里人工挑一单(支持规格冲突强制匹配,需填原因)'
|
||||
: '该物品已暂停匹配,先打开上方「允许匹配」开关'
|
||||
}
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
disabled={!record.allowMatching}
|
||||
onClick={() => setManualMatchItem(record)}
|
||||
>
|
||||
手动匹配订单
|
||||
</Button>
|
||||
</Tooltip>
|
||||
) : null}
|
||||
{record.status === 'in_stock' && canManageConsignment ? (
|
||||
<>
|
||||
<Tooltip
|
||||
title={
|
||||
record.allowMatching
|
||||
? '从待匹配订单里人工挑一单(支持规格冲突强制匹配,需填原因)'
|
||||
: '该物品已暂停匹配,先打开上方「允许匹配」开关'
|
||||
}
|
||||
>
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
disabled={!record.allowMatching}
|
||||
onClick={() => setManualMatchItem(record)}
|
||||
>
|
||||
手动匹配订单
|
||||
</Button>
|
||||
</Tooltip>
|
||||
<Button
|
||||
size="small"
|
||||
type="link"
|
||||
|
||||
@@ -2987,23 +2987,27 @@ export default function WorkOrdersPanel() {
|
||||
})
|
||||
}}
|
||||
footer={[
|
||||
<Button
|
||||
key="manual-match"
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
const currentOrder = consignmentInterceptModal.order
|
||||
if (!currentOrder) return
|
||||
setConsignmentInterceptModal({
|
||||
open: false,
|
||||
order: null,
|
||||
matchData: null,
|
||||
submitting: false,
|
||||
})
|
||||
setManualMatchOrder(currentOrder)
|
||||
}}
|
||||
>
|
||||
手动指定现货匹配
|
||||
</Button>,
|
||||
// 手动指定现货会直接提交履约/指派(要求 consignment.fulfill),
|
||||
// 与行内入口(canFulfillConsignment 门控)保持一致,无权限不显示
|
||||
canFulfillConsignment ? (
|
||||
<Button
|
||||
key="manual-match"
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
const currentOrder = consignmentInterceptModal.order
|
||||
if (!currentOrder) return
|
||||
setConsignmentInterceptModal({
|
||||
open: false,
|
||||
order: null,
|
||||
matchData: null,
|
||||
submitting: false,
|
||||
})
|
||||
setManualMatchOrder(currentOrder)
|
||||
}}
|
||||
>
|
||||
手动指定现货匹配
|
||||
</Button>
|
||||
) : null,
|
||||
<Button
|
||||
key="ignore-and-publish"
|
||||
onClick={() => {
|
||||
|
||||
@@ -44,3 +44,36 @@ test('按钮点击要真的把状态设上,弹窗的 open 由该状态驱动',
|
||||
assert.ok(source.includes('setManualMatchItem(record)'), '行内按钮必须设置待匹配的现货')
|
||||
assert.ok(source.includes('open={Boolean(manualMatchItem)}'), '弹窗 open 必须由该状态驱动')
|
||||
})
|
||||
|
||||
test('手动匹配入口必须按 consignment.fulfill 门控(提交的是履约动作,不能只挂 manage)', () => {
|
||||
const inventoryPanel = readFileSync(
|
||||
new URL('../src/pages/admin/panels/ConsignmentInventoryPanel.tsx', import.meta.url).pathname,
|
||||
'utf8',
|
||||
)
|
||||
// 库存面板:手动匹配订单按钮要与编辑/作废拆开 —— 前者 fulfill(提交打到
|
||||
// /fulfill、/assign-worker,后端要求 consignment.fulfill),后者 manage
|
||||
assert.ok(
|
||||
inventoryPanel.includes("resolveAdminPermission(sessionPermissions, 'consignment.fulfill')"),
|
||||
'库存面板必须解析 consignment.fulfill 权限',
|
||||
)
|
||||
const buttonIndex = inventoryPanel.indexOf('手动匹配订单')
|
||||
assert.ok(buttonIndex > 0, '找不到「手动匹配订单」按钮')
|
||||
assert.ok(
|
||||
inventoryPanel.slice(0, buttonIndex).lastIndexOf('canFulfillConsignment ?') > 0,
|
||||
'「手动匹配订单」必须挂在 canFulfillConsignment 门下',
|
||||
)
|
||||
|
||||
const ordersPanel = readFileSync(
|
||||
new URL('../src/pages/admin/panels/WorkOrdersPanel.tsx', import.meta.url).pathname,
|
||||
'utf8',
|
||||
)
|
||||
// 拦截弹窗 footer 的入口同样要门控,无 fulfill 权限的人不该看到能直达 403 的按钮
|
||||
const footerButtonIndex = ordersPanel.indexOf('手动指定现货匹配')
|
||||
assert.ok(footerButtonIndex > 0, '找不到「手动指定现货匹配」按钮')
|
||||
const beforeFooterButton = ordersPanel.slice(0, footerButtonIndex)
|
||||
assert.ok(
|
||||
beforeFooterButton.lastIndexOf('canFulfillConsignment ?') >
|
||||
beforeFooterButton.lastIndexOf('footer={['),
|
||||
'拦截弹窗 footer 的「手动指定现货匹配」必须按 canFulfillConsignment 门控',
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user