protected override string ExecuteCore() { string _id = Context.GetParameterValue("id"); decimal id = 0M; if (decimal.TryParse(_id, out id)) { var orderInfo = OrderQueryService.QueryOrder(id); if (orderInfo == null) { InterfaceInvokeException.ThrowCustomMsgException("暂无此订单"); } if (orderInfo.Purchaser.CompanyId != Company.CompanyId) { InterfaceInvokeException.ThrowCustomMsgException("暂无此订单"); } if (orderInfo.Bill == null) { InterfaceInvokeException.ThrowCustomMsgException("暂无账单信息"); } return(ReturnStringUtility.GetOrder(orderInfo)); } InterfaceInvokeException.ThrowParameterErrorException("订单号"); return(""); }
protected override string ExecuteCore() { var pnrContext = Context.GetParameterValue("pnrContent"); var patContent = Context.GetParameterValue("patContent"); _policyId = Context.GetParameterValue("policyId"); _associatePNR = Context.GetParameterValue("associatePNR"); _contact = Context.GetParameterValue("contact"); _orgbatchNo = Context.GetParameterValue("batchNo"); ValidateBusinessParameters(HttpUtility.UrlDecode(pnrContext), HttpUtility.UrlDecode(patContent)); StringBuilder str = new StringBuilder(); var flights = ReserveViewConstuctor.GetQueryFlightView(_pnr.Voyage.Segments, _pnr.Voyage.Type, _pnr.Passengers.First().Type, _pnr.IsTeam); var orderView = GetOrderView(OrderSource.InterfaceOrder, _pnr, new ChinaPay.B3B.DataTransferObject.Common.PNRPair() { BPNR = _associatePNR == "" ? "" : _associatePNR.Split('|')[0], PNR = _associatePNR == "" ? "" : (_associatePNR.Split('|').Count() < 2 ? "" : _associatePNR.Split('|')[1]) }, flights, _contact); var orderInfo = Service.OrderProcessService.ProduceOrder(orderView, _matchedPolicy, Employee, Guid.Empty, false); str.AppendFormat("<id>{0}</id>", orderInfo.Id); str.AppendFormat("<officeNo>{0}</officeNo>", _matchedPolicy.OriginalPolicy == null && _matchedPolicy.NeedAUTH ? _matchedPolicy.OfficeNumber : (_matchedPolicy.OriginalPolicy != null && _matchedPolicy.OriginalPolicy.NeedAUTH ? _matchedPolicy.OriginalPolicy.OfficeCode : "")); str.AppendFormat("<payable>{0}</payable>", _matchedPolicy.ConfirmResource ? 0 : 1); str.Append(ReturnStringUtility.GetOrder(orderInfo)); //清空缓存 ContextCenter.Instance.Remove(_orgbatchNo); return(str.ToString()); }
protected override string ExecuteCore() { var orderId = Context.GetParameterValue("orderId"); var passengers = Context.GetParameterValue("passengers"); var voyages = Context.GetParameterValue("voyages"); var refundType = Context.GetParameterValue("refundType"); var reason = Context.GetParameterValue("reason"); if (string.IsNullOrWhiteSpace(orderId)) { InterfaceInvokeException.ThrowParameterMissException("orderId"); } if (string.IsNullOrWhiteSpace(passengers)) { InterfaceInvokeException.ThrowParameterMissException("passengers"); } if (string.IsNullOrWhiteSpace(voyages)) { InterfaceInvokeException.ThrowParameterMissException("voyages"); } if (string.IsNullOrWhiteSpace(refundType)) { InterfaceInvokeException.ThrowParameterMissException("refundType"); } if (string.IsNullOrWhiteSpace(reason)) { InterfaceInvokeException.ThrowParameterMissException("reason"); } decimal id; if (!decimal.TryParse(orderId, out id)) { InterfaceInvokeException.ThrowParameterErrorException("订单号"); } var order = Service.OrderQueryService.QueryOrder(id); if (order == null) { InterfaceInvokeException.ThrowCustomMsgException("暂无此订单"); } if (order.Purchaser.CompanyId != Company.CompanyId) { InterfaceInvokeException.ThrowCustomMsgException("暂无此订单"); } id = ApplyRefundObj(order, refundType, passengers, voyages, reason); var obj = Service.ApplyformQueryService.QueryApplyform(id); return(ReturnStringUtility.GetApplyform(obj)); }
private Service.PolicyMatch.Domain.PolicyFilterConditions GetPolicyFilter(IEnumerable <DataTransferObject.FlightQuery.FlightView> flights, PolicyType type) { var policyFilterCondition = new Service.PolicyMatch.Domain.PolicyFilterConditions { PolicyType = type, Purchaser = Company.CompanyId, AllowTicketType = ReturnStringUtility.FilterByTime(flights.Min(item => item.Departure.Time)) }; var voyages = getVoyageFilterInfos(flights); policyFilterCondition.Voyages.AddRange(voyages); policyFilterCondition.VoyageType = _pnr.Voyage.Type == ItineraryType.Conjunction ? VoyageType.TransitWay : (_pnr.Voyage.Type == ItineraryType.Notch ? VoyageType.Notch : (_pnr.Voyage.Type == ItineraryType.OneWay ? VoyageType.OneWay : VoyageType.RoundTrip)); policyFilterCondition.PatPrice = _patPrices.Min(item => item.Fare); policyFilterCondition.NeedSubsidize = true; policyFilterCondition.IsUsePatPrice = false; return(policyFilterCondition); }
private Service.PolicyMatch.Domain.PolicyFilterConditions GetPolicyFilter(IEnumerable <DataTransferObject.FlightQuery.FlightView> flights) { PolicyType policyType = ReturnStringUtility.QueryPolicyType(flights, _pnr); var policyFilterCondition = new Service.PolicyMatch.Domain.PolicyFilterConditions { PolicyType = policyType, Purchaser = Company.CompanyId, AllowTicketType = ReturnStringUtility.FilterByTime(flights.Min(item => item.Departure.Time)) }; var voyages = getVoyageFilterInfos(flights); policyFilterCondition.Voyages.AddRange(voyages); policyFilterCondition.VoyageType = _pnr.Voyage.Type == ItineraryType.Conjunction ? VoyageType.TransitWay : (_pnr.Voyage.Type == ItineraryType.Notch ? VoyageType.Notch : (_pnr.Voyage.Type == ItineraryType.OneWay ? VoyageType.OneWay : VoyageType.RoundTrip)); policyFilterCondition.PatPrice = _patPrices.Min(item => item.Fare); policyFilterCondition.SuitReduce = ReturnStringUtility.hasReduce(voyages, policyFilterCondition.PatPrice); policyFilterCondition.NeedSubsidize = true; policyFilterCondition.IsUsePatPrice = fdSuccess || !(flights.Count() == 1 && (flights.FirstOrDefault().BunkType.Value == BunkType.Economic || flights.FirstOrDefault().BunkType.Value == BunkType.FirstOrBusiness)); return(policyFilterCondition); }
protected override string ExecuteCore() { string applyformId = Context.GetParameterValue("applyformId"); decimal id; if (!decimal.TryParse(applyformId, out id)) { InterfaceInvokeException.ThrowParameterErrorException("applyformId"); } var obj = Service.ApplyformQueryService.QueryApplyform(id); if (obj == null) { InterfaceInvokeException.ThrowCustomMsgException("暂无此申请单"); } if (obj.Purchaser.CompanyId != Company.CompanyId) { InterfaceInvokeException.ThrowCustomMsgException("暂无此申请单"); } return(ReturnStringUtility.GetApplyform(obj)); }
protected override string ExecuteCore() { var pnrContext = Context.GetParameterValue("pnrContent"); var patContext = Context.GetParameterValue("patContent"); ValidateBusinessParameters(HttpUtility.UrlDecode(pnrContext), HttpUtility.UrlDecode(patContext)); 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()) { InterfaceInvokeException.ThrowNotFindPolicyException(); } } if (!matchedPolicies.Any()) { InterfaceInvokeException.ThrowNotFindPolicyException(); } StringBuilder str = new StringBuilder(); str.Append("<policies>"); ReturnStringUtility.GetPolicy(matchedPolicies, matchedSpeciafPolicies, str, _policyType, _flights, InterfaceSetting); str.Append("</policies>"); //将匹配出来的政策存入缓存中 CustomContext context = CustomContext.NewContext(); context[_pnr.PnrPair.BPNR + _pnr.PnrPair.PNR] = matchedPolicies; ContextCenter.Instance.Save(context); str.AppendFormat("<batchNo>{0}</batchNo>", context.Id + "0"); return(str.ToString()); }
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); }
private decimal ApplyRefundObj(ChinaPay.B3B.Service.Order.Domain.Order order, string refundType, string passengers, string voyages, string reason) { RefundOrScrapApplyformView applyformView = null; if (refundType == "-1") { applyformView = new ScrapApplyformView(); } else { applyformView = new RefundApplyformView() { RefundType = (RefundType)int.Parse(refundType) }; } var app = Service.ApplyformQueryService.QueryApplyforms(order.Id); string pid = ""; string vid = ""; List <PNRPair> _pnrCode = new List <PNRPair>(); foreach (var item in passengers.Split('^')) { foreach (var o in order.PNRInfos) { var j = o.Passengers.FirstOrDefault(i => i.Name == item); if (j != null) { if (pid != "") { pid += "," + j.Id.ToString(); } else { pid += j.Id.ToString(); } _pnrCode.Add(o.Code); if (!_pnrCode.Contains(o.Code)) { InterfaceInvokeException.ThrowCustomMsgException("当前订单中存在不同的编码"); } foreach (var f in voyages.Split('^')) { if (f.Split('|').Count() < 3) { InterfaceInvokeException.ThrowParameterErrorException("航班信息"); } if (f.Split('|')[0].Length != 6) { InterfaceInvokeException.ThrowParameterErrorException("城市对"); } var departure = f.Split('|')[0].Substring(0, 3).ToUpper(); var arrival = f.Split('|')[0].Substring(3, 3).ToUpper(); var flightNo = f.Split('|')[1]; var flightTime = f.Split('|')[2]; var ff = o.Flights.FirstOrDefault(i => i.Departure.Code == departure && i.Arrival.Code == arrival && i.FlightNo == flightNo && i.TakeoffTime.Date == DateTime.Parse(flightTime)); if (ff != null) { if (!vid.Split(',').Contains(ff.Id.ToString())) { if (vid != "") { vid += "," + ff.Id.ToString(); } else { vid += ff.Id.ToString(); } } } } break; } } } if (pid == "") { InterfaceInvokeException.ThrowCustomMsgException("当前订单中没有找到对应的乘机人信息"); } if (vid == "") { InterfaceInvokeException.ThrowCustomMsgException("当前订单中没有找到对应的航班信息"); } if (!_pnrCode.Any()) { InterfaceInvokeException.ThrowCustomMsgException("当前订单中没有找到对应的编码信息"); } applyformView.PNR = _pnrCode.FirstOrDefault(); applyformView.Passengers = ApplyOrder.getPassengers(pid); applyformView.Reason = reason; foreach (var item in ApplyOrder.getRefundVoyages(vid)) { applyformView.AddVoyage(item); } string lockErrorMsg = ""; ReturnStringUtility.Lock(order.Id, Service.Locker.LockRole.Purchaser, Company, Employee, "申请退改签", out lockErrorMsg); if (!string.IsNullOrEmpty(lockErrorMsg)) { InterfaceInvokeException.ThrowCustomMsgException(lockErrorMsg); } var apply = Service.OrderProcessService.Apply(order.Id, applyformView, Employee, Guid.Empty); ReturnStringUtility.releaseLock(order.Id, Company, Employee); return(apply.Id); }
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(""); }
protected void ValidateBusinessParameters(string pnrContext, string patContext) { if (string.IsNullOrWhiteSpace(pnrContext)) { InterfaceInvokeException.ThrowParameterMissException("编码内容"); } if (string.IsNullOrWhiteSpace(patContext)) { InterfaceInvokeException.ThrowParameterMissException("PAT内容"); } try { var result = CommandService.GetReservedPnr(pnrContext); 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 { _patPrices = Service.Command.Domain.Utility.Parser.GetPatPrices(patContext); if (_patPrices == null) { InterfaceInvokeException.ThrowCustomMsgException("缺少PAT内容"); } if (_patPrices.Count == 0) { InterfaceInvokeException.ThrowCustomMsgException("缺少PAT内容"); } } //if (!_pnr.IsTeam && !_pnr.IsFilled) InterfaceInvokeException.ThrowCustomMsgException( "缺口程编码,需要搭桥"); //验证 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); }