Sfoglia il codice sorgente

Merge branch 'test' of http://110.188.24.182:10023/Fengwo/hotline into test

Dun.Jason 1 settimana fa
parent
commit
729831dafa
35 ha cambiato i file con 274 aggiunte e 87 eliminazioni
  1. 42 1
      src/Hotline.Api/Controllers/IPPbxController.cs
  2. 1 1
      src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs
  3. 1 0
      src/Hotline.Api/Hotline.Api.csproj
  4. 10 0
      src/Hotline.Api/config/appsettings.Test.json
  5. 9 2
      src/Hotline.Application/OrderApp/Handlers/SnapshotHandler/GuiderSystemTimeoutHandler.cs
  6. 1 0
      src/Hotline.Application/OrderApp/OrderApplication.cs
  7. 1 1
      src/Hotline.Application/Snapshot/Contracts/ISnapshotApplication.cs
  8. 2 0
      src/Hotline.Application/Snapshot/DefaultSnapshotApplication.cs
  9. 4 4
      src/Hotline.Application/Snapshot/RedPackApplication.cs
  10. 23 16
      src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs
  11. 2 0
      src/Hotline.Application/Snapshot/ZiGongSnapshotApplication.cs
  12. 11 0
      src/Hotline.Repository.SqlSugar/Snapshot/RedPackRecordRepository.cs
  13. 1 0
      src/Hotline/Snapshot/IRepository/IRedPackRecordRepository.cs
  14. 2 2
      src/Hotline/Snapshot/RedPackRecord.cs
  15. 1 1
      test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs
  16. 1 1
      test/Hotline.Tests/Application/DefaultCallApplicationTest.cs
  17. 1 1
      test/Hotline.Tests/Application/IndustryApplicationTest.cs
  18. 1 1
      test/Hotline.Tests/Application/InviteCodeApplicationTest.cs
  19. 1 1
      test/Hotline.Tests/Application/KnowApplicationTest.cs
  20. 1 1
      test/Hotline.Tests/Application/OrderSnapshotApplicationTest.cs
  21. 1 1
      test/Hotline.Tests/Application/PointsRecordApplicationTest.cs
  22. 20 20
      test/Hotline.Tests/Application/RedPackApplicationTest.cs
  23. 3 3
      test/Hotline.Tests/Application/SnapshotApplicationTest.cs
  24. 1 1
      test/Hotline.Tests/Application/SystemSettingCacheManagerTest.cs
  25. 1 1
      test/Hotline.Tests/Controller/IndustryControllerTest.cs
  26. 1 1
      test/Hotline.Tests/Controller/KnowledgeControllerTest.cs
  27. 2 2
      test/Hotline.Tests/Controller/OrderControllerTest.cs
  28. 2 2
      test/Hotline.Tests/Controller/OrderDelayControllerTest.cs
  29. 1 1
      test/Hotline.Tests/Controller/SnapshotControllerTest.cs
  30. 0 17
      test/Hotline.Tests/Controller/TestSessionContext.cs
  31. 111 0
      test/Hotline.Tests/Controller/TestSessionContextManager.cs
  32. 1 1
      test/Hotline.Tests/Domain/OrderVisitDomainServiceTest.cs
  33. 1 1
      test/Hotline.Tests/Mock/OrderServiceMock.cs
  34. 2 0
      test/Hotline.Tests/Startup.cs
  35. 11 3
      test/Hotline.Tests/TestBase.cs

+ 42 - 1
src/Hotline.Api/Controllers/IPPbxController.cs

@@ -21,6 +21,7 @@ using Hotline.Share.Dtos.Quality;
 using Hotline.Share.Dtos.TrCallCenter;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Share.Enums.Quality;
+using Hotline.Share.Requests;
 using Hotline.Tools;
 using Hotline.Users;
 using Mapster;
@@ -682,7 +683,7 @@ namespace Hotline.Api.Controllers
             {
                 //await _iPPbxApplication.ResetTelStatus(null, dto.TelNo, CancellationToken.None);
             }
-           // dto.Status = await _callTelClient.GetStatusAsync(dto.Status);
+            dto.Status = await _callTelClient.GetStatusAsync(dto.Status);
             //await _callApplication.EndActionAsync(dto.Adapt<EndActionInDto>());
             TelOperation telOperation = new TelOperation
             {
@@ -936,6 +937,46 @@ namespace Hotline.Api.Controllers
             return new PagedDto<TelActionListRep>(total, _mapper.Map<IReadOnlyList<TelActionListRep>>(items));
         }
 
+        /// <summary>
+        /// 坐席动作列表导出
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost("telaction-list/export")]
+        [LogFilterAlpha("导出日志")]
+        public async Task<FileStreamResult> TelActionListExport([FromBody] ExportExcelDto<TelActionListDto> dto)
+        {
+            var total = 0;
+            var items = new List<TelActionRecord>();
+
+            var query = _telActionRecordRepository.Queryable()
+                .WhereIF(string.IsNullOrEmpty(dto.QueryDto.TelNo) == false, x => x.TelNo.Contains(dto.QueryDto.TelNo))
+                .WhereIF(dto.QueryDto.ActionTtype != null, x => x.ActionType == dto.QueryDto.ActionTtype)
+                .WhereIF(string.IsNullOrEmpty(dto.QueryDto.UserName) == false, x => x.UserName.Contains(dto.QueryDto.UserName))
+                .WhereIF(dto.QueryDto.StartTime.HasValue, x => x.CreationTime >= dto.QueryDto.StartTime)
+                .WhereIF(dto.QueryDto.EndTime.HasValue, x => x.CreationTime <= dto.QueryDto.EndTime)
+                .OrderByDescending(x => x.CreationTime);
+
+            if (dto.IsExportAll)
+            {
+                items = await query.ToListAsync();
+            }
+            else
+            {
+                (total, items) = await query.ToPagedListAsync(dto.QueryDto.PageIndex, dto.QueryDto.PageSize);
+            }
+
+            dynamic? dynamicClass = DynamicClassHelper.CreateDynamicClass<TelActionListRep>(dto.ColumnInfos);
+
+            var dtos = _mapper.Map<ICollection<TelActionListRep>>(items)
+                              .Select(stu => _mapper.Map(stu, typeof(TelActionListRep), dynamicClass))
+                              .Cast<object>()
+                              .ToList();
+
+            var stream = ExcelHelper.CreateStream(dtos);
+            return ExcelStreamResult(stream, "坐席动作列表");
+        }
+
         /// <summary>
         /// 坐席动作列表基础数据
         /// </summary>

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

@@ -219,7 +219,7 @@ public class SnapshotController : BaseController
     [AllowAnonymous]
     [HttpGet("user")]
     public async Task<SnapshotUserInfoOutDto> GetUserInfo()
-        => await _snapshotApplication.GetSnapshotUserInfoAsync();
+        => await _snapshotApplication.GetSnapshotUserInfoAsync(HttpContext.RequestAborted);
 
     /// <summary>
     /// 获取我提交的线索列表

+ 1 - 0
src/Hotline.Api/Hotline.Api.csproj

@@ -26,6 +26,7 @@
   </ItemGroup>
 
   <ItemGroup>
+    <ProjectReference Include="..\Hotline.Ai.Jths\Hotline.Ai.Jths.csproj" />
     <ProjectReference Include="..\Hotline.Application\Hotline.Application.csproj" />
     <ProjectReference Include="..\Hotline.WeChat\Hotline.WeChat.csproj" />
     <ProjectReference Include="..\Hotline.XingTang\Hotline.XingTang.csproj" />

+ 10 - 0
src/Hotline.Api/config/appsettings.Test.json

@@ -9,6 +9,16 @@
         "Password": "fengwo123!$!$",
         "Database": 2 //hotline:3, dev:5, test:2, demo:4
     },
+    "MqConfiguration": {
+        "DbConnectionString": "PORT=5432;DATABASE=fwmq;HOST=110.188.24.182;PASSWORD=fengwo11!!;USER ID=dev;",
+        "UseDashBoard": true,
+        "RabbitMq": {
+            "UserName": "dev",
+            "Password": "123456",
+            "HostName": "110.188.24.182",
+            "VirtualHost": "fwt-test"
+        }
+    },
     "SenparcWeixinSetting": {
         "IsDebug": true,
 

+ 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 - 0
src/Hotline.Application/OrderApp/OrderApplication.cs

@@ -3748,6 +3748,7 @@ public class OrderApplication : IOrderApplication, IScopeDependency
         query = query
                 .WhereIF(!string.IsNullOrEmpty(dto.PoliticalIdentityValue), d => d.PoliticalIdentityValue == dto.PoliticalIdentityValue)//政治身份查询
                 .WhereIF(!string.IsNullOrEmpty(dto.Keyword), d => d.Title.Contains(dto.Keyword!)) //标题
+                .WhereIF(!string.IsNullOrEmpty(dto.Title), d => d.Title.Contains(dto.Title!)) //标题
                 .WhereIF(!string.IsNullOrEmpty(dto.ProvinceNo), d => d.ProvinceNo.Contains(dto.ProvinceNo)) //省本地编号
                 .WhereIF(!string.IsNullOrEmpty(dto.ReceiveProvinceNo), d => d.ReceiveProvinceNo.Contains(dto.ReceiveProvinceNo)) //省编号
                 .WhereIF(dto.IsSecret.HasValue, d => d.IsSecret == dto.IsSecret.Value)

+ 1 - 1
src/Hotline.Application/Snapshot/Contracts/ISnapshotApplication.cs

@@ -10,7 +10,7 @@ public interface ISnapshotApplication
     /// 获取用户首页数据
     /// </summary>
     /// <returns></returns>
-    Task<SnapshotUserInfoOutDto> GetSnapshotUserInfoAsync();
+    Task<SnapshotUserInfoOutDto> GetSnapshotUserInfoAsync(CancellationToken token);
 
     /// <summary>
     /// 获取小程序首页数据

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


+ 4 - 4
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -322,10 +322,10 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
                             IsDanger = snapshot.IsDanger,
                             FromPhone = order.FromPhone,
                             FromName = order.FromName,
-                            AuditTime = redPackAudit.AuditTime,
-                            ApprovedAmount = redPackAudit.ApprovedAmount,
-                            AcutalAmount = redPackAudit.AcutalAmount,
-                            IsIssued = redPackAudit.IsSend,
+                            AuditTime = dto.Status == 0 ? redPackAudit.AuditTime : special.AuditTime,
+                            ApprovedAmount = dto.Status == 0 ? redPackAudit.ApprovedAmount : special.ApprovedAmount,
+                            AcutalAmount = dto.Status == 0 ? redPackAudit.AcutalAmount : special.AcutalAmount,
+                            IsIssued = dto.Status == 0 ? redPackAudit.IsSend : special.IsSend,
                             //RecordRemark = record.Remark,
                             County = order.County,
                             // IsRectify = s.IsRepetition

+ 23 - 16
src/Hotline.Application/Snapshot/SnapshotApplicationBase.cs

@@ -37,6 +37,10 @@ using Hotline.ThirdAccountDomainServices.Interfaces;
 using Hotline.Snapshot.IRepository;
 using Hotline.Share.Enums.CallCenter;
 using Hotline.Repository.SqlSugar.Snapshot;
+using Hotline.Settings.Hotspots;
+using Microsoft.Extensions.Options;
+using XF.Utility.MQ;
+using System.Threading;
 
 namespace Hotline.Application.Snapshot;
 
@@ -55,7 +59,7 @@ public abstract class SnapshotApplicationBase
     private readonly IIndustryRepository _industryRepository;
     private readonly IThirdIdentiyService _thirdLoginService;
     private readonly ISessionContext _sessionContext;
-    private readonly IRepository<RedPackRecord> _redPackRecordRepository;
+    private readonly IRedPackRecordRepository _redPackRecordRepository;
     private readonly IOrderSnapshotRepository _orderSnapshotRepository;
     private readonly ISystemSettingCacheManager _sysSetting;
     private readonly ISystemAreaDomainService _systemAreaDomainService;
@@ -81,8 +85,9 @@ public abstract class SnapshotApplicationBase
     private readonly IInviteCodeRepository _inviteCodeRepository;
     private readonly ICitizenRepository _citizenRepository;
     private readonly ISnapshotPointsRecordRepository _pointsRecordRepository;
+    private readonly IOptionsSnapshot<MqConfiguration> _mqConfiguration;
 
-    public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IIndustryRepository industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRepository<RedPackRecord> redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IOrderSnapshotRepository orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, ISystemLogRepository systemLog, IGuiderSystemService guiderSystemService, ICapPublisher capPublisher, Publisher publisher, IFileDomainService fileDomainService, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IOrderVisitRepository orderVisitRepository, IOrderVisitDetailRepository orderVisitDetailRepository, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IInviteCodeRecordRepository inviteCodeRecordRepository, IInviteCodeRepository inviteCodeRepository, ICitizenRepository citizenRepository, ISnapshotPointsRecordRepository snapshotPointsRecordRepository)
+    public SnapshotApplicationBase(IThirdIdentiyService thirdLoginService, IIndustryRepository industryRepository, ISnapshotBulletinRepository bulletinRepository, ISessionContext sessionContext, IRedPackRecordRepository redPackRecordRepository, IRepository<Order> orderRepository, IThirdAccountRepository thirdAccountRepository, IOrderSnapshotRepository orderSnapshotRepository, ISystemSettingCacheManager systemSettingCacheManager, ISystemAreaDomainService systemAreaDomainService, IFileRepository fileRepository, ISystemDicDataCacheManager systemDicDataCacheManager, ISnapshotOrderPublishRepository snapshotOrderPublishRepository, IRepository<WorkflowTrace> workflowTraceRepository, IPractitionerRepository practitionerRepository, IRepository<SystemArea> systemAreaRepository, IVolunteerRepository volunteerRepository, IVolunteerReportRepository volunteerReportRepository, ISystemLogRepository systemLog, IGuiderSystemService guiderSystemService, ICapPublisher capPublisher, Publisher publisher, IFileDomainService fileDomainService, ICommunityInfoRepository communityInfoRepository, IRedPackAuditRepository redPackAuditRepository, IOrderVisitRepository orderVisitRepository, IOrderVisitDetailRepository orderVisitDetailRepository, IRedPackGuiderAuditRepository redPackGuiderAuditRepository, IInviteCodeRecordRepository inviteCodeRecordRepository, IInviteCodeRepository inviteCodeRepository, ICitizenRepository citizenRepository, ISnapshotPointsRecordRepository snapshotPointsRecordRepository, IOptionsSnapshot<MqConfiguration> mqConfiguration)
     {
         _thirdLoginService = thirdLoginService;
         _industryRepository = industryRepository;
@@ -116,6 +121,7 @@ public abstract class SnapshotApplicationBase
         _inviteCodeRepository = inviteCodeRepository;
         _citizenRepository = citizenRepository;
         _pointsRecordRepository = snapshotPointsRecordRepository;
+        _mqConfiguration = mqConfiguration;
     }
 
     #region 小程序
@@ -300,16 +306,19 @@ public abstract class SnapshotApplicationBase
     /// 获取个人中心数据
     /// </summary>
     /// <returns></returns>
-    public async Task<SnapshotUserInfoOutDto> GetSnapshotUserInfoAsync()
+    public async Task<SnapshotUserInfoOutDto> GetSnapshotUserInfoAsync(CancellationToken token)
     {
         var userInfo = await _citizenRepository.GetAsync(_sessionContext.UserId);
 
         var dayTime = DateTime.Now;
-        var readPack = await _redPackRecordRepository.Queryable()
+        var query = _redPackRecordRepository.Queryable()
             .Where(m => m.WXOpenId == _sessionContext.OpenId && m.PickupStatus == ERedPackPickupStatus.Received)
             .Where(m => m.CreationTime.Date == dayTime.Date)
-            .Select(m => SqlFunc.AggregateSum(m.Amount))
-            .FirstAsync();
+            .Select(m => SqlFunc.AggregateSum(m.Amount));
+#if DEBUG
+        var sql = query.ToSqlString();
+#endif
+        var redPack = await query.FirstAsync(token);
 
         var outDto = await _orderRepository.Queryable()
             .Where(m => m.Contact == userInfo.PhoneNumber && m.CreatorId == _sessionContext.UserId)
@@ -318,10 +327,10 @@ public abstract class SnapshotApplicationBase
                 NoReplyCount = SqlFunc.AggregateSum(SqlFunc.IIF(m.Status < EOrderStatus.Filed, 1, 0)),
                 ReplyCount = SqlFunc.AggregateSum(SqlFunc.IIF(m.Status >= EOrderStatus.Filed, 1, 0)),
                 AppraiseCount = SqlFunc.AggregateSum(SqlFunc.IIF(m.Status == EOrderStatus.Visited, 1, 0)),
-            }).FirstAsync();
+            }).FirstAsync(token);
 
-        outDto.DayAmount = readPack;
-        outDto.TotalAmount = userInfo.TotalAmount ?? 0;
+        outDto.DayAmount = redPack;
+        outDto.TotalAmount = await _redPackRecordRepository.GetReceivedTotalAmountAsync(_sessionContext.OpenId, token);
         outDto.PhoneNumber = userInfo.PhoneNumber;
         return outDto;
     }
@@ -479,9 +488,11 @@ public abstract class SnapshotApplicationBase
     public async Task<IList<RedPackOutDto>> GetRedPacksAsync(RedPacksInDto dto, CancellationToken cancellationToken)
     {
         var items = await _redPackRecordRepository.Queryable(includeDeleted: true)
+            .LeftJoin<Order>((m , order) => m.OrderId == order.Id)
             .Where(m => m.IsDeleted == false)
             .Where(m => m.WXOpenId == _sessionContext.OpenId)
-            .Where(m => m.PickupStatus == dto.Status)
+            .WhereIF(dto.Status == ERedPackPickupStatus.Unreceived, (m, order) => m.PickupStatus == dto.Status && (order.HotspotId == null || order.HotspotId.StartsWith("18") == false))
+            .WhereIF(dto.Status != ERedPackPickupStatus.Unreceived, (m, order) => m.PickupStatus == dto.Status)
             .Where(m => m.CreationTime.ToString("yyyy-MM") == dto.Time)
             .LeftJoin<Order>((red, order) => red.OrderId == order.Id)
             .Select((red, order) => new RedPackOutDto
@@ -503,11 +514,7 @@ public abstract class SnapshotApplicationBase
     /// <returns></returns>
     public async Task<string> GetRedPackReceivedTotalAsync(CancellationToken cancellationToken)
     {
-        var totalAmount = await _redPackRecordRepository.Queryable()
-            .Where(m => m.WXOpenId == _sessionContext.OpenId && m.PickupStatus == ERedPackPickupStatus.Received)
-            .Select(m => SqlFunc.AggregateSum(m.Amount))
-            .FirstAsync(cancellationToken);
-        return totalAmount.ToYuanFinance();
+        return (await _redPackRecordRepository.GetReceivedTotalAmountAsync(_sessionContext.OpenId, cancellationToken)).ToYuanFinance();
     }
 
     /// <summary>
@@ -653,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 不存在该数据");
+            ?? throw new UserFriendlyException($"orderId:{orderId} order_snapshot {_mqConfiguration?.Value?.RabbitMq?.VirtualHost} 不存在该数据");
         if (orderSnapshot.IsDeal != null && orderSnapshot.IsDeal == true)
             return;
         // 网格员未回复, 推送事件

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


+ 11 - 0
src/Hotline.Repository.SqlSugar/Snapshot/RedPackRecordRepository.cs

@@ -1,4 +1,6 @@
 using Hotline.Repository.SqlSugar.DataPermissions;
+using Hotline.Share.Enums.Snapshot;
+using Hotline.Share.Tools;
 using Hotline.Snapshot;
 using Hotline.Snapshot.IRepository;
 using SqlSugar;
@@ -15,5 +17,14 @@ public class RedPackRecordRepository : BaseRepository<RedPackRecord>, IRedPackRe
     public RedPackRecordRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
     {
     }
+
+    public async Task<double> GetReceivedTotalAmountAsync(string? openId, CancellationToken cancellationToken)
+    {
+        if (openId.IsNullOrEmpty()) return 0d;
+        return await Queryable()
+            .Where(m => m.WXOpenId == openId && m.PickupStatus == ERedPackPickupStatus.Received)
+            .Select(m => SqlFunc.AggregateSum(m.Amount))
+            .FirstAsync(cancellationToken);
+    }
 }
 

+ 1 - 0
src/Hotline/Snapshot/IRepository/IRedPackRecordRepository.cs

@@ -8,4 +8,5 @@ using XF.Domain.Repository;
 namespace Hotline.Snapshot.IRepository;
 public interface IRedPackRecordRepository : IRepository<RedPackRecord>
 {
+    Task<double> GetReceivedTotalAmountAsync(string? openId, CancellationToken cancellationToken);
 }

+ 2 - 2
src/Hotline/Snapshot/RedPackRecord.cs

@@ -84,12 +84,12 @@ public class RedPackRecord : CreationSoftDeleteEntity
     /// 红包领取状态
     /// </summary>
     [SugarColumn(ColumnDescription = "红包领取状态")]
-    public ERedPackPickupStatus PickupStatus { get; set; }
+    public ERedPackPickupStatus? PickupStatus { get; set; }
 
     /// <summary>
     /// 发放失败原因
     /// </summary>
-    public ERedPackPickupFailCase FailCase { get; set; }
+    public ERedPackPickupFailCase? FailCase { get; set; }
 
     /// <summary>
     /// 备注

+ 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;

+ 20 - 20
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;
@@ -62,7 +62,7 @@ public class RedPackApplicationTest : TestBase
         var industryItems = await _industryRepository.Queryable().Where(m => m.Name == "安全隐患").Select(d => new { d.Id, d.Name, }).ToListAsync();
         var industry = industryItems.First();
         var order = _orderServiceMock.CreateOrder(industryId: industry.Id, industryName: industry.Name, tags: [dhzy.Id])
-            .办理到网格员()
+            .办理到网格员(SetZuoXi)
             .StepHandle(async order => Thread.Sleep(5 * 1000))
             .办理到派单员(Set班长)
             .办理到一级部门(SetPaiDanYuan)
@@ -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>

+ 3 - 3
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;
@@ -237,8 +237,8 @@ public class SnapshotApplicationTest : TestBase
     [Fact]
     public async Task GetSnapshotUserInfo_Test()
     {
-        await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto(), CancellationToken.None);
-        var result = await _snapshotApplication.GetSnapshotUserInfoAsync();
+        //await _identityAppService.GetThredTokenAsync(new ThirdTokenInDto() { ThirdType = EThirdType.Test}, CancellationToken.None);
+        var result = await _snapshotApplication.GetSnapshotUserInfoAsync(CancellationToken.None);
         result.ShouldNotBeNull();
         result.PhoneNumber.ShouldNotBeNullOrEmpty();
         result.PhoneNumberMask.Contains("***").ShouldBeTrue();

+ 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)

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