fix: enhance ticket retrieval logic to validate UUID format and adjust query conditions accordingly
parent
99889f425a
commit
14a86343df
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue