feat: 套餐发布状态与可见/可购开关

This commit is contained in:
2025-12-15 17:29:41 +08:00
parent e6a66b109a
commit 2778a4ebdf
15 changed files with 7022 additions and 9 deletions

View File

@@ -65,10 +65,25 @@ public sealed record CreateTenantPackageCommand : IRequest<TenantPackageDto>
public string? FeaturePoliciesJson { get; init; }
/// <summary>
/// 是否可售
/// 是否仍启用(平台控制)
/// </summary>
public bool IsActive { get; init; } = true;
/// <summary>
/// 是否对外可见(展示页/套餐列表可见性)。
/// </summary>
public bool IsPublicVisible { get; init; } = true;
/// <summary>
/// 是否允许新租户购买/选择(仅影响新购)。
/// </summary>
public bool IsAllowNewTenantPurchase { get; init; } = true;
/// <summary>
/// 发布状态(草稿/已发布)。
/// </summary>
public TenantPackagePublishStatus PublishStatus { get; init; } = TenantPackagePublishStatus.Published;
/// <summary>
/// 展示排序,数值越小越靠前。
/// </summary>

View File

@@ -70,10 +70,25 @@ public sealed record UpdateTenantPackageCommand : IRequest<TenantPackageDto?>
public string? FeaturePoliciesJson { get; init; }
/// <summary>
/// 是否可售
/// 是否仍启用(平台控制)
/// </summary>
public bool IsActive { get; init; } = true;
/// <summary>
/// 是否对外可见(展示页/套餐列表可见性)。
/// </summary>
public bool IsPublicVisible { get; init; } = true;
/// <summary>
/// 是否允许新租户购买/选择(仅影响新购)。
/// </summary>
public bool IsAllowNewTenantPurchase { get; init; } = true;
/// <summary>
/// 发布状态(草稿/已发布)。
/// </summary>
public TenantPackagePublishStatus PublishStatus { get; init; } = TenantPackagePublishStatus.Published;
/// <summary>
/// 展示排序,数值越小越靠前。
/// </summary>

View File

@@ -71,10 +71,25 @@ public sealed class TenantPackageDto
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>

View File

@@ -38,6 +38,9 @@ public sealed class CreateTenantPackageCommandHandler(ITenantPackageRepository p
MaxDeliveryOrders = request.MaxDeliveryOrders,
FeaturePoliciesJson = request.FeaturePoliciesJson,
IsActive = request.IsActive,
IsPublicVisible = request.IsPublicVisible,
IsAllowNewTenantPurchase = request.IsAllowNewTenantPurchase,
PublishStatus = request.PublishStatus,
SortOrder = request.SortOrder
};

View File

@@ -15,8 +15,8 @@ public sealed class GetPublicTenantPackagesQueryHandler(ITenantPackageRepository
/// <inheritdoc />
public async Task<PagedResult<TenantPackageDto>> Handle(GetPublicTenantPackagesQuery request, CancellationToken cancellationToken)
{
// 1. 仅查询启用套餐
var packages = await packageRepository.SearchAsync(null, true, cancellationToken);
// 1. 仅查询公共可选购套餐(已发布 + 对外可见 + 允许新购 + 启用)
var packages = await packageRepository.SearchPublicPurchasableAsync(cancellationToken);
// 2. 规范化分页参数
var pageIndex = request.Page <= 0 ? 1 : request.Page;
var size = request.PageSize <= 0 ? 20 : request.PageSize;

View File

@@ -42,6 +42,9 @@ public sealed class UpdateTenantPackageCommandHandler(ITenantPackageRepository p
package.MaxDeliveryOrders = request.MaxDeliveryOrders;
package.FeaturePoliciesJson = request.FeaturePoliciesJson;
package.IsActive = request.IsActive;
package.IsPublicVisible = request.IsPublicVisible;
package.IsAllowNewTenantPurchase = request.IsAllowNewTenantPurchase;
package.PublishStatus = request.PublishStatus;
package.SortOrder = request.SortOrder;
// 4. 持久化并返回

View File

@@ -138,6 +138,9 @@ internal static class TenantMapping
MaxDeliveryOrders = package.MaxDeliveryOrders,
FeaturePoliciesJson = package.FeaturePoliciesJson,
IsActive = package.IsActive,
IsPublicVisible = package.IsPublicVisible,
IsAllowNewTenantPurchase = package.IsAllowNewTenantPurchase,
PublishStatus = package.PublishStatus,
SortOrder = package.SortOrder
};