feat: add queue active summary
parent
ba7b81c320
commit
5ef7521e9b
|
@ -128,6 +128,25 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async queueTicketActive(
|
||||||
|
order_id: string,
|
||||||
|
ticket_id: string,
|
||||||
|
): Promise<QueueTicketModel[]> {
|
||||||
|
const order = await this.orderIds(order_id);
|
||||||
|
return this.repo.find({
|
||||||
|
relations: ['items', 'items.queue'],
|
||||||
|
where: {
|
||||||
|
order_id: In(order),
|
||||||
|
id: ticket_id,
|
||||||
|
items: {
|
||||||
|
queue: {
|
||||||
|
status: In(['waiting']),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async queueItemTickets(
|
async queueItemTickets(
|
||||||
order_id: string,
|
order_id: string,
|
||||||
item_id: string,
|
item_id: string,
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { SplitQueueDto } from '../infrastructure/controllers/dto/split-queue.dto
|
||||||
import { SplitQueueManager } from './usecases/split-queue.manager';
|
import { SplitQueueManager } from './usecases/split-queue.manager';
|
||||||
import { LoginQueueDto } from '../infrastructure/controllers/dto/login-queue.dto';
|
import { LoginQueueDto } from '../infrastructure/controllers/dto/login-queue.dto';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import { CustomerQueueTicketSummaryManager } from './usecases/queue/customer-queue-ticket.manager';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class QueueOrchestrator {
|
export class QueueOrchestrator {
|
||||||
|
@ -97,6 +98,16 @@ export class QueueOrchestrator {
|
||||||
return manager.data;
|
return manager.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async queueTicketSummary(order_id: string, ticket_id: string): Promise<any> {
|
||||||
|
const tickets = await this.dataService.queueTicketActive(
|
||||||
|
order_id,
|
||||||
|
ticket_id,
|
||||||
|
);
|
||||||
|
|
||||||
|
const manager = new CustomerQueueTicketSummaryManager(tickets);
|
||||||
|
return manager.data;
|
||||||
|
}
|
||||||
|
|
||||||
async queueItemDetail(order_id: string, item_id: string): Promise<any> {
|
async queueItemDetail(order_id: string, item_id: string): Promise<any> {
|
||||||
const tickets = await this.dataService.queueItemTickets(order_id, item_id);
|
const tickets = await this.dataService.queueItemTickets(order_id, item_id);
|
||||||
const manager = new CustomerQueueItemManager(tickets);
|
const manager = new CustomerQueueItemManager(tickets);
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { CustomerQueueManager } from './customer-queue.manager';
|
||||||
|
|
||||||
|
export class CustomerQueueTicketSummaryManager extends CustomerQueueManager {
|
||||||
|
get data() {
|
||||||
|
const tickets = this.tickets.map((ticket) => {
|
||||||
|
return {
|
||||||
|
id: ticket.id,
|
||||||
|
code: ticket.code,
|
||||||
|
customer: ticket.customer,
|
||||||
|
phone: ticket.phone,
|
||||||
|
date: ticket.date,
|
||||||
|
summary: {
|
||||||
|
total_activities: this.totalActivities(ticket),
|
||||||
|
total_tickets: this.totalTickets(ticket),
|
||||||
|
total_used: this.totalUsedTickets(ticket),
|
||||||
|
total_queue: this.totalQueueTickets(ticket),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return tickets[0];
|
||||||
|
}
|
||||||
|
}
|
|
@ -51,6 +51,14 @@ export class QueueController {
|
||||||
return await this.orchestrator.queueTicketDetail(id, ticket_id);
|
return await this.orchestrator.queueTicketDetail(id, ticket_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get(':id/tickets/:ticket_id/summary')
|
||||||
|
async queueTicketActive(
|
||||||
|
@Param('id') id: string,
|
||||||
|
@Param('ticket_id') ticket_id: string,
|
||||||
|
): Promise<void> {
|
||||||
|
return await this.orchestrator.queueTicketSummary(id, ticket_id);
|
||||||
|
}
|
||||||
|
|
||||||
@Get(':id/items')
|
@Get(':id/items')
|
||||||
async queueItems(@Param('id') id: string): Promise<void> {
|
async queueItems(@Param('id') id: string): Promise<void> {
|
||||||
return await this.orchestrator.queueItems(id);
|
return await this.orchestrator.queueItems(id);
|
||||||
|
|
Loading…
Reference in New Issue