private Policy GetLocalPolicy(PolicyParam policyParam, string policyId, string innerPlatformCode, UserRelation userRealtion, bool IspolicyIsNull, PolicyService policyService, Policy localPolicy)
        {
            PnrData pnrData = PnrHelper.GetPnrData(order.PnrContent);

            if (IspolicyIsNull)
            {
                //全部查询匹配一下
                localPolicy = policyService.GetLocalPolicy(userRealtion, innerPlatformCode, policyParam, pnrData).Find((p) => p.PolicyId == policyId);
                if (localPolicy == null)
                {
                    localPolicy = policyService.GetSharePolicy(userRealtion, innerPlatformCode, policyParam, pnrData).Find((p) => p.PolicyId == policyId);
                }
                if (localPolicy == null && policyId.StartsWith(userRealtion.carrier.Code + "_"))
                {
                    //本地 默认
                    localPolicy = policyService.GetDefaultPolicy(userRealtion, innerPlatformCode, policyParam, pnrData, policyId).FirstOrDefault();
                }
            }
            else
            {
                //非接口重新获取政策
                //本地
                localPolicy = policyService.GetLocalPolicy(userRealtion, innerPlatformCode, policyParam, pnrData).Find((p) => p.PolicyId == policyId);
                if (localPolicy == null)
                {
                    //共享 异地
                    localPolicy = policyService.GetSharePolicy(userRealtion, innerPlatformCode, policyParam, pnrData).Find((p) => p.PolicyId == policyId);
                }
                if (localPolicy == null)
                {
                    if (policyId.StartsWith(userRealtion.carrier.Code + "_"))
                    {
                        //本地 默认
                        localPolicy = policyService.GetDefaultPolicy(userRealtion, innerPlatformCode, policyParam, pnrData, policyId).FirstOrDefault();
                    }
                }
            }
            return(localPolicy);
        }
Esempio n. 2
0
        public void Test2()
        {
            BootStrapper.Boot();
            string         pnrContent     = @" 1.陈绪炎 2.陈耀胜 3.李祖新 4.逄增奎 5.王勇 6.易小平    HTFT12     7.  CA4487 Y   SU02NOV  CTUJZH HK6   1405 1500          E T2--   8.CTU/T CTU/T 028-85512345/CTU HUA LONG AIR SERVICE CO.,LTD/YANGHONG ABCDEFG     9.TL/1405/02NOV/CTU186  10.SSR FOID CA HK1 NI420583198402223411/P6   11.SSR FOID CA HK1 NI222426198404075215/P4   12.SSR FOID CA HK1 NI420523196512060013/P3   13.SSR FOID CA HK1 NI422723196608154631/P2   14.SSR FOID CA HK1 NI422723196309291919/P1   15.SSR FOID CA HK1 NI422723196611120037/P5   16.SSR FQTV CA HK1 CTUJZH 4487 Y02NOV CA002810349584/P1                        + 17.SSR ADTK 1E BY CTU30OCT14/1250 OR CXL CA ALL SEGS                           - 18.OSI CA CTCM18215523063/P5 19.OSI CA CTCT13518105618    20.RMK CA/NW2W0K 21.CTU186       >PAT:A   01 Y FARE:CNY1310.00 TAX:CNY50.00 YQ:CNY50.00  TOTAL:1410.00  SFC:01    SFN:01       ";
            PnrData        pnrData        = PnrHelper.GetPnrData(pnrContent);
            string         PolicyId       = "13703423";
            PlatformPolicy platformPolicy = PlatformFactory.GetPlatformByCode("517").GetPoliciesByPnrContent(pnrContent, true, pnrData).Find((p) => p.Id == PolicyId);

            return;


            OrderService IOrderService = ObjectFactory.GetInstance <OrderService>();

            AuthManager.SaveUser(new BPiaoBao.SystemSetting.Domain.Services.Auth.CurrentUserInfo()
            {
                Code            = "5105241974",
                OperatorAccount = "梦之旅",
                OperatorName    = "陈良文"
            });


            IOrderService.CreateInterfaceOrder("517", "04787578460867039561");
        }
        private void SetInterface(string platformCode, string operatorName, string source, ref decimal TotlePaidPirce, PlatformPolicy policy, UserRelation userRealtion, ref PlatformOrder platformOrder, PnrData pnrData)
        {
            #region 接口政策信息

            order.Policy.AreaCity            = policy.AreaCity;
            order.Policy.PolicyId            = policy.Id;
            order.Policy.PlatformCode        = platformCode;
            order.Policy.OriginalPolicyPoint = policy.PolicyPoint;
            order.Policy.DownPoint           = 0m;
            order.Policy.PaidPoint           = policy.PolicyPoint;
            if (source != "back")
            {
                order.Policy.PolicyPoint = order.Policy.PaidPoint;
            }
            order.Policy.ReturnMoney = policy.ReturnMoney;
            order.Policy.IsLow       = policy.IsLow;
            order.Policy.SeatPrice   = policy.SeatPrice;
            order.Policy.ABFee       = policy.ABFee;
            order.Policy.RQFee       = policy.RQFee;

            order.Policy.Remark           = policy.Remark;
            order.Policy.IsChangePNRCP    = policy.IsChangePNRCP;
            order.Policy.IsSp             = policy.IsSp;
            order.Policy.PolicyType       = policy.PolicyType;
            order.Policy.WorkTime         = policy.WorkTime;
            order.Policy.ReturnTicketTime = policy.ReturnTicketTime;
            order.Policy.AnnulTicketTime  = policy.AnnulTicketTime;
            order.Policy.CPOffice         = policy.CPOffice;
            order.Policy.OrderId          = order.OrderId;
            order.Policy.PolicySourceType = EnumPolicySourceType.Interface;
            order.Policy.CarryCode        = order.SkyWays[0].CarrayCode;
            order.Policy.IssueSpeed       = policy.IssueSpeed;
            order.Policy.TodayGYCode      = policy.TodayGYCode;
            #endregion
        }
        public override object Execute()
        {
            //记录时间
            StringBuilder sbLog = new StringBuilder();
            Stopwatch     watch = new Stopwatch();

            try
            {
                watch.Start();
                string    platformCode = getParame("platformCode").ToString();
                string    policyId     = getParame("policyId").ToString();
                string    operatorName = getParame("operatorName").ToString();
                string    source       = getParame("source").ToString();
                PolicyDto policyUI     = source != "back" ? (getParame("policy") as PolicyDto) : null;

                decimal TotlePaidPirce = 0m;
                OldOutOrderId = order.OutOrderId;
                string          innerPlatformCode = "系统";
                DataBill        databill          = new DataBill();
                DomesticService domesticService   = ObjectFactory.GetInstance <DomesticService>();
                UserRelation    userRealtion      = domesticService.GetUserRealtion(order.BusinessmanCode);
                bool            IspolicyIsNull    = false;

                if (policyUI != null)
                {
                    //赋值
                    order.Policy = PolicyDtoPolicy(policyUI, order.Policy, source);
                }
                else
                {
                    #region 原获取政策
                    PolicyParam policyParam = new PolicyParam();
                    policyParam.code              = order.BusinessmanCode;
                    policyParam.PnrContent        = order.PnrContent;
                    policyParam.OrderId           = order.OrderId;
                    policyParam.OrderType         = order.OrderType;
                    policyParam.OrderSource       = order.OrderSource;
                    policyParam.IsChangePnrTicket = order.IsChangePnrTicket;
                    policyParam.IsDestine         = order.OrderSource == EnumOrderSource.WhiteScreenDestine ? true : false;
                    Passenger pasData = order.Passengers.Where(p => p.PassengerType != EnumPassengerType.Baby).FirstOrDefault();
                    if (pasData != null)
                    {
                        policyParam.defFare   = pasData.SeatPrice.ToString();
                        policyParam.defTAX    = pasData.ABFee.ToString();
                        policyParam.defRQFare = pasData.RQFee.ToString();
                    }
                    if (order.Policy == null)
                    {
                        IspolicyIsNull = true;
                        order.Policy   = new Policy();
                    }
                    Policy         localPolicy   = null;
                    PlatformPolicy policy        = null;
                    PlatformOrder  platformOrder = null;
                    PolicyService  policyService = ObjectFactory.GetInstance <PolicyService>();
                    watch.Stop();
                    sbLog.AppendFormat("初始话变量时间:{0}\r\n", watch.Elapsed.ToString());
                    watch.Restart();

                    if (platformCode != innerPlatformCode)
                    {
                        PnrData pnrData = PnrHelper.GetPnrData(order.PnrContent);
                        policy = PlatformFactory.GetPlatformByCode(platformCode).GetPoliciesByPnrContent(order.PnrContent, order.IsLowPrice, pnrData).Find((p) => p.Id == policyId);
                        watch.Stop();
                        sbLog.AppendFormat("0.调用方法【GetPlatformByCode】用时:{0}\r\n", watch.Elapsed.ToString());
                        watch.Restart();

                        if (policy == null)
                        {
                            localPolicy = GetLocalPolicy(policyParam, policyId, innerPlatformCode, userRealtion, IspolicyIsNull, policyService, localPolicy);
                            watch.Stop();
                            sbLog.AppendFormat("1.调用方法【GetLocalPolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                            watch.Restart();
                            if (localPolicy != null)
                            {
                                order.Policy = localPolicy;
                            }
                            else
                            {
                                throw new OrderCommException("政策发生变动,请重新获取政策!!!");
                            }
                        }
                        else
                        {
                            SetInterface(platformCode, operatorName, source, ref TotlePaidPirce, policy, userRealtion, ref platformOrder, pnrData);
                            watch.Stop();
                            sbLog.AppendFormat("2.调用方法【SetInterface】用时:{0}\r\n", watch.Elapsed.ToString());
                            watch.Restart();
                        }
                    }
                    else
                    {
                        localPolicy = GetLocalPolicy(policyParam, policyId, innerPlatformCode, userRealtion, IspolicyIsNull, policyService, localPolicy);
                        watch.Stop();
                        sbLog.AppendFormat("3.调用方法【GetLocalPolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                        watch.Restart();
                        if (localPolicy == null)
                        {
                            PnrData pnrData = PnrHelper.GetPnrData(order.PnrContent);
                            localPolicy = policyService.GetInterfacePolicy(policyParam, "", userRealtion, pnrData).Find((p) => p.PolicyId == policyId);
                            watch.Stop();
                            sbLog.AppendFormat("4.调用方法【GetInterfacePolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                            watch.Restart();
                            if (localPolicy != null)
                            {
                                policy.AreaCity    = localPolicy.AreaCity;
                                policy.Id          = localPolicy.PolicyId;
                                policy.PolicyPoint = localPolicy.PolicyPoint;
                                if (source != "back")
                                {
                                    policy.PolicyPoint = localPolicy.PaidPoint;
                                }
                                policy.ReturnMoney      = localPolicy.ReturnMoney;
                                policy.IsLow            = localPolicy.IsLow;
                                policy.SeatPrice        = localPolicy.SeatPrice;
                                policy.ABFee            = localPolicy.ABFee;
                                policy.RQFee            = localPolicy.RQFee;
                                policy.Remark           = localPolicy.Remark;
                                policy.IsChangePNRCP    = localPolicy.IsChangePNRCP;
                                policy.IsSp             = localPolicy.IsSp;
                                policy.PolicyType       = localPolicy.PolicyType;
                                policy.WorkTime         = localPolicy.WorkTime;
                                policy.ReturnTicketTime = localPolicy.ReturnTicketTime;
                                policy.AnnulTicketTime  = localPolicy.AnnulTicketTime;
                                policy.CPOffice         = localPolicy.CPOffice;
                                policy.IssueSpeed       = localPolicy.IssueSpeed;
                                TotlePaidPirce          = platformOrder.TotlePaidPirce;

                                SetInterface(platformCode, operatorName, source, ref TotlePaidPirce, policy, userRealtion, ref platformOrder, pnrData);
                                watch.Stop();
                                sbLog.AppendFormat("5.调用方法【GetInterfacePolicy】用时:{0}\r\n", watch.Elapsed.ToString());
                                watch.Restart();
                            }
                            else
                            {
                                if (localPolicy == null)
                                {
                                    throw new OrderCommException("政策发生变动,请重新获取政策!");
                                }
                            }
                        }
                        else
                        {
                            //赋值
                            order.Policy = localPolicy;
                        }
                    }
                    #endregion
                }


                decimal _OrderMoney = 0m;
                if (source != "back")
                {
                    //扣点组类型
                    DeductionType deductionType = order.Policy.PolicySourceType == EnumPolicySourceType.Local ? DeductionType.Local : (order.Policy.PolicySourceType == EnumPolicySourceType.Share ? DeductionType.Share : DeductionType.Interface);
                    if (policyUI != null)
                    {
                        order.Policy.PolicyPoint = order.Policy.PaidPoint;
                    }
                    PlatformDeductionParam pfDp = new PlatformDeductionParam();
                    foreach (SkyWay leg in order.SkyWays)
                    {
                        pfDp.FlyLineList.Add(new FlyLine()
                        {
                            CarrayCode   = leg.CarrayCode,
                            FromCityCode = leg.FromCityCode,
                            ToCityCode   = leg.ToCityCode
                        });
                    }
                    //匹配扣点规则
                    domesticService.MatchDeductionRole(order.Policy, pfDp, order.SkyWays[0].CarrayCode, userRealtion.deductionGroup, userRealtion, deductionType);
                    watch.Stop();
                    sbLog.AppendFormat("6.调用方法【MatchDeductionRole】用时:{0}\r\n", watch.Elapsed.ToString());
                    watch.Restart();

                    //佣金
                    order.Policy.Commission = databill.GetCommission(order.Policy.PolicyPoint, order.Policy.SeatPrice, order.Policy.ReturnMoney);
                    //单人支付金额 根据选择的政策 设置价格
                    for (int i = 0; i < order.Passengers.Count; i++)
                    {
                        Passenger p = order.Passengers[i];
                        if (p.PassengerType != EnumPassengerType.Baby)
                        {
                            p.SeatPrice = order.Policy.SeatPrice;
                            p.ABFee     = order.Policy.ABFee;
                            p.RQFee     = order.Policy.RQFee;
                            p.PayMoney  = databill.GetPayPrice(order.Policy.SeatPrice, order.Policy.ABFee, order.Policy.RQFee, order.Policy.PolicyPoint, order.Policy.ReturnMoney);
                        }
                        else
                        {
                            p.PayMoney = databill.GetPayPrice(p.SeatPrice, p.ABFee, p.RQFee, 0, 0);
                        }
                    }
                    _OrderMoney = order.Passengers.Sum(p => p.PayMoney);
                    order.OrderCommissionTotalMoney = order.Passengers.Sum(p => p.PassengerType != EnumPassengerType.Baby ? databill.GetCommission(order.Policy.PolicyPoint, order.Policy.SeatPrice, order.Policy.ReturnMoney) : 0);
                }

                #region 支付信息
                if (order.OrderPay == null)
                {
                    order.OrderPay = new OrderPay();
                }

                order.OrderPay.OrderId   = order.OrderId;
                order.OrderPay.PaidMoney = TotlePaidPirce;
                if (source != "back")
                {
                    order.OrderPay.PayMoney  = _OrderMoney;
                    order.OrderMoney         = _OrderMoney;
                    order.OrderPay.PayStatus = EnumPayStatus.NoPay;
                }
                order.OrderPay.PaidStatus    = EnumPaidStatus.NoPaid;
                order.OrderPay.TradePoundage = 0m;
                order.OrderPay.SystemFee     = 0m;
                order.CpOffice = order.Policy.CPOffice;
                #endregion


                #region 根据政策扣点明细计算支付分润
                if (source != "back")
                {
                    domesticService.CreateBillDetails(order, userRealtion);
                    watch.Stop();
                    sbLog.AppendFormat("7.调用方法【CreateBillDetails】用时:{0}\r\n", watch.Elapsed.ToString());
                }
                #endregion
                order.WriteLog(new OrderLog()
                {
                    OperationContent  = string.Format("{0}选择政策,政策:{1},编号:{2},订单号:{3},出票速度:{4}", source, order.Policy.PolicyPoint, order.Policy.PolicyId, order.OrderId, order.Policy.IssueSpeed),
                    OperationDatetime = DateTime.Now,
                    OperationPerson   = operatorName,
                    IsShowLog         = false
                });

                order.WriteLog(new OrderLog()
                {
                    OperationContent  = string.Format("选择政策,订单号:{0},出票速度:{1}", order.OrderId, order.Policy.IssueSpeed),
                    OperationDatetime = DateTime.Now,
                    OperationPerson   = operatorName,
                    IsShowLog         = true
                });

                if (source == "back")
                {
                    //order.ChangeStatus(EnumOrderStatus.WaitAndPaid);
                    order.ChangeStatus(EnumOrderStatus.PayWaitCreatePlatformOrder);
                }
                else
                {
                    order.ChangeStatus(EnumOrderStatus.NewOrder);
                }
            }
            finally
            {
                if (sbLog.ToString() != "")
                {
                    new CommLog().WriteLog("NewSelectPolicyBehavior", sbLog.ToString());
                }
            }
            if (order.Policy.PolicySourceType == EnumPolicySourceType.Interface)
            {
                order.Policy.Code        = string.Empty;
                order.Policy.Name        = string.Empty;
                order.Policy.CashbagCode = string.Empty;
            }
            return(null);
        }
Esempio n. 5
0
        public Order CreateOrderByPnrContent(Order order, string pnrContent, EnumPnrImportType PnrImportType, CreateOrderParam OrderParam, string businessmanCode, string CarrierCode, string businessmanName, string account, bool IsChangePnrTicket)
        {
            #region 验证PNR
            if (pnrContent.ToUpper().Contains("NO PNR"))
            {
                pnrContent = pnrContent.ToUpper().Replace("NO PNR", "");
            }
            FormatPNR format = new FormatPNR();
            if (format.GetPnrContentByteLength(pnrContent) > 2000)
            {
                throw new PnrAnalysisFailException("RT和PAT内容长度超出范围[0-2000]个字符,请去掉多余的空格,再导入!");
            }
            if (pnrContent.Trim().Contains("授权"))
            {
                throw new PnrAnalysisFailException(pnrContent);
            }
            if (pnrContent.Trim().Contains("数据包不完整"))
            {
                throw new PnrAnalysisFailException(pnrContent);
            }


            string   Msg        = "";
            PnrModel pnrMode    = null;
            PatModel patMode    = null;
            PatModel infPatMode = null;
            string   Pnr        = string.Empty;
            PnrAnalysis.Model.SplitPnrCon splitPnrCon = null;
            //PNR内容导入
            if (OrderParam == null)
            {
                splitPnrCon = format.GetSplitPnrCon(pnrContent);
                string RTCon  = splitPnrCon.RTCon;
                string PatCon = splitPnrCon.AdultPATCon != string.Empty ? splitPnrCon.AdultPATCon : splitPnrCon.ChdPATCon;

                if (string.IsNullOrEmpty(PatCon) || string.IsNullOrEmpty(RTCon) || !PatCon.Contains("PAT:A"))
                {
                    throw new PnrAnalysisFailException("RT和PAT内容不能为空!");
                }
                //去重复和备注
                string pnrRemark = string.Empty;
                RTCon = format.DelRepeatRTCon(RTCon, ref pnrRemark);
                if (!string.IsNullOrEmpty(pnrRemark))
                {
                    PatCon = PatCon.Replace(pnrRemark, "");
                }
                pnrContent = RTCon + "\r\n" + PatCon;
                Pnr        = format.GetPNR(RTCon, out Msg);
                if (string.IsNullOrEmpty(Pnr) || !format.IsPnr(Pnr))
                {
                    throw new PnrAnalysisFailException("PNR内容提取编码失败,请检查编码内容!");
                }

                pnrMode = format.GetPNRInfo(Pnr, RTCon, false, out Msg);
                if (pnrMode == null || pnrMode._LegList.Count == 0)
                {
                    throw new PnrAnalysisFailException("PNR内容解析航段信息失败,请检查编码内容");
                }

                //成人或者儿童PAT
                patMode = format.GetPATInfo(PatCon, out Msg);

                if (PnrImportType == EnumPnrImportType.PnrContentImport)
                {
                    if (pnrMode._PasType == "2")
                    {
                        throw new PnrAnalysisFailException("该编码【" + Pnr + "】为儿童编码,请选择“儿童编码”通道导入!");
                    }
                }
                else if (PnrImportType == EnumPnrImportType.GenericPnrImport)
                {
                    if (pnrMode._PasType == "2")
                    {
                        throw new PnrAnalysisFailException("该编码【" + Pnr + "】为儿童编码,请选择“儿童编码”通道导入!");
                    }
                }
            }
            else
            {
                PnrData pnrData = OrderParam.pnrData;
                if (pnrData == null)
                {
                    if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                    {
                        throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:预定内容有误!");
                    }
                    else
                    {
                        throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:PNR内容解析失败!");
                    }
                }
                //订座失败,请重新预定!失败原因:预定内容有误!
                //导入失败,请重新导入!失败原因:[PnrData]PNR内容解析失败,PnrData Fail!

                pnrMode    = pnrData.PnrMode;
                patMode    = pnrData.PatMode;
                infPatMode = pnrData.InfPatMode;
                Pnr        = order.OrderType == 0 ? pnrData.AdultPnr : pnrData.ChdPnr;

                if (pnrMode == null || pnrMode._LegList.Count == 0)
                {
                    if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                    {
                        throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:预定航段内容有误!");
                    }
                    else
                    {
                        throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:解析编码航段内容有误!");
                    }
                }

                //订座失败,请重新预定!失败原因:预定航段内容有误!
                //导入失败,请重新导入!失败原因:解析编码航段内容有误!
            }

            if (!pnrMode.PnrConIsOver)
            {
                if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                {
                    throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:预定内容有误!");
                }
                else
                {
                    throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:编码内容信息有误,RT编码内容需以Office号结尾,请检查编码内容!");
                }
            }

            //订座失败,请重新预定!失败原因:预定内容有误!
            //导入失败,请重新导入!失败原因:编码内容信息有误,RT编码内容需以Office号结尾,请检查编码内容!

            if (pnrMode.PnrStatus.Trim() == "")
            {
                if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                {
                    throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:解析出编码状态有误!");
                }
                else
                {
                    throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:解析出编码状态有误,请检查编码内容!");
                }
            }
            //订座失败,请重新预定!失败原因:解析出编码状态有误!
            //导入失败,请重新导入!失败原因:解析出编码状态有误,请检查编码内容


            if (pnrMode.PnrStatus.Contains("XX") ||
                pnrMode.PnrStatus.Contains("NO") ||
                pnrMode.PnrStatus.Contains("HL") ||
                pnrMode.PnrStatus.Contains("HN")
                )
            {
                if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                {
                    throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:编码状态有误,状态为:" + pnrMode.PnrStatus + "!");
                }
                else
                {
                    throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:编码状态有误,状态为XX,NO,HL,HN项不能导入!");
                }

                //订座失败,请重新预定!失败原因:编码状态有误,状态为:“+pnrMode.PnrStatus+”!
                //导入失败,请重新导入!失败原因:编码状态有误,状态为XX,NO,HL,HN项不能导入!
            }
            else if (!pnrMode.PassengerNameIsCorrent && pnrMode.ErrorPassengerNameList.Count > 0)//乘机人名字检查
            {
                if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                {
                    throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!");
                }
                else
                {
                    throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!");
                }
            }
            //订座失败,请重新预定!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!");
            //导入失败,请重新导入!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!");

            else if (!pnrMode.PnrConHasFirstNum)//乘客姓名序号是否已1开始
            {
                if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                {
                    throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容!");
                }
                else
                {
                    throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容!");
                }
            }
            //订座失败,请重新预定!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容!
            //导入失败,请重新导入!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容!


            //else if (string.IsNullOrEmpty(pnrMode._BigPnr))
            //    throw new PnrAnalysisFailException("编码[" + Pnr + "]PNR内容中没有大编码,请补齐大编码后导入!");
            //else if (pnrMode.HasExistNoSsr)
            //    throw new PnrAnalysisFailException("编码内容中乘客证件号不全,请补全证件号!");
            //else if (pnrMode.SsrIsRepeat)
            //    throw new PnrAnalysisFailException("编码内容中乘客证件号重复,请检查PNR内容证件号!");
            else if (pnrMode.TravelType > 3)
            {
                if (PnrImportType == EnumPnrImportType.WhiteScreenDestine)
                {
                    throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:系统暂不支持缺口程和多程航段!");
                }
                else
                {
                    throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:系统暂不支持缺口程和多程航段!");
                }
            }
            //订座失败,请重新预定!失败原因:系统暂不支持缺口程和多程航段!
            //导入失败,请重新导入!失败原因:系统暂不支持缺口程和多程航段!


            //JD导入 验证
            if (pnrMode._CarryCode.ToUpper().Contains("JD"))
            {
                bool JDIsPass = true;
                //编码中成人 儿童 婴儿 个数
                int adultNum = 0, childNum = 0, YNum = 0;
                foreach (PassengerInfo item in pnrMode._PassengerList)
                {
                    if (item.PassengerType == "1")
                    {
                        adultNum++;
                    }
                    if (item.PassengerType == "2")
                    {
                        childNum++;
                    }
                    if (item.PassengerType == "3")
                    {
                        YNum++;
                    }
                }
                bool b1 = adultNum == 1 && childNum == 0 && YNum == 0;
                bool b2 = adultNum == 0 && childNum == 1 && YNum == 0;
                bool b3 = adultNum == 1 && childNum == 1 && YNum == 0;
                bool b4 = adultNum == 1 && childNum == 1 && YNum == 1;
                bool b5 = adultNum == 1 && childNum == 0 && YNum == 1;
                if (!(b1 || b2 || b3 || b4 || b5))
                {
                    JDIsPass = false;
                }
                if (!JDIsPass)
                {
                    throw new PnrAnalysisFailException("JD航空编码【" + Pnr + "】中只能有一个成人,一个儿童,一个婴儿,请手动处理编码内容!");
                }
            }
            decimal TicketPrice = 0m, INFTicketPrice = 0m;
            decimal SeatPrice = 0m, TaxFare = 0m, RQFare = 0m;
            decimal INFSeatPrice = 0m, INFTaxFare = 0m, INFRQFare = 0m;


            if (patMode == null || patMode.UninuePatList.Count == 0)
            {
                throw new PnrAnalysisFailException("PAT解析价格失败");
            }
            if (patMode.IsOverMaxPrice)
            {
                throw new PnrAnalysisFailException("PAT支付价格超出范围!");
            }
            //默认取低价
            PatInfo pat = order.IsLowPrice ? patMode.UninuePatList[0] : patMode.UninuePatList[patMode.UninuePatList.Count - 1];
            decimal.TryParse(pat.Price, out TicketPrice);
            decimal.TryParse(pat.Fare, out SeatPrice);
            decimal.TryParse(pat.TAX, out TaxFare);
            decimal.TryParse(pat.RQFare, out RQFare);
            if (SeatPrice <= 0)
            {
                throw new PnrAnalysisFailException("舱位价不能小于等于0");
            }
            if (TicketPrice <= 0)
            {
                throw new PnrAnalysisFailException("PAT总价不能小于等于0");
            }

            //PNR内容导入
            if (OrderParam == null)
            {
                if (pnrMode.HasINF && !string.IsNullOrEmpty(splitPnrCon.INFPATCon.Trim())) //如果有婴儿
                {
                    if (string.IsNullOrEmpty(splitPnrCon.INFPATCon) || !splitPnrCon.INFPATCon.Contains("PAT:A*IN"))
                    {
                        throw new PnrAnalysisFailException("编码中含有婴儿,为获取到婴儿的PAT价格信息!");
                    }

                    infPatMode = format.GetPATInfo(splitPnrCon.INFPATCon, out Msg);
                    if (infPatMode == null || infPatMode.UninuePatList.Count == 0)
                    {
                        throw new PnrAnalysisFailException("婴儿PAT解析价格失败");
                    }
                    //默认取低价
                    PatInfo patInf = order.IsLowPrice ? infPatMode.UninuePatList[0] : infPatMode.UninuePatList[infPatMode.UninuePatList.Count - 1];
                    decimal.TryParse(patInf.Price, out INFTicketPrice);
                    decimal.TryParse(patInf.Fare, out INFSeatPrice);
                    decimal.TryParse(patInf.TAX, out INFTaxFare);
                    decimal.TryParse(patInf.RQFare, out INFRQFare);
                    if (INFTicketPrice <= 0)
                    {
                        throw new PnrAnalysisFailException("婴儿舱位价不能小于等于0");
                    }
                    if (INFTicketPrice <= 0)
                    {
                        throw new PnrAnalysisFailException("婴儿PAT总价不能小于等于0");
                    }

                    pnrContent = pnrContent + "\r\n" + splitPnrCon.INFPATCon;
                }
            }
            else
            {
                if (pnrMode != null && pnrMode.HasINF && infPatMode != null) //如果有婴儿
                {
                    if (infPatMode == null || infPatMode.UninuePatList.Count == 0)
                    {
                        throw new PnrAnalysisFailException("婴儿PAT解析价格失败");
                    }
                    //默认取低价
                    PatInfo patInf = order.IsLowPrice ? infPatMode.UninuePatList[0] : infPatMode.UninuePatList[infPatMode.UninuePatList.Count - 1];
                    decimal.TryParse(patInf.Price, out INFTicketPrice);
                    decimal.TryParse(patInf.Fare, out INFSeatPrice);
                    decimal.TryParse(patInf.TAX, out INFTaxFare);
                    decimal.TryParse(patInf.RQFare, out INFRQFare);
                    if (INFTicketPrice <= 0)
                    {
                        throw new PnrAnalysisFailException("婴儿舱位价不能小于等于0");
                    }
                    if (INFTicketPrice <= 0)
                    {
                        throw new PnrAnalysisFailException("婴儿PAT总价不能小于等于0");
                    }
                }
            }

            if (TicketPrice <= 0)
            {
                throw new PnrAnalysisFailException("票面总价不能小于等于0");
            }

            #endregion

            //构造数据
            double FlyAdvanceTime = 1;// SettingSection.GetInstances().Cashbag.FlyAdvanceTime;
            double.TryParse(System.Configuration.ConfigurationManager.AppSettings["FlyAdvanceTime"].ToString(), out FlyAdvanceTime);
            order.PnrCode         = Pnr;
            order.BigCode         = pnrMode._BigPnr;
            order.OrderType       = pnrMode._PasType == "1" ? 0 : 1;
            order.PnrType         = pnrMode._PnrType == "1" ? 0 : 1;
            order.Remark          = "";
            order.TicketPrice     = TicketPrice;
            order.INFTicketPrice  = INFTicketPrice;
            order.BusinessmanCode = businessmanCode;
            order.BusinessmanName = businessmanName;
            order.CarrierCode     = CarrierCode;
            order.OperatorAccount = account;
            order.CreateTime      = DateTime.Now;
            order.PnrContent      = pnrContent;
            order.HasAfterSale    = false;
            order.YdOffice        = pnrMode._Office;
            decimal          defaultOrderMoney = 0m;
            bool             HaveBabyFlag      = false;
            List <SkyWay>    SkyWays           = new List <SkyWay>();
            List <Passenger> Passengers        = new List <Passenger>();
            if (OrderParam == null)
            {
                DateTime tempStartTime = System.DateTime.Now;
                string   Seat          = string.Empty;
                //内容导入
                foreach (var leg in pnrMode._LegList)
                {
                    Seat = leg.Seat;
                    //如果有子舱位就用子舱位
                    if (!string.IsNullOrEmpty(leg.ChildSeat) && leg.ChildSeat.Trim().Length == 2)
                    {
                        Seat = leg.ChildSeat.Trim();
                    }
                    SkyWays.Add(new SkyWay()
                    {
                        FromCityCode  = leg.FromCode,
                        ToCityCode    = leg.ToCode,
                        FlightNumber  = leg.FlightNum,
                        StartDateTime = DateTime.Parse(leg.FlyDate1 + " " + leg.FlyStartTime.Insert(2, ":") + ":00"),
                        ToDateTime    = DateTime.Parse(leg.FlyDateE + " " + leg.FlyEndTime.Insert(2, ":") + ":00"),
                        CarrayCode    = leg.AirCode,
                        Seat          = Seat,
                        FromTerminal  = getHZL(leg.FromCode, leg.AirCode, leg.FromCityT1),
                        ToTerminal    = getHZL(leg.ToCode, leg.AirCode, leg.ToCityT2),
                        Discount      = baseQuery.GetZK(leg.FromCode, leg.ToCode, leg.AirCode, leg.Seat, SeatPrice)
                    });
                }
                tempStartTime = SkyWays[0].StartDateTime.AddHours(-FlyAdvanceTime);
                if (DateTime.Compare(tempStartTime, System.DateTime.Now) <= 0)
                {
                    //起飞时间小于预定时间  已起飞 已失效 不能导入
                    throw new PnrAnalysisFailException("航班起飞前" + FlyAdvanceTime + "小时内不能导入编码内容!");
                }
                foreach (var pas in pnrMode._PassengerList)
                {
                    if (pas.PassengerType == "3")
                    {
                        Passengers.Add(new Passenger()
                        {
                            PassengerName = pas.PassengerName,
                            CardNo        = pas.SsrCardID,
                            SeatPrice     = INFSeatPrice,
                            ABFee         = INFTaxFare,
                            RQFee         = INFRQFare,
                            PassengerType = EnumPassengerType.Baby,
                            TicketStatus  = EnumTicketStatus.Unknown,
                            Mobile        = pas.PassengerTel,
                        });
                        defaultOrderMoney += INFSeatPrice + INFTaxFare + INFRQFare;
                        HaveBabyFlag       = true;
                    }
                    else
                    {
                        Passengers.Add(new Passenger()
                        {
                            PassengerName = pas.PassengerName,
                            CardNo        = pas.SsrCardID,
                            SeatPrice     = SeatPrice,
                            ABFee         = TaxFare,
                            RQFee         = RQFare,
                            PassengerType = (EnumPassengerType)pas.PassengerType.ToInt(),
                            TicketStatus  = EnumTicketStatus.Unknown,
                            Mobile        = pas.PassengerTel
                        });
                        defaultOrderMoney += SeatPrice + TaxFare + RQFare;
                    }
                }
            }
            else
            {
                //是否儿童订单
                bool IsChdOrder = false;
                foreach (PassengerDto pas in OrderParam.PassengerDtos)
                {
                    if (pas.PassengerType == EnumPassengerType.Baby)
                    {
                        Passengers.Add(new Passenger()
                        {
                            PassengerName = pas.PassengerName,
                            CardNo        = pas.CardNo,
                            SeatPrice     = INFSeatPrice,
                            ABFee         = INFTaxFare,
                            RQFee         = INFRQFare,
                            PassengerType = EnumPassengerType.Baby,
                            TicketStatus  = EnumTicketStatus.Unknown,
                            Mobile        = pas.Mobile,
                            IdType        = pas.IdType,
                            SexType       = pas.SexType,
                            Birth         = pas.Birth
                        });
                        defaultOrderMoney += INFSeatPrice + INFTaxFare + INFRQFare;
                        HaveBabyFlag       = true;
                    }
                    else
                    {
                        IsChdOrder = pas.PassengerType == EnumPassengerType.Child ? true : false;
                        Passengers.Add(new Passenger()
                        {
                            PassengerName = pas.PassengerName,
                            CardNo        = pas.CardNo,
                            SeatPrice     = SeatPrice,
                            ABFee         = TaxFare,
                            RQFee         = RQFare,
                            PassengerType = pas.PassengerType,
                            TicketStatus  = EnumTicketStatus.Unknown,
                            Mobile        = pas.Mobile,
                            IdType        = pas.IdType,
                            SexType       = pas.SexType,
                            Birth         = pas.Birth
                        });
                        defaultOrderMoney += SeatPrice + TaxFare + RQFare;
                    }
                }

                List <LegInfo> legInfo = pnrMode._LegList;
                //白屏预定
                int i = 0;
                foreach (SkyWayDto leg in OrderParam.SkyWayDtos)
                {
                    string strSeat = leg.Seat;
                    //处理儿童的舱位问题
                    if (IsChdOrder)
                    {
                        if (!"FCY".Contains(leg.Seat.ToUpper()))
                        {
                            if (legInfo[0].Seat.Trim().ToUpper() != leg.Seat.Trim().ToUpper())
                            {
                                strSeat = "Y";
                            }
                        }
                    }
                    else
                    {
                        //如果有子舱位就用子舱位
                        if (legInfo.Count > i && !string.IsNullOrEmpty(legInfo[i].ChildSeat) && legInfo[i].ChildSeat.Trim().Length == 2)
                        {
                            strSeat = legInfo[i].ChildSeat.Trim();
                        }
                    }
                    SkyWays.Add(new SkyWay()
                    {
                        FromCityCode  = leg.FromCityCode,
                        ToCityCode    = leg.ToCityCode,
                        FlightNumber  = leg.FlightNumber,
                        StartDateTime = leg.StartDateTime,
                        ToDateTime    = leg.ToDateTime,
                        CarrayCode    = leg.CarrayCode,
                        Seat          = strSeat,
                        FromTerminal  = leg.FromTerminal,
                        ToTerminal    = leg.ToTerminal,
                        Discount      = leg.Discount,
                        FlightModel   = leg.FlightModel
                    });
                    i++;
                }
            }
            order.SkyWays      = SkyWays;
            order.Passengers   = Passengers;
            order.OrderMoney   = defaultOrderMoney;
            order.HaveBabyFlag = HaveBabyFlag;
            //是否换编码出票
            order.IsChangePnrTicket = IsChangePnrTicket;
            //order.Policy = new Policy();
            order.OrderPay = new OrderPay()
            {
                PaidStatus = EnumPaidStatus.NoPaid,
                PayStatus  = EnumPayStatus.NoPay,
                OrderId    = order.OrderId
            };
            order.ChangeStatus(EnumOrderStatus.WaitChoosePolicy);
            //订单日志
            order.WriteLog(new OrderLog()
            {
                OperationDatetime = System.DateTime.Now,
                OperationPerson   = account,
                Remark            = "",
                OperationContent  = "生成订单",
                IsShowLog         = true
            });
            return(order);
        }
Esempio n. 6
0
        public static List <PlatformPolicy> GetPoliciesByPnrContent(string pnrContent, bool IsLowPrice, PnrData pnrData)
        {
            List <PlatformPolicy> lst = new List <PlatformPolicy>();
            var           plst        = ObjectFactory.GetAllInstances <IPlatform>().Where(p => p.IsClosed == false);
            StringBuilder sbLog       = new StringBuilder();

            sbLog.Append("查询政策开始:=============================\r\n");
            sbLog.AppendFormat("时间:{0}", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            if (pnrData.PnrMode != null && pnrData.PnrMode._LegList.Count > 0)
            {
                Parallel.ForEach(plst, p =>
                {
                    System.Diagnostics.Stopwatch swch        = new System.Diagnostics.Stopwatch();
                    List <PlatformPolicy> listPlatformPolicy = new List <PlatformPolicy>();
                    try
                    {
                        swch.Start();
                        listPlatformPolicy = p.GetPoliciesByPnrContent(pnrContent, IsLowPrice, pnrData);
                        lst.AddRange(listPlatformPolicy);
                    }
                    catch
                    {
                        Logger.WriteLog(LogType.WARN, "取" + p.GetPlatformName() + "接口政策失败");
                    }
                    finally
                    {
                        swch.Stop();
                        string strTime = swch.Elapsed.ToString();
                        sbLog.AppendFormat("[{0}]平台:{1} 查询政策用时:{2} \r\n", listPlatformPolicy.Count, p.Code, strTime);
                    }
                });
            }
            else
            {
                sbLog.AppendFormat("编码内容解析失败:PnrContent={0}\r\n", pnrContent);
            }
            sbLog.Append("查询政策结束:=============================\r\n");
            Logger.WriteLog(LogType.INFO, sbLog.ToString());
            return(lst);
        }