From aef74aff62bd9fc2d615f8b15a100432f2bca44f Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期三, 19 三月 2025 14:46:10 +0800
Subject: [PATCH] Merge branch 'master' of http://120.26.58.240:8888/r/LifePaymentApi

---
 LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml      |   30 ++++++
 LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs                    |    1 
 LifePayment/LifePayment.Domain/LifePay/LifePayUser.cs                           |   10 ++
 LifePayment/LifePayment.Application/User/AccountService.cs                      |   21 ++++
 LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs     |    2 
 LifePayment/LifePayment.Domain/Common/ChannelFilter.cs                          |   33 ++++++
 LifePayment/LifePayment.Application.Contracts/User/QrCodeLogin.cs               |    5 +
 LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs          |   10 ++
 LifePayment/LifePayment.Domain/Common/User.cs                                   |    7 -
 LifePayment/LifePayment.Application/User/UserRoleService.cs                     |   34 ++++++
 LifePayment/LifePayment.Domain/Common/ChannelHelper.cs                          |   47 +++++++++
 LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs                  |   25 +++++
 LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs |   24 ++++
 LifePayment/LifePayment.Domain/Common/UserChannle.cs                            |   19 +++
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs                   |    2 
 15 files changed, 262 insertions(+), 8 deletions(-)

diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
index 2a2181f..853c9a4 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
@@ -124,6 +124,16 @@
     /// </summary>
     public string PhoneNumber { get; set; }
 
+    /// <summary>
+    /// 鏈�鍚庣櫥褰曟笭閬�
+    /// </summary>
+    public string? CreationChannle { get; set; }
+
+    /// <summary>
+    /// 鏈�鍚庣櫥褰曟笭閬�
+    /// </summary>
+    public string? LastLoginChannle { get; set; }
+
     public DateTime? LastLoginTime { get; set; }
 
     public DateTime? CreationTime { get; set; }
diff --git a/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs b/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs
index d1f3f9e..74cce24 100644
--- a/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs
@@ -29,6 +29,11 @@
         public string[] RoleNames { get; set; }
 
         /// <summary>
+        /// 娓犻亾鍒楄〃
+        /// </summary>
+        public Guid[] ChannlesId { get; set; }
+
+        /// <summary>
         /// 缁勭粐鏋舵瀯鍏徃id
         /// </summary>
         public Guid? CompanyOrgId { get; set; }
@@ -131,6 +136,12 @@
         /// </summary>
         public IEnumerable<RoleDto> Roles { get; set; }
 
+
+        /// <summary>
+        /// 瑙掕壊淇℃伅
+        /// </summary>
+        public IEnumerable<UserChannleDto> Channles { get; set; }
+
         /// <summary>
         /// 澶囨敞
         /// </summary>
@@ -215,6 +226,19 @@
         public string Remark { get; set; }
     }
 
+    public class UserChannleDto
+    {
+        /// <summary>
+        /// 娓犻亾Id
+        /// </summary>
+        public Guid Id { get; set; }
+
+        /// <summary>
+        /// 娓犻亾鍚�
+        /// </summary>
+        public string Name { get; set; }
+    }
+
     public class GetRolesInput : PageInput
     {
         /// <summary>
diff --git a/LifePayment/LifePayment.Application.Contracts/User/QrCodeLogin.cs b/LifePayment/LifePayment.Application.Contracts/User/QrCodeLogin.cs
index de67ea7..2a96375 100644
--- a/LifePayment/LifePayment.Application.Contracts/User/QrCodeLogin.cs
+++ b/LifePayment/LifePayment.Application.Contracts/User/QrCodeLogin.cs
@@ -75,6 +75,11 @@
         public string[] RoleNames { get; set; }
 
         /// <summary>
+        /// 娓犻亾鍒楄〃
+        /// </summary>
+        public Guid[] ChannlesId { get; set; }
+
+        /// <summary>
         /// 灏忕▼搴廜penId
         /// </summary>
         public string OpenId { get; set; }
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index a18c99a..f87e0a1 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -175,6 +175,8 @@
                                                    new UserListOutput()
                                                    {
                                                        Id = x.Id,
+                                                       CreationChannle = string.IsNullOrEmpty(x.CreationChannleNum) ? "" : _lifePayChannlesRep.Where(c => c.ChannlesNum == x.CreationChannleNum).FirstOrDefault().ChannlesName,
+                                                       LastLoginChannle = string.IsNullOrEmpty(x.LastLoginChannleNum) ? "" : _lifePayChannlesRep.Where(c => c.ChannlesNum == x.LastLoginChannleNum).FirstOrDefault().ChannlesName,
                                                        PhoneNumber = x.PhoneNumber,
                                                        CreationTime = x.CreationTime,
                                                        LastLoginTime = x.LastLoginTime
diff --git a/LifePayment/LifePayment.Application/User/AccountService.cs b/LifePayment/LifePayment.Application/User/AccountService.cs
index 96b3ae8..0837679 100644
--- a/LifePayment/LifePayment.Application/User/AccountService.cs
+++ b/LifePayment/LifePayment.Application/User/AccountService.cs
@@ -6,6 +6,7 @@
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
 using System;
+using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using Volo.Abp;
@@ -27,6 +28,7 @@
         private readonly IConfiguration _configuration;
         private readonly IIdentityModelAuthenticationService _authenticator;
         private readonly IRepository<User, Guid> _userRepository;
+        private readonly IRepository<UserChannle, Guid> _userChannleRep;
         private readonly IIdentityUserAppService _identityUserService;
 
         public AccountService(
@@ -35,7 +37,8 @@
                IIdentityModelAuthenticationService authenticator,
                IRepository<User, Guid> userRepository,
                IIdentityUserAppService identityUserService,
-               IRepository<LifePayUser, Guid> lifePayUserRepository)
+               IRepository<LifePayUser, Guid> lifePayUserRepository,
+               IRepository<UserChannle, Guid> userChannleRep)
         {
             _configuration = configuration;
             _wxManager = wxManager;
@@ -43,6 +46,7 @@
             _lifePayUserRepository = lifePayUserRepository;
             _authenticator = authenticator;
             _userRepository = userRepository;
+            _userChannleRep = userChannleRep;
         }
 
         #region 鏌ヨ
@@ -92,6 +96,7 @@
                 lifeUser = new LifePayUser()
                 {
                     Id = GuidGenerator.Create(),
+                    CreationChannleNum = input.CheckChannelId,
                     PhoneNumber = input.PhoneNumber,
                     LastLoginTime = DateTime.Now
                 };
@@ -100,6 +105,7 @@
             }
             else
             {
+                lifeUser.LastLoginChannleNum = input.CheckChannelId;
                 lifeUser.LastLoginTime = DateTime.Now;
                 await _lifePayUserRepository.UpdateAsync(lifeUser);
             }
@@ -168,6 +174,19 @@
                 DepartmentOrgId = input.ClientId == LifePaymentConstant.ClientId.Back ? input.DepartmentOrgId : null,
                 CompanyOrgId = input.ClientId == LifePaymentConstant.ClientId.Back ? input.CompanyOrgId : null
             });
+
+            List<UserChannle> userChannles = new List<UserChannle>();
+            foreach (var item in input.ChannlesId)
+            {
+                userChannles.Add(new UserChannle()
+                {
+                    Id = Guid.NewGuid(),
+                    ChannleId = item,
+                    UserId = user.Id
+                });
+            }
+
+            await _userChannleRep.InsertManyAsync(userChannles);
             //if (input.ClientId == Constant.ClientType.Back)
             //{
             //    await _distributedEventBus.PublishAsync(new SendPhoneMessageInput
diff --git a/LifePayment/LifePayment.Application/User/UserRoleService.cs b/LifePayment/LifePayment.Application/User/UserRoleService.cs
index 057e212..97fbd78 100644
--- a/LifePayment/LifePayment.Application/User/UserRoleService.cs
+++ b/LifePayment/LifePayment.Application/User/UserRoleService.cs
@@ -1,4 +1,5 @@
 锘縰sing LifePayment.Application.Contracts;
+using LifePayment.Domain;
 using LifePayment.Domain.Models;
 using Microsoft.EntityFrameworkCore;
 using System;
@@ -8,6 +9,7 @@
 using Volo.Abp;
 using Volo.Abp.Application.Services;
 using Volo.Abp.Domain.Repositories;
+using Z.EntityFramework.Plus;
 using ZeroD.Util;
 
 namespace HumanResourcesServices.Application
@@ -16,21 +18,27 @@
     {
         private readonly IRepository<User, Guid> _userRepository;
         private readonly IRepository<Role, Guid> _roleRepository;
+        private readonly IRepository<LifePayChannles, Guid> _channleRepository;
         private readonly IRepository<UserRole, Guid> _userRoleRep;
+        private readonly IRepository<UserChannle, Guid> _userChannleRep;
 
         public UserRoleService(
                IRepository<User, Guid> userRepository,
                IRepository<Role, Guid> roleRepository,
-               IRepository<UserRole, Guid> userRoleRep)
+               IRepository<LifePayChannles, Guid> channleRepository,
+               IRepository<UserRole, Guid> userRoleRep,
+               IRepository<UserChannle, Guid> userChannleRep)
         {
             _userRepository = userRepository;
             _roleRepository = roleRepository;
+            _channleRepository = channleRepository;
             _userRoleRep = userRoleRep;
+            _userChannleRep = userChannleRep;
         }
 
         public async Task<PageOutput<UserDto>> GetBackClientUsers(GetBackClientUsersInput input)
         {
-            var query = _userRepository.Where(s => s.ClientId == Constant.ClientType.Back).Include(i => i.UserRoles).Select(u => new UserDto
+            var query = _userRepository.Where(s => s.ClientId == Constant.ClientType.Back).Include(i => i.UserRoles).Include(i => i.UserChannle).Select(u => new UserDto
             {
                 Id = u.Id,
                 UserName = u.UserName,
@@ -43,6 +51,13 @@
                         {
                             Id = r.Id,
                             Name = r.Name,
+                        },
+                Channles = from uc in u.UserChannle
+                           from c in _channleRepository.Where(s => s.Id == uc.ChannleId)
+                        select new UserChannleDto
+                        {
+                            Id = c.Id,
+                            Name = c.ChannlesName,
                         },
                 Remark = u.Remark,
                 CompanyOrgId = u.CompanyOrgId,
@@ -77,6 +92,21 @@
             entity.Remark = input.Remark;
             entity.DepartmentOrgId = input.DepartmentOrgId;
             entity.CompanyOrgId = input.CompanyOrgId;
+
+            var userchannle = await _userChannleRep.Where(s => s.UserId == input.Id).DeleteAsync();
+            List<UserChannle> userChannles = new List<UserChannle>();
+            foreach (var item in input.ChannlesId)
+            {
+                userChannles.Add(new UserChannle()
+                {
+                    Id = Guid.NewGuid(),
+                    ChannleId = item,
+                    UserId = entity.Id
+                });
+            }
+
+            await _userChannleRep.InsertManyAsync(userChannles);
+
             return Constant.SUCCESS;
         }
 
diff --git a/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs b/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs
new file mode 100644
index 0000000..4c7efd3
--- /dev/null
+++ b/LifePayment/LifePayment.Domain/Common/AbstractChannelFilter.cs
@@ -0,0 +1,25 @@
+锘縰sing LifePayment.Domain.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Volo.Abp.Auditing;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Entities;
+using Volo.Abp.Domain.Repositories;
+using Volo.Abp.Users;
+
+namespace LifePayment.Domain.Common
+{
+    public abstract class AbstractChannelFilter
+    {
+        public abstract Task<IQueryable<ChannelsBase>> GetChannelFilter(IQueryable<ChannelsBase> query);
+
+
+        public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+        protected ICurrentUser CurrentUser => LazyServiceProvider.LazyGetRequiredService<ICurrentUser>();
+
+        protected IRepository<UserChannle> UserChannleRepository => LazyServiceProvider.LazyGetRequiredService<IRepository<UserChannle>>();
+    }
+}
diff --git a/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs b/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs
new file mode 100644
index 0000000..f4d0a5e
--- /dev/null
+++ b/LifePayment/LifePayment.Domain/Common/ChannelFilter.cs
@@ -0,0 +1,33 @@
+锘縰sing LifePayment.Application.Contracts;
+using LifePayment.Domain;
+using LifePayment.Domain.Models;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Volo.Abp;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Entities;
+using Volo.Abp.Domain.Repositories;
+using Z.EntityFramework.Plus;
+using ZeroD.Util;
+
+namespace LifePayment.Domain.Common
+{
+    public class ChannelFilter : AbstractChannelFilter
+    {
+        public async override Task<IQueryable<ChannelsBase>> GetChannelFilter(IQueryable<ChannelsBase> query)
+        {
+            var queryUser = UserChannleRepository.Where(r => r.UserId == CurrentUser.Id).Select(s => s.ChannleId).ToList();
+            var queryResult = query.Where(s => queryUser.Contains(s.ChannleId));
+            return queryResult;
+        }
+    }
+
+    public class ChannelsBase : Entity<Guid>
+    {
+        public Guid ChannleId { get; set; }
+
+    }
+}
diff --git a/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs b/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs
new file mode 100644
index 0000000..cff865d
--- /dev/null
+++ b/LifePayment/LifePayment.Domain/Common/ChannelHelper.cs
@@ -0,0 +1,47 @@
+锘縰sing DynamicQuery.Net.Dto.Input;
+using DynamicQuery.Net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ZeroD.Application.Services.Dto;
+using Volo.Abp.Users;
+using Volo.Abp.Auditing;
+using Volo.Abp.Domain.Entities;
+
+namespace LifePayment.Domain
+{
+    public interface IChannelFilter
+    {
+
+        public Task<IQueryable<TEntity>> GetChannelFilter<TEntity, TKey>(IQueryable<TEntity> query)
+     where TEntity : class, IChannelData, IMayHaveCreator, IEntity<TKey>;
+        //public static IQueryable<T> GetChannleQuery<T>(this IQueryable<T> query, ChannelFilterInput input) where T : class, IChannelData
+        //{
+        //    if (query == null)
+        //    {
+        //        return query;
+        //    }
+        //    if (input.Channels != null && input.Channels.Any())
+        //    {
+        //        query = query.Where(r => input.Channels.Contains(r.ChannelId));
+        //    }
+        //    return query;
+        //}
+
+    }
+
+
+
+    public interface IChannelData
+    {
+       public Guid ChannleId { get; set; }
+    }
+
+    public class ChannelFilterInput
+    {
+        public List<Guid> Channels { get; set; } = new List<Guid>();
+    }
+
+}
diff --git a/LifePayment/LifePayment.Domain/Common/User.cs b/LifePayment/LifePayment.Domain/Common/User.cs
index 92cdc42..48ddd89 100644
--- a/LifePayment/LifePayment.Domain/Common/User.cs
+++ b/LifePayment/LifePayment.Domain/Common/User.cs
@@ -10,9 +10,8 @@
     {
         public User()
         {
-
             UserRoles = new HashSet<UserRole>();
-
+            UserChannle = new HashSet<UserChannle>();
         }
 
         /// <summary>
@@ -180,10 +179,8 @@
         /// </summary>
         public Guid? IndustrialParkId { get; set; }
 
-
-
         public ICollection<UserRole> UserRoles { get; set; }
 
-
+        public ICollection<UserChannle> UserChannle { get; set; }
     }
 }
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Domain/Common/UserChannle.cs b/LifePayment/LifePayment.Domain/Common/UserChannle.cs
new file mode 100644
index 0000000..770adbd
--- /dev/null
+++ b/LifePayment/LifePayment.Domain/Common/UserChannle.cs
@@ -0,0 +1,19 @@
+锘縰sing System;
+using Volo.Abp.Domain.Entities;
+
+namespace LifePayment.Domain.Models
+{
+    public class UserChannle : Entity<Guid>
+    {
+        /// <summary>
+        /// 鐢ㄦ埛Id
+        /// </summary>
+        public  Guid UserId { get; set; }
+
+        /// <summary>
+        /// 娓犻亾Id
+        /// </summary>
+        public  Guid ChannleId { get; set; }
+        public virtual User User { get; set; }
+    }
+}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Domain/LifePay/LifePayUser.cs b/LifePayment/LifePayment.Domain/LifePay/LifePayUser.cs
index bad9e84..5540d1f 100644
--- a/LifePayment/LifePayment.Domain/LifePay/LifePayUser.cs
+++ b/LifePayment/LifePayment.Domain/LifePay/LifePayUser.cs
@@ -20,8 +20,18 @@
         /// </summary>
         public string OpenId { get; set; }
 
+        /// <summary>
+        /// 娉ㄥ唽娓犻亾缂栧彿
+        /// </summary>
+        public string? CreationChannleNum { get; set; }
+
         public string UnionId { get; set; }
 
         public DateTime? LastLoginTime { get; set; }
+
+        /// <summary>
+        /// 鏈�鍚庣櫥褰曟笭閬撶紪鍙�
+        /// </summary>
+        public string? LastLoginChannleNum { get; set; }
     }
 }
\ No newline at end of file
diff --git a/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs b/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs
index e021985..4c5ff12 100644
--- a/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs
+++ b/LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs
@@ -35,6 +35,8 @@
 
         public virtual DbSet<UserRole> UserRoles { get; set; }
 
+        public virtual DbSet<UserChannle> UserChannle { get; set; }
+
         public virtual DbSet<OperateHistory> OperateHistory { get; set; }
 
         public virtual DbSet<LifePayChannles> LifePayChannles { get; set; }
diff --git a/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs b/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs
index 73175b7..9759f0f 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs
+++ b/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs
@@ -149,6 +149,7 @@
                 cacheOptions.KeyPrefix = "LifePaymentServices_";
                 cacheOptions.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromMinutes(20);
             });
+            this.Configure<OssSettings>(configuration.GetSection("ossSettings"));
             this.Configure<ACOOLYOption>(configuration.GetSection("ACOOLY"));
             this.Configure<Config>("AliPayEcsign", configuration.GetSection("AliPayEcsign"));
             this.Configure<InformationOption>(configuration.GetSection("WeiXinCgi"));
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index b32b266..cc63059 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -566,6 +566,16 @@
             鐢ㄦ埛鎵嬫満鍙�
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.UserListOutput.CreationChannle">
+            <summary>
+            鏈�鍚庣櫥褰曟笭閬�
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.UserListOutput.LastLoginChannle">
+            <summary>
+            鏈�鍚庣櫥褰曟笭閬�
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.LifePayOrderListOutput.PhoneNumber">
             <summary>
             鐢ㄦ埛鎵嬫満鍙�
@@ -1456,6 +1466,11 @@
             瑙掕壊
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.CreateBackClientUserInput.ChannlesId">
+            <summary>
+            娓犻亾鍒楄〃
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.CreateBackClientUserInput.CompanyOrgId">
             <summary>
             缁勭粐鏋舵瀯鍏徃id
@@ -1541,6 +1556,11 @@
             瑙掕壊淇℃伅
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.UserDto.Channles">
+            <summary>
+            瑙掕壊淇℃伅
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.UserDto.Remark">
             <summary>
             澶囨敞
@@ -1616,6 +1636,16 @@
             澶囨敞
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.UserChannleDto.Id">
+            <summary>
+            娓犻亾Id
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.UserChannleDto.Name">
+            <summary>
+            娓犻亾鍚�
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.GetRolesInput.QueryCondition">
             <summary>
             鏌ヨ鏉′欢锛氳鑹插悕绉�

--
Gitblit v1.9.1