protected void Page_Load(object sender, EventArgs e) { LogInfo("进入汇付天下自动出票回调...", false); m_Key = System.Configuration.ConfigurationManager.AppSettings["HuifuAutoKey"]; client = new ChinaPnrClient(System.Configuration.ConfigurationManager.AppSettings["HuifuAutoIP"]); if (string.IsNullOrEmpty(m_Key)) { string msg = PnrNo + "_FAIL未配置Key"; LogInfo("未配置Key", false); client.Send(AddHeadLen(msg)); return; } GetParams(); PbProject.Model.Tb_Ticket_Order orderList = new PbProject.Logic.Order.Tb_Ticket_OrderBLL().GetTicketOrderByOrderId(m_GUID); if (orderList == null) { string msg = PnrNo + "_FAIL未找到相应订单"; LogInfo("未找到相应订单", false); client.Send(AddHeadLen(msg)); return; } PnrNo = orderList.PNR; if (!CheckParams()) { if (!string.IsNullOrEmpty(m_DrawResult) && m_DrawResult.Trim() != "000000") { RollBackTicketOrderState(orderList, "出票失败,原因:回调参数不完整"); } string msg = PnrNo + "_FAIL参数不完整"; LogInfo(string.Format("参数不完整,订单号:{0},PNR:{1}", orderList.OrderId, PnrNo), false); client.Send(AddHeadLen(msg)); return; } if (!CheckSign()) { if (m_DrawResult.Trim() != "000000") { RollBackTicketOrderState(orderList, "出票失败,原因:回调签名验证失败"); } string msg = PnrNo + "_FAIL签名验证失败"; LogInfo(string.Format("签名验证失败,订单号:{0},PNR:{1}", orderList.OrderId, PnrNo), false); client.Send(AddHeadLen(msg)); return; } if (orderList.OrderStatusCode == 4) { string msg = PnrNo + "_FAIL已出票"; LogInfo(string.Format("已经出票,无需重复出票,订单号:{0},PNR:{1}", orderList.OrderId, PnrNo), false); client.Send(AddHeadLen(msg)); return; } //Login(orderList); //更新票号 UpdateTicketOrder(orderList); }
/// <summary> /// 更新出票相关信息 /// </summary> /// <param name="order"></param> private void UpdateTicketOrder(PbProject.Model.Tb_Ticket_Order order) { string resultDes = HttpUtility.UrlDecode(m_DrawResultDes, Encoding.GetEncoding("gb2312")); if (m_DrawResult.Trim() == "000000")//出票成功 { string[] passengerInfoList = resultDes.Split(';'); PbProject.Logic.Order.Tb_Ticket_PassengerBLL psb = new PbProject.Logic.Order.Tb_Ticket_PassengerBLL(); List <PbProject.Model.Tb_Ticket_Passenger> psmList = psb.GetPasListByOrderID(order.OrderId); psmList = ModifyPassenger(passengerInfoList, psb, psmList); order = ModifyOrder(order); 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], ""); if (reuslt) { #region 票宝开放服务接口异步通知出票 if (order.OrderSourceType == 5) { PbProject.Logic.PTInterface.PbInterfaceNotify pbInterfaceCmd = new PbProject.Logic.PTInterface.PbInterfaceNotify(); if (pbInterfaceCmd != null) { bool pbNotifyResult = pbInterfaceCmd.NotifyTicketNo(order); } } #endregion string msg = PnrNo + "_SUCC"; client.Send(AddHeadLen(msg)); LogInfo(string.Format("出票成功.订单号:{0},PNR:{1}", order.OrderId, PnrNo), false); } else { LogInfo(string.Format("出票失败.订单号:{0},PNR:{1}", order.OrderId, PnrNo), false); } } else { LogInfo(resultDes + ",订单号:" + order.OrderId + ",PNR:" + PnrNo, false); RollBackTicketOrderState(order, string.Format("出票失败,原因:{0}", resultDes)); } client.Send(AddHeadLen(PnrNo + "_SUCC"));//返回成功 }
/// <summary> /// 出票Socket调用 /// </summary> /// <param name="orderMange"></param> /// <param name="client"></param> /// <param name="order"></param> /// <param name="comModel"></param> /// <param name="data"></param> private void ChinapnrTicketWork(PbProject.Logic.Order.Tb_Ticket_OrderBLL orderMange, ChinaPnrClient client, PbProject.Model.Tb_Ticket_Order order, string data, int AutoCount, ListParam Pm, B2BShowLog Log) { int times = AutoCount; //至少一次 for (int i = 0; i < times; i++) //调用次数 { //调用ChinaPnrClient对象的Send方法,获取发送结果 string result = client.Send(data);//合法请求:0011QUERY_VALID;非法请求:0021QUERY_INVALID 错误描述。 if (result.Contains("0011QUERY_VALID")) { order.A10 = "1";//标识出票成功 string SQL = " update Tb_Ticket_Order set A10=1 where OrderId='" + order.OrderId + "'"; PbProject.Logic.SQLEXBLL.SQLEXBLL_Base ss = new PbProject.Logic.SQLEXBLL.SQLEXBLL_Base(); ss.ExecuteNonQuerySQLInfo(SQL); //ShowChinapnrMsg("出票请求成功,订单ID:" + order.OrderId); //infoLog.Info("出票请求成功,订单ID:" + order.OrderId); Log(3, "出票请求成功,订单ID:" + order.OrderId); break; } else { string logDbMsg = ""; if (string.IsNullOrEmpty(result)) { logDbMsg = "出票请求失败。原因:服务器响应超时"; string msg = string.Format("出票请求失败。原因:服务器响应超时,订单ID:{0}", order.OrderId); //ShowChinapnrMsg(msg); //infoLog.Info(msg); Log(3, msg); } else { string errorStr = result.Substring(17, result.Length - 17).Trim(); if (errorStr.ToLower().IndexOf("airlines") > 0) { logDbMsg = string.Format("出票请求失败。原因:{0},航空公司二字码:{1}", errorStr, order.CarryCode); string msg = string.Format("出票请求失败。原因:{0},航空公司二字码:{1},订单ID:{2}", errorStr, order.CarryCode, order.OrderId); //ShowChinapnrMsg(msg); //infoLog.Info(msg); Log(3, msg); } else { logDbMsg = string.Format("出票请求失败。原因:{0}", errorStr); string msg = string.Format("出票请求失败。原因:{0},订单ID:{1}", errorStr, order.OrderId); //ShowChinapnrMsg(msg); //infoLog.Info(msg); Log(3, msg); } } if (i == times - 1) { string msg = string.Format("已达到最大失败次数,已改为手动出票,订单ID:{0}", order.OrderId); ChinapnrAutofailed(order, msg, Pm, Log); //FailedLogToDb(order, logDbMsg + ",已改为手动出票"); OrderLog(order.OrderId, logDbMsg + ",已改为手动出票", Pm, "2"); } } Thread.Sleep(3000); } }