feat(finance): add overview dashboard and platform fee rate
This commit is contained in:
@@ -0,0 +1,211 @@
|
||||
using TakeoutSaaS.Domain.Finance.Enums;
|
||||
using TakeoutSaaS.Domain.Orders.Enums;
|
||||
|
||||
namespace TakeoutSaaS.Domain.Finance.Models;
|
||||
|
||||
/// <summary>
|
||||
/// 财务概览核心指标快照。
|
||||
/// </summary>
|
||||
public sealed record FinanceOverviewSummarySnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// 今日营业额(支付成功总额)。
|
||||
/// </summary>
|
||||
public decimal TodayGrossRevenue { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 昨日营业额(支付成功总额)。
|
||||
/// </summary>
|
||||
public decimal YesterdayGrossRevenue { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 今日实收(营业额 - 退款)。
|
||||
/// </summary>
|
||||
public decimal TodayNetReceived { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 昨日实收(营业额 - 退款)。
|
||||
/// </summary>
|
||||
public decimal YesterdayNetReceived { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 今日退款。
|
||||
/// </summary>
|
||||
public decimal TodayRefundAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 昨日退款。
|
||||
/// </summary>
|
||||
public decimal YesterdayRefundAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 今日总成本。
|
||||
/// </summary>
|
||||
public decimal TodayTotalCost { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 昨日总成本。
|
||||
/// </summary>
|
||||
public decimal YesterdayTotalCost { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前可提现余额(累计净收入口径)。
|
||||
/// </summary>
|
||||
public decimal WithdrawableBalance { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 上周同日可提现余额(用于环比)。
|
||||
/// </summary>
|
||||
public decimal WithdrawableBalanceLastWeek { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 收入趋势点快照。
|
||||
/// </summary>
|
||||
public sealed record FinanceOverviewIncomeTrendPointSnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务日期(UTC 日期)。
|
||||
/// </summary>
|
||||
public required DateTime BusinessDate { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 实收金额。
|
||||
/// </summary>
|
||||
public decimal NetReceivedAmount { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 利润趋势点快照。
|
||||
/// </summary>
|
||||
public sealed record FinanceOverviewProfitTrendPointSnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务日期(UTC 日期)。
|
||||
/// </summary>
|
||||
public required DateTime BusinessDate { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 营收金额(支付成功总额)。
|
||||
/// </summary>
|
||||
public decimal RevenueAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 成本金额。
|
||||
/// </summary>
|
||||
public decimal CostAmount { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 净利润金额。
|
||||
/// </summary>
|
||||
public decimal NetProfitAmount { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 收入构成项快照。
|
||||
/// </summary>
|
||||
public sealed record FinanceOverviewIncomeCompositionSnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// 渠道。
|
||||
/// </summary>
|
||||
public required DeliveryType Channel { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 金额。
|
||||
/// </summary>
|
||||
public decimal Amount { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 成本构成项快照。
|
||||
/// </summary>
|
||||
public sealed record FinanceOverviewCostCompositionSnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类编码(food/labor/fixed/packaging/platform)。
|
||||
/// </summary>
|
||||
public required string CategoryCode { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 金额。
|
||||
/// </summary>
|
||||
public decimal Amount { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TOP 商品快照。
|
||||
/// </summary>
|
||||
public sealed record FinanceOverviewTopProductSnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// 商品标识。
|
||||
/// </summary>
|
||||
public long ProductId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品名称。
|
||||
/// </summary>
|
||||
public required string ProductName { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 销量。
|
||||
/// </summary>
|
||||
public int SalesQuantity { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 营收金额。
|
||||
/// </summary>
|
||||
public decimal RevenueAmount { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 财务概览页面快照。
|
||||
/// </summary>
|
||||
public sealed record FinanceOverviewDashboardSnapshot
|
||||
{
|
||||
/// <summary>
|
||||
/// 统计维度。
|
||||
/// </summary>
|
||||
public required FinanceCostDimension Dimension { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 门店标识(租户维度为空)。
|
||||
/// </summary>
|
||||
public long? StoreId { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 核心指标汇总。
|
||||
/// </summary>
|
||||
public required FinanceOverviewSummarySnapshot Summary { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 近 30 天收入趋势。
|
||||
/// </summary>
|
||||
public IReadOnlyList<FinanceOverviewIncomeTrendPointSnapshot> IncomeTrend { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 近 30 天利润趋势。
|
||||
/// </summary>
|
||||
public IReadOnlyList<FinanceOverviewProfitTrendPointSnapshot> ProfitTrend { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 收入构成。
|
||||
/// </summary>
|
||||
public IReadOnlyList<FinanceOverviewIncomeCompositionSnapshot> IncomeComposition { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// 成本构成。
|
||||
/// </summary>
|
||||
public IReadOnlyList<FinanceOverviewCostCompositionSnapshot> CostComposition { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// TOP10 商品营收排行。
|
||||
/// </summary>
|
||||
public IReadOnlyList<FinanceOverviewTopProductSnapshot> TopProducts { get; init; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// TOP 榜单统计周期内商品总营收。
|
||||
/// </summary>
|
||||
public decimal TopProductTotalRevenue { get; init; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using TakeoutSaaS.Domain.Finance.Enums;
|
||||
using TakeoutSaaS.Domain.Finance.Models;
|
||||
|
||||
namespace TakeoutSaaS.Domain.Finance.Repositories;
|
||||
|
||||
/// <summary>
|
||||
/// 财务概览仓储契约。
|
||||
/// </summary>
|
||||
public interface IFinanceOverviewRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取财务概览页快照。
|
||||
/// </summary>
|
||||
/// <param name="tenantId">租户标识。</param>
|
||||
/// <param name="dimension">统计维度。</param>
|
||||
/// <param name="storeId">门店标识(门店维度必填)。</param>
|
||||
/// <param name="currentUtc">当前 UTC 时间。</param>
|
||||
/// <param name="cancellationToken">取消标记。</param>
|
||||
Task<FinanceOverviewDashboardSnapshot> GetDashboardSnapshotAsync(
|
||||
long tenantId,
|
||||
FinanceCostDimension dimension,
|
||||
long? storeId,
|
||||
DateTime currentUtc,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
@@ -23,6 +23,11 @@ public sealed class StoreFee : MultiTenantEntityBase
|
||||
/// </summary>
|
||||
public decimal BaseDeliveryFee { get; set; } = 0m;
|
||||
|
||||
/// <summary>
|
||||
/// 平台服务费率(%)。
|
||||
/// </summary>
|
||||
public decimal PlatformServiceRate { get; set; } = 0m;
|
||||
|
||||
/// <summary>
|
||||
/// 打包费模式。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user