@Override
	public TicketPoolTicket[] book(final TicketPoolQueryArgs args) throws Exception {
		
		
		PlanTicket[] planTickets = Queries.query(this.query(args)).toArray(new PlanTicket[0]);
		
		
		
		for(PlanTicket pt : planTickets)
		{
			pt.getGroup().getTickets().remove(pt);
			if(pt.getGroup().getTickets().size() == 0)
			{
			    this._stopRangeGroups.remove(pt.getGroup());	
			}
			
			if(args.getDepartureStop() > pt.getStartStop())
			{
				PlanTicket pre = new PlanTicket();
				pre.setId(UUID.randomUUID());
				pre.setOrginalId(pt.getOrignalId());
				pre.setStartStop(pt.getStartStop());
				pre.setEndStop(args.getDepartureStop());
				pre.setSeat(pt.getSeat());
				pre.getSalableRange().copyFrom(pt.getSalableRange());
				this.addPlanTicketToGroup(pre);
				
			}
			
			
			if(args.getDestinationStop() < pt.getEndStop())
			{
				PlanTicket after = new PlanTicket();
				after.setId(UUID.randomUUID());
				after.setOrginalId(pt.getOrignalId());
				after.setStartStop(args.getDestinationStop());
				after.setEndStop(pt.getEndStop());
				after.setSeat(pt.getSeat());
				after.getSalableRange().copyFrom(pt.getSalableRange());
				this.addPlanTicketToGroup(after);
			}
			
			
		}
		
		
		if(this._stopRangeGroups.size() == 0)
		{
			this._isSoldOut = true;
		}
		
		
		TicketPoolTicket[] rs = new TicketPoolTicket[planTickets.length];
		
		for(int i = 0; i < planTickets.length; i++)
		{
			PlanTicket pt = planTickets[i];
			rs[i] = new TicketPoolTicket();
			rs[i].setSeat(pt.getSeat());
			rs[i].setDepartureStop(args.getDepartureStop());
			rs[i].setDestinationStop(args.getDestinationStop());
			rs[i].setPool(this);
		}
		
		
		return rs;
	}