From 8dc167dc01af5b27332071086d4812fa2ed63e35 Mon Sep 17 00:00:00 2001 From: wxd <123@qq.com> Date: Fri, 12 Jul 2024 18:04:38 +0800 Subject: [PATCH] 0712 --- .../UserTokenDto.cs | 5 ++ .../Persons/PersonAppService.cs | 56 +++++++++++++------ .../appsettings.json | 1 + 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs b/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs index d6e4617..094e9b6 100644 --- a/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs @@ -30,5 +30,10 @@ namespace Shentun.WebPeis /// 会话键值 /// public string SessionKeyValue { get; set; } + + /// + /// 是否开启个人预约 + /// + public char IsOpenPersonalAppointment { get; set; } } } diff --git a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs index e6de184..bee79d6 100644 --- a/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs +++ b/src/Shentun.WebPeis.Application/Persons/PersonAppService.cs @@ -38,6 +38,7 @@ using Shentun.Utilities.Enums; using Shentun.Sms.Client; using Shentun.Utilities; using IdentityModel; +using Shentun.WebPeis.SysParmValues; namespace Shentun.WebPeis.Persons { /// @@ -61,6 +62,7 @@ namespace Shentun.WebPeis.Persons private readonly CacheService _cacheService; private readonly IHttpContextAccessor _httpContextAccessor; private readonly IRepository _customerOrgRepository; + private readonly SysParmValueManager _sysParmValueManager; public PersonAppService(IRepository repository, IConfiguration configuration, IRepository identityUserRepository, @@ -74,7 +76,8 @@ namespace Shentun.WebPeis.Persons CacheService cacheService, IHttpContextAccessor httpContextAccessor, IRepository customerOrgRepository, - IRepository questionRegisterRepository) + IRepository questionRegisterRepository, + SysParmValueManager sysParmValueManager) { _repository = repository; _configuration = configuration; @@ -90,6 +93,7 @@ namespace Shentun.WebPeis.Persons _httpContextAccessor = httpContextAccessor; _customerOrgRepository = customerOrgRepository; _questionRegisterRepository = questionRegisterRepository; + _sysParmValueManager = sysParmValueManager; } public async Task GetByIdAsync(PersonIdInputDto input) @@ -102,8 +106,8 @@ namespace Shentun.WebPeis.Persons entityDto.SexName = await _cacheService.GetSexNameAsync(entityDto.SexId); entityDto.MaritalStatusName = await _cacheService.GetMaritalStatusNameAsync(entityDto.MaritalStatusId); 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'; } @@ -154,7 +158,10 @@ namespace Shentun.WebPeis.Persons _cache.Set(sessionKey, sessionKeyValue, options); token.SessionKey = sessionKey; 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; } @@ -164,7 +171,7 @@ namespace Shentun.WebPeis.Persons [UnitOfWork(IsDisabled = false)] public async Task 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)) { @@ -200,7 +207,7 @@ namespace Shentun.WebPeis.Persons throw new UserFriendlyException("无效的短信校验码或已过期"); } - + var person = await _repository.FindAsync(o => o.IdNo == input.IdNo); if (person != null) { @@ -293,15 +300,15 @@ namespace Shentun.WebPeis.Persons 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 _repository.UpdateAsync(person); //更新用户信息 var user = await _identityUserRepository.GetAsync(person.PersonId); user.Name = input.PersonName; - user.SetPhoneNumber(input.MobileTelephone,false); + user.SetPhoneNumber(input.MobileTelephone, false); await _identityUserRepository.UpdateAsync(user); - + return ObjectMapper.Map(person); } @@ -318,21 +325,21 @@ namespace Shentun.WebPeis.Persons var entity = ObjectMapper.Map(input); - + //更新人员信息 var person = await _repository.GetAsync(o => o.PersonId == input.PersonId); - + await _personManager.UpdateAsync(entity, person); - await _repository.UpdateAsync(person,true); + await _repository.UpdateAsync(person, true); //更新用户信息 var user = await _identityUserRepository.GetAsync(person.PersonId); user.Name = input.PersonName; - - await _identityUserRepository.UpdateAsync(user,true); - + await _identityUserRepository.UpdateAsync(user, true); + + var personDto = await GetByIdAsync(new PersonIdInputDto() { PersonId = input.PersonId }); - + //personDto.MobileTelephone = user.PhoneNumber; //personDto.PersonName = user.Name; @@ -596,7 +603,7 @@ namespace Shentun.WebPeis.Persons } - + /// /// 获取校验码 @@ -765,12 +772,25 @@ namespace Shentun.WebPeis.Persons var verifySmsValidTimeStr = _configuration.GetSection("Sms") .GetSection("VerifySmsValidTime").Value; + + var isTemplateTimeStr = _configuration.GetSection("Sms") + .GetSection("IsTemplateTime").Value; + if (!int.TryParse(verifySmsValidTimeStr, out var verifySmsValidTime)) { throw new Exception("解析校验短信有效时间错误"); } - createSmsTaskDto.Content = message + "|" + verifySmsValidTime.ToString(); + if (isTemplateTimeStr == "N") + { + createSmsTaskDto.Content = message; + } + else + { + createSmsTaskDto.Content = message + "|" + verifySmsValidTime.ToString(); + } + + //发送短信 createSmsTaskDto.TaskCycleType = '0'; await SmsClientHelper.CreateVerifySmsTask(createSmsTaskDto); diff --git a/src/Shentun.WebPeis.HttpApi.Host/appsettings.json b/src/Shentun.WebPeis.HttpApi.Host/appsettings.json index 495cd34..f7df489 100644 --- a/src/Shentun.WebPeis.HttpApi.Host/appsettings.json +++ b/src/Shentun.WebPeis.HttpApi.Host/appsettings.json @@ -54,6 +54,7 @@ "Password": "888888", "VerifySmsTypeId": "3a12e09d-438a-1d08-d4f0-712aef13708d", "VerifySmsValidTime": "1", + "IsTemplateTime": "N", "SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6" }, "Redis": {