notification fix bug

This commit is contained in:
2025-12-11 00:26:02 +03:30
parent 2be360639e
commit 33ead91506
4 changed files with 20 additions and 7 deletions
+13
View File
@@ -19,6 +19,8 @@ import { Cron, CronExpression } from '@nestjs/schedule';
import { OrderRepository } from './repositories/order.repository';
import { FindOrdersDto } from './dto/find-orders.dto';
import { PaginatedResult } from 'src/common/interfaces/pagination.interface';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { OrderCreatedEvent, OrderPaymentSuccessEvent } from '../notifications/events/notification.events';
@Injectable()
export class OrdersService {
@@ -29,10 +31,12 @@ export class OrdersService {
private readonly cartService: CartService,
private readonly paymentsService: PaymentsService,
private readonly orderRepository: OrderRepository,
private readonly eventEmitter2: EventEmitter2,
// private readonly paymentGatewayService: PaymentGatewayService,
) {}
async checkout(userId: string, restaurantId: string) {
console.log('Order created event emitted 000');
const cart = await this.cartService.findOneOrFail(userId, restaurantId);
const { order } = await this.createOrder(userId, restaurantId, cart);
@@ -45,6 +49,15 @@ export class OrdersService {
await this.cartService.clearCart(userId, restaurantId);
this.eventEmitter2.emit(
OrderCreatedEvent.name,
new OrderCreatedEvent(order.id, restaurantId, order.user.id, order.total),
);
this.eventEmitter2.emit(
OrderPaymentSuccessEvent.name,
new OrderPaymentSuccessEvent(order.id, restaurantId, order.user.id, order.total),
);
console.log('Order created event emitted 111');
return { order, paymentUrl };
}