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); }
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); }
/// <summary> /// 添加编码信息 /// </summary> internal void AddPNRInfo(PNRInfo pnrInfo) { if (null == pnrInfo) { throw new ArgumentNullException("pnrInfo", "编码信息不能为空"); } if (_pnrInfos.Exists(item => PNRPair.Equals(item.Code, pnrInfo.Code))) { throw new RepeatedItemException("不能重复加入同一编码"); } _pnrInfos.Add(pnrInfo); }
private void bindHKCode(Order order) { divHKCode.Visible = true; PNRInfo pnr = order.PNRInfos.First(); int passengerCount = pnr.Passengers.Count(); string hkCodes = CommandService.GetBookingTicketsString( new ReservationInfo { AgentPhoneNumber = order.Contact.Mobile, Passengers = (from p in pnr.Passengers select new ReservationPassengerInfo { Name = p.Name, Type = p.PassengerType, CertificateNumber = p.Credentials, CertificateType = p.CredentialsType, MobilephoneNumber = p.Phone, Birthday = p.Birthday } ).ToList(), Segements = (from p in pnr.Flights select new ReservationSegmentInfo { Carrier = p.Carrier.Code, InternalNumber = p.FlightNo, ClassOfService = p.Bunk.Code, Date = p.TakeoffTime, DepartureAirportCode = p.Departure.Code, ArrivalAirportCode = p.Arrival.Code, }).ToList() }, BasePage.OwnerOEMId //new ReservationInformation // { // Airline = pnr.Flights.First().Carrier.Code, // PassengerType = pnr.Passengers.First().PassengerType, // Passengers = pnr.Passengers.Select(ToCommandType).ToList(), // Segments = pnr.Flights.Select(f => ToCommandType(f, passengerCount)).ToList(), // PassengerPhone = order.Contact.Mobile, // } ); var workingSetting = CompanyService.GetWorkingSetting(CurrentCompany.CompanyId); txtHKCode.Text = workingSetting != null?hkCodes.Replace("OfficeNo", workingSetting.DefaultOfficeNumber) : hkCodes; }
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> /// 根据申请单修改订单内容 /// </summary> internal void Update(BaseApplyform applyform) { var originalPNRInfo = this.PNRInfos.FirstOrDefault(item => PNRPair.Equals(item.Code, applyform.OriginalPNR)); if (originalPNRInfo == null) { throw new CustomException("未找到原编码信息"); } PNRInfo newPnrInfo = null; if (applyform is RefundOrScrapApplyform) { newPnrInfo = originalPNRInfo.UpdateContentForRefund(applyform as RefundOrScrapApplyform); } else if (applyform is PostponeApplyform) { newPnrInfo = originalPNRInfo.UpdateContentForPostpone(applyform as PostponeApplyform); } if (newPnrInfo != null) { AddPNRInfo(newPnrInfo); } }
private PNRInfo separate(PNRPair newPNRCode, IEnumerable <Guid> passengers) { var newPnrInfo = new PNRInfo { Code = newPNRCode }; foreach (Guid item in passengers) { Passenger passenger = getPassenger(item); if (passenger == null) { throw new CustomException("不存在的乘机人"); } newPnrInfo.AddPassenger(passenger.Copy()); } foreach (Flight flight in Flights) { newPnrInfo.AddFlight(flight.Copy()); } removePassengers(passengers); return(newPnrInfo); }
internal static PNRInfo GetPNRInfo(OrderView orderView, MatchedPolicy policy) { if (policy == null) { throw new ArgumentNullException("policy"); } var result = new PNRInfo { Code = orderView.PNR }; PassengerType passengerType = orderView.Passengers.First().PassengerType; decimal? averageFare = null; if (orderView.PATPrice != null) { averageFare = Calculator.Round(orderView.PATPrice.Fare / orderView.Flights.Count(), 1); } Flight preFlight = null; var increasing = policy.OemInfo == null?0:policy.OemInfo.ProfitType == OemProfitType.PriceMarkup ? policy.OemInfo.TotalProfit / orderView.Flights.Count() : 0; foreach (FlightView item in orderView.Flights.OrderBy(f => f.TakeoffTime)) { Flight flight = Flight.GetFlight(item, passengerType, policy, averageFare); flight.Increasing = increasing; if (preFlight == null) { // 第一段 flight.Serial = 1; } else { if (preFlight.Arrival.Code == flight.Departure.Code) { flight.Serial = preFlight.Serial + 1; } else { // 缺口程会跳一段(中间跳过的是搭进去的那一段) flight.Serial = preFlight.Serial + 2; } } result.AddFlight(flight); preFlight = flight; } // 调整航班价格信息 if (orderView.PATPrice != null) { if (policy.PolicyType == PolicyType.Special) { // 特殊政策 不调整票面价 } else if (policy.PolicyType == PolicyType.Bargain) { // 对于按价格或折扣方式发布的特价政策不调整票面价 var promotionPolicy = policy.OriginalPolicy as BargainPolicyInfo; if (promotionPolicy == null || promotionPolicy.PriceType == PriceType.Commission || promotionPolicy.PriceType == PriceType.Subtracting || promotionPolicy.Price < 0) { result.reviseFare(orderView.PATPrice.Fare); } } else if (orderView.Source != OrderSource.PlatformOrder && !orderView.IsTeam && result.Flights.Count() == 1 && result.Flights.First().Bunk is GeneralBunk) { // 非预订时,普通舱位的单程不调整票面价 } else { result.reviseFare(orderView.PATPrice.Fare); } // 机建 result.reviseAirportFee(orderView.PATPrice.AirportTax); } foreach (PassengerView item in orderView.Passengers) { Passenger passenger = Passenger.GetPassenger(item); passenger.FillFlights(result.Flights); result.AddPassenger(passenger); } return(result); }