public void PostCorporationReturnsOkWhenModelIsValid()
        {
            var validModel = new CorporationModel
            {
                Name      = "name",
                CompanyId = 1
            };

            var company = new Company();

            _mapperMock.Setup(m => m.Map <CorporationReturnModel>(It.IsAny <Corporation>()))
            .Returns(new CorporationReturnModel());
            _mapperMock.Setup(m => m.Map <Corporation>(It.IsAny <CorporationModel>()))
            .Returns(new Corporation());
            _companyRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(company);

            var result = _sut.PostEntity(validModel) as OkObjectResult;

            Assert.That(result, Is.Not.Null);
            Assert.That((CorporationReturnModel)result.Value, Is.Not.Null);

            _corporationRepositoryMock.Verify(m => m.Add(It.IsAny <Corporation>()), Times.Once);
            _companyRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
        public void update_a_corporation()
        {
            //Create corporation

            Connection one = new Connection();

            CorporationRepo repo = new CorporationRepo(new Connection());

            CorporationModel corporation = new CorporationModel();

            corporation.name    = "name";
            corporation.email   = "email";
            corporation.zip     = "3434-kj";
            corporation.address = "address";

            int id = repo.store(corporation);

            corporation.id = id;

            //Give corporation a new name

            corporation.name = "new name!";
            repo.update(corporation);

            one.Connect();
            SqlCommand    sqlCommand = new SqlCommand("select * from corporation where name = 'new name!'", one.getConnection());
            SqlDataReader reader     = sqlCommand.ExecuteReader();

            Assert.AreEqual(true, reader.HasRows);
            one.disConnect();

            repo.destroy(id);
        }
Exemplo n.º 3
0
        public AddModApplyResponseViewModel AddModApply(AddModApplyRequestViewModel request)
        {
            int rmid = 0;

            AddRetModApplyModel modApplyModel = Mapper.Map <AddModApplyRequestViewModel, AddRetModApplyModel>(request);

            //1.获取改签乘客
            CustomerModel customerModel = _getCustomerServiceBll.GetCustomerByCid(request.Cid);

            modApplyModel.Customer       = customerModel;
            modApplyModel.IsOnlineRefund = request.IsOnline;
            modApplyModel.OrderType      = "M";
            modApplyModel.CorpId         = customerModel.CorpID;

            CorporationModel corporationModel = _getCorpServiceBll.GetCorp(customerModel.CorpID);

            if (corporationModel.IsAmplitudeCorp == "T")
            {
                modApplyModel.OrderStatus = "T";
            }


            using (var transaction = this.Context.Database.BeginTransaction())
            {
                try
                {
                    rmid = _addFltDomesticModApplyServiceBll.AddModApply(modApplyModel);
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw;
                }
            }
            new TaskFactory().StartNew(() =>
            {
                //2.发送提醒邮件
                OperatorModel operatorModel = _getOperatorServiceBll.GetOperatorByOid(corporationModel.ResponsibleOid);
                string mail            = operatorModel.Email;
                string corporationName = corporationModel.CorpName;

                StringBuilder mailContent = new StringBuilder();
                mailContent.Append("<b>客户改签提醒:<b/>");
                mailContent.Append("<br/>");
                mailContent.Append("[" + corporationName + "] 已经申请了改签,订单编号:" + request.OrderId.ToString() + ",请差旅顾问及时处理!");
                mailContent.Append("<br/>");
                mailContent.Append("<b>下单时间:" + DateTime.Now + ",请及时关注~<b/>");
                if (!string.IsNullOrEmpty(mail))
                {
                    bool flag = EmailHelper.SendEmail("", "客户改签提醒", null, null, mailContent.ToString(), mail);
                }
            });

            return(new AddModApplyResponseViewModel()
            {
                Rmid = rmid
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// 修改公司表信息
        /// </summary>
        /// <param name="par"></param>
        /// <param name="properties"></param>
        /// <returns></returns>
        public int UpdateCorpIndividuation(CorporationModel par)
        {
            if (par == null)
            {
                return(-1);
            }

            CorporationEntity corporationEntity =
                Mapper.Map <CorporationModel, CorporationEntity>(par);

            List <string> argList = new List <string>();

            if (corporationEntity.IsNoteVerify.HasValue)
            {
                argList.Add("IsNoteVerify");
            }

            if (corporationEntity.IsAllowUserInsurance.HasValue)
            {
                argList.Add("IsAllowUserInsurance");
            }

            if (corporationEntity.IsShareFly.HasValue)
            {
                argList.Add("IsShareFly");
            }

            if (corporationEntity.IsXYPrice.HasValue)
            {
                argList.Add("IsXYPrice");
            }

            if (corporationEntity.IsAllSeat.HasValue)
            {
                argList.Add("IsAllSeat");
            }

            if (corporationEntity.IsTravelReason.HasValue)
            {
                argList.Add("IsTravelReason");
            }

            if (corporationEntity.IsHeightSeat.HasValue)
            {
                argList.Add("IsHeightSeat");
            }
            if (corporationEntity.IsTraAllSeat.HasValue)
            {
                argList.Add("IsTraAllSeat");
            }

            _corporationDal.Update(corporationEntity, argList.ToArray());
            return(0);
        }
Exemplo n.º 5
0
        public CorporationModel GetCorp(string corpId)
        {
            if (string.IsNullOrEmpty(corpId))
            {
                return(null);
            }
            CorporationEntity corporationEntity =
                _corporationDal.Query <CorporationEntity>(n => n.CorpId.ToLower() == corpId.ToLower()).FirstOrDefault();
            CorporationModel corporationModel =
                Mapper.Map <CorporationEntity, CorporationModel>(corporationEntity);

            return(corporationModel);
        }
Exemplo n.º 6
0
        public ResponseBaseViewModel <CustomerInfoViewModel> GetCustomerInfo()
        {
            int cid = this.GetCid();
            ICustomerDomainFactory customerFactory = new CustomerDomainFactory();
            var customerDomain = customerFactory.CreateDomainObj();
            CustomerInfoModel customerInfoModel = customerDomain.GetCustomerInfo(cid);

            if (customerInfoModel.IsLock == "T")
            {
                throw new Exception("当前客户已经被冻结");
            }
            if (customerInfoModel.IsDel == "T")
            {
                throw new Exception("当前客户已经被删除");
            }

            CustomerInfoViewModel viewModel =
                Mapper.Map <CustomerInfoModel, CustomerInfoViewModel>(customerInfoModel);

            if (!string.IsNullOrEmpty(customerInfoModel.CorpId))
            {
                ICorporationDomainFactory corporationDomainFactory = new CorporationDomainFactory();
                var corpDomain = corporationDomainFactory.CreateDomainObj();
                CorporationModel corporationModel = corpDomain.GetCorporationByCorId(customerInfoModel.CorpId);
                if (corporationModel.IsAmplitudeCorp == "T")
                {
                    viewModel.IsCorpSystemCustomer = "T";
                }
                else
                {
                    viewModel.IsCorpSystemCustomer = "F";
                }
                viewModel.CorpName = corporationModel.CorpName;
            }
            else
            {
                viewModel.IsCorpSystemCustomer = "F";
            }

            ResponseBaseViewModel <CustomerInfoViewModel> v = new ResponseBaseViewModel <CustomerInfoViewModel>()
            {
                Flag = new ResponseCodeViewModel()
                {
                    Code = 0, MojoryToken = this.GetToken()
                },
                Data = viewModel
            };

            return(v);
        }
Exemplo n.º 7
0
        public IActionResult update([FromBody] CorporationModel corporation)
        {
            try
            {
                corporationRepo.update(corporation);
                return(StatusCode(200));
            }

            catch (Exception ex)
            {
                errors.log(ex);
                return(Json(null));
            }
        }
 public bool UpdateCorporation(CorporationModel corp)
 {
     if (Validate(corp))
     {
         var pos = CorporationList.FindIndex(c => c.CorporationId == corp.CorporationId);
         if (pos >= 0)
         {
             CorporationList.RemoveAt(pos);
         }
         CorporationList.Add(corp);
         return(true);
     }
     return(false);
 }
 private bool Validate(CorporationModel corp)
 {
     if (string.IsNullOrEmpty(corp.CorporationId))
     {
         ErrorDescription = "Corporation Id is required";
         return(false);
     }
     if (string.IsNullOrEmpty(corp.Name))
     {
         ErrorDescription = "Corporation Name is required";
         return(false);
     }
     return(true);
 }
Exemplo n.º 10
0
        public async Task <bool> AddCorporation(CorporationModel corp)
        {
            if (Validate(corp))
            {
                if (CorporationList.Exists(c => c.CorporationId == corp.CorporationId))
                {
                    ErrorDescription = "Corporation Id already exists";
                    return(false);
                }
                CorporationList.Add(corp);
                await _corporationLibrary.AddCorporation(corp);

                return(true);
            }
            return(false);
        }
Exemplo n.º 11
0
        public int UpdateCorpIndividuation(GetCorpIndividuationRequestViewModel request)
        {
            CorporationModel corModel = new CorporationModel();

            corModel.CorpId               = request.CorpId;
            corModel.IsNoteVerify         = request.IsNoteVerify;
            corModel.IsAllowUserInsurance = Convert.ToInt32(request.IsAllowUserInsurance);
            corModel.IsShareFly           = request.IsShareFly;
            corModel.IsXYPrice            = request.IsXYPrice;
            corModel.IsAllSeat            = request.IsAllSeat;
            corModel.IsTravelReason       = request.IsTravelReason;
            corModel.IsHeightSeat         = request.IsHeightSeat;
            corModel.IsTraAllSeat         = request.IsTraAllSeat;

            return(_getCorpServiceBll.UpdateCorpIndividuation(corModel));
        }
        public void UpdateCorporationReturnsBadRequestWhenIdFromModelDoesNotMatchIdFromQueryParameter()
        {
            var invalidModel = new CorporationModel
            {
                Id        = 1,
                CompanyId = 1
            };

            var company = new Company();

            _companyRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(company);

            var result = _sut.UpdateEntity(invalidModel, invalidModel.Id + 1) as BadRequestObjectResult;

            Assert.That(result, Is.Not.Null);

            _corporationRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Corporation>()), Times.Never);
            _companyRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
        public void PostCorporationReturnsBadRequestWhenModelIsInvalid()
        {
            var invalidModel = new CorporationModel
            {
                CompanyId = 1
            };
            var company = new Company();

            _sut.ModelState.AddModelError("name", "name is required");

            _companyRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(company);

            var result = _sut.PostEntity(invalidModel) as BadRequestResult;

            Assert.That(result, Is.Not.Null);

            _corporationRepositoryMock.Verify(m => m.Add(It.IsAny <Corporation>()), Times.Never);
            _companyRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
        public void PostCorporationReturnsNotFoundWhenCompanyIsNotFound()
        {
            var validModel = new CorporationModel
            {
                Name      = "",
                CompanyId = 1
            };

            Company company = null;

            _companyRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(company);

            var result = _sut.PostEntity(validModel) as NotFoundObjectResult;

            Assert.That(result, Is.Not.Null);

            _corporationRepositoryMock.Verify(m => m.Add(It.IsAny <Corporation>()), Times.Never);
            _companyRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
        public void UpdateCorporationReturnsNotFoundWhenCorporationIsNotFound()
        {
            var invalidModel = new CorporationModel
            {
                Id        = 1,
                CompanyId = 1
            };

            var company = new Company();

            _corporationRepositoryMock.Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Corporation>()))
            .Returns(false);
            _companyRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(company);

            var result = _sut.UpdateEntity(invalidModel, invalidModel.Id) as NotFoundObjectResult;

            Assert.That(result, Is.Not.Null);

            _corporationRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Corporation>()), Times.Once);
            _companyRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
Exemplo n.º 16
0
        public void store_and_delete_a_corporation()
        {
            Connection one = new Connection();
            Connection two = new Connection();

            CorporationRepo repo = new CorporationRepo(new Connection());

            //Create corporation

            CorporationModel corporation = new CorporationModel();

            corporation.name    = "name";
            corporation.email   = "email";
            corporation.zip     = "3434-kj";
            corporation.address = "address";

            int id = repo.store(corporation);


            one.Connect();
            SqlCommand    sqlCommand = new SqlCommand("select * from corporation where name = 'name' and email ='email' and zip = '3434-kj' and address = 'address'", one.getConnection());
            SqlDataReader reader     = sqlCommand.ExecuteReader();

            Assert.AreEqual(true, reader.HasRows);
            one.disConnect();

            repo.destroy(id);

            two.Connect();

            //Delete corporation

            SqlCommand    sqlCommandTwo = new SqlCommand("select * from corporation where name = 'name' and email ='email' and zip = '3434-kj' and address = 'address'", two.getConnection());
            SqlDataReader readerTwo     = sqlCommandTwo.ExecuteReader();

            Assert.AreEqual(false, readerTwo.HasRows);
            one.disConnect();
        }
        public void UpdateCorporationReturnsOkWhenEverythingIsCorrect()
        {
            var validModel = new CorporationModel
            {
                Id        = 1,
                Name      = "",
                CompanyId = 1
            };

            var company = new Company();

            _corporationRepositoryMock.Setup(m => m.Update(It.IsAny <int>(), It.IsAny <Corporation>()))
            .Returns(true);
            _companyRepositoryMock.Setup(m => m.GetById(It.IsAny <int>()))
            .Returns(company);

            var result = _sut.UpdateEntity(validModel, validModel.Id) as OkResult;

            Assert.That(result, Is.Not.Null);

            _corporationRepositoryMock.Verify(m => m.Update(It.IsAny <int>(), It.IsAny <Corporation>()), Times.Once);
            _companyRepositoryMock.Verify(m => m.GetById(It.IsAny <int>()), Times.Once);
        }
Exemplo n.º 18
0
        public AddTraOrderResponseViewModel AddTraOrder(AddTraOrderRequestViewModel request)
        {
            //判断是否是生产环境,如果不是则强制request.AddOrderType=1,不走接口
            string oidTemp = request.Order.CreateOid;
            TraAddOrderResultModel addOrderResultModel = new TraAddOrderResultModel();
            TraAddOrderModel       addOrderModel       = Mapper.Map <AddTraOrderRequestViewModel, TraAddOrderModel>(request);

            addOrderModel.Order.Cid         = request.Cid;
            addOrderModel.Order.OrderSource = request.OrderSource;



            //0.获取客户信息服务
            addOrderModel.Customer = _getCustomerServiceBll.GetCustomerByCid(request.Cid);
            if (!string.IsNullOrEmpty(addOrderModel.Customer.CorpID))
            {
                CorporationModel corporationModel = _getCorpServiceBll.GetCorp(addOrderModel.Customer.CorpID);
                if (!addOrderModel.Order.IsPrint.HasValue)
                {
                    addOrderModel.Order.IsPrint = corporationModel.IsPrint ?? 0;
                }
                if (!string.IsNullOrEmpty(corporationModel.ResponsibleOid) && request.OrderSource != "O")
                {
                    addOrderModel.Order.CreateOid = corporationModel.ResponsibleOid;
                    if (addOrderModel.OrderStatus == null)
                    {
                        addOrderModel.OrderStatus = new TraOrderStatusModel();
                    }
                    if ((addOrderModel.OrderStatus.ProccessStatus & 64) != 64)
                    {
                        addOrderModel.OrderStatus.ProccessStatus = addOrderModel.OrderStatus.ProccessStatus + 64;
                    }
                }
            }

            //1.添加火车订单
            using (var transaction = this.Context.Database.BeginTransaction())
            {
                try
                {
                    /***
                     * 1)手动路线:
                     * 添加完订单,直接发起送审
                     * 2)自动路线:
                     * 添加完订单,不发起送审,发起申请占位请求,在确认占位后再发起送审
                     * **/
                    addOrderResultModel = _addTraOrderServiceBll.AddTraOrder(addOrderModel);

                    #region 送审

                    if (addOrderResultModel.OrderId > 0 && request.AddOrderType == 1)//手动路线发起送审
                    {
                        SubmitCorpAduitOrderModel submitCorpAduitOrder = new SubmitCorpAduitOrderModel()
                        {
                            OrderInfoList = new List <SubmitCorpAduitOrderDetailModel>()
                            {
                                new SubmitCorpAduitOrderDetailModel()
                                {
                                    OrderId   = addOrderResultModel.OrderId,
                                    OrderType = OrderSourceTypeEnum.Tra
                                }
                            },
                            PolicyId        = addOrderModel.Order.CorpPolicyId,
                            AduitConfigId   = addOrderModel.Order.CorpAduitId,
                            Source          = request.OrderSource,
                            SubmitCid       = request.Cid,
                            SubmitOid       = oidTemp,
                            IsViolatePolicy =
                                (addOrderModel.OrderDetailList.Find(n => !string.IsNullOrEmpty(n.CorpPolicy)) != null
                                    ? true
                                    : false),
                            OrderType = OrderSourceTypeEnum.Tra
                        };
                        _submitCorpAduitOrderServiceBll.Submit(submitCorpAduitOrder);
                    }

                    #endregion

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw;
                }
            }

            if (request.AddOrderType == 0)//自动路线发起占位申请
            {
                //2.发起火车占位
                _requestHoldSeatServiceBll.RequestHoldSeat(addOrderResultModel.AddOrderModel);
            }


            return(new AddTraOrderResponseViewModel()
            {
                OrderId = addOrderResultModel.OrderId,
                AddOrderType = request.AddOrderType
            });
        }
Exemplo n.º 19
0
        /// <summary>
        /// 根据cid,获取查询行程视图
        /// </summary>
        /// <param name="cid"></param>
        /// <returns></returns>
        public BaseQueryTravelModel GetQueryTravelView(int cid)
        {
            BaseQueryTravelModel queryTravelModel  = new BaseQueryTravelModel();
            CustomerInfoModel    customerInfoModel = _customerBll.GetCustomerByCid(cid);

            queryTravelModel.IsMaster             = "F"; //默认为该客户非预订员
            queryTravelModel.IsCorpSystemCustomer = "T"; //默认是差旅系统客户
            CorporationModel corporationModel = null;

            if (!string.IsNullOrEmpty(customerInfoModel.CorpId))
            {
                corporationModel = _corporationBll.GetCorpInfoByCorpId(customerInfoModel.CorpId);
            }

            if (corporationModel != null && corporationModel.IsAmplitudeCorp == "T")
            {
                #region 如果是预订员,则获取当前预定的部门信息

                if (!string.IsNullOrEmpty(customerInfoModel.IsMaster) && customerInfoModel.IsMaster.ToUpper() == "T")
                {
                    queryTravelModel.IsMaster       = "T";
                    queryTravelModel.DepartmentList = new List <CorpDepartmentModel>();
                    List <int>             departIds = new List <int>();
                    CustomerUnionInfoModel customerUnionInfoModel =
                        _customerUnionBll.GetCustomerUnionByCid(customerInfoModel.Cid);
                    if (!string.IsNullOrEmpty(customerUnionInfoModel.CorpDepartIDList)) //0:全部 -1外宾部
                    {
                        string[] departStrings = customerUnionInfoModel.CorpDepartIDList.Split(',');
                        departIds.AddRange(departStrings.Select(departString => Convert.ToInt32(departString)));
                    }
                    else
                    {
                        //如果是NULL,则默认0,-1
                        departIds.Add(0);
                        departIds.Add(-1);
                    }
                    if (departIds.Contains(0)) //全部部门
                    {
                        List <CorpDepartmentModel> departmentModels =
                            _corpDepartmentBll.GetCorpDepartmentByCorpId(customerInfoModel.CorpId);
                        departmentModels.ForEach(
                            n =>
                            queryTravelModel.DepartmentList.Add(new CorpDepartmentModel()
                        {
                            Id         = n.Id,
                            DepartName = n.DepartName
                        }));
                    }
                    else
                    {
                        List <CorpDepartmentModel> departmentModels =
                            _corpDepartmentBll.GetCorpDepartmentByIds(departIds);
                        departmentModels.ForEach(
                            n =>
                            queryTravelModel.DepartmentList.Add(new CorpDepartmentModel()
                        {
                            Id         = n.Id,
                            DepartName = n.DepartName
                        }));
                    }

                    if (queryTravelModel.DepartmentList.Count > 0)
                    {
                        //判断部门中是否存在员工,不存在则剔除
                        List <CustomerInfoModel> departCustomerInfoModels = _customerBll.GetCustomerByDepartId(departIds);
                        if (departCustomerInfoModels != null && departCustomerInfoModels.Count > 0)
                        {
                            for (int i = 0; i < queryTravelModel.DepartmentList.Count; i++)
                            {
                                if (
                                    departCustomerInfoModels.FindAll(
                                        n => n.CorpDepartId == queryTravelModel.DepartmentList[i].Id).Count == 0)
                                {
                                    queryTravelModel.DepartmentList.RemoveAt(i);
                                }
                            }
                        }
                    }

                    if (departIds.Contains(-1)) //外宾部门
                    {
                        queryTravelModel.DepartmentList.Add(new CorpDepartmentModel()
                        {
                            Id = -1, DepartName = "外宾部"
                        });
                    }

                    if (departIds.Count == 1 && departIds.Contains(0))//只有全部部门的时候,追加外宾,对前端网站维护进行容错处理
                    {
                        queryTravelModel.DepartmentList.Add(new CorpDepartmentModel()
                        {
                            Id = -1, DepartName = "外宾部"
                        });
                    }
                }

                #endregion
            }
            else
            {
                queryTravelModel.IsMaster             = "F";
                queryTravelModel.IsCorpSystemCustomer = "F";
            }
            return(queryTravelModel);
        }
Exemplo n.º 20
0
        public decimal GetServiceFeeByCorpId(int cid, string type)
        {
            decimal           serviceFee        = 0;
            CustomerInfoModel customerInfoModel = _customerBll.GetCustomerByCid(cid);
            int sfcid = 0;

            if (!string.IsNullOrEmpty(customerInfoModel.CorpId))//企业客户
            {
                CorporationModel corporationModel = _corporationBll.GetCorpInfoByCorpId(customerInfoModel.CorpId);
                if (!corporationModel.SfcId.HasValue || corporationModel.SfcId == 0)
                {
                    serviceFee = 0;
                }
                else
                {
                    sfcid = corporationModel.SfcId.Value;
                }
            }
            else
            {
                if (!customerInfoModel.SfcId.HasValue || customerInfoModel.SfcId == 0)
                {
                    serviceFee = 0;
                }
                else
                {
                    sfcid = customerInfoModel.SfcId.Value;
                }
            }

            if (sfcid != 0)
            {
                List <ServiceFeeConfigDetailsModel> serviceFeeConfigDetailsModels =
                    _serviceFeeConfigDetailsBll.GetServiceFeeConfigDetailsBySfcId(sfcid);
                //判断当前时间中是否存在服务费
                DateTime nowTime = DateTime.Now;
                string   nowDate = nowTime.ToString("yyyy-MM-dd");

                foreach (var detail in serviceFeeConfigDetailsModels)
                {
                    if (nowTime > Convert.ToDateTime(nowDate + " " + detail.BeginTime) &&
                        nowTime < Convert.ToDateTime(nowDate + " " + detail.EndTime))
                    {
                        if (type == "tra")
                        {
                            if (detail.TrainServiceFee != null)
                            {
                                serviceFee = detail.TrainServiceFee.Value;
                            }
                        }
                        else if (type == "traGrab")
                        {
                            if (detail.TrainGrabTicketServiceFee != null)
                            {
                                serviceFee = detail.TrainGrabTicketServiceFee.Value;
                            }
                        }
                    }
                }
            }

            decimal defaultPrice = 5;

            if (type == "traGrab" && serviceFee == 0)
            {
                serviceFee = defaultPrice;
            }

            return(serviceFee);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 登录
        /// </summary>
        public CustomerInfoModel DoLogin(CustomerLoginModel loginModel)
        {
            if (string.IsNullOrEmpty(loginModel.CorpId))
            {
                throw new Exception("公司代码不能为空");
            }
            //判断是否是商旅客户
            CorporationModel corporationModel = _corporationBll.GetCorpInfoByCorpId(loginModel.CorpId);

            if (corporationModel == null || string.IsNullOrEmpty(corporationModel.IsAmplitudeCorp) ||
                corporationModel.IsAmplitudeCorp.ToUpper() == "F")
            {
                throw new Exception("没有开通差旅功能,请联系客服开通");
            }

            //1.根据用户名,密码,公司代码,验证身份
            CustomerInfoModel customerInfo = _verifyBll.VerifyCustomer(loginModel);


            if (customerInfo == null)
            {
                return(null);
            }

            if (!string.IsNullOrEmpty(customerInfo.IsLock) && customerInfo.IsLock.ToUpper() == "T")
            {
                throw new Exception("该客户已经被冻结,请先解冻再登录");
            }
            if (!string.IsNullOrEmpty(customerInfo.IsDel) && customerInfo.IsDel.ToUpper() == "T")
            {
                throw new Exception("该客户已经被删除,无法登录");
            }

            //2.验证通过后,将token,UserId(key-value)保存到Redis中(事件方式)
            TokenEvent?.Invoke(this,
                               new TokenEventArgs(loginModel.Token, customerInfo.UserId, customerInfo.Cid, loginModel.ClientType));

            //当前个性化如果设置需要短信验证则IsCheckClientId为true
            if ((corporationModel?.IsNoteVerify ?? 0) == 0)
            {
                loginModel.IsCheckClientId = false;
            }
            else
            {
                loginModel.IsCheckClientId = true;
            }


            if (!(loginModel.IsCheckClientId ?? false) && !string.IsNullOrEmpty(loginModel.ClientId))
            {
                //3.更新设备id
                _addAppClientIdServiceBll.AddAppClientId(new AddAppClientIdModel()
                {
                    Cid        = customerInfo.Cid,
                    ClientId   = loginModel.ClientId,
                    ClientType = loginModel.ClientType
                });
            }

            //3.获取设备id
            loginModel.ClientId = _addAppClientIdServiceBll.GetAppClientId(customerInfo.Cid);



            return(customerInfo);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 创建机票订单
        /// </summary>
        /// <param name="orderViewModel"></param>
        /// <returns></returns>
        public AddOrderResponseViewModel AddDomesticOrderApplicationService(AddOrderRequestViewModel orderViewModel)
        {
            string        oidTemp       = orderViewModel.CreateOid;
            int           orderid       = 0;
            AddOrderModel addOrderModel = Mapper.Map <AddOrderRequestViewModel, AddOrderModel>(orderViewModel);

            //0.获取客户信息服务
            addOrderModel.Customer = _getCustomerServiceBll.GetCustomerByCid(orderViewModel.Cid);
            if (!string.IsNullOrEmpty(addOrderModel.Customer.CorpID))
            {
                CorporationModel corporationModel = _getCorpServiceBll.GetCorp(addOrderModel.Customer.CorpID);
                if (!addOrderModel.IsPrint.HasValue)
                {
                    addOrderModel.IsPrint = corporationModel.IsPrint ?? 0;
                }
                if (!string.IsNullOrEmpty(corporationModel.ResponsibleOid) && orderViewModel.OrderSource != "O")
                {
                    addOrderModel.CreateOid = corporationModel.ResponsibleOid;
                }
            }


            //1.获取乘机人的联系人Id对应的乘客信息
            List <int> contactList = addOrderModel.PassengerList.Select(n => n.Contactid ?? 0).ToList();

            addOrderModel.PassengerCustomerList = _getCorpPassengerCustomerServiceBll.GetCorpPassengerCustomer(contactList);

            OperatorModel operatorModel = _getOperatorServiceBll.GetOperatorByOid(addOrderModel.CreateOid);


            //2.创建订单服务
            using (var transaction = this.Context.Database.BeginTransaction())
            {
                try
                {
                    orderid = _addOrderServiceBll.AddDomesticOrder(addOrderModel);

                    #region 送审

                    if (orderid > 0)
                    {
                        SubmitCorpAduitOrderModel submitCorpAduitOrder = new SubmitCorpAduitOrderModel()
                        {
                            OrderInfoList = new List <SubmitCorpAduitOrderDetailModel>()
                            {
                                new SubmitCorpAduitOrderDetailModel()
                                {
                                    OrderId   = orderid,
                                    OrderType = OrderSourceTypeEnum.Flt
                                }
                            },
                            PolicyId        = addOrderModel.CorpPolicyId,
                            AduitConfigId   = addOrderModel.CorpAduitId,
                            Source          = orderViewModel.OrderSource,
                            SubmitCid       = orderViewModel.Cid,
                            SubmitOid       = oidTemp,
                            IsViolatePolicy =
                                (addOrderModel.FlightList.Find(n => !string.IsNullOrEmpty(n.CorpPolicy)) != null
                                    ? true
                                    : false),
                            OrderType = OrderSourceTypeEnum.Flt
                        };
                        _submitCorpAduitOrderServiceBll.Submit(submitCorpAduitOrder);
                    }

                    #endregion

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw;
                }
            }
            string PNRstr  = "";                                                        //获取后邮件中使用
            string testCid = AppSettingsHelper.GetAppSettings(AppSettingsEnum.TestCid); //生产环境,测试帐号不许定位
            if (testCid != orderViewModel.Cid.ToString())
            {
                //3.调取pnr定位服务
                PNRstr = _getPnrNoServiceBll.GetPnrNo(orderid, operatorModel?.Email);
            }
            //4.发送提醒邮件
            new TaskFactory().StartNew(() =>
            {
                string mail               = operatorModel.Email;
                string corporationName    = addOrderModel.PassengerCustomerList[0].Corporation.CorpName;
                string operatorName       = addOrderModel.Cname;
                string dport              = addOrderModel.FlightList[0].Dport;
                string aport              = addOrderModel.FlightList[0].Aport;
                string aDate              = addOrderModel.FlightList[0].TackoffTime.ToString();
                string bDate              = addOrderModel.FlightList[0].ArrivalsTime.ToString();
                StringBuilder mailContent = new StringBuilder();
                mailContent.Append("<b>订单生成提醒:<b/>");
                mailContent.Append("<br/>");
                mailContent.Append("[" + corporationName + "] 已生成订单:" + orderid + ",请差旅顾问及时处理!");
                mailContent.Append("<br/>");
                mailContent.Append("联系人姓名:" + addOrderModel.Cname + "");
                mailContent.Append("<br/>");
                mailContent.Append("行程:" + dport + " - " + aport + "");
                mailContent.Append("<br/>");
                mailContent.Append("起飞时间:" + aDate + "");
                mailContent.Append("<br/>");
                mailContent.Append("抵达时间:" + bDate + "");
                mailContent.Append("<br/>");
                mailContent.Append("<b>下单时间:" + DateTime.Now + ",请及时关注~<b/>");
                if (!string.IsNullOrEmpty(mail))
                {
                    bool flag = EmailHelper.SendEmail("", "订单生成提醒", null, null, mailContent.ToString(), mail);
                }
            });

            return(new AddOrderResponseViewModel()
            {
                OrderId = orderid
            });
        }
Exemplo n.º 23
0
        /// <summary>
        /// 显示创建订单页面
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ComfireFlightOrderResponseViewModel ComfireOrderViewApplicationService(
            ComfireFlightOrderRequestViewModel request)
        {
            CustomerModel           customerModel     = _getCustomerServiceBll.GetCustomerByCid(request.Cid);
            List <ProjectNameModel> projectNameModels = _getProjectNameServiceBll.GetProjectNameByNotDelete(request.Cid);

            List <InsuranceCompanyModel> insuranceCompanyModels = _getInsuranceCompanyServiceBll.GetInsuranceCompany();

            if (request.OrderSource != "O")
            {
                insuranceCompanyModels = insuranceCompanyModels?.FindAll(n => n.UpOnLine == "T");
            }

            ComfireFlightOrderResponseViewModel v = new ComfireFlightOrderResponseViewModel();

            v.CName    = customerModel.RealName;
            v.EMail    = customerModel.Email;
            v.IsMaster = customerModel.IsMaster;
            v.Mobile   = customerModel.Mobile;
            if (!string.IsNullOrEmpty(customerModel.CorpID))
            {
                CorporationModel corporationModel = _getCorpServiceBll.GetCorp(customerModel.CorpID);
                v.IsPrint = corporationModel.IsPrint ?? 0;
                //获取成本中心
                List <CostCenterModel> costCenterModels =
                    _getCostCenterServiceBll.GetCostCenterByNoDelete(customerModel.CorpID);
                v.CostCenterList = Mapper.Map <List <CostCenterModel>, List <CostCenterViewModel> >(costCenterModels);
            }

            v.ProjectNameList = Mapper.Map <List <ProjectNameModel>, List <ProjectNameViewModel> >(projectNameModels);
            v.InsuranceList   = (from n in insuranceCompanyModels
                                 select new FltInsuranceViewModel()
            {
                ProductId = n.CompanyID,
                ProductName = n.ProductName,
                SalePrice = n.FacePrice
            }).ToList();

            v.CardTypeList = (from n in EnumConvert.QueryEnum <CardTypeEnum>()
                              select new SortedListViewModel()
            {
                Key = n.Key,
                Value = n.Value
            }).ToList();

            v.SendTicketTypeList = (from sendTicket in EnumConvert.QueryEnum <SendTicketTypeEnum>()
                                    where
                                    sendTicket.Key != (int)SendTicketTypeEnum.TraAfter &&
                                    sendTicket.Key != (int)SendTicketTypeEnum.TraBefore
                                    select new SortedListViewModel()
            {
                Key = sendTicket.Key,
                Value = sendTicket.Value
            }).ToList();

            List <ContactAddressModel> contactAddressModels =
                _getContactAddressServiceBll.GetContactAddressByCid(request.Cid);

            if (contactAddressModels != null && contactAddressModels.Count > 0)
            {
                v.AddressList = contactAddressModels.Select(n => n.Address).ToList();
            }

            return(v);
        }
        public ConfirmTraOrderResponseViewModel GetTraComfireOrderView(ConfirmTraOrderRequestViewModel request)
        {
            CustomerModel customerModel = _getCustomerServiceBll.GetCustomerByCid(request.Cid);

            ConfirmTraOrderResponseViewModel v = new ConfirmTraOrderResponseViewModel();

            v.CName    = customerModel.RealName;
            v.EMail    = customerModel.Email;
            v.IsMaster = customerModel.IsMaster;
            v.Mobile   = customerModel.Mobile;
            if (!string.IsNullOrEmpty(customerModel.CorpID))
            {
                CorporationModel corporationModel = _getCorpServiceBll.GetCorp(customerModel.CorpID);
                v.IsPrint = corporationModel.IsPrint ?? 0;

                //服务费
                ServiceFeeInfoModel serviceFeeInfoModel = _getServiceFeeServiceBll.GetServiceFeeByCorpId(customerModel.CorpID, corporationModel.SfcId ?? 0);
                v.ServiceFee = serviceFeeInfoModel.TrainServiceFee;
                v.TrainGrabTicketServiceFee = serviceFeeInfoModel.TrainGrabTicketServiceFee;

                //获取成本中心
                List <CostCenterModel> costCenterModels =
                    _getCostCenterServiceBll.GetCostCenterByNoDelete(customerModel.CorpID);
                v.CostCenterList = Mapper.Map <List <CostCenterModel>, List <CostCenterViewModel> >(costCenterModels);
            }
            else
            {
                ServiceFeeInfoModel serviceFeeInfoModel = _getServiceFeeServiceBll.GetServiceFeeBySfcid(customerModel.SfcId ?? 0);
                v.ServiceFee = serviceFeeInfoModel.TrainServiceFee;
                v.TrainGrabTicketServiceFee = serviceFeeInfoModel.TrainGrabTicketServiceFee;
            }

            #region 项目名称
            List <ProjectNameModel> projectNameModels = _getProjectNameServiceBll.GetProjectNameByNotDelete(request.Cid);
            v.ProjectNameList = Mapper.Map <List <ProjectNameModel>, List <ProjectNameViewModel> >(projectNameModels);
            #endregion

            #region 证件类型
            v.CardTypeList = (from n in EnumConvert.QueryEnum <CardTypeEnum>()
                              select new SortedListViewModel()
            {
                Key = n.Key,
                Value = n.Value
            }).ToList();
            #endregion

            #region 配送方式
            v.SendTicketTypeList = (from sendTicket in EnumConvert.QueryEnum <SendTicketTypeEnum>()
                                    where sendTicket.Key != (int)SendTicketTypeEnum.Air
                                    select new SortedListViewModel()
            {
                Key = sendTicket.Key,
                Value = sendTicket.Value
            }).ToList();
            #endregion

            #region 12306帐号
            List <Tra12306AccountModel> accountModels = _get12306AccountServiceBll.GetTra12306Account();
            v.AccountList = (from n in accountModels
                             select new SortedListViewModel()
            {
                Key = n.PassId,
                Value = n.UserName
            }).ToList();
            #endregion

            #region 支付方式

            v.PayTypeList = new List <SortedListViewModel>
            {
                new SortedListViewModel()
                {
                    Key   = PayTypeEnum.Cas.ToString(),
                    Value = PayTypeEnum.Cas.ToDescription()
                },
                new SortedListViewModel()
                {
                    Key   = PayTypeEnum.Chk.ToString(),
                    Value = PayTypeEnum.Chk.ToDescription()
                }
            };
            if (!string.IsNullOrEmpty(customerModel.CorpID))
            {
                v.PayTypeList.Add(new SortedListViewModel()
                {
                    Key   = PayTypeEnum.Cro.ToString(),
                    Value = PayTypeEnum.Cro.ToDescription()
                });
            }

            #endregion

            List <ContactAddressModel> contactAddressModels =
                _getContactAddressServiceBll.GetContactAddressByCid(request.Cid);
            if (contactAddressModels != null && contactAddressModels.Count > 0)
            {
                v.AddressList = contactAddressModels.Select(n => n.Address).ToList();
            }

            return(v);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 获取乘机人/乘车人信息
        /// </summary>
        /// <param name="cid">客户Id</param>
        /// <param name="departId"></param>
        /// <param name="searchArgs">查询参数</param>
        /// <returns></returns>
        public List <PassengerInfoModel> GetPassengerInfoList(int cid, int?departId, string searchArgs = "")
        {
            CustomerInfoModel customer         = GetCustomerInfo(cid);
            CorporationModel  corporationModel = null;

            if (!string.IsNullOrEmpty(customer.CorpId))
            {
                corporationModel = _corporationBll.GetCorpInfoByCorpId(customer.CorpId);
                if (!customer.CorpDepartId.HasValue && corporationModel.IsAmplitudeCorp == "T")
                {
                    throw new Exception("该客户没有所属部门");
                }
            }

            List <PassengerInfoModel> passengerList = new List <PassengerInfoModel>();

            if (corporationModel != null && corporationModel.IsAmplitudeCorp == "T")
            {
                #region 差旅系统客户
                if (departId.HasValue && departId.Value == -1)
                {
                    return(passengerList);
                }
                //1.根据Cid判断当前预定人是否有是预定人
                if (!string.IsNullOrEmpty(customer.IsMaster) && customer.IsMaster.ToUpper() == "T")
                {
                    if (!departId.HasValue)
                    {
                        throw new Exception("预定人请传入departId参数");
                    }

                    #region 是预定人
                    //1.1 根据departId获取对应的Cid
                    List <CustomerInfoModel> customerList = _customerBll.GetCustomerByDepartId(departId.Value, searchArgs);
                    List <int> cidList = new List <int>();
                    if (customerList == null)
                    {
                        customerList = new List <CustomerInfoModel>();
                    }
                    customerList.ForEach(n => cidList.Add(n.Cid));
                    //1.2 然后在通过Cid获取是乘机人信息的联系人信息
                    List <ContactInfoModel> contactList = _contactBll.GetPassengerContactInfoList(cidList) ??
                                                          new List <ContactInfoModel>();
                    passengerList = ConvertContactToPassenger(contactList);
                    #endregion
                }
                else
                {
                    #region 乘车人

                    ContactInfoModel           contactInfo        = _contactBll.GetPassengerContactInfo(cid);
                    List <IdentificationModel> identificationList =
                        _identificationInfoBll.GetIdentificationInfoByContactId(new List <int>()
                    {
                        contactInfo.ContactId
                    });
                    passengerList.Add(new PassengerInfoModel()
                    {
                        ContactId          = contactInfo.ContactId,
                        PassengerName      = contactInfo.Name,
                        Mobile             = contactInfo.Mobile,
                        IdentificationList = identificationList
                    });

                    #endregion
                }

                #endregion
            }
            else
            {
                #region 非差旅系统客户,从常用联系人中获取
                List <ContactInfoModel> contactList = _contactBll.GetPassengerContactInfoList(cid) ??
                                                      new List <ContactInfoModel>();
                if (!string.IsNullOrEmpty(searchArgs))
                {
                    contactList = contactList.FindAll(
                        n => (!string.IsNullOrEmpty(n.EName) && n.EName.Contains(searchArgs)) ||
                        (!string.IsNullOrEmpty(n.CName) && n.CName.Contains(searchArgs)) ||
                        (!string.IsNullOrEmpty(n.Mobile) && n.Mobile == searchArgs));
                }
                if (contactList.Count > 20)
                {
                    contactList = contactList.Take(20).ToList();
                }

                List <ContactInfoModel> contactList2 = new List <ContactInfoModel>();

                contactList.ForEach(n =>
                {
                    if (contactList2.Find(x => x.Name == n.Name) == null)//去除重名
                    {
                        contactList2.Add(n);
                    }
                });

                passengerList = ConvertContactToPassenger(contactList2);
                #endregion
            }
            return(passengerList);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 如果联系人id为0,新增联系人信息;如果不为0,则更新
        /// </summary>
        /// <param name="contactInfo"></param>
        /// <returns></returns>
        public int AddContact(ContactInfoModel contactInfo)
        {
            if (!contactInfo.Cid.HasValue)
            {
                return(0);
            }
            CustomerInfoModel cutCustomerInfoModel = _customerBll.GetCustomerByCid(contactInfo.Cid.Value);

            if (!string.IsNullOrEmpty(cutCustomerInfoModel.CorpId))
            {
                CorporationModel corporationModel = _corporationBll.GetCorpInfoByCorpId(cutCustomerInfoModel.CorpId);
                if (corporationModel.IsAmplitudeCorp == "T")//如果是差旅客户则跳出
                {
                    return(0);
                }
            }

            if (contactInfo.ContactId == 0)//新联系人信息
            {
                //判断是存在相同证件的常用乘客
                bool flag = false;
                List <ContactInfoModel> contactList = _contactBll.GetPassengerContactInfoList(contactInfo.Cid.Value);
                if (contactList != null && contactList.Count > 0)
                {
                    var contact = contactList.Find(n => n.Name == contactInfo.Name);
                    if (contact != null)//存在
                    {
                        List <IdentificationModel> identificationModels =
                            _identificationInfoBll.GetIdentificationInfoByContactId(new List <int>()
                        {
                            contactInfo.ContactId
                        })?.FindAll(n => n.CardNo == contactInfo.CardNo && n.Iid == (contactInfo.CardNoType ?? 0));

                        if (identificationModels != null && identificationModels.Count > 0)
                        {
                            contactInfo.ContactId = contact.ContactId;
                            flag = true;
                        }
                    }
                }


                if (flag)
                {
                    //存在同人,更新
                    UpdateContact(contactInfo);
                }
                else
                {
                    //不存在同人,则新增
                    int contactId = _contactBll.AddContact(contactInfo); //新增联系人信息
                    if (contactInfo.CardNoType.HasValue && !string.IsNullOrEmpty(contactInfo.CardNo))
                    {
                        //新增证件信息
                        _identificationInfoBll.AddIdentificationInfo(new IdentificationModel()
                        {
                            ContactId = contactId,
                            Iid       = contactInfo.CardNoType.Value,
                            CardNo    = contactInfo.CardNo
                        });
                    }
                }
            }
            else
            {
                UpdateContact(contactInfo);
            }

            return(0);
        }