发布、指派和改价都会弹出亏损确认,且不能用「不再提示」跳过;列表发单金额旁增加「高于付款」标签。 Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
|
|
import { getRewardAbovePayment } from '../src/pages/admin/panels/work-order-payment.ts'
|
|
|
|
function orderWithPayment(paymentFen: number, rewardFen: number) {
|
|
return {
|
|
rewardAmount: rewardFen,
|
|
material: {
|
|
source: {
|
|
kuaishouSendCode: { paymentFen },
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
test('发单金额高于用户付款时返回两边金额', () => {
|
|
const loss = getRewardAbovePayment(orderWithPayment(900, 6800))
|
|
assert.ok(loss)
|
|
assert.equal(loss.paymentFen, 900)
|
|
assert.equal(loss.rewardFen, 6800)
|
|
})
|
|
|
|
test('发单金额不超过用户付款时不提示', () => {
|
|
assert.equal(getRewardAbovePayment(orderWithPayment(6800, 6800)), null)
|
|
assert.equal(getRewardAbovePayment(orderWithPayment(6800, 6700)), null)
|
|
})
|
|
|
|
test('用户付款未知时不参与超价提示', () => {
|
|
assert.equal(getRewardAbovePayment({ rewardAmount: 6800, material: {} }), null)
|
|
})
|
|
|
|
test('可传入即将保存的发单金额做预检', () => {
|
|
const order = orderWithPayment(900, 800)
|
|
assert.equal(getRewardAbovePayment(order), null)
|
|
assert.ok(getRewardAbovePayment(order, 1000))
|
|
})
|