|  |  | 
 |  |  | using Z.EntityFramework.Plus; | 
 |  |  | using LifePayment.Domain.LifePay; | 
 |  |  | using pingan.openbank.api.sdk.enums; | 
 |  |  | using System.Linq.Dynamic.Core; | 
 |  |  | using static Volo.Abp.Identity.Settings.IdentitySettingNames; | 
 |  |  |  | 
 |  |  | namespace LifePayment.Application; | 
 |  |  |  | 
 |  |  | 
 |  |  |     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; | 
 |  |  | 
 |  |  |                           IOptions<WxPayOption> wxPayOptions, | 
 |  |  |                           IRepository<LifePayChannles, Guid> lifePayChannlesRep, | 
 |  |  |                           IRepository<LifePayAccount, Guid> lifePayAccount, | 
 |  |  |                           IDataFilter dataFilter) | 
 |  |  |                           IDataFilter dataFilter, | 
 |  |  |                           IChannelFilter channelFilter) | 
 |  |  |     { | 
 |  |  |         _logger = logger; | 
 |  |  |         _aCOOLYManager = aCOOLYManager; | 
 |  |  | 
 |  |  |         _lifePayChannlesRep = lifePayChannlesRep; | 
 |  |  |         _lifePayAccount = lifePayAccount; | 
 |  |  |         this.dataFilter = dataFilter; | 
 |  |  |         _channelFilter = channelFilter; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     #region 查询 | 
 |  |  | 
 |  |  |     /// </summary> | 
 |  |  |     /// <param name="input"></param> | 
 |  |  |     /// <returns></returns> | 
 |  |  |     public async Task<PageOutput<UserListOutput>> GetUserPage(PageInput input) | 
 |  |  |     public async Task<PageOutput<UserListOutput>> GetUserPage(QueryUserPageInput input) | 
 |  |  |     { | 
 |  |  |         var channel = await _lifePayChannlesRep.ToListAsync(); | 
 |  |  |         return await _lifePayUserRepository.Select(x => | 
 |  |  |         return await _lifePayUserRepository.Where(x => x.IsDeleted == false) | 
 |  |  |             .WhereIf(!string.IsNullOrEmpty(input.QueryCondition), x => x.PhoneNumber.Contains(input.QueryCondition) || x.Name.Contains(input.QueryCondition)) | 
 |  |  |             .WhereIf(input.CreationTime.HasValue, x => x.CreationTime.ToString("yyyy-MM-dd") == input.CreationTime.Value.ToString("yyyy-MM-dd")) | 
 |  |  |                                             .Select(x => | 
 |  |  |                                                    new UserListOutput() | 
 |  |  |                                                    { | 
 |  |  |                                                        Id = x.Id, | 
 |  |  |                                                        //CreationChannle = string.IsNullOrEmpty(x.CreationChannleNum) ? "" : channel.Where(c => c.ChannlesNum == x.CreationChannleNum).FirstOrDefault().ChannlesName, | 
 |  |  |                                                        //LastLoginChannle = string.IsNullOrEmpty(x.LastLoginChannleNum) ? "" : channel.Where(c => c.ChannlesNum == x.LastLoginChannleNum).FirstOrDefault().ChannlesName, | 
 |  |  |                                                        CreationChannle = string.IsNullOrEmpty(x.CreationChannleNum) ? "" : _lifePayChannlesRep.Where(c => c.ChannlesNum == x.CreationChannleNum).FirstOrDefault().ChannlesName, | 
 |  |  |                                                        LastLoginChannle = string.IsNullOrEmpty(x.LastLoginChannleNum) ? "" : _lifePayChannlesRep.Where(c => c.ChannlesNum == x.LastLoginChannleNum).FirstOrDefault().ChannlesName, | 
 |  |  |                                                        PhoneNumber = x.PhoneNumber, | 
 |  |  |                                                        Name = string.IsNullOrEmpty(x.Name) ? "" : x.Name, | 
 |  |  |                                                        CreationTime = x.CreationTime, | 
 |  |  |                                                        LastLoginTime = x.LastLoginTime | 
 |  |  |                                                    }) | 
 |  |  | 
 |  |  |     /// <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) | 
 |  |  | 
 |  |  |                                                     { | 
 |  |  |                                                         Id = x.Id, | 
 |  |  |                                                         ChannlesRate = x.ChannlesRate, | 
 |  |  |                                                         ChannlesRakeRate = x.ChannlesRakeRate, | 
 |  |  |                                                         ChannlesName = x.ChannlesName, | 
 |  |  |                                                         ChannlesNum = x.ChannlesNum, | 
 |  |  |                                                         Status = x.Status, | 
 |  |  | 
 |  |  |                                                     { | 
 |  |  |                                                         Id = x.Id, | 
 |  |  |                                                         ChannlesRate = x.ChannlesRate, | 
 |  |  |                                                         ChannlesRakeRate = x.ChannlesRakeRate, | 
 |  |  |                                                         ChannlesName = x.ChannlesName, | 
 |  |  |                                                         ChannlesNum = x.ChannlesNum, | 
 |  |  |                                                         Status = x.Status, | 
 |  |  | 
 |  |  |         await _lifePayOrderRepository.UpdateAsync(order); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /// <summary> | 
 |  |  |     /// 微信退款 | 
 |  |  |     /// </summary> | 
 |  |  |     /// <param name="outTradeNo"></param> | 
 |  |  |     /// <param name="reason"></param> | 
 |  |  |     /// <param name="refund"></param> | 
 |  |  |     /// <param name="total"></param> | 
 |  |  |     /// <param name="currency"></param> | 
 |  |  |     /// <returns></returns> | 
 |  |  |     public async Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(string outTradeNo, string reason, int refund, int total, string currency = "CNY") | 
 |  |  |     { | 
 |  |  |         WxPayDomesticRefundsRequest req = new WxPayDomesticRefundsRequest | 
 |  |  | 
 |  |  |         return res; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public async Task<int> AddUpdateUserAccount(AddUpdateUserAccountInput input) | 
 |  |  |     { | 
 |  |  |         var user = await _lifePayUserRepository.Where(r => r.Id == input.UserId && !r.IsDeleted).FirstOrDefaultAsync(); | 
 |  |  |         CheckExtensions.IfTrueThrowUserFriendlyException(user == null, "用户不存在"); | 
 |  |  |  | 
 |  |  |         if (input.Id.HasValue) | 
 |  |  |         { | 
 |  |  |             var userAccount = await _lifePayAccount.Where(x => x.UserId == input.UserId && x.Id == input.Id) | 
 |  |  | 
 |  |  |             }; | 
 |  |  |             await _lifePayAccount.InsertAsync(userAccount); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if (input.LifePayType == LifePayOrderTypeEnum.话费订单) | 
 |  |  |         { | 
 |  |  |             var extraProperties = JsonConvert.DeserializeObject<Model_UserAccountExtraProperties>(input.ExtraProperties); | 
 |  |  |             if (!string.IsNullOrEmpty(extraProperties.Name)) | 
 |  |  |             { | 
 |  |  |                 user.Name = extraProperties.Name; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         return Constant.SUCCESS; | 
 |  |  |     } | 
 |  |  | 
 |  |  |             dto.ChannlesName = input.ChannlesName; | 
 |  |  |             dto.ChannlesNum = input.ChannlesNum; | 
 |  |  |             dto.ChannlesRate = input.ChannlesRate; | 
 |  |  |             dto.ChannlesRakeRate = input.ChannlesRakeRate; | 
 |  |  |             dto.SwitchType = input.SwitchType; | 
 |  |  |             dto.ChannlesType = input.ChannlesType; | 
 |  |  |             dto.Status = input.Status; | 
 |  |  | 
 |  |  |                     { | 
 |  |  |                         Id = x.Id, | 
 |  |  |                         ChannlesRate = x.ChannlesRate, | 
 |  |  |                         ChannlesRakeRate = x.ChannlesRakeRate, | 
 |  |  |                         ChannlesName = x.ChannlesName, | 
 |  |  |                         ChannlesNum = x.ChannlesNum, | 
 |  |  |                         Status = x.Status, |