feat: order tickets
parent
e9d864c922
commit
01b2796c26
|
@ -57,6 +57,9 @@ export class QueueTicketModel
|
|||
@JoinColumn({ name: 'order_id' })
|
||||
order: QueueOrder;
|
||||
|
||||
@Column('varchar')
|
||||
order_id: string;
|
||||
|
||||
@Column({ type: 'bigint' })
|
||||
date: number;
|
||||
|
||||
|
@ -65,7 +68,7 @@ export class QueueTicketModel
|
|||
onDelete: 'CASCADE',
|
||||
onUpdate: 'CASCADE',
|
||||
})
|
||||
items: QueueItem[];
|
||||
items: QueueItemModel[];
|
||||
}
|
||||
|
||||
@Entity(TABLE_NAME.QUEUE_ITEM)
|
||||
|
@ -85,7 +88,7 @@ export class QueueItemModel
|
|||
|
||||
@ManyToOne(() => ItemModel)
|
||||
@JoinColumn({ name: 'item_id' })
|
||||
item: ItemEntity;
|
||||
item: ItemModel;
|
||||
|
||||
@Column('int')
|
||||
qty: number;
|
||||
|
|
|
@ -31,4 +31,13 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
async queueTickets(order_id: string): Promise<QueueTicketModel[]> {
|
||||
return this.repo.find({
|
||||
relations: ['items', 'items.item', 'items.item.item_queue'],
|
||||
where: {
|
||||
order_id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,5 +9,6 @@ export interface QueueTicket extends BaseCoreEntity {
|
|||
phone: string;
|
||||
date: number;
|
||||
order?: QueueOrder;
|
||||
order_id?: string;
|
||||
items: QueueItem[];
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Injectable, UnauthorizedException } from '@nestjs/common';
|
||||
import { TicketDataService } from '../data/services/ticket.service';
|
||||
import { QueueOrder } from './entities/order.entity';
|
||||
import { title } from 'process';
|
||||
|
||||
@Injectable()
|
||||
export class QueueOrchestrator {
|
||||
|
@ -16,4 +17,21 @@ export class QueueOrchestrator {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
async queueTickets(order_id: string): Promise<any> {
|
||||
const tickets = await this.dataService.queueTickets(order_id);
|
||||
const items = tickets[0].items;
|
||||
return items.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
title: item.item.name,
|
||||
qty: item.qty,
|
||||
available: true,
|
||||
average: 12,
|
||||
nearest: '13:10',
|
||||
crowded_level: 20,
|
||||
available_time: '15:00',
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,9 @@ export class QueueController {
|
|||
async loginCustomer(@Param('id') id: string): Promise<QueueOrder> {
|
||||
return await this.orchestrator.loginCustomer(id);
|
||||
}
|
||||
|
||||
@Get('tickets/:id')
|
||||
async queueTickets(@Param('id') id: string): Promise<void> {
|
||||
return await this.orchestrator.queueTickets(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue