feat: add detail item ticket
parent
32d4064f0a
commit
ac86289182
|
@ -41,6 +41,19 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
|||
});
|
||||
}
|
||||
|
||||
async queueTicketItems(
|
||||
order_id: string,
|
||||
ticket_id: string,
|
||||
): Promise<QueueTicketModel[]> {
|
||||
return this.repo.find({
|
||||
relations: ['items', 'items.item', 'items.item.item_queue'],
|
||||
where: {
|
||||
order_id,
|
||||
id: ticket_id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async queueItemTickets(
|
||||
order_id: string,
|
||||
item_id: string,
|
||||
|
|
|
@ -44,6 +44,62 @@ export class QueueOrchestrator {
|
|||
});
|
||||
}
|
||||
|
||||
async queueTicketDetail(order_id: string, ticket_id: string): Promise<any> {
|
||||
const tickets = await this.dataService.queueTicketItems(
|
||||
order_id,
|
||||
ticket_id,
|
||||
);
|
||||
return tickets.map((ticket) => {
|
||||
const totalActivities = ticket.items.length;
|
||||
const totalTickets = ticket.items.reduce(
|
||||
(acc, item) => acc + item.qty,
|
||||
0,
|
||||
);
|
||||
const totalUsed = 0;
|
||||
const totalQueue = 0;
|
||||
return {
|
||||
id: ticket.id,
|
||||
code: ticket.code,
|
||||
customer: ticket.customer,
|
||||
phone: ticket.phone,
|
||||
date: ticket.date,
|
||||
summary: {
|
||||
total_activities: totalActivities,
|
||||
total_tickets: totalTickets,
|
||||
total_used: totalUsed,
|
||||
total_queue: totalQueue,
|
||||
},
|
||||
items: ticket.items.map((item) => {
|
||||
return {
|
||||
id: item.item_id,
|
||||
title: item.item.item_queue?.name ?? item.item.name,
|
||||
image_url: item.item.image_url,
|
||||
summary: {
|
||||
total_tickets: item.qty,
|
||||
total_used: 0,
|
||||
total_queue: 1,
|
||||
},
|
||||
queue: [
|
||||
{
|
||||
code: 'A001',
|
||||
qty: 1,
|
||||
time: '15:00',
|
||||
status: 'waiting',
|
||||
},
|
||||
],
|
||||
queue_condition: {
|
||||
available: true,
|
||||
average: 12,
|
||||
nearest: '13:10',
|
||||
crowded_level: 20,
|
||||
available_time: '15:00',
|
||||
},
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async queueItemDetail(order_id: string, item_id: string): Promise<any> {
|
||||
const tickets = await this.dataService.queueItemTickets(order_id, item_id);
|
||||
return tickets.map((ticket) => {
|
||||
|
|
|
@ -1,13 +1,4 @@
|
|||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
Res,
|
||||
} from '@nestjs/common';
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
|
||||
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
||||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
||||
|
@ -33,6 +24,14 @@ export class QueueController {
|
|||
return await this.orchestrator.queueTickets(id);
|
||||
}
|
||||
|
||||
@Get(':id/tickets/items')
|
||||
async queueTicketItems(
|
||||
@Param('id') id: string,
|
||||
@Param('ticket_id') ticket_id: string,
|
||||
): Promise<void> {
|
||||
return await this.orchestrator.queueTicketDetail(id, ticket_id);
|
||||
}
|
||||
|
||||
@Get(':id/items')
|
||||
async queueItems(@Param('id') id: string): Promise<void> {
|
||||
return await this.orchestrator.queueItems(id);
|
||||
|
|
Loading…
Reference in New Issue