From 1c54e47b9ef030609bf22f98846c6a852f4ae531 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sat, 30 Aug 2025 17:55:13 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EAI=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E6=9C=8D=E5=8A=A1=E5=8F=8A=E6=89=A9=E5=B1=95=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87userId=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/AiUserRoleMenuDto.cs | 11 ++++++ .../Services/AiAccountService.cs | 39 +++++++++++++++++++ .../IServices/IAccountService.cs | 3 +- .../Services/AccountService.cs | 3 +- Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs | 2 +- 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/AiUserRoleMenuDto.cs create mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AiAccountService.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/AiUserRoleMenuDto.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/AiUserRoleMenuDto.cs new file mode 100644 index 00000000..d3297f59 --- /dev/null +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/AiUserRoleMenuDto.cs @@ -0,0 +1,11 @@ +using Yi.Framework.Rbac.Domain.Shared.Dtos; + +namespace Yi.Framework.AiHub.Application.Contracts.Dtos; + +public class AiUserRoleMenuDto:UserRoleMenuDto +{ + /// + /// 是否绑定服务号 + /// + public bool IsBindFuwuhao { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AiAccountService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AiAccountService.cs new file mode 100644 index 00000000..e5290f0d --- /dev/null +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/AiAccountService.cs @@ -0,0 +1,39 @@ +using Mapster; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Services; +using Volo.Abp.Users; +using Yi.Framework.AiHub.Application.Contracts.Dtos; +using Yi.Framework.AiHub.Domain.Entities; +using Yi.Framework.Rbac.Application.Contracts.IServices; +using Yi.Framework.Rbac.Domain.Shared.Dtos; +using Yi.Framework.SqlSugarCore.Abstractions; + +namespace Yi.Framework.AiHub.Application.Services; + +public class AiAccountService : ApplicationService +{ + private IAccountService _accountService; + private ISqlSugarRepository _userRepository; + + public AiAccountService(IAccountService accountService, ISqlSugarRepository userRepository) + { + _accountService = accountService; + _userRepository = userRepository; + } + + /// + /// 获取ai用户信息 + /// + /// + [Authorize] + [HttpGet("account/ai")] + public async Task GetAsync() + { + var userId = CurrentUser.GetId(); + var userAccount = await _accountService.GetAsync(null, null, userId: CurrentUser.GetId()); + var output = userAccount.Adapt(); + output.IsBindFuwuhao = await _userRepository.IsAnyAsync(x => userId == x.UserId); + return output; + } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs index 1dd7c6e6..d0c21f00 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application.Contracts/IServices/IAccountService.cs @@ -24,8 +24,9 @@ namespace Yi.Framework.Rbac.Application.Contracts.IServices /// /// /// + /// /// - Task GetAsync(string? userName, long? phone); + Task GetAsync(string? userName, long? phone,Guid? userId = null); /// /// 校验电话验证码,需要与电话号码绑定 diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs index b898feda..5f9c6654 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Application/Services/AccountService.cs @@ -284,11 +284,12 @@ namespace Yi.Framework.Rbac.Application.Services } [RemoteService(isEnabled: false)] - public async Task GetAsync(string? userName, long? phone) + public async Task GetAsync(string? userName, long? phone = null, Guid? userId = null) { var user = await _userRepository._DbQueryable .WhereIF(userName is not null, x => x.UserName == userName) .WhereIF(phone is not null, x => x.Phone == phone) + .WhereIF(userId is not null, x => x.Id == userId) .Where(x => x.State == true) .FirstAsync(); diff --git a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs index 4c55ef9c..9e08520e 100644 --- a/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs +++ b/Yi.Abp.Net8/src/Yi.Abp.Web/YiAbpWebModule.cs @@ -106,7 +106,7 @@ namespace Yi.Abp.Web //本地开发环境,可以禁用作业执行 if (host.IsDevelopment()) { - Configure(options => { options.IsEnabled = true; }); + Configure(options => { options.IsEnabled = false; }); } //请求日志 From 1b00e505b7e63fb00c232cab5a60c4f9cae8134c Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sat, 30 Aug 2025 18:02:46 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E4=BA=8C=E7=BB=B4=E7=A0=81=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E7=99=BB=E5=BD=95=E7=94=A8=E6=88=B7=E7=9A=84?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/FuwuhaoService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs index f47eb872..c58c38dc 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs @@ -140,6 +140,11 @@ public class FuwuhaoService : ApplicationService [HttpPost("fuwuhao/qrcode")] public async Task GetQrCodeAsync([FromQuery] SceneTypeEnum sceneType) { + if (sceneType == SceneTypeEnum.Bind && CurrentUser.Id is null) + { + throw new UserFriendlyException("绑定微信,需登录用户,请重新登录后重试"); + } + //生成一个随机场景值 var scene = Guid.NewGuid().ToString("N"); var qrCodeUrl = await _fuwuhaoManager.CreateQrCodeAsync(scene); From 72387235a07e6e56bc0fde6f8d6d66711d6ea242 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sat, 30 Aug 2025 21:17:25 +0800 Subject: [PATCH 3/5] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=BC=8F=E9=94=81=E8=8E=B7=E5=8F=96=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E8=B6=85=E6=97=B6=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs | 3 +-- .../rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs index c58c38dc..53262863 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs @@ -95,8 +95,7 @@ public class FuwuhaoService : ApplicationService //制作幂等 await using (var handle = - await DistributedLock.TryAcquireLockAsync($"Yi:fuwuhao:callbacklock:{scene}", - TimeSpan.FromSeconds(60))) + await DistributedLock.TryAcquireLockAsync($"Yi:fuwuhao:callbacklock:{scene}")) { if (handle == null) { diff --git a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs index 2185bcc9..a4f226e4 100644 --- a/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs +++ b/Yi.Abp.Net8/module/rbac/Yi.Framework.Rbac.Domain/Managers/AccountManager.cs @@ -308,8 +308,7 @@ namespace Yi.Framework.Rbac.Domain.Managers //制作幂等 await using (var handle = - await DistributedLock.TryAcquireLockAsync($"{CacheKeyPrefix}Register:Lock:{userName}", - TimeSpan.FromSeconds(60))) + await DistributedLock.TryAcquireLockAsync($"{CacheKeyPrefix}Register:Lock:{userName}")) { if (handle is null) { From 96a09d89800bf348373bb28dac5830ae37b4c5a5 Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sat, 30 Aug 2025 21:58:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=97=B6=E8=BF=94=E5=9B=9E=E5=80=BC=E6=9C=AA?= =?UTF-8?q?=E5=8C=85=E5=90=AB=E7=94=A8=E6=88=B7ID=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Managers/Fuwuhao/FuwuhaoManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/Fuwuhao/FuwuhaoManager.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/Fuwuhao/FuwuhaoManager.cs index b08e2a2b..e733a6ba 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/Fuwuhao/FuwuhaoManager.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Domain/Managers/Fuwuhao/FuwuhaoManager.cs @@ -240,7 +240,7 @@ public class FuwuhaoManager : DomainService //说明没有绑定过,直接绑定 await _userRepository.InsertAsync(new AiUserExtraInfoEntity(bindUserId.Value, openId)); - return (SceneResultEnum.Bind,null); + return (SceneResultEnum.Bind,bindUserId); break; default: throw new ArgumentOutOfRangeException(nameof(sceneType), sceneType, null); From 25c736dc0a9fcd6c8776ec9933b06f1fbe0fd52a Mon Sep 17 00:00:00 2001 From: ccnetcore Date: Sat, 30 Aug 2025 22:07:09 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=89=AB=E7=A0=81?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E5=9C=A8=E9=9D=9E=E7=AD=89=E5=BE=85=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8B=E4=BB=8D=E8=A2=AB=E5=A4=84=E7=90=86=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/FuwuhaoService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs index 53262863..160f3fab 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/FuwuhaoService.cs @@ -108,6 +108,11 @@ public class FuwuhaoService : ApplicationService return "success"; // 跳过直接返回成功 } + if (cache.SceneResult != SceneResultEnum.Wait) + { + return "success"; // 跳过直接返回成功 + } + //根据操作类型,进行业务处理,返回处理结果,再写入缓存,10s过去,相当于用户10s扫完app后,轮询要在10秒内完成 var scenResult = await _fuwuhaoManager.CallBackHandlerAsync(cache.SceneType, body.FromUserName, cache.UserId);