Exemplo n.º 1
0
        /// <summary>
        ///     等级修改
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public GradeChangeView GetGradeChangeView(object id)
        {
            var find = GetSingle(id);

            if (find == null)
            {
                throw new ValidException("等级考核结果不存在");
            }

            var user = Resolve <IUserService>().GetSingle(find.UserId);

            if (user == null)
            {
                throw new ValidException("用户不存在");
            }

            var view = new GradeChangeView
            {
                Id              = find.Id.ToString(),
                UserName        = user.GetUserName(),
                GradeName       = Resolve <IGradeService>().GetGrade(user.GradeId)?.Name,
                KpiResult       = find.KpiResult,
                ChangeGradeName = Resolve <IGradeService>().GetGrade(find.ChangeGradeId)?.Name
            };

            return(view);
        }
Exemplo n.º 2
0
        public ServiceResult SaveChangeGrade(GradeChangeView view)
        {
            var find = GetSingle(view.Id);

            if (find == null)
            {
                throw new ValidException("等级考核结果不存在");
            }

            var user = Resolve <IUserService>().GetSingle(find.UserId);

            if (user == null)
            {
                throw new ValidException("用户不存在");
            }

            if (find.GradeId != user.GradeId)
            {
                return(ServiceResult.Failure("用户等级已发生改变"));
            }

            if (find.GradeId == find.ChangeGradeId)
            {
                return(ServiceResult.Failure("用户当前等级和更改后等级一样,无需修改"));
            }

            if (find.KpiResult == KpiResult.NoChange)
            {
                return(ServiceResult.Failure("考核结果为保持,无需修改"));
            }

            user.GradeId = find.ChangeGradeId;
            var result = Resolve <IUserService>().UpdateUser(user);

            if (result)
            {
                Log($"会员{user.GetUserName()}考核通过,手动修改等级成功");
                Resolve <IUserService>().DeleteUserCache(user.Id, user.UserName);
                return(ServiceResult.Success);
            }

            return(ServiceResult.Failure("等级修改失败"));
        }