From 12cb0dd9f762c0f171a68678bad2ad0371bf808b Mon Sep 17 00:00:00 2001 From: gdlcf88 Date: Sat, 29 Jul 2023 17:47:08 +0800 Subject: [PATCH] Add `GetRefundListDto.PaymentId` --- common.props | 2 +- .../Payments/Refunds/Dtos/GetRefundListDto.cs | 2 ++ .../Payments/Refunds/RefundAppService.cs | 23 +++++++++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/common.props b/common.props index 7e50a21f..94f2b069 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 5.0.0-preview.1 + 5.0.0-preview.2 $(NoWarn);CS1591 true EasyAbp Team diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/GetRefundListDto.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/GetRefundListDto.cs index 0ddfe922..a2783896 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/GetRefundListDto.cs +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application.Contracts/EasyAbp/EShop/Payments/Refunds/Dtos/GetRefundListDto.cs @@ -7,5 +7,7 @@ namespace EasyAbp.EShop.Payments.Refunds.Dtos public class GetRefundListDto : PagedAndSortedResultRequestDto { public Guid? UserId { get; set; } + + public Guid? PaymentId { get; set; } } } \ No newline at end of file diff --git a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs index e81a713a..0017e7d3 100644 --- a/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs +++ b/modules/EasyAbp.EShop.Payments/src/EasyAbp.EShop.Payments.Application/EasyAbp/EShop/Payments/Refunds/RefundAppService.cs @@ -62,16 +62,31 @@ namespace EasyAbp.EShop.Payments.Refunds protected override async Task> CreateFilteredQueryAsync(GetRefundListDto input) { - return input.UserId.HasValue - ? await _repository.GetQueryableByUserIdAsync(input.UserId.Value) - : await _repository.GetQueryableAsync(); + return (input.UserId.HasValue + ? await _repository.GetQueryableByUserIdAsync(input.UserId.Value) + : await _repository.GetQueryableAsync()) + .WhereIf(input.PaymentId.HasValue, x => x.PaymentId == input.PaymentId.Value); } // Todo: should a store owner user see orders of other stores in the same payment/refund? [Authorize] public override async Task> GetListAsync(GetRefundListDto input) { - if (input.UserId != CurrentUser.GetId()) + if (input.UserId.HasValue) + { + if (input.UserId.Value != CurrentUser.GetId()) + { + await CheckPolicyAsync(GetListPolicyName); + } + } + else if (input.PaymentId.HasValue) + { + if ((await _paymentRepository.FindAsync(input.PaymentId.Value))?.UserId != CurrentUser.GetId()) + { + await CheckPolicyAsync(GetListPolicyName); + } + } + else { await CheckPolicyAsync(GetListPolicyName); }