| | |
| | | using LifePayment.Domain.Shared; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Nest; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Linq.Dynamic.Core; |
| | | using System.Threading.Tasks; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Application.Services; |
| | |
| | | { |
| | | 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; |
| | |
| | | IRepository<User, Guid> userRepository, |
| | | IIdentityUserAppService identityUserService, |
| | | IRepository<LifePayUser, Guid> lifePayUserRepository, |
| | | IRepository<LifePayChannles, Guid> lifePayChannlesRepository, |
| | | IRepository<UserChannle, Guid> userChannleRep, |
| | | IDistributedCache<string> distributedCache) |
| | | { |
| | |
| | | _wxManager = wxManager; |
| | | _identityUserService = identityUserService; |
| | | _lifePayUserRepository = lifePayUserRepository; |
| | | _lifePayChannlesRepository = lifePayChannlesRepository; |
| | | _authenticator = authenticator; |
| | | _userRepository = userRepository; |
| | | _userChannleRep = userChannleRep; |
| | |
| | | return result; |
| | | } |
| | | |
| | | public async Task<BackClientUserInfoOutput> GetBackClientUserInfo() |
| | | { |
| | | var channlesNums = await _userChannleRep.Where(x => x.UserId == CurrentUser.Id).Select(s => s.ChannleId).Distinct().ToListAsync(); |
| | | |
| | | var channleList = await _lifePayChannlesRepository.Where(x => channlesNums.Contains(x.ChannlesNum)).Select(s => new ChannelOutput() |
| | | { |
| | | Name = s.ChannlesName, |
| | | ChannlesId = s.Id, |
| | | ChannlesNum = s.ChannlesNum |
| | | }).ToListAsync(); |
| | | |
| | | BackClientUserInfoOutput result = new BackClientUserInfoOutput() |
| | | { |
| | | IsBackClientUser = CurrentUser.ClientId == Constant.ClientType.Back, |
| | | IsSystem = CurrentUser.IsSystem, |
| | | ChannleList = channleList |
| | | }; |
| | | return result; |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 操作 |
| | |
| | | /// <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) |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | |
| | | return res.Id; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | |
| | | } |