feat: vip auto generate queue
parent
6807d00cbe
commit
1878d03c0f
|
@ -97,9 +97,7 @@ export class ChangeStatusBookingHandler
|
|||
},
|
||||
relations: ['items', 'items.bundling_items'],
|
||||
});
|
||||
console.log('change status', { dataID, couchData, booking });
|
||||
mappingTransaction(booking);
|
||||
console.log('after mapping');
|
||||
|
||||
if (!couchData) {
|
||||
console.log('save data to couch');
|
||||
|
|
|
@ -19,11 +19,13 @@ import { SplitQueueManager } from './usecases/split-queue.manager';
|
|||
import { LoginQueueDto } from '../infrastructure/controllers/dto/login-queue.dto';
|
||||
import * as moment from 'moment';
|
||||
import { CustomerQueueTicketSummaryManager } from './usecases/queue/customer-queue-ticket.manager';
|
||||
import { TransactionDataService } from 'src/modules/transaction/transaction/data/services/transaction-data.service';
|
||||
|
||||
@Injectable()
|
||||
export class QueueOrchestrator {
|
||||
constructor(
|
||||
private readonly dataService: TicketDataService,
|
||||
public readonly dataService: TicketDataService,
|
||||
public readonly transactionService: TransactionDataService,
|
||||
private readonly queueService: QueueService,
|
||||
private readonly queueOrderService: QueueOrderService,
|
||||
private readonly registerQueueManager: RegisterQueueManager,
|
||||
|
|
|
@ -28,7 +28,7 @@ export class CustomerQueueItemListManager extends CustomerQueueManager {
|
|||
const item_qty = items.reduce((acc, item) => acc + item.qty, 0);
|
||||
const queueItem = item.item.item_queue ?? item.item;
|
||||
return {
|
||||
id: item.item_id,
|
||||
id: queueItem.id,
|
||||
queue_item_id: item.id,
|
||||
title: queueItem.name,
|
||||
image_url: item.item.image_url,
|
||||
|
|
|
@ -3,7 +3,9 @@ import { CustomerQueueManager } from './customer-queue.manager';
|
|||
export class CustomerQueueItemManager extends CustomerQueueManager {
|
||||
get data() {
|
||||
return this.tickets.map((ticket) => {
|
||||
const queueItems = this.mergeQueueItems(ticket);
|
||||
const item = ticket.items[0];
|
||||
|
||||
return {
|
||||
id: ticket.id,
|
||||
code: ticket.code,
|
||||
|
@ -17,7 +19,7 @@ export class CustomerQueueItemManager extends CustomerQueueManager {
|
|||
total_used: this.totalUsedTickets(ticket),
|
||||
total_queue: this.totalQueueTickets(ticket),
|
||||
},
|
||||
queue: item.queue
|
||||
queue: queueItems[0].queues
|
||||
.sort((a, b) => b.time - a.time)
|
||||
.map((q) => {
|
||||
return {
|
||||
|
|
|
@ -10,6 +10,7 @@ import { Queue } from '../../domain/entities/queue.entity';
|
|||
import { RegisterQueueDto } from './dto/register-queue.dto';
|
||||
import { SplitQueueDto } from './dto/split-queue.dto';
|
||||
import { LoginQueueDto } from './dto/login-queue.dto';
|
||||
import { LoginReceiptDto } from './dto/login-receipt.dto';
|
||||
|
||||
@ApiTags(`Queue`)
|
||||
@Controller(`v1/${MODULE_NAME.QUEUE}`)
|
||||
|
@ -33,6 +34,12 @@ export class QueueController {
|
|||
return await this.orchestrator.loginPhone(data);
|
||||
}
|
||||
|
||||
@Post('login/receipt')
|
||||
async loginReceipt(@Body() { id }: LoginReceiptDto): Promise<QueueOrder> {
|
||||
console.log(id);
|
||||
return await this.orchestrator.loginCustomer(id);
|
||||
}
|
||||
|
||||
@Get('login/:id')
|
||||
async loginCustomer(@Param('id') id: string): Promise<QueueOrder> {
|
||||
return await this.orchestrator.loginCustomer(id);
|
||||
|
|
|
@ -9,17 +9,22 @@ import { QueueOrder } from '../../domain/entities/order.entity';
|
|||
import { QueueTicket } from '../../domain/entities/ticket.entity';
|
||||
import { QueueItem } from '../../domain/entities/queue-item.entity';
|
||||
import * as moment from 'moment';
|
||||
import { QueueOrchestrator } from '../../domain/queue.orchestrator';
|
||||
import { TransactionUserType } from 'src/modules/transaction/transaction/constants';
|
||||
import { RegisterQueueManager } from '../../domain/usecases/register-queue.manager';
|
||||
import { RegisterQueueDto } from '../controllers/dto/register-queue.dto';
|
||||
import { QueueService } from '../../data/services/queue.service';
|
||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||
import { QueueBucketReadService } from '../../data/services/queue-bucket';
|
||||
|
||||
@EventsHandler(TransactionChangeStatusEvent, TransactionCreateQueueEvent)
|
||||
export class QueueTransactionHandler
|
||||
implements IEventHandler<TransactionChangeStatusEvent>
|
||||
{
|
||||
constructor(
|
||||
private dataService: TransactionDataService,
|
||||
private queueService: TicketDataService,
|
||||
private orchestrator: QueueOrchestrator,
|
||||
private readonly dataService: TransactionDataService,
|
||||
private readonly ticketService: TicketDataService,
|
||||
private readonly queueService: QueueService,
|
||||
private readonly bucketService: QueueBucketReadService,
|
||||
) {}
|
||||
|
||||
async handle(event: TransactionChangeStatusEvent) {
|
||||
|
@ -62,7 +67,7 @@ export class QueueTransactionHandler
|
|||
const ticket: QueueTicket = { ...customerOrder, items };
|
||||
const order: QueueOrder = { ...customerOrder, tickets: [ticket] };
|
||||
|
||||
const queueOrder = await this.queueService.createQueueOrder(order);
|
||||
const queueOrder = await this.ticketService.createQueueOrder(order);
|
||||
if (
|
||||
transaction.customer_category?.has_vip_pass ||
|
||||
transaction.customer_type === TransactionUserType.VIP
|
||||
|
@ -79,10 +84,25 @@ export class QueueTransactionHandler
|
|||
qty: 1,
|
||||
};
|
||||
|
||||
this.orchestrator.create(payload);
|
||||
this.create(payload);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async create(data: RegisterQueueDto): Promise<void> {
|
||||
const queue = await this.queueService.getTicketItems(
|
||||
data.ticket_id,
|
||||
data.item_id,
|
||||
);
|
||||
const queueRequest: any = {
|
||||
qty: data.qty,
|
||||
item_id: queue.id,
|
||||
};
|
||||
const registerQueueManager = new RegisterQueueManager(this.bucketService);
|
||||
registerQueueManager.setData(queueRequest);
|
||||
registerQueueManager.setService(this.queueService, TABLE_NAME.QUEUE);
|
||||
await registerQueueManager.execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,11 +51,11 @@ import { SplitQueueManager } from './domain/usecases/split-queue.manager';
|
|||
],
|
||||
controllers: [QueueController, QueueAdminController],
|
||||
providers: [
|
||||
QueueTransactionHandler,
|
||||
|
||||
QueueOrchestrator,
|
||||
QueueAdminOrchestrator,
|
||||
|
||||
QueueTransactionHandler,
|
||||
|
||||
TransactionDataService,
|
||||
TicketDataService,
|
||||
QueueDataService,
|
||||
|
|
|
@ -59,7 +59,7 @@ export class TransactionModel
|
|||
@Column('varchar', { name: 'season_period_type_name', nullable: true })
|
||||
season_period_type_name: string;
|
||||
|
||||
@ManyToOne(() => TransactionDemographyModel)
|
||||
@ManyToOne(() => VipCategoryModel)
|
||||
@JoinColumn({ name: 'customer_category_id' })
|
||||
customer_category: VipCategoryModel;
|
||||
|
||||
|
|
Loading…
Reference in New Issue