mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 08:25:43 +00:00
Refactor business logic for train,schedule,coach,seat and search modules
This commit is contained in:
@@ -17,8 +17,8 @@ export class AgentsService {
|
||||
if (!agent || !agent.active) throw new NotFoundException('Agent not found or inactive');
|
||||
if (!agent.user.passenger) throw new BadRequestException('Agent must have passenger account');
|
||||
|
||||
const trip = await this.prisma.trip.findUnique({ where: { id: dto.tripId } });
|
||||
if (!trip) throw new NotFoundException('Trip not found');
|
||||
const schedule = await this.prisma.trainSchedule.findUnique({ where: { id: dto.scheduleId } });
|
||||
if (!schedule) throw new NotFoundException('Schedule not found');
|
||||
|
||||
const seatIds = dto.passengers.map(p => p.seatId);
|
||||
const seats = await this.prisma.seat.findMany({ where: { id: { in: seatIds } } });
|
||||
@@ -31,7 +31,7 @@ export class AgentsService {
|
||||
data: {
|
||||
bookingRef: generateRef(),
|
||||
passengerId: agent.user.passenger.id,
|
||||
tripId: dto.tripId,
|
||||
scheduleId: dto.scheduleId,
|
||||
status: dto.paymentMethod === 'CASH' ? 'CONFIRMED' : 'PENDING_PAYMENT',
|
||||
totalMinor,
|
||||
seats: {
|
||||
|
||||
Reference in New Issue
Block a user