| | |
| | | using System.Threading.Tasks; |
| | | using Volo.Abp; |
| | | using Volo.Abp.Application.Services; |
| | | using Volo.Abp.Caching; |
| | | using Volo.Abp.Domain.Repositories; |
| | | using Volo.Abp.Identity; |
| | | using Volo.Abp.Identity.Application.Contracts.Account; |
| | | using Volo.Abp.IdentityModel; |
| | | using ZeroD.Util; |
| | | using ZeroD.Util.Fadd; |
| | | using static LifePayment.Domain.Shared.LifePaymentConstant; |
| | | |
| | | |
| | |
| | | private readonly IRepository<User, Guid> _userRepository; |
| | | private readonly IRepository<UserChannle, Guid> _userChannleRep; |
| | | private readonly IIdentityUserAppService _identityUserService; |
| | | private readonly IDistributedCache<string> _distributedCache; |
| | | |
| | | |
| | | public AccountService( |
| | | IWxManager wxManager, |
| | |
| | | IRepository<User, Guid> userRepository, |
| | | IIdentityUserAppService identityUserService, |
| | | IRepository<LifePayUser, Guid> lifePayUserRepository, |
| | | IRepository<UserChannle, Guid> userChannleRep) |
| | | IRepository<UserChannle, Guid> userChannleRep, |
| | | IDistributedCache<string> distributedCache) |
| | | { |
| | | _configuration = configuration; |
| | | _wxManager = wxManager; |
| | |
| | | _authenticator = authenticator; |
| | | _userRepository = userRepository; |
| | | _userChannleRep = userChannleRep; |
| | | _distributedCache = distributedCache; |
| | | } |
| | | |
| | | #region 查询 |
| | | |
| | | public async Task<WxMiniAppIndentityInfo> GetLifePayWxIndentity(string code) |
| | | { |
| | | var res = await _wxManager.GetWxOauth2AccessToken(code); |
| | | var result = new WxMiniAppIndentityInfo |
| | | var cacheData = await _distributedCache.GetAsync(code); |
| | | var result = new WxMiniAppIndentityInfo(); |
| | | if (cacheData != null) |
| | | { |
| | | SessionKey = res.SessionKey, |
| | | OpenId = res.OpenId, |
| | | UnionId = res.UnionId |
| | | }; |
| | | result.OpenId = cacheData; |
| | | } |
| | | else |
| | | { |
| | | var res = await _wxManager.GetWxOauth2AccessToken(code); |
| | | result = new WxMiniAppIndentityInfo |
| | | { |
| | | SessionKey = res.SessionKey, |
| | | OpenId = res.OpenId, |
| | | UnionId = res.UnionId |
| | | }; |
| | | if (!string.IsNullOrEmpty(res.OpenId)) |
| | | { |
| | | await _distributedCache.SetAsync(code, res.OpenId, options: new Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions() |
| | | { |
| | | AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(24) |
| | | }); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | |
| | | var user = await _userRepository.Where(r => r.UserName == accessRequestDto.UserName && !r.IsDeleted).FirstOrDefaultAsync(); |
| | | |
| | | // 记录日志 |
| | | // await PublishUserOperateHistoryEvent(LogsSpecies.Login, LogsSpecies.Login, user.Id, user.Id, creatorName: user.Name); |
| | | // await PublishUserOperateHistoryEvent(LogsSpecies.Login, LogsSpecies.Login, user.Id, user.Id, creatorName: user.Name); |
| | | |
| | | return result; |
| | | } |