/// <summary> /// 复制差旅订单 /// </summary> /// <param name="copyFltOrderModel"></param> /// <returns></returns> public int CopyOrder(CopyFltOrderModel copyFltOrderModel) { FltOrderEntity copyFromOrderEntity = _fltOrderDal.Find <FltOrderEntity>(copyFltOrderModel.CopyFromOrderId); if (copyFromOrderEntity == null) { throw new Exception("复制来源订单异常"); } List <FltFlightEntity> copyFromFlightEntities = _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true).ToList(); List <FltPassengerEntity> copyFromPassengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true) .ToList(); List <FltTicketNoEntity> copyFromTicketNoEntities = _fltTicketNoDal.Query <FltTicketNoEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true) .ToList(); FltOrderUnionEntity copyFromOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(copyFltOrderModel.CopyFromOrderId); FltCorpCostCenterEntity copyFromCostCenterEntity = _fltCorpCostCenterDal.Find <FltCorpCostCenterEntity>(copyFltOrderModel.CopyFromOrderId); FltOrderEntity fltOrderEntity = Mapper.Map <FltOrderEntity, FltOrderEntity>(copyFromOrderEntity); FltOrderUnionEntity fltOrderUnionEntity = Mapper.Map <FltOrderUnionEntity, FltOrderUnionEntity>(copyFromOrderUnionEntity); FltCorpCostCenterEntity fltCorpCostCenterEntity = Mapper.Map <FltCorpCostCenterEntity, FltCorpCostCenterEntity>(copyFromCostCenterEntity); List <FltFlightEntity> fltFlightEntities = Mapper.Map <List <FltFlightEntity>, List <FltFlightEntity> >(copyFromFlightEntities); List <FltPassengerEntity> fltPassengerEntities = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerEntity> >(copyFromPassengerEntities); List <FltTicketNoEntity> fltTicketNoEntities = Mapper.Map <List <FltTicketNoEntity>, List <FltTicketNoEntity> >(copyFromTicketNoEntities); fltOrderEntity.Payamount = copyFltOrderModel.PayAmount; fltOrderEntity.CreditcardfeeAmount = copyFltOrderModel.CreditCardfeeamount; fltOrderEntity.Voucheramount = copyFltOrderModel.Voucheramount; fltOrderEntity.SendTicketAmount = copyFltOrderModel.SendTicketamount; fltOrderEntity.Totalamount = fltOrderEntity.Payamount + fltOrderEntity.CreditcardfeeAmount; fltOrderEntity.CreateOid = copyFltOrderModel.CreateOid; if (string.IsNullOrEmpty(fltOrderEntity.Remark)) { fltOrderEntity.Remark = "无"; } fltOrderEntity.ReturnAccountOid = ""; fltOrderEntity.ReturnAccountTime = null; fltOrderEntity.OutTicketStatus = "N"; fltOrderEntity.ProcessStatus = 1; fltOrderEntity.Orderstatus = "P"; if (string.IsNullOrEmpty(fltOrderEntity.Description)) { fltOrderEntity.Description = ","; } if (string.IsNullOrEmpty(fltOrderEntity.IsOnLinePay)) { fltOrderEntity.IsOnLinePay = "F"; } if (string.IsNullOrEmpty(fltOrderEntity.SendTicketType)) { fltOrderEntity.SendTicketType = SendTicketTypeEnum.Not.ToString(); } fltOrderEntity.RealAcceptDatetime = null; fltOrderEntity.RealPayDatetime = null; fltOrderEntity.Collectiontime = null; fltOrderEntity.CollectionOid = string.Empty; fltOrderEntity.PrintTicketOid = null; fltOrderEntity.PrintTicketTime = null; fltOrderEntity.PrintOrderTime = null; if (copyFltOrderModel.CopyType == "X")//虚出复制 { //判断当前原始订单是否有虚退 int xuTuiCount = _fltRetModApplyDal.Query <FltRetModApplyEntity>( n => n.OrderType.ToUpper() == "R" && n.OrderId == copyFltOrderModel.CopyFromOrderId && n.OrderStatus.ToUpper() != "C" && n.RefundType == "虚退").Count(); if (xuTuiCount == 0) { throw new Exception("当前订单不存在虚退,不允许虚退复制"); } fltOrderEntity.OrderDate = copyFromOrderEntity.OrderDate; fltOrderEntity.CopyType = "X"; //如果当前原始订单不是虚退复制的订单 if (string.IsNullOrEmpty(copyFromOrderEntity.CopyType)) { fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId; } else { if (copyFromOrderEntity.CopyType == "X" && copyFromOrderEntity.CopyFromOrderId.HasValue) { fltOrderEntity.CopyFromOrderId = copyFromOrderEntity.CopyFromOrderId; } else { fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId; } } } else { fltOrderEntity.CopyType = "C"; fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId; fltOrderEntity.OrderDate = DateTime.Now; } fltOrderEntity = _fltOrderDal.Insert(fltOrderEntity); if (fltOrderUnionEntity != null) { fltOrderUnionEntity.OrderId = fltOrderEntity.OrderId; fltOrderUnionEntity.FivePrintId = null; fltOrderUnionEntity.FivePrintLastTime = null; fltOrderUnionEntity.IsNeedPrintTime = null; if (string.IsNullOrEmpty(fltOrderUnionEntity.IsMobile)) { fltOrderUnionEntity.IsMobile = "F"; } _fltOrderUnionDal.Insert(fltOrderUnionEntity); } foreach (var fltFlightEntity in fltFlightEntities) { CopyFltFlightModel copyFltFlightModel = copyFltOrderModel.FlightList.Find(n => n.Sequence == fltFlightEntity.Sequence); if (string.IsNullOrEmpty(fltFlightEntity.RecordNo)) { fltFlightEntity.RecordNo = "AAAAAA"; } fltFlightEntity.OrderId = fltOrderEntity.OrderId; fltFlightEntity.Sequence = copyFltFlightModel.Sequence; fltFlightEntity.OilFee = copyFltFlightModel.OilFee; fltFlightEntity.Rate = copyFltFlightModel.Rate; fltFlightEntity.SalePrice = copyFltFlightModel.SalePrice; fltFlightEntity.TaxFee = copyFltFlightModel.TaxFee; if (string.IsNullOrEmpty(fltFlightEntity.Airportson)) { fltFlightEntity.Airportson = "----"; } _fltFlightDal.Insert(fltFlightEntity); } foreach (var fltPassengerEntity in fltPassengerEntities) { fltPassengerEntity.OrderId = fltOrderEntity.OrderId; if (string.IsNullOrEmpty(fltPassengerEntity.Remark)) { fltPassengerEntity.Remark = "无"; } _fltPassengerDal.Insert(fltPassengerEntity); } if (fltTicketNoEntities != null && fltTicketNoEntities.Count > 0) { foreach (var fltTicketNoEntity in fltTicketNoEntities) { fltTicketNoEntity.OrderId = fltOrderEntity.OrderId; _fltTicketNoDal.Insert(fltTicketNoEntity); } } if (fltCorpCostCenterEntity != null) { fltCorpCostCenterEntity.Orderid = fltOrderEntity.OrderId; _fltCorpCostCenterDal.Insert <FltCorpCostCenterEntity>(fltCorpCostCenterEntity); } FltOrderLogEntity log = new FltOrderLogEntity() { OrderId = fltOrderEntity.OrderId, LogTime = DateTime.Now, LogType = "新建订单", Remark = "复制订单,来源订单号:" + copyFltOrderModel.CopyFromOrderId + ",马甲订单号:" + fltOrderEntity.CopyFromOrderId, Oid = fltOrderEntity.CreateOid }; _fltOrderLogDal.Insert(log); //将原始订单设置为线上隐藏 if (copyFltOrderModel.CopyType == "X") { copyFromOrderEntity.IsOnlineShow = 1; _fltOrderDal.Update(copyFromOrderEntity, new string[] { "IsOnlineShow" }); } return(fltOrderEntity.OrderId); }
public GetRetApplyModel GetRetApply(GetRetApplyQueryModel query) { FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(query.OrderId); if (fltOrderEntity == null) { throw new Exception("查无此订单"); } if ((fltOrderEntity.ProcessStatus & 8) != 8) { throw new Exception("该订单未出票,不能提交改签申请"); } if (fltOrderEntity.Cid != query.Cid && query.Customer != null && query.Customer.UserID.ToLower() != "administrator") { throw new Exception("查无此订单"); } GetRetApplyModel result = new GetRetApplyModel(); List <FltFlightEntity> flightEntities = _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == query.OrderId).ToList(); List <FltPassengerEntity> passengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == query.OrderId).ToList(); List <FltTicketNoEntity> fltTicketNoEntities = _fltTicketNoDal.Query <FltTicketNoEntity>(n => n.OrderId == query.OrderId).ToList(); List <SearchCityModel> cityModels = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList(); List <SearchAirportModel> airportModels = cityModels.SelectMany(n => n.AirportList).ToList(); List <FltClassNameModel> classNameModels = _getClassNameBll.GetFlightClassName(); /* * 判断是否来回程开在一个票号上 * 如果乘机人的票数=行程数量,则代表分开开;不等于则开在同一票上 * **/ int nameTicketCount = fltTicketNoEntities.FindAll(n => n.PassengerName == passengerEntities[0].Name).Count; int flightCount = flightEntities.Count; bool isSame = (nameTicketCount != flightCount); //是否开在同一票号上 result.FlightList = new List <FltFlightModel>(); result.CName = fltOrderEntity.Cname; result.Mobile = fltOrderEntity.Mobile; result.Email = fltOrderEntity.Email; result.Cid = fltOrderEntity.Cid; result.CorpAduitId = fltOrderEntity.CorpAduitId; result.CorpPolicyId = fltOrderEntity.CorpPolicyId; result.FlightList = Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >(flightEntities); result.FlightList.ForEach(n => { SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == n.Dport.ToLower()); if (airportModel != null) { n.DportName = airportModel.AirportLongName; SearchCityModel cityModel = cityModels.Find(x => x.CityCode.ToLower() == airportModel.CityCode.ToLower()); n.DportCity = cityModel.CityName; } SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == n.Aport.ToLower()); if (airportModel2 != null) { n.AportName = airportModel2.AirportLongName; SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower()); n.AportCity = cityModel2.CityName; } FltClassNameModel classNameModel = classNameModels.Find( x => !string.IsNullOrEmpty(x.MClass) && !string.IsNullOrEmpty(n.Class) && x.MClass.ToLower() == n.Class.ToLower() && !string.IsNullOrEmpty(x.AirlineCode) && !string.IsNullOrEmpty(n.AirlineNo) && x.AirlineCode.ToLower() == n.AirlineNo.ToLower()); if (classNameModel != null) { n.ClassName = classNameModel.ClassName; n.ClassEnName = classNameModel.ClassEnName; } }); List <FltPassengerModel> fltPassengerModels = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >(passengerEntities); result.PassengerList = new List <FltPassengerModel>(); foreach (var ticketNo in fltTicketNoEntities) { FltPassengerModel fltPassengerModel2 = fltPassengerModels.Find(n => n.Name == ticketNo.PassengerName); FltPassengerModel fltPassengerModel = Mapper.Map <FltPassengerModel, FltPassengerModel>(fltPassengerModel2); fltPassengerModel.RetApplyTicketNo = ticketNo.AirlineNo + "-" + ticketNo.TicketNo; if (isSame) { #region 开同一票号的行程 List <string> dportList = result.FlightList.Select(n => n.Dport).ToList(); List <string> aportList = result.FlightList.Select(n => n.Aport).ToList(); List <string> lineList = new List <string>(); List <string> lineList2 = new List <string>(); for (int i = 0; i < dportList.Count; i++) { string dport = dportList[i]; string aport = aportList[i]; SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == dport.ToLower()); SearchCityModel cityModel = cityModels.Find(n => n.CityCode.ToLower() == airportModel.CityCode.ToLower()); SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == aport.ToLower()); SearchCityModel cityModel2 = cityModels.Find(n => n.CityCode.ToLower() == airportModel2.CityCode.ToLower()); lineList.Add(cityModel.CityName + "-" + cityModel2.CityName); lineList2.Add(dport + "-" + aport); } fltPassengerModel.RetApplyFlightLine = Convert(lineList); fltPassengerModel.RetApplyDAportList = lineList2; fltPassengerModel.RetApplySequence = 1; fltPassengerModel.RetApplyFlightNo = result.FlightList.Select(n => n.FlightNo).ToList().FirstOrDefault(); #endregion } else { #region 没有开在同一票号 var flight = result.FlightList.Find(n => n.Sequence == ticketNo.Sequence); SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == flight.Dport.ToLower()); SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == flight.Aport.ToLower()); if (airportModel != null && airportModel2 != null) { SearchCityModel cityModel = cityModels.Find(n => n.CityCode.ToLower() == airportModel.CityCode.ToLower()); SearchCityModel cityModel2 = cityModels.Find(n => n.CityCode.ToLower() == airportModel2.CityCode.ToLower()); fltPassengerModel.RetApplyFlightLine = cityModel.CityName + "-" + cityModel2.CityName; } fltPassengerModel.RetApplyDAportList = new List <string>() { flight.Dport + "-" + flight.Aport }; fltPassengerModel.RetApplySequence = flight.Sequence; fltPassengerModel.RetApplyFlightNo = flight.FlightNo; #endregion } result.PassengerList.Add(fltPassengerModel); } List <int> pidList = result.PassengerList.Select(n => n.PId).ToList(); List <string> orderStatusList = new List <string>() { "C" }; var select = from flight in Context.Set <FltRetModFlightApplyEntity>() join apply in Context.Set <FltRetModApplyEntity>() on flight.Rmid equals apply.Rmid into c from apply in c.DefaultIfEmpty() where !orderStatusList.Contains(apply.OrderStatus) && pidList.Contains(flight.Pid) && apply.OrderType.ToUpper() == "R" select flight; List <FltRetModFlightApplyEntity> list = select.ToList(); if (list != null && list.Count > 0) { result.PassengerList.ForEach(n => { FltRetModFlightApplyEntity l = list.Find(x => x.Pid == n.PId && x.Sequence == n.RetApplySequence); if (l != null) { n.IsRet = true; } }); } else { result.PassengerList.ForEach(n => { FltTicketNoEntity fltTicketNoEntity = fltTicketNoEntities.Find(x => x.PassengerName == n.Name && x.Sequence == n.RetApplySequence); if (fltTicketNoEntity != null && fltTicketNoEntity.TicketNoStatus == "R") { n.IsRet = true; } }); } return(result); }
public GetModApplyModel GetModApplyView(GetModApplyQueryModel query) { //1.判断是否已经出票 FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(query.OrderId); if (fltOrderEntity == null) { throw new Exception("查无此订单"); } if ((fltOrderEntity.ProcessStatus & 8) != 8) { throw new Exception("该订单未出票,不能提交改签申请"); } if (fltOrderEntity.Cid != query.Cid && query.Customer != null && query.Customer.UserID.ToLower() != "administrator") { throw new Exception("查无此订单"); } List <FltFlightEntity> flightEntities = _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == query.OrderId).ToList(); List <FltPassengerEntity> passengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == query.OrderId).ToList(); List <FltTicketNoEntity> fltTicketNoEntities = _fltTicketNoDal.Query <FltTicketNoEntity>(n => n.OrderId == query.OrderId).ToList(); //5.获取机场信息 List <SearchCityModel> cityModels = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList(); List <SearchAirportModel> airportModels = cityModels.SelectMany(n => n.AirportList).ToList(); List <FltClassNameModel> classNameModels = _getClassNameBll.GetFlightClassName(); GetModApplyModel result = new GetModApplyModel(); result.CName = fltOrderEntity.Cname; result.Mobile = fltOrderEntity.Mobile; result.Email = fltOrderEntity.Email; result.Cid = fltOrderEntity.Cid; result.CorpAduitId = fltOrderEntity.CorpAduitId; result.CorpPolicyId = fltOrderEntity.CorpPolicyId; result.PassengerList = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >(passengerEntities); result.FlightList = Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >(flightEntities); result.FlightList.ForEach(n => { SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == n.Dport.ToLower()); if (airportModel != null) { n.DportName = airportModel.AirportLongName; SearchCityModel cityModel = cityModels.Find(x => x.CityCode.ToLower() == airportModel.CityCode.ToLower()); n.DportCity = cityModel.CityName; } SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == n.Aport.ToLower()); if (airportModel2 != null) { n.AportName = airportModel2.AirportLongName; SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower()); n.AportCity = cityModel2.CityName; } FltClassNameModel classNameModel = classNameModels.Find( x => !string.IsNullOrEmpty(x.MClass) && !string.IsNullOrEmpty(n.Class) && x.MClass.ToLower() == n.Class.ToLower() && !string.IsNullOrEmpty(x.AirlineCode) && !string.IsNullOrEmpty(n.AirlineNo) && x.AirlineCode.ToLower() == n.AirlineNo.ToLower()); if (classNameModel != null) { n.ClassName = classNameModel.ClassName; n.ClassEnName = classNameModel.ClassEnName; } }); List <int> pidList = result.PassengerList.Select(n => n.PId).ToList(); #region 判断该乘机人是否有未处理的改签申请 List <string> orderStatusList = new List <string>() { "C", "F" }; var select = from flight in Context.Set <FltRetModFlightApplyEntity>() join apply in Context.Set <FltRetModApplyEntity>() on flight.Rmid equals apply.Rmid into c from apply in c.DefaultIfEmpty() where !orderStatusList.Contains(apply.OrderStatus) && pidList.Contains(flight.Pid) && apply.OrderType.ToUpper() == "M" select flight; List <FltRetModFlightApplyEntity> listMod = select.ToList();//已经改签人 if (listMod != null && listMod.Count > 0) { result.PassengerList.ForEach(n => { FltRetModFlightApplyEntity l = listMod.Find(x => x.Pid == n.PId); if (l != null) { n.IsMod = true; } }); } #endregion #region 判断该乘机人是否有存在退票申请 List <string> refundStatusList = new List <string>() { "C" }; var selectRefund = from flight in Context.Set <FltRetModFlightApplyEntity>() join apply in Context.Set <FltRetModApplyEntity>() on flight.Rmid equals apply.Rmid into c from apply in c.DefaultIfEmpty() where !refundStatusList.Contains(apply.OrderStatus) && pidList.Contains(flight.Pid) && apply.OrderType.ToUpper() == "R" select flight; List <FltRetModFlightApplyEntity> listRefund = selectRefund.ToList();//已经退票 if (listRefund != null && listRefund.Count > 0) { result.PassengerList.ForEach(n => { FltRetModFlightApplyEntity l = listRefund.Find(x => x.Pid == n.PId); if (l != null) { n.IsRet = true; } }); } #endregion //获取航程允许改签的乘机人Id foreach (var fltFlightModel in result.FlightList) { fltFlightModel.AllowModPidList = new List <int>(); foreach (var fltPassengerModel in result.PassengerList) { //判断当前是否已经退票 FltRetModFlightApplyEntity isRefund = listRefund.Find(n => n.Sequence == fltFlightModel.Sequence && fltPassengerModel.PId == n.Pid); //判断票号使用情况 FltTicketNoEntity fltTicketNoEntity = fltTicketNoEntities.Find( x => x.PassengerName == fltPassengerModel.Name && x.Sequence == fltFlightModel.Sequence); if (fltTicketNoEntity != null && fltTicketNoEntity.TicketNoStatus == "R")//如果当前乘机人对应航段票号已经退票了 { isRefund = new FltRetModFlightApplyEntity(); } if (isRefund == null) { //再判断是否已经改签 FltRetModFlightApplyEntity isMod = listMod.Find(n => n.Sequence == fltFlightModel.Sequence && fltPassengerModel.PId == n.Pid); if (isMod == null) { fltFlightModel.AllowModPidList.Add(fltPassengerModel.PId); } } } if (fltFlightModel.AllowModPidList.Count > 1) { fltFlightModel.AllowModPidList = fltFlightModel.AllowModPidList.Distinct().ToList(); } } return(result); }