feat: add manual recharge and operation logs
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user