public AuditResultModel DoSecondAudit(AuditModApplySecond secondAudit) { FltRetModApplyEntity modApplyEntity = _fltRetModApplyDal.Find <FltRetModApplyEntity>(_modApplyQuery.Id); List <FltRetModFlightApplyEntity> modFlightApplyEntities = _fltRetModFlightApplyDal.Query <FltRetModFlightApplyEntity>(n => n.Rmid == modApplyEntity.Rmid).ToList(); FltRetModApplyLogEntity log = new FltRetModApplyLogEntity() { Rmid = modApplyEntity.Rmid, Oid = "sys", LogType = "审批申请", LogTime = DateTime.Now }; #region 进行审批 List <string> properties = new List <string>(); if (IsAgree) { modApplyEntity.OrderStatus = FltModApplyStatusEnum.P.ToString(); log.Remark = "改签申请审核状态:二级审核通过。二级审核人:" + _modApplyQuery.AuditCustomer?.RealName; } else { modApplyEntity.OrderStatus = FltModApplyStatusEnum.C.ToString(); log.Remark = "改签申请审核状态:二级审核不通过。二级审核人:" + _modApplyQuery.AuditCustomer?.RealName; } #endregion modFlightApplyEntities.ForEach(n => n.OrderStatus = modApplyEntity.OrderStatus); properties.Add("OrderStatus"); _fltRetModApplyDal.Update(modApplyEntity, properties.ToArray()); modFlightApplyEntities.ForEach(n => { _fltRetModFlightApplyDal.Update(n, properties.ToArray()); }); _fltRetModApplyLogDal.Insert(log); return(new AuditResultModel() { Code = 0, AuditResult = log.Remark, OwnCid = modApplyEntity.Cid, Id = modApplyEntity.Rmid, OrderType = OrderSourceTypeEnum.FltModApply }); }
public ConfirmRetModAuditPriceResultModel ConfirmRetAuditPrice(ConfirmRetModAuditPriceModel query) { FltRetModApplyEntity fltRetModApplyEntity = _fltRetModApplyDal.Find <FltRetModApplyEntity>(query.Rmid); if (fltRetModApplyEntity == null) { throw new Exception("查无此申请"); } if (fltRetModApplyEntity.OrderStatus != FltRetApplyStatusEnum.A.ToString()) { throw new Exception("该审核已经提交审批"); } fltRetModApplyEntity.EditOid = query.Cid.ToString(); fltRetModApplyEntity.EditTime = DateTime.Now; fltRetModApplyEntity.OrderStatus = FltRetApplyStatusEnum.D.ToString(); _fltRetModApplyDal.Update(fltRetModApplyEntity, new string[] { "EditOid", "EditTime", "OrderStatus" }); bool isViolatePolicy = false; foreach (var detail in query.DetailList) { FltRetModFlightApplyEntity flightApplyEntity = _fltRetModFlightApplyDal.Query <FltRetModFlightApplyEntity>( n => n.Rmid == query.Rmid && n.Sequence == detail.Sequence && n.Pid == detail.Pid) .FirstOrDefault(); if (flightApplyEntity == null) { continue; } if (!string.IsNullOrEmpty(flightApplyEntity.PolicyDesc)) { isViolatePolicy = true; } flightApplyEntity.OrderStatus = fltRetModApplyEntity.OrderStatus; flightApplyEntity.ChoiceReasonId = detail.ChoiceReasonId; _fltRetModFlightApplyDal.Update(flightApplyEntity, new string[] { "ChoiceReasonId", "OrderStatus" }); } FltRetModApplyLogEntity log = new FltRetModApplyLogEntity() { Rmid = fltRetModApplyEntity.Rmid, LogTime = DateTime.Now, LogType = "修改退票申请", Oid = "sys", Remark = "进行核价" }; _fltRetModApplyLogDal.Insert(log); return(new ConfirmRetModAuditPriceResultModel() { IsSuccess = true, Rmid = fltRetModApplyEntity.Rmid, CorpAduitId = fltRetModApplyEntity.CorpAduitId, CorpPolicyId = fltRetModApplyEntity.CorpPolicyId, OwnCid = fltRetModApplyEntity.Cid, IsViolatePolicy = isViolatePolicy }); }
/// <summary> /// 核价确认阶段取消申请 /// </summary> /// <param name="query"></param> /// <returns></returns> public int CancelFltModApplyByWaitAuditStep(CancelFltRetModApplyModel query) { FltRetModApplyEntity fltRetModApplyEntity = _fltRetModApplyDal.Find <FltRetModApplyEntity>(query.Rmid); string orderType = fltRetModApplyEntity.OrderType == "M" ? "改签" : "退票"; if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() != "administrator" && query.Customer.Cid != fltRetModApplyEntity.Cid) { throw new Exception($"查无此{orderType}申请"); } if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() == "administrator") { throw new Exception($"管理员帐号不能取消{orderType}申请"); } string orderStatus = FltModApplyStatusEnum.C.ToString(); string wOrderStatus = FltModApplyStatusEnum.A.ToString(); if (fltRetModApplyEntity.OrderType == "R") { orderStatus = FltRetApplyStatusEnum.C.ToString(); wOrderStatus = FltRetApplyStatusEnum.A.ToString(); } if (fltRetModApplyEntity.OrderStatus == orderStatus) { throw new Exception($"当前{orderType}申请已经取消!"); } if (fltRetModApplyEntity.OrderStatus != wOrderStatus) { throw new Exception($"当前{orderType}申请无法取消!"); } fltRetModApplyEntity.OrderStatus = orderStatus; _fltRetModApplyDal.Update(fltRetModApplyEntity, new string[] { "OrderStatus" }); List <FltRetModFlightApplyEntity> fltRetModFlightApplyEntities = _fltRetModFlightApplyDal.Query <FltRetModFlightApplyEntity>(n => n.Rmid == query.Rmid, true).ToList(); foreach (var fltRetModFlightApplyEntity in fltRetModFlightApplyEntities) { fltRetModFlightApplyEntity.OrderStatus = orderStatus; _fltRetModFlightApplyDal.Update(fltRetModFlightApplyEntity, new string[] { "OrderStatus" }); } FltRetModApplyLogEntity log = new FltRetModApplyLogEntity(); log.LogTime = DateTime.Now; log.LogType = "取消申请"; log.Oid = "Sys"; log.Remark = "核价确认时取消了申请"; log.Rmid = query.Rmid; _fltRetModApplyLogDal.Insert(log); return(0); }
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 QueryFlightModApplyListModel QueryFlightModApplyList(QueryFlightModApplyListDataQueryModel query) { QueryFlightModApplyListModel resultModel = new QueryFlightModApplyListModel(); resultModel.ApplyDataList = new List <QueryFlightModApplyListDataModel>(); //List<string> orderstatusList = new List<string>() {"C" }; var select = from modApply in Context.Set <FltRetModApplyEntity>().AsNoTracking() join order in Context.Set <FltOrderEntity>().AsNoTracking() on modApply.OrderId equals order.OrderId into o from order in o.DefaultIfEmpty() join customer in Context.Set <CustomerInfoEntity>().AsNoTracking() on modApply.Cid equals customer.Cid into c from customer in c.DefaultIfEmpty() where modApply.OrderType.ToUpper() == "M" && (order.IsInter == "N" || order.IsInter == "n") && (modApply.IsHidden ?? 0) == 0 select new QueryFlightModApplyListDataModel() { Rmid = modApply.Rmid, CreateTime = modApply.CreateTime, OrderId = modApply.OrderId, OrderStatus = modApply.OrderStatus, Cid = modApply.Cid, CorpId = customer.CorpID, Cpid = modApply.Cpid, CpidSecond = modApply.CpidSecond }; #region 查询条件 //if(!query.IsHidden) //{ // select = select.Where(n=>n.ish) //} if (query.Cid.HasValue) { select = select.Where(n => n.Cid == query.Cid.Value); } if (!string.IsNullOrEmpty(query.CorpId)) { select = select.Where(n => n.CorpId == query.CorpId); } if (query.AllowShowDataBeginTime.HasValue) { select = select.Where(n => n.CreateTime > query.AllowShowDataBeginTime.Value); } if (query.OrderId.HasValue) { select = select.Where(n => n.OrderId == query.OrderId.Value); } if (!string.IsNullOrEmpty(query.OrderStatus)) { select = select.Where(n => n.OrderStatus.ToUpper() == query.OrderStatus.ToUpper()); } if (query.TackOffBeginTime.HasValue) { select = select.Where( n => Context.Set <FltRetModFlightApplyEntity>() .Where(m => m.TackoffTime >= query.TackOffBeginTime.Value) .Select(m => m.Rmid).Contains(n.Rmid)); } if (query.TackOffEndTime.HasValue) { query.TackOffEndTime = query.TackOffEndTime.Value.AddDays(1); select = select.Where( n => Context.Set <FltRetModFlightApplyEntity>() .Where(m => m.TackoffTime < query.TackOffEndTime.Value) .Select(m => m.Rmid).Contains(n.Rmid)); } if (query.OrderBeginTime.HasValue) { select = select.Where(n => n.CreateTime >= query.OrderBeginTime.Value); } if (query.OrderEndTime.HasValue) { query.OrderEndTime = query.OrderEndTime.Value.AddDays(1); select = select.Where(n => n.CreateTime < query.OrderEndTime.Value); } if (!string.IsNullOrEmpty(query.PassengerName)) { select = select.Where( n => Context.Set <FltRetModFlightApplyEntity>().Where(m => m.FltPassenger.Name.Contains(query.PassengerName)) .Select(m => m.Rmid).Contains(n.Rmid) ); } #endregion resultModel.TotalCount = select.Count();//查询所有结果的数量 //如果是导出操作 则返回全部订单 if ((query.IsExport ?? 0) == 0) { select = select.OrderByDescending(n => n.Rmid).Skip(query.PageSize * (query.PageIndex - 1)).Take(query.PageSize); } else { select = select.OrderByDescending(n => n.Rmid); } resultModel.ApplyDataList = select.ToList();//分页结果 List <int> rmidList = new List <int>(); resultModel.ApplyDataList.ForEach(n => rmidList.Add(n.Rmid)); List <FltRetModFlightApplyEntity> flightApplyEntities = _fltRetModFlightApplyDal.Query <FltRetModFlightApplyEntity>(n => rmidList.Contains(n.Rmid), true).ToList(); List <SearchCityModel> cityModels = query.AportInfo.CountryList.SelectMany(n => n.CityList).ToList(); List <SearchAirportModel> airportModels = cityModels.SelectMany(n => n.AirportList).ToList(); List <FltRetModFlightApplyModel> flightApplyModels = Mapper.Map <List <FltRetModFlightApplyEntity>, List <FltRetModFlightApplyModel> > (flightApplyEntities); #region 乘机人信息 List <int> pidList = flightApplyModels.Select(n => n.Pid).ToList(); List <FltPassengerEntity> passengerEntities = _fltPassengerDal.Query <FltPassengerEntity>(n => pidList.Contains(n.PId), true).ToList(); List <FltPassengerModel> passengerModels = Mapper.Map <List <FltPassengerEntity>, List <FltPassengerModel> >(passengerEntities); #endregion flightApplyModels.ForEach(n => { SearchAirportModel airportModel = airportModels.Find(x => x.AirportCode.ToLower() == n.Dport.ToLower()); if (airportModel != null) { n.DportName = airportModel.AirportName; 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.AirportName; SearchCityModel cityModel2 = cityModels.Find(x => x.CityCode.ToLower() == airportModel2.CityCode.ToLower()); n.AportCity = cityModel2.CityName; } n.PassengerModel = passengerModels.Find(x => x.PId == n.Pid); }); resultModel.ApplyDataList.ForEach(n => { if (n.Cpid.HasValue) { n.FirstAuditCustomer = query.CorpCustomerList?.Find(x => x.Cid == n.Cpid.Value); } if (n.CpidSecond.HasValue) { n.SecondAuditCustomer = query.CorpCustomerList?.Find(x => x.Cid == n.CpidSecond.Value); } n.DetailList = flightApplyModels.FindAll(x => x.Rmid == n.Rmid); List <int> dPidList = new List <int>(); List <int> sequenceList = new List <int>(); n.DetailList.ForEach(x => { dPidList.Add(x.Pid); sequenceList.Add(x.Sequence); }); dPidList = dPidList.Distinct().ToList(); sequenceList = sequenceList.Distinct().ToList(); n.PassengerList = new List <FltPassengerModel>(); foreach (var pid in dPidList) { n.PassengerList.Add(passengerModels.Find(x => x.PId == pid)); } n.FlightList = new List <FltFlightModel>(); foreach (var sequence in sequenceList) { var dd = n.DetailList.Find(x => x.Sequence == sequence); n.FlightList.Add(new FltFlightModel() { FlightNo = dd.FlightNo, Dport = dd.Dport, Aport = dd.Aport, DportName = dd.DportName, AportName = dd.AportName, AportCity = dd.AportCity, DportCity = dd.DportCity, TackoffTime = dd.TackoffTime ?? Convert.ToDateTime("2000-01-01") }); } }); return(resultModel); }