Exemplo n.º 1
0
        public List <SearchFlightModel> SearchFlight(SearchFlightQueryModel query)
        {
            List <SearchFlightModel> ibeFlightModels = _searchFlightServiceBll.SearchFlight(query);

            List <SearchFlightModel> list = new List <SearchFlightModel>();

            foreach (var searchFlightModel in ibeFlightModels)
            {
                //个性化不显示共享航班,如当前是共享航班,则不加入list
                if (query.IsShareFly == 0 && searchFlightModel.IsShared)
                {
                    continue;
                }
                //接口数据为单独展示

                if ((query.IsXYPrice ?? 0) == 0)
                {
                    for (var i = 0; i < searchFlightModel.DetailList.Count; i++)
                    {
                        if (searchFlightModel.DetailList[i].PriceType != "C")//"C"不等于普通价格
                        {
                            //判断一下当前协议价格是否存在普通价格
                            var temp = searchFlightModel.DetailList.Find(
                                n => n.Class == searchFlightModel.DetailList[i].Class && n.PriceType == "C");
                            if (temp == null)
                            {
                                var searchModel = searchFlightModel.DetailList[i];                              //协议价格信息
                                SearchFlightDetailModel searchModelCopy =
                                    Mapper.Map <SearchFlightDetailModel, SearchFlightDetailModel>(searchModel); //复制一个价格信息
                                searchModelCopy.PriceType = "C";                                                //更改成非协议
                                searchModelCopy.SalePrice = searchModel.FacePrice;                              //把销售价更改成面单价
                                searchModelCopy.Rate      = ((Convert.ToDecimal(searchModelCopy.SalePrice) / Convert.ToDecimal(searchModelCopy.BaseFacePrice)) * 10).ToString("0.0");
                                searchFlightModel.DetailList.Add(searchModelCopy);
                            }
                        }
                    }
                }
                searchFlightModel.DetailList =
                    searchFlightModel.DetailList.OrderBy(n => Convert.ToDecimal(n.SalePrice)).ToList();
                list.Add(searchFlightModel);
            }

            //是否显示全部舱位:

            return(list);
        }
Exemplo n.º 2
0
        public SearchFlightResponseViewModel Search(SearchFlightRequestViewModel request)
        {
            if (request.Cid == 0)
            {
                throw new Exception("请传入客户Id");
            }

            //2.根据Cid查询客户信息
            CustomerModel customerModel = _getCustomerServiceBll.GetCustomerByCid(request.Cid);

            //调用查询该客户的差旅政策服务
            CorpPolicyDetailConfigModel poilConfigModel =
                _getCustomerCorpPolicyServiceBll.GetCorpPolicyById(request.PolicyId ?? 0, customerModel.CorpID, "N");

            SearchFlightQueryModel query = new SearchFlightQueryModel()
            {
                AirlineNo         = request.AirlineNo,
                Aport             = request.Aport,
                TackOffTime       = request.TackOffTime,
                Dport             = request.Dport,
                CorpPolicy        = poilConfigModel,
                CardNoList        = request.CardNoList,
                PassengerNameList = request.PassengerNameList,
                CorpId            = customerModel.CorpID,
                OrderSource       = request.OrderSource,
                IsShareFly        = customerModel.Corporation.IsShareFly,
                IsXYPrice         = customerModel.Corporation.IsXYPrice,
                IsAllSeat         = customerModel.Corporation.IsAllSeat,
                IsHeightSeat      = customerModel.Corporation.IsHeightSeat
            };

            //调用查询航班服务
            List <SearchFlightModel> searchFlightModels = _searchFlightServiceBll.SearchFlight(query);

            SearchFlightResponseViewModel viewModel = new SearchFlightResponseViewModel();

            viewModel.FlightList       = Mapper.Map <List <SearchFlightModel>, List <SearchFlightViewModel> >(searchFlightModels);
            viewModel.AirlineQuery     = searchFlightModels.Select(n => n.AirlineDesc).Distinct().ToList();
            viewModel.AportNameQuery   = searchFlightModels.Select(n => n.AportName).Distinct().ToList();
            viewModel.DportNameQuery   = searchFlightModels.Select(n => n.DportName).Distinct().ToList();
            viewModel.TackOffTimeQuery = searchFlightModels.Select(n => n.TackOffDate).Distinct().ToList();
            viewModel.ClassQuery       = searchFlightModels.SelectMany(n => n.DetailList).Select(n => n.ClassDesc).Distinct().ToList();
            viewModel.PolicyReason     = poilConfigModel?.PolicyReason;
            return(viewModel);
        }
Exemplo n.º 3
0
        public List <SearchFlightModel> SearchFlight(SearchFlightQueryModel query)
        {
            List <SearchFlightModel> polictFlightModels = _ibeFlightServiceBll.SearchFlight(query);


            #region 判断是否在名单内

            bool flag1 = true; //人名判断
            bool flag2 = true; //证件判断

            query.PassengerNameList.ForEach(n =>
            {
                if (!_checkPassengerIsInWhiteListBll.CheckPassengerName(n))//一旦有一个人不存在名单内,就设置不在名单
                {
                    flag1 = false;
                }
            });


            query.CardNoList.ForEach(n =>
            {
                if (!_checkPassengerIsInWhiteListBll.CheckPassengerCardNo(n))//一旦有一个人不存在名单内,就设置不在名单
                {
                    flag2 = false;
                }
            });

            #endregion


            List <SearchFlightModel> tempFlightModels = new List <SearchFlightModel>();

            foreach (SearchFlightModel polictFlightModel in polictFlightModels)
            {
                SearchFlightModel tempFlightModel = polictFlightModel;
                //根据不同的航司获取对应的名单判断规则
                bool flag0 = flag2;                                                     //默认证件判断
                if (CheckByNameAirlineNo.Contains(tempFlightModel.AirlineNo.ToUpper())) //人名判断
                {
                    flag0 = flag1;
                }

                List <SearchFlightDetailModel> tempFlightDetailModels = new List <SearchFlightDetailModel>();
                foreach (SearchFlightDetailModel searchFlightDetailModel in polictFlightModel.DetailList)
                {
                    //不在名单内,去除B2G价格,并且将协议价格转成普通价格
                    if (!flag0)
                    {
                        if (searchFlightDetailModel.PriceType == "C")
                        {
                            tempFlightDetailModels.Add(searchFlightDetailModel);
                        }
                        else if (searchFlightDetailModel.PriceType == "X")
                        {
                            searchFlightDetailModel.PriceType = "C";
                            searchFlightDetailModel.SalePrice = searchFlightDetailModel.FacePrice;
                            searchFlightDetailModel.Rate      = searchFlightDetailModel.FRate;
                            tempFlightDetailModels.Add(searchFlightDetailModel);
                        }
                    }
                    else //在名单内,不做任何处理
                    {
                        tempFlightDetailModels.Add(searchFlightDetailModel);
                    }
                }

                if (tempFlightDetailModels.Count > 0)
                {
                    tempFlightModel.DetailList = tempFlightDetailModels;
                    tempFlightModels.Add(tempFlightModel);
                }
            }

            return(tempFlightModels);
        }
        public List <SearchFlightModel> SearchFlight(SearchFlightQueryModel query)
        {
            List <SearchFlightModel> ibeFlightModels = _checkWhitelFlightSearch.SearchFlight(query);

            if (string.IsNullOrEmpty(query.CorpId)) //没有公司Id的直接返回ibe航班信息
            {
                return(ibeFlightModels);
            }
            CorpPolicyDetailConfigModel policyModel = query.CorpPolicy;


            #region 将差旅政策包装到IBE航班信息

            List <SearchFlightModel> flightTempList = new List <SearchFlightModel>();
            #region 没有差旅政策
            if (policyModel == null)
            {
                foreach (var model in ibeFlightModels)
                {
                    foreach (var detail in model.DetailList)
                    {
                        detail.IsViolate              = "F";
                        detail.ViolateNPolicyValL     = "F";
                        detail.ViolateNPolicyValLDesc = "";
                        detail.ViolateNPolicyValT     = "F";
                        detail.ViolateNPolicyValTDesc = "";
                        detail.ViolateNPolicyValR     = "F";
                        detail.ViolateNPolicyValRDesc = "";
                        detail.ViolateNPolicyValY     = "F";
                        detail.ViolateNPolicyValYDesc = "F";
                    }
                    flightTempList.Add(model);
                }
                return(flightTempList);
            }
            #endregion
            #region 存在差旅政策
            #region 判断
            //个性化设置 是否显示全部舱位 如果选否,按照下一个“最高舱位限制”政策的舱位
            if ((query.IsAllSeat ?? 0) == 0)
            {
                if (query.IsHeightSeat == 1)
                {
                    LimitClassType = 1;//(最高仓位限制)
                }
                else if (query.IsHeightSeat == 0)
                {
                    LimitClassType = 2;//一旦限制的仓位买完了,显示上一级仓位
                }
            }


            int?    nPolicyValLValue = null;                                                       //国内机票低价航班为出发时间前后XX分钟内最低航班 //判断明细
            int?    nPolicyValTValue = null;                                                       //国内机票提前预定 提前XXX天以上预定航班 //判断主体
            decimal?nPolicyValRValue = null;                                                       // 国内机票XXX折扣限制  //判断明细
            string  nPolicyValY      = string.Empty;                                               //国内机票仓等限制 Y经济舱/C公务舱/F头等舱  //判断明细
            if (!string.IsNullOrEmpty(policyModel.NPolicyValL) && policyModel.NPolicyValL != "-1") //存在该政策,并且非不受限制
            {
                nPolicyValLValue = Convert.ToInt32(policyModel.NPolicyValL);
            }
            if (!string.IsNullOrEmpty(policyModel.NPolicyValT) && policyModel.NPolicyValT != "-1")
            {
                nPolicyValTValue = Convert.ToInt32(policyModel.NPolicyValT);
            }
            if (!string.IsNullOrEmpty(policyModel.NPolicyValR) && policyModel.NPolicyValR != "-1")
            {
                nPolicyValRValue = Convert.ToDecimal(policyModel.NPolicyValR);
            }
            if (!string.IsNullOrEmpty(policyModel.NPolicyValY))
            {
                nPolicyValY = policyModel.NPolicyValY;
            }

            #endregion

            string isViolate              = "F";
            string violateNPolicyValT     = "F";
            string violateNPolicyValTDesc = string.Empty;

            #region 提前预定判断政策

            if (nPolicyValTValue.HasValue)
            {
                double day = (query.TackOffTime - Convert.ToDateTime(DateTime.Now.ToShortDateString())).TotalDays;
                if (day < nPolicyValTValue.Value)
                {
                    isViolate          = "T";
                    violateNPolicyValT = "T";
                    if (query.CorpId == "JYJR")
                    {
                        violateNPolicyValTDesc = "航班预定需需提前" + nPolicyValTValue.Value + "天以上航班预定";
                    }
                    else
                    {
                        violateNPolicyValTDesc = "提前" + nPolicyValTValue.Value + "天以上预定航班";
                    }
                }
            }

            #endregion
            foreach (var model in ibeFlightModels)
            {
                foreach (var detail in model.DetailList)
                {
                    detail.ViolateNPolicyValT     = violateNPolicyValT;
                    detail.ViolateNPolicyValTDesc = violateNPolicyValTDesc;

                    #region 折扣限制政策判断

                    if (nPolicyValRValue.HasValue && Convert.ToDecimal(detail.Rate) > nPolicyValRValue)
                    {
                        detail.ViolateNPolicyValR     = "T";
                        detail.ViolateNPolicyValRDesc = nPolicyValRValue + "折以下的航班";
                    }
                    else
                    {
                        detail.ViolateNPolicyValR     = "F";
                        detail.ViolateNPolicyValRDesc = "";
                    }

                    #endregion

                    #region 仓等限制政策判断

                    if (!string.IsNullOrEmpty(nPolicyValY))
                    {
                        if (detail.FatherClass == "J")
                        {
                            detail.FatherClass = "C";
                        }
                        if (nPolicyValY != detail.FatherClass)
                        {
                            detail.ViolateNPolicyValY     = "T";
                            detail.ViolateNPolicyValYDesc = "未预定" +
                                                            (nPolicyValY == "Y"
                                                                ? "经济舱"
                                                                : nPolicyValY == "C" ? "公务舱" : "头等舱");
                        }
                        else
                        {
                            detail.ViolateNPolicyValY     = "F";
                            detail.ViolateNPolicyValYDesc = "";
                        }
                        #region 隐藏仓位
                        var classIndex = nPolicyValY == "Y"
                                    ? 1
                                    : nPolicyValY == "C" ? 2 : 3;

                        if (LimitClassType == 1)
                        {
                            model.DetailList = model.DetailList.Where(a => (a.ClassDesc.Contains("经济舱") ? 1 : ((a.ClassDesc.Contains("公务舱") || a.ClassDesc.Contains("商务舱")) ? 2 : 3)) <= classIndex).ToList();
                        }
                        else if (LimitClassType == 2)
                        {
                            //如果最高仓位买完显示全部仓位
                            int count = model.DetailList.FindAll(n => n.ClassIndex <= classIndex).Count;//所有仓位到限制最高仓位的数量
                            if (count > 0)
                            {
                                model.DetailList = model.DetailList.Where(a => (a.ClassDesc.Contains("经济舱") ? 1 : ((a.ClassDesc.Contains("公务舱") || a.ClassDesc.Contains("商务舱")) ? 2 : 3)) <= classIndex).ToList();
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        detail.ViolateNPolicyValY     = "F";
                        detail.ViolateNPolicyValYDesc = "";
                    }

                    #endregion

                    #region 航班前后XX分钟内是否最低价格政策判断

                    if (nPolicyValLValue.HasValue)
                    {
                        decimal?minPrice = GetMinSalePrice(Convert.ToDateTime(model.TackOffTime), nPolicyValLValue.Value, ibeFlightModels, Convert.ToDecimal(detail.SalePrice));
                        if (minPrice.HasValue)
                        {
                            detail.ViolateNPolicyValL     = "T";
                            detail.ViolateNPolicyValLDesc = "未选择前后" + nPolicyValLValue.Value + "分钟内最低价格为" +
                                                            minPrice.Value.ToString("0");
                            detail.MinSalePrice = Convert.ToDecimal(minPrice.Value.ToString("0"));
                        }
                        else
                        {
                            detail.ViolateNPolicyValL     = "F";
                            detail.ViolateNPolicyValLDesc = "";
                        }
                    }
                    else
                    {
                        detail.ViolateNPolicyValL     = "F";
                        detail.ViolateNPolicyValLDesc = "";
                    }

                    #endregion

                    if (isViolate == "T")
                    {
                        detail.IsViolate = "T";
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(detail.ViolateNPolicyValRDesc) &&
                            string.IsNullOrEmpty(detail.ViolateNPolicyValYDesc) &&
                            string.IsNullOrEmpty(detail.ViolateNPolicyValLDesc))
                        {
                            detail.IsViolate = "F";
                        }
                        else
                        {
                            detail.IsViolate = "T";
                        }
                    }
                }
                if (model.DetailList != null && model.DetailList.Any())
                {
                    flightTempList.Add(model);
                }
            }
            #endregion

            #endregion

            return(flightTempList);
        }
        public List <SearchFlightModel> SearchFlight(SearchFlightQueryModel query)
        {
            List <SearchFlightModel> ibeFlightModels  = _searchContainPolicyFlightBll.SearchFlight(query);
            List <SearchFlightModel> filterSearchlist = new List <SearchFlightModel>();

            //个性化设置过滤
            foreach (var searchFlightModel in ibeFlightModels)
            {
                //TODO:2)个性化不显示共享航班,如当前是共享航班,则不加入list
                if (query.IsShareFly == 0 && searchFlightModel.IsShared)
                {
                    continue;
                }
                //TODO:3)协议价格是单独展示
                //if (query.IsXYPrice == 1)
                //{
                //    List<SearchFlightDetailModel> interDetail = new List<SearchFlightDetailModel>();
                //    for (var i = 0; i < searchFlightModel.DetailList.Count; i++)
                //    {
                //        if (searchFlightModel.DetailList[i].PriceType != "C")//"C"不等于普通价格
                //        {
                //            var SearchModel = searchFlightModel.DetailList[i];
                //            SearchFlightDetailModel SearchModelCopy = (SearchFlightDetailModel)searchFlightModel.DetailList[i].Clone();//TODO:mapper
                //            SearchModelCopy.PriceType = "C";//更改成非协议
                //            SearchModelCopy.SalePrice = SearchModel.FacePrice;//把销售价更改成面单价
                //            SearchModelCopy.Rate = ((Convert.ToDecimal(SearchModelCopy.SalePrice) / Convert.ToDecimal(SearchModelCopy.BaseFacePrice)) * 10).ToString("0.0");
                //            interDetail.Add(SearchModelCopy);
                //        }
                //    }
                //    searchFlightModel.DetailList.AddRange(interDetail);
                //}

                filterSearchlist.Add(searchFlightModel);
            }

            if (string.IsNullOrEmpty(query.CorpId)) //没有公司Id的直接返回ibe航班信息
            {
                return(filterSearchlist);
            }

            if (filterSearchlist == null || filterSearchlist.Count == 0)
            {
                return(filterSearchlist);
            }

            foreach (var searchFlightModel in filterSearchlist)
            {
                if (string.IsNullOrEmpty(searchFlightModel.SharedFlightNo) ||
                    string.IsNullOrEmpty(searchFlightModel.AirlineNo) ||
                    string.IsNullOrEmpty(searchFlightModel.FlightNo))
                {
                    continue;
                }

                //通过实际航班找到它对应的信息
                SearchFlightModel shared = filterSearchlist.Find(n => (n.AirlineNo + n.FlightNo) == searchFlightModel.SharedFlightNo);
                if (shared != null && shared.DetailList != null && shared.DetailList.Count > 0)
                {
                    SearchFlightDetailModel priceDetail = shared.DetailList.Find(n => n.PriceType == "X" || n.PriceType == "G");
                    if (priceDetail != null)
                    {
                        searchFlightModel.IsSharedFlightNoHasXieYiPrice = true;
                    }
                }
            }

            return(filterSearchlist);
        }
        public List <SearchFlightModel> SearchFlight(SearchFlightQueryModel query)
        {
            int LimitClassType = 0;

            if (string.IsNullOrEmpty(query.AirlineNo))
            {
                throw new Exception("请传入改签航班号");
            }

            string        airlineNo     = query.AirlineNo;
            List <string> airlineNoList = new List <string> {
                airlineNo
            };

            if (airlineNo == "MU")
            {
                airlineNoList.Add("FM");
            }
            else if (airlineNo == "FM")
            {
                airlineNoList.Add("MU");
            }

            query.AirlineNo = ""; //无论是否传入航司三字码,都置为空
            List <SearchFlightModel> ibeFlightModels = _ibeFlightServiceBll.SearchFlight(query);

            ibeFlightModels.ForEach(n =>
            {
                if (airlineNoList.Contains(n.AirlineNo))
                {
                    n.IsOriginalAirlineNo = true;
                }
                else
                {
                    n.IsOriginalAirlineNo = false;
                }
            });
            //改签只显示同航司航班
            ibeFlightModels = ibeFlightModels.FindAll(n => n.IsOriginalAirlineNo);

            #region 判断差标
            //个性化设置 是否显示全部舱位 如果选否,按照下一个“最高舱位限制”政策的舱位
            if ((query.IsAllSeat ?? 0) == 0)
            {
                if (query.IsHeightSeat == 1)
                {
                    LimitClassType = 1;//(最高仓位限制)
                }
                else if (query.IsHeightSeat == 0)
                {
                    LimitClassType = 2;//一旦限制的仓位买完了,显示上一级仓位
                }
            }
            var nPolicyValY = query.CorpPolicy?.NPolicyValY;
            //不根据差标限制仓等
            if (!IsLimitClass || string.IsNullOrWhiteSpace(nPolicyValY))
            {
                return(ibeFlightModels);
            }
            var classIndex = nPolicyValY == "Y"
            ? 1
            : nPolicyValY == "C" ? 2 : 3;

            foreach (var item in ibeFlightModels)
            {
                //item.DetailList = item.DetailList.Where(a => (a.ClassDesc.Contains("经济舱") ? 1 : ((a.ClassDesc.Contains("公务舱") || a.ClassDesc.Contains("商务舱")) ? 2 : 3)) <= classIndex).ToList();
                if (LimitClassType == 1)
                {
                    item.DetailList = item.DetailList.Where(a => (a.ClassDesc.Contains("经济舱") ? 1 : ((a.ClassDesc.Contains("公务舱") || a.ClassDesc.Contains("商务舱")) ? 2 : 3)) <= classIndex).ToList();
                }
                else if (LimitClassType == 2)
                {
                    //如果最高仓位买完显示全部仓位
                    int count = item.DetailList.FindAll(n => n.ClassIndex <= classIndex).Count;//所有仓位到限制最高仓位的数量
                    if (count > 0)
                    {
                        item.DetailList = item.DetailList.Where(a => (a.ClassDesc.Contains("经济舱") ? 1 : ((a.ClassDesc.Contains("公务舱") || a.ClassDesc.Contains("商务舱")) ? 2 : 3)) <= classIndex).ToList();
                    }
                }
            }
            ibeFlightModels = ibeFlightModels.Where(a => a.DetailList != null && a.DetailList.Any()).ToList();
            return(ibeFlightModels);

            #endregion
        }