feat: add manual recharge and operation logs

This commit is contained in:
hectorzhao
2026-07-01 15:54:56 +08:00
parent 50d75f1cf3
commit 7ff6d7eac3
14 changed files with 339 additions and 32 deletions
+29
View File
@@ -104,6 +104,35 @@ describe('BillingService', () => {
});
});
it('creates manual recharge records for operator top-ups', async () => {
const prisma = createPrismaMock();
const service = new BillingService(prisma as never);
const order = await service.createManualRecharge({
tenantId: 'tenant-1',
amountCents: 2000,
smsUnits: 0,
operatorId: 'admin-1',
remark: '线下转账人工充值',
});
expect(order).toEqual(expect.objectContaining({ amountCents: 2000, payMethod: 'manual_topup', status: 'paid' }));
expect(prisma.rechargeOrder.create).toHaveBeenCalledWith({
data: expect.objectContaining({
payMethod: 'manual_topup',
operatorId: 'admin-1',
remark: '线下转账人工充值',
}),
});
expect(prisma.accountTransaction.create).toHaveBeenCalledWith({
data: expect.objectContaining({
transactionType: 'recharge',
amountCents: 2000,
relatedType: 'recharge_order',
}),
});
});
it('writes freeze, charge, release, refund, and adjustment transactions', async () => {
const prisma = createPrismaMock();
const service = new BillingService(prisma as never);