Exemplo n.º 1
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内容");
                }
            }
        }
Exemplo n.º 2
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);
        }