fix: enhance ticket retrieval logic to validate UUID format and adjust query conditions accordingly

pull/142/head
shancheas 2025-06-26 18:05:02 +07:00
parent 99889f425a
commit 14a86343df
1 changed files with 7 additions and 4 deletions

View File

@ -52,12 +52,15 @@ export class TicketDataService extends BaseDataService<QueueTicket> {
});
if (!order) {
// Check if id is a valid UUID format
const uuidRegex =
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
const whereCondition = !uuidRegex.test(id)
? { invoice_code: id, booking_date: new Date() }
: { id, booking_date: new Date() };
const { customer_name, customer_phone } =
await this.transaction.findOneOrFail({
where: {
id,
booking_date: new Date(),
},
where: whereCondition,
});
const start = moment().startOf('day').valueOf();