From da23d17af85299ae97c45507b47ec44860e93471 Mon Sep 17 00:00:00 2001 From: chenchun Date: Fri, 14 Nov 2025 18:00:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=BA=E5=B0=8A=E4=BA=AB=E5=8C=85=20?= =?UTF-8?q?Token=20=E5=88=97=E8=A1=A8=E6=96=B0=E5=A2=9E=E6=8C=89=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=85=8D=E8=B4=B9=E8=BF=87=E6=BB=A4=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AF=B7=E6=B1=82=20DTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 PremiumTokenUsageGetListInput,包含 IsFree 过滤项并继承分页 DTO - 修改 UsageStatisticsService.GetPremiumTokenUsageListAsync 签名为使用新的输入 DTO,并根据 IsFree 添加 WhereIF 过滤 - 微调 DTO 导入与格式化(PremiumTokenUsageGetListOutput) --- .../PremiumTokenUsageGetListInput.cs | 12 +++ .../PremiumTokenUsageGetListOutput.cs | 81 ++++++++++--------- .../Services/UsageStatisticsService.cs | 10 ++- 3 files changed, 60 insertions(+), 43 deletions(-) create mode 100644 Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListInput.cs diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListInput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListInput.cs new file mode 100644 index 00000000..e3766e10 --- /dev/null +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListInput.cs @@ -0,0 +1,12 @@ +using Volo.Abp.Application.Dtos; +using Yi.Framework.Ddd.Application.Contracts; + +namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics; + +public class PremiumTokenUsageGetListInput : PagedAllResultRequestDto +{ + /// + /// 是否免费 + /// + public bool? IsFree { get; set; } +} \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs index 0027df6f..d3b29ffc 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application.Contracts/Dtos/UsageStatistics/PremiumTokenUsageGetListOutput.cs @@ -1,56 +1,57 @@ using Volo.Abp.Application.Dtos; +using Yi.Framework.Ddd.Application.Contracts; namespace Yi.Framework.AiHub.Application.Contracts.Dtos.UsageStatistics; public class PremiumTokenUsageGetListOutput : CreationAuditedEntityDto { - /// - /// id - /// - public Guid Id { get; set; } + /// + /// id + /// + public Guid Id { get; set; } - /// - /// 用户ID - /// - public Guid UserId { get; set; } + /// + /// 用户ID + /// + public Guid UserId { get; set; } - /// - /// 包名称 - /// - public string PackageName { get; set; } + /// + /// 包名称 + /// + public string PackageName { get; set; } - /// - /// 总用量(总token数) - /// - public long TotalTokens { get; set; } + /// + /// 总用量(总token数) + /// + public long TotalTokens { get; set; } - /// - /// 剩余用量(剩余token数) - /// - public long RemainingTokens { get; set; } + /// + /// 剩余用量(剩余token数) + /// + public long RemainingTokens { get; set; } - /// - /// 已使用token数 - /// - public long UsedTokens { get; set; } + /// + /// 已使用token数 + /// + public long UsedTokens { get; set; } - /// - /// 到期时间 - /// - public DateTime? ExpireDateTime { get; set; } + /// + /// 到期时间 + /// + public DateTime? ExpireDateTime { get; set; } - /// - /// 是否激活 - /// - public bool IsActive { get; set; } + /// + /// 是否激活 + /// + public bool IsActive { get; set; } - /// - /// 购买金额 - /// - public decimal PurchaseAmount { get; set; } + /// + /// 购买金额 + /// + public decimal PurchaseAmount { get; set; } - /// - /// 备注 - /// - public string? Remark { get; set; } + /// + /// 备注 + /// + public string? Remark { get; set; } } \ No newline at end of file diff --git a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs index bd00a6de..ffb49bb9 100644 --- a/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs +++ b/Yi.Abp.Net8/module/ai-hub/Yi.Framework.AiHub.Application/Services/UsageStatisticsService.cs @@ -147,15 +147,19 @@ public class UsageStatisticsService : ApplicationService, IUsageStatisticsServic /// /// [HttpGet("usage-statistics/premium-token-usage/list")] - public async Task> GetPremiumTokenUsageListAsync(PagedAllResultRequestDto input) + public async Task> GetPremiumTokenUsageListAsync( + PremiumTokenUsageGetListInput input) { var userId = CurrentUser.GetId(); RefAsync total = 0; // 获取尊享包Token信息 var entities = await _premiumPackageRepository._DbQueryable .Where(x => x.UserId == userId) - .OrderByDescending(x=>x.CreationTime) + .WhereIF(input.IsFree == true, x => x.PurchaseAmount > 0) + .WhereIF(input.IsFree == false, x => x.PurchaseAmount == 0) + .OrderByDescending(x => x.CreationTime) .ToPageListAsync(input.SkipCount, input.MaxResultCount, total); - return new PagedResultDto(total, entities.Adapt>()); + return new PagedResultDto(total, + entities.Adapt>()); } } \ No newline at end of file