public IActionResult MAJIA() { var sql = string.Empty; var num = 10000000000; var aaa = "abcdefghijklmnopqrstuvwxyz"; int[] s = new int[5]; for (int i = 0; i < 20; i++) { var ra = new Random(); var name = string.Empty; for (int k = 0; k < s.Length; k++) { name += aaa.Substring(ra.Next(0, aaa.Length), 1); } var userGuid = Guid.NewGuid().ToString("N"); var phone = num++; var password = CryptoHelper.AddSalt(userGuid, CryptoHelper.Md5("123456")); sql += $"INSERT INTO `t_utility_user` VALUES ('{userGuid}', NULL, NULL, '{name}', '{name}', '{password}', '{phone}', 'M', '2000-01-01 00:00:00', NULL, NULL, '{userGuid}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', '{userGuid}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', 'guodan', 1);"; sql += $"INSERT INTO `t_consumer` VALUES ('{userGuid}', NULL, 0, NULL, NULL, NULL, 1, '{userGuid}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', '{userGuid}', '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', NULL, 1);"; } return(Success <string>(sql)); }
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, "密码更新失败!")); }
public IActionResult ResetPassword([FromBody] PhonePasswordCodeRequestDto dto) { var biz = new AccountBiz(); if (!biz.VerifyCode(dto.Phone, dto.Code)) { return(Failed(ErrorCode.VerificationCode, "手机验证码错误!")); } var model = biz.GetUserByPhone(dto.Phone).FirstOrDefault(); if (model == null) { return(Failed(ErrorCode.Empty, "该手机号未注册")); } model.LastUpdatedBy = model.UserGuid; model.Password = CryptoHelper.AddSalt(model.UserGuid, dto.Password); if (string.IsNullOrEmpty(model.Password)) { return(Failed(ErrorCode.SystemException, "密码加盐失败")); } return(biz.UpdateUser(model) ? Success() : Failed(ErrorCode.DataBaseError, "密码更新失败!")); }
public async Task <IActionResult> ModifyPassword([FromBody] HospitalModifyPasswordRequestDto requestDto) { if (string.IsNullOrEmpty(UserID)) { return(Failed(ErrorCode.Empty, "账号不存在或已禁用")); } var hospitalBiz = new HospitalBiz(); var model = await hospitalBiz.GetAsync(UserID); if (model is null) { return(Failed(ErrorCode.Empty, "账号不存在或已禁用")); } var addSaltPwd = CryptoHelper.AddSalt(model.HospitalGuid, requestDto.Password); if (!model.Password.Equals(addSaltPwd, StringComparison.OrdinalIgnoreCase)) { return(Failed(ErrorCode.Empty, "账号或密码错误")); } model.LastUpdatedBy = model.HospitalGuid; model.LastUpdatedDate = DateTime.Now; model.Password = CryptoHelper.AddSalt(model.HospitalGuid, requestDto.NewPassword); var result = await hospitalBiz.UpdateAsync(model); return(result ? Success() : Failed(ErrorCode.Empty, "密码更新失败!")); }
public async Task <IActionResult> LoginAsync([FromBody] HosipitalLoginRequestDto loginRequestDto) { var hospitalBiz = new HospitalBiz(); var model = await hospitalBiz.GetModelByAccountAsync(loginRequestDto.Account); if (model is null) { return(Failed(ErrorCode.Empty, "账号不存在或已禁用")); } if (!model.Password.Equals(CryptoHelper.AddSalt(model.HospitalGuid, loginRequestDto.Password), StringComparison.OrdinalIgnoreCase)) { return(Failed(ErrorCode.Empty, "账号或密码错误")); } var response = new HospitalLoginResponseDto { HospitalGuid = model.HospitalGuid, HospitalName = model.HosName, Token = CreateToken(model.HospitalGuid, Common.EnumDefine.UserType.Doctor, 30), }; return(Success(response)); }
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, "服务人员绑定微信失败")); }
public async Task <IActionResult> UpdateAccountAsync([FromBody] UpdateAccountRequestDto request) { var managerAccountBiz = new ManagerAccountBiz(); var accountModel = await managerAccountBiz.GetAsync(request.UserGuid); if (accountModel == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } var accounts = await managerAccountBiz.GetModelsAsync(request.UserGuid, request.Account, request.Phone); if (accounts.Count() > 0) { return(Failed(ErrorCode.UserData, "账号存在或者手机号已经存在")); } accountModel.Account = request.Account; accountModel.Enable = request.Enable; accountModel.IsSuper = request.IsSuper; accountModel.LastUpdatedBy = UserID; accountModel.LastUpdatedDate = DateTime.Now; accountModel.OrganizationGuid = request.OrganizationGuid; if (!string.IsNullOrWhiteSpace(request.Password)) { accountModel.Password = CryptoHelper.AddSalt(request.UserGuid, request.Password); } accountModel.Birthday = request.Birthday; accountModel.Email = request.Email; accountModel.Gender = request.Gender; accountModel.NickName = request.UserName; accountModel.Phone = request.Phone; accountModel.PortraitGuid = request.PortraitGuid; accountModel.UserName = request.UserName; accountModel.WechatOpenid = request.WechatOpenid; var accountRoleModels = new List <AccountRoleModel>(); foreach (var item in request.Roles) { accountRoleModels.Add(new AccountRoleModel { Arguid = Guid.NewGuid().ToString("N"), CreatedBy = UserID, CreationDate = DateTime.Now, Enable = request.Enable, LastUpdatedBy = UserID, OrgGuid = string.Empty, LastUpdatedDate = DateTime.Now, RoleGuid = item, UserGuid = request.UserGuid, }); } if (!await new ManagerAccountBiz().UpdateAsync(accountModel, accountRoleModels)) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
public async Task <IActionResult> AddAccountAsync([FromBody] AddAccountRequestDto request) { var managerAccountBiz = new ManagerAccountBiz(); var accounts = await managerAccountBiz.GetModelsAsync(request.Account, request.Phone); if (accounts.Count() > 0) { return(Failed(ErrorCode.UserData, "账号存在或者手机号已存在")); } string userGuid = Guid.NewGuid().ToString("N"); var accountModel = new AccountModel { Account = request.Account, UserGuid = userGuid, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = request.Enable, IsSuper = request.IsSuper, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrganizationGuid = request.OrganizationGuid, OrgGuid = string.Empty, Password = CryptoHelper.AddSalt(userGuid, request.Password), Birthday = request.Birthday, Email = request.Email, Gender = request.Gender, NickName = request.UserName, Phone = request.Phone, PortraitGuid = request.PortraitGuid, UserName = request.UserName, WechatOpenid = request.WechatOpenid }; List <AccountRoleModel> accountRoleModels = new List <AccountRoleModel>(); foreach (var item in request.Roles) { accountRoleModels.Add(new AccountRoleModel { Arguid = Guid.NewGuid().ToString("N"), CreatedBy = UserID, CreationDate = DateTime.Now, Enable = request.Enable, LastUpdatedBy = UserID, OrgGuid = string.Empty, LastUpdatedDate = DateTime.Now, RoleGuid = item, UserGuid = userGuid, }); } if (!await new ManagerAccountBiz().AddAsync(accountModel, accountRoleModels)) { return(Failed(ErrorCode.UserData, "添加失败")); } return(Success()); }
public IActionResult Login([FromBody] LoginRequestDto request) { var biz = new AccountBiz(); var query = biz.GetUserByPhone(request.Phone); var model = query.FirstOrDefault(m => string.Equals(m.Password, CryptoHelper.AddSalt(m.UserGuid, request.Password), StringComparison.OrdinalIgnoreCase)); if (model == null) { return(Failed(ErrorCode.InvalidIdPassword)); } // 启用XMPP的情况下,就检查用户IM账号是否存在 if (enableXmpp) { var status = Client.QueryStatusAsync(model.UserGuid); status.Wait(); // 如果不存在,则注册该用户的IM账号 if (status.Result == IMStatus.NotExist) { RegisterIM(model); } } if (!string.IsNullOrWhiteSpace(request.OpenId) && request.OpenId != model.WechatOpenid) { model.WechatOpenid = request.OpenId; model.LastUpdatedDate = DateTime.Now; var upRes = biz.UpdateUser(model); Logger.Debug($"用户登录时,更新用户({model.UserGuid}) openid 结果:请求参数{JsonConvert.SerializeObject(request)} 更新结果-{upRes.ToString()}"); } var scoreBiz = new ScoreRulesBiz(); scoreBiz.AddScoreByRules(model.UserGuid, ActionEnum.Login, request.UserType); var response = new LoginResponseDto { UserId = model.UserGuid, NickName = model.NickName, Token = CreateToken(model.UserGuid, request.UserType, request.Days > 0 ? request.Days : 999), Xmpp = httpBind, Domain = domain, RabbitMQ = rabbitMQws }; return(Success(response)); }
public async Task <IActionResult> Login([FromBody] MealCanteenLoginRequestDto request) { var modelList = await new MealOperatorBiz().GetModelListByCondition(request.UserName); var model = modelList.FirstOrDefault(m => string.Equals(m.Password, CryptoHelper.AddSalt(m.OperatorGuid, request.Password), StringComparison.OrdinalIgnoreCase)); if (model is null) { return(Failed(ErrorCode.InvalidIdPassword, "账号或密码不正确")); } var token = CreateToken(model.OperatorGuid, Common.EnumDefine.UserType.Unknown, 30); return(Success(new MealCanteenLoginResponseDto { OperatorGuid = model.OperatorGuid, HospitalGuid = model.HospitalGuid, UserName = model.UserName, Token = token })); }
public IActionResult LoginAdmin([FromBody] LoginAdminRequestDto request) { var biz = new AccountBiz(); var query = biz.GetAdministrator(request.Account); var model = query.FirstOrDefault(m => string.Equals(m.Password, CryptoHelper.AddSalt(m.UserGuid, request.Password), StringComparison.OrdinalIgnoreCase)); if (model == null) { return(Failed(ErrorCode.InvalidIdPassword)); } var response = new LoginResponseDto { UserId = model.UserGuid, NickName = model.NickName, Token = CreateToken(model.UserGuid, UserType.Admin, request.Days > 0 ? request.Days : 999) }; return(Success(response)); }
public async Task <IActionResult> ResetTherapistPwdAsync(string therapistId) { var therapistModel = await new TherapistBiz().GetModelAsync(therapistId); if (therapistModel == null) { return(Failed(ErrorCode.Empty, "无此服务人员数据,请核对")); } //手机号后六位 var sourcesMd5Pwd = therapistModel.TherapistPhone.Substring (therapistModel.TherapistPhone.Length - 6).Md5().ToUpper(); var pwd = CryptoHelper.AddSalt(therapistModel.TherapistGuid, sourcesMd5Pwd); therapistModel.TherapistPassword = pwd; var affect = therapistModel.Update(); return(affect > 0 ? Success() : Failed(ErrorCode.DataBaseError, "重置服务人员密码错误")); }
public IActionResult MealOperatorUpdatePassword(string password) { // 前端传输的密码为MD5加密后的结果 if (string.IsNullOrEmpty(password) || password.Length != 32) { return(Failed(ErrorCode.FormatError, "密码为空或者无效")); } var mealOperatorBiz = new MealOperatorBiz(); var userModel = mealOperatorBiz.GetModelAsync(UserID).Result; if (userModel == null) { return(Failed(ErrorCode.Empty, "用户不存在或者已经注销")); } userModel.Password = CryptoHelper.AddSalt(UserID, password); if (string.IsNullOrEmpty(userModel.Password)) { return(Failed(ErrorCode.SystemException, "密码加盐失败")); } return(mealOperatorBiz.UpdateAsync(userModel).Result ? Success() : Failed(ErrorCode.DataBaseError, "密码更新失败")); }
public async Task <IActionResult> ResetPasswordAsync([FromBody] ResetPasswordResponseDto request) { HospitalBiz hospitalBiz = new HospitalBiz(); var entity = await hospitalBiz.GetAsync(request.Guid); if (entity == null) { return(Failed(ErrorCode.DataBaseError)); } if (string.IsNullOrWhiteSpace(entity.Account)) { return(Failed(ErrorCode.DataBaseError, "请先设置账号")); } var password = "******";//默认密码 entity.Password = CryptoHelper.AddSalt(entity.HospitalGuid, GD.Common.Helper.CryptoHelper.Md5(password)); entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; await hospitalBiz.UpdateAsync(entity); return(Success()); }
public async Task <IActionResult> TherapistLoginAsync([FromBody] TherapistLoginRequestDto loginRequestDto) { var model = await new TherapistBiz().GetModelByPhoneAsync(loginRequestDto.TherapistPhone); if (model == null) { return(Failed(ErrorCode.InvalidIdPassword)); } if (!string.Equals(model.TherapistPassword, CryptoHelper.AddSalt(model.TherapistGuid, loginRequestDto.TherapistPassword), StringComparison.OrdinalIgnoreCase)) { return(Failed(ErrorCode.InvalidIdPassword)); } var response = new TherapistLoginResponseDto { TherapistGuid = model.TherapistGuid, TherapistName = model.TherapistName, Token = CreateToken(model.TherapistGuid, Common.EnumDefine.UserType.Aesthetician, 30), }; return(Success(response)); }
public IActionResult UpdatePassword(string password) { // 前端传输的密码为MD5加密后的结果 if (string.IsNullOrEmpty(password) || password.Length != 32) { return(Failed(ErrorCode.FormatError, "密码为空或者无效")); } var biz = new AccountBiz(); var userModel = biz.GetUserById(UserID); if (userModel == null) { return(Failed(ErrorCode.Empty, "用户不存在或者已经注销")); } userModel.Password = CryptoHelper.AddSalt(UserID, password); if (string.IsNullOrEmpty(userModel.Password)) { return(Failed(ErrorCode.SystemException, "密码加盐失败")); } return(biz.UpdateUser(userModel) ? Success() : Failed(ErrorCode.DataBaseError, "密码更新失败")); }
public async Task <IActionResult> UpdateAccountPasswordAsync([FromBody] UpdateAccountPasswordRequestDto request) { var managerAccountBiz = new ManagerAccountBiz(); var entity = await managerAccountBiz.GetAsync(UserID); if (entity == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } if (entity.Password != CryptoHelper.AddSalt(entity.UserGuid, request.OldPassword)) { return(Failed(ErrorCode.UserData, "旧密码输入错误")); } entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; entity.Password = CryptoHelper.AddSalt(entity.UserGuid, request.Password); var result = await managerAccountBiz.UpdateAsync(entity); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
public async Task <IActionResult> RegisterMerchantAsync([FromBody] RegisterMerchantRequestDto request) { if (!request.Scopes.Any()) { return(Failed(ErrorCode.UserData, "经营范围数据为空!")); } var merchantBiz = new MerchantBiz(); if (await merchantBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } //商户信息 string merchantGuid = Guid.NewGuid().ToString("N"); var merchantModel = new MerchantModel { Status = MerchantModel.StatusEnum.Approved.ToString(), MerchantGuid = merchantGuid, MerchantPicture = request.MerchantPicture, MerchantName = request.MerchantName, CreatedBy = merchantGuid, SignatureGuid = request.SignatureGuid, Telephone = request.Telephone, OrgGuid = string.Empty, MerchantAddress = $"{request.Province}{request.City}{request.Area}{request.Street}", Latitude = request.Latitude, Longitude = request.Longitude, LastUpdatedBy = merchantGuid, Password = CryptoHelper.AddSalt(merchantGuid, request.Password), Account = request.Account, Enable = true, Area = request.Area, City = request.City, Province = request.Province, Street = request.Street, HospitalGuid = request.HospitalGuid ?? string.Empty }; //商户经营范围信息 var lstScope = request.Scopes.Select(scope => new ScopeModel { ScopeGuid = Guid.NewGuid().ToString("N"), ScopeDicGuid = scope.ScopeDicGuid, MerchantGuid = merchantModel.MerchantGuid, PictureGuid = scope.AccessoryGuid, CreatedBy = merchantGuid, OrgGuid = string.Empty, LastUpdatedBy = merchantGuid }).ToList(); //商户配置项证书信息 & 配置项证书附件信息 var lstCertificate = request.Certificates.Select(item => new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = item.AccessoryGuid, OwnerGuid = merchantModel.MerchantGuid, DicGuid = item.DicGuid, CreatedBy = UserID, OrgGuid = string.Empty, LastUpdatedBy = UserID }); var lstAccessory = (await new AccessoryBiz().GetListAsync(request.Certificates.Select(a => a.AccessoryGuid).ToArray())).ToList(); lstAccessory.ForEach(a => { a.OwnerGuid = lstCertificate.FirstOrDefault(b => b.PictureGuid == a.AccessoryGuid)?.CertificateGuid; a.LastUpdatedDate = DateTime.Now; a.CreatedBy = UserID; }); var result = await merchantBiz.RegisterMerchantAsync(merchantModel, lstScope, lstCertificate, lstAccessory); if (!result) { Failed(ErrorCode.DataBaseError, "商户注册数据插入不成功!"); } return(Success()); }
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)); }
public async Task <IActionResult> CreateConsumerHealthInfo([FromBody] CreateConsumerRequestDto request) { if (request.Informations.Count <= 0) { return(Failed(ErrorCode.Empty, "基础信息未提交")); } if (request.Informations.Any(d => string.IsNullOrEmpty(d.InformationGuid))) { return(Failed(ErrorCode.Empty, "基础信息未提交")); } var userBiz = new UserBiz(); var user = await userBiz.GetByPnoneAsync(request.Phone); if (user != null) { return(Failed(ErrorCode.Empty, $"该手机号【{request.Phone}】已注册,请直接在会员列表搜索")); } var userGuid = Guid.NewGuid().ToString("N"); var pwd = request.Phone.Substring(request.Phone.Length - 6); var userModel = new UserModel() { Phone = request.Phone, UserGuid = userGuid, UserName = string.IsNullOrWhiteSpace(request.UserName) ? userGuid.Substring(0, 6) : request.UserName,//userGuid.Substring(0, 6), Password = CryptoHelper.AddSalt(userGuid, CryptoHelper.Md5(pwd)), NickName = userGuid.Substring(0, 6), Gender = string.IsNullOrWhiteSpace(request.Gender) ? "M" : request.Gender, Birthday = request.Birthday, IdentityNumber = request.IdentityNumber, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = "" }; var consumerModel = new ConsumerModel() { ConsumerGuid = userGuid, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = "" }; var infos = request.Informations.Select(d => new ConsumerHealthInfoModel() { InfoRecordGuid = Guid.NewGuid().ToString("N"), UserGuid = userGuid, InformationGuid = d.InformationGuid, InformationType = d.InformationType?.ToString(), OptionGuids = JsonConvert.SerializeObject(d.OptionGuids), ResultValue = d.ResultValue, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = "" }).ToList(); var consumerBiz = new ConsumerBiz(); var result = await consumerBiz.CreateConsumerHealthInfo(userModel, consumerModel, infos); if (!result) { return(Failed(ErrorCode.Empty, "注册失败,请稍后重试")); } return(Success()); }
public async Task <IActionResult> UpdateMerchantAsync([FromBody] UpdateMerchantRequestDto request) { var merchantBiz = new MerchantBiz(); var merchantModel = await merchantBiz.GetAsync(request.MerchantGuid); if (merchantModel == null) { return(Failed(ErrorCode.UserData, "商户不存在!")); } if (request.Account != merchantModel.Account && await merchantBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } //商户信息 merchantModel.MerchantPicture = request.MerchantPicture; merchantModel.MerchantName = request.MerchantName; merchantModel.Telephone = request.Telephone; merchantModel.LastUpdatedBy = merchantModel.MerchantGuid; merchantModel.LastUpdatedDate = DateTime.Now; merchantModel.Latitude = request.Latitude; merchantModel.Longitude = request.Longitude; merchantModel.Account = request.Account; if (null != request.Password) { merchantModel.Password = CryptoHelper.AddSalt(merchantModel.MerchantGuid, request.Password); } merchantModel.MerchantAddress = $"{request.Province}{request.City}{request.Area}{request.Street}"; merchantModel.Area = request.Area; merchantModel.City = request.City; merchantModel.Province = request.Province; merchantModel.Street = request.Street; merchantModel.HospitalGuid = request.HospitalGuid ?? string.Empty; //商户经营范围信息 var scopes = request.Scopes.Select(scope => new ScopeModel { ScopeGuid = Guid.NewGuid().ToString("N"), ScopeDicGuid = scope.ScopeDicGuid, MerchantGuid = merchantModel.MerchantGuid, PictureGuid = scope.AccessoryGuid, CreatedBy = merchantModel.MerchantGuid, OrgGuid = string.Empty, LastUpdatedBy = merchantModel.MerchantGuid }); //商户配置项证书信息 & 配置项证书附件信息 var lstCertificate = request.Certificates.Select(item => new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = item.AccessoryGuid, OwnerGuid = merchantModel.MerchantGuid, DicGuid = item.DicGuid, CreatedBy = UserID, OrgGuid = string.Empty, LastUpdatedBy = UserID }); var result = await merchantBiz.UpdateMerchantAsync(merchantModel, scopes, lstCertificate); if (!result) { Failed(ErrorCode.DataBaseError, "商户修改失败!"); } return(Success()); }
public async Task <IActionResult> AddHospitalAsync([FromBody] AddHospitalRequestDto request) { HospitalBiz hospitalBiz = new HospitalBiz(); if (await hospitalBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } var hospitalGuid = Guid.NewGuid().ToString("N"); var textGuid = Guid.NewGuid().ToString("N"); request.Content = string.IsNullOrWhiteSpace(request.Content) ? "暂无详细" : request.Content; request.HosTag = string.IsNullOrWhiteSpace(request.HosTag) ? "暂无标签" : request.HosTag; var richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = hospitalGuid, TextGuid = textGuid, }; var hospitalModel = new HospitalModel { HosAbstract = request.HosAbstract, HosDetailGuid = textGuid, HosLevel = request.HosLevel, HosName = request.HosName, HosTag = request.HosTag, Location = request.Location, LogoGuid = request.LogoGuid, PlatformType = PlatformType.CloudDoctor.ToString(), RegisteredDate = request.RegisteredDate, Visibility = request.Visibility, HospitalGuid = hospitalGuid, CreatedBy = UserID, LastUpdatedBy = UserID, Enable = request.Enable, OrgGuid = string.Empty, ContactNumber = request.ContactNumber, Sort = request.Sort, GuidanceUrl = request.GuidanceUrl ?? string.Empty, ExternalLink = request.ExternalLink ?? string.Empty, Password = CryptoHelper.AddSalt(hospitalGuid, request.Password), Account = request.Account, IsHospital = request.IsHospital, Longitude = request.Longitude, Latitude = request.Latitude }; var officeAll = await new OfficeBiz().GetAllAsync2(); var offices = officeAll.Select(a => (new { a.OfficeName, ParentName = officeAll.FirstOrDefault(b => b.OfficeGuid == a.ParentOfficeGuid)?.OfficeName, a.Sort, a.Enable, a.PictureGuid })).Distinct(); var offices2 = new List <OfficeModel>(); foreach (var item in offices) { GetOfficeModel(item.ParentName, item.OfficeName, item.Sort, item.Enable, item.PictureGuid, hospitalModel, offices2, offices); } var result = await hospitalBiz.AddAsync(hospitalModel, richtextModel, offices2); if (!result) { return(Failed(ErrorCode.UserData, "添加失败")); } return(Success()); }
public async Task <IActionResult> UpdateHospitalAsync([FromBody] UpdateHospitalRequestDto request) { var hospitalBiz = new HospitalBiz(); var hospitalModel = await hospitalBiz.GetAsync(request.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } if (request.Account != hospitalModel.Account && await hospitalBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } var contentBiz = new RichtextBiz(); request.Content = string.IsNullOrWhiteSpace(request.Content) ? "暂无详细" : request.Content; request.HosTag = string.IsNullOrWhiteSpace(request.HosTag) ? "暂无标签" : request.HosTag; var richtextModel = await contentBiz.GetAsync(hospitalModel.HosDetailGuid); var richtextIsAdd = false; if (richtextModel != null) { richtextModel.Content = request.Content; richtextModel.LastUpdatedBy = UserID; richtextModel.LastUpdatedDate = DateTime.Now; richtextModel.OrgGuid = string.Empty; richtextModel.OwnerGuid = request.HospitalGuid; } else { var textGuid = Guid.NewGuid().ToString("N"); richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = hospitalModel.HospitalGuid, TextGuid = textGuid, }; hospitalModel.HosDetailGuid = textGuid; richtextIsAdd = true; } hospitalModel.HosAbstract = request.HosAbstract; hospitalModel.HosLevel = request.HosLevel; hospitalModel.HosName = request.HosName; hospitalModel.HosTag = request.HosTag; hospitalModel.Location = request.Location; hospitalModel.LogoGuid = request.LogoGuid; hospitalModel.RegisteredDate = request.RegisteredDate; hospitalModel.Visibility = request.Visibility; hospitalModel.LastUpdatedBy = UserID; hospitalModel.LastUpdatedDate = DateTime.Now; hospitalModel.Enable = request.Enable; hospitalModel.ContactNumber = request.ContactNumber; hospitalModel.Sort = request.Sort; hospitalModel.GuidanceUrl = request.GuidanceUrl ?? string.Empty; hospitalModel.ExternalLink = request.ExternalLink ?? string.Empty; hospitalModel.Account = request.Account; hospitalModel.IsHospital = request.IsHospital; hospitalModel.Longitude = request.Longitude; hospitalModel.Latitude = request.Latitude; if (null != request.Password) { hospitalModel.Password = CryptoHelper.AddSalt(hospitalModel.HospitalGuid, request.Password); } var response = await hospitalBiz.UpdateAsync(hospitalModel, richtextModel, richtextIsAdd); if (!response) { return(Failed(ErrorCode.DataBaseError, "修改失败")); } return(Success(response)); }
public IActionResult Register([FromBody] PhonePasswordCodeRequestDto request) { var accountBiz = new AccountBiz(); if (!accountBiz.VerifyCode(request.Phone, request.Code)) { return(Failed(ErrorCode.VerificationCode, "手机验证码错误")); } var userID = Guid.NewGuid().ToString("N"); var saltPassword = CryptoHelper.AddSalt(userID, request.Password); if (string.IsNullOrEmpty(saltPassword)) { return(Failed(ErrorCode.SystemException, "密码加盐失败")); } var biz = new AccountBiz(); var list = biz.GetUserByPhone(request.Phone); if (list.Any()) { return(Failed(ErrorCode.DuplicatePhone, "该手机号已经注册")); } #region 获取用户是否有推荐关注公众号记录,若有,则将推荐人设为平台账户推荐人 var recommendUser = TryGetSubscriptionRecommendUser(request.OpenId); if (!string.IsNullOrWhiteSpace(recommendUser)) { request.Referrer = recommendUser; } #endregion var userModel = new UserModel { UserGuid = userID, WechatOpenid = request.OpenId, NickName = userID.Substring(0, 6), UserName = userID.Substring(0, 6), Phone = request.Phone, Password = saltPassword, Birthday = new DateTime(2000, 1, 1), RecommendGuid = request.Referrer, CreatedBy = userID, LastUpdatedBy = userID, OrgGuid = "guodan" }; var consumerModel = new ConsumerModel { ConsumerGuid = userID, CreatedBy = userID, LastUpdatedBy = userID }; var registerModel = new RegisterModel { PlatformType = request.PlatformType, Parameters = request.Parameters }; var result = biz.Register(userModel, consumerModel, registerModel); if (result == null) { return(Failed(ErrorCode.DuplicatePhone)); } if (result.Value) { var message = string.Empty; if (enableXmpp && !RegisterIM(userModel)) // 启用XMPP的情况下,才执行注册 { message = $"register im account failed. user id: {userID}, user phone: {request.Phone}"; Logger.Error(message); } var scoreBiz = new ScoreRulesBiz(); scoreBiz.AddScoreByRules(userID, ActionEnum.Registered, UserType.Consumer); if (!string.IsNullOrEmpty(request.Referrer)) { scoreBiz.AddScoreByRules(request.Referrer, ActionEnum.RecommendRegistered, UserType.Doctor); scoreBiz.AddScoreByRules(request.Referrer, ActionEnum.RecommendRegistered, UserType.Consumer); } return(Success(userID, message)); } else { return(Failed(ErrorCode.DataBaseError)); } }