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:
MSuMshk
2026-02-02 09:11:44 +08:00
parent 54feee53b8
commit 0f900e108d
97 changed files with 7047 additions and 12 deletions

View File

@@ -0,0 +1,101 @@
using MediatR;
using TakeoutSaaS.Application.App.TenantPackages.Contracts;
using TakeoutSaaS.Domain.Tenants.Enums;
namespace TakeoutSaaS.Application.App.TenantPackages.Commands;
/// <summary>
/// 创建租户套餐命令。
/// </summary>
public sealed record CreateTenantPackageCommand : IRequest<TenantPackageListDto>
{
/// <summary>
/// 套餐名称。
/// </summary>
public string Name { get; init; } = string.Empty;
/// <summary>
/// 套餐描述。
/// </summary>
public string? Description { get; init; }
/// <summary>
/// 套餐类型。
/// </summary>
public TenantPackageType PackageType { get; init; }
/// <summary>
/// 月付价格。
/// </summary>
public decimal? MonthlyPrice { get; init; }
/// <summary>
/// 年付价格。
/// </summary>
public decimal? YearlyPrice { get; init; }
/// <summary>
/// 最大门店数。
/// </summary>
public int? MaxStoreCount { get; init; }
/// <summary>
/// 最大账号数。
/// </summary>
public int? MaxAccountCount { get; init; }
/// <summary>
/// 最大存储空间GB
/// </summary>
public int? MaxStorageGb { get; init; }
/// <summary>
/// 最大短信额度。
/// </summary>
public int? MaxSmsCredits { get; init; }
/// <summary>
/// 最大配送订单数。
/// </summary>
public int? MaxDeliveryOrders { get; init; }
/// <summary>
/// 功能策略 JSON。
/// </summary>
public string? FeaturePoliciesJson { get; init; }
/// <summary>
/// 是否启用。
/// </summary>
public bool IsActive { get; init; }
/// <summary>
/// 是否公开可见。
/// </summary>
public bool IsPublicVisible { get; init; }
/// <summary>
/// 是否允许新租户购买。
/// </summary>
public bool IsAllowNewTenantPurchase { get; init; }
/// <summary>
/// 发布状态。
/// </summary>
public TenantPackagePublishStatus PublishStatus { get; init; }
/// <summary>
/// 是否推荐。
/// </summary>
public bool IsRecommended { get; init; }
/// <summary>
/// 标签列表。
/// </summary>
public string[] Tags { get; init; } = [];
/// <summary>
/// 排序序号。
/// </summary>
public int SortOrder { get; init; }
}

View File

@@ -0,0 +1,14 @@
using MediatR;
namespace TakeoutSaaS.Application.App.TenantPackages.Commands;
/// <summary>
/// 删除租户套餐命令(软删除)。
/// </summary>
public sealed record DeleteTenantPackageCommand : IRequest<bool>
{
/// <summary>
/// 套餐 ID。
/// </summary>
public long TenantPackageId { get; init; }
}

View File

@@ -0,0 +1,106 @@
using MediatR;
using TakeoutSaaS.Application.App.TenantPackages.Contracts;
using TakeoutSaaS.Domain.Tenants.Enums;
namespace TakeoutSaaS.Application.App.TenantPackages.Commands;
/// <summary>
/// 更新租户套餐命令。
/// </summary>
public sealed record UpdateTenantPackageCommand : IRequest<TenantPackageListDto?>
{
/// <summary>
/// 套餐 ID。
/// </summary>
public long TenantPackageId { get; init; }
/// <summary>
/// 套餐名称。
/// </summary>
public string Name { get; init; } = string.Empty;
/// <summary>
/// 套餐描述。
/// </summary>
public string? Description { get; init; }
/// <summary>
/// 套餐类型。
/// </summary>
public TenantPackageType PackageType { get; init; }
/// <summary>
/// 月付价格。
/// </summary>
public decimal? MonthlyPrice { get; init; }
/// <summary>
/// 年付价格。
/// </summary>
public decimal? YearlyPrice { get; init; }
/// <summary>
/// 最大门店数。
/// </summary>
public int? MaxStoreCount { get; init; }
/// <summary>
/// 最大账号数。
/// </summary>
public int? MaxAccountCount { get; init; }
/// <summary>
/// 最大存储空间GB
/// </summary>
public int? MaxStorageGb { get; init; }
/// <summary>
/// 最大短信额度。
/// </summary>
public int? MaxSmsCredits { get; init; }
/// <summary>
/// 最大配送订单数。
/// </summary>
public int? MaxDeliveryOrders { get; init; }
/// <summary>
/// 功能策略 JSON。
/// </summary>
public string? FeaturePoliciesJson { get; init; }
/// <summary>
/// 是否启用。
/// </summary>
public bool IsActive { get; init; }
/// <summary>
/// 是否公开可见。
/// </summary>
public bool IsPublicVisible { get; init; }
/// <summary>
/// 是否允许新租户购买。
/// </summary>
public bool IsAllowNewTenantPurchase { get; init; }
/// <summary>
/// 发布状态。
/// </summary>
public TenantPackagePublishStatus PublishStatus { get; init; }
/// <summary>
/// 是否推荐。
/// </summary>
public bool IsRecommended { get; init; }
/// <summary>
/// 标签列表。
/// </summary>
public string[] Tags { get; init; } = [];
/// <summary>
/// 排序序号。
/// </summary>
public int SortOrder { get; init; }
}