Browse Source

合并冲突

qinchaoyue 1 month ago
parent
commit
27a3fe5f41
31 changed files with 221 additions and 168 deletions
  1. 2 2
      src/Hotline.Application/Identity/IdentityAppService.cs
  2. 0 0
      src/Hotline.Application/Snapshot/DefaultSnapshotApplication.cs
  3. 27 34
      src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs
  4. 37 15
      src/Hotline.Application/Snapshot/SnapshotThirdAccountSupplier.cs
  5. 0 0
      src/Hotline.Application/Snapshot/ZiGongSnapshotApplication.cs
  6. 0 23
      src/Hotline.Repository.SqlSugar/Snapshot/GuiderInfoRepository.cs
  7. 16 2
      src/Hotline.Repository.SqlSugar/Snapshot/SnapshotUserInfoRepository.cs
  8. 5 0
      src/Hotline.Repository.SqlSugar/Snapshot/VolunteerRepository.cs
  9. 0 22
      src/Hotline/Snapshot/GuiderInfo.cs
  10. 0 13
      src/Hotline/Snapshot/Interfaces/IGuiderInfoRepository.cs
  11. 13 0
      src/Hotline/Snapshot/Interfaces/ISnapshotUserInfoRepository.cs
  12. 26 3
      src/Hotline/Snapshot/SnapshotUserInfo.cs
  13. 27 1
      src/Hotline/ThirdAccountDomainServices/Interfaces/IThirdAccountDomainService.cs
  14. 0 15
      src/Hotline/ThirdAccountDomainServices/ThirdAccount.cs
  15. 1 1
      src/Hotline/ThirdAccountDomainServices/ThirdAccountDomainFactory.cs
  16. 2 1
      test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs
  17. 2 1
      test/Hotline.Tests/Application/DefaultCallApplicationTest.cs
  18. 2 1
      test/Hotline.Tests/Application/IndustryApplicationTest.cs
  19. 8 6
      test/Hotline.Tests/Application/InviteCodeApplicationTest.cs
  20. 2 1
      test/Hotline.Tests/Application/KnowApplicationTest.cs
  21. 2 1
      test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs
  22. 2 1
      test/Hotline.Tests/Application/RedPackApplicationTest.cs
  23. 14 12
      test/Hotline.Tests/Application/SnapshotApplicationTest.cs
  24. 2 1
      test/Hotline.Tests/Application/SystemSettingCacheManagerTest.cs
  25. 2 1
      test/Hotline.Tests/Controller/IndustryControllerTest.cs
  26. 2 1
      test/Hotline.Tests/Controller/KnowledgeControllerTest.cs
  27. 3 2
      test/Hotline.Tests/Controller/OrderControllerTest.cs
  28. 2 1
      test/Hotline.Tests/Controller/SnapshotControllerTest.cs
  29. 1 0
      test/Hotline.Tests/Controller/TestSessionContext.cs
  30. 2 1
      test/Hotline.Tests/Domain/OrderVisitDomainServiceTest.cs
  31. 19 6
      test/Hotline.Tests/TestBase.cs

+ 2 - 2
src/Hotline.Application/Identity/IdentityAppService.cs

@@ -320,7 +320,8 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
         {
             thirdAccount = thirdToken.Adapt<ThirdAccount>();
             thirdAccount.PhoneNumber = phone.PhoneNumber;
-            thirdAccount.Id = await _thirdAccountDomainFactory.RegisterAsync(thirdAccount, token);
+            thirdAccount.Id = await _thirdAccountRepository.AddAsync(thirdAccount);
+            await _thirdAccountDomainFactory.RegisterAsync(thirdAccount, token);
         }
 
         return await GetJwtToken(thirdAccount, token);
@@ -352,7 +353,6 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
         
         var dicOutData = new Dictionary<string, object>()
         {
-            { "UserType", thirdAccount.CitizenType },
             { "Token", token },
             { "OpenId", thirdAccount.OpenId },
             { "PhoneNumber", thirdAccount.PhoneNumber },

File diff suppressed because it is too large
+ 0 - 0
src/Hotline.Application/Snapshot/DefaultSnapshotApplication.cs


+ 27 - 34
src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs

@@ -69,7 +69,6 @@ public abstract class SnapshotApplicationBase
     private readonly IGuiderSystemService _guiderSystemService;
     private readonly ICapPublisher _capPublisher;
     private readonly Publisher _publisher;
-    private readonly IGuiderInfoRepository _guiderInfoRepository;
     private readonly IFileDomainService _fileDomainService;
     private readonly ICommunityInfoRepository _communityInfoRepository;
     private readonly IRedPackAuditRepository _redPackAuditRepository;
@@ -78,8 +77,9 @@ public abstract class SnapshotApplicationBase
     private readonly IOrderVisitDetailRepository _orderVisitDetailRepository;
     private readonly IInviteCodeRecordRepository _inviteCodeRecordRepository;
     private readonly IInviteCodeRepository _inviteCodeRepository;
+    private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
 
-    public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IIndustryRepository industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRepository<RedPackRecord> redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IOrderSnapshotRepository orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, ISystemLogRepository systemLog, IGuiderSystemService guiderSystemService, ICapPublisher capPublisher, Publisher publisher, IGuiderInfoRepository guiderInfoRepository, IFileDomainService fileDomainService, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IOrderVisitRepository orderVisitRepository, IOrderVisitDetailRepository orderVisitDetailRepository, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IInviteCodeRecordRepository inviteCodeRecordRepository, IInviteCodeRepository inviteCodeRepository)
+    public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IIndustryRepository industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRepository<RedPackRecord> redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IOrderSnapshotRepository orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, ISystemLogRepository systemLog, IGuiderSystemService guiderSystemService, ICapPublisher capPublisher, Publisher publisher, IFileDomainService fileDomainService, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IOrderVisitRepository orderVisitRepository, IOrderVisitDetailRepository orderVisitDetailRepository, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IInviteCodeRecordRepository inviteCodeRecordRepository, IInviteCodeRepository inviteCodeRepository, ISnapshotUserInfoRepository snapshotUserInfoRepository)
     {
         _thirdLoginService = thirdLoginService;
         _industryRepository = industryRepository;
@@ -103,7 +103,6 @@ public abstract class SnapshotApplicationBase
         _guiderSystemService = guiderSystemService;
         _capPublisher = capPublisher;
         _publisher = publisher;
-        _guiderInfoRepository = guiderInfoRepository;
         _fileDomainService = fileDomainService;
         _communityInfoRepository = communityInfoRepository;
         _redPackAuditRepository = redPackAuditRepository;
@@ -112,6 +111,7 @@ public abstract class SnapshotApplicationBase
         _redPackGuiderAuditRepository = redPackGuiderAuditRepository;
         _inviteCodeRecordRepository = inviteCodeRecordRepository;
         _inviteCodeRepository = inviteCodeRepository;
+        _snapshotUserInfoRepository = snapshotUserInfoRepository;
     }
 
     #region 小程序
@@ -295,20 +295,17 @@ public abstract class SnapshotApplicationBase
     /// <returns></returns>
     public async Task<SnapshotUserInfoOutDto> GetSnapshotUserInfoAsync()
     {
-        var openId = _sessionContext.OpenId;
-        var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(openId);
-        if (thirdAccount.PhoneNumber.IsNullOrEmpty() && _sessionContext.Phone.NotNullOrEmpty())
-            thirdAccount.PhoneNumber = _sessionContext.Phone;
+        var userInfo = await _snapshotUserInfoRepository.GetAsync(_sessionContext.UserId);
 
         var dayTime = DateTime.Now;
         var readPack = await _redPackRecordRepository.Queryable()
-            .Where(m => m.WXOpenId == openId && m.PickupStatus == ERedPackPickupStatus.Received)
+            .Where(m => m.WXOpenId == _sessionContext.OpenId && m.PickupStatus == ERedPackPickupStatus.Received)
             .Where(m => m.CreationTime.Date == dayTime.Date)
             .Select(m => SqlFunc.AggregateSum(m.Amount))
             .FirstAsync();
 
         var outDto = await _orderRepository.Queryable()
-            .Where(m => m.Contact == thirdAccount.PhoneNumber)
+            .Where(m => m.Contact == userInfo.PhoneNumber)
             .Select(m => new SnapshotUserInfoOutDto
             {
                 NoReplyCount = SqlFunc.AggregateSum(SqlFunc.IIF(m.Status < EOrderStatus.Filed, 1, 0)),
@@ -317,9 +314,8 @@ public abstract class SnapshotApplicationBase
             }).FirstAsync();
 
         outDto.DayAmount = readPack;
-        throw new NotImplementedException("TotalAmount");
-        //outDto.TotalAmount = thirdAccount.TotalAmount;
-        outDto.PhoneNumber = thirdAccount.PhoneNumber;
+        outDto.TotalAmount = userInfo.TotalAmount;
+        outDto.PhoneNumber = userInfo.PhoneNumber;
         return outDto;
     }
 
@@ -469,10 +465,9 @@ public abstract class SnapshotApplicationBase
     /// <returns></returns>
     public async Task<string> GetRedPackReceivedTotalAsync(CancellationToken cancellationToken)
     {
-        var member = await _thirdAccountRepository.GetAsync(m => m.OpenId == _sessionContext.OpenId || m.PhoneNumber == _sessionContext.Phone, cancellationToken)
+        var member = await _snapshotUserInfoRepository.GetAsync(m => m.Id == _sessionContext.UserId, cancellationToken)
             ?? throw UserFriendlyException.SameMessage("用户不存在");
-        throw new NotImplementedException("TotalAmount");
-        //return member.TotalAmount.ToYuanFinance();
+        return member.TotalAmount.ToYuanFinance();
     }
 
     /// <summary>
@@ -531,30 +526,31 @@ public abstract class SnapshotApplicationBase
         { 
             throw new UserFriendlyException(200, "邀请码格式错误");
         }
-        var third = await _thirdAccountRepository.GetByOpenIdAsync(_sessionContext.OpenId)
+        var userInfo = await _snapshotUserInfoRepository.GetAsync(_sessionContext.UserId)
             ?? throw UserFriendlyException.SameMessage("用户不存在");
-        //if (third.InvitationCode.NotNullOrEmpty())
-        //{
-        //    throw new UserFriendlyException(200, "邀请码已存在");
-        //}
+        if (userInfo.InvitationCode.NotNullOrEmpty())
+        {
+            throw new UserFriendlyException(200, "邀请码已存在");
+        }
         if (_inviteCodeRecordRepository.Queryable().Where(m => m.InviteCode == dto.InvitationCode).Any())
         {
             throw new UserFriendlyException(200, "邀请码已经被使用");
         }
-        //third.InvitationCode = dto.InvitationCode;
+        userInfo.InvitationCode = dto.InvitationCode;
         var invite = await _inviteCodeRepository.Queryable()
             .Where(m => invitationCode >= m.BeginCode && invitationCode <= m.EndCode)
             .FirstAsync() ?? throw new UserFriendlyException(200, "邀请码无效");
+        var thirdInfo = await _thirdAccountRepository.GetAsync(userInfo.ThirdAccountId);
         var entity = new InviteCodeRecord
         {
             OrgId = invite.Id,
             OrgName = invite.OrgName,
             InviteCode = dto.InvitationCode,
-            WXOpenId = third.OpenId,
-            PhoneNumber = third.PhoneNumber,
-            Name = third.UserName,
+            WXOpenId = thirdInfo.OpenId,
+            PhoneNumber = userInfo.PhoneNumber,
+            Name = userInfo.Name,
         };
-        await _thirdAccountRepository.UpdateAsync(third);
+        await _snapshotUserInfoRepository.UpdateAsync(userInfo);
         await _inviteCodeRecordRepository.AddAsync(entity);
     }
 
@@ -669,21 +665,18 @@ public abstract class SnapshotApplicationBase
             .Where(m => m.Id == orderId)
             .Select(m => new { m.MemberName, m.MemberMobile })
             .FirstAsync(cancellationToken);
-        var guider = await _guiderInfoRepository.GetByPhoneNumberAsync(guiderInfo.MemberMobile);
+        var guider = await _snapshotUserInfoRepository.GetByPhoneNumberAsync(guiderInfo.MemberMobile);
         if (guider != null) return;
 
-        var entity = new GuiderInfo
+        var entity = new SnapshotUserInfo
         {
             Name = guiderInfo.MemberName,
-            PhoneNumber = guiderInfo.MemberMobile
+            PhoneNumber = guiderInfo.MemberMobile,
+            CitizenType = EReadPackUserType.Guider
         };
-        entity.Id = await _guiderInfoRepository.AddAsync(entity, cancellationToken);
         var third = await _thirdAccountRepository.GetByPhoneNumberAsync(guiderInfo.MemberMobile);
-
-        if (third == null) return;
-        third.UserId = entity.Id;
-        third.CitizenType = EReadPackUserType.Guider;
-        await _thirdAccountRepository.UpdateAsync(third, cancellationToken);
+        entity.ThirdAccountId = third?.Id;
+        entity.Id = await _snapshotUserInfoRepository.AddAsync(entity, cancellationToken);
     }
 
     /// <summary>

+ 37 - 15
src/Hotline.Application/Snapshot/SnapshotThirdAccountSupplier.cs

@@ -4,9 +4,11 @@ using Hotline.Repository.SqlSugar.Snapshot;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.Snapshot;
 using Hotline.Share.Enums.User;
+using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
+using IdentityModel;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -18,18 +20,14 @@ using XF.Domain.Dependency;
 namespace Hotline.Application.Snapshot;
 public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDependency
 {
-    private readonly IGuiderInfoRepository _guiderInfoRepository;
     private readonly IThirdAccountRepository _thirdAccountRepository;
-    private readonly ICitizenRepository _citizenRepository;
     private readonly IVolunteerRepository _volunteerRepository;
     private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
     private readonly ISystemSettingCacheManager _systemSettingCacheManager;
 
-    public SnapshotThirdAccountSupplier(IGuiderInfoRepository guiderInfoRepository, IThirdAccountRepository thirdAccountRepository, ICitizenRepository citizenRepository, IVolunteerRepository volunteerRepository, ISnapshotUserInfoRepository snapshotUserInfoRepository, ISystemSettingCacheManager systemSettingCacheManager)
+    public SnapshotThirdAccountSupplier(IThirdAccountRepository thirdAccountRepository, IVolunteerRepository volunteerRepository, ISnapshotUserInfoRepository snapshotUserInfoRepository, ISystemSettingCacheManager systemSettingCacheManager)
     {
-        _guiderInfoRepository = guiderInfoRepository;
         _thirdAccountRepository = thirdAccountRepository;
-        _citizenRepository = citizenRepository;
         _volunteerRepository = volunteerRepository;
         _snapshotUserInfoRepository = snapshotUserInfoRepository;
         _systemSettingCacheManager = systemSettingCacheManager;
@@ -37,13 +35,33 @@ public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDe
 
     public async Task<List<Claim>> GetClaimAsync(ThirdAccount account, List<Claim> claims, CancellationToken token)
     {
-        return await Task.FromResult(claims);
+        var userInfo = await _snapshotUserInfoRepository.GetByThirdIdAsync(account.Id);
+        if(userInfo != null)
+        {
+            var subject = claims.Find(m => m.Type == JwtClaimTypes.Subject);
+            if (subject != null)
+                claims.Remove(subject);
+            claims.Add(new(JwtClaimTypes.Subject, userInfo.Id));
+        }
+        return claims;
     }
 
     public async Task<Dictionary<string, object>> GetLoginOutDataAsync(ThirdAccount thirdAccount, Dictionary<string, object> dicOutData, CancellationToken cancel)
     {
         var isVolunteer = await _volunteerRepository.IsVolunteerAsync(thirdAccount.PhoneNumber);
         var user = await _snapshotUserInfoRepository.Queryable().Where(m => m.ThirdAccountId == thirdAccount.Id).FirstAsync();
+        if (user == null)
+        {
+            user = new SnapshotUserInfo
+            {
+                CitizenType = EReadPackUserType.Citizen,
+                ThirdAccountId = thirdAccount.Id,
+                Name = thirdAccount.UserName,
+                PhoneNumber = thirdAccount.PhoneNumber,
+            };
+            await _snapshotUserInfoRepository.AddAsync(user);
+        }
+        dicOutData.Add("UserType", user.CitizenType);
         dicOutData.Add("IsVolunteer", isVolunteer);
         dicOutData.Add("InvitationCode", user.InvitationCode);
         return dicOutData;
@@ -59,21 +77,25 @@ public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDe
         return await Task.FromResult(thirdDto);
     }
 
-    public async Task<string> RegisterAsync(ThirdAccount thirdAccount, CancellationToken token)
+    public async Task RegisterAsync(ThirdAccount thirdAccount, CancellationToken token)
     {
-        thirdAccount.CitizenType = EReadPackUserType.Citizen;
-        var guider = await _guiderInfoRepository.GetByPhoneNumberAsync(thirdAccount.PhoneNumber);
-        if (guider != null)
+        var userInfo = await _snapshotUserInfoRepository.GetByPhoneNumberAsync(thirdAccount.PhoneNumber);
+        if (userInfo != null)
         {
-            thirdAccount.CitizenType = EReadPackUserType.Guider;
-            thirdAccount.UserId = guider.Id;
+            userInfo.CitizenType = EReadPackUserType.Guider;
+            userInfo.ThirdAccountId = thirdAccount.Id;
+            await _snapshotUserInfoRepository.UpdateAsync(userInfo);
         }
         else
         {
-            var citizen = await _citizenRepository.Queryable().Where(m => m.PhoneNumber == thirdAccount.PhoneNumber).FirstAsync();
-            thirdAccount.UserId = citizen?.Id;
+            userInfo = new SnapshotUserInfo
+            {
+                ThirdAccountId = thirdAccount.Id,
+                PhoneNumber = thirdAccount.PhoneNumber,
+                CitizenType = EReadPackUserType.Citizen,
+            };
+            await _snapshotUserInfoRepository.AddAsync(userInfo);
         }
-        return await _thirdAccountRepository.AddAsync(thirdAccount);
     }
 }
 

File diff suppressed because it is too large
+ 0 - 0
src/Hotline.Application/Snapshot/ZiGongSnapshotApplication.cs


+ 0 - 23
src/Hotline.Repository.SqlSugar/Snapshot/GuiderInfoRepository.cs

@@ -1,23 +0,0 @@
-using Hotline.Repository.SqlSugar.DataPermissions;
-using Hotline.Snapshot;
-using Hotline.Snapshot.Interfaces;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using XF.Domain.Dependency;
-
-namespace Hotline.Repository.SqlSugar.Snapshot;
-public class GuiderInfoRepository : BaseRepository<GuiderInfo>, IGuiderInfoRepository, IScopeDependency
-{
-    public GuiderInfoRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
-    {
-    }
-
-    public async Task<GuiderInfo> GetByPhoneNumberAsync(string phoneNumber)
-    {
-        return await Queryable().Where(m => m.PhoneNumber == phoneNumber).FirstAsync();
-    }
-}

+ 16 - 2
src/Hotline.Repository.SqlSugar/Snapshot/SnapshotUserInfoRepository.cs

@@ -1,4 +1,7 @@
-using Hotline.Snapshot.Interfaces;
+using Hotline.Repository.SqlSugar.DataPermissions;
+using Hotline.Share.Tools;
+using Hotline.Snapshot;
+using Hotline.Snapshot.Interfaces;
 using Hotline.Snapshot;
 using System;
 using System.Collections.Generic;
@@ -10,10 +13,21 @@ using SqlSugar;
 using Hotline.Repository.SqlSugar.DataPermissions;
 
 namespace Hotline.Repository.SqlSugar.Snapshot;
+
 public class SnapshotUserInfoRepository : BaseRepository<SnapshotUserInfo>, ISnapshotUserInfoRepository, IScopeDependency
 {
     public SnapshotUserInfoRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
     {
     }
-}
 
+    public async Task<SnapshotUserInfo?> GetByPhoneNumberAsync(string? phoneNumber)
+    {
+        if (phoneNumber.IsNullOrEmpty()) return null;
+        return await Queryable().Where(m => m.PhoneNumber == phoneNumber).FirstAsync();
+    }
+
+    public async Task<SnapshotUserInfo> GetByThirdIdAsync(string id)
+    {
+        return await Queryable().Where(m => m.ThirdAccountId == id).FirstAsync();
+    }
+}

+ 5 - 0
src/Hotline.Repository.SqlSugar/Snapshot/VolunteerRepository.cs

@@ -24,6 +24,11 @@ public class VolunteerRepository : BaseRepository<Volunteer>, IVolunteerReposito
         return await Queryable().Where(m => m.PhoneNumber == phone.Trim()).FirstAsync();
     }
 
+    /// <summary>
+    /// 是否是志愿者
+    /// </summary>
+    /// <param name="phoneNumber"></param>
+    /// <returns></returns>
     public async Task<bool> IsVolunteerAsync(string? phoneNumber)
     {
         if (phoneNumber.IsNullOrEmpty()) return false;

+ 0 - 22
src/Hotline/Snapshot/GuiderInfo.cs

@@ -1,22 +0,0 @@
-using System.ComponentModel;
-using XF.Domain.Repository;
-
-namespace Hotline.Snapshot;
-
-/// <summary>
-/// 网格员信息
-/// 当网格系统回推信息时, 填入网格员信息
-/// </summary>
-[Description("网格员信息")]
-public class GuiderInfo : CreationSoftDeleteEntity
-{
-    /// <summary>
-    /// 姓名
-    /// </summary>
-    public string Name { get; set; }
-
-    /// <summary>
-    /// 手机号码
-    /// </summary>
-    public string PhoneNumber { get; set; }
-}

+ 0 - 13
src/Hotline/Snapshot/Interfaces/IGuiderInfoRepository.cs

@@ -1,13 +0,0 @@
-using Hotline.Share.Dtos.Snapshot;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using XF.Domain.Repository;
-
-namespace Hotline.Snapshot.Interfaces;
-public interface IGuiderInfoRepository : IRepository<GuiderInfo>
-{
-    Task<GuiderInfo> GetByPhoneNumberAsync(string phoneNumber);
-}

+ 13 - 0
src/Hotline/Snapshot/Interfaces/ISnapshotUserInfoRepository.cs

@@ -8,5 +8,18 @@ using XF.Domain.Repository;
 namespace Hotline.Snapshot.Interfaces;
 public interface ISnapshotUserInfoRepository : IRepository<SnapshotUserInfo>
 {
+    /// <summary>
+    /// 根据电话号码获取用户信息
+    /// </summary>
+    /// <param name="phoneNumber"></param>
+    /// <returns></returns>
+    Task<SnapshotUserInfo?> GetByPhoneNumberAsync(string? phoneNumber);
+
+    /// <summary>
+    /// 根据第三方账号Id获取用户信息
+    /// </summary>
+    /// <param name="id"></param>
+    /// <returns></returns>
+    Task<SnapshotUserInfo> GetByThirdIdAsync(string id);
 }
 

+ 26 - 3
src/Hotline/Snapshot/SnapshotUserInfo.cs

@@ -1,4 +1,5 @@
-using SqlSugar;
+using Hotline.Share.Enums.Snapshot;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -9,10 +10,12 @@ using XF.Domain.Repository;
 
 namespace Hotline.Snapshot;
 
+/// <summary>
+/// 网格员和普通随手拍人员信息
+/// </summary>
 [Description("随手拍用户信息")]
 public class SnapshotUserInfo : CreationSoftDeleteEntity
 {
-
     /// <summary>
     /// 用户自己填的邀请码
     /// </summary>
@@ -27,7 +30,27 @@ public class SnapshotUserInfo : CreationSoftDeleteEntity
 
     /// <summary>
     /// 第三方账号Id
+    /// <inheritdoc cref="Hotline.ThirdAccountDomainServices.ThirdAccount"/>
     /// </summary>
     [SugarColumn(ColumnDescription = "第三方账号Id")]
-    public string ThirdAccountId { get; set; }
+    public string? ThirdAccountId { get; set; }
+
+    /// <summary>
+    /// 用户类型
+    /// 注册时根据手机号码判断是否是 网格员
+    /// </summary>
+    [SugarColumn(ColumnDescription = "用户类型")]
+    public EReadPackUserType CitizenType { get; set; }
+
+    /// <summary>
+    /// 姓名
+    /// </summary>
+    [SugarColumn(ColumnDescription = "姓名")]
+    public string? Name { get; set; }
+
+    /// <summary>
+    /// 电话号码
+    /// </summary>
+    [SugarColumn(ColumnDescription = "电话号码")]
+    public string? PhoneNumber { get; set; }
 }

+ 27 - 1
src/Hotline/ThirdAccountDomainServices/Interfaces/IThirdAccountDomainService.cs

@@ -9,12 +9,38 @@ using System.Threading.Tasks;
 namespace Hotline.ThirdAccountDomainServices.Interfaces;
 public interface IThirdAccountDomainService
 {
-    Task<string> RegisterAsync(ThirdAccount account, CancellationToken token);
+    /// <summary>
+    /// 如何用户不存在,注册新的用户
+    /// </summary>
+    /// <param name="account"></param>
+    /// <param name="token"></param>
+    /// <returns></returns>
+    Task RegisterAsync(ThirdAccount account, CancellationToken token);
 
+    /// <summary>
+    /// 登录成功后添加到SessionContext中的参数
+    /// </summary>
+    /// <param name="account"></param>
+    /// <param name="claims"></param>
+    /// <param name="token"></param>
+    /// <returns></returns>
     Task<List<Claim>> GetClaimAsync(ThirdAccount account, List<Claim> claims, CancellationToken token);
 
+    /// <summary>
+    /// 登录成功后返回给前端的参数
+    /// </summary>
+    /// <param name="thirdAccount"></param>
+    /// <param name="dicOutData"></param>
+    /// <param name="cancel"></param>
+    /// <returns></returns>
     Task<Dictionary<string, object>> GetLoginOutDataAsync(ThirdAccount thirdAccount, Dictionary<string, object> dicOutData, CancellationToken cancel);
 
+    /// <summary>
+    /// 调用第三方接口需要的入参
+    /// </summary>
+    /// <param name="thirdDto"></param>
+    /// <param name="token"></param>
+    /// <returns></returns>
     Task<ThirdTokenDto> GetThirdParameterAsync(ThirdTokenDto thirdDto, CancellationToken token);
 }
 

+ 0 - 15
src/Hotline/ThirdAccountDomainServices/ThirdAccount.cs

@@ -15,21 +15,6 @@ namespace Hotline.ThirdAccountDomainServices;
 [Description("小程序账号信息")]
 public class ThirdAccount : CreationSoftDeleteEntity
 {
-    /// <summary>
-    /// 关联用户信息
-    /// 如果是市民: 关联 <inheritdoc cref="Citizen"/>
-    /// 如果是网格员: 关联 <inheritdoc cref="GuiderInfo"/>
-    /// </summary>
-    [SugarColumn(ColumnDescription = "关联用户信息")]
-    public string? UserId { get; set; }
-
-    /// <summary>
-    /// 用户类型
-    /// 注册时根据手机号码判断是否是 网格员
-    /// </summary>
-    [SugarColumn(ColumnDescription = "用户类型")]
-    public EReadPackUserType CitizenType { get; set; }
-
     /// <summary>
     /// 电话
     /// </summary>

+ 1 - 1
src/Hotline/ThirdAccountDomainServices/ThirdAccountDomainFactory.cs

@@ -35,7 +35,7 @@ public class ThirdAccountDomainFactory : IThirdAccountDomainService, ISelfDepend
     public async Task<ThirdTokenDto> GetThirdParameterAsync(ThirdTokenDto thirdDto, CancellationToken token)
         => await GetSupplier(thirdDto.AppType).GetThirdParameterAsync(thirdDto, token);
 
-    public async Task<string> RegisterAsync(ThirdAccount account, CancellationToken token)
+    public async Task RegisterAsync(ThirdAccount account, CancellationToken token)
         => await GetSupplier(account.AppType).RegisterAsync(account, token);
 }
 

+ 2 - 1
test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs

@@ -5,6 +5,7 @@ using Hotline.Identity.Roles;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Tools;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Mapster;
@@ -24,7 +25,7 @@ namespace Hotline.Tests.Application;
 public class BiSnapshotApplicationTest : TestBase
 {
     private readonly IBiSnapshotApplication _biSnapshotApplication;
-    public BiSnapshotApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData, IBiSnapshotApplication biSnapshotApplication) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData)
+    public BiSnapshotApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData, IBiSnapshotApplication biSnapshotApplication, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _biSnapshotApplication = biSnapshotApplication;
     }

+ 2 - 1
test/Hotline.Tests/Application/DefaultCallApplicationTest.cs

@@ -11,6 +11,7 @@ using Hotline.Settings;
 using Hotline.Share.Dtos.CallCenter;
 using Hotline.Share.Dtos.Order;
 using Hotline.Share.Enums.CallCenter;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -30,7 +31,7 @@ public class DefaultCallApplicationTest : TestBase
     private readonly IOrderRepository _orderRepository;
     private readonly ICallTelClient _callTelClient;
 
-    public DefaultCallApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, XingTangCallApplication defaultCallApplication, IOrderVisitRepository orderVisitRepository, IRepository<CallNative> callNativeRepository, IOrderRepository orderRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData, ICallTelClient callTelClient) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData)
+    public DefaultCallApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, XingTangCallApplication defaultCallApplication, IOrderVisitRepository orderVisitRepository, IRepository<CallNative> callNativeRepository, IOrderRepository orderRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData, ICallTelClient callTelClient, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _fixture = new Fixture();
         _defaultCallApplication = defaultCallApplication;

+ 2 - 1
test/Hotline.Tests/Application/IndustryApplicationTest.cs

@@ -16,6 +16,7 @@ using XF.Domain.Repository;
 using Hotline.Settings;
 using XF.Domain.Cache;
 using Hotline.ThirdAccountDomainServices.Interfaces;
+using Hotline.ThirdAccountDomainServices;
 
 namespace Hotline.Tests.Application;
 public class IndustryApplicationTest : TestBase
@@ -24,7 +25,7 @@ public class IndustryApplicationTest : TestBase
     private readonly IIndustryRepository _industryRepository;
     private readonly ISystemOrganizeRepository _systemOrganizeRepository;
 
-    public IndustryApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IIndustryApplication industryApplication, IIndustryRepository industryRepository, ISystemOrganizeRepository systemOrganizeRepository, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData)
+    public IndustryApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IIndustryApplication industryApplication, IIndustryRepository industryRepository, ISystemOrganizeRepository systemOrganizeRepository, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _industryApplication = industryApplication;
         _industryRepository = industryRepository;

+ 8 - 6
test/Hotline.Tests/Application/InviteCodeApplicationTest.cs

@@ -6,6 +6,7 @@ using Hotline.Repository.SqlSugar.Snapshot;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Snapshot.Interfaces;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -28,14 +29,16 @@ public class InviteCodeApplicationTest : TestBase
     private readonly IInviteCodeRepository _inviteCodeRepository;
     private readonly ISessionContext _sessionContext;
     private readonly IInviteCodeRecordRepository _inviteCodeRecordRepository;
+    private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
 
-    public InviteCodeApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IInviteCodeApplication inviteCodeApplication, ISnapshotApplication snapshotApplication, IInviteCodeRepository inviteCodeRepository, ISessionContext sessionContext, IInviteCodeRecordRepository inviteCodeRecordRepository, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData)
+    public InviteCodeApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IInviteCodeApplication inviteCodeApplication, ISnapshotApplication snapshotApplication, IInviteCodeRepository inviteCodeRepository, ISessionContext sessionContext, IInviteCodeRecordRepository inviteCodeRecordRepository, ITypedCache<SystemSetting> cacheSettingData, ISnapshotUserInfoRepository snapshotUserInfoRepository, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _inviteCodeApplication = inviteCodeApplication;
         _snapshotApplication = snapshotApplication;
         this._inviteCodeRepository = inviteCodeRepository;
         _sessionContext = sessionContext;
         _inviteCodeRecordRepository = inviteCodeRecordRepository;
+        _snapshotUserInfoRepository = snapshotUserInfoRepository;
     }
 
     [Fact]
@@ -55,12 +58,11 @@ public class InviteCodeApplicationTest : TestBase
         await _inviteCodeRepository.RemoveAsync(id);
 
         SetWeiXin();
-        throw new NotImplementedException("TotalAmount");
 
-        //await _thirdAccountRepository.Updateable()
-        //    .SetColumns(m => m.InvitationCode, null)
-        //    .Where(m => m.OpenId == _sessionContext.OpenId)
-        //    .ExecuteCommandAsync();
+        await _snapshotUserInfoRepository.Updateable()
+            .SetColumns(m => m.InvitationCode, null)
+            .Where(m => m.ThirdAccountId == _sessionContext.UserId)
+            .ExecuteCommandAsync();
         await _inviteCodeRecordRepository.Removeable().Where(m => m.InviteCode == "110").ExecuteCommandAsync();
         await _snapshotApplication.SaveInvitationCodeAsync(new SaveInvitationCodeInDto { InvitationCode = "110"});
 

+ 2 - 1
test/Hotline.Tests/Application/KnowApplicationTest.cs

@@ -7,6 +7,7 @@ using Hotline.KnowledgeBase.Notifies;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Knowledge;
 using Hotline.Share.Tools;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Mapster;
@@ -33,7 +34,7 @@ public class KnowApplicationTest : TestBase
     private readonly IRepository<KnowledgeWord> _knowledgeWordRepository;
     private readonly IRepository<KnowledgeHotWord> _knowledgeHotWordRepository;
 
-    public KnowApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IKnowApplication knowApplication, IMediator mediator, IRepository<KnowledgeBase.Knowledge> knowledgeRepository, IKnowledgeDomainService knowledgeDomainService, IRepository<KnowledgeWord> knowledgeWordRepository, IRepository<KnowledgeHotWord> knowledgeHotWordRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData)
+    public KnowApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IKnowApplication knowApplication, IMediator mediator, IRepository<KnowledgeBase.Knowledge> knowledgeRepository, IKnowledgeDomainService knowledgeDomainService, IRepository<KnowledgeWord> knowledgeWordRepository, IRepository<KnowledgeHotWord> knowledgeHotWordRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _knowApplication = knowApplication;
         _mediator = mediator;

+ 2 - 1
test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs

@@ -14,6 +14,7 @@ using Hotline.Share.Requests;
 using Hotline.Share.Tools;
 using Hotline.Snapshot.Interfaces;
 using Hotline.Tests.Mock;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -44,7 +45,7 @@ public class OrderSnapshotApplicationTest : TestBase
     private readonly IRedPackApplication _redPackApplication;
     private readonly IOrderRepository _orderRepository;
 
-    public OrderSnapshotApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, OrderServiceMock orderServiceMock, ISystemDicDataCacheManager systemDicDataCacheManager, IOrderSnapshotRepository orderSnapshotRepository, IOrderSnapshotApplication orderSnapshotApplication, ISnapshotApplication snapshotApplication, IIndustryLogRepository industryLogRepository, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, ISnapshotLabelLogRepository snapshotLabelLogRepository, ITypedCache<SystemSetting> cacheSettingData, IRedPackApplication redPackApplication, IOrderRepository orderRepository) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData)
+    public OrderSnapshotApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, OrderServiceMock orderServiceMock, ISystemDicDataCacheManager systemDicDataCacheManager, IOrderSnapshotRepository orderSnapshotRepository, IOrderSnapshotApplication orderSnapshotApplication, ISnapshotApplication snapshotApplication, IIndustryLogRepository industryLogRepository, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, ISnapshotLabelLogRepository snapshotLabelLogRepository, ITypedCache<SystemSetting> cacheSettingData, IRedPackApplication redPackApplication, IOrderRepository orderRepository, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _orderServiceMock = orderServiceMock;
         _systemDicDataCacheManager = systemDicDataCacheManager;

+ 2 - 1
test/Hotline.Tests/Application/RedPackApplicationTest.cs

@@ -10,6 +10,7 @@ using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Hotline.Tests.Mock;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -34,7 +35,7 @@ public class RedPackApplicationTest : TestBase
     private readonly IIndustryRepository _industryRepository;
     private readonly ISpecialRedPackAuditRepository _specialRedPackAuditRepository;
 
-    public RedPackApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IRedPackApplication redPackApplication, IRedPackRecordRepository redPackRecordRepository, ITypedCache<SystemSetting> cacheSettingData, OrderServiceMock orderServiceMock, ISystemDicDataCacheManager systemDicDataCacheManager, IIndustryRepository industryRepository, ISpecialRedPackAuditRepository specialRedPackAuditRepository) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData)
+    public RedPackApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IRedPackApplication redPackApplication, IRedPackRecordRepository redPackRecordRepository, ITypedCache<SystemSetting> cacheSettingData, OrderServiceMock orderServiceMock, ISystemDicDataCacheManager systemDicDataCacheManager, IIndustryRepository industryRepository, ISpecialRedPackAuditRepository specialRedPackAuditRepository, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _redPackApplication = redPackApplication;
         _redPackRecordRepository = redPackRecordRepository;

+ 14 - 12
test/Hotline.Tests/Application/SnapshotApplicationTest.cs

@@ -18,6 +18,7 @@ using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Hotline.Tests.Mock;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -47,8 +48,9 @@ public class SnapshotApplicationTest : TestBase
     private readonly IIndustryLogRepository _industryLogRepository;
     private readonly IRedPackApplication _redPackApplication;
     private readonly IOrderSnapshotApplication _orderSnapshotApplication;
+    private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
 
-    public SnapshotApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, ISnapshotApplication snapshotApplication, IIdentityAppService identityAppService, IRepository<RedPackRecord> redPackRecordRepository, IIndustryApplication industryApplication, IIndustryRepository industryRepository, IFileRepository fileRepository, OrderServiceMock orderServiceMock, IOrderRepository orderRepository, IOrderSnapshotRepository orderSnapshotRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ISessionContext sessionContext, IGuiderSystemService guiderSystemService, ISystemSettingCacheManager systemSettingCacheManager, ICommunityInfoRepository communityInfoRepository, IIndustryLogRepository industryLogRepository, IRedPackApplication redPackApplication, IOrderSnapshotApplication orderSnapshotApplication, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData)
+    public SnapshotApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, ISnapshotApplication snapshotApplication, IIdentityAppService identityAppService, IRepository<RedPackRecord> redPackRecordRepository, IIndustryApplication industryApplication, IIndustryRepository industryRepository, IFileRepository fileRepository, OrderServiceMock orderServiceMock, IOrderRepository orderRepository, IOrderSnapshotRepository orderSnapshotRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ISessionContext sessionContext, IGuiderSystemService guiderSystemService, ISystemSettingCacheManager systemSettingCacheManager, ICommunityInfoRepository communityInfoRepository, IIndustryLogRepository industryLogRepository, IRedPackApplication redPackApplication, IOrderSnapshotApplication orderSnapshotApplication, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory, ISnapshotUserInfoRepository snapshotUserInfoRepository) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _snapshotApplication = snapshotApplication;
         _identityAppService = identityAppService;
@@ -67,6 +69,7 @@ public class SnapshotApplicationTest : TestBase
         _industryLogRepository = industryLogRepository;
         _redPackApplication = redPackApplication;
         _orderSnapshotApplication = orderSnapshotApplication;
+        _snapshotUserInfoRepository = snapshotUserInfoRepository;
     }
 
     /// <summary>
@@ -248,7 +251,7 @@ public class SnapshotApplicationTest : TestBase
         var token = await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto(), CancellationToken.None);
         var newToken = await _identityAppService.RefreshTokenAsync(token["OpenId"].ToString(), CancellationToken.None);
         newToken.ShouldNotBeNull();
-        newToken["Token"].ShouldBe(token["Token"]);
+        newToken["OpenId"].ShouldBe(token["OpenId"].ToString());
         newToken["PhoneNumber"].ToString().ShouldNotBeNullOrEmpty();
     }
 
@@ -260,7 +263,7 @@ public class SnapshotApplicationTest : TestBase
     public async Task GetThirdToken_Test()
     {
         var result = await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto { LoginCode = "0c3Adhll2zDMBe413rnl2KvEym2AdhlH" }, CancellationToken.None);
-        var token = result["Token"];
+        result["PhoneNumber"].ToString().ShouldNotBeNullOrEmpty();
     }
 
     [Fact]
@@ -362,15 +365,14 @@ public class SnapshotApplicationTest : TestBase
         var code = new Random().Next(100, 200).ToString();
         try
         {
-            throw new NotImplementedException("TotalAmount");
-
-            //await _thirdAccountRepository.Updateable()
-            //    .SetColumns(m => m.InvitationCode, null)
-            //    .Where(m => m.OpenId == _sessionContext.OpenId)
-            //    .ExecuteCommandAsync();
-            //await _snapshotApplication.SaveInvitationCodeAsync(new SaveInvitationCodeInDto { InvitationCode = code });
-            //var third = await _thirdAccountRepository.GetByOpenIdAsync(_sessionContext.OpenId);
-            //third.InvitationCode.ShouldBe(code);
+            await _snapshotUserInfoRepository.Updateable()
+                .SetColumns(m => m.InvitationCode, null)
+                .Where(m => m.Id == _sessionContext.UserId)
+                .ExecuteCommandAsync();
+            await _snapshotApplication.SaveInvitationCodeAsync(new SaveInvitationCodeInDto { InvitationCode = code });
+            var userInfo = await _snapshotUserInfoRepository.GetAsync(_sessionContext.UserId);
+            userInfo.ShouldNotBeNull();
+            userInfo!.InvitationCode.ShouldBe(code);
         }
         catch (Exception e)
         {

+ 2 - 1
test/Hotline.Tests/Application/SystemSettingCacheManagerTest.cs

@@ -3,6 +3,7 @@ using Hotline.Caching.Interfaces;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;
 using Hotline.Settings;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -23,7 +24,7 @@ public class SystemSettingCacheManagerTest : TestBase
     private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
     private readonly IRepository<SystemSetting> _systemSettingRepository;
 
-    public SystemSettingCacheManagerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, ISystemSettingCacheManager systemSettingCacheManager, ISystemDicDataCacheManager systemDicDataCacheManager, IRepository<SystemSetting> systemSettingRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData)
+    public SystemSettingCacheManagerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, ISystemSettingCacheManager systemSettingCacheManager, ISystemDicDataCacheManager systemDicDataCacheManager, IRepository<SystemSetting> systemSettingRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _systemSettingCacheManager = systemSettingCacheManager;
         _systemDicDataCacheManager = systemDicDataCacheManager;

+ 2 - 1
test/Hotline.Tests/Controller/IndustryControllerTest.cs

@@ -3,6 +3,7 @@ using Hotline.Api.Controllers.Snapshot;
 using Hotline.Identity.Accounts;
 using Hotline.Identity.Roles;
 using Hotline.Settings;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -21,7 +22,7 @@ namespace Hotline.Tests.Controller;
 public class IndustryControllerTest : TestBase
 {
     private readonly IndustryController _industryController;
-    public IndustryControllerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IndustryController industryController, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData)
+    public IndustryControllerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, IndustryController industryController, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _industryController = industryController;
         _industryController.ControllerContext = new ControllerContext

+ 2 - 1
test/Hotline.Tests/Controller/KnowledgeControllerTest.cs

@@ -7,6 +7,7 @@ using Hotline.Share.Dtos.FlowEngine;
 using Hotline.Share.Dtos.Knowledge;
 using Hotline.Share.Enums.KnowledgeBase;
 using Hotline.Tests.Mock;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -28,7 +29,7 @@ public class KnowledgeControllerTest : TestBase
     private readonly KnowledgeController _knowledgeController;
     private readonly IRepository<KnowledgeBase.Knowledge> _knowledgeRepository;
 
-    public KnowledgeControllerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, KnowledgeServiceMock knowledgeServiceMock, KnowledgeController knowledgeController, IRepository<KnowledgeBase.Knowledge> knowledgeRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData)
+    public KnowledgeControllerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, KnowledgeServiceMock knowledgeServiceMock, KnowledgeController knowledgeController, IRepository<KnowledgeBase.Knowledge> knowledgeRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _knowledgeServiceMock = knowledgeServiceMock;
         _knowledgeController = knowledgeController;

+ 3 - 2
test/Hotline.Tests/Controller/OrderControllerTest.cs

@@ -43,6 +43,7 @@ using XF.Domain.Cache;
 using XF.Domain.Exceptions;
 using XF.Domain.Repository;
 using Hotline.ThirdAccountDomainServices.Interfaces;
+using Hotline.ThirdAccountDomainServices;
 
 namespace Hotline.Tests.Controller;
 
@@ -82,9 +83,9 @@ public class OrderControllerTest : TestBase
         ISystemLogRepository systemLogRepository, IOrderVisitDomainService orderVisitDomainService,
         IRepository<OrderVisitDetail> orderVisitDetailRepository, ISystemDicDataCacheManager systemDicDataCacheManager,
         IWorkflowDomainService workflowDomainService,
-        ITypedCache<SystemSetting> cacheSettingData)
+        ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory)
         : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount,
-            cacheSettingData)
+            cacheSettingData, thirdAccountDomainFactory)
     {
         _hotspotRepository = hotspotRepository;
         _orderController = orderController;

+ 2 - 1
test/Hotline.Tests/Controller/SnapshotControllerTest.cs

@@ -10,6 +10,7 @@ using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.Snapshot;
 using Hotline.Share.Tools;
 using Hotline.Snapshot.Interfaces;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Microsoft.AspNetCore.Http;
@@ -34,7 +35,7 @@ public class SnapshotControllerTest : TestBase
     private readonly IEasyCachingProvider _easyCaching;
     private readonly IRedisCachingProvider _redisCaching;
 
-    public SnapshotControllerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, SnapshotController snapshotController, IOrderRepository orderRepository, IOrderSnapshotRepository orderSnapshotRepository, IIndustryRepository industryRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, IEasyCachingProvider easyCaching, IRedisCachingProvider redisCaching, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData)
+    public SnapshotControllerTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, SnapshotController snapshotController, IOrderRepository orderRepository, IOrderSnapshotRepository orderSnapshotRepository, IIndustryRepository industryRepository, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, IEasyCachingProvider easyCaching, IRedisCachingProvider redisCaching, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _snapshotController = snapshotController;
         _snapshotController.ControllerContext = new ControllerContext

+ 1 - 0
test/Hotline.Tests/Controller/TestSessionContext.cs

@@ -16,6 +16,7 @@ public class TestSessionContext : ISessionContext, IScopeDependency
     {
         _contextAccessor = httpContextAccessor;
         _changeSessionProvider = serviceProvider.GetService<ISessionContextProvider>();
+        //_contextAccessor.HttpContext ??= new DefaultHttpContext();
         //if (httpContextAccessor.HttpContext == null) _contextAccessor.HttpContext = new DefaultHttpContext();
     }
 

+ 2 - 1
test/Hotline.Tests/Domain/OrderVisitDomainServiceTest.cs

@@ -14,6 +14,7 @@ using Hotline.Share.Enums.Order;
 using Hotline.Share.Enums.Push;
 using Hotline.Share.Tools;
 using Hotline.Tests.Mock;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using Mapster;
@@ -38,7 +39,7 @@ public class OrderVisitDomainServiceTest : TestBase
     private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
     private readonly ISystemLogRepository _logRepository;
 
-    public OrderVisitDomainServiceTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IOrderVisitDomainService orderVisitDomainService, IOrderVisitRepository orderVisitRepository, IRepository<OrderVisitDetail> orderVisitDetailRepository, Publisher publisher, IOrderRepository orderRepository, OrderServiceMock orderServiceMock, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ISettingOrderVisitSmsReplyRuleRepository settingOrderVisitSmsReplyRuleRepository, ISystemDicDataCacheManager systemDicDataCacheManager, IOptionsSnapshot<AppConfiguration> appOptions, ISystemLogRepository logRepository, ITypedCache<SystemSetting> cacheSettingData) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData)
+    public OrderVisitDomainServiceTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IOrderVisitDomainService orderVisitDomainService, IOrderVisitRepository orderVisitRepository, IRepository<OrderVisitDetail> orderVisitDetailRepository, Publisher publisher, IOrderRepository orderRepository, OrderServiceMock orderServiceMock, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdService, IThirdAccountRepository thirdAccount, ISettingOrderVisitSmsReplyRuleRepository settingOrderVisitSmsReplyRuleRepository, ISystemDicDataCacheManager systemDicDataCacheManager, IOptionsSnapshot<AppConfiguration> appOptions, ISystemLogRepository logRepository, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _orderVisitDomainService = orderVisitDomainService;
         _orderVisitRepository = orderVisitRepository;

+ 19 - 6
test/Hotline.Tests/TestBase.cs

@@ -6,8 +6,11 @@ using Hotline.Identity.Roles;
 using Hotline.Settings;
 using Hotline.Share.Dtos.Users;
 using Hotline.Share.Enums.Order;
+using Hotline.Share.Enums.ThirdAccount;
 using Hotline.Share.Enums.User;
+using Hotline.Snapshot.Interfaces;
 using Hotline.Tests.Infrastructure;
+using Hotline.ThirdAccountDomainServices;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Users;
 using IdentityModel;
@@ -31,8 +34,9 @@ public class TestBase
     public readonly IThirdIdentiyService _thirdIdentiyService;
     public readonly IThirdAccountRepository _thirdAccountRepository;
     private readonly ITypedCache<SystemSetting> _cacheSettingData;
+    public readonly ThirdAccountDomainFactory _thirdAccountDomainFactory;
 
-    public TestBase(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData)
+    public TestBase(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory)
     {
         _thirdAccountRepository = thirdAccountRepository;
         _thirdIdentiyService = thirdIdentiyService;
@@ -55,6 +59,7 @@ public class TestBase
         }
 
         _cacheSettingData = cacheSettingData;
+        _thirdAccountDomainFactory = thirdAccountDomainFactory;
     }
 
     public void SetSettingCache(string code, string value)
@@ -123,7 +128,7 @@ public class TestBase
     }
 
     public void Set政法委()
-    { 
+    {
         SetOperator("区县政法委", "自流井区人民政府/自流井区政法委", "单元测试政法委", "001055048", "13408389849", EUserType.Normal, TestSettingConstants.ZFWAccountName);
     }
 
@@ -134,7 +139,7 @@ public class TestBase
 
     public void SetWeiXin()
     {
-        SetOperator("微信用户", "", "", "", "138001389877", EUserType.Normal, TestSettingConstants.WeiXinAccountName);
+        SetOperator("微信用户", "", "", "", "138001389877", EUserType.Normal, TestSettingConstants.WeiXinAccountName, EThirdType.WeChat, EAppType.Snapshot);
     }
 
     public void Set网格员()
@@ -142,7 +147,7 @@ public class TestBase
         SetOperator("网格员", "市民热线服务中心", "单元测试网格员", "001", "13408389849", EUserType.Normal, TestSettingConstants.GuiderAccountName);
     }
 
-    private void SetOperator(string displayName, string fullOrgName, string name, string orgId, string phoneNo, EUserType userType, string userName)
+    private void SetOperator(string displayName, string fullOrgName, string name, string orgId, string phoneNo, EUserType userType, string userName, EThirdType? thirdType = null, EAppType? appType = null)
     {
         var account = _accountRepository.GetExtAsync(
             d => d.UserName == userName,
@@ -188,7 +193,6 @@ public class TestBase
         List<Claim> userClaims = [
             new(JwtClaimTypes.Subject, account.Id ?? thirdAccount.Id),
             new(JwtClaimTypes.PhoneNumber, account.PhoneNo ?? thirdAccount.PhoneNumber),
-            new(ClaimTypes.NameIdentifier, user.Id),
             new(AppClaimTypes.UserDisplayName, account.Name),
             new(AppClaimTypes.DepartmentId, user.OrgId ?? string.Empty),
             new(AppClaimTypes.DepartmentIsCenter, user.Organization?.IsCenter.ToString() ?? false.ToString()),
@@ -200,10 +204,19 @@ public class TestBase
             new(AppClaimTypes.OpenId, thirdAccount?.OpenId ?? string.Empty),
             new("AppScope", appScope)
         ];
+        if (appType != null && thirdType != null)
+        {
+            var claims = _thirdAccountDomainFactory.GetClaimAsync(new ThirdAccount { Id = thirdAccount.Id, PhoneNumber = phoneNo, AccountType = thirdType.Value, AppType = appType.Value }, new List<Claim>(), CancellationToken.None).GetAwaiter().GetResult();
+            userClaims.Add(new(ClaimTypes.NameIdentifier, claims.First().Value));
+        }
+        else
+        {
+            userClaims.Add(new(ClaimTypes.NameIdentifier, user.Id));
+        }
         userClaims.AddRange(account.Roles.Select(d => new Claim(JwtClaimTypes.Role, d.Name)));
         ClaimsIdentity identity = new ClaimsIdentity(userClaims);
         var principal = new ClaimsPrincipal(identity);
         _httpContextAccessor.HttpContext.User = principal;
-        
+
     }
 }

Some files were not shown because too many files changed in this diff