예제 #1
0
        public GetOneCustomerBasicInformationResponse GetOneCustomerBasicInformation(Guid oid)
        {
            GetOneCustomerBasicInformationResponse result;

            try
            {
                //依据条件查找客户基本信息
                var existingCustomer = _customerRepository.GetById(oid);
                if (existingCustomer == null)
                {
                    return(null);
                }

                //映射为返回类型
                result = _mapper.Map <GetOneCustomerBasicInformationResponse>(existingCustomer);

                //增加服务信息
                var service = _serviceRepository.GetServiceByCustomerOid(existingCustomer.OID);
                if (service != null)
                {
                    result.ServiceOid  = service.OID;
                    result.ServiceName = service.Name;
                }

                //增加归属客服信息
                var supporter = _supporterRepository.GetById(existingCustomer.SupporterOid);
                if (supporter != null)
                {
                    result.SupporterName = supporter.UserName;
                }

                //增加归属代理信息
                var agenter = _agenterRepository.GetById(existingCustomer.AgenterOid);
                if (agenter != null)
                {
                    result.AgenterName = agenter.UserName;
                }

                //增加职业信息
                var customerJob = _customerJobRepository.GetCustomerJobByCustomerOid(existingCustomer.OID);
                if (customerJob != null)
                {
                    result.JobName = customerJob.Job.Name;
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(result);
        }
예제 #2
0
        //// UpdateSupporterPasswordCommand命令的处理程序
        //// 整个命令处理程序的核心都在这里
        //// 不仅包括命令验证的收集,持久化,还有领域事件和通知的添加
        //public Task<Unit> Handle(UpdateSupporterPasswordCommand request, CancellationToken cancellationToken)
        //{
        //    // 命令验证
        //    if (!request.IsValid())
        //    {
        //        // 错误信息收集
        //        NotifyValidationErrors(request);
        //        // 返回,结束当前线程
        //        return Task.FromResult(new Unit());
        //    }

        //    var existingSupporter = _supporterRepository.GetById(request.OID);
        //    if (existingSupporter == null)
        //    {
        //        //用户不存在
        //        return Task.FromResult(new Unit());
        //    }

        //    if (existingSupporter.Password == request.Password)
        //    {
        //        //密码相同,无需修改
        //        return Task.FromResult(new Unit());
        //    }

        //    // 统一提交
        //    if (Commit())
        //    {
        //        // 提交成功后,这里可以发布领域事件,
        //        // 比如欢迎用户注册邮件呀,短信呀等

        //        //Bus.RaiseEvent(new StudentRegisteredEvent(student.Id, student.Name, student.Email, student.BirthDate, student.Phone));
        //    }

        //    return Task.FromResult(new Unit());
        //}

        //public Task<Unit> Handle(GetAllSupporterCommand request, CancellationToken cancellationToken)
        //{
        //    // 命令验证
        //    if (!request.IsValid())
        //    {
        //        // 错误信息收集
        //        NotifyValidationErrors(request);
        //        // 返回,结束当前线程
        //        return Task.FromResult(new Unit());
        //    }

        //    _supporterRepository.GetAllValidSupporters.GetAll();

        //    //统一提交
        //    if (Commit())
        //    { }

        //    return Task.FromResult(new Unit());
        //}



        /// <summary>
        /// 客服修改密码
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task <Unit> Handle(UpdateSupporterPasswordCommand request, CancellationToken cancellationToken)
        {
            // 命令验证
            if (!request.IsValid())
            {
                // 错误信息收集
                NotifyValidationErrors(request);//主要为验证的信息
                // 返回,结束当前线程
                return(Task.FromResult(new Unit()));
            }

            //验证用户是否存在
            var existingSupporter = _supporterRepository.GetById(request.OID);

            if (existingSupporter == null)
            {
                //引发错误事件
                Bus.RaiseEvent(new DomainNotification("", "用户不存在!"));
                return(Task.FromResult(new Unit()));
            }

            if (existingSupporter.Password != request.Password)
            {
                //引发错误事件
                Bus.RaiseEvent(new DomainNotification("", "用户旧密码错误,无法修改!"));
                return(Task.FromResult(new Unit()));
            }

            existingSupporter.UpdatePassword(request.NewPassword);

            if (Commit())
            {
                // 提交成功后,这里可以发布领域事件,比如短信通知
            }
            return(Task.FromResult(new Unit()));
        }
예제 #3
0
        public QueryOneCustomerDietListByPageResponse QueryOneCustomerDietListByPage(Guid customerOid, int pageIndex, int pageSize)
        {
            QueryOneCustomerDietListByPageResponse result;

            try
            {
                //依据条件查询食谱列表
                var existingDietList = _customerDietRepository.QueryCustomerDietListByPage(customerOid, pageIndex, pageSize);

                //查询食谱列表的总条数
                var existingDietCount = _customerDietRepository.QueryCustomerDietListCount(customerOid);

                //映射为返回类型
                result               = new QueryOneCustomerDietListByPageResponse();
                result.DietList      = new PageModel <OneCustomerDietByPage>();
                result.DietList.Data = _mapper.Map <List <OneCustomerDietByPage> >(existingDietList);

                //补齐其余部分
                var customer = _customerRepository.GetById(customerOid);
                if (customer == null)
                {
                    return(result);
                }
                result.UserName  = customer.UserName;
                result.Cellphone = customer.Cellphone;

                var service = _serviceRepository.GetServiceByCustomerOid(customerOid);
                if (service != null)
                {
                    result.ServiceName = service.Name;
                }

                //组合页码数据
                result.DietList.PageIndex = pageIndex + 1;                                                      //页码索引
                result.DietList.PageSize  = pageSize;                                                           //每页大小
                result.DietList.DataCount = existingDietCount;                                                  //数据总数
                result.DietList.PageCount = Convert.ToInt32(Math.Ceiling(existingDietCount * 1.0d / pageSize)); //总页数

                //增加类别,归属客服信息,归属代理信息
                int i = 0;
                foreach (var item in existingDietList)
                {
                    //supporter
                    var supporter = _supporterRepository.GetById(item.SupporterOid);
                    if (supporter != null)
                    {
                        result.DietList.Data[i].SupporterName = supporter.UserName;
                    }
                    else
                    {
                        result.DietList.Data[i].SupporterName = "未知";
                    }

                    //status
                    if (result.DietList.Data[i].Status == 0)
                    {
                        result.DietList.Data[i].StatusDescription = "正常";
                    }
                    else if (result.DietList.Data[i].Status == -1)
                    {
                        result.DietList.Data[i].StatusDescription = "已删除";
                    }

                    //lastOperater
                    var operater = _supporterRepository.GetById(item.LastOperate.Oid);
                    if (operater != null)
                    {
                        result.DietList.Data[i].LastOperater = operater.UserName;
                    }
                    else
                    {
                        result.DietList.Data[i].LastOperater = "未知";
                    }
                    result.DietList.Data[i].LatOperateTime = item.LastOperate.Time;

                    result.DietList.Data[i].ID = (pageIndex * pageSize) + i + 1;
                    i++;
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(result);
        }
예제 #4
0
        public GetOneSupporterTodoDietListByDailyPageResponse GetOneSupporterTodoDietListByDailyPage(Guid supporterOid, DateTime dateTime, int pageIndex, int pageSize)
        {
            GetOneSupporterTodoDietListByDailyPageResponse result;

            try
            {
                //查询指定客服管理的所有客户列表
                var needDoneCustomerList = _customerRepository.QueryOneSupporterCustomerList(supporterOid);

                //查询指定客服管理的所有客户的总条数
                var needDoneCustomerListCount = needDoneCustomerList.Count();

                //依据条件查询每日已经完成食谱列表
                var doneCustomerList = _customerRepository.QueryOneSupporterDoneDietListByDaily(supporterOid, dateTime);

                //查询每日已经完成食谱列表的总条数
                var doneCustomerListCount = doneCustomerList.Count();

                //待办事项
                List <TodoListByPage> todoDietList = new List <TodoListByPage>();

                //代办事项的食谱列表
                foreach (var needDoneCustomer in needDoneCustomerList)
                {
                    var existingDiet = (
                        from t in doneCustomerList
                        where (t.OID == needDoneCustomer.OID)
                        select t);
                    if (existingDiet.Count() <= 0)
                    {
                        todoDietList.Add(_mapper.Map <TodoListByPage>(needDoneCustomer));
                    }
                }

                //映射为返回类型
                result = new GetOneSupporterTodoDietListByDailyPageResponse();
                result.TodoDietList      = new PageModel <TodoListByPage>();
                result.TodoDietList.Data = todoDietList.Skip(pageIndex * pageSize).Take(pageSize).ToList();

                //增加个人信息
                foreach (var customer in result.TodoDietList.Data)
                {
                    var service = _serviceRepository.GetServiceByCustomerOid(customer.UserOid);
                    customer.ServiceName = service.Name;
                }

                //增加其他信息
                result.TodoDate = dateTime;
                var supporter = _supporterRepository.GetById(supporterOid);
                if (supporter == null)
                {
                    result.SupporterName = "未知客服";
                }
                else
                {
                    result.SupporterName = supporter.UserName;
                }

                //组合页码数据
                result.TodoDietList.PageIndex = pageIndex + 1;                                                                                        //页码索引
                result.TodoDietList.PageSize  = pageSize;                                                                                             //每页大小
                result.TodoDietList.DataCount = needDoneCustomerListCount - doneCustomerListCount;                                                    //数据总数
                result.TodoDietList.PageCount = Convert.ToInt32(Math.Ceiling((needDoneCustomerListCount - doneCustomerListCount) * 1.0d / pageSize)); //总页数
            }
            catch (Exception)
            {
                return(null);
            }
            return(result);
        }