|
|
@ -38,6 +38,7 @@ using Shentun.Utilities.Enums; |
|
|
using Shentun.Sms.Client; |
|
|
using Shentun.Sms.Client; |
|
|
using Shentun.Utilities; |
|
|
using Shentun.Utilities; |
|
|
using IdentityModel; |
|
|
using IdentityModel; |
|
|
|
|
|
using Shentun.WebPeis.SysParmValues; |
|
|
namespace Shentun.WebPeis.Persons |
|
|
namespace Shentun.WebPeis.Persons |
|
|
{ |
|
|
{ |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
@ -61,6 +62,7 @@ namespace Shentun.WebPeis.Persons |
|
|
private readonly CacheService _cacheService; |
|
|
private readonly CacheService _cacheService; |
|
|
private readonly IHttpContextAccessor _httpContextAccessor; |
|
|
private readonly IHttpContextAccessor _httpContextAccessor; |
|
|
private readonly IRepository<CustomerOrg> _customerOrgRepository; |
|
|
private readonly IRepository<CustomerOrg> _customerOrgRepository; |
|
|
|
|
|
private readonly SysParmValueManager _sysParmValueManager; |
|
|
public PersonAppService(IRepository<Person> repository, |
|
|
public PersonAppService(IRepository<Person> repository, |
|
|
IConfiguration configuration, |
|
|
IConfiguration configuration, |
|
|
IRepository<Volo.Abp.Identity.IdentityUser, Guid> identityUserRepository, |
|
|
IRepository<Volo.Abp.Identity.IdentityUser, Guid> identityUserRepository, |
|
|
@ -74,7 +76,8 @@ namespace Shentun.WebPeis.Persons |
|
|
CacheService cacheService, |
|
|
CacheService cacheService, |
|
|
IHttpContextAccessor httpContextAccessor, |
|
|
IHttpContextAccessor httpContextAccessor, |
|
|
IRepository<CustomerOrg> customerOrgRepository, |
|
|
IRepository<CustomerOrg> customerOrgRepository, |
|
|
IRepository<QuestionRegister> questionRegisterRepository) |
|
|
|
|
|
|
|
|
IRepository<QuestionRegister> questionRegisterRepository, |
|
|
|
|
|
SysParmValueManager sysParmValueManager) |
|
|
{ |
|
|
{ |
|
|
_repository = repository; |
|
|
_repository = repository; |
|
|
_configuration = configuration; |
|
|
_configuration = configuration; |
|
|
@ -90,6 +93,7 @@ namespace Shentun.WebPeis.Persons |
|
|
_httpContextAccessor = httpContextAccessor; |
|
|
_httpContextAccessor = httpContextAccessor; |
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
_questionRegisterRepository = questionRegisterRepository; |
|
|
_questionRegisterRepository = questionRegisterRepository; |
|
|
|
|
|
_sysParmValueManager = sysParmValueManager; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public async Task<PersonDto> GetByIdAsync(PersonIdInputDto input) |
|
|
public async Task<PersonDto> GetByIdAsync(PersonIdInputDto input) |
|
|
@ -102,8 +106,8 @@ namespace Shentun.WebPeis.Persons |
|
|
entityDto.SexName = await _cacheService.GetSexNameAsync(entityDto.SexId); |
|
|
entityDto.SexName = await _cacheService.GetSexNameAsync(entityDto.SexId); |
|
|
entityDto.MaritalStatusName = await _cacheService.GetMaritalStatusNameAsync(entityDto.MaritalStatusId); |
|
|
entityDto.MaritalStatusName = await _cacheService.GetMaritalStatusNameAsync(entityDto.MaritalStatusId); |
|
|
entityDto.NationName = await _cacheService.GetNationNameAsync(entityDto.NationId); |
|
|
entityDto.NationName = await _cacheService.GetNationNameAsync(entityDto.NationId); |
|
|
var questionRegister = await _questionRegisterRepository.FindAsync(o=>o.PersonId == input.PersonId); |
|
|
|
|
|
if(questionRegister != null) |
|
|
|
|
|
|
|
|
var questionRegister = await _questionRegisterRepository.FindAsync(o => o.PersonId == input.PersonId); |
|
|
|
|
|
if (questionRegister != null) |
|
|
{ |
|
|
{ |
|
|
entityDto.IsHaveQuestionRegister = 'Y'; |
|
|
entityDto.IsHaveQuestionRegister = 'Y'; |
|
|
} |
|
|
} |
|
|
@ -154,7 +158,10 @@ namespace Shentun.WebPeis.Persons |
|
|
_cache.Set(sessionKey, sessionKeyValue, options); |
|
|
_cache.Set(sessionKey, sessionKeyValue, options); |
|
|
token.SessionKey = sessionKey; |
|
|
token.SessionKey = sessionKey; |
|
|
token.SessionKeyValue = sessionKeyValue; |
|
|
token.SessionKeyValue = sessionKeyValue; |
|
|
|
|
|
|
|
|
|
|
|
var isOpenPersonalAppointmentStr = await _sysParmValueManager.GetSysParmValueAsync(Guid.Empty, "is_open_personal_appointment"); |
|
|
|
|
|
if (string.IsNullOrWhiteSpace(isOpenPersonalAppointmentStr)) |
|
|
|
|
|
isOpenPersonalAppointmentStr = "Y"; |
|
|
|
|
|
token.IsOpenPersonalAppointment = Convert.ToChar(isOpenPersonalAppointmentStr); |
|
|
return token; |
|
|
return token; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@ -164,7 +171,7 @@ namespace Shentun.WebPeis.Persons |
|
|
[UnitOfWork(IsDisabled = false)] |
|
|
[UnitOfWork(IsDisabled = false)] |
|
|
public async Task<UserTokenDto> CreateAsync(CreatePersonDto input) |
|
|
public async Task<UserTokenDto> CreateAsync(CreatePersonDto input) |
|
|
{ |
|
|
{ |
|
|
if(input == null) throw new UserFriendlyException("input参数不能为空"); |
|
|
|
|
|
|
|
|
if (input == null) throw new UserFriendlyException("input参数不能为空"); |
|
|
|
|
|
|
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) |
|
|
using (var unitOfWork = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true)) |
|
|
{ |
|
|
{ |
|
|
@ -200,7 +207,7 @@ namespace Shentun.WebPeis.Persons |
|
|
throw new UserFriendlyException("无效的短信校验码或已过期"); |
|
|
throw new UserFriendlyException("无效的短信校验码或已过期"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var person = await _repository.FindAsync(o => o.IdNo == input.IdNo); |
|
|
var person = await _repository.FindAsync(o => o.IdNo == input.IdNo); |
|
|
if (person != null) |
|
|
if (person != null) |
|
|
{ |
|
|
{ |
|
|
@ -293,15 +300,15 @@ namespace Shentun.WebPeis.Persons |
|
|
throw new UserFriendlyException("无效的短信校验码或已过期"); |
|
|
throw new UserFriendlyException("无效的短信校验码或已过期"); |
|
|
} |
|
|
} |
|
|
//更新人员信息
|
|
|
//更新人员信息
|
|
|
var person = await _repository.GetAsync(o =>o.PersonId == input.PersonId); |
|
|
|
|
|
|
|
|
var person = await _repository.GetAsync(o => o.PersonId == input.PersonId); |
|
|
await _personManager.UpdateAsync(entity, person); |
|
|
await _personManager.UpdateAsync(entity, person); |
|
|
await _repository.UpdateAsync(person); |
|
|
await _repository.UpdateAsync(person); |
|
|
//更新用户信息
|
|
|
//更新用户信息
|
|
|
var user = await _identityUserRepository.GetAsync(person.PersonId); |
|
|
var user = await _identityUserRepository.GetAsync(person.PersonId); |
|
|
user.Name = input.PersonName; |
|
|
user.Name = input.PersonName; |
|
|
user.SetPhoneNumber(input.MobileTelephone,false); |
|
|
|
|
|
|
|
|
user.SetPhoneNumber(input.MobileTelephone, false); |
|
|
await _identityUserRepository.UpdateAsync(user); |
|
|
await _identityUserRepository.UpdateAsync(user); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ObjectMapper.Map<Person, PersonDto>(person); |
|
|
return ObjectMapper.Map<Person, PersonDto>(person); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
@ -318,21 +325,21 @@ namespace Shentun.WebPeis.Persons |
|
|
|
|
|
|
|
|
var entity = ObjectMapper.Map<UpdatePersonDto, Person>(input); |
|
|
var entity = ObjectMapper.Map<UpdatePersonDto, Person>(input); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新人员信息
|
|
|
//更新人员信息
|
|
|
var person = await _repository.GetAsync(o => o.PersonId == input.PersonId); |
|
|
var person = await _repository.GetAsync(o => o.PersonId == input.PersonId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _personManager.UpdateAsync(entity, person); |
|
|
await _personManager.UpdateAsync(entity, person); |
|
|
await _repository.UpdateAsync(person,true); |
|
|
|
|
|
|
|
|
await _repository.UpdateAsync(person, true); |
|
|
//更新用户信息
|
|
|
//更新用户信息
|
|
|
var user = await _identityUserRepository.GetAsync(person.PersonId); |
|
|
var user = await _identityUserRepository.GetAsync(person.PersonId); |
|
|
user.Name = input.PersonName; |
|
|
user.Name = input.PersonName; |
|
|
|
|
|
|
|
|
await _identityUserRepository.UpdateAsync(user,true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _identityUserRepository.UpdateAsync(user, true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var personDto = await GetByIdAsync(new PersonIdInputDto() { PersonId = input.PersonId }); |
|
|
var personDto = await GetByIdAsync(new PersonIdInputDto() { PersonId = input.PersonId }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//personDto.MobileTelephone = user.PhoneNumber;
|
|
|
//personDto.MobileTelephone = user.PhoneNumber;
|
|
|
//personDto.PersonName = user.Name;
|
|
|
//personDto.PersonName = user.Name;
|
|
|
|
|
|
|
|
|
@ -596,7 +603,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 获取校验码
|
|
|
/// 获取校验码
|
|
|
@ -765,12 +772,25 @@ namespace Shentun.WebPeis.Persons |
|
|
|
|
|
|
|
|
var verifySmsValidTimeStr = _configuration.GetSection("Sms") |
|
|
var verifySmsValidTimeStr = _configuration.GetSection("Sms") |
|
|
.GetSection("VerifySmsValidTime").Value; |
|
|
.GetSection("VerifySmsValidTime").Value; |
|
|
|
|
|
|
|
|
|
|
|
var isTemplateTimeStr = _configuration.GetSection("Sms") |
|
|
|
|
|
.GetSection("IsTemplateTime").Value; |
|
|
|
|
|
|
|
|
if (!int.TryParse(verifySmsValidTimeStr, out var verifySmsValidTime)) |
|
|
if (!int.TryParse(verifySmsValidTimeStr, out var verifySmsValidTime)) |
|
|
{ |
|
|
{ |
|
|
throw new Exception("解析校验短信有效时间错误"); |
|
|
throw new Exception("解析校验短信有效时间错误"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
createSmsTaskDto.Content = message + "|" + verifySmsValidTime.ToString(); |
|
|
|
|
|
|
|
|
if (isTemplateTimeStr == "N") |
|
|
|
|
|
{ |
|
|
|
|
|
createSmsTaskDto.Content = message; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
createSmsTaskDto.Content = message + "|" + verifySmsValidTime.ToString(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//发送短信
|
|
|
//发送短信
|
|
|
createSmsTaskDto.TaskCycleType = '0'; |
|
|
createSmsTaskDto.TaskCycleType = '0'; |
|
|
await SmsClientHelper.CreateVerifySmsTask(createSmsTaskDto); |
|
|
await SmsClientHelper.CreateVerifySmsTask(createSmsTaskDto); |
|
|
|