This commit is contained in:
@@ -26,8 +26,8 @@ import { Payment } from 'src/modules/payments/entities/payment.entity';
|
|||||||
@Index({ properties: ['restaurant', 'status'] })
|
@Index({ properties: ['restaurant', 'status'] })
|
||||||
@Index({ properties: ['restaurant', 'orderNumber'] })
|
@Index({ properties: ['restaurant', 'orderNumber'] })
|
||||||
export class Order extends BaseEntity {
|
export class Order extends BaseEntity {
|
||||||
@ManyToOne(() => User)
|
@ManyToOne(() => User, { nullable: true })
|
||||||
user!: User;
|
user?: User | null;
|
||||||
|
|
||||||
@ManyToOne(() => Restaurant)
|
@ManyToOne(() => Restaurant)
|
||||||
restaurant!: Restaurant;
|
restaurant!: Restaurant;
|
||||||
|
|||||||
@@ -133,6 +133,12 @@ export class PaymentListeners {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!order.user){
|
||||||
|
this.logger.error(
|
||||||
|
`User not found: ${event.orderId} for restaurant: ${event.restaurantId}`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const userRecipients = [
|
const userRecipients = [
|
||||||
{
|
{
|
||||||
userId: order.user.id,
|
userId: order.user.id,
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ export class PaymentsService {
|
|||||||
await this.em.transactional(async em => {
|
await this.em.transactional(async em => {
|
||||||
const order = await em.findOne(Order, { id: ctx.order.id }, { populate: ['user', 'restaurant'] });
|
const order = await em.findOne(Order, { id: ctx.order.id }, { populate: ['user', 'restaurant'] });
|
||||||
if (!order) throw new NotFoundException(OrderMessage.NOT_FOUND);
|
if (!order) throw new NotFoundException(OrderMessage.NOT_FOUND);
|
||||||
|
if (!order.user) throw new NotFoundException(OrderMessage.USER_NOT_FOUND);
|
||||||
if (order.status === OrderStatus.PAID) {
|
if (order.status === OrderStatus.PAID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user