From f885db9e204c172c62779f45c3edee3cae463b8d Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期二, 01 四月 2025 16:00:33 +0800
Subject: [PATCH] Merge branch 'dev-lifepay-v1.3' of http://120.26.58.240:8888/r/LifePaymentApi into dev-lifepay-v1.3

---
 LifePayment/LifePayment.Application/User/AccountService.cs |   81 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 76 insertions(+), 5 deletions(-)

diff --git a/LifePayment/LifePayment.Application/User/AccountService.cs b/LifePayment/LifePayment.Application/User/AccountService.cs
index 7ddb6db..936156c 100644
--- a/LifePayment/LifePayment.Application/User/AccountService.cs
+++ b/LifePayment/LifePayment.Application/User/AccountService.cs
@@ -5,9 +5,11 @@
 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;
@@ -16,6 +18,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;
@@ -27,6 +30,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;
@@ -42,6 +46,7 @@
                IRepository<User, Guid> userRepository,
                IIdentityUserAppService identityUserService,
                IRepository<LifePayUser, Guid> lifePayUserRepository,
+               IRepository<LifePayChannles, Guid> lifePayChannlesRepository,
                IRepository<UserChannle, Guid> userChannleRep,
                IDistributedCache<string> distributedCache)
         {
@@ -49,6 +54,7 @@
             _wxManager = wxManager;
             _identityUserService = identityUserService;
             _lifePayUserRepository = lifePayUserRepository;
+            _lifePayChannlesRepository = lifePayChannlesRepository;
             _authenticator = authenticator;
             _userRepository = userRepository;
             _userChannleRep = userChannleRep;
@@ -88,6 +94,28 @@
             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,
+                SwitchType = s.SwitchType,
+            }).ToListAsync();
+
+            BackClientUserInfoOutput result = new BackClientUserInfoOutput()
+            {
+                IsBackClientUser = CurrentUser.ClientId == Constant.ClientType.Back,
+                IsSystem = CurrentUser.IsSystem,
+                ChannleList = channleList
+            };
+            return result;
+        }
+
+
         #endregion
 
         #region 鎿嶄綔
@@ -105,7 +133,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)
             {
@@ -125,21 +152,60 @@
                 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();
+                var channlesNums = await _userChannleRep.Where(x => x.UserId == backClientUser.Id).Select(s => s.ChannleId).Distinct().ToListAsync();
+                channlesNum = await _lifePayChannlesRepository.Where(x => channlesNums.Contains(x.ChannlesNum)).Select(s => new ChannelOutput()
+                {
+                    Name = s.ChannlesName,
+                    ChannlesId = s.Id,
+                    ChannlesNum = s.ChannlesNum,
+                    SwitchType = s.SwitchType,
+                }).ToListAsync();
+            }
+
+            var result = await LifePayUserMesssageByPhone(lifeUser.PhoneNumber);
+            result.UserId = lifeUser.Id;
+            return result;
+        }
+
+        public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayUserMesssageByIduser(Guid id)
+        {
+            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 == phoneNumber).FirstOrDefaultAsync();
+            if (backClientUser != null)
+            {
+                var channlesNums = await _userChannleRep.Where(x => x.UserId == backClientUser.Id).Select(s => s.ChannleId).Distinct().ToListAsync();
+                channlesNum = await _lifePayChannlesRepository.Where(x => channlesNums.Contains(x.ChannlesNum)).Select(s => new ChannelOutput()
+                {
+                    Name = s.ChannlesName,
+                    ChannlesId = s.Id,
+                    ChannlesNum = s.ChannlesNum,
+                    SwitchType = s.SwitchType,
+                }).ToListAsync();
             }
 
             LifePayPhoneMesssageCodeLoginOutput result = new LifePayPhoneMesssageCodeLoginOutput()
             {
-                UserId = lifeUser.Id,
                 IsBackClientUser = backClientUser == null ? false : true,
                 ChannlesNum = channlesNum
             };
-
-
             return result;
         }
 
@@ -283,10 +349,15 @@
 
             return res.Id;
         }
+
+
+        
+
         #endregion
 
         #endregion
 
 
     }
+
 }
\ No newline at end of file

--
Gitblit v1.9.1