///// <summary> ///// 根据旅客订座记录编号,获取其详细信息。(此方法没有被外部调用) ///// </summary> ///// <param name="pnrCode">编码</param> ///// <returns>执行结果</returns> //private static ExecuteResult<IssuedPNR> GetTeamPNRDetail(string pnrCode) //{ // var rtnCommand = new RTNCommand(pnrCode); // rtnCommand.Execute(); // var issuedPNR = Parser.GetPNRDetail(rtnCommand.ReturnString); // return GetExecuteResult(issuedPNR, rtnCommand.ReturnString); //} ///// <summary> ///// 根据旅客订座记录编号,获取其详细信息。 ///// </summary> ///// <param name="pnrPair">PNR</param> ///// <returns>执行结果</returns> //private static ExecuteResult<IssuedPNR> GetPNRDetail(PNRPair pnrPair, bool isTeam) //{ // if (PNRPair.IsNullOrEmpty(pnrPair)) // { // throw new ArgumentException("编码错误"); // } // // 优先通过大编码获取信息, // return isTeam && !string.IsNullOrWhiteSpace(pnrPair.BPNR) ? GetTeamPNRDetail(pnrPair.BPNR) : GetPNRDetail(pnrPair); //} ///// <summary> ///// 根据旅客订座记录编号,获取其详细信息。 ///// </summary> ///// <param name="pnrPair">PNR</param> ///// <returns>执行结果</returns> //private static ExecuteResult<IssuedPNR> GetPNRDetail(PNRPair pnrPair) //{ // if (PNRPair.IsNullOrEmpty(pnrPair)) // { // throw new ArgumentException("编码错误"); // } // var commandString = string.Empty; // IssuedPNR issuedPNR = null; // if (!string.IsNullOrWhiteSpace(pnrPair.BPNR)) // { // var rtCommand = new RTCommand(pnrPair.BPNR, CommandType.PNRExtraction, ReturnResultType.All); // rtCommand.Execute(); // commandString = rtCommand.ReturnString; // } // else // { // var rtxCommand = new RTXCommand(pnrPair.PNR); // rtxCommand.Execute(); // commandString = rtxCommand.ReturnString; // } // switch (Parser.GetPassengerConsistsType(commandString)) // { // case PassengerConsistsType.Individual: // issuedPNR = Parser.GetPNRDetail(commandString); // break; // case PassengerConsistsType.Group: // // 通过上面的数据,解析出PNRPair; // PNRPair result = Parser.GetPnrPair(commandString); // // 这里用大编提取数据,切记切记,用小编提取不到; // return GetTeamPNRDetail(string.IsNullOrWhiteSpace(result.BPNR) ? result.PNR : result.BPNR); // default: // break; // } // return GetExecuteResult<IssuedPNR>(issuedPNR, commandString); //} #endregion /// <summary> /// /// </summary> /// <param name="pnrPair"></param> /// <param name="oemId"> </param> /// <returns></returns> /// <remarks> /// 由于在订座后立即提取了编码信息,所在所有的调用此方法时都应该是用大系统提取,所以,这里先写死了; /// </remarks> public static ExecuteResult <ReservedPnr> GetReservedPnr(PNRPair pnrPair, Guid oemId) { if (PNRPair.IsNullOrEmpty(pnrPair)) { throw new ArgumentException("编码错误"); } var userName = "******"; ExecuteResult <ReservedPnr> reservedPnrInfo; var repository = Factory.CreateCommandRepository(); // 防止出现问题,检查输入编码; pnrPair = Domain.Utility.Parser.SwitchPnrPair(pnrPair); if (!string.IsNullOrWhiteSpace(pnrPair.BPNR))//若大系统编码为空,则使用大系统提大编码 { reservedPnrInfo = repository.Rt(pnrPair.BPNR, userName); } else { reservedPnrInfo = repository.Rtx(pnrPair.PNR, userName); } if (reservedPnrInfo.Success) { PidManagementService.SaveCounter(oemId, true); } return(reservedPnrInfo); }
string AppendPNR(PNRPair pnr, string tip) { if (PNRPair.IsNullOrEmpty(pnr)) { return(string.Empty); } if (RenderedPNR.Any(pnr.Equals)) { return(string.Empty); } var result = new StringBuilder(" "); result.Append(tip); if (!string.IsNullOrWhiteSpace(pnr.PNR)) { result.AppendFormat(PNRFORMAT, pnr.PNR.ToUpper(), "小"); } result.Append(" "); if (!string.IsNullOrWhiteSpace(pnr.BPNR)) { result.AppendFormat(PNRFORMAT, pnr.BPNR.ToUpper(), "大"); } RenderedPNR.Add(pnr); return(result.ToString()); }
internal PNRInfo UpdateContentForRefund(RefundOrScrapApplyform refundOrScrapApplyform) { PNRInfo result = null; IEnumerable <Guid> passengers = refundOrScrapApplyform.GetAppliedPassengers(); IEnumerable <Guid> flights = refundOrScrapApplyform.GetAppliedFlights(); if (isAllPassengers(passengers) && isAllFlights(flights)) { removeAll(); } else if (isAllPassengers(passengers)) { removeFlights(flights); } else if (isAllFlights(flights)) { removePassengers(passengers); } else { if (PNRPair.IsNullOrEmpty(refundOrScrapApplyform.NewPNR)) { throw new CustomException("未提供分离后的新编码"); } result = separate(refundOrScrapApplyform.NewPNR, passengers); result.removeFlights(flights); } return(result); }
/// <summary> /// 根据给出的旅客订座记录编号和姓名,修改旅客证件号码。 /// </summary> /// <param name="pnrPair">旅客订座记录编号</param> /// <param name="name">旅客姓名</param> /// <param name="oldNumber">原证件号</param> /// <param name="newNumber">新证件号</param> /// <param name="type">证件类型</param> /// <param name="oemId">OEM编号</param> /// <returns></returns> public static ExecuteResult <ReservedPnr> ModifyCertificateNumber(PNRPair pnrPair, string name, string oldNumber, string newNumber, CredentialsType type, Guid oemId) { // 参数验证 if (PNRPair.IsNullOrEmpty(pnrPair)) { throw new ArgumentException("旅客订座记录编码"); } var userName = "******"; try { var repository = Factory.CreateCommandRepository(); PidManagementService.SaveCounter(oemId, true); var result = repository.SsrFoid(pnrPair.PNR, name, oldNumber, newNumber, type, userName); if (result.Success) { PidManagementService.SaveCounter(oemId, true); } return(result); } catch (Exception e) { return(new ExecuteResult <ReservedPnr>() { Success = false, Message = e.Message, Result = null }); } }
/// <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()); }
string checkReservationPNRValidity(Guid oemId) { if (!PNRPair.IsNullOrEmpty(this.ReservationPNR)) { var executeResult = CommandService.GetReservedPnr(ReservationPNR, oemId); if (executeResult.Success) { CommandService.ValidatePNR(executeResult.Result, IsChildrenOrder ? PassengerType.Child : PassengerType.Adult); if (Source == OrderSource.PlatformOrder && executeResult.Result.Passengers != null && executeResult.Result.Passengers.Join(PNRInfos.First().Passengers, p => p.Name, p => p.Name, (p, q) => p).Count() != executeResult.Result.Passengers.Count) { LogService.SaveExceptionLog(new Exception("乘机人信息不符") { Source = "编码验证" }, "订单号:" + Id + ",编码内容中的乘机人姓名为:" + string.Join(",", executeResult.Result.Passengers.Select(p => p.Name))); } } else { //throw new CustomException("编码提取失败"); if (OrderSource.PlatformOrder != Source) { return("暂时无法验证您导入编码的位置是否有效,请您自行确认"); } else { LogService.SaveExceptionLog(new CustomException(string.Format("由于编码内容提取失败,平台预订的编码:{0} 未进行有效性验证,时间:{1:yyyy-MM-dd HH:mm}", ReservationPNR.ToListString(), DateTime.Now))); } } } return(string.Empty); }
/// <summary> /// 将待授权的旅客订座记录编号的权限授予指定的OfficeNo /// </summary> /// <param name="pnrPair">待授权的旅客订座记录编号</param> /// <param name="officeNo">待授权的OfficeNo</param> /// <param name="oemId"> </param> /// <returns></returns> /// <remarks> /// 使用在订好编码后,向出票方授权; /// </remarks> public static ExecuteResult <string> AuthorizeByOfficeNo(PNRPair pnrPair, string officeNo, Guid oemId) { // 参数验证 if (PNRPair.IsNullOrEmpty(pnrPair)) { throw new ArgumentException("旅客订座记录编码"); } const ConfigUseType type = ConfigUseType.Reserve; var userName = GetUserName(oemId, type); var officeNumber = GetOfficeNumber(oemId, type); if (userName == null || officeNumber == null) { return(new ExecuteResult <string> { Result = null, Success = false, Message = "OEM未设置可用配置,且没有设置使用平台配置。" }); } var repository = Factory.CreateCommandRepository(); var result = repository.Authorize(pnrPair.PNR, officeNumber, new string[] { officeNo }, userName); if (result.Success) { PidManagementService.SaveCounter(oemId, true); } return(result); }
/// <summary> /// 查询订票后价格 /// </summary> /// <returns>执行结果</returns> public static ExecuteResult <IEnumerable <PriceView> > QueryPriceByPNR(PNRPair pnrPair, PassengerType passengerType, Guid oemId) { // 参数验证 if (PNRPair.IsNullOrEmpty(pnrPair)) { throw new ArgumentException("旅客订座记录编码"); } // 这里到底是执行了RT还是RTX呢,PAT现在只在执行订座时会提,所以提取时应使用的订座配置; const ConfigUseType type = ConfigUseType.Reserve; var userName = GetUserName(oemId, type); if (userName == null) { return(new ExecuteResult <IEnumerable <PriceView> > { Result = null, Success = false, Message = "OEM未设置可用配置,且没有设置使用平台配置。" }); } var repository = Factory.CreateCommandRepository(); var result = repository.PnrPat(pnrPair.PNR, passengerType, userName); if (result.Success) { PidManagementService.SaveCounter(oemId, HasUsePlatformConfig(oemId, type)); } return(result); }
internal static ExternalOrder NewExternalOrder(OrderView orderView, PolicyMatch.MatchedPolicy matchedPolicy, DataTransferObject.Organization.EmployeeDetailInfo employee, AuthenticationChoise choise = AuthenticationChoise.NoNeedAUTH) { if (!orderView.Flights.Any()) { throw new ArgumentNullException("orderView", "缺少航段信息"); } if (!orderView.Passengers.Any()) { throw new ArgumentNullException("orderView", "缺少乘机人信息"); } if (matchedPolicy == null) { throw new CustomException("无相关政策信息"); } #region 构造BASE var result = new ExternalOrder { Contact = orderView.Contact, ReservationPNR = PNRPair.IsNullOrEmpty(orderView.PNR) ? null : orderView.PNR, IsReduce = orderView.IsReduce, IsTeam = orderView.IsTeam, AssociateOrderId = orderView.AssociateOrderId, AssociatePNR = orderView.AssociatePNR, Source = orderView.Source, Choise = choise, CustomNo = matchedPolicy.OriginalPolicy == null ? string.Empty : matchedPolicy.OriginalPolicy.CustomCode, VisibleRole = OrderRole.Platform | OrderRole.Purchaser, ForbidChangPNR = false, NeedAUTH = matchedPolicy.OriginalPolicy == null ? matchedPolicy.NeedAUTH : matchedPolicy.OriginalPolicy.NeedAUTH }; var deduction = Deduction.GetDeduction(matchedPolicy); var product = ProductInfo.GetProductInfo(matchedPolicy); var specialProduct = product as SpeicalProductInfo; if (specialProduct != null && !hasETDZPermission(matchedPolicy.Provider, specialProduct)) { result.Supplier = getSupplierInfo(matchedPolicy, specialProduct); } else { result.Provider = getProvider(matchedPolicy, product); } result.IsCustomerResource = ProductInfo.IsCustomerResource(matchedPolicy); result.IsStandby = ProductInfo.IsStandby(matchedPolicy); result.Purchaser = getPurchaserInfo(employee, deduction); var pnrInfo = PNRInfo.GetPNRInfo(orderView, matchedPolicy); result.AddPNRInfo(pnrInfo); result.TripType = pnrInfo.TripType; result.Status = result.RequireConfirm ? OrderStatus.Applied : OrderStatus.Ordered; if (result.Status == OrderStatus.Applied) { result.VisibleRole |= result.IsThirdRelation ? OrderRole.Supplier : OrderRole.Provider; } #endregion return(result); }
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(""); }
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("缺口程编码,需要搭桥"); } }
bool updateOrderForResource(PNRPair pnrCode, decimal?patPrice, Guid oemId) { if (PNRPair.IsNullOrEmpty(pnrCode)) { throw new CustomException("编码信息不能为空"); } var pnrInfo = this._pnrInfos.First(); bool fareRevised = false; fareRevised = pnrInfo.UpdateContentForResource(pnrCode, (Product as SpeicalProductInfo).SpeicalProductType != SpecialProductType.OtherSpecial, patPrice, IsStandby, oemId, PNRInfos.First().PNRContent != string.Empty, IsThirdRelation); ReservationPNR = pnrInfo.Code; SupplyTime = DateTime.Now; return(fareRevised); }
/// <summary> /// 出票方同意退/废票 /// 不会退款,仅提交财务审核 /// </summary> internal IEnumerable <Service.Distribution.Domain.Bill.Refund.RefundFlight> AgreeByProvider(RefundProcessView processView, string operatorAccount, string operatorName) { checkProcessByBusiness(); if (RequireSeparatePNR && PNRPair.IsNullOrEmpty(processView.NewPNR)) { throw new CustomException("未提供分离后的新编码"); } NewPNR = processView.NewPNR; var refundFlights = AgreeByProviderExecuteCore(processView); Status = RefundApplyformStatus.AgreedByProviderBusiness; Operator = operatorName; OperatorAccount = operatorAccount; Processed(); return(refundFlights); }
/// <summary> /// 判断对应的起飞机场的旅客订座记录是否被取消。 /// </summary> /// <param name="airport"></param> /// <returns></returns> public bool PnrCodeCancelled(string airport) { if (airport == null) { throw new ArgumentNullException("airport"); } if (ExchangeList.FirstStop.Airport != airport && (ExchangeList.SecondStop == null || ExchangeList.SecondStop.Airport != airport)) { //throw new ArgumentNullException("airport"); return(true); //在航段不存在的情况下 默认为验证通过 } var exchangeDetail = ExchangeList.FirstStop.Airport == airport ? ExchangeList.FirstStop : ExchangeList.SecondStop; return(PNRPair.IsNullOrEmpty(exchangeDetail.PnrPair)); }
/// <summary> /// 通过编码获取政策 /// </summary> /// <param name="pnrPair">编码</param> /// <param name="filter">过滤条件</param> public static RequestResult <IEnumerable <ExternalPolicyView> > Match(PNRPair pnrPair, ExternalPolicyFilter filter) { if (filter == null) { throw new ArgumentNullException("filter"); } if (PNRPair.IsNullOrEmpty(pnrPair)) { throw new ArgumentNullException("pnrPair"); } var matchedResult = new List <ExternalPolicyView>(); var platforms = new List <Processor.PlatformBase> { Yeexing.Platform.Instance }; var validPlatforms = platforms.Where(p => p.Setting != null && p.Setting.Enabled).ToList(); if (validPlatforms.Count > 1) { Parallel.ForEach(validPlatforms, platform => { var processor = platform.GetPolicyProcessor(); var matchResult = processor.Match(pnrPair, filter); if (matchResult.Success) { matchedResult.AddRange(matchResult.Result); } }); } else { foreach (var platform in validPlatforms) { var processor = platform.GetPolicyProcessor(); var matchResult = processor.Match(pnrPair, filter); if (matchResult.Success) { matchedResult.AddRange(matchResult.Result); } } } return(new RequestResult <IEnumerable <ExternalPolicyView> > { Success = true, Result = matchedResult }); }
private void setPNRPair(ApplyformView applyformView) { if (applyformView is BalanceRefundApplyView) { OriginalPNR = applyformView.PNR; return; } if (PNRPair.IsNullOrEmpty(applyformView.PNR)) { throw new CustomException("缺少编码信息 "); } var pnrInfo = this.Order.PNRInfos.FirstOrDefault(item => item.IsSamePNR(applyformView.PNR)); if (pnrInfo == null) { throw new NotFoundException("原订单中不存在编码信息。" + applyformView.PNR.ToString()); } this.OriginalPNR = pnrInfo.Code; }
internal PNRInfo UpdateContentForPostpone(PostponeApplyform postponeApplyform) { PNRInfo result = null; IEnumerable <Guid> passengers = postponeApplyform.GetAppliedPassengers(); if (isAllPassengers(passengers)) { updateFlights(postponeApplyform.Flights); } else { if (PNRPair.IsNullOrEmpty(postponeApplyform.NewPNR)) { throw new CustomException("未提供分离后的新编码"); } result = separate(postponeApplyform.NewPNR, passengers); result.updateFlights(postponeApplyform.Flights); } return(result); }
/// <summary> /// 根据PNR编号,取消指定姓名的旅客的预定 /// </summary> /// <param name="pnrPair">PNR编号</param> /// <param name="voyages">姓名</param> /// <param name="oemId"> </param> /// <returns>执行结果</returns> public static bool CancelPassengersByPNR(string[] passengerNames, PNRPair pnrPair, Guid oemId) { // 参数验证 if (PNRPair.IsNullOrEmpty(pnrPair)) { throw new ArgumentException("旅客订座记录编码"); } const ConfigUseType type = ConfigUseType.Reserve; var userName = GetUserName(oemId, type); if (userName == null) { return(false); } var repository = Factory.CreateCommandRepository(); var result = repository.Xe(pnrPair.PNR, passengerNames, userName); PidManagementService.SaveCounter(oemId, HasUsePlatformConfig(oemId, type)); return(result); }
/// <summary> /// 支付成功 /// </summary> internal void PaySuccess(DateTime?payTime) { if (this.Status == OrderStatus.Ordered) { if (IsSpecial) { var specialProduct = Product as SpeicalProductInfo; if (specialProduct.RequireConfirm) { Status = OrderStatus.PaidForETDZ; } else { switch (specialProduct.SpeicalProductType) { case SpecialProductType.CostFree: case SpecialProductType.Bloc: case SpecialProductType.Business: case SpecialProductType.LowToHigh: Status = PNRPair.IsNullOrEmpty(ReservationPNR) ? OrderStatus.PaidForSupply : OrderStatus.PaidForETDZ; break; default: Status = OrderStatus.PaidForSupply; break; } } } else { this.Status = OrderStatus.PaidForETDZ; } Purchaser.PayTime = payTime; VisibleRole |= Status == OrderStatus.PaidForETDZ || !IsThirdRelation ? OrderRole.Provider : OrderRole.Supplier; } else { throw new StatusException(this.Id.ToString()); } }
/// <summary> /// 同意改期 /// </summary> internal void Agree(PostponeView postponeView, string operatorAccount, string @operator) { if (this.Status == PostponeApplyformStatus.Applied || this.Status == PostponeApplyformStatus.Paid) { if (postponeView == null || postponeView.Items == null || !postponeView.Items.Any()) { throw new CustomException("改期信息不能为空"); } foreach (var flight in this.Flights) { var postponeVoyageView = postponeView.Items.FirstOrDefault(item => flight.OriginalFlight.IsSameVoyage(item.AirportPair)); if (postponeVoyageView == null) { throw new NotFoundException("缺少航段【" + flight.OriginalFlight.Departure.Code + "-" + flight.OriginalFlight.Arrival.Code + "】的改期信息"); } flight.NewFlight.FlightNo = postponeVoyageView.FlightNo; flight.NewFlight.AirCraft = postponeVoyageView.AirCraft; flight.NewFlight.TakeoffTime = postponeVoyageView.TakeoffTime; flight.NewFlight.LandingTime = postponeVoyageView.LandingTime; flight.OriginalFlight.Ticket.RemoveFlight(flight.OriginalFlight); flight.OriginalFlight.Ticket.AddFlight(flight.NewFlight); } if (!PNRPair.IsNullOrEmpty(postponeView.NewPNR)) { this.NewPNR = postponeView.NewPNR; } this.Status = PostponeApplyformStatus.Postponed; this.Operator = @operator; this.OperatorAccount = operatorAccount; Processed(); this.Order.Update(this); } else { throw new StatusException(this.Id.ToString()); } }
private PNRPair validateTicketNos(PNRPair etdzPNR, IEnumerable <TicketNoView.Item> ticketNoItems, Guid oemId) { PNRPair validatePNR = etdzPNR; if (PNRPair.IsNullOrEmpty(etdzPNR)) { validatePNR = Code; } if (ConfigurationManager.AppSettings["ValidateTicketNo"] == "1") { ExecuteResult <IEnumerable <Command.Domain.PNR.Passenger> > execResult = CommandService.GetTicketNumbersByPnr(validatePNR, oemId); if (execResult.Success) { foreach (TicketNoView.Item item in ticketNoItems) { if (execResult.Result.FirstOrDefault(pt => pt.Name == item.Name && pt.TicketNumbers == item.TicketNos) == null) { throw new CustomException("乘机人[" + item.Name + "]的票号[" + item.TicketNos + "]与编码中的票号信息不匹配"); } } } } return(validatePNR); }
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); }
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内容"); } } }
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); }
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)); }
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)); } } }