示例#1
0
        /// <summary>
        /// 生成订单
        /// </summary>
        public string ProduceOrder(Guid policyId, PolicyType policyType, Guid publisher, string officeNo, string source, int choise, bool needAUTH, bool HasSubsidized,
                                   bool IsUsePatPrice, bool forbidChnagePNR)
        {
            var           orderView     = Session["OrderView"] as OrderView;
            var           flights       = Session["ReservedFlights"] as IEnumerable <FlightView>;
            MatchedPolicy matchedPolicy = MatchedPolicyCache.FirstOrDefault(p => p.Id == policyId);

            if (matchedPolicy == null)
            {
                throw new CustomException("政策选择超时");
            }
            if (flights.First().BunkType != null && orderView.Source == OrderSource.PlatformOrder &&
                (flights.First().BunkType == BunkType.Free || matchedPolicy.OriginalPolicy is SpecialPolicyInfo && ((SpecialPolicyInfo)matchedPolicy.OriginalPolicy).Type == SpecialProductType.LowToHigh))
            {
                SpecialPolicy policy = PolicyManageService.GetSpecialPolicy(policyId);
                //低打高返和集团票性质一样 不需要去订坐 2013-4-3 wangsl
                //if (policy != null && (policy.SynBlackScreen||policy.Type==SpecialProductType.LowToHigh))
                if (policy != null && policy.SynBlackScreen)
                {
                    PNRPair pnr = PNRHelper.ReserveSeat(flights, orderView.Passengers);
                    orderView.PNR = pnr;
                }
            }
            Order order = OrderProcessService.ProduceOrder(orderView, matchedPolicy, CurrentUser, BasePage.OwnerOEMId, forbidChnagePNR, (AuthenticationChoise)choise);

            FlightQuery.ClearFlightQuerySessions();
            if (order.Source == OrderSource.PlatformOrder && !PNRPair.IsNullOrEmpty(order.ReservationPNR) && !String.IsNullOrWhiteSpace(order.Product.OfficeNo))
            {
                if (needAUTH)
                {
                    authorize(order.ReservationPNR, officeNo, source, BasePage.OwnerOEMId);
                }
            }
            return(order.Id.ToString());
        }
示例#2
0
        protected override string ExecuteCore()
        {
            var flights    = Context.GetParameterValue("flights");
            var passengers = Context.GetParameterValue("passengers");
            var contact    = Context.GetParameterValue("contact");
            var policyType = Context.GetParameterValue("policyType");

            Vaild(flights, passengers, contact, policyType, InterfaceSetting);

            DataTransferObject.Order.OrderView orderView = new DataTransferObject.Order.OrderView();
            bindOrderView(flights, passengers, contact, orderView);
            var pnrh = new PNRHelper();

            try
            {
                if ((PolicyType)byte.Parse(policyType) != PolicyType.Special)
                {
                    PNRPair pnr = pnrh.ReserveSeat(loadFlightView(flights, passengers), orderView.Passengers, Employee, Company);
                    orderView.PNR = pnr;
                }
                if (pnrh.RequirePat(loadFlightView(flights, passengers), (PolicyType)byte.Parse(policyType)))
                {
                    orderView.PATPrice = pnrh.Pat(orderView.PNR, loadFlightView(flights, passengers), PassengerType.Adult);
                }
                MatchedPolicy policy = QueryPolicies((PolicyType)byte.Parse(policyType), flights, passengers, orderView);
                if (policy != null)
                {
                    if (policy.PolicyType == PolicyType.Special)
                    {
                        var p = PolicyManageService.GetSpecialPolicy(policy.Id);
                        if (p != null && p.SynBlackScreen)
                        {
                            PNRPair pnr = pnrh.ReserveSeat(loadFlightView(flights, passengers), orderView.Passengers, Employee, Company);
                            orderView.PNR = pnr;
                        }
                    }
                    orderView.IsTeam = false;
                    orderView.Source = OrderSource.InterfaceReservaOrder;
                    Order order = OrderProcessService.ProduceOrder(orderView, policy, Employee, Guid.Empty, false);
                    if (order.Source == OrderSource.InterfaceReservaOrder && !PNRPair.IsNullOrEmpty(order.ReservationPNR) && !String.IsNullOrWhiteSpace(order.Product.OfficeNo))
                    {
                        if (policy.NeedAUTH && !string.IsNullOrEmpty(policy.OfficeNumber))
                        {
                            authorize(order.ReservationPNR, policy.OfficeNumber);
                        }
                    }
                    return("<id>" + order.Id + "</id><payable>" + (policy.ConfirmResource ? 0 : 1) + "</payable>" + ReturnStringUtility.GetOrder(order));
                }
            }
            catch (Exception ex)
            {
                InterfaceInvokeException.ThrowCustomMsgException(ex.Message);
            }
            InterfaceInvokeException.ThrowCustomMsgException("生成订单失败,没有对应直达航班!");
            return("");
        }
示例#3
0
        protected static SupplierInfo getSupplierInfo(MatchedPolicy specialPolicy, SpeicalProductInfo product)
        {
            var supplier = CompanyService.GetCompanyDetail(specialPolicy.Provider);

            if (!publisherIsValid(supplier))
            {
                throw new CustomException("产品发布方已无效,无法生成订单");
            }
            return(new Domain.SupplierInfo(specialPolicy.Provider, supplier.AbbreviateName)
            {
                Rebate = Deduction.GetDeduction(specialPolicy).Supplier,
                Product = product
            });
        }
示例#4
0
        protected static ProviderInfo getProvider(MatchedPolicy policy, ProductInfo product)
        {
            var provider = CompanyService.GetCompanyDetail(policy.Provider);

            if (!publisherIsValid(provider))
            {
                throw new CustomException("出票方已无效,无法生成订单");
            }
            return(new Domain.ProviderInfo(policy.Provider, provider.AbbreviateName)
            {
                Rebate = Deduction.GetDeduction(policy).Provider,
                Product = product,
                PurchaserRelationType = policy.RelationType,
            });
        }
示例#5
0
        /// <summary>
        /// 生成申请单
        /// </summary>
        public string ProduceApplyform(Guid policyId, PolicyType policyType, string officeNo, decimal orderId, string source, int choise, bool needAUTH, bool IsUsePatPrice)
        {
            var           applyformView = Session["ApplyformView"] as UpgradeApplyformView;
            MatchedPolicy matchedPolicy = MatchedPolicyCache.FirstOrDefault(p => p.Id == policyId);

            if (matchedPolicy == null)
            {
                throw new CustomException("政策选择超时");
            }
            decimal newOrderId = OrderProcessService.Apply(orderId, applyformView, matchedPolicy, CurrentUser, BasePage.OwnerOEMId);

            FlightQuery.ClearFlightQuerySessions();
            if (needAUTH)
            {
                authorize(applyformView.NewPNR, officeNo, source, BasePage.OwnerOEMId);
            }
            BasePage.ReleaseLock(orderId);
            return(newOrderId.ToString());
        }
示例#6
0
        /// <summary>
        /// 换出票方
        /// </summary>
        internal void ChangeProvider(MatchedPolicy policy, bool forbidChangePNR)
        {
            checkCanChangeProvider(policy);
            var newProvider = getProvider(policy, ProductInfo.GetProductInfo(policy));

            if (newProvider.PurchaserRelationType == RelationType.Interior)
            {
                throw new CustomException("该政策是采购的上级发布的政策,不允许指向给该出票方,请重新选择");
            }
            this.Provider       = newProvider;
            this.ForbidChangPNR = forbidChangePNR;
            this.IsB3BOrder     = !policy.IsExternal;
            if (this.IsSpecial)
            {
                var deduction = Deduction.GetDeduction(policy);
                this.Supplier.Rebate = deduction.Purchaser;
            }
            this.Status = OrderStatus.PaidForETDZ;
            CustomNo    = policy.OriginalPolicy == null ? string.Empty : policy.OriginalPolicy.CustomCode;
        }
示例#7
0
 public void UpdateProvision(MatchedPolicy policy)
 {
     if (policy.PolicyType == PolicyType.Bargain || policy.PolicyType == PolicyType.BargainDefault)
     {
         var regulation = policy as IHasRegulation;
         Provider.Product.RefundAndReschedulingProvision.Refund     = regulation.RefundRegulation;
         Provider.Product.RefundAndReschedulingProvision.Scrap      = regulation.InvalidRegulation;
         Provider.Product.RefundAndReschedulingProvision.Transfer   = regulation.EndorseRegulation;
         Provider.Product.RefundAndReschedulingProvision.Alteration = regulation.ChangeRegulation;
     }
     else
     {
         var    flight            = PNRInfos.First().Flights.First();
         var    pattern           = new Regex("^[a-zA-Z\\d/]+$");
         var    details           = FoundationService.QueryDetailList(flight.Carrier.Code, flight.Bunk.Code).Where(item => pattern.IsMatch(item.Bunks));
         string refundRegulation  = string.Empty;
         string changeRegulation  = string.Empty;
         string endorseRegulation = string.Empty;
         foreach (var item in details)
         {
             refundRegulation  += "航班起飞前:" + item.ScrapBefore + ";航班起飞后:" + item.ScrapAfter;
             changeRegulation  += "航班起飞前:" + item.ChangeBefore + ";航班起飞后:" + item.ChangeAfter;
             endorseRegulation += item.Endorse;
         }
         if (string.IsNullOrWhiteSpace(refundRegulation))
         {
             refundRegulation = "以航司具体规定为准";
         }
         if (string.IsNullOrWhiteSpace(changeRegulation))
         {
             changeRegulation = "以航司具体规定为准";
         }
         Provider.Product.RefundAndReschedulingProvision.Refund     = refundRegulation;
         Provider.Product.RefundAndReschedulingProvision.Scrap      = details.Any() ? details.First().Scrap : "以航司具体规定为准";
         Provider.Product.RefundAndReschedulingProvision.Transfer   = endorseRegulation;
         Provider.Product.RefundAndReschedulingProvision.Alteration = changeRegulation;
     }
 }
示例#8
0
        protected override void ValidateBusinessParameters()
        {
            if (string.IsNullOrWhiteSpace(_pnrContent))
            {
                throw new InterfaceInvokeException("1", "编码");
            }
            if (string.IsNullOrWhiteSpace(_policyId))
            {
                throw new InterfaceInvokeException("1", "政策编号");
            }
            if (!Guid.TryParse(_policyId, out _Id))
            {
                throw new InterfaceInvokeException("1", "政策编号");
            }
            if (string.IsNullOrWhiteSpace(_orgbatchNo))
            {
                throw new InterfaceInvokeException("1", "导入批次号");
            }
            _batchNo   = _orgbatchNo.Substring(0, _orgbatchNo.Length - 1);
            _isNeedPat = _orgbatchNo.Substring(_orgbatchNo.Length - 1, 1);
            if (_contact.Trim() != "")
            {
                if (_contact.Split('|').Count() < 3)
                {
                    throw new InterfaceInvokeException("1", "联系信息不完整");
                }
                if (_contact.Split('|')[0].Trim() == "")
                {
                    throw new InterfaceInvokeException("8", "联系信息中姓名");
                }
                if (_contact.Split('|')[1].Trim() == "")
                {
                    throw new InterfaceInvokeException("8", "联系信息中手机");
                }
                //if (_contact.Split('|')[2].Trim() == "") throw new InterfaceInvokeException("8", "联系信息中邮箱");
            }
            if (_associatePNR != "")
            {
                if (!Regex.IsMatch(_associatePNR, "(\\w)+"))
                {
                    throw new InterfaceInvokeException("1", "关联编码");
                }
                if (_associatePNR.Split('|').Any() && _associatePNR.Split('|')[0] != "" && _associatePNR.Split('|')[0].Length != 6)
                {
                    throw new InterfaceInvokeException("1", "关联编码");
                }
                if (_associatePNR.Split('|').Count() == 2 && _associatePNR.Split('|')[1] != "" && _associatePNR.Split('|')[1].Length != 6)
                {
                    throw new InterfaceInvokeException("1", "关联编码");
                }
            }
            try
            {
                var result = CommandService.GetReservedPnr(_pnrContent);
                if (result.Success)
                {
                    _pnr = result.Result;
                }
            }
            catch (Exception)
            {
                throw new InterfaceInvokeException("1", "编码内容");
            }
            if (_pnr == null)
            {
                throw new InterfaceInvokeException("1", "编码内容");
            }
            //如果遇到证件号不全体提编码
            if (_pnr.Passengers.Any(p => string.IsNullOrEmpty(p.CertificateNumber)) && !PNRPair.IsNullOrEmpty(_pnr.PnrPair))
            {
                var rtResult = CommandService.GetReservedPnr(_pnr.PnrPair, Guid.Empty);
                if (rtResult.Success && !rtResult.Result.HasCanceled)
                {
                    _pnr = rtResult.Result;
                }
            }
            _flights = ReserveViewConstuctor.GetQueryFlightView(_pnr.Voyage.Segments, _pnr.Voyage.Type, _pnr.Passengers.First().Type, _pnr.IsTeam).ToList();
            if (!_flights.Any())
            {
                throw new InterfaceInvokeException("9", "编码中缺少航班信息");
            }
            var flight = _flights.FirstOrDefault();

            if (flight.BunkType != null && flight.BunkType.Value == BunkType.Free)
            {
                _patPrices = new List <DataTransferObject.Command.PNR.PriceView> {
                    new DataTransferObject.Command.PNR.PriceView {
                        AirportTax = flight.AirportFee, BunkerAdjustmentFactor = flight.BAF, Fare = 0, Total = flight.AirportFee + flight.BAF
                    }
                };
            }
            else
            {
                _patPrices = Service.Command.Domain.Utility.Parser.GetPatPrices(_pnrContent);
                if (_patPrices == null)
                {
                    throw new InterfaceInvokeException("9", "缺少PAT内容");
                }
                if (_patPrices.Count == 0)
                {
                    throw new InterfaceInvokeException("9", "缺少PAT内容");
                }
            }
            if (DataTransferObject.Common.PNRPair.IsNullOrEmpty(_pnr.PnrPair))
            {
                throw new InterfaceInvokeException("9", "内容中缺少编码");
            }
            if (string.IsNullOrWhiteSpace(_pnr.PnrPair.PNR) && string.IsNullOrWhiteSpace(_pnr.PnrPair.BPNR))
            {
                throw new InterfaceInvokeException("9", "编码信息不全");
            }
            //上次导入内容是没有传入pat信息,需要重新匹配政策
            if (_isNeedPat == "1")
            {
                PNRHelper.SaveImportInfo(_pnr, _pnr.PnrPair, _patPrices.MinOrDefaultElement(item => item.Fare), _pnr.Passengers.First().Type, _patPrices.MaxOrDefaultElement(item => item.Fare), out fdSuccess);
                var policyFilterCondition = GetPolicyFilter(_flights);
                //匹配政策
                List <MatchedPolicy> matchedPolicies        = Service.PolicyMatch.PolicyMatchServcie.MatchBunk(policyFilterCondition, false, _pnr.Passengers.First().Type, 10).ToList();
                List <MatchedPolicy> matchedSpeciafPolicies = null;
                if ((_policyType & PolicyType.Special) != PolicyType.Special && (_policyType & PolicyType.Team) != PolicyType.Team)
                {
                    policyFilterCondition  = GetPolicyFilter(_flights, PolicyType.Special);
                    matchedSpeciafPolicies = Service.PolicyMatch.PolicyMatchServcie.MatchBunk(policyFilterCondition, false, _pnr.Passengers.First().Type, 10).ToList();
                    if (!matchedPolicies.Any() && !matchedSpeciafPolicies.Any())
                    {
                        throw new InterfaceInvokeException("9", "没有找到相关政策");
                    }
                }
                if (!matchedPolicies.Any())
                {
                    throw new InterfaceInvokeException("9", "没有找到相关政策");
                }
                _matchedPolicy = matchedPolicies.FirstOrDefault(item => item.Id == _Id);
                if (_matchedPolicy == null)
                {
                    _matchedPolicy = matchedSpeciafPolicies.FirstOrDefault(item => item.Id == _Id);
                }
                if (_matchedPolicy == null && policyFilterCondition.SuitReduce)
                {
                    throw new InterfaceInvokeException("9", "您选择的政策不支持低打。请重新选择");
                }
                if (_matchedPolicy == null)
                {
                    throw new InterfaceInvokeException("9", "没有找到相关政策");
                }
            }
            else
            {
                //从缓存中取出政策
                _customContext = ContextCenter.Instance[_batchNo];
                if (_customContext == null)
                {
                    throw new InterfaceInvokeException("9", "政策选择超时,请重新导入pnr内容");
                }
                var matchedPolicies = _customContext[_pnr.PnrPair.BPNR + _pnr.PnrPair.PNR] as List <MatchedPolicy>;
                if (matchedPolicies == null)
                {
                    throw new InterfaceInvokeException("9", "政策选择超时,请重新导入pnr内容");
                }
                _matchedPolicy = matchedPolicies.FirstOrDefault(item => item.Id == _Id);
                if (_matchedPolicy == null)
                {
                    throw new InterfaceInvokeException("9", "没找到对应的政策,请重新导入pnr内容");
                }
            }
        }
示例#9
0
        internal static Order NewOrder(OrderView orderView, MatchedPolicy matchedPolicy, EmployeeDetailInfo employee, bool forbidChnagePnr, Guid oemid, AuthenticationChoise choise = AuthenticationChoise.NoNeedAUTH)
        {
            if (!orderView.Flights.Any())
            {
                throw new ArgumentNullException("orderView", "缺少航段信息");
            }
            if (!orderView.Passengers.Any())
            {
                throw new ArgumentNullException("orderView", "缺少乘机人信息");
            }
            if (matchedPolicy == null)
            {
                throw new CustomException("无相关政策信息");
            }

            var result = new Order {
                Contact          = orderView.Contact,
                ReservationPNR   = PNRPair.IsNullOrEmpty(orderView.PNR) ? null : orderView.PNR,
                IsReduce         = orderView.IsReduce,
                IsTeam           = orderView.IsTeam,
                AssociateOrderId = orderView.AssociateOrderId,
                AssociatePNR     = orderView.AssociatePNR,
                Source           = orderView.Source,
                Choise           = choise,
                CustomNo         = matchedPolicy.OriginalPolicy == null ? string.Empty : matchedPolicy.OriginalPolicy.CustomCode,
                VisibleRole      = OrderRole.Platform | OrderRole.Purchaser,
                IsB3BOrder       = true,
                ForbidChangPNR   = forbidChnagePnr,
                NeedAUTH         = matchedPolicy.OriginalPolicy == null ? matchedPolicy.NeedAUTH : matchedPolicy.OriginalPolicy.NeedAUTH
            };

            if (oemid != Guid.Empty)
            {
                result.OEMID = oemid;
            }
            var deduction      = Deduction.GetDeduction(matchedPolicy);
            var product        = ProductInfo.GetProductInfo(matchedPolicy);
            var specialProduct = product as SpeicalProductInfo;

            if (specialProduct != null && !hasETDZPermission(matchedPolicy.Provider, specialProduct))
            {
                result.Supplier = getSupplierInfo(matchedPolicy, specialProduct);
            }
            else
            {
                result.Provider = getProvider(matchedPolicy, product);
            }
            result.IsCustomerResource = ProductInfo.IsCustomerResource(matchedPolicy);
            result.IsStandby          = ProductInfo.IsStandby(matchedPolicy);
            result.Purchaser          = getPurchaserInfo(employee, deduction);
            var pnrInfo = PNRInfo.GetPNRInfo(orderView, matchedPolicy);

            result.AddPNRInfo(pnrInfo);
            result.TripType = pnrInfo.TripType;
            result.Status   = result.RequireConfirm ? OrderStatus.Applied : OrderStatus.Ordered;
            if (result.Status == OrderStatus.Applied)
            {
                result.VisibleRole |= result.IsThirdRelation ? OrderRole.Supplier : OrderRole.Provider;
            }
            return(result);
        }
示例#10
0
        private BunkInfo constructBunkView(Bunk bunk, MatchedPolicy policy, ChinaPay.B3B.Service.Foundation.Domain.BasicPrice price)
        {
            var result = new BunkInfo()
            {
                Policy = new ChinaPay.B3B.DataTransferObject.FlightQuery.PolicyView()
                {
                    Id               = policy.OriginalPolicy == null ? Guid.Empty : policy.OriginalPolicy.Id,
                    Owner            = policy.Provider,
                    Type             = policy.PolicyType,
                    CustomerResource = false
                }
            };

            result.ShowPrice = policy.ParValue != 0;
            if (policy.PolicyType == PolicyType.Special)
            {
                // 特殊票是单独处理的
                var specialPolicy = policy.OriginalPolicy as DataTransferObject.Policy.SpecialPolicyInfo;
                result.Code        = bunk == null ? string.Empty : bunk.Code;
                result.SeatCount   = bunk == null ? specialPolicy.ResourceAmount : bunk.SeatCount; // 剩余位置数 从政策上获取
                result.Fare        = policy.ParValue.TrimInvaidZero();                             // 票面价从政策上取
                result.Rebate      = string.Empty;                                                 // 无返点
                result.Amount      = policy.SettleAmount;
                result.Description = "特殊票";
                result.BunkType    = bunk == null ? new BunkType?() : bunk.Type;
                switch (specialPolicy.Type)
                {
                case SpecialProductType.Singleness:
                case SpecialProductType.Disperse:
                    result.Policy.CustomerResource = true;
                    break;

                case SpecialProductType.CostFree:
                    result.Policy.CustomerResource = !specialPolicy.SynBlackScreen;
                    result.ShowPrice = true;
                    break;
                }
            }
            else
            {
                result.Code      = bunk.Code;
                result.SeatCount = bunk.SeatCount;
                result.Fare      = policy.ParValue.TrimInvaidZero();
                result.Rebate    = policy.Commission.TrimInvaidZero();
                result.Amount    = policy.SettleAmount;

                if (policy.PolicyType == PolicyType.Bargain && bunk is Service.FlightQuery.Domain.GeneralBunk)
                {
                    result.Description = "特价票";
                }
                else
                {
                    if (bunk is Service.FlightQuery.Domain.FirstOrBusinessBunk)
                    {
                        result.Description = (bunk as Service.FlightQuery.Domain.FirstOrBusinessBunk).Description;
                    }
                    else if (bunk is Service.FlightQuery.Domain.EconomicBunk)
                    {
                        result.Description = "经济舱";
                    }
                    else if (bunk is Service.FlightQuery.Domain.PromotionBunk)
                    {
                        result.Description = (bunk as Service.FlightQuery.Domain.PromotionBunk).Description;
                    }
                    else if (bunk is Service.FlightQuery.Domain.ProductionBunk)
                    {
                        result.Description = "往返产品";
                    }
                    else
                    {
                        result.Description = string.Empty;
                    }
                }
                result.BunkType = bunk.Type;
            }
            if (bunk != null && bunk is Service.FlightQuery.Domain.GeneralBunk)
            {
                result.Discount = ((bunk as Service.FlightQuery.Domain.GeneralBunk).Discount).TrimInvaidZero();
                if (policy.PolicyType == PolicyType.Special)
                {
                    result.RenderDiscount = price != null && policy.ParValue != 0 ? Math.Round(policy.ParValue / price.Price, 2).ToString() : string.Empty;
                }
                else
                {
                    result.RenderDiscount = ((bunk as Service.FlightQuery.Domain.GeneralBunk).Discount).TrimInvaidZero();
                }
            }
            else
            {
                result.RenderDiscount = result.Discount = string.Empty;
            }
            // 退改签规定
            // 普通政策时,获取基础数据中普通舱位的退改签信息
            // 其他情况,获取政策上的退改签信息
            if ((policy.PolicyType == PolicyType.Normal || policy.PolicyType == PolicyType.NormalDefault || policy.PolicyType == PolicyType.OwnerDefault) && bunk is Service.FlightQuery.Domain.GeneralBunk)
            {
                result.EI = GetGeneralBunkRegulation(bunk);
            }
            else
            {
                if (policy.OriginalPolicy is DataTransferObject.Policy.IHasRegulation)
                {
                    var regulation = policy.OriginalPolicy as DataTransferObject.Policy.IHasRegulation;
                    result.EI = GetRegulation(regulation);
                }
                else
                {
                    result.EI = string.Empty;
                }
            }
            result.SuportChild = bunk != null && bunk.SuportChild;

            return(result);
        }
示例#11
0
文件: PNRInfo.cs 项目: 842549829/Pool
        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);
        }