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()); }