feat(M08-B): 补保洁结算发放记录
This commit is contained in:
@@ -122,6 +122,26 @@ const app = await buildApp({
|
||||
calls.push(['confirmSettlement', input]);
|
||||
return settlementResponse('CONFIRMED');
|
||||
},
|
||||
async markSettlementPaid(input) {
|
||||
calls.push(['markSettlementPaid', input]);
|
||||
return {
|
||||
...settlementResponse('PAID'),
|
||||
paidBy: input.userId,
|
||||
paidAt: new Date(),
|
||||
payoutChannel: input.payoutChannel,
|
||||
payoutReference: input.payoutReference,
|
||||
payoutError: ''
|
||||
};
|
||||
},
|
||||
async recordSettlementPayoutFailure(input) {
|
||||
calls.push(['recordSettlementPayoutFailure', input]);
|
||||
return {
|
||||
...settlementResponse('CONFIRMED'),
|
||||
payoutChannel: input.payoutChannel || '',
|
||||
payoutReference: input.payoutReference || '',
|
||||
payoutError: input.error
|
||||
};
|
||||
},
|
||||
async reclaimTimeouts(input) {
|
||||
calls.push(['reclaimTimeouts', input]);
|
||||
return { reclaimed: 2, taskIds: ['101', '102'] };
|
||||
@@ -322,6 +342,37 @@ assert.equal(confirmedSettlement.statusCode, 200);
|
||||
assert.equal(calls.at(-1)[0], 'confirmSettlement');
|
||||
assert.equal(calls.at(-1)[1].settlementId, '501');
|
||||
|
||||
const failedPayout = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/admin-api/cleaning/settlements/501/payout-failure',
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
payoutChannel: 'WECHAT_TRANSFER',
|
||||
payoutReference: 'wx-failed-001',
|
||||
error: 'insufficient merchant balance',
|
||||
note: 'retry later'
|
||||
}
|
||||
});
|
||||
assert.equal(failedPayout.statusCode, 200);
|
||||
assert.equal(calls.at(-1)[0], 'recordSettlementPayoutFailure');
|
||||
assert.equal(calls.at(-1)[1].settlementId, '501');
|
||||
assert.equal(calls.at(-1)[1].error, 'insufficient merchant balance');
|
||||
|
||||
const paidSettlement = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/admin-api/cleaning/settlements/501/paid',
|
||||
headers: { authorization: `Bearer ${token}` },
|
||||
payload: {
|
||||
payoutChannel: 'WECHAT_TRANSFER',
|
||||
payoutReference: 'wx-paid-001',
|
||||
note: 'paid'
|
||||
}
|
||||
});
|
||||
assert.equal(paidSettlement.statusCode, 200);
|
||||
assert.equal(paidSettlement.json().data.status, 'PAID');
|
||||
assert.equal(paidSettlement.json().data.payoutReference, 'wx-paid-001');
|
||||
assert.equal(calls.at(-1)[0], 'markSettlementPaid');
|
||||
|
||||
const reclaimed = await app.inject({
|
||||
method: 'POST',
|
||||
url: '/admin-api/cleaning/reclaim-timeouts',
|
||||
@@ -383,8 +434,12 @@ function settlementResponse(status) {
|
||||
totalRewardCents: 1200,
|
||||
periodStart: new Date(),
|
||||
periodEnd: new Date(),
|
||||
paidBy: status === 'PAID' ? '31' : null,
|
||||
confirmedAt: status === 'CONFIRMED' ? new Date() : null,
|
||||
paidAt: null,
|
||||
paidAt: status === 'PAID' ? new Date() : null,
|
||||
payoutChannel: '',
|
||||
payoutReference: '',
|
||||
payoutError: '',
|
||||
note: ''
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user