Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def confirm_seats_reservations
- @order.connection.sections.each do |section|
- if section.train.brand.name == 'LS'
- sprinter = SprinterClient.new
- @order.bookings.pluck(:booking_nr).uniq.each do |booking_nr|
- sprinter.confirm_booking(booking_nr)
- end
- elsif section.train.brand.name == 'LEO'
- connection = @order.connection
- train = @order.connection.sections.first.train
- # travel_train = @order.connection.unpersist
- travel_train = Travel::Train.new(train_id: train.id, start_date: connection.sections.first.start_date, finish_date: train.sections.last.end_date, connection_id: connection.id,
- first_station: train.sections.first.start_stop.station_id, last_station: train.sections.last.end_stop.station_id)
- connector = LeoSales::Connector.new([travel_train], @order.passengers)
- # TODO Zakładamy, że można zwrócić bilet do 15 min przed odjazdem, zweryfikować!
- return_order_expiration = ((@order.valid_from - 15.minutes) - Time.zone.now).to_i
- book_params = REDIS_POOL.with do |redis|
- redis.expire("Leo_reservation_#{connection.id}_#{train.id}_#{@order.passengers.map(&:id).sort}", return_order_expiration)
- redis.get("Leo_reservation_#{connection.id}_#{train.id}_#{@order.passengers.map(&:id).sort}")
- end
- parsed_book_params = JSON.parse(book_params)
- order_code = parsed_book_params["order_code"]
- connector.pay_order(order_code)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement