notification fix bug
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user