Ejemplo n.º 1
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.º 2
0
        /// <summary>
        /// 生成订单
        /// </summary>
        public static RequestResult <ExternalOrderView> Produce(decimal orderId, DataTransferObject.Order.OrderView orderView, DataTransferObject.Policy.ExternalPolicyView policy)
        {
            if (orderView == null)
            {
                throw new ArgumentNullException("orderView");
            }
            if (policy == null)
            {
                throw new ArgumentNullException("policy");
            }

            var processor = createOrderProcessor(policy.Platform);

            return(processor.Produce(orderId, orderView, policy));
        }
Ejemplo n.º 3
0
        public RequestResult <ExternalOrderView> Produce(decimal orderId, DataTransferObject.Order.OrderView orderView, string pnrContent, string patContent, DataTransferObject.Policy.ExternalPolicyView policy)
        {
            if (orderView.UseBPNR)
            {
                return(Produce(orderId, orderView, policy));
            }
            RequestResult <ExternalOrderView> result;
            var request  = string.Empty;
            var response = string.Empty;

            try {
                var platform = new IBEService {
                    Url = Platform.Address
                };
                var pnr           = orderView.UseBPNR?orderView.PNR.BPNR:orderView.PNR.PNR;
                var pnrText       = GetPnrParameter(pnrContent, patContent);
                var yeexingPolicy = policy as DataTransferObject.Policy.YeexingPolicyView;
                var signValue     = new Dictionary <string, string>
                {
                    { "userName", Platform.UserName },
                    { "pnr", pnr },
                    { "pnrText", pnrText },
                    { "plcid", policy.Id },
                    { "ibePrice", yeexingPolicy.IBEPrice },
                    { "out_orderid", orderId.ToString() },
                    { "disc", yeexingPolicy.Disc },
                    { "extReward", yeexingPolicy.extReward }
                };
                var signText = Sign(signValue);
                request  = GetRequestValue(signValue, signText);
                response = platform.ParsePnrBook(Platform.UserName, pnr, pnrText, policy.Id, yeexingPolicy.IBEPrice, orderId.ToString(), yeexingPolicy.Disc, yeexingPolicy.extReward, signText);
                result   = parseProduceResponse(response);
            } catch (Exception ex) {
                result = new RequestResult <ExternalOrderView> {
                    Success    = false,
                    ErrMessage = "系统错误,请联系平台"
                };
                LogService.SaveExceptionLog(ex, "易行生成订单");
                response = ex.Message;
            }
            SaveRequestLog(response, request, "生成订单");
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 生成订单
        /// </summary>
        public static RequestResult <ExternalOrderView> Produce(decimal orderId, DataTransferObject.Order.OrderView orderView, string pnrContent, string patContent, DataTransferObject.Policy.ExternalPolicyView policy)
        {
            if (orderView == null)
            {
                throw new ArgumentNullException("orderView");
            }
            if (string.IsNullOrWhiteSpace(pnrContent))
            {
                throw new ArgumentNullException("pnrContent");
            }
            if (string.IsNullOrWhiteSpace(patContent))
            {
                throw new ArgumentNullException("patContent");
            }
            if (policy == null)
            {
                throw new ArgumentNullException("policy");
            }

            pnrContent = pnrContent.RemovePrintedContent().RemoveETermSpecialContentOnWeb();
            var processor = createOrderProcessor(policy.Platform);

            return(processor.Produce(orderId, orderView, pnrContent, patContent, policy));
        }
Ejemplo n.º 5
0
 private void bindOrderView(string flights, string passengers, string contact, DataTransferObject.Order.OrderView orderView)
 {
     orderView.Flights = loadFlightView(flights, passengers).Select(view => new DataTransferObject.Order.FlightView
     {
         SerialNo          = view.Serial,
         Departure         = view.Departure.Code,
         Arrival           = view.Arrival.Code,
         TakeoffTime       = view.Departure.Time,
         LandingTime       = view.Arrival.Time,
         Airline           = view.AirlineCode,
         FlightNo          = view.FlightNo,
         YBPrice           = view.YBPrice,
         AirCraft          = view.Aircraft,
         Bunk              = view.BunkCode,
         Fare              = view.Fare,
         Type              = view.BunkType == null ? BunkType.Economic : view.BunkType.Value,
         IsShare           = view.IsShare,
         ArrivalTerminal   = view.Arrival.Terminal,
         DepartureTerminal = view.Departure.Terminal
     });
     orderView.Passengers = loadPassenger(passengers, orderView);
     if (contact != "")
     {
         var c = contact.Split('|');
         orderView.Contact = new DataTransferObject.Order.Contact()
         {
             Name   = c[0],
             Mobile = c[1],
             Email  = c[2]
         };
     }
     else
     {
         orderView.Contact = new DataTransferObject.Order.Contact()
         {
             Name   = Employee.Name,
             Mobile = Employee.Cellphone,
             Email  = Employee.Email
         };
     }
     orderView.TripType = DataTransferObject.Command.PNR.ItineraryType.OneWay;
 }
Ejemplo n.º 6
0
        private MatchedPolicy QueryPolicies(PolicyType policyType, string flights, string passengers, DataTransferObject.Order.OrderView orderView)
        {
            PassengerType passengerType         = PassengerType.Adult;
            var           policyFilterCondition = new PolicyFilterConditions
            {
                PolicyType = policyType,
                Purchaser  = Company.CompanyId
            };
            IEnumerable <VoyageFilterInfo> voyages = getVoyageFilterInfos(flights, passengers);

            // 特殊票时,只取航班查询处选择的价格
            if (policyType == PolicyType.Special)
            {
                PolicyView policyView   = null;
                var        flightFlight = voyages.FirstOrDefault();
                if (flightFlight != null && flightFlight.Bunk == null)
                {
                    policyFilterCondition.PatPrice = orderView.PATPrice != null ? orderView.PATPrice.Fare : (decimal?)null;
                }
                else if (policyView != null && flightFlight != null && flightFlight.Bunk == null)
                {
                    policyFilterCondition.PublishFare = policyView.PublishFare;
                }
            }
            else
            {
                policyFilterCondition.PatPrice = orderView.PATPrice != null ? orderView.PATPrice.Fare : (decimal?)null;
            }
            policyFilterCondition.Voyages.AddRange(voyages);
            policyFilterCondition.VoyageType      = VoyageType.OneWay;
            policyFilterCondition.SuitReduce      = hasReduce(voyages, orderView.PATPrice != null ? orderView.PATPrice.Fare : (decimal?)null);
            policyFilterCondition.NeedSubsidize   = true;
            policyFilterCondition.IsUsePatPrice   = false;
            policyFilterCondition.AllowTicketType = FilterByTime(voyages.Min(f => f.Flight.TakeOffTime));
            policyFilterCondition.MaxdRebate      = 0;

            IEnumerable <MatchedPolicy> matchedPolicies = PolicyMatchServcie.MatchBunk(policyFilterCondition, false, passengerType, 1).ToList();

            if (!matchedPolicies.Any() || matchedPolicies.FirstOrDefault() == null)
            {
                InterfaceInvokeException.ThrowNotFindPolicyException();
            }
            return(matchedPolicies.FirstOrDefault());
        }
Ejemplo n.º 7
0
        private List <DataTransferObject.Order.PassengerView> loadPassenger(string passengers, DataTransferObject.Order.OrderView orderView)
        {
            var list = new List <DataTransferObject.Order.PassengerView>();

            foreach (var item in passengers.Split('^'))
            {
                var p = item.Split('|');
                list.Add(new DataTransferObject.Order.PassengerView()
                {
                    Name            = p[0],
                    CredentialsType = (Common.Enums.CredentialsType) byte.Parse(p[1]),
                    Credentials     = p[2],
                    Phone           = p[3],
                    PassengerType   = Common.Enums.PassengerType.Adult
                });
            }
            return(list);
        }
Ejemplo n.º 8
0
 public RequestResult <DataTransferObject.Order.External.ExternalOrderView> Produce(decimal orderId, DataTransferObject.Order.OrderView orderView, DataTransferObject.Policy.ExternalPolicyView policy)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 9
0
        public RequestResult <DataTransferObject.Order.External.ExternalOrderView> Produce(decimal orderId, DataTransferObject.Order.OrderView orderView, string pnrContent, string patContent, DataTransferObject.Policy.ExternalPolicyView policy)
        {
            RequestResult <DataTransferObject.Order.External.ExternalOrderView> result;
            var request  = string.Empty;
            var response = string.Empty;

            try {
                pnrContent = pnrContent.Trim().TrimEnd('>');
                patContent = patContent.Trim().TrimEnd('>');
                var requestModel = new _51bookCreateOrder.createOrderByRtPatRequest()
                {
                    agencyCode                 = Platform.UserName,
                    pnrTxt                     = pnrContent,
                    pataTxt                    = patContent,
                    outOrderNo                 = orderId.ToString(),
                    policyIdSpecified          = true,
                    policyId                   = int.Parse(policy.Id),
                    allowSwitchPolicySpecified = true,
                    allowSwitchPolicy          = 0,
                    needProductTypeSpecified   = true,
                    needProductType            = 2,
                    allowSwitchPnrSpecified    = true,
                    allowSwitchPnr             = 1,
                    doPaySpecified             = true,
                    payTypeSpecified           = true,
                    linkMan                    = Platform.Contact,
                    linkPhone                  = Platform.ContactPhone,
                    createdBy                  = Platform.UserName,
                    ticketNotifiedUrl          = Platform.ETDZNotifyUrl,
                    paymentReturnUrl           = Platform.PayReturnUrl
                };
                var signValue = new Dictionary <string, string>
                {
                    { "agencyCode", Platform.UserName },
                    { "createdBy", requestModel.createdBy },
                    { "doPay", requestModel.doPay.ToString() },
                    { "linkMan", requestModel.linkMan },
                    { "linkPhone", requestModel.linkPhone },
                    { "payBank", requestModel.payBank },
                    { "payType", requestModel.payType.ToString() },
                    { "policyId", requestModel.policyId.ToString() }
                };
                requestModel.sign = Sign(signValue);
                var platform = new _51bookCreateOrder.CreateOrderByRtPatServiceImpl_1_0Service {
                    Url = Platform.Address_CreateOrderByPnrText
                };
                request = GetModelString(requestModel);
                var responseModel = platform.createOrderByRtPat(requestModel);
                response = GetModelString(responseModel);
                result   = parseProduceResponse(responseModel);
            } catch (Exception ex) {
                LogService.SaveExceptionLog(ex, "51book生成订单");
                result = new RequestResult <DataTransferObject.Order.External.ExternalOrderView> {
                    Success    = false,
                    ErrMessage = "系统错误,请联系平台"
                };
                response = ex.Message;
            }
            SaveRequestLog(response, request, "生成订单");
            return(result);
        }