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); }
/// <summary> /// 根据订单号获取订单信息 /// </summary> /// <param name="orderId"></param> /// <returns></returns> public FltOrderInfoModel GetFltOrderById(int orderId) { FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(orderId); if (fltOrderEntity == null) { return(null); } //1.根据订单号 获取航段信息 List <FltFlightEntity> flightEntities = _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == orderId, true).ToList(); //2.根据订单号 获取乘机人信息 List <FltPassengerEntity> passengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == orderId, true).ToList(); //3.根据订单号 获取成本中心 FltCorpCostCenterEntity costCenterEntity = _fltCorpCostCenterDal.Query <FltCorpCostCenterEntity>(n => n.Orderid == orderId, true).FirstOrDefault(); //4.获取仓等信息 List <FltClassNameModel> classNameModels = _getClassNameBll.GetFlightClassName(); //5.获取机场信息 List <SearchCityModel> cityModels = AportInfo?.CountryList.SelectMany(n => n.CityList).ToList(); List <SearchAirportModel> airportModels = cityModels?.SelectMany(n => n.AirportList).ToList(); //6.机票订单扩展表 FltOrderUnionEntity fltOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(orderId); FltOrderInfoModel result = Mapper.Map <FltOrderEntity, FltOrderInfoModel>(fltOrderEntity); if (!string.IsNullOrEmpty(costCenterEntity?.Depart)) { result.CostCenter = costCenterEntity.Depart; } if (fltOrderUnionEntity?.ProjectId != null && ProjectNameList != null) { ProjectNameModel projectNameModel = ProjectNameList.Find(n => n.ProjectId == fltOrderUnionEntity.ProjectId.Value); result.ProjectName = projectNameModel?.ProjectName; } //result.CorpPolicy = fltOrderUnionEntity?.CorpPolicy; result.PassengerList = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >( passengerEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId)); result.FlightList = Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >( flightEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId)); result.PassengerList.ForEach(n => { if (n.InsCompanyId.HasValue) { n.InsuranceName = InsuranceCompanyList?.Find(x => x.CompanyID == n.InsCompanyId.Value)?.ProductName; } }); #region 行程信息 result.CorpPolicy = string.Empty; result.ChoiceReason = string.Empty; foreach (var n in result.FlightList) { if (!string.IsNullOrEmpty(n.CorpPolicy) && n.CorpPolicy.ToLower() != "undefined") { result.CorpPolicy += ";" + n.CorpPolicy; } if (!string.IsNullOrEmpty(n.ChoiceReason) && n.ChoiceReason.ToLower() != "undefined") { result.ChoiceReason += ";" + n.ChoiceReason; } 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; } } if (!string.IsNullOrEmpty(result.CorpPolicy)) { result.CorpPolicy = result.CorpPolicy.Substring(1); } if (!string.IsNullOrEmpty(result.ChoiceReason)) { result.ChoiceReason = result.ChoiceReason.Substring(1); } #endregion return(result); }
public QueryFlightOrderDataModel QueryFlightOrder(QueryFlightOrderQueryModel query) { var select = _fltOrderDal.Query <FltOrderEntity>(n => n.OrderId == query.OrderId, true); FltOrderEntity fltOrderEntity = select.FirstOrDefault(); if (fltOrderEntity == null) { throw new Exception("查无此订单"); } //如果登录用户没有查看全部订单的权限 if ((query.Customer.IsShowAllOrder ?? 0) == 0) { if (!query.IsFromAduitQuery)//不是来自审批人查询 { if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() != "administrator" && query.Customer.Cid != fltOrderEntity.Cid) { throw new Exception("查无此订单"); } } } if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() == "administrator") { if ((query.CidList != null && !query.CidList.Contains(fltOrderEntity.Cid)) || query.CidList == null) { throw new Exception("查无此订单"); } } //1.根据订单号 获取航段信息 List <FltFlightEntity> flightEntities = _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == query.OrderId, true).ToList(); //2.根据订单号 获取乘机人信息 List <FltPassengerEntity> passengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == query.OrderId, true).ToList(); //3.根据订单号 获取成本中心 FltCorpCostCenterEntity costCenterEntity = _fltCorpCostCenterDal.Query <FltCorpCostCenterEntity>(n => n.Orderid == query.OrderId, true).FirstOrDefault(); //4.获取仓等信息 List <FltClassNameModel> classNameModels = _getClassNameBll.GetFlightClassName(); //5.获取机场信息 List <SearchCityModel> cityModels = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList(); List <SearchAirportModel> airportModels = cityModels.SelectMany(n => n.AirportList).ToList(); FltOrderUnionEntity fltOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(query.OrderId); #region 机票正单信息 QueryFlightOrderDataModel result = Mapper.Map <FltOrderEntity, QueryFlightOrderDataModel>(fltOrderEntity); if (!string.IsNullOrEmpty(costCenterEntity?.Depart)) { result.CostCenter = costCenterEntity.Depart; } if (fltOrderUnionEntity?.ProjectId != null && query.ProjectName != null) { ProjectNameModel projectNameModel = query.ProjectName.Find(n => n.ProjectId == fltOrderUnionEntity.ProjectId.Value); result.ProjectName = projectNameModel?.ProjectName; result.ProjectId = fltOrderUnionEntity.ProjectId; } result.PassengerList = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >( passengerEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId)); result.FlightList = Mapper.Map <List <FltFlightEntity>, List <FltFlightModel> >( flightEntities.FindAll(n => n.OrderId == fltOrderEntity.OrderId)); #region 行程 int index1 = 0; foreach (var n in result.FlightList) { 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; } index1++; } #endregion #endregion #region 机票退改签订单信息 //改签订单 List <string> modName = new List <string>(); List <string> modSequenceList = new List <string>(); _getFlightModOrderBll.AportInfo = query.AportInfo; List <FltModOrderModel> fltModOrderList = _getFlightModOrderBll.GetModOrderByOrderId(query.OrderId); if (fltModOrderList != null && fltModOrderList.Count > 0) { fltModOrderList = fltModOrderList.FindAll(n => (n.ProcessStatus & 8) == 8); fltModOrderList.ForEach(n => { n.FltModFlightList.ForEach(x => { n.FltModPassengerList.ForEach(m => { modSequenceList.Add(x.Sequence + "|" + m.Name); }); FltClassNameModel classNameModel = classNameModels.Find( m => !string.IsNullOrEmpty(m.MClass) && !string.IsNullOrEmpty(x.Class) && m.MClass.ToLower() == x.Class.ToLower() && !string.IsNullOrEmpty(m.AirlineCode) && !string.IsNullOrEmpty(x.AirlineNo) && m.AirlineCode.ToLower() == x.AirlineNo.ToLower()); if (classNameModel != null) { x.ClassName = classNameModel.ClassName; x.ClassEnName = classNameModel.ClassEnName; } }); }); modSequenceList = modSequenceList.Distinct().ToList(); } //退票订单 List <string> retName = new List <string>(); List <string> refundSequenceList = new List <string>(); List <FltRefundOrderModel> fltRefundOrderList = _getFlighRefundOrderBll.GetFlighRefundOrderByOrderId(query.OrderId); if (fltRefundOrderList != null && fltRefundOrderList.Count > 0) { fltRefundOrderList = fltRefundOrderList.FindAll(n => n.RefundCustomer == "T"); fltRefundOrderList.ForEach(n => { n.DetailList.ForEach(x => { FltFlightModel flightTemp = result.FlightList.Find(m => m.Sequence == x.Sequence); x.Dport = flightTemp.Dport; x.DportName = flightTemp.DportName; x.DportCity = flightTemp.DportCity; x.Aport = flightTemp.Aport; x.AportName = flightTemp.AportName; x.AportCity = flightTemp.AportCity; x.FlightNo = flightTemp.FlightNo; x.Class = flightTemp.Class; refundSequenceList.Add(x.Sequence + "|" + x.PassengerName); retName.Add(x.PassengerName); }); }); refundSequenceList = refundSequenceList.Distinct().ToList(); result.FltRefundOrderList = fltRefundOrderList; } #region 先处理改签情况 if (fltModOrderList != null) { List <FltModOrderModel> tempList = new List <FltModOrderModel>(); foreach (string modSequence in modSequenceList) { int sequence = Convert.ToInt32(modSequence.Split('|')[0]); string passengerName = modSequence.Split('|')[1]; var flightRmidList = fltModOrderList.SelectMany(n => n.FltModFlightList) .Where(n => n.Sequence == sequence) .Select(n => n.Rmid) .ToList(); var passengerRmidList = fltModOrderList.SelectMany(n => n.FltModPassengerList) .Where(n => n.Name == passengerName) .Select(n => n.Rmid) .ToList(); int maxRmid = fltModOrderList.Where( n => flightRmidList.Contains(n.Rmid) && passengerRmidList.Contains(n.Rmid)) .Max(n => n.Rmid); var temp = fltModOrderList.Find(n => n.Rmid == maxRmid); if (tempList.Find(n => n.Rmid == temp.Rmid) == null) { tempList.Add(temp); } } result.FltModOrderList = tempList; result.FltModOrderList.ForEach(n => { n.FltModPassengerList.ForEach(x => { modName.Add(x.Name); }); }); } #endregion #region 既有改签又有退票 if (fltModOrderList != null && refundSequenceList.Count > 0) { foreach (string refundSequence in refundSequenceList) { //将相同行程号,并且是相同人名的改签行程删除 int sequence = Convert.ToInt32(refundSequence.Split('|')[0]); string passengerName = refundSequence.Split('|')[1]; for (int i = 0; i < fltModOrderList.Count; i++) { List <FltModPassengerModel> fltModPassengerModels = fltModOrderList[i].FltModPassengerList.FindAll(n => n.Name == passengerName); FltModFlightModel fltModFlightModel = fltModOrderList[i].FltModFlightList.Find(n => n.Sequence == sequence); if (fltModPassengerModels != null && fltModPassengerModels.Count > 0 && fltModFlightModel != null) { fltModOrderList[i].FltModFlightList.Remove(fltModFlightModel); } } } if (fltModOrderList != null && fltModOrderList.Count > 0) { List <FltModOrderModel> index = new List <FltModOrderModel>(); for (int i = 0; i < fltModOrderList.Count; i++) { if (fltModOrderList[i].FltModFlightList.Count == 0) { index.Add(fltModOrderList[i]); } } foreach (var i in index) { fltModOrderList.Remove(i); } modName = new List <string>(); result.FltModOrderList = fltModOrderList; result.FltModOrderList.ForEach(n => { n.FltModPassengerList.ForEach(x => { modName.Add(x.Name); }); }); } } #endregion #endregion result.PassengerList.ForEach(n => { if (n.InsCompanyId.HasValue) { n.InsuranceName = query.InsuranceCompany?.Find(x => x.CompanyID == n.InsCompanyId.Value)?.ProductName; } if (modName.Count > 0) { n.IsMod = (modName.Find(x => x == n.Name) != null ? true : false); } if (retName.Count > 0) { n.IsRet = (retName.Find(x => x == n.Name) != null ? true : false); } }); return(result); }
public FltRetModApplyModel GetRetModApply(int rmid) { FltRetModApplyEntity fltRetModApply = _fltRetModApplyDal.Find <FltRetModApplyEntity>(rmid); List <FltRetModFlightApplyEntity> fltRetModFlightApplyEntities = _fltRetModFlightApplyDal.Query <FltRetModFlightApplyEntity>(n => n.Rmid == rmid).ToList(); List <FltRetModApplyLogEntity> fltRetModApplyLogEntities = _fltRetModApplyLogDal.Query <FltRetModApplyLogEntity>(n => n.Rmid == rmid).ToList(); FltRetModApplyModel fltRetModApplyModel = Mapper.Map <FltRetModApplyEntity, FltRetModApplyModel>(fltRetModApply); fltRetModApplyModel.DetailList = Mapper.Map <List <FltRetModFlightApplyEntity>, List <FltRetModFlightApplyModel> >( fltRetModFlightApplyEntities); fltRetModApplyModel.LogList = Mapper.Map <List <FltRetModApplyLogEntity>, List <FltRetModApplyLogModel> >( fltRetModApplyLogEntities); List <SearchCityModel> cityModels = AportInfo?.CountryList.SelectMany(n => n.CityList).ToList(); List <SearchAirportModel> airportModels = cityModels?.SelectMany(n => n.AirportList).ToList(); #region 乘机人信息 List <int> pidList = fltRetModApplyModel.DetailList.Select(n => n.Pid).ToList(); List <FltPassengerEntity> passengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => pidList.Any(x => x == n.PId)).ToList(); #endregion //4.获取仓等信息 List <FltClassNameModel> classNameModels = _getClassNameBll.GetFlightClassName(); fltRetModApplyModel.DetailList.ForEach(n => { FltFlightEntity orderFlightEntity = _fltFlightDal.Query <FltFlightEntity>(x => x.OrderId == fltRetModApplyModel.OrderId && x.Sequence == n.Sequence) .FirstOrDefault(); if (orderFlightEntity != null) { if (!n.TackoffTime.HasValue) { n.TackoffTime = orderFlightEntity.TackoffTime; } if (string.IsNullOrEmpty(n.FlightNo)) { n.FlightNo = orderFlightEntity.FlightNo; } } string dport = n.Dport.ToLower(); if (fltRetModApplyModel.OrderType == "R" && orderFlightEntity != null) { dport = orderFlightEntity.Dport.ToLower(); } SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == dport); if (airportModel != null) { n.DportName = airportModel.AirportName; SearchCityModel cityModel = cityModels.Find(x => x.CityCode.ToLower() == airportModel.CityCode.ToLower()); n.DportCity = cityModel.CityName; } string aport = n.Aport.ToLower(); if (fltRetModApplyModel.OrderType == "R" && orderFlightEntity != null) { aport = orderFlightEntity.Aport.ToLower(); } SearchAirportModel airportModel2 = airportModels.Find(x => x.AirportCode.ToLower() == aport); if (airportModel2 != null) { n.AportName = airportModel2.AirportName; SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower()); n.AportCity = cityModel2.CityName; } FltPassengerModel passengerModel = Mapper.Map <FltPassengerEntity, FltPassengerModel>(passengerEntities.Find(x => x.PId == n.Pid)); n.PassengerModel = passengerModel; if (fltRetModApplyModel.OrderType == "R") { n.PassengerModel.RefundTicketNo = n.TicketNo; } if (n.ChoiceReasonId.HasValue) { n.ChoiceReason = PolicyReasonList?.Find(x => x.Id == n.ChoiceReasonId.Value)?.Reason; } 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.FlightNo) && x.AirlineCode.ToLower() == n.FlightNo.Substring(0, 2).ToLower()); if (classNameModel != null) { n.ClassName = classNameModel.ClassName; } }); return(fltRetModApplyModel); }
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); }