예제 #1
0
        internal static bool RequirePat(IEnumerable <FlightView> flights, PolicyType policyType)
        {
            // 普通政策,单程根据时间段来决定是否需要P价格,其他的都要
            // 如果是默认政策,舱位是普通舱位时,判断条件跟普通政策一样。
            FlightView firstFlight = flights.First();

            if (firstFlight.BunkType.HasValue)
            {
                BunkType bunkType = firstFlight.BunkType.Value;
                if (policyType == PolicyType.Normal || policyType == PolicyType.NormalDefault ||
                    (policyType == PolicyType.OwnerDefault && (bunkType == BunkType.Economic || bunkType == BunkType.FirstOrBusiness)))
                {
                    switch (flights.Count())
                    {
                    case 2:
                        return(true);

                    case 1:
                        DateTime today = DateTime.Today;
                        return(SystemParamService.PATTimeZones.Any(item => item.Lower.Date <= today && today <= item.Upper.Date));
                    }
                }
            }
            return(false);
        }
예제 #2
0
        internal static bool RequireFD(IEnumerable <FlightView> flights)
        {
            // 普通政策,单程根据时间段来决定是否需要核价格
            // 如果是默认政策,舱位是普通舱位时,判断条件跟普通政策一样。
            FlightView firstFlight = flights.First();

            if (firstFlight.BunkType.HasValue)
            {
                BunkType bunkType = firstFlight.BunkType.Value;
                if ((bunkType == BunkType.Economic || bunkType == BunkType.FirstOrBusiness))
                {
                    switch (flights.Count())
                    {
                    case 2:
                        return(false);

                    case 1:
                        DateTime now = DateTime.Now;
                        return(SystemParamService.FDTimeZones.Any(item => item.Lower.Date <= now && now <= item.Upper.Date));

                    default:
                        return(false);
                    }
                }
            }
            return(false);
        }
예제 #3
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);
        }
예제 #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
        private static void setBunkInfo(FlightView flightView, VoyageTypeValue voyageType, PassengerTypeValue passengerType, TravelTypeValue travelType, PriceView patPrice)
        {
            var bunks = Service.FoundationService.QueryBunk(flightView.AirlineCode,
                                                            flightView.Departure.Code, flightView.Arrival.Code,
                                                            flightView.Departure.Time.Date, flightView.BunkCode,
                                                            voyageType, travelType, passengerType);
            //更改退改签规定数据源
            var    pattern           = new Regex("^[a-zA-Z\\d/]+$");
            var    refundDetail      = FoundationService.QueryDetailList(flightView.AirlineCode, flightView.BunkCode).Where(item => pattern.IsMatch(item.Bunks));
            string refundRegulation  = string.Empty;
            string changeRegulation  = string.Empty;
            string endorseRegulation = string.Empty;
            string remark            = string.Empty;

            foreach (var item in refundDetail)
            {
                refundRegulation  += ("航班起飞前:" + item.ScrapBefore + ";航班起飞后:" + item.ScrapAfter).Replace("<br/>", "").Replace("\r", "").Replace("\n", "").Replace("\t", "");
                changeRegulation  += ("航班起飞前:" + item.ChangeBefore + ";航班起飞后:" + item.ChangeAfter).Replace("<br/>", "").Replace("\r", "").Replace("\n", "").Replace("\t", "");
                endorseRegulation += item.Endorse.Replace("<br/>", "").Replace("\r", "").Replace("\n", "").Replace("\t", "");
                remark             = item.Remark.Replace(" ", "").Replace("<br/>", "").Replace("\r", "").Replace("\n", "").Replace("\t", "");
            }
            if (string.IsNullOrWhiteSpace(refundRegulation))
            {
                refundRegulation = "以航司具体规定为准";
            }
            if (string.IsNullOrWhiteSpace(changeRegulation))
            {
                changeRegulation = "以航司具体规定为准";
            }
            foreach (var item in bunks)
            {
                item.RefundRegulation  = refundRegulation;
                item.ChangeRegulation  = changeRegulation;
                item.EndorseRegulation = endorseRegulation;
                item.Remarks           = remark;
            }
            var bunk = chooseBunk(bunks, voyageType, flightView.YBPrice, patPrice);

            if (bunk != null)
            {
                flightView.EI       = bunk.EI;
                flightView.BunkType = bunk.Type;
                // 明折明扣舱
                var generalBunk = bunk as Service.Foundation.Domain.GeneralBunk;
                if (generalBunk != null)
                {
                    var adultDiscount = generalBunk.GetDiscount(flightView.BunkCode);
                    var adultFare     = Utility.Calculator.Round(flightView.YBPrice * adultDiscount, 1);
                    if (passengerType == PassengerTypeValue.Child)
                    {
                        flightView.Discount = Utility.Calculator.Round(adultDiscount / 2, -3);
                        flightView.Fare     = Utility.Calculator.Round(adultFare / 2, 1);
                    }
                    else
                    {
                        flightView.Discount = adultDiscount;
                        flightView.Fare     = adultFare;
                    }
                    var firstBusinessBunk = generalBunk as Service.Foundation.Domain.FirstBusinessBunk;
                    if (firstBusinessBunk != null)
                    {
                        flightView.BunkDescription = firstBusinessBunk.Description;
                    }
                    return;
                }
                // 特价舱
                var promotionBunk = bunk as Service.Foundation.Domain.PromotionBunk;
                if (promotionBunk != null)
                {
                    flightView.BunkDescription = promotionBunk.Description;
                    return;
                }
                // 免票舱
                var freeBunk = bunk as Service.Foundation.Domain.FreeBunk;
                if (freeBunk != null)
                {
                    flightView.BunkDescription = freeBunk.Description;
                    return;
                }
                // 往返产品舱、联程舱、团队舱
                if (bunk is Service.Foundation.Domain.ProductionBunk || bunk is Service.Foundation.Domain.TransferBunk || bunk is Service.Foundation.Domain.TeamBunk)
                {
                    return;
                }
                throw new CustomException("不支持该舱位导入");
            }
            throw new CustomException("未获取到支持该行程的相关舱位信息");
        }