mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 20:38:17 +00:00
Seatmap rendering and other updates
This commit is contained in:
@@ -44,6 +44,54 @@ export class PaymentsService {
|
||||
]);
|
||||
}
|
||||
|
||||
async getAll(filters: { search?: string; status?: string; method?: string; page?: number; pageSize?: number }) {
|
||||
const { search, status, method, page = 1, pageSize = 10 } = filters;
|
||||
const skip = (page - 1) * pageSize;
|
||||
|
||||
const where: any = {};
|
||||
if (search) {
|
||||
where.OR = [
|
||||
{ id: { contains: search, mode: 'insensitive' } },
|
||||
{ booking: { bookingRef: { contains: search, mode: 'insensitive' } } },
|
||||
];
|
||||
}
|
||||
if (status) {
|
||||
where.status = status;
|
||||
}
|
||||
if (method) {
|
||||
where.method = method;
|
||||
}
|
||||
|
||||
const [items, total] = await Promise.all([
|
||||
this.prisma.paymentIntent.findMany({
|
||||
where,
|
||||
include: { booking: true },
|
||||
skip,
|
||||
take: pageSize,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
this.prisma.paymentIntent.count({ where }),
|
||||
]);
|
||||
|
||||
return {
|
||||
items: items.map(item => ({
|
||||
id: item.id,
|
||||
reference: item.id.substring(0, 8),
|
||||
bookingId: item.bookingId,
|
||||
booking: { bookingRef: item.booking?.bookingRef },
|
||||
amountMinor: item.amountMinor,
|
||||
currency: item.currency,
|
||||
method: item.method,
|
||||
status: item.status,
|
||||
createdAt: item.createdAt,
|
||||
paidAt: item.paidAt,
|
||||
})),
|
||||
total,
|
||||
page,
|
||||
pageSize,
|
||||
};
|
||||
}
|
||||
|
||||
async initiatePayment(dto: InitiatePaymentDto): Promise<InitiateResponseDto> {
|
||||
const booking = await this.prisma.booking.findUnique({
|
||||
where: { id: dto.bookingId },
|
||||
|
||||
Reference in New Issue
Block a user