feat: 支持待分配/待抢单修改付款金额并增加价格历史
This commit is contained in:
@@ -287,6 +287,20 @@ test('已存在的行只做原地替换,不改变位置', () => {
|
||||
assert.equal(totalOf(patched), 124, '行数没变,总数不能变')
|
||||
})
|
||||
|
||||
test('实时替换行时保留价格历史标记,避免入口消失', () => {
|
||||
const existing = {
|
||||
...buildSnapshot({ workOrderId: 100 }),
|
||||
hasPaymentAmountHistory: true,
|
||||
}
|
||||
const patched = patchAdminWorkOrderListItems(
|
||||
buildEnvelope([existing]),
|
||||
buildSnapshot({ workOrderId: 100, status: 'in_progress' }),
|
||||
{ remove: false, insert: false },
|
||||
)
|
||||
const row = itemsOfWorkOrders(patched)[0] as { hasPaymentAmountHistory?: boolean }
|
||||
assert.equal(row.hasPaymentAmountHistory, true)
|
||||
})
|
||||
|
||||
test('状态筛选:已不命中的工单会被移除并扣减总数', () => {
|
||||
const filters = parseAdminWorkOrderListFilters(buildQueryKey({ statuses: 'open' }))!
|
||||
const accepted = buildSnapshot({ workOrderId: 100, status: 'accepted' })
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import test from 'node:test'
|
||||
|
||||
test('价格历史入口只在 hasPaymentAmountHistory 为真时显示,并调用专用接口', async () => {
|
||||
const cell = await readFile(
|
||||
new URL('../src/pages/admin/panels/WorkOrderTableCells.tsx', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(cell.includes('order.hasPaymentAmountHistory ?'))
|
||||
assert.ok(cell.includes('fetchAdminWorkOrderPaymentAmountHistory'))
|
||||
assert.ok(cell.includes('价格历史记录'))
|
||||
|
||||
const service = await readFile(
|
||||
new URL('../src/services/admin/worker-platform.ts', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
assert.ok(service.includes('/payment-amount-history'))
|
||||
})
|
||||
@@ -64,22 +64,16 @@ test('getUserPaymentFen:空值或非法值不误判成 0 元', () => {
|
||||
assert.equal(getUserPaymentFen({ material: {}, sourceOrderAmount: 0 }), null)
|
||||
})
|
||||
|
||||
test('用户付款金额仅在待完善(pending_material)可编辑', () => {
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'pending_material' }), true)
|
||||
assert.equal(
|
||||
canEditUserPaymentAmount({ status: 'pending_material', rawStatus: 'pending_material' }),
|
||||
true,
|
||||
)
|
||||
test('用户付款金额在待完善、待分配、待抢单可编辑', () => {
|
||||
for (const status of ['pending_material', 'unassigned', 'open']) {
|
||||
assert.equal(
|
||||
canEditUserPaymentAmount({ status, rawStatus: status }),
|
||||
true,
|
||||
`${status} 应允许编辑用户付款金额`,
|
||||
)
|
||||
}
|
||||
|
||||
for (const status of [
|
||||
'unassigned',
|
||||
'open',
|
||||
'in_progress',
|
||||
'pending_acceptance',
|
||||
'problem',
|
||||
'accepted',
|
||||
'cancelled',
|
||||
]) {
|
||||
for (const status of ['in_progress', 'pending_acceptance', 'problem', 'accepted', 'cancelled']) {
|
||||
assert.equal(
|
||||
canEditUserPaymentAmount({ status, rawStatus: status }),
|
||||
false,
|
||||
@@ -87,7 +81,11 @@ test('用户付款金额仅在待完善(pending_material)可编辑', () => {
|
||||
)
|
||||
}
|
||||
|
||||
// rawStatus 是后端原始状态,优先级高于运营态 status
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'open', rawStatus: 'pending_material' }), true)
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'pending_material', rawStatus: 'open' }), false)
|
||||
// 运营态优先:拼单母单 rawStatus 仍是 open,但满额后界面显示代练中/待验收,不能再改
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'in_progress', rawStatus: 'open' }), false)
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'pending_acceptance', rawStatus: 'open' }), false)
|
||||
// 未满额时运营态仍是 open,继续允许
|
||||
assert.equal(canEditUserPaymentAmount({ status: 'open', rawStatus: 'open' }), true)
|
||||
// 老数据没有运营态时回退 rawStatus
|
||||
assert.equal(canEditUserPaymentAmount({ status: '', rawStatus: 'pending_material' }), true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user