public QueryFlightModApplyDataModel QueryModApply(QueryFlightModApplyQueryModel query)
        {
            QueryFlightModApplyDataModel queryFlightModApplyDataModel = new QueryFlightModApplyDataModel();

            _getFlightRetModApplyBll.AportInfo        = query.AportInfo;
            _getFlightRetModApplyBll.PolicyReasonList = query.PolicyReasonList;
            FltRetModApplyModel fltRetModApplyModel = _getFlightRetModApplyBll.GetRetModApply(query.Rmid);

            if ((query.Customer.IsShowAllOrder ?? 0) == 0) //如果没有查看全部订单的权限
            {
                if (!query.IsFromAduitQuery)               //不是来自审批人查询
                {
                    if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() != "administrator" &&
                        query.Customer.Cid != fltRetModApplyModel.Cid)
                    {
                        throw new Exception("查无此改签申请");
                    }
                }
            }

            if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() == "administrator")
            {
                if ((query.CidList != null && !query.CidList.Contains(fltRetModApplyModel.Cid)) || query.CidList == null)
                {
                    throw new Exception("查无此改签申请");
                }
            }

            fltRetModApplyModel.ApplyCustomer = query.CorpCustomerList?.Find(n => n.Cid == fltRetModApplyModel.Cid);

            _getFlightModOrderBll.AportInfo = query.AportInfo;
            FltModOrderModel fltModOrderModel = _getFlightModOrderBll.GetModOrderByRmid(query.Rmid);

            queryFlightModApplyDataModel             = queryFlightModApplyDataModel.ConvertFatherToSon(fltRetModApplyModel);
            queryFlightModApplyDataModel.FltModOrder = fltModOrderModel;



            //如果存在改签订单,并且已经出票,则提取改签面价,和改签票号
            if (fltModOrderModel != null && (fltModOrderModel.ProcessStatus & 8) == 8)
            {
                queryFlightModApplyDataModel.ModPrice = fltModOrderModel.ModPrice;
                queryFlightModApplyDataModel.PassengerList.ForEach(n =>
                {
                    n.ModTicketNoList =
                        fltModOrderModel.FltModTicketNoList.FindAll(x => x.PassengerName == n.Name)
                        .Select(x => x.AirlineNo + x.TicketNo)
                        .ToList();
                    n.IsMod = true;
                });
            }


            return(queryFlightModApplyDataModel);
        }
        public GetAuditOrderListResponseViewModel GetAuditOrderList(GetAuditOrderListRequestViewModel request)
        {
            //1.根据Cid查询客户信息
            CustomerModel customerModel = _getCustomerServiceBll.GetCustomerByCid(request.Cid);

            if (string.IsNullOrEmpty(customerModel.IsCheckPerson) || customerModel.IsCheckPerson.ToUpper() != "T")
            {
                throw new Exception("当前用户无权审批");
            }



            AuditOrderListModel list = null;

            if (request.AuditType == 1)//待审批信息
            {
                #region 待审批信息

                list = _getCorpAduitOrderListServiceBll.GetWaitCorpAduitOrderList(new AuditOrderListQueryModel()
                {
                    AuditCid  = request.Cid,
                    PageSize  = request.PageSize,
                    PageIndex = request.PageIndex,
                    Customer  = customerModel
                });

                #endregion
            }
            else if (request.AuditType == 2)//审批通过
            {
                #region 审批通过
                list = _getCorpAduitOrderListServiceBll.GetPassCorpAduitOrderList(new AuditOrderListQueryModel()
                {
                    AuditCid  = request.Cid,
                    PageSize  = request.PageSize,
                    PageIndex = request.PageIndex,
                    Customer  = customerModel
                });
                #endregion
            }
            else if (request.AuditType == 3)//审批不通过
            {
                #region 审批不通过
                list = _getCorpAduitOrderListServiceBll.GetNoPassCorpAduitOrderList(new AuditOrderListQueryModel()
                {
                    AuditCid  = request.Cid,
                    PageSize  = request.PageSize,
                    PageIndex = request.PageIndex,
                    Customer  = customerModel
                });
                #endregion
            }



            #region 组装审批内容
            if (list != null && list.DataList != null && list.DataList.Count > 0)
            {
                //查询机场信息
                _getFltOrderBll.AportInfo = _getCityForFlightServiceBll.SearchAirport(new List <string>()
                {
                    "N"
                });
                _getFlightRetModApplyBll.AportInfo = _getCityForFlightServiceBll.SearchAirport(new List <string>()
                {
                    "N"
                });
                //调用查询该客户的差旅政策服务
                List <ChoiceReasonModel> reasonModels = _getCustomerCorpPolicyServiceBll.GetCorpReasonByCorpId(customerModel.CorpID);
                _getFlightRetModApplyBll.PolicyReasonList = reasonModels;

                foreach (var data in list.DataList)
                {
                    foreach (var detail in data.DetailList)
                    {
                        if (detail.OrderType == OrderSourceTypeEnum.Flt)
                        {
                            FltOrderInfoModel fltOrderInfoModel = _getFltOrderBll.GetFltOrderById(detail.OrderId);
                            if (fltOrderInfoModel == null)
                            {
                                continue;
                            }
                            detail.ChoiceReason      = fltOrderInfoModel.ChoiceReason;
                            detail.CorpPolicy        = fltOrderInfoModel.CorpPolicy;
                            detail.OrderAmount       = fltOrderInfoModel.Payamount;
                            detail.PassengerNameList = fltOrderInfoModel.PassengerNameList;
                            detail.TackOffTimeList   = fltOrderInfoModel.TackOffTimeList;
                            detail.TravelList        = fltOrderInfoModel.TravelList;
                            detail.OrderIdDes        = fltOrderInfoModel.OrderId.ToString();
                        }
                        else if (detail.OrderType == OrderSourceTypeEnum.FltModApply || detail.OrderType == OrderSourceTypeEnum.FltRetApply)
                        {
                            FltRetModApplyModel fltRetModApplyModel =
                                _getFlightRetModApplyBll.GetRetModApply(detail.OrderId);
                            if (fltRetModApplyModel == null)
                            {
                                continue;
                            }
                            detail.ChoiceReason      = fltRetModApplyModel.ChoiceReason;
                            detail.CorpPolicy        = fltRetModApplyModel.CorpPolicy;
                            detail.OrderAmount       = fltRetModApplyModel.TotalAuditPrice;
                            detail.PassengerNameList = fltRetModApplyModel.PassengerNameList;
                            detail.TackOffTimeList   = fltRetModApplyModel.TackOffTimeList;
                            detail.TravelList        = fltRetModApplyModel.TravelList;
                            detail.OrderIdDes        = fltRetModApplyModel.OrderId.ToString();
                        }
                        else if (detail.OrderType == OrderSourceTypeEnum.Tra)
                        {
                            TraOrderInfoModel traOrderInfoModel =
                                _getTraOrderServiceBll.GetTraOrderByOrderId(detail.OrderId);
                            if (traOrderInfoModel == null)
                            {
                                continue;
                            }
                            detail.ChoiceReason      = traOrderInfoModel.ChoiceReason;
                            detail.CorpPolicy        = traOrderInfoModel.CorpPolicy;
                            detail.OrderAmount       = traOrderInfoModel.Order.TotalMoney;
                            detail.PassengerNameList = traOrderInfoModel.PassengerNameList;
                            detail.TackOffTimeList   = traOrderInfoModel.TackOffTimeList;
                            detail.TravelList        = traOrderInfoModel.TravelList;
                            detail.OrderIdDes        = traOrderInfoModel.Order.OrderId.ToString();
                        }
                    }
                }
            }
            #endregion


            GetAuditOrderListResponseViewModel responseViewModel =
                Mapper.Map <AuditOrderListModel, GetAuditOrderListResponseViewModel>(list);
            return(responseViewModel);
        }
        public QueryFlightRetApplyModel QueryRetApply(QueryFlightRetApplyQueryModel query)
        {
            QueryFlightRetApplyModel queryFlightRetApplyModel = new QueryFlightRetApplyModel();

            _getFlightRetModApplyBll.AportInfo        = query.AportInfo;
            _getFlightRetModApplyBll.PolicyReasonList = query.PolicyReasonList;

            FltRetModApplyModel fltRetModApplyModel = _getFlightRetModApplyBll.GetRetModApply(query.Rmid);

            if ((query.Customer.IsShowAllOrder ?? 0) == 0) //没有查看全部订单权限
            {
                if (!query.IsFromAduitQuery)               //不是来自审批人查询
                {
                    if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() != "administrator" &&
                        query.Customer.Cid != fltRetModApplyModel.Cid)
                    {
                        throw new Exception("查无此退票申请");
                    }
                }
            }


            if (!string.IsNullOrEmpty(query.Customer?.UserID) && query.Customer.UserID.ToLower() == "administrator")
            {
                if ((query.CidList != null && !query.CidList.Contains(fltRetModApplyModel.Cid)) || query.CidList == null)
                {
                    throw new Exception("查无此退票申请");
                }
            }

            fltRetModApplyModel.ApplyCustomer = query.CorpCustomerList?.Find(n => n.Cid == fltRetModApplyModel.Cid);

            _getFlightRetModApplyBll.AportInfo = query.AportInfo;
            queryFlightRetApplyModel           = queryFlightRetApplyModel.ConvertFatherToSon(fltRetModApplyModel);
            if (!string.IsNullOrEmpty(queryFlightRetApplyModel.Remark) &&
                queryFlightRetApplyModel.Remark.Contains("航空公司收"))
            {
                int d = queryFlightRetApplyModel.Remark.IndexOf("航空公司收", StringComparison.Ordinal);
                queryFlightRetApplyModel.Remark = queryFlightRetApplyModel.Remark.Substring(0, d);
            }

            FltRefundOrderModel refundOrderModel = _getFlighRefundOrderBll.GetFlighRefundOrderByRmid(query.Rmid);

            if (refundOrderModel != null)
            {
                queryFlightRetApplyModel.RefundOrder = refundOrderModel;
                queryFlightRetApplyModel.PassengerList.ForEach(n =>
                {
                    n.IsRet = true;
                });
            }


            List <int> sequenceList = fltRetModApplyModel.DetailList.Select(n => n.Sequence).Distinct().ToList();
            List <FltRetFlightModel> fltRetFlightModels = new List <FltRetFlightModel>();

            foreach (var sequence in sequenceList)
            {
                List <FltRetModFlightApplyModel> fltRetModFlightApplyModels =
                    fltRetModApplyModel.DetailList.FindAll(n => n.Sequence == sequence);
                FltRetFlightModel fltRetFlightModel =
                    Mapper.Map <FltRetModFlightApplyModel, FltRetFlightModel>(fltRetModFlightApplyModels[0]);
                fltRetFlightModel.PassengerList = fltRetModFlightApplyModels.Select(n => n.PassengerModel).ToList();
                fltRetFlightModels.Add(fltRetFlightModel);
            }

            queryFlightRetApplyModel.FltRetFlightList = fltRetFlightModels;
            return(queryFlightRetApplyModel);
        }