소스 검색

Merge branch 'test' into lib/test

libin 1 개월 전
부모
커밋
504c72a269
37개의 변경된 파일201개의 추가작업 그리고 116개의 파일을 삭제
  1. 1 1
      src/Hotline.Api/Controllers/Snapshot/RedPackController.cs
  2. 1 0
      src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs
  3. 6 5
      src/Hotline.Application/Identity/IdentityAppService.cs
  4. 4 0
      src/Hotline.Application/Mappers/MapperConfigs.cs
  5. 1 1
      src/Hotline.Application/Snapshot/IRedPackApplication.cs
  6. 9 6
      src/Hotline.Application/Snapshot/RedPackApplication.cs
  7. 7 4
      src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs
  8. 17 11
      src/Hotline.Application/Snapshot/SnapshotThirdAccountSupplier.cs
  9. 0 5
      src/Hotline.Repository.SqlSugar/Snapshot/SnapshotUserInfoRepository.cs
  10. 19 4
      src/Hotline.Repository.SqlSugar/Snapshot/ThirdAccountRepository.cs
  11. 5 0
      src/Hotline.Share/Dtos/Snapshot/OrderDto.cs
  12. 0 4
      src/Hotline/Hotline.csproj
  13. 0 7
      src/Hotline/Snapshot/Interfaces/ISnapshotUserInfoRepository.cs
  14. 15 0
      src/Hotline/Snapshot/OrderSnapshot.cs
  15. 0 7
      src/Hotline/Snapshot/SnapshotUserInfo.cs
  16. 1 33
      src/Hotline/ThirdAccountDomainServices/Interfaces/IThirdAccountDomainService.cs
  17. 4 2
      src/Hotline/ThirdAccountDomainServices/Interfaces/IThirdAccountRepository.cs
  18. 46 0
      src/Hotline/ThirdAccountDomainServices/Interfaces/IThirdAccountSupplier.cs
  19. 4 4
      src/Hotline/ThirdAccountDomainServices/ThirdAccounSupplierFactory.cs
  20. 6 0
      src/Hotline/ThirdAccountDomainServices/ThirdAccount.cs
  21. 28 0
      src/Hotline/ThirdAccountDomainServices/ThirdAccountDomainService.cs
  22. 1 1
      test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs
  23. 1 1
      test/Hotline.Tests/Application/DefaultCallApplicationTest.cs
  24. 1 1
      test/Hotline.Tests/Application/IndustryApplicationTest.cs
  25. 2 2
      test/Hotline.Tests/Application/InviteCodeApplicationTest.cs
  26. 1 1
      test/Hotline.Tests/Application/KnowApplicationTest.cs
  27. 1 1
      test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs
  28. 2 2
      test/Hotline.Tests/Application/RedPackApplicationTest.cs
  29. 4 2
      test/Hotline.Tests/Application/SnapshotApplicationTest.cs
  30. 1 1
      test/Hotline.Tests/Application/SystemSettingCacheManagerTest.cs
  31. 1 1
      test/Hotline.Tests/Controller/IndustryControllerTest.cs
  32. 1 1
      test/Hotline.Tests/Controller/KnowledgeControllerTest.cs
  33. 1 1
      test/Hotline.Tests/Controller/OrderControllerTest.cs
  34. 1 1
      test/Hotline.Tests/Controller/SnapshotControllerTest.cs
  35. 1 1
      test/Hotline.Tests/Domain/OrderVisitDomainServiceTest.cs
  36. 2 1
      test/Hotline.Tests/Mock/ThirdTestService.cs
  37. 6 4
      test/Hotline.Tests/TestBase.cs

+ 1 - 1
src/Hotline.Api/Controllers/Snapshot/RedPackController.cs

@@ -193,7 +193,7 @@ public class RedPackController : BaseController
     /// <returns></returns>
     [HttpPut("audit")]
     public async Task UpdateRedPackAuditAsync([FromBody] UpdateRedPackAuditInDto dto)
-        => await _redPackApplication.AuditRedPackAuditAsync(dto);
+        => await _redPackApplication.AuditRedPackAuditAsync(dto, HttpContext.RequestAborted);
 
     /// <summary>
     /// 获取审核短信模板

+ 1 - 0
src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs

@@ -119,6 +119,7 @@ public class SnapshotController : BaseController
         }
         var orderSnapshot = dto.Adapt<OrderSnapshot>();
         orderSnapshot.Id = order.Id;
+        orderSnapshot.SnapshotUserId = _sessionContext.UserId;
         orderSnapshot.IndustryId = dto.IndustryId;
         orderSnapshot.IndustryName = industry.Name;
         orderSnapshot.CompanyName = dto.CompanyName;

+ 6 - 5
src/Hotline.Application/Identity/IdentityAppService.cs

@@ -50,7 +50,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
     private readonly IThirdAccountRepository _thirdAccountRepository;
     private readonly ISystemLogRepository _systemLog;
     private readonly ThirdIdentiyFactory _thirdIdentiyFactory;
-    private readonly ThirdAccountDomainFactory _thirdAccountDomainFactory;
+    private readonly ThirdAccounSupplierFactory _thirdAccountDomainFactory;
 
     public IdentityAppService(
         IAccountRepository accountRepository,
@@ -66,7 +66,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
         IThirdAccountRepository thirdAccountRepository,
         ISystemLogRepository systemLog,
         ThirdIdentiyFactory thirdIdentiyFactory,
-        ThirdAccountDomainFactory thirdAccountDomainFactory)
+        ThirdAccounSupplierFactory thirdAccountDomainFactory)
     {
         _accountRepository = accountRepository;
         _accountDomainService = accountDomainService;
@@ -313,12 +313,13 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
         thirdDto = await _thirdAccountDomainFactory.GetThirdParameterAsync(thirdDto, token);
         var thirdToken = await _thirdIdentiyFactory.GetTokenAsync(thirdDto, token);
         var phone = await _thirdIdentiyFactory.GetPhoneNumberAsync(thirdDto, token);
-        var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(thirdToken.OpenId);
+        var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(thirdToken.OpenId, token);
 
         // 新用户注册
         if (thirdAccount is null)
         {
-            thirdAccount = thirdToken.Adapt<ThirdAccount>();
+            thirdAccount = dto.Adapt<ThirdAccount>();
+            thirdToken.Adapt(thirdAccount);
             thirdAccount.PhoneNumber = phone.PhoneNumber;
             thirdAccount.Id = await _thirdAccountRepository.AddAsync(thirdAccount);
             await _thirdAccountDomainFactory.RegisterAsync(thirdAccount, token);
@@ -329,7 +330,7 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
 
     public async Task<Dictionary<string, object>> RefreshTokenAsync(string openId, CancellationToken token)
     {
-        var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(openId)
+        var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(openId, token)
             ?? throw UserFriendlyException.SameMessage("未找到用户信息");
 
         return await GetJwtToken(thirdAccount, token);

+ 4 - 0
src/Hotline.Application/Mappers/MapperConfigs.cs

@@ -34,6 +34,10 @@ namespace Hotline.Application.Mappers
             //    ? null
             //    : src.ExecuteParam.ToJson().FromJson<Dictionary<string, object>>());
 
+            config.ForType<ThirdTokenInDto, ThirdAccount>()
+                .Map(d => d.AppType, x => x.AppType)
+                .Map(d => d.AccountType, x => x.ThirdType);
+                
             config.ForType<ExcelContent, Order>()
                 .Map(d => d.FirstVisitResult, x => x.VisitResult)
                 .IgnoreNullValues(true);

+ 1 - 1
src/Hotline.Application/Snapshot/IRedPackApplication.cs

@@ -15,7 +15,7 @@ public interface IRedPackApplication
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    Task AuditRedPackAuditAsync(UpdateRedPackAuditInDto dto);
+    Task AuditRedPackAuditAsync(UpdateRedPackAuditInDto dto, CancellationToken token);
 
     /// <summary>
     /// 网格员红包审核通过或拒绝

+ 9 - 6
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -48,8 +48,9 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     private readonly IPushDomainService _pushDomainService;
     private readonly ILogger<RedPackApplication> _logger;
     private readonly ISystemDicDataCacheManager _systemDic;
+    private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
 
-    public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, IRepository<OrderSpecial> orderSpecialRepository, ISessionContext sessionContext, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IThirdAccountRepository thirdAccountRepository, ISupplementRecordRepository supplementRecordRepository, IPushDomainService pushDomainService, ILogger<RedPackApplication> logger, ISpecialRedPackAuditRepository specialRedPackAuditRepository, ISystemDicDataCacheManager systemDic)
+    public RedPackApplication(IOrderSnapshotRepository orderSnapshotRepository, ISnapshotSMSTemplateRepository snapshotSMSTemplateRepository, IOrderRepository orderRepository, IIndustryRepository industryRepository, IRedPackAuditRepository redPackAuditRepository, IRedPackRecordRepository redPackRecordRepository, IRepository<OrderSpecial> orderSpecialRepository, ISessionContext sessionContext, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IThirdAccountRepository thirdAccountRepository, ISupplementRecordRepository supplementRecordRepository, IPushDomainService pushDomainService, ILogger<RedPackApplication> logger, ISpecialRedPackAuditRepository specialRedPackAuditRepository, ISystemDicDataCacheManager systemDic, ISnapshotUserInfoRepository snapshotUserInfoRepository)
     {
         _orderSnapshotRepository = orderSnapshotRepository;
         _snapshotSMSTemplateRepository = snapshotSMSTemplateRepository;
@@ -66,6 +67,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         _logger = logger;
         _specialRedPackAuditRepository = specialRedPackAuditRepository;
         _systemDic = systemDic;
+        _snapshotUserInfoRepository = snapshotUserInfoRepository;
     }
 
     /// <summary>
@@ -73,7 +75,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
     /// </summary>
     /// <param name="dto"></param>
     /// <returns></returns>
-    public async Task AuditRedPackAuditAsync(UpdateRedPackAuditInDto dto)
+    public async Task AuditRedPackAuditAsync(UpdateRedPackAuditInDto dto, CancellationToken token)
     {
         var status = ERedPackAuditStatus.Refuse;
         if (dto.Status == ESnapshotSMSStatus.Agree)
@@ -91,12 +93,13 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         redPackAudit.AuditOrgName = _sessionContext.OrgName;
         redPackAudit.ApprovedAmount = redPackAudit.ShouldAmount;
         var order = await _orderRepository.Queryable()
-            .Where(m => m.Id == redPackAudit.OrderId)
-            .Select(m => new { m.Id, m.No, m.FromName, m.FromPhone })
-            .FirstAsync() ?? throw UserFriendlyException.SameMessage("工单不存在");
+            .LeftJoin<OrderSnapshot>((order, snapshot) => order.Id == snapshot.Id)
+            .Where((order, snapshot) => order.Id == redPackAudit.OrderId)
+            .Select((order, snapshot) => new { order.Id, order.No, order.FromName, order.FromPhone , snapshot.SnapshotUserId})
+            .FirstAsync(token) ?? throw UserFriendlyException.SameMessage("工单不存在");
         if (status == ERedPackAuditStatus.Agree)
         {
-            var third = await _thirdAccountRepository.GetByPhoneNumberAsync(order.FromPhone);
+            var third = await _thirdAccountRepository.GetByExternalIdAsync(order.SnapshotUserId, token);
             var entity = new RedPackRecord
             {
                 OrderId = redPackAudit.OrderId,

+ 7 - 4
src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs

@@ -540,13 +540,12 @@ public abstract class SnapshotApplicationBase
         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 = thirdInfo.OpenId,
+            WXOpenId = _sessionContext.OpenId,
             PhoneNumber = userInfo.PhoneNumber,
             Name = userInfo.Name,
         };
@@ -674,9 +673,13 @@ public abstract class SnapshotApplicationBase
             PhoneNumber = guiderInfo.MemberMobile,
             CitizenType = EReadPackUserType.Guider
         };
-        var third = await _thirdAccountRepository.GetByPhoneNumberAsync(guiderInfo.MemberMobile);
-        entity.ThirdAccountId = third?.Id;
         entity.Id = await _snapshotUserInfoRepository.AddAsync(entity, cancellationToken);
+        var third = (await _thirdAccountRepository.GetByPhoneNumberAsync(guiderInfo.MemberMobile, cancellationToken))
+            .Where(m => m.ExternalId == null)
+            .ToList();
+
+        third.ForEach(m => m.ExternalId = entity.Id);
+        await _thirdAccountRepository.UpdateRangeAsync(third);
     }
 
     /// <summary>

+ 17 - 11
src/Hotline.Application/Snapshot/SnapshotThirdAccountSupplier.cs

@@ -1,9 +1,11 @@
 using Hotline.Caching.Interfaces;
 using Hotline.Orders;
 using Hotline.Repository.SqlSugar.Snapshot;
+using Hotline.Settings;
 using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums.Snapshot;
 using Hotline.Share.Enums.User;
+using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
 using Hotline.ThirdAccountDomainServices;
@@ -18,25 +20,29 @@ using System.Threading.Tasks;
 using XF.Domain.Dependency;
 
 namespace Hotline.Application.Snapshot;
-public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDependency
+public class SnapshotThirdAccountSupplier : IThirdAccountSupplier, IScopeDependency
 {
     private readonly IThirdAccountRepository _thirdAccountRepository;
+    private readonly IThirdAccountDomainService _thirdAccountDomainService;
     private readonly IVolunteerRepository _volunteerRepository;
     private readonly ISnapshotUserInfoRepository _snapshotUserInfoRepository;
     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;
         _volunteerRepository = volunteerRepository;
         _snapshotUserInfoRepository = snapshotUserInfoRepository;
         _systemSettingCacheManager = systemSettingCacheManager;
+        _systemLog = systemLog;
+        _thirdAccountDomainService = thirdAccountDomainService;
     }
 
     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);
             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)
     {
         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
             {
                 CitizenType = EReadPackUserType.Citizen,
-                ThirdAccountId = thirdAccount.Id,
                 Name = thirdAccount.UserName,
                 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("IsVolunteer", isVolunteer);
@@ -83,18 +89,18 @@ public class SnapshotThirdAccountSupplier : IThirdAccountDomainService, IScopeDe
         if (userInfo != null)
         {
             userInfo.CitizenType = EReadPackUserType.Guider;
-            userInfo.ThirdAccountId = thirdAccount.Id;
             await _snapshotUserInfoRepository.UpdateAsync(userInfo);
+            await _thirdAccountDomainService.UpdateExternalIdAsync(thirdAccount.Id, thirdAccount.ExternalId, userInfo.Id, token);
         }
         else
         {
             userInfo = new SnapshotUserInfo
             {
-                ThirdAccountId = thirdAccount.Id,
                 PhoneNumber = thirdAccount.PhoneNumber,
                 CitizenType = EReadPackUserType.Citizen,
             };
-            await _snapshotUserInfoRepository.AddAsync(userInfo);
+            userInfo.Id = await _snapshotUserInfoRepository.AddAsync(userInfo);
+            await _thirdAccountDomainService.UpdateExternalIdAsync(thirdAccount.Id, thirdAccount.ExternalId, userInfo.Id, token);
         }
     }
 }

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

@@ -25,9 +25,4 @@ public class SnapshotUserInfoRepository : BaseRepository<SnapshotUserInfo>, ISna
         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();
-    }
 }

+ 19 - 4
src/Hotline.Repository.SqlSugar/Snapshot/ThirdAccountRepository.cs

@@ -11,13 +11,28 @@ public class ThirdAccountRepository : BaseRepository<ThirdAccount>,  IThirdAccou
     {
     }
 
-    public async Task<ThirdAccount> GetByOpenIdAsync(string openId)
+    public async Task<ThirdAccount> GetByExternalIdAsync(string externalId, CancellationToken token)
+    {
+        return await Queryable()
+            .Where(m => m.ExternalId == externalId)
+            .FirstAsync(token);
+    }
+
+    public async Task<ThirdAccount> GetByOpenIdAsync(string openId, CancellationToken token)
         => await Queryable()
         .Where(p => p.OpenId == openId)
-        .FirstAsync();
+        .FirstAsync(token);
 
-    public async Task<ThirdAccount?> GetByPhoneNumberAsync(string phoneNumber)
+    public async Task<List<ThirdAccount>> GetByPhoneNumberAsync(string phoneNumber, CancellationToken token)
         => await Queryable()
         .Where(m => m.PhoneNumber == phoneNumber)
-        .FirstAsync();
+        .ToListAsync(token);
+
+    public async Task UpdateExternalIdAsync(string id, string externalId, CancellationToken token)
+    {
+        await Updateable()
+            .SetColumns(m => m.ExternalId, externalId)
+            .Where(m => m.Id == id)
+            .ExecuteCommandAsync(token);
+    }
 }

+ 5 - 0
src/Hotline.Share/Dtos/Snapshot/OrderDto.cs

@@ -178,6 +178,11 @@ public class AddSnapshotOrderInDto : Position
     /// </summary>
     public string CompanyName { get; set; }
 
+    /// <summary>
+    /// 扩展字段
+    /// </summary>
+    public string? Attach { get; set; }
+
     public string GetContent(EIndustryType industryType)
     {
         if (industryType == EIndustryType.Declare)

+ 0 - 4
src/Hotline/Hotline.csproj

@@ -24,8 +24,4 @@
     <ProjectReference Include="..\XF.Domain.Repository\XF.Domain.Repository.csproj" />
   </ItemGroup>
 
-  <ItemGroup>
-    <Folder Include="ThirdAccountDomainServices\Register\" />
-  </ItemGroup>
-
 </Project>

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

@@ -14,12 +14,5 @@ public interface ISnapshotUserInfoRepository : IRepository<SnapshotUserInfo>
     /// <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);
 }
 

+ 15 - 0
src/Hotline/Snapshot/OrderSnapshot.cs

@@ -14,6 +14,13 @@ namespace Hotline.Snapshot;
 [Description("工单表扩展")]
 public class OrderSnapshot : CreationSoftDeleteEntity
 {
+    /// <summary>
+    /// 上报用户的Id
+    /// <inheritdoc cref="SnapshotUserInfo"/>
+    /// </summary>
+    [SugarColumn(ColumnDescription = "上报用户的Id")]
+    public string? SnapshotUserId { get; set; }
+
     /// <summary>
     /// 行业Id
     /// <inheritdoc cref="Industry"/> 表的Id
@@ -386,4 +393,12 @@ public class OrderSnapshot : CreationSoftDeleteEntity
     [SugarColumn(ColumnDescription = "重办原因")]
     public string? SpecialReasonName { get; set; }
     #endregion
+
+    /// <summary>
+    /// 扩展字段
+    /// 如果别的系统希望通过界面收集某个字段, 然后我们系统不需要使用, 就可以放这里.
+    /// 第三方系统在获取我们系统工单时直接把这个字段数据返回即可
+    /// </summary>
+    [SugarColumn(ColumnDescription = "12345不使用的扩展字段,第三方系统使用")]
+    public string? Attach { get; set; }
 }

+ 0 - 7
src/Hotline/Snapshot/SnapshotUserInfo.cs

@@ -28,13 +28,6 @@ public class SnapshotUserInfo : CreationSoftDeleteEntity
     [SugarColumn(ColumnDescription = "历史已经领取金额总和(单位:元)")]
     public double TotalAmount { get; set; }
 
-    /// <summary>
-    /// 第三方账号Id
-    /// <inheritdoc cref="Hotline.ThirdAccountDomainServices.ThirdAccount"/>
-    /// </summary>
-    [SugarColumn(ColumnDescription = "第三方账号Id")]
-    public string? ThirdAccountId { get; set; }
-
     /// <summary>
     /// 用户类型
     /// 注册时根据手机号码判断是否是 网格员

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

@@ -9,38 +9,6 @@ using System.Threading.Tasks;
 namespace Hotline.ThirdAccountDomainServices.Interfaces;
 public interface IThirdAccountDomainService
 {
-    /// <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);
+    Task UpdateExternalIdAsync(string id,string oldExternalId, string externalId, CancellationToken token);
 }
 

+ 4 - 2
src/Hotline/ThirdAccountDomainServices/Interfaces/IThirdAccountRepository.cs

@@ -3,6 +3,8 @@
 namespace Hotline.ThirdAccountDomainServices.Interfaces;
 public interface IThirdAccountRepository : IRepository<ThirdAccount>
 {
-    Task<ThirdAccount> GetByOpenIdAsync(string openId);
-    Task<ThirdAccount?> GetByPhoneNumberAsync(string memberMobile);
+    Task<ThirdAccount> GetByExternalIdAsync(string externalId, CancellationToken token);
+    Task<ThirdAccount> GetByOpenIdAsync(string openId, CancellationToken token);
+    Task<List<ThirdAccount>> GetByPhoneNumberAsync(string memberMobile, CancellationToken token);
+    Task UpdateExternalIdAsync(string id, string externalId, CancellationToken token);
 }

+ 46 - 0
src/Hotline/ThirdAccountDomainServices/Interfaces/IThirdAccountSupplier.cs

@@ -0,0 +1,46 @@
+using Hotline.Share.Dtos.Snapshot;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Hotline.ThirdAccountDomainServices.Interfaces;
+
+public interface IThirdAccountSupplier
+{
+    /// <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);
+}

+ 4 - 4
src/Hotline/ThirdAccountDomainServices/ThirdAccountDomainFactory.cs → src/Hotline/ThirdAccountDomainServices/ThirdAccounSupplierFactory.cs

@@ -12,16 +12,16 @@ using System.Threading.Tasks;
 using XF.Domain.Dependency;
 
 namespace Hotline.ThirdAccountDomainServices;
-public class ThirdAccountDomainFactory : IThirdAccountDomainService, ISelfDependency, IScopeDependency
+public class ThirdAccounSupplierFactory : IThirdAccountSupplier, ISelfDependency, IScopeDependency
 {
-    private readonly IEnumerable<IThirdAccountDomainService> _serviceItems;
+    private readonly IEnumerable<IThirdAccountSupplier> _serviceItems;
 
-    public ThirdAccountDomainFactory(IEnumerable<IThirdAccountDomainService> serviceItems)
+    public ThirdAccounSupplierFactory(IEnumerable<IThirdAccountSupplier> serviceItems)
     {
         _serviceItems = serviceItems;
     }
 
-    public IThirdAccountDomainService GetSupplier(EAppType enumType)
+    public IThirdAccountSupplier GetSupplier(EAppType enumType)
         => _serviceItems
         .FirstOrDefault(supplier => supplier.GetType().Name.ToLower().StartsWith(enumType.ToString().ToLower()))
         ?? _serviceItems.First();

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

@@ -15,6 +15,12 @@ namespace Hotline.ThirdAccountDomainServices;
 [Description("小程序账号信息")]
 public class ThirdAccount : CreationSoftDeleteEntity
 {
+    /// <summary>
+    /// 外部业务唯一标识
+    /// </summary>
+    [SugarColumn(ColumnDescription = "外部业务唯一标识")]
+    public string? ExternalId { get; set; }
+
     /// <summary>
     /// 电话
     /// </summary>

+ 28 - 0
src/Hotline/ThirdAccountDomainServices/ThirdAccountDomainService.cs

@@ -0,0 +1,28 @@
+using Hotline.Settings;
+using Hotline.ThirdAccountDomainServices.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using XF.Domain.Dependency;
+
+namespace Hotline.ThirdAccountDomainServices;
+
+public class ThirdAccountDomainService : IThirdAccountDomainService, IScopeDependency
+{
+    private readonly ISystemLogRepository _systemLogRepository;
+    private readonly IThirdAccountRepository _thirdAccountRepository;
+
+    public ThirdAccountDomainService(ISystemLogRepository systemLogRepository, IThirdAccountRepository thirdAccountRepository)
+    {
+        _systemLogRepository = systemLogRepository;
+        _thirdAccountRepository = thirdAccountRepository;
+    }
+
+    public async Task UpdateExternalIdAsync(string id,string oldExternalId, string externalId, CancellationToken token)
+    {
+        _systemLogRepository.Add("更新thirdAccount.ExternalId", id, $"原{oldExternalId}, 更新 {externalId}", "GetLoginOutDataAsync", 1);
+        await _thirdAccountRepository.UpdateExternalIdAsync(id, externalId, token);
+    }
+}

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

@@ -25,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _biSnapshotApplication = biSnapshotApplication;
     }

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

@@ -31,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _fixture = new Fixture();
         _defaultCallApplication = defaultCallApplication;

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

@@ -25,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _industryApplication = industryApplication;
         _industryRepository = industryRepository;

+ 2 - 2
test/Hotline.Tests/Application/InviteCodeApplicationTest.cs

@@ -31,7 +31,7 @@ public class InviteCodeApplicationTest : TestBase
     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, ISnapshotUserInfoRepository snapshotUserInfoRepository, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _inviteCodeApplication = inviteCodeApplication;
         _snapshotApplication = snapshotApplication;
@@ -61,7 +61,7 @@ public class InviteCodeApplicationTest : TestBase
 
         await _snapshotUserInfoRepository.Updateable()
             .SetColumns(m => m.InvitationCode, null)
-            .Where(m => m.ThirdAccountId == _sessionContext.UserId)
+            .Where(m => m.Id == _sessionContext.UserId)
             .ExecuteCommandAsync();
         await _inviteCodeRecordRepository.Removeable().Where(m => m.InviteCode == "110").ExecuteCommandAsync();
         await _snapshotApplication.SaveInvitationCodeAsync(new SaveInvitationCodeInDto { InvitationCode = "110"});

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

@@ -34,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _knowApplication = knowApplication;
         _mediator = mediator;

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

@@ -45,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _orderServiceMock = orderServiceMock;
         _systemDicDataCacheManager = systemDicDataCacheManager;

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

@@ -35,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _redPackApplication = redPackApplication;
         _redPackRecordRepository = redPackRecordRepository;
@@ -120,7 +120,7 @@ public class RedPackApplicationTest : TestBase
             IsSendSms = true,
             RedPackAuditId = audit.Id,
         };
-        await _redPackApplication.AuditRedPackAuditAsync(inDto);
+        await _redPackApplication.AuditRedPackAuditAsync(inDto, CancellationToken.None);
         var suInDto = new UpdateRedPackRecordInDto
         {
             RedPackAuditId = audit.Id,

+ 4 - 2
test/Hotline.Tests/Application/SnapshotApplicationTest.cs

@@ -14,6 +14,8 @@ using Hotline.Share.Dtos.Snapshot;
 using Hotline.Share.Enums;
 using Hotline.Share.Enums.Order;
 using Hotline.Share.Enums.Snapshot;
+using Hotline.Share.Enums.ThirdAccount;
+using Hotline.Share.Enums.User;
 using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.Interfaces;
@@ -50,7 +52,7 @@ public class SnapshotApplicationTest : TestBase
     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, ThirdAccountDomainFactory thirdAccountDomainFactory, ISnapshotUserInfoRepository snapshotUserInfoRepository) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory, ISnapshotUserInfoRepository snapshotUserInfoRepository) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _snapshotApplication = snapshotApplication;
         _identityAppService = identityAppService;
@@ -262,7 +264,7 @@ public class SnapshotApplicationTest : TestBase
     [Fact]
     public async Task GetThirdToken_Test()
     {
-        var result = await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto { LoginCode = "0c3Adhll2zDMBe413rnl2KvEym2AdhlH" }, CancellationToken.None);
+        var result = await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto { AppType = EAppType.Snapshot, ThirdType = EThirdType.WeChat,   LoginCode = "0c3Adhll2zDMBe413rnl2KvEym2AdhlH" }, CancellationToken.None);
         result["PhoneNumber"].ToString().ShouldNotBeNullOrEmpty();
     }
 

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

@@ -24,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _systemSettingCacheManager = systemSettingCacheManager;
         _systemDicDataCacheManager = systemDicDataCacheManager;

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

@@ -22,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
     {
         _industryController = industryController;
         _industryController.ControllerContext = new ControllerContext

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

@@ -29,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _knowledgeServiceMock = knowledgeServiceMock;
         _knowledgeController = knowledgeController;

+ 1 - 1
test/Hotline.Tests/Controller/OrderControllerTest.cs

@@ -83,7 +83,7 @@ public class OrderControllerTest : TestBase
         ISystemLogRepository systemLogRepository, IOrderVisitDomainService orderVisitDomainService,
         IRepository<OrderVisitDetail> orderVisitDetailRepository, ISystemDicDataCacheManager systemDicDataCacheManager,
         IWorkflowDomainService workflowDomainService,
-        ITypedCache<SystemSetting> cacheSettingData, ThirdAccountDomainFactory thirdAccountDomainFactory)
+        ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory)
         : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount,
             cacheSettingData, thirdAccountDomainFactory)
     {

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

@@ -35,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _snapshotController = snapshotController;
         _snapshotController.ControllerContext = new ControllerContext

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

@@ -39,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, ThirdAccountDomainFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
+    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, ThirdAccounSupplierFactory thirdAccountDomainFactory) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory)
     {
         _orderVisitDomainService = orderVisitDomainService;
         _orderVisitRepository = orderVisitRepository;

+ 2 - 1
test/Hotline.Tests/Mock/ThirdTestService.cs

@@ -20,7 +20,8 @@ public class ThirdTestService : IThirdIdentiyService, IScopeDependency
         return new ThirdTokenOutDto
         {
             SessionKey = "sessionKeyfjdklsafjdskla",
-            OpenId = "测试生成的OpenId"
+            OpenId = "测试生成的OpenId",
+            UnIonId = "测试生成的UnionId",
         };
     }
 }

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

@@ -8,6 +8,7 @@ using Hotline.Share.Dtos.Users;
 using Hotline.Share.Enums.Order;
 using Hotline.Share.Enums.ThirdAccount;
 using Hotline.Share.Enums.User;
+using Hotline.Share.Tools;
 using Hotline.Snapshot.Interfaces;
 using Hotline.Tests.Infrastructure;
 using Hotline.ThirdAccountDomainServices;
@@ -34,9 +35,9 @@ public class TestBase
     public readonly IThirdIdentiyService _thirdIdentiyService;
     public readonly IThirdAccountRepository _thirdAccountRepository;
     private readonly ITypedCache<SystemSetting> _cacheSettingData;
-    public readonly ThirdAccountDomainFactory _thirdAccountDomainFactory;
+    public readonly ThirdAccounSupplierFactory _thirdAccountDomainFactory;
 
-    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)
+    public TestBase(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory)
     {
         _thirdAccountRepository = thirdAccountRepository;
         _thirdIdentiyService = thirdIdentiyService;
@@ -206,8 +207,9 @@ public class TestBase
         ];
         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));
+            var claims = _thirdAccountDomainFactory.GetClaimAsync(new ThirdAccount { Id = thirdAccount?.Id, PhoneNumber = phoneNo, AccountType = thirdType.Value, AppType = appType.Value, ExternalId = thirdAccount?.ExternalId }, new List<Claim>(), CancellationToken.None).GetAwaiter().GetResult();
+            if (claims.NotNullOrEmpty())
+                userClaims.Add(new(ClaimTypes.NameIdentifier, claims.First().Value));
         }
         else
         {