Example #1
0
 private static OrderView GetOrderView(OrderSource orderSource, ReservedPnr pnrContent, PNRPair associatePNR, IEnumerable <FlightView> flightViews,
                                       PassengerType passengerType)
 {
     return(new OrderView
     {
         FdSuccess = true,
         Source = orderSource,
         PNR = pnrContent.PnrPair,
         Passengers = pnrContent.Passengers.OrderBy(p => p.Name).Select(p => new PassengerView
         {
             Name = p.Name,
             Credentials = p.CertificateNumber,
             CredentialsType = CredentialsType.身份证,
             PassengerType = passengerType,
             Phone = p.Mobilephone
         }),
         Flights = flightViews.Select(ReserveViewConstuctor.GetOrderFlightView).ToList(),
         Contact = new Contact
         {
             Name = BasePage.LogonCompany.Contact,
             Mobile = BasePage.LogonCompany.ContactPhone,
             Email = BasePage.LogonCompany.ContactEmail
         },
         AssociatePNR = associatePNR,
         IsTeam = pnrContent.IsTeam,
         TripType = pnrContent.Voyage.Type
     });
 }
Example #2
0
        private static void saveImportInfo(HttpContext context, ReservedPnr pnrContent, PNRPair associatePNR, OrderSource orderSource, PriceView patPrice, PriceView maxpatPrice, PassengerType passengerType)
        {
            bool fdSuccess = true;
            IEnumerable <FlightView> reservedFlights = ReserveViewConstuctor.GetQueryFlightView(pnrContent.Voyage.Segments, pnrContent.Voyage.Type,
                                                                                                pnrContent.Passengers.First().Type, pnrContent.IsTeam, patPrice);

            if (maxpatPrice != null && maxpatPrice.Fare != 0 && pnrContent.Voyage.Type == ItineraryType.OneWay &&
                passengerType == PassengerType.Adult)
            {
                var flight = reservedFlights.First();
                if (flight.Fare != maxpatPrice.Fare && flight.Fare != 0 && (flight.BunkType == BunkType.Economic || flight.BunkType == BunkType.FirstOrBusiness))
                {
                    FareErrorLog fare = new FareErrorLog
                    {
                        Carrier    = flight.AirlineCode,
                        Departure  = flight.Departure.Code,
                        Arrival    = flight.Arrival.Code,
                        FlightDate = flight.Departure.Time.Date,
                        Bunk       = flight.BunkCode,
                        Fare       = patPrice.Fare,
                    };
                    if (PNRHelper.RequireFD(reservedFlights))
                    {
                        try
                        {
                            flight.Fare = patPrice.Fare = PriceCheckService.CheckFd(flight.AirlineCode, flight.Departure.Code, flight.Arrival.Code,
                                                                                    flight.BunkCode, flight.Departure.Time);
                            fare.IsTreatment = true;
                        }
                        catch (Exception ex)
                        {
                            LogService.SaveExceptionLog(ex, string.Format("{0}{1}{2}{3}({4})", flight.AirlineCode, flight.Departure.Code, flight.Arrival.Code, flight.BunkCode, flight.Departure.Time));
                            fare.IsTreatment = false;
                            fdSuccess        = false;
                        }
                    }
                    else
                    {
                        fdSuccess = false;
                        B3BEmailSender.SendFareError(fare, flight.Fare);
                    }
                    LogService.SaveFareErrorLog(fare);
                }
            }


            OrderView orderView = GetOrderView(orderSource, pnrContent, associatePNR, reservedFlights, passengerType);

            orderView.FdSuccess  = fdSuccess;
            orderView.PatContent = pnrContent.PatRawData;
            orderView.PnrContent = pnrContent.PnrRawData;
            orderView.UseBPNR    = !pnrContent.UsedCrsCode;
            orderView.PATPrice   = patPrice;
            context.Session["ReservedFlights"] = reservedFlights;
            context.Session["OrderView"]       = orderView;
        }
Example #3
0
 private static void CheckFligtTime(ReservedPnr reservedPnr)
 {
     if (reservedPnr.Voyage.Segments.Any())
     {
         var firstFlightDate      = reservedPnr.Voyage.Segments.Min(f => f.Date.AddHours(f.DepartureTime.Hour).AddMinutes(f.DepartureTime.Minute));
         var minutesBeforeTakeOff = (firstFlightDate - DateTime.Now).TotalMinutes;
         if (minutesBeforeTakeOff <= SystemParamService.FlightDisableTime)
         {
             throw new CustomException("由于时间受限,飞机起飞前" + SystemParamService.FlightDisableTime + "分钟,不允许再购买此航班");
         }
     }
 }
Example #4
0
        public static void ValidatePNR(ReservedPnr reservedPnr, Common.Enums.PassengerType passengerType)
        {
            if (reservedPnr.HasCanceled)
            {
                throw new PNRCanceledExceptioin(passengerType.GetDescription() + "订座记录已取消");
            }
            if (PNRPair.IsNullOrEmpty(reservedPnr.PnrPair))
            {
                throw new ArgumentException("缺少编码");
            }

            if (reservedPnr.Passengers == null || reservedPnr.Passengers.Count == 0)
            {
                throw new CustomException(passengerType.GetDescription() + "编码缺少乘机人信息");
            }
            if (reservedPnr.Passengers.First().Type != passengerType)
            {
                throw new CustomException(passengerType.GetDescription() + "编码错误(不是" + passengerType.GetDescription() + "编码)");
            }

            if (reservedPnr.Voyage.Segments == null || reservedPnr.Voyage.Segments.Count == 0)
            {
                throw new CustomException(passengerType.GetDescription() + "编码缺少航班信息");
            }
            var errorPassenger = reservedPnr.Passengers.FirstOrDefault(item => string.IsNullOrWhiteSpace(item.CertificateNumber));

            if (errorPassenger != null)
            {
                throw new CustomException(passengerType.GetDescription() + "编码乘机人 [" + errorPassenger.Name + "] 缺少有效的 SSR FOID 项");
            }

            foreach (var item in reservedPnr.Voyage.Segments)
            {
                if (item.Status == "DW")
                {
                    throw new PNRAlternateStateException(passengerType.GetDescription() + "订座记录处于候补状态");
                }
                if (!(item.Status.Contains("K") || item.Status == "RR" ||
                      (item.Status == "NN" && System.Configuration.ConfigurationManager.AppSettings["NNStatusAirline"].Contains(item.AirlineCode))))
                {
                    throw new SellOutException("用户所定航班已销售完毕");
                }
            }
            if (reservedPnr.IsTeam && reservedPnr.TotalNumber != reservedPnr.ActualNumber)
            {
                throw new CustomException("团队成员数量与团队编码成员数不一致");
            }
            if (reservedPnr.NeedFill)
            {
                throw new CustomException("缺口程编码,需要搭桥");
            }
        }
Example #5
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));
        }
Example #6
0
        public static void SaveImportInfo(ReservedPnr pnrContent, PNRPair associatePNR, PriceView minPatPrice,
                                          PassengerType passengerType, PriceView maxPatPrice, out bool fdSuccess)
        {
            fdSuccess = true;
            IEnumerable <FlightView> reservedFlights = ReserveViewConstuctor.GetQueryFlightView(pnrContent.Voyage.Segments, pnrContent.Voyage.Type,
                                                                                                pnrContent.Passengers.First().Type, pnrContent.IsTeam, minPatPrice);

            if (maxPatPrice != null && maxPatPrice.Fare != 0 && pnrContent.Voyage.Type == ItineraryType.OneWay &&
                passengerType == PassengerType.Adult)
            {
                var flight = reservedFlights.First();
                if (flight.Fare != maxPatPrice.Fare && flight.Fare != 0 && (flight.BunkType == BunkType.Economic || flight.BunkType == BunkType.FirstOrBusiness))
                {
                    FareErrorLog fare = new FareErrorLog
                    {
                        Carrier     = flight.AirlineCode,
                        Departure   = flight.Departure.Code,
                        Arrival     = flight.Arrival.Code,
                        FlightDate  = flight.Departure.Time.Date,
                        Bunk        = flight.BunkCode,
                        Fare        = maxPatPrice.Fare,
                        IsTreatment = true
                    };

                    if (PNRHelper.RequireFD(reservedFlights))
                    {
                        try
                        {
                            flight.Fare = minPatPrice.Fare = PriceCheckService.CheckFd(flight.AirlineCode, flight.Departure.Code, flight.Arrival.Code,
                                                                                       flight.BunkCode, flight.Departure.Time);
                        }
                        catch (Exception ex)
                        {
                            LogService.SaveExceptionLog(ex, string.Format("{0}{1}{2}{3}({4})", flight.AirlineCode, flight.Departure.Code, flight.Arrival.Code, flight.BunkCode, flight.Departure.Time));
                            fare.IsTreatment = false;
                            fdSuccess        = false;
                        }
                    }
                    else
                    {
                        fdSuccess        = false;
                        fare.IsTreatment = true;
                        B3BEmailSender.SendFareError(fare, flight.Fare);
                    }
                    LogService.SaveFareErrorLog(fare);
                    //B3BEmailSender.SendFareError(fare, flight.Fare);
                }
            }
        }
Example #7
0
 private static PnrImportResult importChildrenOrder(HttpContext context, ReservedPnr adultPNRContent, ReservedPnr childrenPNRContent, OrderSource orderSource, PriceView patPrice, PriceView maxpatPrice)
 {
     CheckFligtTime(adultPNRContent);
     if (patPrice == null)
     {
         return(new PnrImportResult(false, "需要输入PAT内容", true));
     }
     CommandService.ValidatePNR(childrenPNRContent, PassengerType.Child);
     //if (childrenPNRContent.Price != null) throw new CustomException("儿童编码中不能包含票价组项");
     //CheckPNRWithETDZ(adultPNRContent, Common.Enums.PassengerType.Adult);
     //checkVoyages(adultPNRContent.Segments.Values, childrenPNRContent.Segments.Values);
     //if(adultPNRContent.Passengers.Count < childrenPNRContent.Passengers.Count) {
     //    throw new CustomException("儿童数不能超过成人数");
     //}
     patPrice.AirportTax = 0m; //儿童票机建是0
     patPrice.Total      = patPrice.AirportTax + patPrice.BunkerAdjustmentFactor + patPrice.Fare;
     saveImportInfo(context, childrenPNRContent, adultPNRContent.PnrPair, orderSource, patPrice, maxpatPrice, PassengerType.Child);
     return(new PnrImportResult(true));
 }
Example #8
0
        /// <summary>
        /// 根据内容,转换成订座后的旅客订座信息。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static ExecuteResult <ReservedPnr> GetReservedPnr(string str)
        {
            ReservedPnr reservedPnr = Domain.Utility.Parser.GetPnrContent(str);

            if (reservedPnr != null)
            {
                return(new ExecuteResult <ReservedPnr>
                {
                    Success = true,
                    Result = reservedPnr,
                    Message = str
                });
            }

            return(new ExecuteResult <ReservedPnr>
            {
                Success = false,
                Message = str
            });
        }
Example #9
0
        public ExecuteResult <ReservedPnr> SsrFoid(string pnrCode, string name, string oldNumber, string newNumber, CredentialsType certificateType, string userName)
        {
            var veService = new veSWScnService();

            veService.Url = ReplaceUrl(veService.Url);
            string returnString = veService.SSRFOID(pnrCode, name, oldNumber, newNumber, certificateType.ToString(),
                                                    "KMG215", userName);

            XDocument xdoc = XDocument.Parse(returnString, LoadOptions.None);

            returnString = xdoc.Element("VESSRFOID") != null
                               ? xdoc.Element("VESSRFOID").Element("PNR").Value
                               : returnString;

            string      rawData = returnString;
            ReservedPnr result  = Domain.Utility.Parser.GetPnrContent(rawData);

            return(new ExecuteResult <ReservedPnr>
            {
                Success = (result != null),
                Result = result,
                Message = rawData
            });
        }
Example #10
0
        protected void ValidateBusinessParameters(string _pnrContent)
        {
            if (string.IsNullOrWhiteSpace(_pnrContent))
            {
                InterfaceInvokeException.ThrowParameterMissException("编码内容");
            }
            try
            {
                var result = CommandService.GetReservedPnr(_pnrContent);
                if (result.Success)
                {
                    _pnr = result.Result;
                }
            }
            catch (Exception)
            {
                InterfaceInvokeException.ThrowParameterErrorException("编码内容");
            }
            if (_pnr == null)
            {
                InterfaceInvokeException.ThrowParameterErrorException("编码内容");
            }
            if (DataTransferObject.Common.PNRPair.IsNullOrEmpty(_pnr.PnrPair))
            {
                InterfaceInvokeException.ThrowParameterErrorException("内容中缺少编码");
            }
            if (string.IsNullOrWhiteSpace(_pnr.PnrPair.PNR) && string.IsNullOrWhiteSpace(_pnr.PnrPair.BPNR))
            {
                InterfaceInvokeException.ThrowParameterErrorException("编码信息不全");
            }
            //如果遇到证件号不全体提编码
            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())
            {
                InterfaceInvokeException.ThrowCustomMsgException("编码中缺少航班信息");
            }
            _policyType = ReturnStringUtility.QueryPolicyType(_flights, _pnr);
            var flight = _flights.FirstOrDefault();

            if (flight.BunkType != null && flight.BunkType.Value == BunkType.Free)
            {
                _patPrices = new List <PriceView> {
                    new PriceView {
                        AirportTax = flight.AirportFee, BunkerAdjustmentFactor = flight.BAF, Fare = 0, Total = flight.AirportFee + flight.BAF
                    }
                };
            }
            else
            {
                //没有传入pat信息  就虚拟一个高价的pat
                _patPrices = new List <PriceView> {
                    new PriceView {
                        AirportTax = 100000, BunkerAdjustmentFactor = 100000, Fare = 100000, Total = 300000
                    }
                };
            }
            //验证
            CommandService.ValidatePNR(_pnr, _pnr.Passengers.First().Type);
        }
Example #11
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内容");
                }
            }
        }
Example #12
0
        private DataTransferObject.Order.OrderView GetOrderView(DataTransferObject.Order.OrderSource orderSource, ReservedPnr pnrContent, DataTransferObject.Common.PNRPair associatePNR, IEnumerable <DataTransferObject.FlightQuery.FlightView> flightViews, string Contact)
        {
            var patPrice = _patPrices.First();

            return(new DataTransferObject.Order.OrderView
            {
                Source = orderSource,
                PNR = pnrContent.PnrPair,
                Passengers = pnrContent.Passengers.OrderBy(p => p.Name).Select(p => new DataTransferObject.Order.PassengerView
                {
                    Name = p.Name,
                    Credentials = p.CertificateNumber,
                    CredentialsType = p.CertificateType,
                    PassengerType = p.Type,
                    Phone = p.Mobilephone
                }),
                Flights = flightViews.Select(ReserveViewConstuctor.GetOrderFlightView).ToList(),
                Contact = new DataTransferObject.Order.Contact
                {
                    Name = Contact == "" ? Company.Contact : Contact.Split('|')[0],
                    Mobile = Contact == "" ? Company.ContactPhone : Contact.Split('|')[1],
                    Email = Contact == "" ? Company.ContactEmail : Contact.Split('|')[2]
                },
                AssociatePNR = associatePNR,
                IsTeam = pnrContent.IsTeam,
                TripType = pnrContent.Voyage.Type,
                PATPrice = new DataTransferObject.Command.PNR.PriceView
                {
                    AirportTax = patPrice.AirportTax,
                    BunkerAdjustmentFactor = patPrice.BunkerAdjustmentFactor,
                    Fare = _matchedPolicy.ParValue,
                    Total = patPrice.AirportTax + patPrice.BunkerAdjustmentFactor + _matchedPolicy.ParValue
                }
            });
        }
Example #13
0
        protected override void ValidateBusinessParameters()
        {
            if (string.IsNullOrWhiteSpace(_pnrContent))
            {
                throw new InterfaceInvokeException("8", "编码内容");
            }
            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 (DataTransferObject.Common.PNRPair.IsNullOrEmpty(_pnr.PnrPair))
            {
                throw new InterfaceInvokeException("1", "内容中缺少编码");
            }
            if (string.IsNullOrWhiteSpace(_pnr.PnrPair.PNR) && string.IsNullOrWhiteSpace(_pnr.PnrPair.BPNR))
            {
                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", "编码中缺少航班信息");
            }
            _policyType = queryPolicyType(_flights);
            var flight = _flights.FirstOrDefault();

            if (flight.BunkType != null && flight.BunkType.Value == BunkType.Free)
            {
                _patPrices = new List <PriceView> {
                    new 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 (!_pnr.IsTeam && !_pnr.IsFilled) throw new InterfaceInvokeException("9", "缺口程编码,需要搭桥");
            //验证
            CommandService.ValidatePNR(_pnr, _pnr.Passengers.First().Type);
            PNRHelper.SaveImportInfo(_pnr, _pnr.PnrPair, _patPrices.MinOrDefaultElement(item => item.Fare), _pnr.Passengers.First().Type, _patPrices.MaxOrDefaultElement(item => item.Fare), out fdSuccess);
        }
Example #14
0
        public static PolicyType QueryPolicyType(IEnumerable <DataTransferObject.FlightQuery.FlightView> flights, ReservedPnr _pnr)
        {
            PolicyType policyType = PolicyType.Bargain;

            if (_pnr.IsTeam)
            {
                policyType = PolicyType.Team;
            }
            else
            {
                // 根据舱位的类型来决定政策类型
                if (flights.Any(f => f.BunkType == BunkType.Promotion || f.BunkType == BunkType.Production || f.BunkType == BunkType.Transfer))
                {
                    policyType = PolicyType.Bargain;
                }
                else
                {
                    switch (flights.First().BunkType)
                    {
                    case BunkType.Economic:
                    case BunkType.FirstOrBusiness:
                        policyType = PolicyType.Normal | PolicyType.Bargain;
                        break;

                    case BunkType.Promotion:
                    case BunkType.Production:
                    case BunkType.Transfer:
                        policyType = PolicyType.Bargain;
                        break;

                    default:
                        policyType = PolicyType.Special;
                        break;
                    }
                }
            }
            return(policyType);
        }