From 8c4e906848c5f453369ead6cd8024aeb7b113771 Mon Sep 17 00:00:00 2001 From: lingling <kety1122@163.com> Date: 星期三, 19 三月 2025 16:20:19 +0800 Subject: [PATCH] 添加过滤 --- /dev/null | 47 ----------------------- LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml | 5 ++ LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs | 4 +- LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 9 +++- LifePayment/LifePayment.Domain/Common/IChannelFilter.cs | 41 ++++++++++++++++++++ LifePayment/LifePayment.Domain/Common/ChannelFilter.cs | 14 +++++-- 6 files changed, 64 insertions(+), 56 deletions(-) diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index f87e0a1..3e317b6 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -45,7 +45,7 @@ private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRep; private readonly IRepository<LifePayAccount, Guid> _lifePayAccount; private readonly IDataFilter dataFilter; - + private readonly IChannelFilter _channelFilter; private readonly IAliPayApi _aliPayApi; private readonly IWxPayApi _wxPayApi; private readonly WxPayOption _wxPayOptions; @@ -65,7 +65,8 @@ IOptions<WxPayOption> wxPayOptions, IRepository<LifePayChannles, Guid> lifePayChannlesRep, IRepository<LifePayAccount, Guid> lifePayAccount, - IDataFilter dataFilter) + IDataFilter dataFilter, + IChannelFilter channelFilter) { _logger = logger; _aCOOLYManager = aCOOLYManager; @@ -81,6 +82,7 @@ _lifePayChannlesRep = lifePayChannlesRep; _lifePayAccount = lifePayAccount; this.dataFilter = dataFilter; + _channelFilter = channelFilter; } #region 鏌ヨ @@ -222,7 +224,8 @@ /// <returns></returns> public async Task<PageOutput<LifePayOrderListOutput>> GetLifePayOrderPage(QueryLifePayOrderListInput input) { - var result = await (from a in _lifePayOrderRepository.Where(x => x.PayStatus != LifePayStatusEnum.鏈敮浠�) + + var result = await (from a in _channelFilter.GetChannelLifePayOrderFilter(_lifePayOrderRepository) .WhereIf(input.BeginFinishTime.HasValue, x => x.FinishTime >= input.BeginFinishTime) .WhereIf(input.EndFinishTime.HasValue, x => x.FinishTime <= input.EndFinishTime) .WhereIf(input.BeginPayTime.HasValue, x => x.PayTime >= input.BeginPayTime) diff --git a/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs b/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs index 4c7efd3..2b44105 100644 --- a/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs +++ b/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs @@ -12,9 +12,9 @@ namespace LifePayment.Domain.Common { - public abstract class AbstractChannelFilter + public abstract class AbstractChannelFilter : IChannelFilter, ISingletonDependency { - public abstract Task<IQueryable<ChannelsBase>> GetChannelFilter(IQueryable<ChannelsBase> query); + public abstract IQueryable<LifePayOrder> GetChannelLifePayOrderFilter(IQueryable<LifePayOrder> query); public IAbpLazyServiceProvider LazyServiceProvider { get; set; } diff --git a/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs b/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs index f4d0a5e..11cde80 100644 --- a/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs +++ b/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Channels; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Services; @@ -17,11 +18,16 @@ { public class ChannelFilter : AbstractChannelFilter { - public async override Task<IQueryable<ChannelsBase>> GetChannelFilter(IQueryable<ChannelsBase> query) + public override IQueryable<LifePayOrder> GetChannelLifePayOrderFilter(IQueryable<LifePayOrder> query) { - var queryUser = UserChannleRepository.Where(r => r.UserId == CurrentUser.Id).Select(s => s.ChannleId).ToList(); - var queryResult = query.Where(s => queryUser.Contains(s.ChannleId)); - return queryResult; + if (CurrentUser.ClientId == Constant.ClientType.Back) + { + var queryUser = UserChannleRepository.Where(r => r.UserId == CurrentUser.Id).Select(s => s.ChannleId).ToList(); + var queryResult = query.Where(s => (s.ChannelId.HasValue && queryUser.Contains(s.ChannelId.Value)) || !s.ChannelId.HasValue); + return queryResult; + } + + return query; } } diff --git a/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs b/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs deleted file mode 100644 index cff865d..0000000 --- a/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs +++ /dev/null @@ -1,47 +0,0 @@ -锘縰sing DynamicQuery.Net.Dto.Input; -using DynamicQuery.Net; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ZeroD.Application.Services.Dto; -using Volo.Abp.Users; -using Volo.Abp.Auditing; -using Volo.Abp.Domain.Entities; - -namespace LifePayment.Domain -{ - public interface IChannelFilter - { - - public Task<IQueryable<TEntity>> GetChannelFilter<TEntity, TKey>(IQueryable<TEntity> query) - where TEntity : class, IChannelData, IMayHaveCreator, IEntity<TKey>; - //public static IQueryable<T> GetChannleQuery<T>(this IQueryable<T> query, ChannelFilterInput input) where T : class, IChannelData - //{ - // if (query == null) - // { - // return query; - // } - // if (input.Channels != null && input.Channels.Any()) - // { - // query = query.Where(r => input.Channels.Contains(r.ChannelId)); - // } - // return query; - //} - - } - - - - public interface IChannelData - { - public Guid ChannleId { get; set; } - } - - public class ChannelFilterInput - { - public List<Guid> Channels { get; set; } = new List<Guid>(); - } - -} diff --git a/LifePayment/LifePayment.Domain/Common/IChannelFilter.cs b/LifePayment/LifePayment.Domain/Common/IChannelFilter.cs new file mode 100644 index 0000000..d56f0eb --- /dev/null +++ b/LifePayment/LifePayment.Domain/Common/IChannelFilter.cs @@ -0,0 +1,41 @@ +锘縰sing LifePayment.Domain.Models; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Domain.Entities; + +namespace LifePayment.Domain +{ + public interface IChannelFilter + { + + + public IQueryable<LifePayOrder> GetChannelLifePayOrderFilter(IQueryable<LifePayOrder> query); + + //public static IQueryable<T> GetChannleQuery<T>(this IQueryable<T> query, ChannelFilterInput input) where T : class, IChannelData + //{ + // if (query == null) + // { + // return query; + // } + // if (input.Channels != null && input.Channels.Any()) + // { + // query = query.Where(r => input.Channels.Contains(r.ChannelId)); + // } + // return query; + //} + + } + + + + //public interface IChannelData + //{ + // public Guid ChannleId { get; set; } + //} + + //public class ChannelFilterInput + //{ + // public List<Guid> Channels { get; set; } = new List<Guid>(); + //} + +} diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml index cc63059..85e98c3 100644 --- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml +++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml @@ -1715,6 +1715,11 @@ 瑙掕壊 </summary> </member> + <member name="P:LifePayment.Application.Contracts.CreateAccountInput.ChannlesId"> + <summary> + 娓犻亾鍒楄〃 + </summary> + </member> <member name="P:LifePayment.Application.Contracts.CreateAccountInput.OpenId"> <summary> 灏忕▼搴廜penId -- Gitblit v1.9.1