fix bug in online payment success notif
This commit is contained in:
@@ -6,13 +6,13 @@ import { Permission } from 'src/common/enums/permission.enum';
|
|||||||
import { NotifTitleEnum } from 'src/modules/notifications/interfaces/notification.interface';
|
import { NotifTitleEnum } from 'src/modules/notifications/interfaces/notification.interface';
|
||||||
import { NotificationService } from 'src/modules/notifications/services/notification.service';
|
import { NotificationService } from 'src/modules/notifications/services/notification.service';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { PaymentMethodEnum } from '../interface/payment';
|
|
||||||
import { OrdersService } from 'src/modules/orders/providers/orders.service';
|
import { OrdersService } from 'src/modules/orders/providers/orders.service';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class PaymentListeners {
|
export class PaymentListeners {
|
||||||
private readonly logger = new Logger(PaymentListeners.name);
|
private readonly logger = new Logger(PaymentListeners.name);
|
||||||
private orderCreatedSmsTemplateId: string;
|
private orderCreatedSmsTemplateId: string;
|
||||||
|
private paymentSucceedSmsTemplateId: string;
|
||||||
constructor(
|
constructor(
|
||||||
private readonly adminService: AdminRepository,
|
private readonly adminService: AdminRepository,
|
||||||
private readonly notificationService: NotificationService,
|
private readonly notificationService: NotificationService,
|
||||||
@@ -20,6 +20,7 @@ export class PaymentListeners {
|
|||||||
private readonly orderService: OrdersService,
|
private readonly orderService: OrdersService,
|
||||||
) {
|
) {
|
||||||
this.orderCreatedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_CREATED') ?? '123';
|
this.orderCreatedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_CREATED') ?? '123';
|
||||||
|
this.paymentSucceedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ONLINE_PAYMENT_SUCCEED') ?? '123';
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPaymentMethodFarsi(method: string): string {
|
private getPaymentMethodFarsi(method: string): string {
|
||||||
@@ -90,7 +91,7 @@ export class PaymentListeners {
|
|||||||
adminId: admin.id,
|
adminId: admin.id,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// admin notifs
|
||||||
await this.notificationService.sendNotification({
|
await this.notificationService.sendNotification({
|
||||||
restaurantId: event.restaurantId,
|
restaurantId: event.restaurantId,
|
||||||
message: {
|
message: {
|
||||||
@@ -131,16 +132,17 @@ export class PaymentListeners {
|
|||||||
userId: order.user.id,
|
userId: order.user.id,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
// user notif
|
||||||
await this.notificationService.sendNotification({
|
await this.notificationService.sendNotification({
|
||||||
restaurantId: event.restaurantId,
|
restaurantId: event.restaurantId,
|
||||||
message: {
|
message: {
|
||||||
title: NotifTitleEnum.PAYMENT_SUCCESS,
|
title: NotifTitleEnum.PAYMENT_SUCCESS,
|
||||||
content: `پرداخت سفارش شماره ${order.orderNumber} با روش ${this.getPaymentMethodFarsi(order.paymentMethod.method)} و مبلغ ${order.total} تومان با موفقیت انجام شد`,
|
content: `پرداخت سفارش شماره ${order.orderNumber} با روش ${this.getPaymentMethodFarsi(order.paymentMethod.method)} و مبلغ ${order.total} تومان با موفقیت انجام شد`,
|
||||||
sms: {
|
sms: {
|
||||||
templateId: this.orderCreatedSmsTemplateId,
|
templateId: this.paymentSucceedSmsTemplateId,
|
||||||
parameters: {
|
parameters: {
|
||||||
orderNumber: String(order.orderNumber),
|
orderNumber: event.orderNumber,
|
||||||
total: order.total.toString(),
|
total: event.total.toString(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
pushNotif: {
|
pushNotif: {
|
||||||
|
|||||||
Reference in New Issue
Block a user