Browse Source

短信

master
DESKTOP-G961P6V\Zhh 1 year ago
parent
commit
239d533841
  1. 14
      src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs
  2. 20
      src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs
  3. 4
      src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs
  4. 26
      src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
  5. 1
      src/Shentun.WebPeis.Domain.Shared/Enums/CacheKeys.cs
  6. 1
      test/Shentun.WebPeis.Application.Tests/appsettings.json

14
src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs

@ -9,7 +9,7 @@ namespace Shentun.WebPeis.Persons
/// <summary>
/// 微信OpenId
/// </summary>
public string WechatOpenId { get; set; }
public string? WechatOpenId { get; set; }
/// <summary>
/// 姓名
/// </summary>
@ -19,6 +19,18 @@ namespace Shentun.WebPeis.Persons
/// 手机号码
/// </summary>
public string MobileTelephone { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string IdNo { get; set; }
/// <summary>
/// 会话键
/// </summary>
public string SessionKey { get; set; }
/// <summary>
/// 会话键值
/// </summary>
public string SessionKeyValue { get; set; }
}
}

20
src/Shentun.WebPeis.Application.Contracts/UserTokenDto.cs

@ -6,9 +6,29 @@ namespace Shentun.WebPeis
{
public class UserTokenDto
{
/// <summary>
/// 是否新用户
/// </summary>
public string IsNewUser { get; set; } = "Y";
/// <summary>
/// 微信OpenId
/// </summary>
public string OpenId { get; set; }
/// <summary>
/// 访问TOKEN
/// </summary>
public string AccessToken { get; set; }
/// <summary>
/// 刷新Token
/// </summary>
public string RefreshToken { get; set; }
/// <summary>
/// 会话键
/// </summary>
public string SessionKey { get; set; }
/// <summary>
/// 会话键值
/// </summary>
public string SessionKeyValue { get; set; }
}
}

4
src/Shentun.WebPeis.Application/AppointSchedules/AppointScheduleAppService.cs

@ -97,8 +97,8 @@ namespace Shentun.WebPeis.AppointSchedules
{
AppointScheduleId = x.Key.AppointScheduleId,
AppointDate = x.Key.AppointDate,
IsWork = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) == 0 ? 'N' : 'Y',
IsFull = (x.Key.AmNumberLimit + x.Key.PmNumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N'
IsWork = x.Key.IsWork,
IsFull = x.Key.AppointScheduleTimes.Sum(m => m.NumberLimit) <= x.Key.AppointScheduleTimes.Sum(m => m.AppointNumber) ? 'Y' : 'N'
}).ToList();
return list;
}

26
src/Shentun.WebPeis.Application/Persons/PersonAppService.cs

@ -71,7 +71,7 @@ namespace Shentun.WebPeis.Persons
IRepository<PatientRegister> patientRegisterRepository,
IRepository<Patient> patientRepository,
CacheService cacheService,
IHttpContextAccessor httpContextAccessor,
//IHttpContextAccessor httpContextAccessor,
IRepository<CustomerOrg> customerOrgRepository)
{
_repository = repository;
@ -85,7 +85,7 @@ namespace Shentun.WebPeis.Persons
_patientRegisterRepository = patientRegisterRepository;
_patientRepository = patientRepository;
_cacheService = cacheService;
_httpContextAccessor = httpContextAccessor;
//_httpContextAccessor = httpContextAccessor;
_customerOrgRepository = customerOrgRepository;
}
@ -130,6 +130,11 @@ namespace Shentun.WebPeis.Persons
var dicStr = dic.Select(m => m.Key + "=" + m.Value).DefaultIfEmpty().Aggregate((m, n) => m + "&" + n);
var token = await GetTokenAsync(dicStr);
var sessionKey = CacheKeys.SessionKey + Guid.NewGuid().ToString();
var sessionKeyValue = Guid.NewGuid().ToString();
_cache.Set(sessionKey, sessionKeyValue);
token.SessionKey = sessionKey;
token.SessionKeyValue = sessionKeyValue;
return token;
}
@ -411,13 +416,22 @@ namespace Shentun.WebPeis.Persons
{
throw new UserFriendlyException("input不能为空");
}
if (string.IsNullOrWhiteSpace(input.WechatOpenId))
//if (string.IsNullOrWhiteSpace(input.WechatOpenId))
//{
// throw new UserFriendlyException("WechatOpenId不能为空");
//}
//if (_cache.Get(CacheKeys.OpenIdKey + input.WechatOpenId) != input.WechatOpenId)
//{
// throw new UserFriendlyException("无效的WechatOpenId");
//}
if (string.IsNullOrWhiteSpace(input.SessionKey))
{
throw new UserFriendlyException("WechatOpenId不能为空");
throw new UserFriendlyException("SessionKey不能为空");
}
if (_cache.Get(CacheKeys.OpenIdKey + input.WechatOpenId) != input.WechatOpenId)
if (_cache.Get(input.SessionKey) != input.SessionKeyValue)
{
throw new UserFriendlyException("无效的WechatOpenId");
throw new UserFriendlyException("无效的SessionKeyValue");
}
if (string.IsNullOrWhiteSpace(input.PersonName))

1
src/Shentun.WebPeis.Domain.Shared/Enums/CacheKeys.cs

@ -8,5 +8,6 @@ namespace Shentun.WebPeis.Enums
{
public const string OpenIdKey = "OpenIdKey";
public const string SmsKey = "SmsKey";
public const string SessionKey = "SessionKey";
}
}

1
test/Shentun.WebPeis.Application.Tests/appsettings.json

@ -47,6 +47,7 @@
"User": "admin",
"Password": "888888",
"VerifySmsTypeId": "3a12e09d-438a-1d08-d4f0-712aef13708d",
"VerifySmsValidTime": "1",
"SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6"
}
}
Loading…
Cancel
Save