added some feature for plugin

This commit is contained in:
2026-09-08 18:00:56 +03:30
parent 67a03d9593
commit 58744d0f91
7 changed files with 147 additions and 7 deletions
+22 -2
View File
@@ -8,6 +8,7 @@ import { Prisma, SmsAccount, SmsLedgerType } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service';
import { AuditService } from '../audit/audit.service';
import { AdminNotifyService } from '../notifications/admin-notify.service';
import { RuntimeSettingsService } from '../notifications/runtime-settings.service';
import { iranYmd } from '../common/iran-time.util';
import {
ChargeSmsWalletDto,
@@ -27,6 +28,7 @@ export class SmsService {
private readonly prisma: PrismaService,
private readonly audit: AuditService,
private readonly notify: AdminNotifyService,
private readonly runtime: RuntimeSettingsService,
) {}
async listTenants() {
@@ -374,7 +376,7 @@ export class SmsService {
async remoteOverview(tenantId: string) {
const account = await this.ensureAccount(tenantId);
const usage = await this.computeUsageStats(account.id);
const charge = this.chargeInfoOf(account);
const charge = await this.chargeInfoForRemote(tenantId, account);
return {
wallet: {
@@ -417,7 +419,8 @@ export class SmsService {
}
async remoteChargeInfo(tenantId: string) {
const charge = await this.getChargeInfo(tenantId);
const account = await this.ensureAccount(tenantId);
const charge = await this.chargeInfoForRemote(tenantId, account);
return {
card: charge.card,
iban: charge.iban,
@@ -894,6 +897,23 @@ export class SmsService {
);
}
private async chargeInfoForRemote(tenantId: string, account: SmsAccount) {
const tenant = await this.prisma.tenant.findUnique({
where: { id: tenantId },
select: { product: true },
});
if (tenant?.product === 'khanegi') {
const deposit = this.runtime.getKhanegiDeposit();
return {
card: deposit.sms_charge_card_number,
iban: deposit.sms_charge_sheba,
accountHolder: deposit.sms_charge_account_holder,
instruction: deposit.sms_charge_note,
};
}
return this.chargeInfoOf(account);
}
private chargeInfoOf(account: SmsAccount) {
return {
card: account.chargeCard || '',