fix: connect operations pages to real backend

This commit is contained in:
hectorzhao
2026-07-02 15:16:34 +08:00
parent ab421cf8a7
commit 321cf716f2
22 changed files with 1255 additions and 429 deletions
+10
View File
@@ -35,6 +35,9 @@ function createPrismaMock() {
findMany: jest.fn(),
create: jest.fn(),
},
operationLog: {
create: jest.fn(),
},
};
}
@@ -131,6 +134,13 @@ describe('BillingService', () => {
relatedType: 'recharge_order',
}),
});
expect(prisma.operationLog.create).toHaveBeenCalledWith({
data: expect.objectContaining({
action: 'billing.manual_recharge',
resource: 'recharge_order',
resourceId: 'order-1',
}),
});
});
it('writes freeze, charge, release, refund, and adjustment transactions', async () => {
+18 -2
View File
@@ -199,8 +199,8 @@ export class BillingService {
return order;
}
createManualRecharge(data: CreateManualRechargeDto) {
return this.createRechargeOrder({
async createManualRecharge(data: CreateManualRechargeDto) {
const order = await this.createRechargeOrder({
tenantId: data.tenantId,
amountCents: data.amountCents,
smsUnits: data.smsUnits ?? 0,
@@ -208,6 +208,22 @@ export class BillingService {
operatorId: data.operatorId,
remark: data.remark,
});
await this.prisma.operationLog.create({
data: {
tenantId: data.tenantId,
userId: data.operatorId,
action: 'billing.manual_recharge',
resource: 'recharge_order',
resourceId: order.id,
detail: {
amountCents: data.amountCents,
smsUnits: data.smsUnits ?? 0,
orderNo: order.orderNo,
remark: data.remark,
} as Prisma.InputJsonValue,
},
});
return order;
}
estimateSmsCost(data: EstimateSmsCostDto) {