fix: update ticket retrieval logic to include booking date in query conditions
parent
e25ad6500f
commit
e1d8975dda
|
@ -51,27 +51,28 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
|
|||
],
|
||||
});
|
||||
|
||||
// if (!order) {
|
||||
// const { customer_name, customer_phone } =
|
||||
// await this.transaction.findOneOrFail({
|
||||
// where: {
|
||||
// id,
|
||||
// },
|
||||
// });
|
||||
if (!order) {
|
||||
const { customer_name, customer_phone } =
|
||||
await this.transaction.findOneOrFail({
|
||||
where: {
|
||||
id,
|
||||
booking_date: new Date(),
|
||||
},
|
||||
});
|
||||
|
||||
// const start = moment().startOf('day').valueOf();
|
||||
// const end = moment().endOf('day').valueOf();
|
||||
// const order = this.order.findOneOrFail({
|
||||
// relations: ['tickets'],
|
||||
// where: {
|
||||
// customer: customer_name,
|
||||
// phone: customer_phone,
|
||||
// date: Between(start, end),
|
||||
// },
|
||||
// });
|
||||
const start = moment().startOf('day').valueOf();
|
||||
const end = moment().endOf('day').valueOf();
|
||||
const order = this.order.findOneOrFail({
|
||||
relations: ['tickets'],
|
||||
where: {
|
||||
customer: customer_name,
|
||||
phone: customer_phone,
|
||||
date: Between(start, end),
|
||||
},
|
||||
});
|
||||
|
||||
// return order;
|
||||
// }
|
||||
return order;
|
||||
}
|
||||
|
||||
return order;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ export class GenerateQueueManager {
|
|||
async generate(transaction: TransactionModel) {
|
||||
const date = transaction.booking_date ?? transaction.invoice_date;
|
||||
const queue_date = moment(date, 'YYYY-MM-DD').unix();
|
||||
const isToday = moment(date, 'YYYY-MM-DD').isSame(moment(), 'day');
|
||||
|
||||
const { id, customer_name, customer_phone, invoice_code } = transaction;
|
||||
|
||||
|
@ -40,10 +41,9 @@ export class GenerateQueueManager {
|
|||
|
||||
const items = this.generateItems(transaction.items);
|
||||
|
||||
const existTicket = await this.ticketService.ticketByUser(
|
||||
customer_name,
|
||||
customer_phone,
|
||||
);
|
||||
const existTicket = isToday
|
||||
? await this.ticketService.ticketByUser(customer_name, customer_phone)
|
||||
: null;
|
||||
|
||||
const insertTickets: QueueTicket[] = [];
|
||||
if (customer_name && customer_phone && existTicket) {
|
||||
|
|
Loading…
Reference in New Issue