Exemplo n.º 1
0
        public async Task <IActionResult> BindTherapistWeChatOpenIdAsync([FromBody] BindTherapistWeChatOpenIdRequestDto requestDto)
        {
            var biz = new TherapistBiz();

            var model = await biz.GetModelByPhoneAsync(requestDto.TherapistPhone);

            if (model == null)
            {
                return(Failed(ErrorCode.InvalidIdPassword));
            }

            if (!string.Equals(model.TherapistPassword, CryptoHelper.AddSalt(model.TherapistGuid, requestDto.TherapistPassword), StringComparison.OrdinalIgnoreCase))
            {
                return(Failed(ErrorCode.InvalidIdPassword));
            }

            if (string.Equals(model.WeChatOpenId, requestDto.WeChatOpenId, StringComparison.OrdinalIgnoreCase))
            {
                return(Failed(ErrorCode.UserData, "已绑定过,无需重复绑定"));
            }

            model.WeChatOpenId = requestDto.WeChatOpenId;

            var result = await biz.UpdateAsync(model);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "服务人员绑定微信失败"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> TherapistResetPasswordAsync([FromBody] TherapistResetPasswordAsyncRequestDto requestDto)
        {
            var therapistBiz = new TherapistBiz();

            var biz = new AccountBiz();

            if (!biz.VerifyCode(requestDto.Phone, requestDto.Code))
            {
                return(Failed(ErrorCode.VerificationCode, "手机验证码错误!"));
            }

            var model = await therapistBiz.GetModelByPhoneAsync(requestDto.Phone);

            if (model == null)
            {
                return(Failed(ErrorCode.Empty, "该手机号未注册"));
            }

            model.LastUpdatedBy     = string.IsNullOrWhiteSpace(UserID) ? "test" : UserID;
            model.TherapistPassword = CryptoHelper.AddSalt(model.TherapistGuid, requestDto.Password);
            if (string.IsNullOrEmpty(model.TherapistPassword))
            {
                return(Failed(ErrorCode.SystemException, "密码加盐失败"));
            }

            return(therapistBiz.UpdateAsync(model).Result ? Success() : Failed(ErrorCode.DataBaseError, "密码更新失败!"));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> GetTherapistDetailInfo(string therapistGuid)
        {
            if (string.IsNullOrEmpty(therapistGuid))
            {
                return(Failed(ErrorCode.Empty, "参数不正确"));
            }

            var therapistBiz = new TherapistBiz();

            var therapist = await therapistBiz.GetTherapistDetailInfoAsync(UserID, therapistGuid);

            return(Success(therapist));
        }
Exemplo n.º 4
0
        public IActionResult TherapistUpdatePassword(string password)
        {
            // 前端传输的密码为MD5加密后的结果
            if (string.IsNullOrEmpty(password) || password.Length != 32)
            {
                return(Failed(ErrorCode.FormatError, "密码为空或者无效"));
            }
            var therapistBiz = new TherapistBiz();
            var biz          = new AccountBiz();
            var userModel    = therapistBiz.GetAsync(UserID).Result;

            if (userModel == null)
            {
                return(Failed(ErrorCode.Empty, "用户不存在或者已经注销"));
            }

            userModel.TherapistPassword = CryptoHelper.AddSalt(UserID, password);
            if (string.IsNullOrEmpty(userModel.TherapistPassword))
            {
                return(Failed(ErrorCode.SystemException, "密码加盐失败"));
            }

            return(therapistBiz.UpdateAsync(userModel).Result ? Success() : Failed(ErrorCode.DataBaseError, "密码更新失败"));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> UpdateTherapist([FromBody] ModifyTherapistRequestDto requestDto)
        {
            if (requestDto.ClassifyGuids.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "所属大类未选择"));
            }

            if (requestDto.Tag?.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "擅长需填写"));
            }

            if (string.Join("", requestDto.Tag).Length > 300)
            {
                return(Failed(ErrorCode.Empty, "擅长超过最大长度限制"));
            }

            if (requestDto?.MerchantProjectGuidList.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "服务项目未选择"));
            }

            if (!string.IsNullOrEmpty(requestDto.Introduction))
            {
                if (requestDto.Introduction.Length > 500)
                {
                    return(Failed(ErrorCode.Empty, "个人简介超过最大长度限制"));
                }
            }

            var therapistBiz = new TherapistBiz();

            var model = await therapistBiz.GetModelAsync(requestDto.TherapistGuid);

            if (model is null)
            {
                return(Failed(ErrorCode.Empty, "服务人员不存在"));
            }

            var IsTherapistPhoneExist = therapistBiz.IsTherapistPhoneExist(requestDto.TherapistPhone, true, requestDto.TherapistGuid);

            if (IsTherapistPhoneExist)
            {
                return(Failed(ErrorCode.UserData, "该手机号已注册!"));
            }

            model.TherapistName   = requestDto.TherapistName;
            model.TherapistPhone  = requestDto.TherapistPhone;
            model.PortraitGuid    = requestDto.PortraitGuid;
            model.JobTitle        = requestDto.JobTitle;
            model.Introduction    = requestDto.Introduction;
            model.Tag             = JsonConvert.SerializeObject(requestDto.Tag);
            model.LastUpdatedBy   = UserID;
            model.LastUpdatedDate = DateTime.Now;

            var tpModelList = requestDto.MerchantProjectGuidList.Distinct().Select(d => new TherapistProjectModel()
            {
                TherapistProjectGuid = Guid.NewGuid().ToString("N"),
                TherapistGuid        = model.TherapistGuid,
                ProjectGuid          = d,
                CreatedBy            = UserID,
                CreationDate         = DateTime.Now,
                LastUpdatedBy        = UserID,
                LastUpdatedDate      = DateTime.Now,
                Enable = true
            }).ToList();

            var classifyModels = requestDto.ClassifyGuids.Distinct().Select(d => new MerchantTherapistClassifyModel()
            {
                TherapistClassifyGuid = Guid.NewGuid().ToString("N"),
                TherapistGuid         = model.TherapistGuid,
                ClassifyGuid          = d,
                CreatedBy             = UserID,
                CreationDate          = DateTime.Now,
                LastUpdatedBy         = UserID,
                LastUpdatedDate       = DateTime.Now,
                Enable  = true,
                OrgGuid = ""
            }).ToList();

            var result = therapistBiz.UpdateTherapist(model, tpModelList, classifyModels);

            return(result ? Success() : Failed(ErrorCode.DataBaseError, "更新失败,请检查!"));
        }
Exemplo n.º 6
0
        public IActionResult AddNewTherapist([FromBody] AddNewTherapistRequestDto requestDto)
        {
            if (requestDto.ClassifyGuids.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "所属大类未选择"));
            }

            if (requestDto.Tag?.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "擅长需填写"));
            }

            if (string.Join("", requestDto.Tag).Length > 300)
            {
                return(Failed(ErrorCode.Empty, "擅长超过最大长度限制"));
            }

            if (requestDto.MerchantProjectGuidList.Count() <= 0)
            {
                return(Failed(ErrorCode.Empty, "服务项目未选择"));
            }

            if (!string.IsNullOrEmpty(requestDto.Introduction))
            {
                if (requestDto.Introduction.Length > 500)
                {
                    return(Failed(ErrorCode.Empty, "个人简介超过最大长度限制"));
                }
            }

            var therapistBiz = new TherapistBiz();

            var IsTherapistPhoneExist = therapistBiz.IsTherapistPhoneExist(requestDto.TherapistPhone);

            if (IsTherapistPhoneExist)
            {
                return(Failed(ErrorCode.UserData, "该手机号已注册!"));
            }

            var therapistGuid = Guid.NewGuid().ToString("N");

            var tModel = new TherapistModel()
            {
                TherapistGuid     = therapistGuid,
                TherapistName     = requestDto.TherapistName,
                JobTitle          = requestDto.JobTitle,
                MerchantGuid      = UserID,
                PortraitGuid      = requestDto.PortraitGuid,
                TherapistPhone    = requestDto.TherapistPhone,
                TherapistPassword = CryptoHelper.AddSalt(therapistGuid, requestDto.TherapistPassword),
                Introduction      = requestDto.Introduction,
                Tag             = JsonConvert.SerializeObject(requestDto.Tag),
                CreatedBy       = UserID,
                CreationDate    = DateTime.Now,
                LastUpdatedBy   = UserID,
                LastUpdatedDate = DateTime.Now
            };

            var tpModelList = requestDto.MerchantProjectGuidList.Distinct().Select(d => new TherapistProjectModel()
            {
                TherapistProjectGuid = Guid.NewGuid().ToString("N"),
                TherapistGuid        = tModel.TherapistGuid,
                ProjectGuid          = d,
                CreatedBy            = UserID,
                CreationDate         = DateTime.Now,
                LastUpdatedBy        = UserID,
                LastUpdatedDate      = DateTime.Now,
                Enable = true
            }).ToList();

            var classifyModels = requestDto.ClassifyGuids.Distinct().Select(d => new MerchantTherapistClassifyModel()
            {
                TherapistClassifyGuid = Guid.NewGuid().ToString("N"),
                TherapistGuid         = tModel.TherapistGuid,
                ClassifyGuid          = d,
                CreatedBy             = UserID,
                CreationDate          = DateTime.Now,
                LastUpdatedBy         = UserID,
                LastUpdatedDate       = DateTime.Now,
                Enable  = true,
                OrgGuid = ""
            }).ToList();

            var response = therapistBiz.AddNewTherapist(tModel, tpModelList, classifyModels);

            return(Success(response));
        }