chore: add recurring invoice proccesor logic

This commit is contained in:
mahyargdz
2025-03-11 11:52:46 +03:30
parent fdf1bc908c
commit 4503721b90
17 changed files with 310 additions and 36 deletions
@@ -39,3 +39,8 @@ export interface IAnnouncementNotificationData extends IBaseNotificationData {
description: string;
date: Date;
}
export interface ISubscriptionNotificationData extends IBaseNotificationData {
planName: string;
invoiceId: string;
}
@@ -14,6 +14,7 @@ import {
IAnnouncementNotificationData,
IBaseNotificationData,
IInvoiceNotificationData,
ISubscriptionNotificationData,
ITicketNotificationData,
IWalletNotificationData,
} from "../interfaces/ISendNotificationData";
@@ -316,6 +317,34 @@ export class NotificationsService {
// //************************ */
async createRucurringInvoiceNotification(recipientId: string, data: IInvoiceNotificationData, queryRunner: QueryRunner) {
const message = NotificationMessage.RECURRING_INVOICE_MESSAGE.replace("[invoiceNumber]", data.invoiceId);
//sent notification based on the userSettings
const { isActive } = await this.userSettingsService.getUserNotificationSettingWithType(NotifType.RECURRING_INVOICE, recipientId);
if (isActive) {
await this.smsService.sendRecurringInvoiceDraftSms(data.userPhone, data.invoiceId, data.price);
//send email too
}
return this.createNotification(
{ title: NotificationMessage.RECURRING_INVOICE, type: NotifType.RECURRING_INVOICE, message, recipientId },
queryRunner,
);
}
async createBlockServiceNotification(recipientId: string, data: ISubscriptionNotificationData, queryRunner: QueryRunner) {
const message = NotificationMessage.BLOCK_SERVICE_MESSAGE.replace("[serviceName]", data.planName);
//sent notification based on the userSettings
const { isActive } = await this.userSettingsService.getUserNotificationSettingWithType(NotifType.BLOCK_SERVICE, recipientId);
if (isActive) {
await this.smsService.sendBlockServiceSms(data.userPhone, data.invoiceId, data.planName);
//send email too
}
return this.createNotification(
{ title: NotificationMessage.BLOCK_SERVICE, type: NotifType.BLOCK_SERVICE, message, recipientId },
queryRunner,
);
}
// async createServiceNotification(recipientId: string, sendNotifData: ISendNotificationData) {
// const message = NotificationMessage.CREATE_SERVICE_MESSAGE.replace("[serviceName]", sendNotifData.serviceName);
// //sent notification based on the userSettings
@@ -341,15 +370,4 @@ export class NotificationsService {
// }
// //************************ */
// async createBlockServiceNotification(recipientId: string, sendNotifData: ISendNotificationData) {
// const message = NotificationMessage.BLOCK_SERVICE_MESSAGE.replace("[serviceName]", sendNotifData.serviceName);
// //sent notification based on the userSettings
// const { isActive } = await this.userSettingsService.getUserNotificationSettingWithType(NotifType.BLOCK_SERVICE, recipientId);
// if (isActive) {
// await this.smsService.sendBlockServiceSms(sendNotifData.userPhone, sendNotifData.serviceName);
// //send email too
// }
// return this.createNotification({ title: NotificationMessage.BLOCK_SERVICE, message, recipientId });
// }
}