|
@@ -1,9 +1,11 @@
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.Caching.Interfaces;
|
|
using Hotline.Orders;
|
|
using Hotline.Orders;
|
|
using Hotline.Repository.SqlSugar.Snapshot;
|
|
using Hotline.Repository.SqlSugar.Snapshot;
|
|
|
|
+using Hotline.Settings;
|
|
using Hotline.Share.Dtos.Snapshot;
|
|
using Hotline.Share.Dtos.Snapshot;
|
|
using Hotline.Share.Enums.Snapshot;
|
|
using Hotline.Share.Enums.Snapshot;
|
|
using Hotline.Share.Enums.User;
|
|
using Hotline.Share.Enums.User;
|
|
|
|
+using Hotline.Share.Tools;
|
|
using Hotline.Snapshot;
|
|
using Hotline.Snapshot;
|
|
using Hotline.Snapshot.Interfaces;
|
|
using Hotline.Snapshot.Interfaces;
|
|
using Hotline.ThirdAccountDomainServices;
|
|
using Hotline.ThirdAccountDomainServices;
|
|
@@ -18,25 +20,29 @@ using System.Threading.Tasks;
|
|
using XF.Domain.Dependency;
|
|
using XF.Domain.Dependency;
|
|
|
|
|
|
namespace Hotline.Application.Snapshot;
|
|
namespace Hotline.Application.Snapshot;
|
|
-public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDependency
|
|
|
|
|
|
+public class SnapshotThirdAccountSupplier : IThirdAccountSupplier, IScopeDependency
|
|
{
|
|
{
|
|
private readonly IThirdAccountRepository _thirdAccountRepository;
|
|
private readonly IThirdAccountRepository _thirdAccountRepository;
|
|
|
|
+ private readonly IThirdAccountDomainService _thirdAccountDomainService;
|
|
private readonly IVolunteerRepository _volunteerRepository;
|
|
private readonly IVolunteerRepository _volunteerRepository;
|
|
private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
|
|
private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
private readonly ISystemSettingCacheManager _systemSettingCacheManager;
|
|
|
|
+ private readonly ISystemLogRepository _systemLog;
|
|
|
|
|
|
- public SnapshotThirdAccountSupplier(IThirdAccountRepository thirdAccountRepository, IVolunteerRepository volunteerRepository, ISnapshotUserInfoRepository snapshotUserInfoRepository, ISystemSettingCacheManager systemSettingCacheManager)
|
|
|
|
|
|
+ public SnapshotThirdAccountSupplier(IThirdAccountRepository thirdAccountRepository, IVolunteerRepository volunteerRepository, ISnapshotUserInfoRepository snapshotUserInfoRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemLogRepository systemLog, IThirdAccountDomainService thirdAccountDomainService)
|
|
{
|
|
{
|
|
_thirdAccountRepository = thirdAccountRepository;
|
|
_thirdAccountRepository = thirdAccountRepository;
|
|
_volunteerRepository = volunteerRepository;
|
|
_volunteerRepository = volunteerRepository;
|
|
_snapshotUserInfoRepository = snapshotUserInfoRepository;
|
|
_snapshotUserInfoRepository = snapshotUserInfoRepository;
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
_systemSettingCacheManager = systemSettingCacheManager;
|
|
|
|
+ _systemLog = systemLog;
|
|
|
|
+ _thirdAccountDomainService = thirdAccountDomainService;
|
|
}
|
|
}
|
|
|
|
|
|
public async Task<List<Claim>> GetClaimAsync(ThirdAccount account, List<Claim> claims, CancellationToken token)
|
|
public async Task<List<Claim>> GetClaimAsync(ThirdAccount account, List<Claim> claims, CancellationToken token)
|
|
{
|
|
{
|
|
- var userInfo = await _snapshotUserInfoRepository.GetByThirdIdAsync(account.Id);
|
|
|
|
- if(userInfo != null)
|
|
|
|
|
|
+ var userInfo = await _snapshotUserInfoRepository.GetAsync(account.ExternalId);
|
|
|
|
+ if (userInfo != null)
|
|
{
|
|
{
|
|
var subject = claims.Find(m => m.Type == JwtClaimTypes.Subject);
|
|
var subject = claims.Find(m => m.Type == JwtClaimTypes.Subject);
|
|
if (subject != null)
|
|
if (subject != null)
|
|
@@ -49,17 +55,17 @@ public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDe
|
|
public async Task<Dictionary<string, object>> GetLoginOutDataAsync(ThirdAccount thirdAccount, Dictionary<string, object> dicOutData, CancellationToken cancel)
|
|
public async Task<Dictionary<string, object>> GetLoginOutDataAsync(ThirdAccount thirdAccount, Dictionary<string, object> dicOutData, CancellationToken cancel)
|
|
{
|
|
{
|
|
var isVolunteer = await _volunteerRepository.IsVolunteerAsync(thirdAccount.PhoneNumber);
|
|
var isVolunteer = await _volunteerRepository.IsVolunteerAsync(thirdAccount.PhoneNumber);
|
|
- var user = await _snapshotUserInfoRepository.Queryable().Where(m => m.ThirdAccountId == thirdAccount.Id).FirstAsync();
|
|
|
|
- if (user == null)
|
|
|
|
|
|
+ var user = await _snapshotUserInfoRepository.GetAsync(thirdAccount.ExternalId);
|
|
|
|
+ if (user == null || thirdAccount.ExternalId.IsNullOrEmpty())
|
|
{
|
|
{
|
|
user = new SnapshotUserInfo
|
|
user = new SnapshotUserInfo
|
|
{
|
|
{
|
|
CitizenType = EReadPackUserType.Citizen,
|
|
CitizenType = EReadPackUserType.Citizen,
|
|
- ThirdAccountId = thirdAccount.Id,
|
|
|
|
Name = thirdAccount.UserName,
|
|
Name = thirdAccount.UserName,
|
|
PhoneNumber = thirdAccount.PhoneNumber,
|
|
PhoneNumber = thirdAccount.PhoneNumber,
|
|
};
|
|
};
|
|
- await _snapshotUserInfoRepository.AddAsync(user);
|
|
|
|
|
|
+ user.Id = await _snapshotUserInfoRepository.AddAsync(user);
|
|
|
|
+ await _thirdAccountDomainService.UpdateExternalIdAsync(thirdAccount.Id, thirdAccount.ExternalId, user.Id, cancel);
|
|
}
|
|
}
|
|
dicOutData.Add("UserType", user.CitizenType);
|
|
dicOutData.Add("UserType", user.CitizenType);
|
|
dicOutData.Add("IsVolunteer", isVolunteer);
|
|
dicOutData.Add("IsVolunteer", isVolunteer);
|
|
@@ -83,18 +89,18 @@ public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDe
|
|
if (userInfo != null)
|
|
if (userInfo != null)
|
|
{
|
|
{
|
|
userInfo.CitizenType = EReadPackUserType.Guider;
|
|
userInfo.CitizenType = EReadPackUserType.Guider;
|
|
- userInfo.ThirdAccountId = thirdAccount.Id;
|
|
|
|
await _snapshotUserInfoRepository.UpdateAsync(userInfo);
|
|
await _snapshotUserInfoRepository.UpdateAsync(userInfo);
|
|
|
|
+ await _thirdAccountDomainService.UpdateExternalIdAsync(thirdAccount.Id, thirdAccount.ExternalId, userInfo.Id, token);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
userInfo = new SnapshotUserInfo
|
|
userInfo = new SnapshotUserInfo
|
|
{
|
|
{
|
|
- ThirdAccountId = thirdAccount.Id,
|
|
|
|
PhoneNumber = thirdAccount.PhoneNumber,
|
|
PhoneNumber = thirdAccount.PhoneNumber,
|
|
CitizenType = EReadPackUserType.Citizen,
|
|
CitizenType = EReadPackUserType.Citizen,
|
|
};
|
|
};
|
|
- await _snapshotUserInfoRepository.AddAsync(userInfo);
|
|
|
|
|
|
+ userInfo.Id = await _snapshotUserInfoRepository.AddAsync(userInfo);
|
|
|
|
+ await _thirdAccountDomainService.UpdateExternalIdAsync(thirdAccount.Id, thirdAccount.ExternalId, userInfo.Id, token);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|