Пример #1
0
        internal PriceView Pat(PNRPair pnr, IEnumerable <FlightView> flights, PassengerType passengerType)
        {
            ExecuteResult <IEnumerable <PriceView> > execResult = CommandService.QueryPriceByPNR(pnr, passengerType, Guid.Empty);

            if (execResult.Success)
            {
                decimal   minFare      = execResult.Result.Min(item => item.Fare);
                PriceView minPriceView = execResult.Result.First(item => item.Fare == minFare);
                // 检查是否与基础数据中的价格相同,不同则记录日志
                if (flights.Count() == 1)
                {
                    FlightView flight = flights.First();
                    if (flight.BunkType.HasValue && (flight.BunkType.Value == BunkType.Economic || flight.BunkType.Value == BunkType.FirstOrBusiness) && flight.Fare != minFare &&
                        passengerType == PassengerType.Adult)
                    {
                        var fare = new FareErrorLog
                        {
                            Carrier    = flight.AirlineCode,
                            Departure  = flight.Departure.Code,
                            Arrival    = flight.Arrival.Code,
                            FlightDate = flight.Departure.Time.Date,
                            Bunk       = flight.BunkCode,
                            Fare       = minFare
                        };
                        LogService.SaveFareErrorLog(fare);
                        //B3BEmailSender.SendFareError(fare, flight.Fare);
                    }
                }
                return(minPriceView);
            }
            return(null);
        }
Пример #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));
        }
Пример #3
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);
                }
            }
        }
Пример #4
0
        internal static PriceView Pat(PNRPair pnr, IEnumerable <FlightView> flights, PassengerType passengerType)
        {
            ExecuteResult <IEnumerable <PriceView> > execResult = CommandService.QueryPriceByPNR(pnr, passengerType, BasePage.OwnerOEMId);

            if (execResult.Success)
            {
                var     currentFare = flights.Sum(f => f.Fare);
                decimal maxFare     = execResult.Result.Any(item => item.Fare == currentFare)
                                      ? currentFare : execResult.Result.Max(item => item.Fare);
                PriceView minPriceView = execResult.Result.FirstOrDefault(item => item.Fare == maxFare);
                // 检查是否与基础数据中的价格相同,不同则记录日志
                if (flights.Count() == 1)
                {
                    FlightView flight = flights.First();
                    if (flight.BunkType.HasValue && (flight.BunkType.Value == BunkType.Economic || flight.BunkType.Value == BunkType.FirstOrBusiness) && flight.Fare != maxFare &&
                        passengerType == PassengerType.Adult)
                    {
                        var fare = new FareErrorLog
                        {
                            Carrier     = flight.AirlineCode,
                            Departure   = flight.Departure.Code,
                            Arrival     = flight.Arrival.Code,
                            FlightDate  = flight.Departure.Time.Date,
                            Bunk        = flight.BunkCode,
                            Fare        = maxFare,
                            IsTreatment = true
                        };
                        if (RequireFD(flights))
                        {
                            PriceCheckService.CheckFd(flight.AirlineCode, flight.Departure.Code, flight.Arrival.Code,
                                                      fare.FlightDate);
                        }
                        else
                        {
                            fare.IsTreatment = false;
                            B3BEmailSender.SendFareError(fare, flight.Fare);
                        }
                        LogService.SaveFareErrorLog(fare);
                    }
                }
                return(minPriceView);
            }
            return(null);
        }
Пример #5
0
        public static PnrImportResult ImportByPNRCode(string adultPNRCode, string childPNRCode, PassengerType passengerType, string patContent, HttpContext context)
        {
            PnrImportResult             result;
            ExecuteResult <ReservedPnr> adultPNRContent = getPNRContent(adultPNRCode);

            if (adultPNRContent.Success && !adultPNRContent.Result.HasCanceled)
            {
                adultPNRContent.Result.PatRawData = patContent;
                List <PriceView> patPrices   = Service.Command.Domain.Utility.Parser.GetPatPrices(patContent);
                decimal          minFare     = (patPrices == null || patPrices.Count == 0) ? 0 : patPrices.Min(p => p.Fare);
                PriceView        patPrice    = (patPrices == null || patPrices.Count == 0) ? null : patPrices.First(item => item.Fare == minFare);
                PriceView        maxpatPrice = GetMaxPatPrice(patPrices);

                if (passengerType == PassengerType.Child)
                {
                    ExecuteResult <ReservedPnr> childrenPNRContent = getPNRContent(childPNRCode);
                    if (childrenPNRContent.Success)
                    {
                        result            = importChildrenOrder(context, adultPNRContent.Result, childrenPNRContent.Result, OrderSource.CodeImport, patPrice, maxpatPrice);
                        result.PNRContent = adultPNRContent.Message;
                        return(result);
                    }
                    else
                    {
                        throw new CustomException("提取儿童编码信息失败:" + childrenPNRContent.Message);
                    }
                }
                else
                {
                    result            = importAdultOrder(context, adultPNRContent.Result, OrderSource.CodeImport, patPrice, maxpatPrice);
                    result.PNRContent = adultPNRContent.Message;
                    return(result);
                }
            }
            else
            {
                throw new CustomException("提取成人编码信息失败:" + adultPNRContent.Message);
            }
        }
Пример #6
0
        public static PnrImportResult ImportByPNRContent(string pnrContent, string adultPNRCode, PassengerType passengerType, HttpContext context)
        {
            //// 做一些替换,注意,所有的序号开始前的数据全部被替换了;
            //pnrContent = Regex.Replace(pnrContent, "(\\n)+", "");
            //pnrContent = Regex.Replace(pnrContent, "(\\r)+", ";");

            //if (Parser.GetPassengerConsistsType(pnrContent) == PassengerConsistsType.Group)
            //{
            //    pnrContent = Regex.Replace(pnrContent, @"(?:(?:^.*;|^))(?=\s?0\.)", "");
            //    // 2012-10-29 同CodeLineRegex一起修改的;
            //    // pnrContent = Regex.Replace(pnrContent, @"^.*;(?=\s0\.)", "");
            //}
            //else
            //{
            //    // 2012-10-29 同CodeLineRegex一起修改的;
            //    pnrContent = Regex.Replace(pnrContent, @"(?:(?:^.*;|^))(?=\s?1\.)", "");
            //}

            var pnrContentModel = CommandService.GetReservedPnr(pnrContent);

            if (pnrContentModel == null || !pnrContentModel.Success)
            {
                throw new CustomException("编码内容解析失败,请确认编码内容是否正确");
            }
            else if (pnrContentModel.Result.HasCanceled)
            {
                throw new CustomException("编码已被取消,请确认!");
            }
            else
            {
                if (PNRPair.IsNullOrEmpty(pnrContentModel.Result.PnrPair))
                {
                    throw new CustomException("内容中缺少编码");
                }
                //if (string.IsNullOrWhiteSpace(pnrContentModel.Code.PNR)) throw new CustomException("缺少小编码");
                if (string.IsNullOrWhiteSpace(pnrContentModel.Result.PnrPair.PNR) && string.IsNullOrWhiteSpace(pnrContentModel.Result.PnrPair.BPNR))
                {
                    throw new CustomException("编码信息不全");
                }

                List <PriceView> patPrices = Service.Command.Domain.Utility.Parser.GetPatPrices(pnrContent);
                //if (patPrices == null || patPrices.Count == 0) throw new CustomException("缺少PAT内容");

                decimal   minFare     = (patPrices == null || patPrices.Count == 0) ? 0 : patPrices.Min(p => p.Fare);
                PriceView patPrice    = (patPrices == null || patPrices.Count == 0) ? null : patPrices.First(item => item.Fare == minFare);
                PriceView maxPatPrice = GetMaxPatPrice(patPrices);

                if (passengerType == PassengerType.Child)
                {
                    ExecuteResult <ReservedPnr> adultPNRContent = getPNRContent(adultPNRCode);
                    if (adultPNRContent.Success)
                    {
                        return(importChildrenOrder(context, adultPNRContent.Result, pnrContentModel.Result, OrderSource.ContentImport, patPrice, maxPatPrice));
                    }
                    else
                    {
                        throw new CustomException("提取成人编码信息失败:" + adultPNRContent.Message);
                    }
                }
                else
                {
                    return(importAdultOrder(context, pnrContentModel.Result, OrderSource.ContentImport, patPrice, maxPatPrice));
                }
            }
        }
Пример #7
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;
        }
Пример #8
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));
 }