use of alfio.model.AdditionalServiceItem.AdditionalServiceItemStatus in project alf.io by alfio-event.
the class TicketReservationManager method acquireItems.
private void acquireItems(TicketStatus ticketStatus, AdditionalServiceItemStatus asStatus, PaymentProxy paymentProxy, String reservationId, String email, CustomerName customerName, String userLanguage, String billingAddress, int eventId) {
Map<Integer, Ticket> preUpdateTicket = ticketRepository.findTicketsInReservation(reservationId).stream().collect(toMap(Ticket::getId, Function.identity()));
int updatedTickets = ticketRepository.updateTicketsStatusWithReservationId(reservationId, ticketStatus.toString());
Map<Integer, Ticket> postUpdateTicket = ticketRepository.findTicketsInReservation(reservationId).stream().collect(toMap(Ticket::getId, Function.identity()));
postUpdateTicket.forEach((id, ticket) -> {
auditUpdateTicket(preUpdateTicket.get(id), Collections.emptyMap(), ticket, Collections.emptyMap(), eventId);
});
int updatedAS = additionalServiceItemRepository.updateItemsStatusWithReservationUUID(reservationId, asStatus);
Validate.isTrue(updatedTickets + updatedAS > 0, "no items have been updated");
specialPriceRepository.updateStatusForReservation(singletonList(reservationId), Status.TAKEN.toString());
ZonedDateTime timestamp = ZonedDateTime.now(ZoneId.of("UTC"));
int updatedReservation = ticketReservationRepository.updateTicketReservation(reservationId, TicketReservationStatus.COMPLETE.toString(), email, customerName.getFullName(), customerName.getFirstName(), customerName.getLastName(), userLanguage, billingAddress, timestamp, paymentProxy.toString());
Validate.isTrue(updatedReservation == 1, "expected exactly one updated reservation, got " + updatedReservation);
waitingQueueManager.fireReservationConfirmed(reservationId);
if (paymentProxy == PaymentProxy.PAYPAL || paymentProxy == PaymentProxy.ADMIN) {
// we must notify the plugins about ticket assignment and send them by email
Event event = eventRepository.findByReservationId(reservationId);
TicketReservation reservation = findById(reservationId).orElseThrow(IllegalStateException::new);
findTicketsInReservation(reservationId).stream().filter(ticket -> StringUtils.isNotBlank(ticket.getFullName()) || StringUtils.isNotBlank(ticket.getFirstName()) || StringUtils.isNotBlank(ticket.getEmail())).forEach(ticket -> {
Locale locale = Locale.forLanguageTag(ticket.getUserLanguage());
if (paymentProxy == PaymentProxy.PAYPAL) {
sendTicketByEmail(ticket, locale, event, getTicketEmailGenerator(event, reservation, locale));
}
extensionManager.handleTicketAssignment(ticket);
});
}
}
use of alfio.model.AdditionalServiceItem.AdditionalServiceItemStatus in project alf.io by alfio-event.
the class TicketReservationManager method completeReservation.
/**
* Set the tickets attached to the reservation to the ACQUIRED state and the ticket reservation to the COMPLETE state. Additionally it will save email/fullName/billingaddress/userLanguage.
*/
void completeReservation(int eventId, String reservationId, String email, CustomerName customerName, Locale userLanguage, String billingAddress, Optional<String> specialPriceSessionId, PaymentProxy paymentProxy) {
if (paymentProxy != PaymentProxy.OFFLINE) {
TicketStatus ticketStatus = paymentProxy.isDeskPaymentRequired() ? TicketStatus.TO_BE_PAID : TicketStatus.ACQUIRED;
AdditionalServiceItemStatus asStatus = paymentProxy.isDeskPaymentRequired() ? AdditionalServiceItemStatus.TO_BE_PAID : AdditionalServiceItemStatus.ACQUIRED;
acquireItems(ticketStatus, asStatus, paymentProxy, reservationId, email, customerName, userLanguage.getLanguage(), billingAddress, eventId);
final TicketReservation reservation = ticketReservationRepository.findReservationById(reservationId);
extensionManager.handleReservationConfirmation(reservation, eventId);
// cleanup unused special price codes...
specialPriceSessionId.ifPresent(specialPriceRepository::unbindFromSession);
}
auditingRepository.insert(reservationId, null, eventId, Audit.EventType.RESERVATION_COMPLETE, new Date(), Audit.EntityType.RESERVATION, reservationId);
}
Aggregations