wip: notification emails surrounding groups bookings and inquiries
This commit is contained in:
1 parent
a1751f699b
commit
d0358e584c
6 files changed
+163
-162
No files matched your search
@@ -346,7 +346,6 @@ class AccommodationBookingService
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
'booking' => $booking,
|
||||
'priceBreakdown' => $this->breakdownCalculator->compute($booking) ?? [],
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
@@ -393,7 +392,6 @@ class AccommodationBookingService
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
'booking' => $booking,
|
||||
'priceBreakdown' => $this->breakdownCalculator->compute($booking) ?? [],
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
@@ -425,8 +423,8 @@ class AccommodationBookingService
|
||||
}
|
||||
|
||||
/**
|
||||
* Transitions a booking from inquiry to booking. Idempotent — a no-op if the booking
|
||||
* is already accepted.
|
||||
* Transitions a booking from inquiry to booking and notifies office and customer.
|
||||
* Idempotent — a no-op (including no emails) if the booking is already accepted.
|
||||
*/
|
||||
public function acceptBooking(AccommodationBooking $booking): void
|
||||
{
|
||||
@@ -437,6 +435,55 @@ class AccommodationBookingService
|
||||
$booking->setIsInquiry(false);
|
||||
$booking->setAcceptedAt(new \DateTimeImmutable());
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->sendOfferAcceptedNotificationEmail($booking);
|
||||
$this->sendOfferAcceptedCustomerEmail($booking);
|
||||
}
|
||||
|
||||
public function sendOfferAcceptedNotificationEmail(AccommodationBooking $booking): void
|
||||
{
|
||||
try {
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
'booking' => $booking,
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
'to' => $this->officeEmail,
|
||||
'subject' => sprintf('Angebot angenommen: %s', $booking->getAccommodation()?->getName()),
|
||||
'template' => 'email/offer_accepted.html.twig',
|
||||
'attachments' => [],
|
||||
],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to send offer accepted notification email', [
|
||||
'booking_id' => $booking->getId(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function sendOfferAcceptedCustomerEmail(AccommodationBooking $booking): void
|
||||
{
|
||||
try {
|
||||
$this->mailer->createAndSendEmail(
|
||||
[
|
||||
'booking' => $booking,
|
||||
'accessLink' => $this->accessLinkOrNull($booking),
|
||||
],
|
||||
[
|
||||
'to' => $booking->getEmail(),
|
||||
'subject' => 'Deine Buchung ist bestätigt',
|
||||
'template' => 'email/offer_accepted_customer.html.twig',
|
||||
'attachments' => [],
|
||||
],
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->error('Failed to send offer accepted customer email', [
|
||||
'booking_id' => $booking->getId(),
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function accessLinkOrNull(AccommodationBooking $booking): ?string
|
||||
|
||||
Reference in new issue
Block a user