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) {
|
if (!order) {
|
||||||
// const { customer_name, customer_phone } =
|
const { customer_name, customer_phone } =
|
||||||
// await this.transaction.findOneOrFail({
|
await this.transaction.findOneOrFail({
|
||||||
// where: {
|
where: {
|
||||||
// id,
|
id,
|
||||||
// },
|
booking_date: new Date(),
|
||||||
// });
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// const start = moment().startOf('day').valueOf();
|
const start = moment().startOf('day').valueOf();
|
||||||
// const end = moment().endOf('day').valueOf();
|
const end = moment().endOf('day').valueOf();
|
||||||
// const order = this.order.findOneOrFail({
|
const order = this.order.findOneOrFail({
|
||||||
// relations: ['tickets'],
|
relations: ['tickets'],
|
||||||
// where: {
|
where: {
|
||||||
// customer: customer_name,
|
customer: customer_name,
|
||||||
// phone: customer_phone,
|
phone: customer_phone,
|
||||||
// date: Between(start, end),
|
date: Between(start, end),
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
|
|
||||||
// return order;
|
return order;
|
||||||
// }
|
}
|
||||||
|
|
||||||
return order;
|
return order;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ export class GenerateQueueManager {
|
||||||
async generate(transaction: TransactionModel) {
|
async generate(transaction: TransactionModel) {
|
||||||
const date = transaction.booking_date ?? transaction.invoice_date;
|
const date = transaction.booking_date ?? transaction.invoice_date;
|
||||||
const queue_date = moment(date, 'YYYY-MM-DD').unix();
|
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;
|
const { id, customer_name, customer_phone, invoice_code } = transaction;
|
||||||
|
|
||||||
|
@ -40,10 +41,9 @@ export class GenerateQueueManager {
|
||||||
|
|
||||||
const items = this.generateItems(transaction.items);
|
const items = this.generateItems(transaction.items);
|
||||||
|
|
||||||
const existTicket = await this.ticketService.ticketByUser(
|
const existTicket = isToday
|
||||||
customer_name,
|
? await this.ticketService.ticketByUser(customer_name, customer_phone)
|
||||||
customer_phone,
|
: null;
|
||||||
);
|
|
||||||
|
|
||||||
const insertTickets: QueueTicket[] = [];
|
const insertTickets: QueueTicket[] = [];
|
||||||
if (customer_name && customer_phone && existTicket) {
|
if (customer_name && customer_phone && existTicket) {
|
||||||
|
|
Loading…
Reference in New Issue