This commit is contained in:
@@ -18,6 +18,7 @@ export class OrderListeners {
|
|||||||
private readonly logger = new Logger(OrderListeners.name);
|
private readonly logger = new Logger(OrderListeners.name);
|
||||||
private orderCreatedSmsTemplateId: string;
|
private orderCreatedSmsTemplateId: string;
|
||||||
private orderStatusChangedSmsTemplateId: string;
|
private orderStatusChangedSmsTemplateId: string;
|
||||||
|
private orderPendingPaymentSmsTemplateId: string;
|
||||||
// private orderCompletedSmsTemplateId: string;
|
// private orderCompletedSmsTemplateId: string;
|
||||||
constructor(
|
constructor(
|
||||||
private readonly adminService: AdminRepository,
|
private readonly adminService: AdminRepository,
|
||||||
@@ -28,6 +29,8 @@ export class OrderListeners {
|
|||||||
) {
|
) {
|
||||||
this.orderCreatedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_CREATED') ?? '123';
|
this.orderCreatedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_CREATED') ?? '123';
|
||||||
this.orderStatusChangedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_STATUS_CHANGE') ?? '123';
|
this.orderStatusChangedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_STATUS_CHANGE') ?? '123';
|
||||||
|
this.orderPendingPaymentSmsTemplateId =
|
||||||
|
this.configService.get<string>('SMS_PATTERN_ORDER_PENDING_PAYMENT') ?? '123';
|
||||||
// this.orderCompletedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_STATUS_COMPLETED') ?? '123';
|
// this.orderCompletedSmsTemplateId = this.configService.get<string>('SMS_PATTERN_ORDER_STATUS_COMPLETED') ?? '123';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +116,41 @@ export class OrderListeners {
|
|||||||
userId: event.userId,
|
userId: event.userId,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
if (event.newStatus === OrderStatus.COMPLETED) {
|
if (event.newStatus === OrderStatus.PENDING_PAYMENT) {
|
||||||
|
if (!event?.userId) {
|
||||||
|
this.logger.log(
|
||||||
|
`User not found for order: ${event.orderId} for shop: ${event.shopId} and order number: ${event.orderNumber}`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.notificationService.sendNotification({
|
||||||
|
shopId: event.shopId,
|
||||||
|
message: {
|
||||||
|
title: NotifTitleEnum.ORDER_STATUS_CHANGED,
|
||||||
|
content: `سفارش شماره ${event.orderNumber} در انتظار پرداخت است. لطفا برای پرداخت به جزئیات سفارش در اپ مراجعه کنید`,
|
||||||
|
sms: {
|
||||||
|
templateId: this.orderPendingPaymentSmsTemplateId,
|
||||||
|
parameters: {
|
||||||
|
orderNumber: event.orderNumber,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
pushNotif: {
|
||||||
|
title: `پرداخت سفارش`,
|
||||||
|
content: `سفارش شماره ${event.orderNumber} در انتظار پرداخت است. لطفا برای پرداخت به جزئیات سفارش مراجعه کنید`,
|
||||||
|
icon: `/`,
|
||||||
|
action: {
|
||||||
|
type: NotifTitleEnum.ORDER_STATUS_CHANGED,
|
||||||
|
url: `/orders/${event.orderId}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
recipients,
|
||||||
|
metadata: {
|
||||||
|
priority: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else if (event.newStatus === OrderStatus.COMPLETED) {
|
||||||
|
|
||||||
if (!event?.userId) {
|
if (!event?.userId) {
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
|
|||||||
Reference in New Issue
Block a user