From 2ece861c311599d31c96ab36fcf3b19d6208d552 Mon Sep 17 00:00:00 2001 From: zhengyuxuan <zhengyuxuan1995> Date: 星期三, 19 三月 2025 13:13:39 +0800 Subject: [PATCH] fix:账号管理新增渠道 --- LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs | 10 +++ LifePayment/LifePayment.Domain/Common/User.cs | 7 - LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml | 30 ++++++++++ LifePayment/LifePayment.Application/User/UserRoleService.cs | 34 ++++++++++ LifePayment/LifePayment.Domain/LifePay/LifePayUser.cs | 10 +++ LifePayment/LifePayment.Application.Contracts/User/CreateBackClientUserInput.cs | 24 ++++++++ LifePayment/LifePayment.Domain/Common/UserChannle.cs | 19 ++++++ LifePayment/LifePayment.Application/User/AccountService.cs | 2 LifePayment/LifePayment.EntityFrameworkCore/LifePaymentServicesDbContext.cs | 2 LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 3 + 10 files changed, 134 insertions(+), 7 deletions(-) diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs index 2a2181f..38e0d09 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/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs index 2f04efb..861b680 100644 --- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs +++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs @@ -171,10 +171,13 @@ /// <returns></returns> public async Task<PageOutput<UserListOutput>> GetUserPage(PageInput input) { + var channel = await _lifePayChannlesRep.ToListAsync(); return await _lifePayUserRepository.Select(x => new UserListOutput() { Id = x.Id, + //CreationChannle = string.IsNullOrEmpty(x.CreationChannleNum) ? "" : channel.Where(c => c.ChannlesNum == x.CreationChannleNum).FirstOrDefault().ChannlesName, + //LastLoginChannle = string.IsNullOrEmpty(x.LastLoginChannleNum) ? "" : channel.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..bf2d4e3 100644 --- a/LifePayment/LifePayment.Application/User/AccountService.cs +++ b/LifePayment/LifePayment.Application/User/AccountService.cs @@ -92,6 +92,7 @@ lifeUser = new LifePayUser() { Id = GuidGenerator.Create(), + CreationChannleNum = input.CheckChannelId, PhoneNumber = input.PhoneNumber, LastLoginTime = DateTime.Now }; @@ -100,6 +101,7 @@ } else { + lifeUser.LastLoginChannleNum = input.CheckChannelId; lifeUser.LastLoginTime = DateTime.Now; await _lifePayUserRepository.UpdateAsync(lifeUser); } 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/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..b4b9c3d --- /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 virtual Guid UserId { get; set; } + + /// <summary> + /// 娓犻亾Id + /// </summary> + public virtual 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..e326820 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/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