use of alfio.model.Audit.EventType.CANCEL_TICKET in project alf.io by alfio-event.
the class AdminReservationManager method removeTicketsFromReservation.
private void removeTicketsFromReservation(TicketReservation reservation, Event event, List<Integer> ticketIds, boolean notify, String username, boolean removeReservation) {
String reservationId = reservation.getId();
if (notify && !ticketIds.isEmpty()) {
Organization o = eventManager.loadOrganizer(event, username);
ticketRepository.findByIds(ticketIds).forEach(t -> {
if (StringUtils.isNotBlank(t.getEmail())) {
sendTicketHasBeenRemoved(event, o, t);
}
});
}
Integer userId = userRepository.findIdByUserName(username).orElse(null);
Date date = new Date();
ticketIds.forEach(id -> auditingRepository.insert(reservationId, userId, event.getId(), CANCEL_TICKET, date, TICKET, id.toString()));
ticketRepository.resetCategoryIdForUnboundedCategoriesWithTicketIds(ticketIds);
ticketFieldRepository.deleteAllValuesForTicketIds(ticketIds);
MapSqlParameterSource[] args = ticketIds.stream().map(id -> new MapSqlParameterSource("ticketId", id).addValue("reservationId", reservationId).addValue("eventId", event.getId()).addValue("newUuid", UUID.randomUUID().toString())).toArray(MapSqlParameterSource[]::new);
jdbc.batchUpdate(ticketRepository.batchReleaseTickets(), args);
if (!removeReservation) {
// #407 update invoice/receipt model only if the reservation is still "PENDING", otherwise we could lead to accountancy problems
if (UPDATE_INVOICE_STATUSES.contains(reservation.getStatus())) {
updateInvoiceReceiptModel(event, reservation.getUserLanguage(), reservationId);
}
extensionManager.handleTicketCancelledForEvent(event, ticketRepository.findUUIDs(ticketIds));
} else {
extensionManager.handleReservationsCancelledForEvent(event, ticketRepository.findReservationIds(ticketIds));
}
}
Aggregations