zhengyuxuan
2025-03-27 877a696655516acaa1ee19ecbc8d050394c26c2b
LifePayment/LifePayment.Application/User/AccountService.cs
@@ -16,6 +16,7 @@
using Volo.Abp.Identity;
using Volo.Abp.Identity.Application.Contracts.Account;
using Volo.Abp.IdentityModel;
using Volo.Abp.Threading;
using ZeroD.Util;
using ZeroD.Util.Fadd;
using static LifePayment.Domain.Shared.LifePaymentConstant;
@@ -78,7 +79,7 @@
                {
                    await _distributedCache.SetAsync(code, res.OpenId, options: new Microsoft.Extensions.Caching.Distributed.DistributedCacheEntryOptions()
                    {
                        AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)
                        AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(24)
                    });
                }
@@ -103,17 +104,9 @@
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="UserFriendlyException"></exception>
        public async Task<Guid> LifePayPhoneMesssageCodeLogin(LifePayPhoneMesssageCodeLoginInput input)
        public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayPhoneMesssageCodeLogin(LifePayPhoneMesssageCodeLoginInput input)
        {
            //var vcodeType = VerificationCodeBusinessTypeEnum.LifePayPhoneMesssageCodeLogin;
            //var checkResult = await _verificationCodeManager.CheckVerificationCodeByBusinessType(vcodeType,
            //                                                                                     input.PhoneNumber,
            //                                                                                     input.Code,
            //                                                                                     true);
            //CheckExtensions.IfTrueThrowUserFriendlyException(!checkResult,
            //                                                 CustomeErrorMessage.SometingWrongOrSometing, "验证码", "已失效");
            string[] channlesNum = new string[0];
            var lifeUser = await _lifePayUserRepository.Where(x => x.PhoneNumber == input.PhoneNumber).FirstOrDefaultAsync();
            if (lifeUser == null)
            {
@@ -133,9 +126,48 @@
                lifeUser.LastLoginTime = DateTime.Now;
                await _lifePayUserRepository.UpdateAsync(lifeUser);
            }
            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();
            }
            return lifeUser.Id;
            LifePayPhoneMesssageCodeLoginOutput result = new LifePayPhoneMesssageCodeLoginOutput()
            {
                UserId = lifeUser.Id,
                IsBackClientUser = backClientUser == null ? false : true,
                ChannlesNum = channlesNum
            };
            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 backClientUser = await _userRepository.Where(x => x.ClientId == Constant.ClientType.Back
             && x.PhoneNumber == lifeUser.PhoneNumber).FirstOrDefaultAsync();
            if (backClientUser != null)
            {
                channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id).Select(s => s.ChannleId).ToArrayAsync();
            }
            LifePayPhoneMesssageCodeLoginOutput result = new LifePayPhoneMesssageCodeLoginOutput()
            {
                UserId = id,
                IsBackClientUser = backClientUser == null ? false : true,
                ChannlesNum = channlesNum
            };
            return result;
        }
        public async Task<IdentityModelTokenCacheItem> GetTokenForWeb(AccessRequestDto accessRequestDto, string webClientIp)
        {
@@ -160,11 +192,11 @@
        public async Task<Guid> CreateAccount(CreateAccountInput input, bool isSend, bool isAdminCreate = false)
        {
            if (input.ClientId == LifePaymentConstant.ClientId.Back)
            {
                CheckExtensions.IfTrueThrowUserFriendlyException(!input.CompanyOrgId.HasValue || !input.DepartmentOrgId.HasValue,
                                                                 "所属公司和部门不能为空");
            }
            //if (input.ClientId == LifePaymentConstant.ClientId.Back)
            //{
            //    CheckExtensions.IfTrueThrowUserFriendlyException(!input.CompanyOrgId.HasValue || !input.DepartmentOrgId.HasValue,
            //                                                     "所属公司和部门不能为空");
            //}
            var any = await _userRepository.Where(x => x.PhoneNumber == input.PhoneNumber && x.ClientId == input.ClientId).AnyAsync();
            CheckExtensions.IfTrueThrowUserFriendlyException(any,