feat(admin): 新增管理员角色、账单、订阅、套餐管理功能
- 新增 AdminRolesController 实现角色 CRUD 和权限管理 - 新增 BillingsController 实现账单查询功能 - 新增 SubscriptionsController 实现订阅管理功能 - 新增 TenantPackagesController 实现套餐管理功能 - 新增租户详情、配额使用、账单列表等查询功能 - 新增 TenantPackage、TenantSubscription 等领域实体 - 新增相关枚举:SubscriptionStatus、TenantPackageType 等 - 更新 appsettings 配置文件 - 更新权限授权策略提供者 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using MediatR;
|
||||
using TakeoutSaaS.Application.App.Tenants.Contracts;
|
||||
using TakeoutSaaS.Application.App.Tenants.Queries;
|
||||
using TakeoutSaaS.Domain.Tenants.Repositories;
|
||||
using TakeoutSaaS.Shared.Abstractions.Results;
|
||||
|
||||
namespace TakeoutSaaS.Application.App.Tenants.Handlers;
|
||||
|
||||
/// <summary>
|
||||
/// 获取租户账单列表查询处理器。
|
||||
/// </summary>
|
||||
public sealed class GetTenantBillingsQueryHandler(ITenantRepository tenantRepository)
|
||||
: IRequestHandler<GetTenantBillingsQuery, PagedResult<TenantBillingListDto>>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public async Task<PagedResult<TenantBillingListDto>> Handle(
|
||||
GetTenantBillingsQuery request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
// 1. 查询租户账单(分页)
|
||||
var (billings, totalCount) = await tenantRepository.GetBillingsAsync(
|
||||
request.TenantId,
|
||||
request.Page,
|
||||
request.PageSize,
|
||||
cancellationToken);
|
||||
|
||||
// 2. 获取租户名称
|
||||
var tenant = await tenantRepository.FindByIdAsync(request.TenantId, cancellationToken);
|
||||
var tenantName = tenant?.Name;
|
||||
|
||||
// 3. 映射为 DTO
|
||||
var items = billings.Select(b => new TenantBillingListDto
|
||||
{
|
||||
Id = b.Id,
|
||||
TenantId = b.TenantId,
|
||||
TenantName = tenantName,
|
||||
StatementNo = b.StatementNo,
|
||||
BillingType = b.BillingType,
|
||||
PeriodStart = b.PeriodStart,
|
||||
PeriodEnd = b.PeriodEnd,
|
||||
AmountDue = b.AmountDue,
|
||||
AmountPaid = b.AmountPaid,
|
||||
DiscountAmount = b.DiscountAmount,
|
||||
TaxAmount = b.TaxAmount,
|
||||
Currency = b.Currency,
|
||||
Status = b.Status,
|
||||
DueDate = b.DueDate,
|
||||
OverdueNotifiedAt = b.OverdueNotifiedAt,
|
||||
CreatedAt = b.CreatedAt,
|
||||
UpdatedAt = b.UpdatedAt
|
||||
}).ToList();
|
||||
|
||||
// 4. 返回分页结果
|
||||
return new PagedResult<TenantBillingListDto>(items, totalCount, request.Page, request.PageSize);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user