feat: add manual recharge and operation logs
This commit is contained in:
@@ -48,6 +48,14 @@ export interface CreateRechargeOrderDto {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface CreateManualRechargeDto {
|
||||
tenantId: string;
|
||||
amountCents: number;
|
||||
smsUnits?: number;
|
||||
operatorId?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface EstimateSmsCostDto {
|
||||
tenantId: string;
|
||||
applicationId?: string;
|
||||
@@ -147,6 +155,18 @@ export class BillingService {
|
||||
});
|
||||
}
|
||||
|
||||
listManualRechargeRecords(tenantId?: string) {
|
||||
return this.prisma.rechargeOrder.findMany({
|
||||
where: {
|
||||
tenantId,
|
||||
payMethod: 'manual_topup',
|
||||
},
|
||||
include: { plan: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: 100,
|
||||
});
|
||||
}
|
||||
|
||||
async createRechargeOrder(data: CreateRechargeOrderDto) {
|
||||
const plan = data.planId ? await this.prisma.billingPlan.findUnique({ where: { id: data.planId } }) : null;
|
||||
const amountCents = data.amountCents ?? plan?.priceCents ?? 0;
|
||||
@@ -179,6 +199,17 @@ export class BillingService {
|
||||
return order;
|
||||
}
|
||||
|
||||
createManualRecharge(data: CreateManualRechargeDto) {
|
||||
return this.createRechargeOrder({
|
||||
tenantId: data.tenantId,
|
||||
amountCents: data.amountCents,
|
||||
smsUnits: data.smsUnits ?? 0,
|
||||
payMethod: 'manual_topup',
|
||||
operatorId: data.operatorId,
|
||||
remark: data.remark,
|
||||
});
|
||||
}
|
||||
|
||||
estimateSmsCost(data: EstimateSmsCostDto) {
|
||||
const billingUnits = estimateBillingUnits(data.content);
|
||||
const unitPrice = data.unitPrice ?? 0;
|
||||
|
||||
Reference in New Issue
Block a user