public void OnCreateOrder() { //if (_QXValue.Contains("|62|"))//控制是否自动生成订单 //{ List <PbProject.Model.Tb_Ticket_SkyWay> skyList = new PbProject.Logic.Order.Tb_Ticket_SkyWayBLL().GetSkyWayListBySQLWhere("OrderId='" + _order.OrderId + "'"); PnrAnalysis.FormatPNR ss = new PnrAnalysis.FormatPNR(); string RTContent = skyList[0].NewPnrContent.Replace("\r", "").Replace("\t", "").Replace("\n", ""); string PATContent = ss.RemoveHideChar(skyList[0].Pat).Replace("\r", "").Replace("\t", "").Replace("\n", ""); #region 处理高低开 if (!_order.Space.Contains("1")) //不为子舱位 { string bb = ""; PnrAnalysis.PatModel sss = ss.GetPATInfo(skyList[0].NewPnrContent, out bb); if (sss.ChildPat != null) { for (int i = 0; i < sss.PatList.Count; i++) { if (sss.PatList[i].SeatGroup == sss.ChildPat.SeatGroup) { sss.PatList.Remove(sss.PatList[i]); break; } } PatInfo patFirst = sss.PatList[0]; PatInfo patLast = sss.PatList[sss.PatList.Count - 1]; //if (_QXValue.Contains("|60|")) //{ PATContent = ss.NewPatData(patFirst); //} //else //{ // PATContent = ss.NewPatData(patLast); //} bool IsOnePrice = false; RTContent = ss.RemoveChildSeat(RTContent, out IsOnePrice); } } #endregion //OnErrorNew(1, "517开始生成订单", "517生成订单"); DataSet dsReson; if (_order.PolicyId.Split('~')[1].ToString() != "") //判断有无子政策ID { dsReson = _517Service.CreateOrderByPnrAndPAT(_517Accout, _517Password, _517Ag, RTContent, _order.BigCode, Convert.ToInt32(_order.PolicyId.Split('~')[0].ToString()), _order.LinkMan, _order.LinkManPhone, _order.PolicyId.Split('~')[1].ToString(), PATContent, _order.PNR); } else { dsReson = _517Service.CreateOrderByPnrAndPAT(_517Accout, _517Password, _517Ag, RTContent, _order.BigCode, Convert.ToInt32(_order.PolicyId.Split('~')[0].ToString()), _order.LinkMan, _order.LinkManPhone, "", PATContent, _order.PNR); } string mes517Create = ""; for (int i = 0; i < dsReson.Tables[0].Rows.Count; i++) { for (int j = 0; j < dsReson.Tables[0].Columns.Count; j++) { mes517Create = mes517Create + dsReson.Tables[0].Columns[i].ColumnName + ":" + dsReson.Tables[0].Rows[i][j].ToString() + "/"; //DataTable转化成String类型 } } mes517Create = "table's name:" + dsReson.Tables[0].TableName + "/table's content:" + mes517Create; CreateLog(_order.OrderId, "预定", mes517Create, 1); if (dsReson.Tables[0].TableName == "error") //生成订单失败,记录日志 { CreateLog(_order.OrderId, "预定", mes517Create, 3); //OnErrorNew(1, "517生成订单失败", "517生成订单"); } else { if (dsReson.Tables[0].Rows[0]["OrderId"].ToString() != "") { //OnErrorNew(1, "517生成订单成功", "517生成订单"); CreateLog(_order.OrderId, "预定", "517生成订单成功!", 3); if (dsReson.Tables[0].Rows[0]["TotlePirce"].ToString() == "") { dsReson.Tables[0].Rows[0]["TotlePirce"] = "0"; } OnPay(Convert.ToDecimal(dsReson.Tables[0].Rows[0]["TotlePirce"].ToString()), dsReson.Tables[0].Rows[0]["OrderId"].ToString(), mes517Create); } else { CreateLog(_order.OrderId, "预定", "517生成订单失败:" + mes517Create, 3); } } //} }
/// <summary> /// 确认订单 /// </summary> /// <param name="writer"></param> /// <param name="parames"></param> public override void Create(ResponseWriter writer, System.Collections.Specialized.NameValueCollection parames) { var userLogin = AuthLogin.GetUserInfo(Username); string adultOrderId = parames["adultOrderId"]; string childOrderId = parames["childOrderId"]; string adultPolicyGuid = parames["adultPolicyGuid"]; //成人政策guid string childPolicyGuid = parames["childPolicyGuid"]; //婴儿政策guid string remark = parames["remark"]; var adultPolicy = PolicyCacheManager.Get(adultPolicyGuid) as PolicyParamForAPI; var childPolicy = PolicyCacheManager.Get(childPolicyGuid) as PolicyParamForAPI; OrderInputParam InputParam = createOrderInputParam(adultOrderId, childOrderId); Tb_Ticket_OrderBLL orderBLL = new Tb_Ticket_OrderBLL(); if (adultPolicy == null) { writer.WriteEx(554, "Cache is disabled", "政策缓存已失效,请重新操作"); } else { #region 更新订单 主要修改价格,政策和添加订单账单明细 Bill bill = new Bill(); Data d = new Data(userLogin.Company.UninCode);//采购佣金进舍规则: 0.舍去佣金保留到元、1.舍去佣金保留到角、2.舍去佣金保留到分 string ErrMsg = ""; bool IsSuc = false; //扩展参数 ParamEx pe = new ParamEx(); pe.UsePIDChannel = userLogin.FQP.KongZhiXiTong != null && userLogin.FQP.KongZhiXiTong.Contains("|48|") ? 2 : 0; //发送指令管理类 SendInsManage SendIns = new SendInsManage(userLogin.User.LoginName, userLogin.Company.UninCode, pe, userLogin.Configparam); //提示 StringBuilder sbTip = new StringBuilder(); try { AjaxPolicyMatchOutData APM = new AjaxPolicyMatchOutData(); APM.OutPutPolicyList.Add(adultPolicy); APM.OutPutPolicyList.Add(childPolicy); //供应商Office string GYOffice = userLogin.Configparam != null?userLogin.Configparam.Office.ToUpper() : ""; if (InputParam != null && APM != null && APM.OutPutPolicyList != null && APM.OutPutPolicyList.Count > 0) { AjAxPolicyParam AdultPolicy = adultPolicy; AjAxPolicyParam ChildPolicy = childPolicy; //至少选择一条政策 成人或者儿童 if (AdultPolicy == null && ChildPolicy == null) { writer.WriteEx(567, "choose one policy at least", "请选择一条政策数据"); } else { PatInfo INFPrice = null; if (HasBaby(InputParam)) { //婴儿价格 INFPrice = GetINFPAT(); } //订单实体需要更改数据的字段名 List <string> UpdateOrderFileds = new List <string>(); //订单修改字段 UpdateOrderFileds.AddRange(new string[] { "OldRerurnMoney", "OldPolicyPoint", "OutOrderPayMoney", "A7", "A13", "A1", "A11", "PrintOffice", "CPCpyNo", "YDRemark", "PolicyId", "AirPoint", "PolicyPoint", "ReturnPoint", "PolicyMoney", "PolicyCancelTime", "PolicyReturnTime", "DiscountDetail", "PolicyType", "PolicySource", "AutoPrintFlag", "PolicyRemark", "PMFee", "ABFee", "FuelFee", "BabyFee", "PayMoney", "OrderMoney" }); //航段实体需要更改数据的字段名 List <string> UpdateSkyWayFileds = new List <string>(); //航段修改字段 UpdateSkyWayFileds.AddRange(new string[] { "SpacePrice", "ABFee", "FuelFee", "Discount" }); //乘客实体需要更改数据的字段名 List <string> UpdatePasFileds = new List <string>(); //修改乘机人 UpdatePasFileds.AddRange(new string[] { "PMFee", "ABFee", "FuelFee" }); //承运人二字码 string CarrayCode = string.Empty; string orderIDs = ""; //婴儿与编码中的婴儿个数是否不一致 true不一致 false一致 bool IsINFCheck = false; //婴儿与编码中的婴儿个数是否不一致提示 string INFCountCheckMsg = "<b class=\"red\">编码中婴儿个数与预订婴儿个数不一致,请手动补全编码中婴儿!</b>"; //Bill返回有无SQL bool IsBillOK = false; //修改实体相关的值后更新即可 for (int i = 0; i < InputParam.OrderParamModel.Count; i++) { OrderMustParamModel item = InputParam.OrderParamModel[i]; //承运人二字码 CarrayCode = item.Order.CarryCode.Split('/')[0].ToUpper().Trim(); if (orderIDs.Contains(item.Order.OrderId)) { continue; } else { orderIDs += item.Order.OrderId + "|"; } #region 设置需要更改数据的字段名集合 item.UpdateOrderFileds = UpdateOrderFileds; item.UpdateSkyWayFileds = UpdateSkyWayFileds; item.UpdatePassengerFileds = UpdatePasFileds; #endregion #region 实体处理 //订单中的总价 decimal TotalPMPrice = 0m, TotalABFare = 0, TotalRQFare = 0m; //item.Order.YDRemark = remark; //预订备注信息 item.Order.YDRemark = remark; //订单处理 成人订单政策 if (!item.Order.IsChdFlag && AdultPolicy != null) { #region 成人或者婴儿实体价格赋值 //检测白屏预订婴儿个数与编码中的婴儿个数 if (item.Order.OrderSourceType == 1 || item.Order.OrderSourceType == 5) { IsINFCheck = yudingINFCheck(InputParam.PnrInfo, item.PasList); } //婴儿价格 decimal INFPMFee = 0m, INFABFare = 0m, INFRQFare = 0m; if (INFPrice != null) { decimal.TryParse(INFPrice.Fare, out INFPMFee); decimal.TryParse(INFPrice.TAX, out INFABFare); decimal.TryParse(INFPrice.RQFare, out INFRQFare); } //成人价格 decimal PMFee = AdultPolicy.SeatPrice, ABFare = AdultPolicy.ABFare, RQFare = AdultPolicy.RQFare; #region 特价缓存处理 //特价时特价缓存处理 为特价且PAT内容不为空 if (AdultPolicy.PolicyKind == 2 && item.SkyList[0].Pat.Trim() != "") { //白屏和PNR导入 if (item.Order.OrderSourceType == 1 || item.Order.OrderSourceType == 2 || item.Order.OrderSourceType == 6 || item.Order.OrderSourceType == 10) { //特价缓存 SpecialCabinPriceInfoBLL SpBll = new SpecialCabinPriceInfoBLL(); PnrAnalysis.FormatPNR pnrformat = new PnrAnalysis.FormatPNR(); string errMsg = ""; PnrAnalysis.PatModel Pat = pnrformat.GetPATInfo(item.SkyList[0].Pat.Trim(), out errMsg); if (Pat.UninuePatList.Count > 0) { decimal m_Fare = 0m; decimal m_TAX = 0m; decimal m_RQFare = 0m; decimal.TryParse(Pat.UninuePatList[0].Fare, out m_Fare); decimal.TryParse(Pat.UninuePatList[0].TAX, out m_TAX); decimal.TryParse(Pat.UninuePatList[0].RQFare, out m_RQFare); //价格不相等 if (m_Fare != PMFee) { //存入缓存 SpBll.SaveSpPrice(item.SkyList[0].CarryCode.ToUpper(), item.SkyList[0].FlightCode, item.SkyList[0].FromDate, item.SkyList[0].FromCityCode, item.SkyList[0].ToCityCode, item.SkyList[0].Space, m_Fare, m_TAX, m_RQFare); } } } } #endregion //乘机人实体处理 for (int j = 0; j < item.PasList.Count; j++) { if (item.PasList[j].PassengerType == 1) { //成人 item.PasList[j].PMFee = PMFee; item.PasList[j].ABFee = ABFare; item.PasList[j].FuelFee = RQFare; } else { //婴儿 if (item.PasList[j].PassengerType == 3 && INFPrice != null) { item.PasList[j].PMFee = INFPMFee; item.PasList[j].ABFee = INFABFare; item.PasList[j].FuelFee = INFRQFare; } } if (item.PasList[j].PassengerType == 1 || item.PasList[j].PassengerType == 3) { //订单价格 TotalPMPrice += item.PasList[j].PMFee; TotalABFare += item.PasList[j].ABFee; TotalRQFare += item.PasList[j].FuelFee; } } //航段实体处理 //string Discount = "0"; for (int k = 0; k < item.SkyList.Count; k++) { item.SkyList[k].ABFee = ABFare; item.SkyList[k].FuelFee = RQFare; //只是单程才重新赋值 if (item.SkyList.Count == 1) { item.SkyList[k].SpacePrice = PMFee; } //item.SkyList[k].Discount = AdultPolicy.DiscountRate.ToString(); //if (Discount.Length > 10) //{ // Discount = Discount.Substring(0, 10); //} //item.SkyList[k].Discount = Discount; } //成人订单(含有婴儿) 赋值 item.Order.PMFee = TotalPMPrice; item.Order.ABFee = TotalABFare; item.Order.FuelFee = TotalRQFare; if (INFPrice != null) { //婴儿票面价 item.Order.BabyFee = INFPMFee; } item.Order.PolicyId = AdultPolicy.PolicyId; item.Order.PolicyPoint = AdultPolicy.PolicyPoint; item.Order.ReturnMoney = AdultPolicy.PolicyReturnMoney; item.Order.AirPoint = AdultPolicy.AirPoint; item.Order.ReturnPoint = AdultPolicy.ReturnPoint; item.Order.LaterPoint = AdultPolicy.LaterPoint; item.Order.PolicyMoney = AdultPolicy.PolicyYongJin; item.Order.DiscountDetail = AdultPolicy.DiscountDetail; item.Order.PolicyType = int.Parse(AdultPolicy.PolicyType); item.Order.PolicySource = int.Parse(AdultPolicy.PolicySource); item.Order.AutoPrintFlag = int.Parse(AdultPolicy.AutoPrintFlag); item.Order.PolicyCancelTime = AdultPolicy.FPGQTime; item.Order.PolicyReturnTime = AdultPolicy.PolicyReturnTime; //出票公司编号 string CPCpyNo = string.IsNullOrEmpty(AdultPolicy.CPCpyNo) ? userLogin.mSupCompany.UninCode : AdultPolicy.CPCpyNo; item.Order.CPCpyNo = CPCpyNo.Length > 12 ? CPCpyNo.Substring(0, 12) : CPCpyNo; item.Order.PolicyRemark = AdultPolicy.PolicyRemark;//政策备注 //原始政策返点 item.Order.OldPolicyPoint = AdultPolicy.OldPolicyPoint; //原始政策现返 item.Order.OldReturnMoney = AdultPolicy.OldPolicyReturnMoney; item.Order.A1 = 1; //已确认 item.Order.A2 = AdultPolicy.PolicyKind; //政策种类 item.Order.A7 = AdultPolicy.AirPoint; //航空公司返点 item.Order.A11 = AdultPolicy.PatchPonit; //补点 ////计算订单金额 //item.Order.PayMoney = d.CreateOrderPayMoney(item.Order, item.PasList); ////出票方收款金额 //item.Order.OrderMoney = d.CreateOrderOrderMoney(item.Order, item.PasList); bill.CreateOrderAndTicketPayDetailNew(item.Order, item.PasList); //出票Office if (AdultPolicy.PolicyOffice != "") { item.Order.PrintOffice = AdultPolicy.PolicyOffice; } if ((item.Order.OrderSourceType == 1 || item.Order.OrderSourceType == 2)) { //自动授权Office if (AdultPolicy.PolicyOffice.Trim().Length == 6 && !GYOffice.Contains(AdultPolicy.PolicyOffice.Trim().ToUpper())) { SendIns.AuthToOffice(item.Order.PNR, AdultPolicy.PolicyOffice, item.Order.Office, out ErrMsg); } //备注HU的A舱要添加一个指令才能入库,OSI HU CKIN SSAC/S1 if (AdultPolicy.PolicySource == "1" && AdultPolicy.PolicyType == "1" && AdultPolicy.AutoPrintFlag == "2" && item.Order.PNR.Trim().Length == 6 && item.Order.CarryCode.ToUpper().Trim() == "HU" && item.Order.Space.ToUpper().Trim() == "A") { string Office = item.Order.Office, Cmd = string.Format("RT{0}|OSI HU CKIN SSAC/S1^\\", item.Order.PNR.Trim()); SendIns.Send(Cmd, ref Office, 10); } } if (item.Order.PolicySource <= 2) { //本地政策提示 sbTip.Append("</br><ul><li>1.请于一小时内支付此订单,未支付将自动取消</li><li>2.编码内容中必须存在证件内容一项</li><li>3.PNR需要包含证件号</li><li>" + (IsINFCheck ? "4." + INFCountCheckMsg : "") + "</li></ul>"); } else { //接口和共享政策提示 if (AdultPolicy.PolicyOffice.Trim().Length == 6) { sbTip.Append("</br><ul><li>1.编码内容中必须存在证件内容一项</li><li>2.PNR需要包含证件号</li><li>3.请授权,授权指令:RMK TJ AUTH " + AdultPolicy.PolicyOffice + "</li>" + (IsINFCheck ? "4." + INFCountCheckMsg : "") + "</ul>"); } else { sbTip.Append("<ul ><li>1.编码内容中必须存在证件内容一项!</li><li>2.PNR需要包含证件号!</li>" + (IsINFCheck ? "3." + INFCountCheckMsg : "") + "</ul>"); } } #endregion } else { if (ChildPolicy != null) { #region 儿童实体赋值 //儿童订单政策 //儿童价格 decimal PMFee = ChildPolicy.SeatPrice, ABFare = ChildPolicy.ABFare, RQFare = ChildPolicy.RQFare; //乘机人实体处理 for (int j = 0; j < item.PasList.Count; j++) { if (item.PasList[j].PassengerType == 2) { //儿童 item.PasList[j].PMFee = PMFee; item.PasList[j].ABFee = ABFare; item.PasList[j].FuelFee = RQFare; //订单价格 TotalPMPrice += item.PasList[j].PMFee; TotalABFare += item.PasList[j].ABFee; TotalRQFare += item.PasList[j].FuelFee; } } //航段实体处理 //string Discount = "0"; for (int k = 0; k < item.SkyList.Count; k++) { item.SkyList[k].ABFee = ABFare; item.SkyList[k].FuelFee = RQFare; //只是单程才重新赋值 if (item.SkyList.Count == 1) { item.SkyList[k].SpacePrice = PMFee; } //Discount = ChildPolicy.DiscountRate.ToString(); //if (Discount.Length > 10) //{ // Discount = Discount.Substring(0, 10); //} //item.SkyList[k].Discount = Discount; } //儿童订单赋值 item.Order.PMFee = TotalPMPrice; item.Order.ABFee = TotalABFare; item.Order.FuelFee = TotalRQFare; //出票公司编号 string CPCpyNo = string.IsNullOrEmpty(ChildPolicy.CPCpyNo) ? userLogin.mSupCompany.UninCode : ChildPolicy.CPCpyNo; item.Order.CPCpyNo = CPCpyNo.Length > 12 ? CPCpyNo.Substring(0, 12) : CPCpyNo; item.Order.PolicyId = ChildPolicy.PolicyId; item.Order.AirPoint = ChildPolicy.AirPoint; item.Order.PolicyPoint = ChildPolicy.PolicyPoint; item.Order.ReturnPoint = ChildPolicy.ReturnPoint; item.Order.LaterPoint = ChildPolicy.LaterPoint; item.Order.ReturnMoney = ChildPolicy.PolicyReturnMoney; item.Order.PolicyMoney = ChildPolicy.PolicyYongJin; item.Order.DiscountDetail = ChildPolicy.DiscountDetail; item.Order.PolicyType = int.Parse(ChildPolicy.PolicyType); item.Order.PolicySource = int.Parse(ChildPolicy.PolicySource); item.Order.AutoPrintFlag = int.Parse(ChildPolicy.AutoPrintFlag); item.Order.PolicyCancelTime = ChildPolicy.FPGQTime; item.Order.PolicyReturnTime = ChildPolicy.PolicyReturnTime; item.Order.PolicyRemark = ChildPolicy.PolicyRemark;//政策备注 //原始政策返点 item.Order.OldPolicyPoint = ChildPolicy.OldPolicyPoint; //原始政策现返 item.Order.OldReturnMoney = ChildPolicy.OldPolicyReturnMoney; item.Order.A1 = 1; //已确认 item.Order.A7 = ChildPolicy.AirPoint; //航空公司返点 //政策种类 item.Order.A2 = ChildPolicy.PolicyKind; ////计算订单金额; //item.Order.PayMoney = d.CreateOrderPayMoney(item.Order, item.PasList); ////出票方收款金额 //item.Order.OrderMoney = d.CreateOrderOrderMoney(item.Order, item.PasList); bill.CreateOrderAndTicketPayDetailNew(item.Order, item.PasList); //出票Office if (ChildPolicy.PolicyOffice != "") { item.Order.PrintOffice = ChildPolicy.PolicyOffice; } //--------------------------------------- #endregion } } //代付返点,金额 if (item.Order.PolicySource > 2) { // 接口 取原始政策 item.Order.A7 = item.Order.OldPolicyPoint; item.Order.OutOrderPayMoney = d.CreateOrderIntfacePrice(item.Order, item.PasList); } else { //本地 取航空公司政策 decimal tempOldPolicyPoint = item.Order.OldPolicyPoint; item.Order.OldPolicyPoint = item.Order.A7; item.Order.OutOrderPayMoney = d.CreateOrderIntfacePrice(item.Order, item.PasList); item.Order.OldPolicyPoint = tempOldPolicyPoint; } item.Order.A13 = d.CreateOrderIntfacePrice(item.Order, item.PasList);// 后返金额 #endregion #region 添加订单账单明细sql List <string> sqlList = bill.CreateOrderAndTicketPayDetailNew(item.Order, item.PasList); if (sqlList != null && sqlList.Count > 0) { IsBillOK = true; InputParam.ExecSQLList.AddRange(sqlList.ToArray()); } #endregion }//For结束 //订单金额是否有误 bool IsOrderPayZero = false; foreach (OrderMustParamModel item in InputParam.OrderParamModel) { //判断金额是否正确 if (item.Order.PayMoney <= 0 || ((item.Order.PayMoney + item.Order.PayMoney * 0.003M) < item.Order.OrderMoney)) { IsOrderPayZero = true; PbProject.WebCommon.Log.Log.RecordLog("OrderServices", "PayMoneyError|" + ErrMsg + "订单:PayMoney=" + item.Order.PayMoney + " OrderMoney=" + item.Order.OrderMoney + "SQL:" + string.Join("\r\n ", InputParam.ExecSQLList.ToArray()), true, HttpContext.Current.Request); // DataBase.LogCommon.Log.Error("OrderServices", new Exception(ErrMsg + "订单:PayMoney=" + item.Order.PayMoney + " OrderMoney=" + item.Order.OrderMoney + "SQL:" + string.Join("\r\n ", InputParam.ExecSQLList.ToArray()))); break; } } #region 验证和修改订单 if (!IsBillOK) { ErrMsg = "订单生成失败!!"; PbProject.WebCommon.Log.Log.RecordLog("OrderServices", "时间:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\t" + ErrMsg + "SQL:" + string.Join("\r\n ", InputParam.ExecSQLList.ToArray()), true, HttpContext.Current.Request); } else { if (!IsOrderPayZero) { //修改订单有关实体信息 IsSuc = orderBLL.UpdateOrder(ref InputParam, out ErrMsg); if (IsSuc) { ErrMsg = "订单生成成功!" + sbTip.ToString(); } else { PbProject.WebCommon.Log.Log.RecordLog("OrderServices", "时间:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\t" + ErrMsg + "SQL:" + string.Join("\r\n ", InputParam.ExecSQLList.ToArray()), true, HttpContext.Current.Request); ErrMsg = "订单生成失败!"; } } else { PbProject.WebCommon.Log.Log.RecordLog("OrderServices", "时间:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\t" + ErrMsg + "SQL:" + string.Join("\r\n ", InputParam.ExecSQLList.ToArray()), true, HttpContext.Current.Request); ErrMsg = "订单金额错误,生成订单失败!"; } } #endregion } } else { ErrMsg = "未获取到政策数据,生成订单失败!"; } } catch (Exception ex) { PbProject.WebCommon.Log.Log.RecordLog("OrderServices", "时间:" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\t" + ErrMsg, true, HttpContext.Current.Request); ErrMsg = "订单生成异常," + ex.Message; DataBase.LogCommon.Log.Error("OrderServices" + userLogin.User.id.ToString(), ex); } finally { if (IsSuc) { writer.Write("ok"); } else { writer.WriteEx(567, "confirm Order Error", ErrMsg); } } #endregion } }
public void OnCreateOrder() { //if (_QXValue.Contains("|62|"))//控制是否自动生成订单 //{ List <PbProject.Model.Tb_Ticket_SkyWay> skyList = new PbProject.Logic.Order.Tb_Ticket_SkyWayBLL().GetSkyWayListBySQLWhere("OrderId='" + _order.OrderId + "'"); PnrAnalysis.FormatPNR ss = new PnrAnalysis.FormatPNR(); string RTContent = skyList[0].NewPnrContent.Replace("\r", "").Replace("\t", "").Replace("\n", ""); string PATContent = ss.RemoveHideChar(skyList[0].Pat).Replace("\r", "").Replace("\t", "").Replace("\n", ""); #region 处理高低开 if (!_order.Space.Contains("1"))//不为子舱位 { string bb = ""; PnrAnalysis.PatModel sss = ss.GetPATInfo(skyList[0].NewPnrContent, out bb); if (sss.ChildPat != null) { for (int i = 0; i < sss.PatList.Count; i++) { if (sss.PatList[i].SeatGroup == sss.ChildPat.SeatGroup) { sss.PatList.Remove(sss.PatList[i]); break; } } PatInfo patFirst = sss.PatList[0]; PatInfo patLast = sss.PatList[sss.PatList.Count - 1]; //if (_QXValue.Contains("|60|")) //{ PATContent = ss.NewPatData(patFirst); //} //else //{ // PATContent = ss.NewPatData(patLast); //} bool IsOnePrice = false; RTContent = ss.RemoveChildSeat(RTContent, out IsOnePrice); } } #endregion //OnErrorNew(1, "517开始生成订单", "517生成订单"); DataSet dsReson; dsReson = _yeeXingService.ParsePnrBookContract(_yeeXingAccout, _yeeXingAccout2, _order.PNR, RTContent, PATContent, _order.PolicyId, _order.PMFee.ToString(), _order.OrderId, _order.PolicyPoint.ToString(), _order.ReturnMoney.ToString()); string mesYeeXingCreate = ""; for (int i = 0; i < dsReson.Tables[0].Rows.Count; i++) { for (int j = 0; j < dsReson.Tables[0].Columns.Count; j++) { mesYeeXingCreate = mesYeeXingCreate + dsReson.Tables[0].Columns[i].ColumnName + ":" + dsReson.Tables[0].Rows[i][j].ToString() + "/";//DataTable转化成String类型 } } mesYeeXingCreate = "table's name:" + dsReson.Tables[0].TableName + "/table's content:" + mesYeeXingCreate; CreateLog(_order.OrderId, "预定", mesYeeXingCreate, 1); if (dsReson.Tables[0].Rows[0]["is_success"].ToString() == "F")//生成订单失败,记录日志 { CreateLog(_order.OrderId, "预定", mesYeeXingCreate, 3); } else { CreateLog(_order.OrderId, "预定", "易行生成订单成功!", 3); if (dsReson.Tables[0].Rows[0]["totalPrice"].ToString() == "") { dsReson.Tables[0].Rows[0]["totalPrice"] = "0"; } OnPay(Convert.ToDecimal(dsReson.Tables[0].Rows[0]["totalPrice"].ToString()), dsReson.Tables[0].Rows[0]["orderid"].ToString(), mesYeeXingCreate); } //} }
/// <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); } }
/* BSP常见错误信息 * MRT:HT0LYJ IGNORED * INCOMPLETE PNR/FN * PLEASE CHECK TKT ELEMENT * CHECK BLINK CODE * ELE NBR */ /// <summary> /// BSP订单处理 /// </summary> /// <param name="Order"></param> private void BspHandle(Tb_Ticket_Order Order, List <ListParam> LPList, BSPShowLog Log) { //订单日志 StringBuilder sbLog = new StringBuilder(); if (Order != null) { //订单出票公司信息 ListParam TicketLP = LPList.Find(delegate(ListParam _tempLP) { return(Order.OwnerCpyNo.Contains(_tempLP.CpyNo)); }); //编码解析类 PnrAnalysis.FormatPNR pnrFormat = new PnrAnalysis.FormatPNR(); //判断标识 List <string> NumTickList = new List <string>(); List <string> PTList = null; List <Tb_Ticket_Passenger> PasList = null; try { Log(0, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "订单号:" + Order.OrderId + "=======================start=====================\r\n"); string GYCpyNo = Order.OwnerCpyNo; if (GYCpyNo.Length >= 12) { GYCpyNo = GYCpyNo.Substring(0, 12); } string CarrayCode = Order.CarryCode.Split('/')[0]; Tb_Ticket_PrintOffice PrintOffice = GetPrintOffice(GYCpyNo, CarrayCode); if (PrintOffice == null || PrintOffice.PrintCode == "") { Log(0, string.Format("{0}未设置打票机号,请手动出票!", CarrayCode)); sbLog.Append(string.Format("{0}未设置打票机号,请手动出票!", CarrayCode)); return; } //出票Office string pOffice = string.IsNullOrEmpty(PrintOffice.OfficeCode) ? Order.PrintOffice : PrintOffice.OfficeCode; string PrintCode = PrintOffice.PrintCode; string Pnr = Order.PNR;//Pnr编码 if (pOffice == "") { Log(0, string.Format("{0}出票Office不能为空!", CarrayCode)); sbLog.Append(string.Format("{0}出票Office不能为空!", CarrayCode)); return; } //获取乘客 string sqlWhere = string.Format(" OrderId='{0}' order by PassengerType", Order.OrderId); Tb_Ticket_Passenger pMode = null; PasList = Manage.CallMethod("Tb_Ticket_Passenger", "GetList", null, new object[] { sqlWhere }) as List <Tb_Ticket_Passenger>; if (PasList == null || PasList.Count == 0) { Log(0, string.Format("订单号:{0}没有找到对应的乘客信息!", Order.OrderId)); sbLog.Append(string.Format("订单号:{0}没有找到对应的乘客信息!", Order.OrderId)); return; } else { pMode = PasList[0]; } 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); //指令管理类 //SendInsManage SendManage = new SendInsManage(Order.OwnerCpyNo, GYCpyNo, config); if (config == null) { Log(0, string.Format("订单号{0},公司{1}未设置使用配置信息,请设置!", Order.OrderId, CarrayCode)); sbLog.Append(string.Format("订单号{0},公司{1}未设置使用配置信息,请设置!", Order.OrderId, CarrayCode)); return; } if (string.IsNullOrEmpty(Order.PNR)) { Log(0, string.Format("订单号{0}中没有PNR,请检查!", Order.OrderId)); sbLog.Append(string.Format("订单号{0}中没有PNR,请检查!", Order.OrderId)); return; } ParamObject PM = new ParamObject(); PM.ServerIP = config.WhiteScreenIP; PM.ServerPort = int.Parse(config.WhiteScreenPort); PM.Office = pOffice; //发送指令 string SendIns = "RT" + Pnr; //返回数据 string Recvdata = string.Empty; PM.code = SendIns; PM.IsPn = true; // Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); //授权检查 if (Recvdata.ToUpper().Contains("授权")) { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},发送指令需要授权!", Order.OrderId, Pnr, pOffice)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},发送指令需要授权!", Order.OrderId, Pnr, pOffice)); return; } else if (Recvdata.ToUpper().Contains("CANCELLED")) { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,出票失败!", Order.OrderId, Pnr, pOffice)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,出票失败!", Order.OrderId, Pnr, pOffice)); return; } string Msg = ""; string Xe = "", RR = ""; string PnrStatus = pnrFormat.GetPnrStatus(Recvdata, out Msg); if (PnrStatus.Contains("NO")) { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},不能自动出票!!", Order.OrderId, Pnr, pOffice, PnrStatus)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},不能自动出票!!", Order.OrderId, Pnr, pOffice, PnrStatus)); return; } //存在的票号 PTList = GetTicketNum(Pnr, Recvdata.ToUpper(), pnrFormat); List <string> RRList = null; List <string> XEList = null; if (PTList.Count == 0) { Start: { //进行出票 HashObject hash = GetNumList(Recvdata); XEList = hash["XEList"] as List <string>; RRList = hash["RRList"] as List <string>; List <string> StartXeList = hash["StartXeList"] as List <string>; //XE项 if (StartXeList.Count > 0) { for (int i = 0; i < StartXeList.Count; i++) { string XeStr = StartXeList[i]; if (XeStr != "") { //发送指令 SendIns = "RT" + Pnr + "|XE" + XeStr + "|@"; PM.code = SendIns; PM.IsPn = false; //Recvdata = SendNewPID.SendCommand(PM);//MRT:JG61M2 IGNORED Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); //判断是否XE成功 if (pnrFormat.INFMarkIsOK(Recvdata, out Msg)) { /* 3U8881 E TU30APR CTUPEK HK1 0730 1005 * JG61M2 - 航空公司使用自动出票时限, 请检查PNR *** 预订酒店指令HC, 详情 HC:HELP *** */ //发送指令 SendIns = "RT" + Pnr; PM.code = SendIns; PM.IsPn = true; //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); goto Start; } } } } } string patPrice = "pat:a"; if (!Order.IsChdFlag) { //成人 patPrice = "pat:a"; } else { //儿童 patPrice = "pat:a*ch"; } //发送指令 SendIns = "RT" + Pnr + "|" + patPrice; PM.code = SendIns; PM.IsPn = false; //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); if (Recvdata.IndexOf("PAT") == -1) { //发送指令 Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,未能PAT出票价,出票失败!", Order.OrderId, Pnr, pOffice)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码已取消,未能PAT出票价,出票失败!", Order.OrderId, Pnr, pOffice)); return; } //比较 string xuhao = "", Seat = "", Err = ""; decimal _xsFare = 0m; bool IsExistParice = false; PnrAnalysis.PatModel PAT = pnrFormat.GetPATInfo(Recvdata.Replace("\r", ""), out Err); foreach (PatInfo pat in PAT.UninuePatList) { decimal.TryParse(pat.Fare, out _xsFare); //存在此价格 if (_xsFare == pMode.PMFee) { IsExistParice = true; xuhao = pat.SerialNum; Seat = pat.SeatGroup; break; } } if (!IsExistParice) { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},舱位价{3}与Pat价格{4}不一致,出票失败!", Order.OrderId, Pnr, pOffice, pMode.PMFee, _xsFare)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},舱位价{3}与Pat价格{4}不一致,出票失败!", Order.OrderId, Pnr, pOffice, pMode.PMFee, _xsFare)); return; } //做价格进去 SendIns = "RT" + Pnr + "|" + patPrice + "|SFC:" + xuhao + "|@"; PM.code = SendIns; PM.IsPn = false; //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); if (Recvdata.Contains("超时") || Recvdata.Contains("NO PNR")) { //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); } //做备注 decimal _Discount = 0m; if (decimal.TryParse(Order.Discount, out _Discount) && Order.Space.IndexOf("Y") == -1 && Order.Space.IndexOf("C") == -1 && Order.Space.IndexOf("F") == -1 && _Discount < 100) { //做价格进去 SendIns = "RT" + Pnr + "|EI:不得签转|@"; PM.code = SendIns; PM.IsPn = false; //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); if (Recvdata != "" && Recvdata.Contains("超时")) { //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); } } foreach (string item in XEList) { if (item != "") { Xe += "XE" + item + "|"; } } foreach (string item in RRList) { if (item != "") { RR += item + "RR" + "|"; } } if (Xe.Trim(new char[] { '|' }) == "") { Xe = ""; } else { Xe = "|" + Xe.Trim('|') + "|"; } if (RR.Trim(new char[] { '|' }) == "") { RR = ""; } else { RR = "|" + RR.Trim('|') + "|"; } if (RR == "") { RR = "|"; } if (XEList == null || XEList.Count == 0 || Xe == "") { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},未能取出出票时限!!", Order.OrderId, Pnr, pOffice, PnrStatus)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},未能取出出票时限!!", Order.OrderId, Pnr, pOffice, PnrStatus)); return; } //组合打票指令 string etdz = "rt" + Pnr + Xe + RR.TrimEnd('|') + "|ETDZ " + PrintCode; etdz = etdz.Replace("||", "|"); //出票 SendIns = etdz; PM.code = SendIns; PM.IsPn = false; // Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); if (Recvdata.Contains("超时") || Recvdata.Contains("NO PNR")) { //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); } if (Recvdata.Contains("请输入证件信息")) { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},编码中没有证件号,请输入证件信息,否则不能出票!", Order.OrderId, Pnr, pOffice, PnrStatus)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3},编码中没有证件号,请输入证件信息,否则不能出票!", Order.OrderId, Pnr, pOffice, PnrStatus)); return; } if (Recvdata.ToUpper().Contains("STOCK")) { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + Recvdata + "没有票号了!", Order.OrderId, Pnr, pOffice, PnrStatus)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + Recvdata + "没有票号了!", Order.OrderId, Pnr, pOffice, PnrStatus)); return; } //出票成功 if (Recvdata.Contains("CNY") && Recvdata.ToUpper().Contains(Pnr.ToUpper())) { /*CNY2730.00 HF9550 * 876-3250823439 876-3250823441 */ SendIns = "RT" + Pnr; PM.code = SendIns; PM.IsPn = true; //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); //存在的票号 PTList = GetTicketNum(Pnr, Recvdata.ToUpper(), pnrFormat); } else { //出票失败 重试 if (!Recvdata.ToUpper().Contains("**ELECTRONIC TICKET PNR**") && Recvdata.ToUpper().Contains("SSR TKNE") && Recvdata.ToUpper().Contains("/DPN") && Recvdata.ToUpper().Contains("RMK " + CarrayCode + "/")) { //"ETRY:" 重试指令 SendIns = "RT" + Pnr + "|ETRY:"; PM.code = SendIns; PM.IsPn = false; //Recvdata = SendNewPID.SendCommand(PM); Recvdata = WriteLogDB(PM, TicketLP); //指令日志 Log(0, string.Format("\r\n【订单号{0}】发送指令>{1}\r\n接收数据:\r\n{2}\r\n", Order.OrderId, SendIns, Recvdata)); } else { Log(0, string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + "出票失败,{4}", Order.OrderId, Pnr, pOffice, PnrStatus, Recvdata)); sbLog.Append(string.Format("订单号{0},编码{1} 出票Office{2},编码状态为{3}," + "出票失败,{4}", Order.OrderId, Pnr, pOffice, PnrStatus, Recvdata)); } } } } catch (Exception ex) { Log(0, string.Format("订单号{0},出票异常:{1}", Order.OrderId, ex.Message + ex.Source + ex.StackTrace.ToString())); sbLog.Append(string.Format("订单号{0},出票异常:{1}", Order.OrderId, ex.Message + ex.Source + ex.StackTrace.ToString())); } finally { string TicketMsg = ""; Log_Tb_AirOrder OrderLog = new Log_Tb_AirOrder(); //执行SQl语句 List <string> sqlList = new List <string>(); //修改订单数据列表 List <string> OrderList = new List <string>(); if (TicketLP != null) { //解锁 OrderList.Add(" LockCpyNo='' "); OrderList.Add(" LockLoginName='' "); OrderList.Add(" LockTime='1900-01-01' "); OrderList.Add(" CPTime=getdate() "); OrderList.Add(" CPName='管理员' "); OrderList.Add(string.Format(" CPCpyNo='{0}' ", TicketLP.CpyNo)); OrderList.Add(" CPRemark='BSP自动出票' "); OrderList.Add(string.Format(" CPCpyName='{0}' ", TicketLP.UninAllName)); //日志 OrderLog.id = Guid.NewGuid(); OrderLog.OrderId = Order.OrderId; OrderLog.OperType = "出票"; OrderLog.OperTime = DateTime.Now; OrderLog.OperLoginName = "管理员"; OrderLog.OperUserName = "******"; OrderLog.CpyNo = TicketLP.CpyNo; OrderLog.CpyType = 1; OrderLog.CpyName = TicketLP.UninAllName; } if (PTList != null && PTList.Count > 0 && PasList != null && PasList.Count > 0) { string PasName = "", TicketNumber = ""; for (int i = 0; i < PTList.Count; i++) { if (PTList[i].Split('|').Length == 2) { TicketNumber = PTList[i].Split('|')[0]; PasName = PTList[i].Split('|')[1]; Tb_Ticket_Passenger Passenger = PasList.Find(delegate(Tb_Ticket_Passenger _tempPassenger) { return(PTList[i].ToUpper().Trim().Contains(_tempPassenger.PassengerName.ToUpper().Trim())); }); if (Passenger != null) { sqlList.Add(string.Format(" update Tb_Ticket_Passenger set TicketNumber='{0}',TicketStatus=2 where id='{1}' and PassengerName='{2}' ", TicketNumber, Passenger.id.ToString(), Passenger.PassengerName)); } } } //修改订单数据 OrderList.Add(" TicketStatus=2 "); OrderList.Add(" OrderStatusCode=4 "); if (OrderList.Count > 0) { sqlList.Add(string.Format(" update Tb_Ticket_Order set {0} where id='{1}' ", string.Join(",", OrderList.ToArray()), Order.id.ToString())); } //出票成功 TicketMsg = "出票成功"; OrderLog.WatchType = 5; //日志 OrderLog.OperContent = "订单号:" + Order.OrderId + " BSP自动出票成功," + string.Format(",", PasList.ToArray()); //修改数据库状态 } else { //出票失败 TicketMsg = "出票失败"; //修改订单自动出票尝试次数 if (Order.AutoPrintTimes > 3)//尝试次数大于3改为手动出票 { sqlList.Add(string.Format(" update Tb_Ticket_Order set AutoPrintFlag=0,AutoPrintTimes=CAST(AutoPrintTimes as int)+1 where id='{0}' ", Order.id.ToString())); } else { sqlList.Add(string.Format(" update Tb_Ticket_Order set AutoPrintTimes=CAST(AutoPrintTimes as int)+1 where id='{0}' ", Order.id.ToString())); } OrderLog.WatchType = 2; //日志 OrderLog.OperContent = "BSP自动出票失败," + sbLog.ToString(); } //日志 string tempSql = Dal.Mapping.MappingHelper <Log_Tb_AirOrder> .CreateInsertModelSql(OrderLog); sqlList.Add(tempSql); string Msg = ""; //修改数据库 if (!Manage.ExecuteSqlTran(sqlList, out Msg)) { Log(0, string.Format("订单号{0},修改数据库失败:{1}", Order.OrderId, Msg)); } Log(0, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "订单号:" + Order.OrderId + " " + TicketMsg + "=======================end=====================\r\n"); } } }