示例#1
0
        /// <summary>
        ///  记录订单日志
        /// </summary>
        /// <param name="OrderId">订单号</param>
        /// <param name="LogContent">订单日志内容</param>
        /// <param name="LogType">日志类型 1支付宝 2汇付</param>
        /// <returns></returns>
        public bool OrderLog(string OrderId, string LogContent, ListParam LP, string LogType)
        {
            bool Issuc = false;

            try
            {
                LogContent = LogContent.Replace("自动出票启动!", "");
                PbProject.Model.Log_Tb_AirOrder m_OrderLog = new PbProject.Model.Log_Tb_AirOrder();
                m_OrderLog.id            = Guid.NewGuid();
                m_OrderLog.OrderId       = OrderId;
                m_OrderLog.OperType      = "修改";
                m_OrderLog.OperTime      = DateTime.Now;
                m_OrderLog.OperContent   = LogContent;
                m_OrderLog.OperLoginName = LP != null ? LP.UninAllName : "系统管理员";
                m_OrderLog.OperUserName  = LP != null ? LP.UserName : "******";
                m_OrderLog.WatchType     = 2;
                string tempSql = PbProject.Dal.Mapping.MappingHelper <PbProject.Model.Log_Tb_AirOrder> .CreateInsertModelSql(m_OrderLog);

                Issuc = Manage.ExecuteNonQuerySQLInfo(tempSql);
            }
            catch (Exception ex)
            {
                if (LogType == "1")
                {
                    //记录日志
                    PnrAnalysis.LogText.LogWrite(ex.Message + "\r\r", "Alipay_OrderLogErr");
                }
                else if (LogType == "2")
                {
                    //记录日志
                    PnrAnalysis.LogText.LogWrite(ex.Message + "\r\r", "China_OrderLogErr");
                }
            }
            return(Issuc);
        }
示例#2
0
        /// <summary>
        /// 指令记录到数据库
        /// </summary>
        /// <param name="PM"></param>
        /// <param name="TicketLP"></param>
        /// <returns></returns>
        public string WriteLogDB(ParamObject PM, ListParam TicketLP)
        {
            string         Recvdata = "";
            Tb_SendInsData sendins  = new Tb_SendInsData();

            try
            {
                sendins.SendTime = System.DateTime.Now;
                Recvdata         = SendNewPID.SendCommand(PM);
                sendins.RecvTime = System.DateTime.Now;
            }
            catch (Exception ex)
            {
            }
            finally
            {
                try
                {
                    //指令记入数据库
                    sendins.SendIns         = PM.code;
                    sendins.RecvData        = Recvdata;
                    sendins.SendInsType     = 18;
                    sendins.Office          = PM.Office;
                    sendins.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                    sendins.UserAccount     = "BSP";
                    sendins.CpyNo           = TicketLP.CpyNo;
                    //插入数据库
                    Manage.ExecuteNonQuerySQLInfo(PbProject.Dal.Mapping.MappingHelper <Tb_SendInsData> .CreateInsertModelSql(sendins, new List <string>()
                    {
                        "id"
                    }));
                }
                catch (Exception)
                {
                }
            }
            return(Recvdata);
        }
示例#3
0
        /// <summary>
        /// 返回数据
        /// </summary>
        /// <param name="fromcity">起飞城市三字码</param>
        /// <param name="tocity">抵达城市三字码</param>
        /// <param name="totime">起飞时间</param>
        /// <param name="arrtime">抵达时间</param>
        /// <param name="starttime">起飞日期</param>
        /// <param name="cw">舱位</param>
        /// <param name="aircode">航空公司</param>
        /// <param name="aircono">航班号</param>
        /// <param name="fd">返点</param>
        /// <param name="strYh">现返</param>
        /// <param name="hidId">GUID</param>
        /// <param name="Fare">固定特价</param>
        /// <param name="TAX">基建</param>
        /// <param name="RQFare">燃油</param>
        /// <param name="isGuding">是否固定特价</param>
        /// <param name="Yprice">是否固定特价</param>
        private SpecialPrice PlyMatch(UserLoginInfo userInfo, string fromcity, string tocity, string totime, string arrtime, string starttime,
                                      string cw, string aircode, string aircono, string fd, string strYh, string hidId,
                                      string Fare, string TAX, string RQFare, bool isGuding, string Yprice
                                      )
        {
            SpecialPrice sp = new SpecialPrice();

            try
            {
                string[] strValue = new string[4];
                //非固定特价PATA数据
                if (!isGuding)
                {
                    #region pat 数据
                    // ig|SS MU747/X/30NOV/KMGSHANN1/0730 1025|pat:a&kmg226#1
                    //发送指令获取
                    DateTime dt      = DateTime.Parse(starttime);
                    string   cmd     = "SS " + aircode + aircono + "/" + cw + "/" + dt.ToString("R").Substring(4, 7).Replace(" ", "") + dt.Year.ToString().Substring(2) + "/" + fromcity + tocity + "NN1/" + totime.Replace(":", "") + " " + arrtime.Replace(":", "") + "|pat:a";
                    string   zhiling = cmd;
                    string   strVale = string.Empty;
                    //---------修改部分----------
                    if (userInfo.Configparam != null)
                    {
                        //开启使用特价缓存  true 开启 false关闭
                        bool IsUseSpCache = userInfo.FQP.KongZhiXiTong != null && userInfo.FQP.KongZhiXiTong.Contains("|99|");
                        //特价缓存
                        SpecialCabinPriceInfoBLL  SpBll     = new SpecialCabinPriceInfoBLL();
                        Tb_SpecialCabin_PriceInfo PriceInfo = null;
                        if (IsUseSpCache)
                        {
                            SpBll.GetSpPrice(aircode, aircono, DateTime.Parse(starttime + " " + totime + ":00"), fromcity, tocity, cw);
                        }
                        if (PriceInfo == null)
                        {
                            //格式化编码内容类
                            PnrAnalysis.FormatPNR pnrformat = new PnrAnalysis.FormatPNR();
                            //扩展参数
                            ParamEx pe = new ParamEx();
                            pe.UsePIDChannel = userInfo.FQP.KongZhiXiTong != null && userInfo.FQP.KongZhiXiTong.Contains("|48|") ? 2 : 0;
                            SendInsManage SendManage = new SendInsManage(userInfo.User.LoginName, userInfo.Company.UninCode, pe, userInfo.Configparam);
                            string        Office     = userInfo.Configparam.Office.Split('^')[0];
                            strVale = SendManage.Send(cmd, ref Office, 15);//发送获取特价指令
                            string  error = "";
                            decimal spFare = 0m, spABFare = 0m, spRQFare = 0m;
                            //价格实体
                            PnrAnalysis.PatModel Pat = pnrformat.GetPATInfo(strVale, out error);
                            if (Pat != null && Pat.UninuePatList.Count > 0)
                            {
                                strValue[0] = Pat.UninuePatList[0].Fare;   //舱位价
                                strValue[1] = Pat.UninuePatList[0].TAX;    //基建
                                strValue[2] = Pat.UninuePatList[0].RQFare; //燃油
                                strValue[3] = Pat.UninuePatList[0].Price;  //总计(舱位价+基建+燃油)
                                decimal.TryParse(strValue[0], out spFare);
                                decimal.TryParse(strValue[1], out spABFare);
                                decimal.TryParse(strValue[2], out spRQFare);
                            }
                            else
                            {
                                //-----------------2013-5-6添加----------------------------------------------
                                //没有PAT出价格 预订一个编码PAT价格后取消PNR 即使编码没有取消 后台程序自动取消
                                string ErrMsg = "";
                                if (ConfigIsSet(out ErrMsg))
                                {
                                    //----------构造航段和乘客---------------
                                    List <Tb_Ticket_Passenger> pList      = GetPassengerList();
                                    List <Tb_Ticket_SkyWay>    skywaylist = new List <Tb_Ticket_SkyWay>();
                                    Tb_Ticket_SkyWay           sky        = new Tb_Ticket_SkyWay();
                                    sky.CarryCode    = aircode;
                                    sky.FlightCode   = aircono;
                                    sky.FromDate     = DateTime.Parse(starttime + " " + totime + ":00");
                                    sky.ToDate       = DateTime.Parse(starttime + " " + arrtime + ":00");
                                    sky.FromCityCode = fromcity;
                                    sky.ToCityCode   = tocity;
                                    sky.Space        = cw;
                                    skywaylist.Add(sky);

                                    //-------------------------
                                    //预订编码 获取价格
                                    RePnrObj pnrObj      = GetPnrInfo(aircode, pList, skywaylist, out ErrMsg);
                                    string   AdultPnr    = string.Empty;
                                    Log_Pnr  logAdultPnr = null;
                                    //成人预订信息编码记录
                                    if (pnrObj.AdultYudingList.Count > 0)
                                    {
                                        AdultPnr = pnrObj.AdultPnr;
                                        if (string.IsNullOrEmpty(AdultPnr) || AdultPnr.Trim().Length != 6)
                                        {
                                            AdultPnr = "";
                                        }
                                        //记录编码日志
                                        YuDingPnrLog(pnrObj, pnrObj.AdultYudingList.Keys[0], pnrObj.AdultYudingList.Values[0], AdultPnr, pnrObj.Office, out logAdultPnr);
                                    }
                                    if (!string.IsNullOrEmpty(pnrObj.AdultPnr))
                                    {
                                        //取消编码
                                        if (SendManage.CancelPnr(pnrObj.AdultPnr, pnrObj.Office))
                                        {
                                            if (logAdultPnr != null)
                                            {
                                                //修改状态
                                                logAdultPnr.Flag = true;
                                                string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(logAdultPnr, "id");

                                                Manage.ExecuteNonQuerySQLInfo(tempSql);
                                            }
                                        }
                                    }
                                    //获取价格
                                    if (pnrObj.PatModelList != null && pnrObj.PatModelList.Length > 0)
                                    {
                                        Pat = pnrObj.PatModelList[0];
                                        if (Pat != null && Pat.UninuePatList.Count > 0)
                                        {
                                            strValue[0] = Pat.UninuePatList[0].Fare;   //舱位价
                                            strValue[1] = Pat.UninuePatList[0].TAX;    //基建
                                            strValue[2] = Pat.UninuePatList[0].RQFare; //燃油
                                            strValue[3] = Pat.UninuePatList[0].Price;  //总计(舱位价+基建+燃油)
                                            decimal.TryParse(strValue[0], out spFare);
                                            decimal.TryParse(strValue[1], out spABFare);
                                            decimal.TryParse(strValue[2], out spRQFare);
                                        }
                                    }
                                }
                                //---------------------------------------------------------------
                            }
                            if (spFare != 0m)
                            {
                                //存入缓存
                                SpBll.SaveSpPrice(aircode.ToUpper(), aircono, DateTime.Parse(starttime + " " + totime + ":00"), fromcity, tocity, cw, spFare, spABFare, spRQFare);
                            }
                        }
                        else
                        {
                            strValue[0] = PriceInfo.SpPrice.ToString();  //舱位价
                            strValue[1] = PriceInfo.SpABFare.ToString(); //基建
                            strValue[2] = PriceInfo.SpRQFare.ToString(); //燃油
                            strValue[3] = (PriceInfo.SpPrice + PriceInfo.SpABFare + PriceInfo.SpRQFare).ToString();
                        }
                    }
                    #endregion
                }
                else
                {
                    strValue[0] = Fare;   //舱位价
                    strValue[1] = TAX;    //基建
                    strValue[2] = RQFare; //燃油
                    strValue[3] = (decimal.Parse(Fare) + decimal.Parse(TAX) + decimal.Parse(RQFare)).ToString();
                }

                //实付金额
                string sjvalue = new PbProject.Logic.Pay.Data(userInfo.Company.UninCode).CreatePassengerPayFee(decimal.Parse(strValue[0]), decimal.Parse(strValue[1]), decimal.Parse(strValue[2]), decimal.Parse(fd), decimal.Parse(strYh), 1).ToString();
                string pyj     = new PbProject.Logic.Pay.Data(userInfo.Company.UninCode).CreateCommissionCG(decimal.Parse(strValue[0]), decimal.Parse(fd)).ToString();

                string ZK = "";
                if (Yprice != "0")//如果传的有Y舱价格,则是特价类型的,则计算折扣
                {
                    PbProject.Logic.Pay.DataAction plpd = new PbProject.Logic.Pay.DataAction();
                    //特价时候需要计算折扣,让前台计算加入哪一个折扣范围
                    decimal tempFare = 0;
                    decimal.TryParse(strValue[0], out tempFare);
                    decimal tempYprice = 0;
                    decimal.TryParse(Yprice, out tempYprice);
                    //计算特价的折扣
                    ZK = (new PbProject.Logic.Pay.DataAction().FourToFiveNum((tempFare / tempYprice), 4) * 100).ToString("f2");
                    decimal tempZK = 0;
                    decimal.TryParse(ZK, out tempZK);
                    ZK = plpd.FourToFiveNum(tempZK, 0).ToString();
                }


                if (strValue[0] != "" || strValue[1] != "" || strValue[2] != "" || strValue[3] != "")
                {
                    decimal tempPrice = 0;
                    decimal.TryParse(strValue[0], out tempPrice);


                    #region  pat 有数据
                    sp.SpacePrice   = tempPrice.ToString("f0");
                    sp.Tax          = strValue[1];
                    sp.RQFare       = strValue[2];
                    sp.TotalPrice   = strValue[3];
                    sp.RealPayPrice = sjvalue;
                    sp.Commission   = pyj;
                    sp.GUID         = hidId;
                    sp.Discount     = ZK;
                    #endregion
                }
                else
                {
                    #region pat 没有数据

                    #endregion pat 出来没有数据
                }

                //最终sb格式 0舱位价@1基建@2燃油@3总计(舱位价+基建+燃油)@4实付金额@5佣金@6guid@7特价计算的折扣
                return(sp);
                //Response.Write("");
            }
            catch (Exception ex)
            {
                return(sp);
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //string result = "<?xml version=\"1.0\" encoding=\"gb2312\" ?><orderinfo><pnr>HF5N1R</pnr><code>1</code><message /><orderno></orderno><orderstatus>1</orderstatus><paystatus>1</paystatus><pnrsrcid>0101912051714341204</pnrsrcid ><payprice>543.6</ payprice><tradeno>2012051773929436</tradeno><tickets><ticket><passenger>张平</passenger><tktno>876-2037972475</tktno></ticket></tickets></orderinfo>";
        //System.Threading.Thread.Sleep(50000);
        OnErrorNew("进入 Pay_AutoPayByAlipayNotifyUrl_Load()", true);

        try
        {
            if (Request.Form["ticketnoinfo"] != null && Request.Form["ticketnoinfo"].ToString() != "")
            {
                string ticketnoinfo = Request.Form["ticketnoinfo"].ToString();
                ticketnoinfo = HttpUtility.UrlDecode(ticketnoinfo, Encoding.GetEncoding("gb2312"));

                OnErrorNew("ticketnoinfo内容:" + ticketnoinfo, false);
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(ticketnoinfo);
                DataSet      ds  = new DataSet();
                StringReader rea = new StringReader(doc.InnerXml);

                XmlTextReader xmlReader = new XmlTextReader(rea);

                ds.ReadXml(xmlReader);
                PbProject.Model.Tb_Ticket_Order Order = new PbProject.Logic.Order.Tb_Ticket_OrderBLL().GetTicketOrderByOrderId(ds.Tables[0].Rows[0]["pnrsrcid"].ToString());
                //Login(Order);
                if (ticketnoinfo.IndexOf("支付成功后,取票号失败,请您手工操作") > -1)
                {
                    #region 记录操作日志
                    //添加操作订单的内容
                    PbProject.Model.Log_Tb_AirOrder OrderLog = new PbProject.Model.Log_Tb_AirOrder();

                    OrderLog.id          = Guid.NewGuid();
                    OrderLog.OrderId     = Order.OrderId;
                    OrderLog.OperType    = "修改";
                    OrderLog.OperTime    = DateTime.Now;
                    OrderLog.OperContent = "于 " + DateTime.Now + " 航空公司已出票,自动取票号失败,请您手工出票!";
                    OrderLog.WatchType   = 2;
                    string tempSql = PbProject.Dal.Mapping.MappingHelper <PbProject.Model.Log_Tb_AirOrder> .CreateInsertModelSql(OrderLog);

                    #endregion
                    OnErrorNew("支付成功后,取票号失败,请您手工操作!", false);
                    return;
                }
                if (Order.OrderStatusCode == 4)
                {
                    OnErrorNew("该票号已经出票", false);
                    return;
                }

                int tcount = 0;
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    PbProject.Logic.Order.Tb_Ticket_PassengerBLL psb     = new PbProject.Logic.Order.Tb_Ticket_PassengerBLL();
                    List <PbProject.Model.Tb_Ticket_Passenger>   psmList = psb.GetPasListByOrderID(ds.Tables[0].Rows[0]["pnrsrcid"].ToString());
                    OnErrorNew("开始修改票号", false);
                    for (int i = 0; i < psmList.Count; i++)
                    {
                        for (int j = 0; j < ds.Tables[2].Rows.Count; j++)
                        {
                            if (ds.Tables[2].Rows[j]["tktno"].ToString() != "")
                            {
                                if (psmList[i].PassengerName.ToUpper() == ds.Tables[2].Rows[j]["passenger"].ToString().ToUpper() || psmList[i].PassengerName.ToUpper() == HttpUtility.UrlDecode(ds.Tables[2].Rows[j]["passenger"].ToString().ToUpper(), Encoding.Default) || psmList[i].PassengerName.ToUpper() == HttpUtility.UrlDecode(ds.Tables[2].Rows[j]["passenger"].ToString().ToUpper()))
                                {
                                    psmList[i].TicketStatus = 2;
                                    psmList[i].TicketNumber = ds.Tables[2].Rows[j]["tktno"].ToString().Trim();
                                    tcount++;
                                }
                            }
                        }
                    }

                    if (tcount != psmList.Count)
                    {
                        #region 记录操作日志
                        //添加操作订单的内容
                        PbProject.Logic.SQLEXBLL.SQLEXBLL_Base sqlbase  = new PbProject.Logic.SQLEXBLL.SQLEXBLL_Base();
                        PbProject.Model.Log_Tb_AirOrder        OrderLog = new PbProject.Model.Log_Tb_AirOrder();

                        OrderLog.id          = Guid.NewGuid();
                        OrderLog.OrderId     = Order.OrderId;
                        OrderLog.OperType    = "修改";
                        OrderLog.OperTime    = DateTime.Now;
                        OrderLog.OperContent = "自动回填票号失败:乘机人与票号不符,需要手动操作!";
                        OrderLog.WatchType   = 2;
                        string tempSql = PbProject.Dal.Mapping.MappingHelper <PbProject.Model.Log_Tb_AirOrder> .CreateInsertModelSql(OrderLog);

                        sqlbase.ExecuteNonQuerySQLInfo(tempSql);
                        #endregion
                    }

                    decimal payprice = 0;

                    try
                    {
                        if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 &&
                            !string.IsNullOrEmpty(ds.Tables[0].Rows[0]["payprice"].ToString()) &&
                            !ds.Tables[0].Rows[0]["payprice"].ToString().Contains("-"))
                        {
                            payprice = payprice = Convert.ToDecimal(ds.Tables[0].Rows[0]["payprice"].ToString());
                        }
                    }
                    catch (Exception)
                    {
                    }

                    if (payprice != 0)
                    {
                        Order.AirPoint = 1 - (payprice - Order.ABFee - Order.FuelFee) / Order.PMFee;
                        Order.AirPoint = Math.Round(Order.AirPoint, 3);
                    }
                    //是否更改订单状态
                    //默认更改状态
                    bool IsUpdateOrderStatus = true;
                    try
                    {
                        foreach (PbProject.Model.Tb_Ticket_Passenger item in psmList)
                        {
                            //婴儿没有回帖票号 不修改状态
                            if (item.PassengerType == 3 && string.IsNullOrEmpty(item.TicketNumber.Trim()))
                            {
                                IsUpdateOrderStatus = false;
                                break;
                            }
                        }
                        if ((IsUpdateOrderStatus) && (tcount == psmList.Count))
                        {
                            Order.OrderStatusCode = 4;
                        }
                    }
                    catch (Exception)
                    {
                    }
                    List <PbProject.Model.User_Company> mCompany = new PbProject.Logic.ControlBase.BaseDataManage().
                                                                   CallMethod("User_Company", "GetList", null, new Object[] { "UninCode='" + Order.CPCpyNo + "'" }) as List <PbProject.Model.User_Company>;

                    List <PbProject.Model.User_Employees> mUser = new PbProject.Logic.ControlBase.BaseDataManage().
                                                                  CallMethod("User_Employees", "GetList", null, new Object[] { " IsAdmin=0 and CpyNo='" + Order.CPCpyNo + "'" }) as List <PbProject.Model.User_Employees>;

                    bool reuslt = new PbProject.Logic.Order.Tb_Ticket_OrderBLL().OperOrderCP(Order, psmList, mUser[0], mCompany[0], (IsUpdateOrderStatus ? "B2B自动出票" : "B2B自动出票【婴儿票请手动处理】"));
                    if (reuslt)
                    {
                        //零时改回状态
                        BaseDataManage manage = new BaseDataManage();
                        manage.ExecuteNonQuerySQLInfo("update Tb_Ticket_Order set OrderStatusCode=" + Order.OrderStatusCode + " where OrderId='" + Order.OrderId + "'");

                        #region  票宝开放服务接口异步通知出票

                        if (Order.OrderSourceType == 5)
                        {
                            PbProject.Logic.PTInterface.PbInterfaceNotify pbInterfaceCmd = new PbProject.Logic.PTInterface.PbInterfaceNotify();
                            if (pbInterfaceCmd != null)
                            {
                                bool pbNotifyResult = pbInterfaceCmd.NotifyTicketNo(Order);
                            }
                        }
                        #endregion
                        OnErrorNew(string.Format("出票成功.订单号:{0},PNR:{1}", Order.OrderId, Order.PNR), false);
                    }
                    else
                    {
                        OnErrorNew(string.Format("出票失败.订单号:{0},PNR:{1}", Order.OrderId, Order.PNR), false);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            #region 记录数据日志
            try
            {
                OnErrorNew("报错:" + ex.Message, false);
            }
            catch { }
            #endregion
        }
    }
示例#5
0
        //自动取消处理线程
        public static void XEPNRProcess()
        {
            string SendIns  = string.Empty;
            string RecvData = string.Empty;
            string Office   = string.Empty;
            string ErrMsg   = string.Empty;
            string Pnr      = string.Empty;
            string OrderId  = string.Empty;

            PnrAnalysis.FormatPNR pnrFormat = new FormatPNR();
            while (true)
            {
                try
                {
                    SendIns  = string.Empty;
                    RecvData = string.Empty;
                    Office   = string.Empty;
                    ErrMsg   = string.Empty;
                    Pnr      = string.Empty;
                    OrderId  = string.Empty;

                    //组织订单过滤条件
                    //订单来源:白屏预订PNR
                    string tmpSQL = " OrderSourceType=1 " +
                                    //订单状态:新订单,等待支付
                                    "and OrderStatusCode=1 " +
                                    //支付状态:未付
                                    "and PayStatus=0 " +
                                    //预订公司编号(归属的落地运营商编号范围)
                                    "and left(OwnerCpyNo,12) in (" + string.Join(",", m_XePNRInfo.CompanyNoList.ToArray()) + ") " +
                                    //预定时间超过设置取消时间值
                                    " and DateDiff(minute,CreateTime,getdate())>" + m_XePNRInfo.XEMinutes.ToString() +
                                    //3天内的预定订单
                                    " and DateDiff(day,CreateTime,getdate())<" + XePNR.m_XePNRInfo.day.ToString();

                    //取消订单表
                    List <Tb_Ticket_Order> list = Manage.CallMethod("Tb_Ticket_Order", "GetList", null, new object[] { tmpSQL }) as List <Tb_Ticket_Order>;
                    //滤过的PNR
                    List <string> tempPntList = new List <string>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        //停止服务,则退出处理
                        if (m_XePNRInfo.EndFlag || XeLog == null)
                        {
                            return;
                        }
                        Tb_Ticket_Order tmpTicketOrder = list[i];
                        ///控制权限
                        string KonZhiXT = GetGYParameters(tmpTicketOrder.OwnerCpyNo);
                        //是否关闭后台自动取消编码功能
                        if (KonZhiXT != null && KonZhiXT.Contains("|98|"))
                        {
                            continue;
                        }
                        #region 过滤掉已经处理的PNR
                        if (tempPntList.Contains("'" + tmpTicketOrder.PNR + "'"))
                        {
                            continue;
                        }
                        #endregion

                        #region 检查同一编码、同一预订公司下是否存在已付款的订单
                        //包括收银
                        string tmpSQL3 = "  PNR='" + tmpTicketOrder.PNR + "'"
                                         + " and CreateTime>='" + tmpTicketOrder.CreateTime.ToString("yyyy-MM-dd") + "' and ( (OrderStatusCode in(3,4) and  PayStatus=0)  or   PayStatus=1 or OrderStatusCode=4 )";
                        bool flag1 = (bool)Manage.CallMethod("Tb_Ticket_Order", "IsExist", null, new object[] { tmpSQL3 });
                        if (flag1)
                        {
                            if (tmpTicketOrder.PNR != "")
                            {
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                            }
                            //存在已经支付的订单,略过
                            //记录日志
                            Log.Record("XePnr.log", "订单号:" + tmpTicketOrder.OrderId + ",PNR编号:" + tmpTicketOrder.PNR + "存在已经付款订单,略过该PNR...");
                            continue;
                        }
                        #endregion 检查同一编码、同一预订公司下是否存在已付款的订单

                        #region 提取并检查PNR是否已经出票或RR状态,如果是则略过
                        string GYCpyNo = tmpTicketOrder.OwnerCpyNo;
                        if (GYCpyNo.Length >= 12)
                        {
                            GYCpyNo = GYCpyNo.Substring(0, 12);
                        }
                        List <Bd_Base_Parameters> baseParamList = Manage.CallMethod("Bd_Base_Parameters", "GetList", null, new Object[] { "CpyNo='" + GYCpyNo + "'" }) as List <Bd_Base_Parameters>;
                        ConfigParam config = Bd_Base_ParametersBLL.GetConfigParam(baseParamList);
                        if (config == null)
                        {
                            XeLog(1, string.Format("订单号{0},落地运营商未设置使用配置信息,请设置!", tmpTicketOrder.OrderId));
                            //移除该落地运营商 该落地运营商未设置配置参数
                            if (m_XePNRInfo.CompanyNoList.Contains("'" + GYCpyNo + "'"))
                            {
                                m_XePNRInfo.CompanyNoList.Remove("'" + GYCpyNo + "'");
                            }
                            continue;
                        }
                        OrderId = tmpTicketOrder.OrderId;
                        Office  = string.IsNullOrEmpty(tmpTicketOrder.Office) ? config.Office.Split('^')[0] : tmpTicketOrder.Office;
                        if (string.IsNullOrEmpty(Office))
                        {
                            XeLog(1, string.Format("订单号{0}中没有Office或者落地运营商没有设置Office,请检查!", OrderId));
                            //移除该落地运营商 该落地运营商未设置配置参数
                            if (m_XePNRInfo.CompanyNoList.Contains("'" + GYCpyNo + "'"))
                            {
                                m_XePNRInfo.CompanyNoList.Remove("'" + GYCpyNo + "'");
                            }
                            continue;
                        }
                        Pnr = tmpTicketOrder.PNR;
                        if (string.IsNullOrEmpty(tmpTicketOrder.PNR) || (tmpTicketOrder.PNR.Trim() == ""))
                        {
                            XeLog(1, string.Format("订单号{0}中没有PNR,更改为已取消订单!", OrderId));

                            //更改订单状态为已经取消订单
                            string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }

                        Tb_SendInsData SendModel = new Tb_SendInsData();
                        ParamObject    PM        = new ParamObject();
                        PM.ServerIP   = config.WhiteScreenIP;
                        PM.ServerPort = int.Parse(config.WhiteScreenPort);
                        PM.Office     = Office;
                        //发送指令
                        SendIns = "RT" + Pnr;
                        PM.code = SendIns;
                        PM.IsPn = true;

                        SendModel.SendIns         = SendIns;             //发送指令
                        SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                        SendModel.SendTime        = System.DateTime.Now; //发送时间
                        SendModel.Office          = Office;
                        SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                        SendModel.UserAccount     = "扫描程序";
                        SendModel.CpyNo           = GYCpyNo;
                        //返回数据
                        RecvData           = SendNewPID.SendCommand(PM);
                        SendModel.RecvData = RecvData;
                        SendModel.RecvTime = System.DateTime.Now;
                        //记录指令到数据库
                        LogData(SendModel);

                        //指令日志
                        XeLog(1, string.Format("\r\n【编码:{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n订单号:{3}\r\n", Pnr, SendIns, RecvData, tmpTicketOrder.OrderId));
                        if (RecvData.Contains("授权"))
                        {
                            //更改订单状态为已经取消订单
                            string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            if (tmpTicketOrder.PNR != "")
                            {
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                            }
                            XeLog(1, string.Format("订单号{0}中{1} {2},只取消订单不取消编码!", OrderId, Pnr, RecvData));
                            continue;
                        }
                        string PnrStatus = pnrFormat.GetPnrStatus(RecvData, out ErrMsg);
                        if (!PnrStatus.ToUpper().Contains("HK") && !PnrStatus.ToUpper().Contains("HL") && !PnrStatus.ToUpper().Contains("NO"))//(PnrStatus.Contains("RR") || PnrStatus.Contains("XX"))
                        {
                            if (tmpTicketOrder.PNR != "")
                            {
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                            }
                            XeLog(1, string.Format("订单号{0}中{1}状态为{2},只取消订单,不处理PNR!", OrderId, Pnr, PnrStatus));

                            //更改订单状态为已经取消订单
                            string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }
                        #endregion 提取并检查PNR是否已经出票或RR状态,如果是则略过

                        #region 发送取消PNR指令并检查结果

                        if (PnrStatus.ToUpper().Contains("HK") || PnrStatus.ToUpper().Contains("HL") || PnrStatus.ToUpper().Contains("NO"))
                        {
                            //取消编码
                            SendIns = "RT" + Pnr + "|XEPNR@" + Pnr;
                            PM.code = SendIns;
                            PM.IsPn = false;

                            SendModel                 = new Tb_SendInsData();
                            SendModel.SendIns         = SendIns;             //发送指令
                            SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                            SendModel.SendTime        = System.DateTime.Now; //发送时间
                            SendModel.Office          = Office;
                            SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                            SendModel.UserAccount     = "扫描程序";
                            SendModel.CpyNo           = GYCpyNo;
                            //返回数据
                            RecvData           = SendNewPID.SendCommand(PM);
                            SendModel.RecvData = RecvData;
                            SendModel.RecvTime = System.DateTime.Now;
                            //记录指令到数据库
                            LogData(SendModel);

                            //指令日志
                            XeLog(1, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", OrderId, SendIns, RecvData));

                            if (RecvData.ToUpper().Contains("CANCELLED"))
                            {
                                //加入不需要取消的列表
                                tempPntList.Add("'" + tmpTicketOrder.PNR + "'");
                                //取消编码成功后 取消订单
                                List <string> ListSQL = new List <string>();
                                //修改订单数据
                                string tempSql = "update Tb_Ticket_Order set OrderStatusCode=2,TicketStatus=6  where id='" + tmpTicketOrder.id + "'";
                                ListSQL.Add(tempSql);//
                                //修改乘客数据
                                tempSql = "update Tb_Ticket_Passenger set TicketStatus=6  where OrderId='" + OrderId + "'";
                                ListSQL.Add(tempSql);//1.添加订单日志

                                //取消编码 订单日志
                                Log_Tb_AirOrder OrderLog = new Log_Tb_AirOrder();
                                OrderLog.id            = Guid.NewGuid();
                                OrderLog.OperContent   = "订单超过" + m_XePNRInfo.XEMinutes.ToString() + "分钟未能成功支付,系统于" + System.DateTime.Now + "订单自动取消";;
                                OrderLog.OperLoginName = "管理员";
                                OrderLog.OperTime      = DateTime.Now;
                                OrderLog.OperType      = "修改";
                                OrderLog.OperUserName  = "******";
                                OrderLog.OrderId       = OrderId;
                                OrderLog.WatchType     = 1;
                                //订单出票公司信息
                                ListParam TicketLP = LPList.Find(delegate(ListParam _tempLP)
                                {
                                    return(tmpTicketOrder.OwnerCpyNo.Contains(_tempLP.CpyNo));
                                });
                                if (TicketLP != null)
                                {
                                    OrderLog.CpyName = TicketLP.UninAllName;
                                    OrderLog.CpyNo   = TicketLP.CpyNo;
                                    OrderLog.CpyType = 1;
                                }
                                else
                                {
                                    OrderLog.CpyName = tmpTicketOrder.OwnerCpyName;
                                    OrderLog.CpyNo   = tmpTicketOrder.OwnerCpyNo;
                                    OrderLog.CpyType = 1;
                                }
                                tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Tb_AirOrder> .CreateInsertModelSql(OrderLog);

                                ListSQL.Add(tempSql);
                                //取消订单
                                if (Manage.ExecuteSqlTran(ListSQL, out ErrMsg))
                                {
                                    XeLog(1, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " 订单号:" + OrderId + " 订单已取消");
                                }
                            }
                        }
                        #endregion 发送取消PNR指令并检查结果
                    }

                    #region //修改滤过的PNR状态
                    if (tempPntList.Count > 0)
                    {
                        string sqlWhere = " update Log_Pnr set  Flag=1 where   Pnr in(" + string.Join(",", tempPntList.ToArray()) + ")";
                        Manage.ExecuteNonQuerySQLInfo(sqlWhere);
                    }

                    #endregion

                    #region    //生成了编码 没有生成订单的编码
                    string tmpSQL2 = " left(CpyNo,12) in (" + string.Join(",", m_XePNRInfo.CompanyNoList.ToArray()) + ") and DateDiff(minute,OperTime,getdate())>" + m_XePNRInfo.XEMinutes.ToString() + " and OrderFlag=0 and Flag=0 and RetryCount<" + m_XePNRInfo.ReTryCount;
                    //过滤掉没有连接成功的PNR
                    List <string> lstRepeat = new List <string>();
                    //取消PNR表 没有写入订单的数据
                    List <Log_Pnr> list2 = Manage.CallMethod("Log_Pnr", "GetList", null, new object[] { tmpSQL2 }) as List <Log_Pnr>;
                    for (int j = 0; j < list2.Count; j++)
                    {
                        //停止服务,则退出处理
                        if (m_XePNRInfo.EndFlag)
                        {
                            return;
                        }
                        Log_Pnr tmpLogPnr = list2[j];
                        ///控制权限
                        string KonZhiXT = GetGYParameters(tmpLogPnr.CpyNo);
                        //是否关闭后台自动取消编码功能
                        if (KonZhiXT != null && KonZhiXT.Contains("|98|"))
                        {
                            continue;
                        }
                        string GYCpyNo = tmpLogPnr.CpyNo.Length >= 12 ? tmpLogPnr.CpyNo.Substring(0, 12) : tmpLogPnr.CpyNo;
                        //勾选了该落地运营商的才取消编码
                        if (!m_XePNRInfo.CompanyNoList.Contains("'" + GYCpyNo + "'"))
                        {
                            continue;
                        }
                        //不取消滤过的PNR
                        if (tmpLogPnr.PNR != "" && tempPntList.Contains("'" + tmpLogPnr.PNR + "'"))
                        {
                            tmpLogPnr.Flag = true;
                            string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }

                        #region 取消PNR
                        string pnr = tmpLogPnr.PNR;
                        //pnr为空不处理  //Office为空不处理
                        if (string.IsNullOrEmpty(pnr) || string.IsNullOrEmpty(tmpLogPnr.OfficeCode))
                        {
                            tmpLogPnr.Flag = true;
                            string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                            Manage.ExecuteNonQuerySQLInfo(tempSql);
                            continue;
                        }
                        ////IP端口为空不处理
                        string[] strIPPort = tmpLogPnr.A7.Split('|');
                        if (strIPPort.Length == 2)
                        {
                            if (pnr.Trim() == "")
                            {
                                tmpLogPnr.Flag = true;
                                string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                                Manage.ExecuteNonQuerySQLInfo(tempSql);
                                continue;
                            }


                            string ip   = strIPPort[0];
                            int    Port = 0;
                            int.TryParse(strIPPort[1], out Port);

                            Tb_SendInsData SendModel = new Tb_SendInsData();
                            ParamObject    PM        = new ParamObject();
                            PM.ServerIP   = ip;
                            PM.ServerPort = Port;
                            PM.Office     = tmpLogPnr.OfficeCode;

                            //发送指令
                            SendIns = "RT" + pnr;
                            PM.code = SendIns;

                            SendModel.SendIns         = SendIns;             //发送指令
                            SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                            SendModel.SendTime        = System.DateTime.Now; //发送时间
                            SendModel.Office          = Office;
                            SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                            SendModel.UserAccount     = "扫描程序";
                            SendModel.CpyNo           = GYCpyNo;
                            //过滤连接不通的IP端口
                            if (lstRepeat.Contains(SendModel.ServerIPAndPort))
                            {
                                continue;
                            }
                            //返回数据
                            RecvData           = SendNewPID.SendCommand(PM);
                            SendModel.RecvData = RecvData;
                            SendModel.RecvTime = System.DateTime.Now;
                            //记录指令到数据库
                            LogData(SendModel);
                            //过滤连接不通的IP端口
                            if (RecvData.Contains("由于连接方在一段时间后没有正确答复或连接的主机没有反应") || RecvData.Contains("不知道这样的主机"))
                            {
                                lstRepeat.Add(SendModel.ServerIPAndPort);
                            }
                            //指令日志
                            XeLog(1, string.Format("\r\n【编码:{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Pnr, SendIns, RecvData));
                            string PnrStatus = pnrFormat.GetPnrStatus(RecvData, out ErrMsg);
                            if (!PnrStatus.Contains("RR") && !PnrStatus.Contains("XX") && PnrStatus != "")
                            {
                                if (PnrStatus.ToUpper().Contains("HK") || PnrStatus.ToUpper().Contains("HL") || PnrStatus.ToUpper().Contains("NO"))
                                {
                                    //发送指令
                                    SendIns = "RT" + pnr + "|XePNR@" + pnr;
                                    PM.code = SendIns;

                                    SendModel                 = new Tb_SendInsData();
                                    SendModel.SendIns         = SendIns;             //发送指令
                                    SendModel.SendInsType     = 13;                  //扫描程序发送的指令
                                    SendModel.SendTime        = System.DateTime.Now; //发送时间
                                    SendModel.Office          = Office;
                                    SendModel.ServerIPAndPort = PM.ServerIP + ":" + PM.ServerPort;
                                    SendModel.UserAccount     = "扫描程序";
                                    SendModel.CpyNo           = GYCpyNo;
                                    //返回数据
                                    RecvData           = SendNewPID.SendCommand(PM);
                                    SendModel.RecvData = RecvData;
                                    SendModel.RecvTime = System.DateTime.Now;
                                    //记录指令到数据库
                                    LogData(SendModel);

                                    //指令日志
                                    XeLog(1, string.Format("\r\n【编码:{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", pnr, SendIns, RecvData));
                                    if (RecvData.ToUpper().Contains("CANCELLED"))
                                    {
                                        //取消成功
                                        tmpLogPnr.Flag = true;
                                    }
                                    else
                                    {
                                        //取消失败
                                        tmpLogPnr.Flag = false;
                                        tmpLogPnr.RetryCount++;
                                    }
                                    string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                                    Manage.ExecuteNonQuerySQLInfo(tempSql);
                                }
                            }
                            else
                            {
                                tmpLogPnr.Flag = true;
                                string tempSql = PbProject.Dal.Mapping.MappingHelper <Log_Pnr> .CreateUpdateModelSql(tmpLogPnr, "id");

                                Manage.ExecuteNonQuerySQLInfo(tempSql);
                            }
                        }
                        #endregion
                    }
                    //更新数据库
                    //if (UpdateSQL.Count > 0)
                    //{
                    //    Manage.ExecuteSqlTran(UpdateSQL, out ErrMsg);
                    //}
                    #endregion
                }
                catch (Exception ex)
                {
                    //记录错误日志
                    Log.Record("XePnrError.log", ex, "XEPNRProcess:自动取消PNR处理过程出错!");
                }
                //遍历时间间隔
                Thread.Sleep(m_XePNRInfo.InterMinutes * 1000);//分钟
            }
        }