chore: notif service

This commit is contained in:
mahyargdz
2025-06-07 00:10:02 +03:30
parent dba7cec544
commit f4ce67c00c
3 changed files with 19 additions and 33 deletions
-4
View File
@@ -20,10 +20,6 @@ async function bootstrap() {
done(null);
});
fastifyAdapter.getInstance().addContentTypeParser("text/plain", (_request, _payload, done) => {
done(null);
});
const app = await NestFactory.create<NestFastifyApplication>(AppModule, fastifyAdapter);
app.useGlobalPipes(new ValidationPipe({ transform: true, whitelist: true }));
@@ -194,12 +194,7 @@ export class NotificationsService {
queryRunner,
);
if (isActive) {
await this.smsService.sendWalletChargeSms(
data.userPhone,
numberFormat(data.amount),
numberFormat(data.balance),
dateFormat(data.date),
);
await this.smsService.sendWalletChargeSms(data.userPhone, data.amount, data.balance, dateFormat(data.date));
if (data.userEmail) await this.emailService.sendWalletEmail(data);
}
return this.createNotification(
@@ -219,13 +214,7 @@ export class NotificationsService {
queryRunner,
);
if (isActive) {
await this.smsService.sendWalletDeductionSms(
data.userPhone,
numberFormat(data.amount),
numberFormat(data.balance),
data.reason,
dateFormat(data.date),
);
await this.smsService.sendWalletDeductionSms(data.userPhone, data.amount, data.balance, data.reason, dateFormat(data.date));
if (data.userEmail) await this.emailService.sendWalletEmail(data);
}
return this.createNotification(
@@ -409,7 +398,7 @@ export class NotificationsService {
);
if (isActive) {
await this.smsService.sendPaymentReminderSms(data.userPhone, numberFormat(data.amount));
await this.smsService.sendPaymentReminderSms(data.userPhone, data.amount);
if (data.userEmail) await this.emailService.sendPaymentReminderEmail(data);
}
@@ -435,7 +424,7 @@ export class NotificationsService {
);
if (isActive) {
await this.smsService.sendPaymentCancellationSms(data.userPhone, numberFormat(data.amount));
await this.smsService.sendPaymentCancellationSms(data.userPhone, data.amount);
if (data.userEmail) await this.emailService.sendPaymentCancellationEmail(data);
}
+15 -14
View File
@@ -6,6 +6,7 @@ import { catchError, firstValueFrom } from "rxjs";
import { SmsMessage } from "../../../common/enums/message.enum";
import { ISmsConfigs } from "../../../configs/sms.config";
import { SMS_CONFIG } from "../constants";
import { numberFormat } from "./international.utils";
import { truncateIfLong } from "./string.utils";
import { ISmsGetLineResponse, ISmsVerifyBody, ISmsVerifyResponse } from "../interfaces/ISms";
@@ -181,11 +182,11 @@ export class SmsService {
}
//************************************************* */
async sendWalletChargeSms(mobile: string, amount: string, newBalance: string, date: string) {
async sendWalletChargeSms(mobile: string, amount: number, newBalance: number, date: string) {
const smsData: ISmsVerifyBody = {
Parameters: [
{ name: "amount", value: amount },
{ name: "newBalance", value: newBalance },
{ name: "amount", value: numberFormat(amount) },
{ name: "newBalance", value: numberFormat(newBalance) },
{ name: "date", value: date },
],
Mobile: mobile,
@@ -212,11 +213,11 @@ export class SmsService {
}
//************************************************* */
async sendWalletDeductionSms(mobile: string, amount: string, newBalance: string, reason: string, date: string) {
async sendWalletDeductionSms(mobile: string, amount: number, newBalance: number, reason: string, date: string) {
const smsData: ISmsVerifyBody = {
Parameters: [
{ name: "amount", value: amount },
{ name: "newBalance", value: newBalance },
{ name: "amount", value: numberFormat(amount) },
{ name: "newBalance", value: numberFormat(newBalance) },
{ name: "reason", value: truncateIfLong(reason) },
{ name: "date", value: date },
],
@@ -371,7 +372,7 @@ export class SmsService {
const smsData: ISmsVerifyBody = {
Parameters: [
{ name: "invoiceId", value: invoiceId },
{ name: "amount", value: amount.toString() },
{ name: "amount", value: numberFormat(amount) },
{ name: "paidDate", value: paidDate },
],
Mobile: mobile,
@@ -404,7 +405,7 @@ export class SmsService {
const smsData: ISmsVerifyBody = {
Parameters: [
{ name: "invoiceId", value: invoiceId },
{ name: "amount", value: amount.toString() },
{ name: "amount", value: numberFormat(amount) },
{ name: "dueDate", value: dueDate },
],
Mobile: mobile,
@@ -436,8 +437,8 @@ export class SmsService {
const smsData: ISmsVerifyBody = {
Parameters: [
{ name: "invoiceId", value: invoiceId },
{ name: "amount", value: amount.toString() },
{ name: "lateFee", value: lateFee.toString() },
{ name: "amount", value: numberFormat(amount) },
{ name: "lateFee", value: numberFormat(lateFee) },
{ name: "dueDate", value: dueDate },
],
Mobile: mobile,
@@ -530,9 +531,9 @@ export class SmsService {
//************************************************* */
//************************************************* */
async sendPaymentReminderSms(mobile: string, amount: string) {
async sendPaymentReminderSms(mobile: string, amount: number) {
const smsData: ISmsVerifyBody = {
Parameters: [{ name: "amount", value: amount }],
Parameters: [{ name: "amount", value: numberFormat(amount) }],
Mobile: mobile,
TemplateId: this.smsConfigs.SMS_PATTERN_PAYMENT_REMINDER,
};
@@ -557,9 +558,9 @@ export class SmsService {
}
//************************************************* */
async sendPaymentCancellationSms(mobile: string, amount: string) {
async sendPaymentCancellationSms(mobile: string, amount: number) {
const smsData: ISmsVerifyBody = {
Parameters: [{ name: "amount", value: amount }],
Parameters: [{ name: "amount", value: numberFormat(amount) }],
Mobile: mobile,
TemplateId: this.smsConfigs.SMS_PATTERN_PAYMENT_CANCELLATION,
};