예제 #1
0
        private List <FltRefundOrderModel> Convert(List <FltRefundOrderEntity> refundOrderEntities)
        {
            List <FltRefundOrderModel> refundModels = new List <FltRefundOrderModel>();
            List <int> rmidList = refundOrderEntities.Select(n => n.RefundId).ToList();
            List <FltRefundOrderDetailEntity> refundOrderDetailEntities =
                _fltRefundOrderDetailDal.Query <FltRefundOrderDetailEntity>(n => rmidList.Any(x => x == n.Rid)).ToList();


            foreach (FltRefundOrderEntity fltRefundOrderEntity in refundOrderEntities)
            {
                FltRefundOrderModel refundModel = Mapper.Map <FltRefundOrderEntity, FltRefundOrderModel>(fltRefundOrderEntity);
                List <FltRefundOrderDetailEntity> detailList = refundOrderDetailEntities.FindAll(n => n.Rid == fltRefundOrderEntity.RefundId);
                refundModel.DetailList = Mapper.Map <List <FltRefundOrderDetailEntity>, List <FltRefundDetailOrderModel> >(detailList);
                refundModels.Add(refundModel);
            }



            return(refundModels);
        }
        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);
        }