fix: correct application cmpp credentials

This commit is contained in:
hectorzhao
2026-07-09 17:18:39 +08:00
parent 57a4c86a79
commit 767f0ca9aa
13 changed files with 149 additions and 24 deletions
+33
View File
@@ -143,6 +143,39 @@ describe('BillingService', () => {
});
});
it('allows negative manual recharge amounts for balance correction', async () => {
const prisma = createPrismaMock();
const service = new BillingService(prisma as never);
const order = await service.createManualRecharge({
tenantId: 'tenant-1',
amountCents: -300,
smsUnits: 0,
operatorId: 'admin-1',
remark: '人工冲正',
});
expect(order).toEqual(expect.objectContaining({ amountCents: -300, payMethod: 'manual_topup', status: 'paid' }));
expect(prisma.tenantAccount.update).toHaveBeenCalledWith({
where: { tenantId: 'tenant-1' },
data: { balanceCents: 700, smsUnits: 20 },
});
expect(prisma.accountTransaction.create).toHaveBeenCalledWith({
data: expect.objectContaining({
transactionType: 'recharge',
amountCents: -300,
balanceAfter: 700,
relatedType: 'recharge_order',
}),
});
expect(prisma.operationLog.create).toHaveBeenCalledWith({
data: expect.objectContaining({
action: 'billing.manual_recharge',
detail: expect.objectContaining({ amountCents: -300, remark: '人工冲正' }),
}),
});
});
it('writes freeze, charge, release, refund, and adjustment transactions', async () => {
const prisma = createPrismaMock();
const service = new BillingService(prisma as never);