예제 #1
0
        protected void SearchAirLine(object sender, EventArgs e)
        {
            var     id = Request.QueryString["id"];
            decimal orderId;

            if (decimal.TryParse(id, out orderId))
            {
                var order      = Service.OrderQueryService.QueryOrder(orderId);
                var passengers = hidApplyPassengers.Value.Split(',');
                var voyages    = hidApplyFlights.Value.Split(',');
                var pnr        = hidApplyPNR.Value.Replace("(小)", string.Empty).Replace("(大)", string.Empty).Split('|');
                if (passengers.Any() && voyages.Any())
                {
                    var currentPNRPair = order.PNRInfos.FirstOrDefault(p => p.Code.PNR == pnr[0] && p.Code.BPNR == pnr[1]);
                    if (currentPNRPair == null)
                    {
                        ShowMessage("编码信息错误!");
                        return;
                    }
                    var selectedPasserengerIds = passengers.Select(Guid.Parse);
                    var selectedVoyageIds      = voyages.Select(Guid.Parse);
                    var selectedPasserengers   = from sp in selectedPasserengerIds
                                                 from op in currentPNRPair.Passengers
                                                 where sp == op.Id
                                                 select new DataTransferObject.Order.PassengerView()
                    {
                        Name            = op.Name,
                        Credentials     = op.Credentials,
                        CredentialsType = op.CredentialsType,
                        PassengerType   = op.PassengerType,
                        Phone           = op.Phone
                    };
                    var isGoBackFlight = !string.IsNullOrEmpty(Request.Form["date1"]);
                    var applyForm      = new UpgradeApplyformView()
                    {
                        Passengers = selectedPasserengerIds,
                        PNR        = new PNRPair(pnr[0], pnr[1]),
                        PNRSource  = OrderSource.PlatformOrder,
                    };
                    var selectedVoyages = selectedVoyageIds.Join(currentPNRPair.Flights, p => p, p => p.Id, (p, q) => q).ToList();
                    selectedVoyages.ForEach(p => applyForm.AddItem(new UpgradeApplyformView.Item()
                    {
                        Voyage = p.Id,
                        Flight = new FlightView()
                        {
                            SerialNo    = p.Serial,
                            Departure   = p.Departure.Code,
                            Arrival     = p.Arrival.Code,
                            TakeoffTime = p.TakeoffTime,
                            LandingTime = p.LandingTime,
                            Airline     = p.Carrier.Code,
                            YBPrice     = p.YBPrice,
                            FlightNo    = p.FlightNo,
                            AirCraft    = p.AirCraft,
                            Bunk        = p.Bunk.Code,
                            Type        = p.Bunk.Type
                        }
                    }));
                    var flight = selectedVoyages.OrderBy(p => p.TakeoffTime).First();
                    Session["UpgradeApplyformView"] = applyForm;
                    Session["UpgradePassengers"]    = selectedPasserengers.ToList();
                    //Session["ReservedFlights"] = selectedVoyages;
                    //isGoBackFlight =
                    var dealUrl = string.Format("{7}?airline={0}&departure={1}&arrival={2}&goDate={3}{4}&source=4&orderId={5}&provider={6}", flight.Carrier.Code, flight.Departure.Code, flight.Arrival.Code, Request.Form["date0"], isGoBackFlight ? string.Format("&backDate={0}", Request.Form["date1"]) : string.Empty, orderId, order.Provider.CompanyId, isGoBackFlight ? "/FlightReserveModule/FlightQueryGoResult.aspx" : "/FlightReserveModule/FlightQueryResult.aspx");
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "redirect", "window.parent.location.href='" + dealUrl + "'", true);
                }
                else
                {
                    ShowMessage("没有选择需要升舱的航段或乘客!");
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 申请升舱
        /// </summary>
        /// <param name="orderId">订单号</param>
        /// <param name="pnrCode">编码(小编码|大编码)</param>
        /// <param name="passengers">乘机人(乘机人id,以','隔开)</param>
        /// <param name="voyages">航段(航段id|新航班号|新航班日期,以','隔开)</param>
        /// <param name="originalPNR">原始编码 </param>
        public object ApplyUpgrade(decimal orderId, string pnrCode, List <PassengerViewEx> passengers, List <FlihgtInfo> voyages, string originalPNR)
        {
            try
            {
                var pnrPair = originalPNR.Split('|');
                if (originalPNR.ToUpper().IndexOf(pnrCode.ToUpper(), StringComparison.Ordinal) > -1)
                {
                    throw new CustomException("编码与原编码不能相同");
                }
                var flightViews = ImportHelper.AnalysisPNR(pnrCode, HttpContext.Current);
                if (flightViews.Item2.Count() != passengers.Count)
                {
                    throw new CustomException("所选乘客与编码中的乘客数量不一致");
                }
                if (flightViews.Item1.Count() != voyages.Count)
                {
                    throw new CustomException("所选航班与编码中的航班数量不一致");
                }
                var ValidateInfo = passengers.Join(flightViews.Item2, p => p.Name, p => p.Name, (p, q) => 1);
                if (ValidateInfo.Count() != passengers.Count)
                {
                    throw new CustomException("编码中的乘客姓名与所选乘客姓名不匹配!");
                }
                var order = OrderQueryService.QueryOrder(orderId);
                if (order == null)
                {
                    throw new ArgumentNullException("订单不存在");
                }
                List <Flight> allOrderFlights = new List <Flight>();
                foreach (PNRInfo info in order.PNRInfos)
                {
                    allOrderFlights.AddRange(info.Flights);
                }
                var applyformView = new UpgradeApplyformView()
                {
                    NewPNR     = new PNRPair(pnrCode, string.Empty),
                    Passengers = passengers.Select(p => p.PassengerId),
                    PNRSource  = OrderSource.CodeImport,
                    PNR        = new PNRPair(pnrPair[0], pnrPair[1])
                };
                foreach (var item in voyages)
                {
                    var flight = flightViews.Item1.FirstOrDefault(f => f.Departure.Code == item.Departure && f.Arrival.Code == item.Arrival);
                    if (flight == null)
                    {
                        throw new NullReferenceException("所选择的航程与编码提取航程不对应!");
                    }
                    applyformView.AddItem(new UpgradeApplyformView.Item()
                    {
                        Voyage = item.flightId,
                        Flight = new DataTransferObject.Order.FlightView()
                        {
                            SerialNo    = flight.Serial,
                            Airline     = flight.AirlineCode,
                            FlightNo    = flight.FlightNo,
                            Departure   = flight.Departure.Code,
                            Arrival     = flight.Arrival.Code,
                            AirCraft    = flight.Aircraft,
                            TakeoffTime = flight.Departure.Time,
                            LandingTime = flight.Arrival.Time,
                            YBPrice     = flight.YBPrice,
                            Bunk        = flight.BunkCode,
                            Type        = flight.BunkType == null ? BunkType.Economic : flight.BunkType.Value,
                            Fare        = flight.Fare
                        }
                    });
                }

                HttpContext.Current.Session["ApplyformView"]   = applyformView;
                HttpContext.Current.Session["Passengers"]      = passengers;
                HttpContext.Current.Session["ReservedFlights"] = flightViews.Item1;



                //Service.OrderProcessService.Apply(orderId, applyformView, CurrentUser.UserName);
                //releaseLock(orderId);
                return(new
                {
                    IsSuccess = true,
                    QueryString = string.Format("?source=3&orderId={0}&provider={1}", orderId, order.Provider.CompanyId)
                });
            }
            catch (Exception ex)
            {
                return(new
                {
                    IsSuccess = false,
                    QueryString = ex.Message
                });
            }
        }