feat: additional status
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Entity\Groups\AccommodationBooking;
|
||||
use App\Entity\Groups\AccommodationPrice;
|
||||
use App\Entity\Groups\AdditionalService;
|
||||
use App\Entity\Groups\BoardService;
|
||||
use App\Enum\Groups\AccommodationBookingStatus;
|
||||
use App\Form\Model\AccommodationBookingDto;
|
||||
use App\Model\AccommodationBookingQueryParams;
|
||||
use App\Model\CmsHotelData;
|
||||
@@ -264,7 +265,11 @@ class AccommodationBookingService
|
||||
$booking->setPaxCount($dto->paxCount);
|
||||
$booking->setMinorsCount($dto->minorsCount);
|
||||
$booking->setChildrenCount($dto->childrenCount);
|
||||
$booking->setIsInquiry($dto->forceInquiry || $this->computeInquiryStatus($dto, $prices)->isInquiry);
|
||||
$booking->setStatus(
|
||||
$dto->forceInquiry || $this->computeInquiryStatus($dto, $prices)->isInquiry
|
||||
? AccommodationBookingStatus::Inquiry
|
||||
: AccommodationBookingStatus::Booking
|
||||
);
|
||||
|
||||
// Freeze board service as scalar fields (no FK)
|
||||
if (null !== $dto->selectedBoardServiceId) {
|
||||
@@ -412,13 +417,13 @@ class AccommodationBookingService
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets accessLinkIssuedAt for a direct (non-inquiry) booking if it doesn't have one yet.
|
||||
* Sets accessLinkIssuedAt if the booking doesn't have one yet, whatever its status.
|
||||
* No email side effect — the confirmation email is always sent separately via
|
||||
* sendCustomerConfirmationEmail(), regardless of whether a link exists.
|
||||
*/
|
||||
public function issueAccessLinkForDirectBooking(AccommodationBooking $booking): void
|
||||
public function issueAccessLink(AccommodationBooking $booking): void
|
||||
{
|
||||
if ($booking->isInquiry() || null !== $booking->getAccessLinkIssuedAt()) {
|
||||
if (null !== $booking->getAccessLinkIssuedAt()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -426,18 +431,39 @@ class AccommodationBookingService
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Issues the access link only for a confirmed booking. Inquiries from the public flow
|
||||
* deliberately get no link — the office prepares the offer first and issues the link
|
||||
* when it switches the booking to Anfrage.
|
||||
*/
|
||||
public function issueAccessLinkForDirectBooking(AccommodationBooking $booking): void
|
||||
{
|
||||
if (!$booking->isBooking()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->issueAccessLink($booking);
|
||||
}
|
||||
|
||||
/**
|
||||
* Always sends a confirmation email to the customer, whether or not an access link
|
||||
* exists yet — the template renders differently depending on accessLink being present.
|
||||
* exists yet — the template renders differently depending on accessLink being present,
|
||||
* so the subject has to follow the same distinction.
|
||||
*/
|
||||
public function sendCustomerConfirmationEmail(AccommodationBooking $booking): void
|
||||
{
|
||||
if (!$booking->isInquiry()) {
|
||||
$subject = 'Deine Buchung ist bestätigt';
|
||||
} elseif (null !== $booking->getAccessLinkIssuedAt()) {
|
||||
$subject = 'Dein Angebot ist bereit';
|
||||
} else {
|
||||
$subject = 'Deine Anfrage ist bei uns eingegangen';
|
||||
}
|
||||
|
||||
$this->sendBookingEmail(
|
||||
$booking,
|
||||
$booking->getEmail(),
|
||||
$booking->isInquiry()
|
||||
? 'Deine Anfrage ist bei uns eingegangen'
|
||||
: 'Deine Buchung ist bestätigt',
|
||||
$subject,
|
||||
'email/accommodation_booking_customer.html.twig',
|
||||
'Failed to send accommodation booking customer confirmation email',
|
||||
);
|
||||
@@ -464,7 +490,7 @@ class AccommodationBookingService
|
||||
return;
|
||||
}
|
||||
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setStatus(AccommodationBookingStatus::Booking);
|
||||
$booking->setAcceptedAt(new \DateTimeImmutable());
|
||||
$this->entityManager->flush();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user