This commit is contained in:
2023-01-17 17:40:36 +08:00
parent 72c4fedfd5
commit 3f9ffb029b
5 changed files with 74 additions and 13 deletions
@@ -82,7 +82,7 @@ namespace IRaCIS.Core.Application.Contracts
[AllowAnonymous]
public async Task<VerifyEmialGetDoctorInfoOutDto> VerifyEmialGetDoctorInfo(VerifyEmialGetDoctorInfoInDto inDto)
{
var verificationRecord = await _repository.GetQueryable<VerificationCode>().OrderByDescending(x=>x.ExpirationTime).Where(t => (t.EmailOrPhone == inDto.EmailOrPhone) && t.Code == inDto.VerificationCode && t.CodeType == VerifyType.Email).FirstOrDefaultAsync();
var verificationRecord = await _repository.GetQueryable<VerificationCode>().OrderByDescending(x => x.ExpirationTime).Where(t => (t.EmailOrPhone == inDto.EmailOrPhone) && t.Code == inDto.VerificationCode && t.CodeType == VerifyType.Email).FirstOrDefaultAsync();
VerifyEmialGetDoctorInfoOutDto result = new VerifyEmialGetDoctorInfoOutDto();
var doctorInfo = await _doctorRepository.Where(x => x.EMail == inDto.EmailOrPhone).FirstOrDefaultAsync();
@@ -104,7 +104,7 @@ namespace IRaCIS.Core.Application.Contracts
}
else //验证码正确 并且 没有超时
{
result.Token= _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo()));
result.Token = _tokenService.GetToken(IRaCISClaims.Create(new UserBasicInfo()));
}
}
@@ -757,7 +757,7 @@ namespace IRaCIS.Core.Application.Contracts
//await SendInviteEmail(new InviteEmailCommand() { TrialId = trialId, RouteUrl = siteSurvyeSubmit.RouteUrl, UserList = needGenerateList });
await GenerateAccountAsync(needGenerateList,trialId);
await GenerateAccountAsync(needGenerateList, trialId);
await SendSiteSurveyUserJoinEmail(new TrialSiteUserSurveyJoinCommand() { TrialId = trialId, TrialSiteSurveyId = trialSiteSurveyId, RouteUrl = siteSurvyeSubmit.RouteUrl, BaseUrl = siteSurvyeSubmit.BaseUrl, UserList = needGenerateList });
@@ -768,7 +768,7 @@ namespace IRaCIS.Core.Application.Contracts
private async Task GenerateAccountAsync(List<TrialSiteUserSurveyView> needGenerateList,Guid trialId)
private async Task GenerateAccountAsync(List<TrialSiteUserSurveyView> needGenerateList, Guid trialId)
{
foreach (var item in needGenerateList)
{
@@ -776,6 +776,12 @@ namespace IRaCIS.Core.Application.Contracts
//找下系统中是否存在该用户类型的 并且邮箱 或者手机的账户
var sysUserInfo = await _userRepository.Where(t => t.UserTypeId == item.UserTypeId && t.EMail == item.Email).Include(t => t.UserTypeRole).FirstOrDefaultAsync();
var trialType = _repository.Where<Trial>(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault();
if (sysUserInfo == null)
{
@@ -784,13 +790,14 @@ namespace IRaCIS.Core.Application.Contracts
{
var saveItem = _mapper.Map<User>(item);
var trialType = _repository.Where<Trial>(t => t.Id == trialId).Select(t => t.TrialType).FirstOrDefault();
if (trialType == TrialType.NoneOfficial)
{
saveItem.IsTestUser = true;
}
// 中心调研生成账号 都是外部的
saveItem.IsZhiZhun = false;
saveItem.Code = _userRepository.Select(t => t.Code).DefaultIfEmpty().Max() + 1;
saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(User));
@@ -812,6 +819,26 @@ namespace IRaCIS.Core.Application.Contracts
}
if (trialType == TrialType.OfficialTrial || trialType == TrialType.Training)
{
if (sysUserInfo.IsTestUser)
{
throw new BusinessValidationFailedException("正式类型 、培训类型的项目 不允许加入测试用户 ");
}
}
if (trialType == TrialType.NoneOfficial)
{
if (sysUserInfo.IsTestUser == false && sysUserInfo.IsZhiZhun == false)
{
throw new BusinessValidationFailedException("测试项目 不允许加入外部正式用户 ");
}
}
//发送邮件的时候需要用到该字段
item.SystemUserId = sysUserInfo.Id;
@@ -846,7 +873,6 @@ namespace IRaCIS.Core.Application.Contracts
var userId = (Guid)userInfo.SystemUserId;
var siteId = trialSiteSurvey.SiteId;
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
//判断TrialUser中是否存在 不存在就插入
@@ -862,6 +888,9 @@ namespace IRaCIS.Core.Application.Contracts
await _trialSiteUserSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == userInfo.Id, u => new TrialSiteUserSurvey() { IsJoin = true });
}
await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, userId, joinCommand.BaseUrl, joinCommand.RouteUrl);
}
await _trialSiteSurveyRepository.UpdatePartialFromQueryAsync(t => t.Id == trialSiteSurvey.Id && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now });