/// <summary>
 /// 获取机票出票推送内容
 /// </summary>
 /// <returns></returns>
 private void GetFltPrintTicketMessage(SendAppMessageModel sendAppMessageModel)
 {
     if (sendAppMessageModel.OrderType == OrderSourceTypeEnum.Flt &&
         sendAppMessageModel.SendType == SendAppMessageTypeEnum.PrintTicketNotice)
     {
         FltOrderEntity fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(sendAppMessageModel.OrderId);
         sendAppMessageModel.SendContent = string.Format("您的机票订单{0}已经出票,请确认", fltOrderEntity.OrderId);
     }
 }
        /// <summary>
        /// 按照乘机人拆分订单
        /// </summary>
        /// <returns></returns>
        public List <int> SplitFltOrderByPassenger(int orderId, string oid)
        {
            #region 源数据
            FltOrderEntity splitFromOrderEntity = _fltOrderDal.Find <FltOrderEntity>(orderId);
            if (splitFromOrderEntity == null)
            {
                throw new Exception("未找到源订单");
            }
            List <FltFlightEntity> splitFromFlightEntities =
                _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == orderId, true).ToList();
            List <FltPassengerEntity> splitFromPassengerEntities =
                _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == orderId, true)
                .ToList();
            if (splitFromPassengerEntities.Count == 1)
            {
                throw new Exception("只有一个乘机人不能拆单");
            }

            FltOrderUnionEntity     splitFromOrderUnionEntity = _fltOrderUnionDal.Find <FltOrderUnionEntity>(orderId);
            FltCorpCostCenterEntity splitFromCostCenterEntity =
                _fltCorpCostCenterDal.Find <FltCorpCostCenterEntity>(orderId);
            #endregion

            List <int> orderIdList = new List <int>();

            for (int i = 0; i < splitFromPassengerEntities.Count; i++)
            {
                int id = AddOrder(splitFromOrderEntity, splitFromOrderUnionEntity, splitFromCostCenterEntity,
                                  splitFromFlightEntities,
                                  splitFromPassengerEntities[i], (i == 0), oid);
                orderIdList.Add(id);
            }

            return(orderIdList);
        }
示例#3
0
        public AuditResultModel RunAudit(AuditFltOrderQueryModel query)
        {
            FltOrderEntity orderEntity = _fltOrderDal.Find <FltOrderEntity>(query.Id);
            FltOrderModel  orderModel  = Mapper.Map <FltOrderEntity, FltOrderModel>(orderEntity);

            if (orderModel == null)
            {
                throw new MojoryException(MojoryApiResponseCode.NoFindOrder);
            }
            query.FltOrder = orderModel;
            //进行验证
            _validataAuditInfoBll.Validata(query);


            //进行审批
            AuditResultModel code    = new AuditResultModel();
            IRunAuditVisitor visitor = new RunAuditVisitor(_fltOrderDal, _fltOrderLogDal, query);

            if (query.AuditStep == FltOrderCheckStatusEnum.T.ToString())//待一级审批
            {
                AuditOrderAbstract auditOrderFirst = new AuditOrderFirst();
                code = auditOrderFirst.RunAudit(visitor);
            }
            else if (query.AuditStep == FltOrderCheckStatusEnum.S.ToString())//待二级审批
            {
                AuditOrderAbstract auditOrderSecond = new AuditOrderSecond();
                code = auditOrderSecond.RunAudit(visitor);
            }

            return(code);
        }
示例#4
0
        public int AddRetModApply(AddRetModApplyModel addRetModApplyModel)
        {
            FltOrderEntity       fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(addRetModApplyModel.OrderId);
            FltRetModApplyEntity applyEntity    = Mapper.Map <AddRetModApplyModel, FltRetModApplyEntity>(addRetModApplyModel);

            applyEntity.CorpPolicyId = fltOrderEntity.CorpPolicyId;
            applyEntity.CorpAduitId  = fltOrderEntity.CorpAduitId;


            if (!applyEntity.ProcessStatus.HasValue)
            {
                applyEntity.ProcessStatus = 0;
            }
            if (string.IsNullOrEmpty(applyEntity.RefundType))
            {
                applyEntity.RefundType = "实退";
            }
            applyEntity = _fltRetModApplyDal.Insert(applyEntity);

            List <FltRetModFlightApplyEntity> flightApplyEntities =
                Mapper.Map <List <FltRetModFlightApplyModel>, List <FltRetModFlightApplyEntity> >(addRetModApplyModel.DetailList);

            foreach (var fltRetModFlightApplyEntity in flightApplyEntities)
            {
                fltRetModFlightApplyEntity.Rmid        = applyEntity.Rmid;
                fltRetModFlightApplyEntity.OrderStatus = applyEntity.OrderStatus;
                if (string.IsNullOrEmpty(fltRetModFlightApplyEntity.FlightNo))
                {
                    FltFlightEntity flightEntity = _fltFlightDal.Query <FltFlightEntity>(
                        n => n.OrderId == applyEntity.OrderId && n.Sequence == fltRetModFlightApplyEntity.Sequence, true)
                                                   .FirstOrDefault();
                    if (flightEntity != null)
                    {
                        fltRetModFlightApplyEntity.FlightNo = flightEntity.FlightNo;
                    }
                }
                _fltRetModFlightApplyDal.Insert(fltRetModFlightApplyEntity);
            }
            string orderType            = (addRetModApplyModel.OrderType == "R" ? "退票" : "改签");
            FltRetModApplyLogEntity log = new FltRetModApplyLogEntity()
            {
                Rmid    = applyEntity.Rmid,
                Oid     = applyEntity.CreateOid,
                LogTime = DateTime.Now,
                Remark  = addRetModApplyModel.Oid + "新增" + orderType + "申请",
                LogType = "新增"
            };

            _fltRetModApplyLogDal.Insert(log);

            return(applyEntity.Rmid);
        }
        public string GetPnrNo(int orderid, string email)
        {
            string isServer = AppSettingsHelper.GetAppSettings(AppSettingsEnum.IsServer);

            if (isServer != "T")//如果不是生产环境,不定位
            {
                return(string.Empty);
            }
            FltOrderEntity orderEntity = _fltOrderDal.Find <FltOrderEntity>(orderid);

            if ((orderEntity.ProcessStatus & 1) == 1)//如果已经定位,则不再定位
            {
                return(string.Empty);
            }
            string pnrNo = _doPnrNoBll.DoPnrNo(orderid, orderEntity.CreateOid);

            if (!string.IsNullOrEmpty(pnrNo))
            {
                //定位成功之后,设置已定位
                orderEntity.ProcessStatus = orderEntity.ProcessStatus + 1;
                _fltOrderDal.Update(orderEntity, new string[] { "ProcessStatus" });
                _fltOrderLogDal.Insert(new FltOrderLogEntity()
                {
                    OrderId = orderEntity.OrderId,
                    LogTime = DateTime.Now,
                    LogType = "修改订单",
                    Oid     = "sys",
                    Remark  = "线上订单,设置已定位" + pnrNo
                });
            }
            else
            {
                if (!string.IsNullOrEmpty(email))
                {
                    string url = string.Format("http://192.168.1.188/orderprocess/Flt_order.asp?orderid={0}",
                                               orderid);
                    string content = string.Format("订单号:<a  href='{0}' >{1}</a>", url, orderid);
                    new TaskFactory().StartNew(() =>
                    {
                        EmailHelper.SendEmail("", "国内机票定位异常", null, null, content, email);
                    });
                }
            }
            return(pnrNo);
        }
示例#6
0
        public int CancelOnlineCorpOrder(int orderId, int cid, string remark)
        {
            FltOrderEntity orderEntity = _fltOrderDal.Find <FltOrderEntity>(orderId);

            if (orderEntity == null)
            {
                throw new Exception("查无此订单");
            }
            if (cid != orderEntity.Cid)
            {
                throw new Exception("查无此订单");
            }
            if (orderEntity.Orderstatus == "C")
            {
                throw new Exception("此订单已取消");
            }

            if ((orderEntity.ProcessStatus & 8) == 8)
            {
                throw new Exception("此订单已经出票,不能取消");
            }


            FltOrderLogEntity log = new FltOrderLogEntity()
            {
                OrderId = orderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "修改订单"
            };

            orderEntity.Orderstatus = "C";
            orderEntity.CancelType  = "C";
            orderEntity.Remark      = (orderEntity.Remark ?? "") + ",客户自行取消";
            orderEntity.Oid         = "sys";
            log.Remark = "操作人:" + cid + ",原因:" + remark;

            _fltOrderDal.Update(orderEntity, new string[] { "Orderstatus", "CancelType", "Remark", "Oid" });

            _fltOrderLogDal.Insert(log);

            return(0);
        }
示例#7
0
        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);
        }
示例#8
0
        /// <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);
        }
示例#9
0
        /// <summary>
        /// 复制差旅订单
        /// </summary>
        /// <param name="copyFltOrderModel"></param>
        /// <returns></returns>
        public int CopyOrder(CopyFltOrderModel copyFltOrderModel)
        {
            FltOrderEntity copyFromOrderEntity = _fltOrderDal.Find <FltOrderEntity>(copyFltOrderModel.CopyFromOrderId);

            if (copyFromOrderEntity == null)
            {
                throw new Exception("复制来源订单异常");
            }
            List <FltFlightEntity> copyFromFlightEntities =
                _fltFlightDal.Query <FltFlightEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true).ToList();

            List <FltPassengerEntity> copyFromPassengerEntities =
                _fltPassengerDal.Query <FltPassengerEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true)
                .ToList();

            List <FltTicketNoEntity> copyFromTicketNoEntities =
                _fltTicketNoDal.Query <FltTicketNoEntity>(n => n.OrderId == copyFltOrderModel.CopyFromOrderId, true)
                .ToList();

            FltOrderUnionEntity copyFromOrderUnionEntity =
                _fltOrderUnionDal.Find <FltOrderUnionEntity>(copyFltOrderModel.CopyFromOrderId);

            FltCorpCostCenterEntity copyFromCostCenterEntity =
                _fltCorpCostCenterDal.Find <FltCorpCostCenterEntity>(copyFltOrderModel.CopyFromOrderId);

            FltOrderEntity          fltOrderEntity          = Mapper.Map <FltOrderEntity, FltOrderEntity>(copyFromOrderEntity);
            FltOrderUnionEntity     fltOrderUnionEntity     = Mapper.Map <FltOrderUnionEntity, FltOrderUnionEntity>(copyFromOrderUnionEntity);
            FltCorpCostCenterEntity fltCorpCostCenterEntity =
                Mapper.Map <FltCorpCostCenterEntity, FltCorpCostCenterEntity>(copyFromCostCenterEntity);

            List <FltFlightEntity> fltFlightEntities =
                Mapper.Map <List <FltFlightEntity>, List <FltFlightEntity> >(copyFromFlightEntities);
            List <FltPassengerEntity> fltPassengerEntities =
                Mapper.Map <List <FltPassengerEntity>, List <FltPassengerEntity> >(copyFromPassengerEntities);
            List <FltTicketNoEntity> fltTicketNoEntities =
                Mapper.Map <List <FltTicketNoEntity>, List <FltTicketNoEntity> >(copyFromTicketNoEntities);


            fltOrderEntity.Payamount           = copyFltOrderModel.PayAmount;
            fltOrderEntity.CreditcardfeeAmount = copyFltOrderModel.CreditCardfeeamount;
            fltOrderEntity.Voucheramount       = copyFltOrderModel.Voucheramount;
            fltOrderEntity.SendTicketAmount    = copyFltOrderModel.SendTicketamount;
            fltOrderEntity.Totalamount         = fltOrderEntity.Payamount + fltOrderEntity.CreditcardfeeAmount;
            fltOrderEntity.CreateOid           = copyFltOrderModel.CreateOid;
            if (string.IsNullOrEmpty(fltOrderEntity.Remark))
            {
                fltOrderEntity.Remark = "无";
            }

            fltOrderEntity.ReturnAccountOid  = "";
            fltOrderEntity.ReturnAccountTime = null;
            fltOrderEntity.OutTicketStatus   = "N";
            fltOrderEntity.ProcessStatus     = 1;
            fltOrderEntity.Orderstatus       = "P";

            if (string.IsNullOrEmpty(fltOrderEntity.Description))
            {
                fltOrderEntity.Description = ",";
            }
            if (string.IsNullOrEmpty(fltOrderEntity.IsOnLinePay))
            {
                fltOrderEntity.IsOnLinePay = "F";
            }
            if (string.IsNullOrEmpty(fltOrderEntity.SendTicketType))
            {
                fltOrderEntity.SendTicketType = SendTicketTypeEnum.Not.ToString();
            }

            fltOrderEntity.RealAcceptDatetime = null;
            fltOrderEntity.RealPayDatetime    = null;
            fltOrderEntity.Collectiontime     = null;
            fltOrderEntity.CollectionOid      = string.Empty;
            fltOrderEntity.PrintTicketOid     = null;
            fltOrderEntity.PrintTicketTime    = null;
            fltOrderEntity.PrintOrderTime     = null;

            if (copyFltOrderModel.CopyType == "X")//虚出复制
            {
                //判断当前原始订单是否有虚退
                int xuTuiCount = _fltRetModApplyDal.Query <FltRetModApplyEntity>(
                    n => n.OrderType.ToUpper() == "R" &&
                    n.OrderId == copyFltOrderModel.CopyFromOrderId && n.OrderStatus.ToUpper() != "C" &&
                    n.RefundType == "虚退").Count();
                if (xuTuiCount == 0)
                {
                    throw new Exception("当前订单不存在虚退,不允许虚退复制");
                }


                fltOrderEntity.OrderDate = copyFromOrderEntity.OrderDate;
                fltOrderEntity.CopyType  = "X";
                //如果当前原始订单不是虚退复制的订单
                if (string.IsNullOrEmpty(copyFromOrderEntity.CopyType))
                {
                    fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId;
                }
                else
                {
                    if (copyFromOrderEntity.CopyType == "X" && copyFromOrderEntity.CopyFromOrderId.HasValue)
                    {
                        fltOrderEntity.CopyFromOrderId = copyFromOrderEntity.CopyFromOrderId;
                    }
                    else
                    {
                        fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId;
                    }
                }
            }
            else
            {
                fltOrderEntity.CopyType        = "C";
                fltOrderEntity.CopyFromOrderId = copyFltOrderModel.CopyFromOrderId;
                fltOrderEntity.OrderDate       = DateTime.Now;
            }

            fltOrderEntity = _fltOrderDal.Insert(fltOrderEntity);

            if (fltOrderUnionEntity != null)
            {
                fltOrderUnionEntity.OrderId           = fltOrderEntity.OrderId;
                fltOrderUnionEntity.FivePrintId       = null;
                fltOrderUnionEntity.FivePrintLastTime = null;
                fltOrderUnionEntity.IsNeedPrintTime   = null;
                if (string.IsNullOrEmpty(fltOrderUnionEntity.IsMobile))
                {
                    fltOrderUnionEntity.IsMobile = "F";
                }
                _fltOrderUnionDal.Insert(fltOrderUnionEntity);
            }

            foreach (var fltFlightEntity in fltFlightEntities)
            {
                CopyFltFlightModel copyFltFlightModel =
                    copyFltOrderModel.FlightList.Find(n => n.Sequence == fltFlightEntity.Sequence);
                if (string.IsNullOrEmpty(fltFlightEntity.RecordNo))
                {
                    fltFlightEntity.RecordNo = "AAAAAA";
                }
                fltFlightEntity.OrderId   = fltOrderEntity.OrderId;
                fltFlightEntity.Sequence  = copyFltFlightModel.Sequence;
                fltFlightEntity.OilFee    = copyFltFlightModel.OilFee;
                fltFlightEntity.Rate      = copyFltFlightModel.Rate;
                fltFlightEntity.SalePrice = copyFltFlightModel.SalePrice;
                fltFlightEntity.TaxFee    = copyFltFlightModel.TaxFee;
                if (string.IsNullOrEmpty(fltFlightEntity.Airportson))
                {
                    fltFlightEntity.Airportson = "----";
                }
                _fltFlightDal.Insert(fltFlightEntity);
            }

            foreach (var fltPassengerEntity in fltPassengerEntities)
            {
                fltPassengerEntity.OrderId = fltOrderEntity.OrderId;
                if (string.IsNullOrEmpty(fltPassengerEntity.Remark))
                {
                    fltPassengerEntity.Remark = "无";
                }
                _fltPassengerDal.Insert(fltPassengerEntity);
            }

            if (fltTicketNoEntities != null && fltTicketNoEntities.Count > 0)
            {
                foreach (var fltTicketNoEntity in fltTicketNoEntities)
                {
                    fltTicketNoEntity.OrderId = fltOrderEntity.OrderId;
                    _fltTicketNoDal.Insert(fltTicketNoEntity);
                }
            }

            if (fltCorpCostCenterEntity != null)
            {
                fltCorpCostCenterEntity.Orderid = fltOrderEntity.OrderId;
                _fltCorpCostCenterDal.Insert <FltCorpCostCenterEntity>(fltCorpCostCenterEntity);
            }

            FltOrderLogEntity log = new FltOrderLogEntity()
            {
                OrderId = fltOrderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "新建订单",
                Remark  = "复制订单,来源订单号:" + copyFltOrderModel.CopyFromOrderId + ",马甲订单号:" + fltOrderEntity.CopyFromOrderId,
                Oid     = fltOrderEntity.CreateOid
            };

            _fltOrderLogDal.Insert(log);


            //将原始订单设置为线上隐藏
            if (copyFltOrderModel.CopyType == "X")
            {
                copyFromOrderEntity.IsOnlineShow = 1;
                _fltOrderDal.Update(copyFromOrderEntity, new string[] { "IsOnlineShow" });
            }

            return(fltOrderEntity.OrderId);
        }
示例#10
0
        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);
        }
示例#11
0
        /// <summary>
        /// 一级审核
        /// </summary>
        /// <param name="firstAudit"></param>
        /// <returns></returns>
        public AuditResultModel DoFirstAudit(AuditOrderFirst firstAudit)
        {
            FltOrderEntity    fltOrderEntity = _fltOrderDal.Find <FltOrderEntity>(_query.Id);
            FltOrderLogEntity log            = new FltOrderLogEntity()
            {
                OrderId = fltOrderEntity.OrderId,
                LogTime = DateTime.Now,
                LogType = "审批订单",
                Oid     = "sys"
            };



            #region 审批操作

            bool          isSendEmail = false;
            List <string> properties  = new List <string>();
            if (IsAgree)
            {
                bool isHasSecond = _query.FltOrder.CPIdSecond.HasValue; //是否存在二级审批

                if (!isHasSecond)
                {
                    //1.2 如果不存在二级审批,则直接通过
                    fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.W.ToString();
                    log.Remark = string.Format("已通过{0}审批", _query.AuditCustomer?.RealName);
                }
                else
                {
                    isSendEmail = true;
                    //1.2 如果存在二级审批,则发送二级审批邮件
                    fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.S.ToString();
                    log.Remark = string.Format("已通过{0}审批,待二级审核", _query.AuditCustomer?.RealName);
                }
                properties.Add("CheckStatus");
            }
            else
            {
                //2.否决审批
                //2.1 取消订单
                if ((fltOrderEntity.ProcessStatus & 8) == 8)
                {
                    throw new Exception("该订单已经出票,不能否决,请联系客服");
                }
                fltOrderEntity.CheckStatus = FltOrderCheckStatusEnum.J.ToString();
                fltOrderEntity.Orderstatus = "C";
                fltOrderEntity.CancelType  = "C";
                //log.Remark = "订单审核状态:一级审核不通过。一级审核人:" + _query.AuditCustomer?.RealName;
                log.Remark = string.Format("已被{0}拒绝", _query.AuditCustomer?.RealName);
                properties.Add("CheckStatus");
                properties.Add("CancelType");
                properties.Add("Orderstatus");
            }

            #endregion



            _fltOrderDal.Update(fltOrderEntity, properties.ToArray());
            _fltOrderLogDal.Insert(log);

            //发送邮件
            if (isSendEmail)
            {
                SendEmail(fltOrderEntity);
            }

            return(new AuditResultModel()
            {
                Code = 0,
                AuditResult = log.Remark,
                NextAuditCid = fltOrderEntity.CPIdSecond,
                OwnCid = fltOrderEntity.Cid,
                Id = fltOrderEntity.OrderId,
                OrderType = OrderSourceTypeEnum.Flt
            });
        }