feat: add per-org SMS wallet with adm panel and header credit
Bill all platform SMS (including OTP), allow negative balance with manual/auto cutoffs, and support own-panel bypass without wallet debit.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Controller, Get, UseGuards } from '@nestjs/common';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { CurrentUser } from '../auth/current-user.decorator';
|
||||
import { SmsWalletService } from './sms-wallet.service';
|
||||
|
||||
@Controller('sms-wallet')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
export class OrgSmsController {
|
||||
constructor(private readonly wallet: SmsWalletService) {}
|
||||
|
||||
/** خلاصه برای نشان اعتبار در هدر CRM */
|
||||
@Get('summary')
|
||||
async summary(@CurrentUser() user: { organizationId: string }) {
|
||||
const account = await this.wallet.ensureAccount(user.organizationId);
|
||||
const billingEnabled = this.wallet.isBillingEnabled(account);
|
||||
return {
|
||||
billingEnabled,
|
||||
balanceRials: account.balanceRials,
|
||||
pricePerPartRials: account.pricePerPartRials,
|
||||
isBlocked: account.isBlocked,
|
||||
autoBlocked: this.wallet.isAutoBlocked(account),
|
||||
balanceLevel: this.wallet.balanceLevel(account),
|
||||
panelMode: account.panelMode,
|
||||
chargeInfo: billingEnabled ? this.wallet.chargeInfoOf(account) : null,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user