Selaa lähdekoodia

修复特殊红包审核金额显示错误

qinchaoyue 1 viikko sitten
vanhempi
commit
addea2471b
23 muutettua tiedostoa jossa 171 lisäystä ja 60 poistoa
  1. 9 2
      src/Hotline.Application/OrderApp/Handlers/SnapshotHandler/GuiderSystemTimeoutHandler.cs
  2. 1 1
      src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs
  3. 1 1
      test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs
  4. 1 1
      test/Hotline.Tests/Application/DefaultCallApplicationTest.cs
  5. 1 1
      test/Hotline.Tests/Application/IndustryApplicationTest.cs
  6. 1 1
      test/Hotline.Tests/Application/InviteCodeApplicationTest.cs
  7. 1 1
      test/Hotline.Tests/Application/KnowApplicationTest.cs
  8. 1 1
      test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs
  9. 1 1
      test/Hotline.Tests/Application/PointsRecordApplicationTest.cs
  10. 19 19
      test/Hotline.Tests/Application/RedPackApplicationTest.cs
  11. 1 1
      test/Hotline.Tests/Application/SnapshotApplicationTest.cs
  12. 1 1
      test/Hotline.Tests/Application/SystemSettingCacheManagerTest.cs
  13. 1 1
      test/Hotline.Tests/Controller/IndustryControllerTest.cs
  14. 1 1
      test/Hotline.Tests/Controller/KnowledgeControllerTest.cs
  15. 2 2
      test/Hotline.Tests/Controller/OrderControllerTest.cs
  16. 2 2
      test/Hotline.Tests/Controller/OrderDelayControllerTest.cs
  17. 1 1
      test/Hotline.Tests/Controller/SnapshotControllerTest.cs
  18. 0 17
      test/Hotline.Tests/Controller/TestSessionContext.cs
  19. 111 0
      test/Hotline.Tests/Controller/TestSessionContextManager.cs
  20. 1 1
      test/Hotline.Tests/Domain/OrderVisitDomainServiceTest.cs
  21. 1 1
      test/Hotline.Tests/Mock/OrderServiceMock.cs
  22. 2 0
      test/Hotline.Tests/Startup.cs
  23. 11 3
      test/Hotline.Tests/TestBase.cs

+ 9 - 2
src/Hotline.Application/OrderApp/Handlers/SnapshotHandler/GuiderSystemTimeoutHandler.cs

@@ -3,6 +3,7 @@ using Hotline.Settings;
 using Hotline.Share.Tools;
 using Hotline.Snapshot.Notifications;
 using MediatR;
+using XF.Domain.Authentications;
 
 namespace Hotline.Application.OrderApp.Handlers.SnapshotHandler
 {
@@ -14,16 +15,19 @@ namespace Hotline.Application.OrderApp.Handlers.SnapshotHandler
         private readonly ISystemSettingCacheManager _systemSettingCacheManager;
         private readonly IOrderApplication _orderApplication;
         private readonly ISystemLogRepository _systemLogRepository;
+        private readonly ISessionContext _sessionContext;
 
         public GuiderSystemTimeoutHandler(
             ISystemSettingCacheManager systemSettingCacheManager,
             IOrderApplication orderApplication
 ,
-            ISystemLogRepository systemLogRepository)
+            ISystemLogRepository systemLogRepository,
+            ISessionContext sessionContext)
         {
             _systemSettingCacheManager = systemSettingCacheManager;
             _orderApplication = orderApplication;
             _systemLogRepository = systemLogRepository;
+            _sessionContext = sessionContext;
         }
 
         /// <summary>Handles a notification</summary>
@@ -41,7 +45,10 @@ namespace Hotline.Application.OrderApp.Handlers.SnapshotHandler
             catch (Exception e)
             {
                 _systemLogRepository.Add("网格员超时未回复", notification.OrderId, "方法异常", status: 0, executeResult: e.ToJson());
-                throw;
+                if (e.Message.StartsWith("网格员节点已办理完"))
+                    return;
+                else
+                    throw;
             }
             _systemLogRepository.Add("网格员超时未回复", notification.OrderId, "收到事件", "", 1);
         }

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

@@ -660,7 +660,7 @@ public abstract class SnapshotApplicationBase
     public async Task GuiderSystemReplyDelayAsync(string orderId, CancellationToken cancellationToken)
     {
         var orderSnapshot = await _orderSnapshotRepository.GetAsync(orderId)
-            ?? throw new UserFriendlyException($"orderId:{orderId} order_snapshot {_mqConfiguration.Value.RabbitMq.VirtualHost} 不存在该数据");
+            ?? throw new UserFriendlyException($"orderId:{orderId} order_snapshot {_mqConfiguration?.Value?.RabbitMq?.VirtualHost} 不存在该数据");
         if (orderSnapshot.IsDeal != null && orderSnapshot.IsDeal == true)
             return;
         // 网格员未回复, 推送事件

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

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

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

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

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

@@ -32,7 +32,7 @@ public class InviteCodeApplicationTest : TestBase
     private readonly IInviteCodeRecordRepository _inviteCodeRecordRepository;
     private readonly ICitizenRepository _citizenRepository;
 
-    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, ThirdAccounSupplierFactory thirdAccountDomainFactory, ICitizenRepository citizenRepository) : 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, ThirdAccounSupplierFactory thirdAccountDomainFactory, ICitizenRepository citizenRepository, IServiceProvider serviceProvider) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
     {
         _inviteCodeApplication = inviteCodeApplication;
         _snapshotApplication = snapshotApplication;

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

@@ -40,7 +40,7 @@ public class KnowApplicationTest : TestBase
     private readonly IRepository<KnowledgeHotWord> _knowledgeHotWordRepository;
     private readonly IFileDomainService _fileDomainService;
 
-    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, IFileDomainService fileDomainService) : 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, IFileDomainService fileDomainService, IServiceProvider serviceProvider) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
     {
         _knowApplication = knowApplication;
         _mediator = mediator;

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

@@ -55,7 +55,7 @@ public class OrderSnapshotApplicationTest : TestBase
     private readonly IIndustryRepository _industryRepository;
     private readonly OrderController _orderController;
 
-    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, IIndustryCaseRepository industryCaseRepository, ISnapshotPointsRecordRepository pointsRecordRepository, IIndustryRepository industryRepository, OrderController orderController) : 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, IIndustryCaseRepository industryCaseRepository, ISnapshotPointsRecordRepository pointsRecordRepository, IIndustryRepository industryRepository, OrderController orderController, IServiceProvider serviceProvider) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
     {
         _orderServiceMock = orderServiceMock;
         _systemDicDataCacheManager = systemDicDataCacheManager;

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

@@ -24,7 +24,7 @@ public class PointsRecordApplicationTest : TestBase
 {
     private readonly ISnapshotPointsApplication _pointsRecordApplication;
     private readonly ISnapshotApplication _snapshotApplication;
-    public PointsRecordApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory, ISnapshotPointsApplication pointsRecordApplication, ISnapshotApplication snapshotApplication) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+    public PointsRecordApplicationTest(IAccountRepository accountRepository, IRepository<Role> roleRepository, UserController userController, IServiceScopeFactory scopeFactory, IRepository<User> userRepository, IHttpContextAccessor httpContextAccessor, IThirdIdentiyService thirdIdentiyService, IThirdAccountRepository thirdAccountRepository, ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory, ISnapshotPointsApplication pointsRecordApplication, ISnapshotApplication snapshotApplication, IServiceProvider serviceProvider) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
     {
         _pointsRecordApplication = pointsRecordApplication;
         _snapshotApplication = snapshotApplication;

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

@@ -37,7 +37,7 @@ public class RedPackApplicationTest : TestBase
     private readonly ISpecialRedPackAuditRepository _specialRedPackAuditRepository;
     private readonly ISnapshotPointsRecordRepository _pointsRecordRepository;
 
-    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, ISnapshotPointsRecordRepository pointsRecordRepository) : 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, ISnapshotPointsRecordRepository pointsRecordRepository, IServiceProvider serviceProvider) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService, thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
     {
         _redPackApplication = redPackApplication;
         _redPackRecordRepository = redPackRecordRepository;
@@ -80,26 +80,26 @@ public class RedPackApplicationTest : TestBase
                 items = await _redPackApplication.GetRedPackSpecialAuditItems(new SnapshotOrderAuditItemsInDto(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 2)).ToListAsync();
                 items.Where(m => m.No == order.No).Count().ShouldBe(0);
             })
-            //.部门审核特殊红包(Set应急管理局, 29)
-            //.StepHandle(async order =>
-            //{
-            //    var special = await _specialRedPackAuditRepository.Queryable().Where(m => m.OrderId == order.Id).FirstAsync();
-            //    special.ApprovedAmount.ShouldBe(29);
-            //    special.Status.ShouldBe(ERedPackAuditStatus.Agree);
-            //    special.AuditRemark.ShouldBe("红包审核通过");
-            //    var redPackAudit = await _redPackApplication.GetRedPackSpecialAuditBaseDataAsync(order.Id);
-            //    redPackAudit.AuditDetail.AuditId.ShouldNotBeNull();
-            //    redPackAudit.AuditDetail.AuditName.ShouldNotBeNull();
-            //    redPackAudit.AuditDetail.AuditOrgId.ShouldNotBeNull();
-            //    redPackAudit.AuditDetail.AuditOrgName.ShouldNotBeNull();
-            //    redPackAudit.AuditDetail.AuditRemark.ShouldNotBeNull("审核意见不能为空");
-            //    redPackAudit.AuditDetail.AuditRemark.ShouldBe("红包审核通过");
+            .部门审核特殊红包(Set应急管理局, 29)
+            .StepHandle(async order =>
+            {
+                var special = await _specialRedPackAuditRepository.Queryable().Where(m => m.OrderId == order.Id).FirstAsync();
+                special.ApprovedAmount.ShouldBe(29);
+                special.Status.ShouldBe(ERedPackAuditStatus.Agree);
+                special.AuditRemark.ShouldBe("红包审核通过");
+                var redPackAudit = await _redPackApplication.GetRedPackSpecialAuditBaseDataAsync(order.Id);
+                redPackAudit.AuditDetail.AuditId.ShouldNotBeNull();
+                redPackAudit.AuditDetail.AuditName.ShouldNotBeNull();
+                redPackAudit.AuditDetail.AuditOrgId.ShouldNotBeNull();
+                redPackAudit.AuditDetail.AuditOrgName.ShouldNotBeNull();
+                redPackAudit.AuditDetail.AuditRemark.ShouldNotBeNull("审核意见不能为空");
+                redPackAudit.AuditDetail.AuditRemark.ShouldBe("红包审核通过");
 
-            //    var items = await _redPackApplication.GetRedPackSpecialAuditItems(new SnapshotOrderAuditItemsInDto(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1)).ToListAsync();
-            //    items.Count.ShouldNotBe(0, $"工单No: {order.No}");
-            //})
+                var items = await _redPackApplication.GetRedPackSpecialAuditItems(new SnapshotOrderAuditItemsInDto(order.No, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 1)).FirstAsync();
+                items.ApprovedAmount.ShouldBe(29);
+            })
             .GetCreateResult();
-        order.Id.ShouldBeNull();
+        order.Id.ShouldNotBeNull();
     }
 
     /// <summary>

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

@@ -52,7 +52,7 @@ public class SnapshotApplicationTest : TestBase
     private readonly IOrderSnapshotApplication _orderSnapshotApplication;
     private readonly ICitizenRepository _citizenRepository;
 
-    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, ICitizenRepository citizenRepository) : 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, ICitizenRepository citizenRepository, IServiceProvider serviceProvider) : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
     {
         _snapshotApplication = snapshotApplication;
         _identityAppService = identityAppService;

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

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

@@ -83,9 +83,9 @@ public class OrderControllerTest : TestBase
         ISystemLogRepository systemLogRepository, IOrderVisitDomainService orderVisitDomainService,
         IRepository<OrderVisitDetail> orderVisitDetailRepository, ISystemDicDataCacheManager systemDicDataCacheManager,
         IWorkflowDomainService workflowDomainService,
-        ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory)
+        ITypedCache<SystemSetting> cacheSettingData, ThirdAccounSupplierFactory thirdAccountDomainFactory, IServiceProvider serviceProvider)
         : base(accountRepository, roleRepository, userController, scopeFactory, userRepository, httpContextAccessor, thirdService, thirdAccount,
-            cacheSettingData, thirdAccountDomainFactory)
+            cacheSettingData, thirdAccountDomainFactory, serviceProvider)
     {
         _hotspotRepository = hotspotRepository;
         _orderController = orderController;

+ 2 - 2
test/Hotline.Tests/Controller/OrderDelayControllerTest.cs

@@ -41,9 +41,9 @@ namespace Hotline.Tests.Controller
             IOrderDelayRepository orderDelayRepository,
             IOrderRepository orderRepository,
             IMapper mapper,
-            ITestOutputHelper testOutputHelper) : base(accountRepository, roleRepository,
+            ITestOutputHelper testOutputHelper, IServiceProvider serviceProvider) : base(accountRepository, roleRepository,
             userController, scopeFactory, userRepository, httpContextAccessor, thirdIdentiyService,
-            thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory)
+            thirdAccountRepository, cacheSettingData, thirdAccountDomainFactory, serviceProvider)
         {
             _orderController = orderController;
             _orderServiceMock = orderServiceMock;

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

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

@@ -16,23 +16,6 @@ public class TestSessionContext : ISessionContext, IScopeDependency
     {
         _contextAccessor = httpContextAccessor;
         _changeSessionProvider = serviceProvider.GetService<ISessionContextProvider>();
-        //_contextAccessor.HttpContext ??= new DefaultHttpContext();
-        //if (httpContextAccessor.HttpContext == null) _contextAccessor.HttpContext = new DefaultHttpContext();
-    }
-
-    public void ChangeSession(string id)
-    {
-        _contextAccessor.HttpContext = _changeSessionProvider.ChangeSessionByUserId(id, _contextAccessor.HttpContext);
-    }
-
-    public async Task ChangeSessionAsync(string userId, CancellationToken cancellation)
-    {
-        throw new NotImplementedException();
-    }
-
-    public void ChangeSession(string userId, string username, string orgId, string orgname, int orgLevel)
-    {
-        throw new NotImplementedException();
     }
 
     public string? OpenId { get { return _contextAccessor.HttpContext?.User.FindFirstValue(AppClaimTypes.OpenId); } init { } }

+ 111 - 0
test/Hotline.Tests/Controller/TestSessionContextManager.cs

@@ -0,0 +1,111 @@
+using Hotline.Authentications;
+using Hotline.Caching.Interfaces;
+using Hotline.Configurations;
+using Hotline.Identity.Accounts;
+using Hotline.Settings;
+using Hotline.Share.Tools;
+using IdentityModel;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Claims;
+using System.Text;
+using System.Threading.Tasks;
+using XF.Domain.Authentications;
+using XF.Domain.Dependency;
+using XF.Domain.Exceptions;
+using XF.Domain.Repository;
+
+namespace Hotline.Tests.Controller;
+
+public class TestSessionContextManager : ISessionContextManager, IScopeDependency
+{
+    private readonly IServiceProvider _serviceProvider;
+    private readonly ISystemSettingCacheManager _systemSettingCacheManager;
+
+    public TestSessionContextManager(
+        IServiceProvider serviceProvider,
+        ISystemSettingCacheManager systemSettingCacheManager)
+    {
+        _serviceProvider = serviceProvider;
+        _systemSettingCacheManager = systemSettingCacheManager;
+    }
+
+    public async Task ChangeSessionContextByUserIdAsync(string userId, CancellationToken cancellation)
+    {
+        var httpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
+        if (httpContextAccessor.HttpContext == null)
+            httpContextAccessor.HttpContext = new DefaultHttpContext()
+            {
+                RequestServices = _serviceProvider
+            };
+        var accountRepository = _serviceProvider.GetService<IRepository<Account>>();
+
+        var account = await accountRepository.Queryable()
+            .Includes(d => d.User, x => x.Organization)
+            .Includes(d => d.Roles)
+            .FirstAsync(d => d.Id == userId, cancellation);
+
+        List<Claim> userClaims =
+        [
+            new(JwtClaimTypes.Subject, account.Id),
+            new(JwtClaimTypes.PhoneNumber, account.PhoneNo ?? string.Empty),
+            new(ClaimTypes.NameIdentifier, account.Id),
+            new(AppClaimTypes.UserDisplayName, account.Name),
+            new(AppClaimTypes.DepartmentId, account.User?.OrgId ?? string.Empty),
+            new(AppClaimTypes.DepartmentIsCenter, account.User?.Organization?.IsCenter.ToString() ?? string.Empty),
+            new(AppClaimTypes.DepartmentName, account.User?.Organization?.Name ?? string.Empty),
+            new(AppClaimTypes.DepartmentAreaCode, account.User?.Organization?.AreaCode ?? string.Empty),
+            new(AppClaimTypes.DepartmentAreaName, account.User?.Organization?.AreaName ?? string.Empty),
+            new(AppClaimTypes.DepartmentLevel, account.User?.Organization?.Level.ToString() ?? string.Empty),
+            new(AppClaimTypes.AreaId, account.User?.OrgId?.GetHigherOrgId() ?? string.Empty),
+        ];
+        userClaims.AddRange(account.Roles.Select(d => new Claim(JwtClaimTypes.Role, d.Name)));
+        httpContextAccessor.HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity(userClaims));
+    }
+
+    /// <summary>
+    /// 依据source创建对应Session
+    /// </summary>
+    public void ChangeSessionContext(string source)
+    {
+        var setting = _systemSettingCacheManager.GetSetting(SettingConstants.CityBaseConfiguration)?.SettingValue[0];
+        var cityBase = setting.FromJson<CityBaseConfiguration>();
+        DefaultCityBaseConfiguration config = source switch
+        {
+            "province" => cityBase.CityProvinceAssign,
+            "110" => cityBase.PublicSecurity,
+            "yb-enterprise" => cityBase.CityEnterprise,
+            "zzpt" => cityBase.ComprehensiveTreatment,
+            _ => throw new ArgumentOutOfRangeException(nameof(source), source, null)
+        };
+
+        ChangeSession(config.UserId, config.UserName, config.OrgId, config.OrgName, config.OrgId.CalcOrgLevel());
+    }
+
+    #region private
+
+    private void ChangeSession(string userId, string username, string orgId, string orgname, int orgLevel)
+    {
+        var httpContextAccessor = _serviceProvider.GetRequiredService<IHttpContextAccessor>();
+        if (httpContextAccessor.HttpContext == null)
+            throw new UserFriendlyException("current httpContext is null");
+
+        List<Claim> userClaims =
+        [
+            new(JwtClaimTypes.Subject, userId),
+            new(ClaimTypes.NameIdentifier, userId),
+            new(AppClaimTypes.UserDisplayName, username),
+            new(AppClaimTypes.DepartmentId, orgId ?? string.Empty),
+            new(AppClaimTypes.DepartmentIsCenter, orgId?.IsCenter().ToString() ?? string.Empty),
+            new(AppClaimTypes.DepartmentName, orgname ?? string.Empty),
+            new(AppClaimTypes.DepartmentLevel, orgLevel.ToString() ?? string.Empty),
+            new(AppClaimTypes.AreaId, orgId?.GetHigherOrgId() ?? string.Empty),
+        ];
+        httpContextAccessor.HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity(userClaims));
+    }
+
+    #endregion
+}

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

+ 1 - 1
test/Hotline.Tests/Mock/OrderServiceMock.cs

@@ -646,7 +646,7 @@ public class OrderServiceMock
         var inDto = new UpdateRedPackSpecialAuditInDto
         {
             AuditTypeId = basedata.Id,
-            ApprovedAmount = double.Parse(basedata.DicDataName.Split('|')[1]),
+            ApprovedAmount = approvedAmount,
             RedPackAuditId = item.RedPackAuditId,
             Status = ERedPackAuditStatus.Agree,
             Opinion = "红包审核通过",

+ 2 - 0
test/Hotline.Tests/Startup.cs

@@ -54,6 +54,7 @@ using Hotline.Pdf;
 using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Snapshot.IRepository;
 using Hotline.WeChat;
+using Hotline.Tests.Controller;
 
 namespace Hotline.Tests;
 public class Startup
@@ -176,6 +177,7 @@ public class Startup
             services.AddScoped<PushMessageController>();
             services.AddHttpContextAccessor();
             services.AddScoped<ISessionContext, Controller.TestSessionContext>();
+            services.AddScoped<ISessionContextManager, TestSessionContextManager>();
             services.AddScoped<ISessionContextProvider, SessionContextProvider>();
             services.AddScoped<ICallApplication, XingTangCallApplication>();
             services.AddScoped<XingTangCallApplication>();

+ 11 - 3
test/Hotline.Tests/TestBase.cs

@@ -36,8 +36,9 @@ public class TestBase
     public readonly IThirdAccountRepository _thirdAccountRepository;
     private readonly ITypedCache<SystemSetting> _cacheSettingData;
     public readonly ThirdAccounSupplierFactory _thirdAccountDomainFactory;
+    public readonly IServiceProvider _serviceProvider;
 
-    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)
+    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, IServiceProvider serviceProvider)
     {
         _thirdAccountRepository = thirdAccountRepository;
         _thirdIdentiyService = thirdIdentiyService;
@@ -47,7 +48,10 @@ public class TestBase
         _userController = userController;
         _userController.ControllerContext = new ControllerContext
         {
-            HttpContext = new DefaultHttpContext()
+            HttpContext = new DefaultHttpContext
+            {
+                RequestServices = _serviceProvider
+            }
         };
         _scopeFactory = scopeFactory;
         _userRepository = userRepository;
@@ -55,12 +59,16 @@ public class TestBase
 
         if (httpContextAccessor.HttpContext is null)
         {
-            httpContextAccessor.HttpContext = new DefaultHttpContext();
+            httpContextAccessor.HttpContext = new DefaultHttpContext
+            {
+                RequestServices = _serviceProvider
+            };
             SetZuoXi();
         }
 
         _cacheSettingData = cacheSettingData;
         _thirdAccountDomainFactory = thirdAccountDomainFactory;
+        _serviceProvider = serviceProvider;
     }
 
     public void SetSettingCache(string code, string value)