Ejemplo n.º 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());
        }
Ejemplo n.º 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("");
        }
Ejemplo n.º 3
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内容");
                }
            }
        }
Ejemplo n.º 4
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);
        }