Esempio n. 1
0
        private PNRInfo separate(PNRPair newPNRCode, IEnumerable <Guid> passengers)
        {
            var newPnrInfo = new PNRInfo
            {
                Code = newPNRCode
            };

            foreach (Guid item in passengers)
            {
                Passenger passenger = getPassenger(item);
                if (passenger == null)
                {
                    throw new CustomException("不存在的乘机人");
                }
                newPnrInfo.AddPassenger(passenger.Copy());
            }
            foreach (Flight flight in Flights)
            {
                newPnrInfo.AddFlight(flight.Copy());
            }
            removePassengers(passengers);
            return(newPnrInfo);
        }
Esempio n. 2
0
        internal static PNRInfo GetPNRInfo(OrderView orderView, MatchedPolicy policy)
        {
            if (policy == null)
            {
                throw new ArgumentNullException("policy");
            }
            var result = new PNRInfo
            {
                Code = orderView.PNR
            };
            PassengerType passengerType = orderView.Passengers.First().PassengerType;
            decimal?      averageFare   = null;

            if (orderView.PATPrice != null)
            {
                averageFare = Calculator.Round(orderView.PATPrice.Fare / orderView.Flights.Count(), 1);
            }
            Flight preFlight  = null;
            var    increasing = policy.OemInfo == null?0:policy.OemInfo.ProfitType == OemProfitType.PriceMarkup ? policy.OemInfo.TotalProfit / orderView.Flights.Count() : 0;

            foreach (FlightView item in orderView.Flights.OrderBy(f => f.TakeoffTime))
            {
                Flight flight = Flight.GetFlight(item, passengerType, policy, averageFare);
                flight.Increasing = increasing;
                if (preFlight == null)
                {
                    // 第一段
                    flight.Serial = 1;
                }
                else
                {
                    if (preFlight.Arrival.Code == flight.Departure.Code)
                    {
                        flight.Serial = preFlight.Serial + 1;
                    }
                    else
                    {
                        // 缺口程会跳一段(中间跳过的是搭进去的那一段)
                        flight.Serial = preFlight.Serial + 2;
                    }
                }
                result.AddFlight(flight);
                preFlight = flight;
            }
            // 调整航班价格信息
            if (orderView.PATPrice != null)
            {
                if (policy.PolicyType == PolicyType.Special)
                {
                    // 特殊政策 不调整票面价
                }
                else if (policy.PolicyType == PolicyType.Bargain)
                {
                    // 对于按价格或折扣方式发布的特价政策不调整票面价
                    var promotionPolicy = policy.OriginalPolicy as BargainPolicyInfo;
                    if (promotionPolicy == null || promotionPolicy.PriceType == PriceType.Commission || promotionPolicy.PriceType == PriceType.Subtracting ||
                        promotionPolicy.Price < 0)
                    {
                        result.reviseFare(orderView.PATPrice.Fare);
                    }
                }
                else if (orderView.Source != OrderSource.PlatformOrder && !orderView.IsTeam && result.Flights.Count() == 1 && result.Flights.First().Bunk is GeneralBunk)
                {
                    // 非预订时,普通舱位的单程不调整票面价
                }
                else
                {
                    result.reviseFare(orderView.PATPrice.Fare);
                }

                // 机建
                result.reviseAirportFee(orderView.PATPrice.AirportTax);
            }
            foreach (PassengerView item in orderView.Passengers)
            {
                Passenger passenger = Passenger.GetPassenger(item);
                passenger.FillFlights(result.Flights);
                result.AddPassenger(passenger);
            }
            return(result);
        }