Selaa lähdekoodia

Merge branch 'fix/red_pack_audit' into test

qinchaoyue 12 tuntia sitten
vanhempi
commit
54ed6b7d5d

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

@@ -367,8 +367,11 @@ public class IdentityAppService : IIdentityAppService, IScopeDependency
 
     public async Task<Dictionary<string, object>> RefreshTokenAsync(string openId, CancellationToken token)
     {
-        var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(openId, token)
-            ?? throw UserFriendlyException.SameMessage("未找到用户信息");
+        var thirdAccount = await _thirdAccountRepository.GetByOpenIdAsync(openId, token);
+        if (thirdAccount is null)
+        {
+            throw new UserFriendlyException(403, "用户不存在");
+        }
 
         return await GetJwtToken(thirdAccount, token);
     }

+ 11 - 3
src/Hotline.Application/Snapshot/RedPackApplication.cs

@@ -267,8 +267,16 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
         var industry = await _industryRepository.Queryable(includeDeleted: true)
             .LeftJoin<OrderSnapshot>((i, o) => i.Id == o.IndustryId)
             .Where((i, o) => o.Id == id)
-            .Select((i, o) => new { i.Id, i.CitizenReadPackAmount, i.ArgeePoints, i.ExtraDeductedPoints, i.RefusePoints, i.IsPoints,
-            o.IsSafetyDepartment, i.Name})
+            .Select((i, o) => new {
+                i.Id,
+                i.CitizenReadPackAmount,
+                i.ArgeePoints,
+                i.ExtraDeductedPoints,
+                i.RefusePoints,
+                i.IsPoints,
+                o.IsSafetyDepartment,
+                i.Name
+            })
             .FirstAsync();
         outDto.Amount = industry.CitizenReadPackAmount;
         if (industry.Name == "安全隐患" && industry.IsSafetyDepartment.HasValue && industry.IsSafetyDepartment == true)
@@ -417,7 +425,7 @@ public class RedPackApplication : IRedPackApplication, IScopeDependency
             .LeftJoin<RedPackRecord>((redPackAudit, order, snapshot, record) => redPackAudit.Id == record.OrderId)
             .LeftJoin<Industry>((redPackAudit, order, snapshot, record, industry) => snapshot.IndustryId == industry.Id)
             .LeftJoin<IndustryCase>((redPackAudit, order, snapshot, record, industry, industryCase) => snapshot.IndustryCase == industryCase.Id)
-            .Where((redPackAudit, order, snapshot, record, industry) => order.Status >= EOrderStatus.Filed)
+            .Where((redPackAudit, order, snapshot, record, industry) => order.Status >= EOrderStatus.Filed && industry.ApproveOrgId == _sessionContext.OrgId)
             .WhereIF(dto.No.NotNullOrEmpty(), (redPackAudit, order, snapshot, record, industry) => order.No.Contains(dto.No))
             .WhereIF(dto.Title.NotNullOrEmpty(), (redPackAudit, order, snapshot, record, industry) => order.Title.Contains(dto.Title))
             .WhereIF(dto.FromPhone.NotNullOrEmpty(), (redPackAudit, order, snapshot, record, industry) => order.FromPhone.Contains(dto.FromPhone))

+ 1 - 1
src/Hotline.Repository.SqlSugar/Extensions/SqlSugarStartupExtensions.cs

@@ -30,7 +30,7 @@ namespace Hotline.Repository.SqlSugar.Extensions
     {
         public static void AddSqlSugar(this IServiceCollection services, IConfiguration configuration, string dbName = "Hotline")
         {
-            //services.AddScoped<DatabaseEventDispatcher>();
+            services.AddScoped<DatabaseEventDispatcher>();
             //多租户 new SqlSugarScope(List<ConnectionConfig>,db=>{});
 
             var slaveConnections = new List<SlaveConnectionConfig>();

+ 9 - 9
src/Hotline/FlowEngine/Workflows/WorkflowDomainService.cs

@@ -402,15 +402,15 @@ namespace Hotline.FlowEngine.Workflows
                     }
                     else
                     {
-                        var orgid = nextStepDefine.BusinessType ==  EBusinessType.Seat ||
-									nextStepDefine.BusinessType == EBusinessType.Send ||
-									nextStepDefine.BusinessType == EBusinessType.CenterMonitor ||
-									nextStepDefine.BusinessType == EBusinessType.CenterLeader
-							? OrgSeedData.CenterId
-							: null;
-						//todo 指派给配置的角色
-						//dto.FlowAssignType = EFlowAssignType.Role;
-						dto.NextHandlers.Add(new StepAssignInfo
+                        var orgid = nextStepDefine.BusinessType == EBusinessType.Seat ||
+                                    nextStepDefine.BusinessType == EBusinessType.Send ||
+                                    nextStepDefine.BusinessType == EBusinessType.CenterMonitor ||
+                                    nextStepDefine.BusinessType == EBusinessType.CenterLeader
+                            ? OrgSeedData.CenterId
+                            : null;
+                        //todo 指派给配置的角色
+                        //dto.FlowAssignType = EFlowAssignType.Role;
+                        dto.NextHandlers.Add(new StepAssignInfo
                         {
                             Key = handler.Key,
                             Value = handler.Value,

+ 12 - 12
src/Hotline/Orders/OrderDomainService.cs

@@ -569,20 +569,20 @@ public class OrderDomainService : IOrderDomainService, IScopeDependency
 
     #region 平均派单
 
-    public async Task<bool> SchedulingAtWork(string UserId) 
+    public async Task<bool> SchedulingAtWork(string UserId)
     {
-		var time = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
-		var atWork =  await _schedulingRepository.Queryable()
-			.Includes(x => x.SchedulingUser)
-			.Where(x => x.SchedulingUser.UserId == UserId && x.SchedulingTime == time && x.WorkingTime <= DateTime.Now.TimeOfDay && x.OffDutyTime >= DateTime.Now.TimeOfDay && x.AtWork == true)
-			.AnyAsync();
+        var time = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
+        var atWork = await _schedulingRepository.Queryable()
+            .Includes(x => x.SchedulingUser)
+            .Where(x => x.SchedulingUser.UserId == UserId && x.SchedulingTime == time && x.WorkingTime <= DateTime.Now.TimeOfDay && x.OffDutyTime >= DateTime.Now.TimeOfDay && x.AtWork == true)
+            .AnyAsync();
         return atWork;
-	}
-	/// <summary>
-	/// 平均派单
-	/// </summary>
-	/// <returns></returns>
-	public async Task<StepAssignInfo> AverageOrder(CancellationToken cancellationToken)
+    }
+    /// <summary>
+    /// 平均派单
+    /// </summary>
+    /// <returns></returns>
+    public async Task<StepAssignInfo> AverageOrder(CancellationToken cancellationToken)
     {
         var time = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
         var scheduling = await _schedulingRepository.Queryable().Includes(x => x.SchedulingUser)

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

@@ -328,7 +328,7 @@ public class OrderSnapshotApplicationTest : TestBase
 
                 try
                 {
-                    await _redPackApplication.RevocationRedPackSpecialAuditAsync(new List<string> { specialRedAudit.Id });
+                    await _redPackApplication.RevocationRedPackSpecialAuditAsync([specialRedAudit.Id]);
                 }
                 catch (UserFriendlyException e)
                 {

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

@@ -87,7 +87,8 @@ public class OrderServiceMock
         inDto.Street = "单元测试街道" + DateTime.Now.ToLongDateTimeString();
         inDto.IndustryId = industry.Id;
         inDto.Town = "仙市镇";
-        inDto.County = "大安区";
+        inDto.AreaCode = "510302";
+        inDto.County = "自流井区";
         inDto.Description = "单元测试添加的时间描述";
         inDto.IsSecret = false;
         inDto.PhoneNumber = _sessionContext.Phone;

+ 1 - 1
test/Hotline.Tests/TestBase.cs

@@ -176,7 +176,7 @@ public class TestBase
                 Name = name,
                 OrgId = orgId,
                 PhoneNo = phoneNo,
-                RoleIds = new[] { roleId },
+                RoleIds = [roleId],
                 UserType = userType,
                 UserName = userName
             };