public PatInfo GetINFPAT() { string strPrice = "0|0|0@0|0|0@0|0|0"; string[] strArr = strPrice.Split('@'); PatInfo pat = null; if (strArr.Length > 0) { string[] strData = strArr[0].Split('|'); if (strData.Length == 3) { pat = new PatInfo(); decimal SeatPrice = 0m, ABFare = 0m, RQFare = 0m; decimal.TryParse(strData[0], out SeatPrice); decimal.TryParse(strData[1], out ABFare); decimal.TryParse(strData[2], out RQFare); pat.Fare = strData[0]; pat.TAX = strData[1]; pat.RQFare = strData[2]; pat.Price = (SeatPrice + ABFare + RQFare).ToString(); pat.PriceType = "3"; } } return(pat); }
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); } } //} }
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="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 Order CreateOrderByPnrContent(Order order, string pnrContent, EnumPnrImportType PnrImportType, CreateOrderParam OrderParam, string businessmanCode, string CarrierCode, string businessmanName, string account, bool IsChangePnrTicket) { #region 验证PNR if (pnrContent.ToUpper().Contains("NO PNR")) { pnrContent = pnrContent.ToUpper().Replace("NO PNR", ""); } FormatPNR format = new FormatPNR(); if (format.GetPnrContentByteLength(pnrContent) > 2000) { throw new PnrAnalysisFailException("RT和PAT内容长度超出范围[0-2000]个字符,请去掉多余的空格,再导入!"); } if (pnrContent.Trim().Contains("授权")) { throw new PnrAnalysisFailException(pnrContent); } if (pnrContent.Trim().Contains("数据包不完整")) { throw new PnrAnalysisFailException(pnrContent); } string Msg = ""; PnrModel pnrMode = null; PatModel patMode = null; PatModel infPatMode = null; string Pnr = string.Empty; PnrAnalysis.Model.SplitPnrCon splitPnrCon = null; //PNR内容导入 if (OrderParam == null) { splitPnrCon = format.GetSplitPnrCon(pnrContent); string RTCon = splitPnrCon.RTCon; string PatCon = splitPnrCon.AdultPATCon != string.Empty ? splitPnrCon.AdultPATCon : splitPnrCon.ChdPATCon; if (string.IsNullOrEmpty(PatCon) || string.IsNullOrEmpty(RTCon) || !PatCon.Contains("PAT:A")) { throw new PnrAnalysisFailException("RT和PAT内容不能为空!"); } //去重复和备注 string pnrRemark = string.Empty; RTCon = format.DelRepeatRTCon(RTCon, ref pnrRemark); if (!string.IsNullOrEmpty(pnrRemark)) { PatCon = PatCon.Replace(pnrRemark, ""); } pnrContent = RTCon + "\r\n" + PatCon; Pnr = format.GetPNR(RTCon, out Msg); if (string.IsNullOrEmpty(Pnr) || !format.IsPnr(Pnr)) { throw new PnrAnalysisFailException("PNR内容提取编码失败,请检查编码内容!"); } pnrMode = format.GetPNRInfo(Pnr, RTCon, false, out Msg); if (pnrMode == null || pnrMode._LegList.Count == 0) { throw new PnrAnalysisFailException("PNR内容解析航段信息失败,请检查编码内容"); } //成人或者儿童PAT patMode = format.GetPATInfo(PatCon, out Msg); if (PnrImportType == EnumPnrImportType.PnrContentImport) { if (pnrMode._PasType == "2") { throw new PnrAnalysisFailException("该编码【" + Pnr + "】为儿童编码,请选择“儿童编码”通道导入!"); } } else if (PnrImportType == EnumPnrImportType.GenericPnrImport) { if (pnrMode._PasType == "2") { throw new PnrAnalysisFailException("该编码【" + Pnr + "】为儿童编码,请选择“儿童编码”通道导入!"); } } } else { PnrData pnrData = OrderParam.pnrData; if (pnrData == null) { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:预定内容有误!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:PNR内容解析失败!"); } } //订座失败,请重新预定!失败原因:预定内容有误! //导入失败,请重新导入!失败原因:[PnrData]PNR内容解析失败,PnrData Fail! pnrMode = pnrData.PnrMode; patMode = pnrData.PatMode; infPatMode = pnrData.InfPatMode; Pnr = order.OrderType == 0 ? pnrData.AdultPnr : pnrData.ChdPnr; if (pnrMode == null || pnrMode._LegList.Count == 0) { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:预定航段内容有误!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:解析编码航段内容有误!"); } } //订座失败,请重新预定!失败原因:预定航段内容有误! //导入失败,请重新导入!失败原因:解析编码航段内容有误! } if (!pnrMode.PnrConIsOver) { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:预定内容有误!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:编码内容信息有误,RT编码内容需以Office号结尾,请检查编码内容!"); } } //订座失败,请重新预定!失败原因:预定内容有误! //导入失败,请重新导入!失败原因:编码内容信息有误,RT编码内容需以Office号结尾,请检查编码内容! if (pnrMode.PnrStatus.Trim() == "") { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:解析出编码状态有误!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:解析出编码状态有误,请检查编码内容!"); } } //订座失败,请重新预定!失败原因:解析出编码状态有误! //导入失败,请重新导入!失败原因:解析出编码状态有误,请检查编码内容 if (pnrMode.PnrStatus.Contains("XX") || pnrMode.PnrStatus.Contains("NO") || pnrMode.PnrStatus.Contains("HL") || pnrMode.PnrStatus.Contains("HN") ) { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:编码状态有误,状态为:" + pnrMode.PnrStatus + "!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:编码状态有误,状态为XX,NO,HL,HN项不能导入!"); } //订座失败,请重新预定!失败原因:编码状态有误,状态为:“+pnrMode.PnrStatus+”! //导入失败,请重新导入!失败原因:编码状态有误,状态为XX,NO,HL,HN项不能导入! } else if (!pnrMode.PassengerNameIsCorrent && pnrMode.ErrorPassengerNameList.Count > 0)//乘机人名字检查 { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!"); } } //订座失败,请重新预定!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!"); //导入失败,请重新导入!失败原因:乘机人名字(" + string.Join(",", pnrMode.ErrorPassengerNameList.ToArray()) + ")有误,请检查乘客姓名,生僻字用拼音代替!"); else if (!pnrMode.PnrConHasFirstNum)//乘客姓名序号是否已1开始 { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容!"); } } //订座失败,请重新预定!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容! //导入失败,请重新导入!失败原因:PNR内容中乘客姓名序号项不规范,请检查编码内容! //else if (string.IsNullOrEmpty(pnrMode._BigPnr)) // throw new PnrAnalysisFailException("编码[" + Pnr + "]PNR内容中没有大编码,请补齐大编码后导入!"); //else if (pnrMode.HasExistNoSsr) // throw new PnrAnalysisFailException("编码内容中乘客证件号不全,请补全证件号!"); //else if (pnrMode.SsrIsRepeat) // throw new PnrAnalysisFailException("编码内容中乘客证件号重复,请检查PNR内容证件号!"); else if (pnrMode.TravelType > 3) { if (PnrImportType == EnumPnrImportType.WhiteScreenDestine) { throw new PnrAnalysisFailException("订座失败,请重新预定!失败原因:系统暂不支持缺口程和多程航段!"); } else { throw new PnrAnalysisFailException("导入失败,请重新导入!失败原因:系统暂不支持缺口程和多程航段!"); } } //订座失败,请重新预定!失败原因:系统暂不支持缺口程和多程航段! //导入失败,请重新导入!失败原因:系统暂不支持缺口程和多程航段! //JD导入 验证 if (pnrMode._CarryCode.ToUpper().Contains("JD")) { bool JDIsPass = true; //编码中成人 儿童 婴儿 个数 int adultNum = 0, childNum = 0, YNum = 0; foreach (PassengerInfo item in pnrMode._PassengerList) { if (item.PassengerType == "1") { adultNum++; } if (item.PassengerType == "2") { childNum++; } if (item.PassengerType == "3") { YNum++; } } bool b1 = adultNum == 1 && childNum == 0 && YNum == 0; bool b2 = adultNum == 0 && childNum == 1 && YNum == 0; bool b3 = adultNum == 1 && childNum == 1 && YNum == 0; bool b4 = adultNum == 1 && childNum == 1 && YNum == 1; bool b5 = adultNum == 1 && childNum == 0 && YNum == 1; if (!(b1 || b2 || b3 || b4 || b5)) { JDIsPass = false; } if (!JDIsPass) { throw new PnrAnalysisFailException("JD航空编码【" + Pnr + "】中只能有一个成人,一个儿童,一个婴儿,请手动处理编码内容!"); } } decimal TicketPrice = 0m, INFTicketPrice = 0m; decimal SeatPrice = 0m, TaxFare = 0m, RQFare = 0m; decimal INFSeatPrice = 0m, INFTaxFare = 0m, INFRQFare = 0m; if (patMode == null || patMode.UninuePatList.Count == 0) { throw new PnrAnalysisFailException("PAT解析价格失败"); } if (patMode.IsOverMaxPrice) { throw new PnrAnalysisFailException("PAT支付价格超出范围!"); } //默认取低价 PatInfo pat = order.IsLowPrice ? patMode.UninuePatList[0] : patMode.UninuePatList[patMode.UninuePatList.Count - 1]; decimal.TryParse(pat.Price, out TicketPrice); decimal.TryParse(pat.Fare, out SeatPrice); decimal.TryParse(pat.TAX, out TaxFare); decimal.TryParse(pat.RQFare, out RQFare); if (SeatPrice <= 0) { throw new PnrAnalysisFailException("舱位价不能小于等于0"); } if (TicketPrice <= 0) { throw new PnrAnalysisFailException("PAT总价不能小于等于0"); } //PNR内容导入 if (OrderParam == null) { if (pnrMode.HasINF && !string.IsNullOrEmpty(splitPnrCon.INFPATCon.Trim())) //如果有婴儿 { if (string.IsNullOrEmpty(splitPnrCon.INFPATCon) || !splitPnrCon.INFPATCon.Contains("PAT:A*IN")) { throw new PnrAnalysisFailException("编码中含有婴儿,为获取到婴儿的PAT价格信息!"); } infPatMode = format.GetPATInfo(splitPnrCon.INFPATCon, out Msg); if (infPatMode == null || infPatMode.UninuePatList.Count == 0) { throw new PnrAnalysisFailException("婴儿PAT解析价格失败"); } //默认取低价 PatInfo patInf = order.IsLowPrice ? infPatMode.UninuePatList[0] : infPatMode.UninuePatList[infPatMode.UninuePatList.Count - 1]; decimal.TryParse(patInf.Price, out INFTicketPrice); decimal.TryParse(patInf.Fare, out INFSeatPrice); decimal.TryParse(patInf.TAX, out INFTaxFare); decimal.TryParse(patInf.RQFare, out INFRQFare); if (INFTicketPrice <= 0) { throw new PnrAnalysisFailException("婴儿舱位价不能小于等于0"); } if (INFTicketPrice <= 0) { throw new PnrAnalysisFailException("婴儿PAT总价不能小于等于0"); } pnrContent = pnrContent + "\r\n" + splitPnrCon.INFPATCon; } } else { if (pnrMode != null && pnrMode.HasINF && infPatMode != null) //如果有婴儿 { if (infPatMode == null || infPatMode.UninuePatList.Count == 0) { throw new PnrAnalysisFailException("婴儿PAT解析价格失败"); } //默认取低价 PatInfo patInf = order.IsLowPrice ? infPatMode.UninuePatList[0] : infPatMode.UninuePatList[infPatMode.UninuePatList.Count - 1]; decimal.TryParse(patInf.Price, out INFTicketPrice); decimal.TryParse(patInf.Fare, out INFSeatPrice); decimal.TryParse(patInf.TAX, out INFTaxFare); decimal.TryParse(patInf.RQFare, out INFRQFare); if (INFTicketPrice <= 0) { throw new PnrAnalysisFailException("婴儿舱位价不能小于等于0"); } if (INFTicketPrice <= 0) { throw new PnrAnalysisFailException("婴儿PAT总价不能小于等于0"); } } } if (TicketPrice <= 0) { throw new PnrAnalysisFailException("票面总价不能小于等于0"); } #endregion //构造数据 double FlyAdvanceTime = 1;// SettingSection.GetInstances().Cashbag.FlyAdvanceTime; double.TryParse(System.Configuration.ConfigurationManager.AppSettings["FlyAdvanceTime"].ToString(), out FlyAdvanceTime); order.PnrCode = Pnr; order.BigCode = pnrMode._BigPnr; order.OrderType = pnrMode._PasType == "1" ? 0 : 1; order.PnrType = pnrMode._PnrType == "1" ? 0 : 1; order.Remark = ""; order.TicketPrice = TicketPrice; order.INFTicketPrice = INFTicketPrice; order.BusinessmanCode = businessmanCode; order.BusinessmanName = businessmanName; order.CarrierCode = CarrierCode; order.OperatorAccount = account; order.CreateTime = DateTime.Now; order.PnrContent = pnrContent; order.HasAfterSale = false; order.YdOffice = pnrMode._Office; decimal defaultOrderMoney = 0m; bool HaveBabyFlag = false; List <SkyWay> SkyWays = new List <SkyWay>(); List <Passenger> Passengers = new List <Passenger>(); if (OrderParam == null) { DateTime tempStartTime = System.DateTime.Now; string Seat = string.Empty; //内容导入 foreach (var leg in pnrMode._LegList) { Seat = leg.Seat; //如果有子舱位就用子舱位 if (!string.IsNullOrEmpty(leg.ChildSeat) && leg.ChildSeat.Trim().Length == 2) { Seat = leg.ChildSeat.Trim(); } SkyWays.Add(new SkyWay() { FromCityCode = leg.FromCode, ToCityCode = leg.ToCode, FlightNumber = leg.FlightNum, StartDateTime = DateTime.Parse(leg.FlyDate1 + " " + leg.FlyStartTime.Insert(2, ":") + ":00"), ToDateTime = DateTime.Parse(leg.FlyDateE + " " + leg.FlyEndTime.Insert(2, ":") + ":00"), CarrayCode = leg.AirCode, Seat = Seat, FromTerminal = getHZL(leg.FromCode, leg.AirCode, leg.FromCityT1), ToTerminal = getHZL(leg.ToCode, leg.AirCode, leg.ToCityT2), Discount = baseQuery.GetZK(leg.FromCode, leg.ToCode, leg.AirCode, leg.Seat, SeatPrice) }); } tempStartTime = SkyWays[0].StartDateTime.AddHours(-FlyAdvanceTime); if (DateTime.Compare(tempStartTime, System.DateTime.Now) <= 0) { //起飞时间小于预定时间 已起飞 已失效 不能导入 throw new PnrAnalysisFailException("航班起飞前" + FlyAdvanceTime + "小时内不能导入编码内容!"); } foreach (var pas in pnrMode._PassengerList) { if (pas.PassengerType == "3") { Passengers.Add(new Passenger() { PassengerName = pas.PassengerName, CardNo = pas.SsrCardID, SeatPrice = INFSeatPrice, ABFee = INFTaxFare, RQFee = INFRQFare, PassengerType = EnumPassengerType.Baby, TicketStatus = EnumTicketStatus.Unknown, Mobile = pas.PassengerTel, }); defaultOrderMoney += INFSeatPrice + INFTaxFare + INFRQFare; HaveBabyFlag = true; } else { Passengers.Add(new Passenger() { PassengerName = pas.PassengerName, CardNo = pas.SsrCardID, SeatPrice = SeatPrice, ABFee = TaxFare, RQFee = RQFare, PassengerType = (EnumPassengerType)pas.PassengerType.ToInt(), TicketStatus = EnumTicketStatus.Unknown, Mobile = pas.PassengerTel }); defaultOrderMoney += SeatPrice + TaxFare + RQFare; } } } else { //是否儿童订单 bool IsChdOrder = false; foreach (PassengerDto pas in OrderParam.PassengerDtos) { if (pas.PassengerType == EnumPassengerType.Baby) { Passengers.Add(new Passenger() { PassengerName = pas.PassengerName, CardNo = pas.CardNo, SeatPrice = INFSeatPrice, ABFee = INFTaxFare, RQFee = INFRQFare, PassengerType = EnumPassengerType.Baby, TicketStatus = EnumTicketStatus.Unknown, Mobile = pas.Mobile, IdType = pas.IdType, SexType = pas.SexType, Birth = pas.Birth }); defaultOrderMoney += INFSeatPrice + INFTaxFare + INFRQFare; HaveBabyFlag = true; } else { IsChdOrder = pas.PassengerType == EnumPassengerType.Child ? true : false; Passengers.Add(new Passenger() { PassengerName = pas.PassengerName, CardNo = pas.CardNo, SeatPrice = SeatPrice, ABFee = TaxFare, RQFee = RQFare, PassengerType = pas.PassengerType, TicketStatus = EnumTicketStatus.Unknown, Mobile = pas.Mobile, IdType = pas.IdType, SexType = pas.SexType, Birth = pas.Birth }); defaultOrderMoney += SeatPrice + TaxFare + RQFare; } } List <LegInfo> legInfo = pnrMode._LegList; //白屏预定 int i = 0; foreach (SkyWayDto leg in OrderParam.SkyWayDtos) { string strSeat = leg.Seat; //处理儿童的舱位问题 if (IsChdOrder) { if (!"FCY".Contains(leg.Seat.ToUpper())) { if (legInfo[0].Seat.Trim().ToUpper() != leg.Seat.Trim().ToUpper()) { strSeat = "Y"; } } } else { //如果有子舱位就用子舱位 if (legInfo.Count > i && !string.IsNullOrEmpty(legInfo[i].ChildSeat) && legInfo[i].ChildSeat.Trim().Length == 2) { strSeat = legInfo[i].ChildSeat.Trim(); } } SkyWays.Add(new SkyWay() { FromCityCode = leg.FromCityCode, ToCityCode = leg.ToCityCode, FlightNumber = leg.FlightNumber, StartDateTime = leg.StartDateTime, ToDateTime = leg.ToDateTime, CarrayCode = leg.CarrayCode, Seat = strSeat, FromTerminal = leg.FromTerminal, ToTerminal = leg.ToTerminal, Discount = leg.Discount, FlightModel = leg.FlightModel }); i++; } } order.SkyWays = SkyWays; order.Passengers = Passengers; order.OrderMoney = defaultOrderMoney; order.HaveBabyFlag = HaveBabyFlag; //是否换编码出票 order.IsChangePnrTicket = IsChangePnrTicket; //order.Policy = new Policy(); order.OrderPay = new OrderPay() { PaidStatus = EnumPaidStatus.NoPaid, PayStatus = EnumPayStatus.NoPay, OrderId = order.OrderId }; order.ChangeStatus(EnumOrderStatus.WaitChoosePolicy); //订单日志 order.WriteLog(new OrderLog() { OperationDatetime = System.DateTime.Now, OperationPerson = account, Remark = "", OperationContent = "生成订单", IsShowLog = true }); return(order); }