feat(consignment): 匹配弹窗增加付款金额与售价差价
一键查询待匹配订单与手动匹配寄卖新增「工单用户付款金额」列, 售价后括号显示「用户付款金额 - 售价」差价:正数绿、负数红、 0 黄;拼单不显示差价,付款未知显示 -。
This commit is contained in:
@@ -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)
|
||||
})
|
||||
Reference in New Issue
Block a user