xf 1 year ago
parent
commit
cfaa959fe1
1 changed files with 16 additions and 13 deletions
  1. 16 13
      src/Hotline.Api/Controllers/OrderController.cs

+ 16 - 13
src/Hotline.Api/Controllers/OrderController.cs

@@ -1863,21 +1863,24 @@ public class OrderController : BaseController
             handleStatuses = dto.IsHandled.Value
                 ? new[] { EWorkflowStepStatus.Handled }
                 : new[] { EWorkflowStepStatus.WaitForAccept, EWorkflowStepStatus.WaitForHandle };
-
+        
         RefAsync<int> total = 0;
         var dtos = await _workflowStepRepository.Queryable()
-              .InnerJoin<Workflow>((s, w) => s.WorkflowId == w.Id)
-              .LeftJoin<Order>((s, w, o) => w.ExternalId == o.Id)
-              .WhereIF(dto.IsProvince.HasValue, (s, w, o) => o.IsProvince == dto.IsProvince)
-              .WhereIF(dto.IsHandled.HasValue, (s, w, o) => handleStatuses.Contains(s.Status))
-              .WhereIF(!string.IsNullOrEmpty(dto.Keyword),
-                  (s, w, o) => o.No.Contains(dto.Keyword) || o.Title.Contains(dto.Keyword))
-              .OrderByDescending((s) => s.StepExpiredTime)
-              .Select((s, w, o) => new OrderWaitedDto
-              {
-                  StepExpiredTime = s.StepExpiredTime
-              }, true)
-              .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
+            .InnerJoin<Workflow>((s, w) => s.WorkflowId == w.Id)
+            .LeftJoin<Order>((s, w, o) => w.ExternalId == o.Id)
+            .Where((s, w, o) => SqlFunc.JsonListObjectAny(s.Handlers, "Key", _sessionContext.RequiredUserId) ||
+                                SqlFunc.JsonListObjectAny(s.Handlers, "Key", _sessionContext.RequiredOrgId))
+            .WhereIF(dto.IsProvince.HasValue, (s, w, o) => o.IsProvince == dto.IsProvince)
+            .WhereIF(dto.IsHandled.HasValue, (s, w, o) => handleStatuses.Contains(s.Status))
+            .WhereIF(!string.IsNullOrEmpty(dto.Keyword),
+                (s, w, o) => o.No.Contains(dto.Keyword) || o.Title.Contains(dto.Keyword))
+            .OrderByDescending((s) => s.StepExpiredTime)
+            .Select((s, w, o) => new OrderWaitedDto
+            {
+                StepExpiredTime = s.StepExpiredTime,
+                Status = o.Status
+            }, true)
+            .ToPageListAsync(dto.PageIndex, dto.PageSize, total, HttpContext.RequestAborted);
 
         return new PagedDto<OrderWaitedDto>(total, dtos);
     }