From d7399b083de823860a56b68c79f8e36603fb4ea3 Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期一, 31 三月 2025 13:37:19 +0800 Subject: [PATCH] fix:获取渠道分佣分页列表 --- LifePayment/LifePayment.Application/User/AccountService.cs | 76 +++++++++++++++++++++++++++++--------- 1 files changed, 58 insertions(+), 18 deletions(-) diff --git a/LifePayment/LifePayment.Application/User/AccountService.cs b/LifePayment/LifePayment.Application/User/AccountService.cs index ac9b944..7ba7018 100644 --- a/LifePayment/LifePayment.Application/User/AccountService.cs +++ b/LifePayment/LifePayment.Application/User/AccountService.cs @@ -5,6 +5,7 @@ using LifePayment.Domain.Shared; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Nest; using System; using System.Collections.Generic; using System.Linq; @@ -28,6 +29,7 @@ { private readonly IWxManager _wxManager; private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository; + private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRepository; private readonly IConfiguration _configuration; private readonly IIdentityModelAuthenticationService _authenticator; private readonly IRepository<User, Guid> _userRepository; @@ -43,6 +45,7 @@ IRepository<User, Guid> userRepository, IIdentityUserAppService identityUserService, IRepository<LifePayUser, Guid> lifePayUserRepository, + IRepository<LifePayChannles, Guid> lifePayChannlesRepository, IRepository<UserChannle, Guid> userChannleRep, IDistributedCache<string> distributedCache) { @@ -50,6 +53,7 @@ _wxManager = wxManager; _identityUserService = identityUserService; _lifePayUserRepository = lifePayUserRepository; + _lifePayChannlesRepository = lifePayChannlesRepository; _authenticator = authenticator; _userRepository = userRepository; _userChannleRep = userChannleRep; @@ -89,6 +93,28 @@ return result; } + public async Task<List<ChannelOutput>> GetUserChannel() + { + var userchannel = await _userChannleRep.Where(x => x.UserId == CurrentUser.Id) + .Select(s => new ChannelOutput() + { + Name = _lifePayChannlesRepository.Where(x => x.ChannlesNum == s.ChannleId).Select(r => r.ChannlesName).FirstOrDefault(), + ChannlesNum = s.ChannleId + }).ToListAsync(); + if (userchannel.Count() == 0) + { + userchannel = await _lifePayChannlesRepository + .Select(s => new ChannelOutput() + { + Name = s.ChannlesName, + ChannlesNum = s.ChannlesNum + }).ToListAsync(); + } + + return userchannel; + } + + #endregion #region 鎿嶄綔 @@ -106,7 +132,6 @@ /// <exception cref="UserFriendlyException"></exception> public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayPhoneMesssageCodeLogin(LifePayPhoneMesssageCodeLoginInput input) { - string[] channlesNum = new string[0]; var lifeUser = await _lifePayUserRepository.Where(x => x.PhoneNumber == input.PhoneNumber).FirstOrDefaultAsync(); if (lifeUser == null) { @@ -126,48 +151,58 @@ lifeUser.LastLoginTime = DateTime.Now; await _lifePayUserRepository.UpdateAsync(lifeUser); } + + List<ChannelOutput> channlesNum = new List<ChannelOutput>(); var backClientUser = await _userRepository.Where(x => x.ClientId == Constant.ClientType.Back && x.PhoneNumber == input.PhoneNumber).FirstOrDefaultAsync(); if (backClientUser != null) { - channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id).Select(s => s.ChannleId).ToArrayAsync(); + channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id) + .Select(s => new ChannelOutput() + { + Name = _lifePayChannlesRepository.Where(x => x.ChannlesNum == s.ChannleId).Select(r => r.ChannlesName).FirstOrDefault(), + ChannlesNum = s.ChannleId + }).ToListAsync(); } - LifePayPhoneMesssageCodeLoginOutput result = new LifePayPhoneMesssageCodeLoginOutput() - { - UserId = lifeUser.Id, - IsBackClientUser = backClientUser == null ? false : true, - ChannlesNum = channlesNum - }; - - + var result = await LifePayUserMesssageByPhone(lifeUser.PhoneNumber); + result.UserId = lifeUser.Id; return result; } public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayUserMesssageByIduser(Guid id) { - string[] channlesNum = new string[0]; var lifeUser = await _lifePayUserRepository.Where(x => x.Id == id).FirstOrDefaultAsync(); CheckExtensions.IfTrueThrowUserFriendlyException(lifeUser == null, "鐢ㄦ埛涓嶅瓨鍦�"); + + var result = await LifePayUserMesssageByPhone(lifeUser.PhoneNumber); + result.UserId = id; + return result; + } + + public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayUserMesssageByPhone(string phoneNumber) + { + List<ChannelOutput> channlesNum = new List<ChannelOutput>(); var backClientUser = await _userRepository.Where(x => x.ClientId == Constant.ClientType.Back - && x.PhoneNumber == lifeUser.PhoneNumber).FirstOrDefaultAsync(); + && x.PhoneNumber == phoneNumber).FirstOrDefaultAsync(); if (backClientUser != null) { - channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id).Select(s => s.ChannleId).ToArrayAsync(); + channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id) + .Select(s => new ChannelOutput() + { + Name = _lifePayChannlesRepository.Where(x => x.ChannlesNum == s.ChannleId).Select(r => r.ChannlesName).FirstOrDefault(), + ChannlesNum = s.ChannleId + }).ToListAsync(); } LifePayPhoneMesssageCodeLoginOutput result = new LifePayPhoneMesssageCodeLoginOutput() { - UserId = id, IsBackClientUser = backClientUser == null ? false : true, ChannlesNum = channlesNum }; - - - return result; + return result; } - public async Task<IdentityModelTokenCacheItem> GetTokenForWeb(AccessRequestDto accessRequestDto, string webClientIp) { @@ -309,10 +344,15 @@ return res.Id; } + + + + #endregion #endregion } + } \ No newline at end of file -- Gitblit v1.9.1