feat: inquiry bookings
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Service;
|
||||
|
||||
use App\BusProNet\Model\Room;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Exception\BookingNotPossibleException;
|
||||
use App\Exception\BookingSessionNotFoundException;
|
||||
use App\Exception\NoRoomsAvailableException;
|
||||
use App\Form\Model\BookingDto;
|
||||
@@ -166,6 +167,11 @@ class BookingService
|
||||
* This method initializes a new BookingDto with empty room selections
|
||||
* and saves it to the session. It's designed to be called from the clean
|
||||
* booking entry point without requiring UID parameters.
|
||||
*
|
||||
* Handles three booking status types:
|
||||
* - 'Frei': Regular booking with availability checks
|
||||
* - 'Anfrage': Inquiry booking, allows booking even with 0 availability
|
||||
* - 'Buchungsstop': Booking stopped, no bookings allowed
|
||||
*/
|
||||
public function startFreshBooking(Request $request, int $dateId, int $hotelId, ?int $agencyId = null): BookingDto
|
||||
{
|
||||
@@ -174,13 +180,31 @@ class BookingService
|
||||
throw new NotFoundHttpException(sprintf('Travel data not found for date ID %d and hotel ID %d', $dateId, $hotelId));
|
||||
}
|
||||
|
||||
// Handle Buchungsstop - no bookings allowed at all
|
||||
if ('Buchungsstop' === $travelData->status) {
|
||||
throw new BookingNotPossibleException($dateId, $hotelId);
|
||||
}
|
||||
|
||||
// Determine booking status based on travel status
|
||||
$isInquiryBooking = 'Anfrage' === $travelData->status;
|
||||
$bookingStatus = $isInquiryBooking ? 'A' : 'F';
|
||||
|
||||
// Get available rooms
|
||||
$availableRooms = $travelData->getAvailableRooms();
|
||||
|
||||
// Prevent booking flow entry when no rooms are available
|
||||
if (empty($availableRooms)) {
|
||||
// For regular bookings (Frei), prevent entry when no rooms are available
|
||||
// For inquiry bookings (Anfrage), allow even with 0 availability
|
||||
if (false === $isInquiryBooking && empty($availableRooms)) {
|
||||
throw new NoRoomsAvailableException($dateId, $hotelId);
|
||||
}
|
||||
|
||||
// For inquiry bookings with 0 availability, get all rooms ignoring availability count
|
||||
if ($isInquiryBooking && empty($availableRooms)) {
|
||||
$availableRooms = array_filter($travelData->rooms, function (Room $room) {
|
||||
return \App\BusProNet\Constants::STATUS_AVAILABLE === $room->status;
|
||||
});
|
||||
}
|
||||
|
||||
// Create room selections with zero quantities (user will set these in step 1)
|
||||
$roomSelections = array_map(
|
||||
fn (Room $room) => $this->createRoomSelection($room, []),
|
||||
@@ -191,6 +215,7 @@ class BookingService
|
||||
$bookingCreateDto->roomSelections = $roomSelections;
|
||||
$bookingCreateDto->currentStep = 1;
|
||||
$bookingCreateDto->agencyId = $agencyId;
|
||||
$bookingCreateDto->bookingStatus = $bookingStatus;
|
||||
|
||||
$this->saveBookingCreateDto($request, $bookingCreateDto);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user