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> /// <summary>
/// 微信OpenId /// 微信OpenId
/// </summary> /// </summary>
public string WechatOpenId { get; set; }
public string? WechatOpenId { get; set; }
/// <summary> /// <summary>
/// 姓名 /// 姓名
/// </summary> /// </summary>
@ -19,6 +19,18 @@ namespace Shentun.WebPeis.Persons
/// 手机号码 /// 手机号码
/// </summary> /// </summary>
public string MobileTelephone { get; set; } public string MobileTelephone { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string IdNo { get; set; } 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 public class UserTokenDto
{ {
/// <summary>
/// 是否新用户
/// </summary>
public string IsNewUser { get; set; } = "Y"; public string IsNewUser { get; set; } = "Y";
/// <summary>
/// 微信OpenId
/// </summary>
public string OpenId { get; set; } public string OpenId { get; set; }
/// <summary>
/// 访问TOKEN
/// </summary>
public string AccessToken { get; set; } public string AccessToken { get; set; }
/// <summary>
/// 刷新Token
/// </summary>
public string RefreshToken { get; set; } 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, AppointScheduleId = x.Key.AppointScheduleId,
AppointDate = x.Key.AppointDate, 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(); }).ToList();
return list; return list;
} }

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

@ -71,7 +71,7 @@ namespace Shentun.WebPeis.Persons
IRepository<PatientRegister> patientRegisterRepository, IRepository<PatientRegister> patientRegisterRepository,
IRepository<Patient> patientRepository, IRepository<Patient> patientRepository,
CacheService cacheService, CacheService cacheService,
IHttpContextAccessor httpContextAccessor,
//IHttpContextAccessor httpContextAccessor,
IRepository<CustomerOrg> customerOrgRepository) IRepository<CustomerOrg> customerOrgRepository)
{ {
_repository = repository; _repository = repository;
@ -85,7 +85,7 @@ namespace Shentun.WebPeis.Persons
_patientRegisterRepository = patientRegisterRepository; _patientRegisterRepository = patientRegisterRepository;
_patientRepository = patientRepository; _patientRepository = patientRepository;
_cacheService = cacheService; _cacheService = cacheService;
_httpContextAccessor = httpContextAccessor;
//_httpContextAccessor = httpContextAccessor;
_customerOrgRepository = customerOrgRepository; _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 dicStr = dic.Select(m => m.Key + "=" + m.Value).DefaultIfEmpty().Aggregate((m, n) => m + "&" + n);
var token = await GetTokenAsync(dicStr); 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; return token;
} }
@ -411,13 +416,22 @@ namespace Shentun.WebPeis.Persons
{ {
throw new UserFriendlyException("input不能为空"); 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)) 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 OpenIdKey = "OpenIdKey";
public const string SmsKey = "SmsKey"; public const string SmsKey = "SmsKey";
public const string SessionKey = "SessionKey";
} }
} }

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

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