示例#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)
            });
        }
示例#2
0
 private decimal?getPatPrice(string source)
 {
     if (source != FlightReserveModule.ChoosePolicy.ChangeProviderSource)
     {
         PriceView patInfo = FlightReserveModule.ChoosePolicy.GetPATPrice(source);
         if (patInfo != null)
         {
             return(patInfo.Fare);
         }
     }
     return(null);
 }
示例#3
0
 private bool hasReduce(string source)
 {
     if (source == FlightReserveModule.ChoosePolicy.ChangeProviderSource)
     {
         return(FlightReserveModule.ChoosePolicy.GetOriginalOrder(source).IsReduce);
     }
     else
     {
         IEnumerable <FlightView> voyages = FlightReserveModule.ChoosePolicy.GetFlights(source);
         if (voyages.Count() == 2)
         {
             PriceView patPrice = FlightReserveModule.ChoosePolicy.GetPATPrice(source);
             if (patPrice != null)
             {
                 return(patPrice.Fare < voyages.Sum(item => item.Fare));
             }
         }
         return(false);
     }
 }