feat(consignment): 匹配弹窗增加付款金额与售价差价

一键查询待匹配订单与手动匹配寄卖新增「工单用户付款金额」列,
售价后括号显示「用户付款金额 - 售价」差价:正数绿、负数红、
0 黄;拼单不显示差价,付款未知显示 -。
This commit is contained in:
2026-11-16 14:38:45 +08:00
parent ec11022c1b
commit 866f0d37fd
12 changed files with 279 additions and 12 deletions
@@ -0,0 +1,47 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import {
formatFenMoney,
formatSignedFenMoney,
PAYMENT_PRICE_DIFF_COLOR,
resolvePaymentPriceDiff,
} from '../src/utils/consignment-payment-price-diff.ts'
test('金额展示:分转元,未知返回 -', () => {
assert.equal(formatFenMoney(11000), '¥110.00')
assert.equal(formatFenMoney(0), '¥0.00')
assert.equal(formatFenMoney(null), '-')
assert.equal(formatFenMoney(undefined), '-')
})
test('差价展示:正数带 +、负数带 -、0 不带符号', () => {
assert.equal(formatSignedFenMoney(2000), '+¥20.00')
assert.equal(formatSignedFenMoney(-2000), '-¥20.00')
assert.equal(formatSignedFenMoney(0), '¥0.00')
})
test('售价差价:用户付款 - 售价,正绿负红零黄', () => {
assert.deepEqual(resolvePaymentPriceDiff(15000, 11000), {
diffFen: 4000,
text: '+¥40.00',
color: PAYMENT_PRICE_DIFF_COLOR.positive,
})
assert.deepEqual(resolvePaymentPriceDiff(10000, 11000), {
diffFen: -1000,
text: '-¥10.00',
color: PAYMENT_PRICE_DIFF_COLOR.negative,
})
assert.deepEqual(resolvePaymentPriceDiff(11000, 11000), {
diffFen: 0,
text: '¥0.00',
color: PAYMENT_PRICE_DIFF_COLOR.zero,
})
})
test('售价差价:付款未知、售价缺失或拼单不展示', () => {
assert.equal(resolvePaymentPriceDiff(null, 11000), null)
assert.equal(resolvePaymentPriceDiff(undefined, 11000), null)
assert.equal(resolvePaymentPriceDiff(15000, undefined), null)
assert.equal(resolvePaymentPriceDiff(15000, 11000, { sharingEnabled: true }), null)
})
@@ -54,3 +54,18 @@ test('一键查询待匹配订单:默认展示全部配对并按枪型/钻石/
assert.ok(source.includes('不匹配 {data?.conflictCount ?? 0}'), '必须展示不匹配数量')
assert.ok(source.includes('默认展示全部配对,按 枪型 → 钻石 → 璀璨 排序'), '界面必须说明默认口径')
})
test('一键查询 / 手动匹配:展示工单用户付款金额与售价差价', () => {
const pending = readSource('../src/components/admin/ConsignmentPendingMatchModal.tsx')
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(
manual.includes('sharingEnabled={sharingEnabled && totalQuantity > 1}'),
'拼单不展示差价',
)
})