Beispiel #1
0
        public object QueryRecommand(string departure, string arrival, DateTime flightDate, decimal currentPrice)
        {
            DateTime prev      = flightDate.AddDays(-1).Date;
            DateTime current   = flightDate.Date;
            DateTime next      = flightDate.AddDays(1).Date;
            var      dateItems = new List <DateTime>();

            if (prev > DateTime.Today)
            {
                dateItems.Add(prev);
            }
            dateItems.Add(current);
            dateItems.Add(next);

            Dictionary <DateTime, IEnumerable <Flight> > historyFlights = FlightQueryService.QueryFlightFromHistory(new UpperString(departure), new UpperString(arrival), dateItems);

            if (currentPrice <= 0)
            {
                FlightView flight = FlightReserveModule.ChoosePolicy.GetFlights(FlightReserveModule.ChoosePolicy.ImportSource).First();
                if (flight.BunkType == BunkType.Economic || flight.BunkType == BunkType.FirstOrBusiness)
                {
                    currentPrice = flight.Fare;
                }
                else
                {
                    PriceView patPrice = FlightReserveModule.ChoosePolicy.GetPATPrice(FlightReserveModule.ChoosePolicy.ImportSource);
                    if (patPrice != null)
                    {
                        currentPrice = patPrice.Fare;
                    }
                }
                if (currentPrice <= 0)
                {
                    return(new
                    {
                        Today = new object[0],
                        Yestoday = new object[0],
                        Tomorrow = new object[0]
                    });
                }
            }
            Dictionary <DateTime, IEnumerable <InstructionalFlight> > matchedFlight = PolicyMatchServcie.MatchInstructionalFlights(historyFlights, currentPrice,
                                                                                                                                   CurrentCompany.CompanyId, policys => MatchedPolicyCache = policys.ToList());

            for (int i = 0; i < dateItems.Count; i++)
            {
                FliterRepeater(matchedFlight.ElementAt(i));
            }
            return(new
            {
                Today = matchedFlight[current].Select(RecommandSelector),
                Yestoday = matchedFlight.ContainsKey(prev) ? matchedFlight[prev].Select(RecommandSelector) : null,
                Tomorrow = matchedFlight[next].Select(RecommandSelector)
            });
        }
Beispiel #2
0
        private static PnrImportResult importAdultOrder(HttpContext context, ReservedPnr adultPNRContent, OrderSource orderSource, PriceView patPrice, PriceView maxpatPrice)
        {
            CheckFligtTime(adultPNRContent);
            IEnumerable <FlightView> reservedFlights = ReserveViewConstuctor.GetQueryFlightView(adultPNRContent.Voyage.Segments, adultPNRContent.Voyage.Type, PassengerType.Adult,
                                                                                                adultPNRContent.IsTeam, patPrice);
            bool isFreeTicket = adultPNRContent.Voyage.Segments.Any() && reservedFlights.First().BunkType.Value == BunkType.Free;

            //如果遇到证件号不全体提编码
            if (adultPNRContent.Passengers.Any(p => string.IsNullOrEmpty(p.CertificateNumber)) && !PNRPair.IsNullOrEmpty(adultPNRContent.PnrPair))
            {
                var pnr = adultPNRContent.PnrPair.PNR;
                ExecuteResult <ReservedPnr> rtResult = CommandService.GetReservedPnr(adultPNRContent.PnrPair, BasePage.OwnerOEMId);
                if (rtResult.Success && !rtResult.Result.HasCanceled)
                {
                    string patContent = adultPNRContent.PatRawData;
                    adultPNRContent             = rtResult.Result;
                    adultPNRContent.PnrPair.PNR = pnr;
                    adultPNRContent.PatRawData  = patContent;
                }
            }
            CommandService.ValidatePNR(adultPNRContent, PassengerType.Adult);
            if (!isFreeTicket && patPrice == null)
            {
                return(new PnrImportResult(false, "需要输入PAT内容", true));
            }
            if (isFreeTicket)
            {
                Segment segment = adultPNRContent.Voyage.Segments.First();
                Flight  flight  = FlightQueryService.QueryFlight(segment.AirportPair.Departure, segment.AirportPair.Arrival,
                                                                 segment.Date.AddHours(segment.DepartureTime.Hour).AddMinutes(segment.DepartureTime.Minute), segment.AirlineCode, segment.InternalNo, BasePage.OwnerOEMId);
                if (flight != null)
                {
                    patPrice = new PriceView
                    {
                        Total                  = flight.BAF.Adult + flight.AirportFee,
                        Fare                   = 0m,
                        AirportTax             = flight.AirportFee,
                        BunkerAdjustmentFactor = flight.BAF.Adult
                    };
                }
            }
            if (patPrice == null)
            {
                throw new CustomException("缺少PAT内容");
            }
            //if (adultPNRContent.Price != null) throw new CustomException("成人编码中不能包含票价组项");
            saveImportInfo(context, adultPNRContent, null, orderSource, patPrice, maxpatPrice, PassengerType.Adult);
            return(new PnrImportResult(true));
        }