重构账单查询sql
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 26s
Docker Build & Deploy / Deploy to Production (push) Successful in 7s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 2s
Docker Build & Deploy / WeChat Notification (push) Successful in 2s

This commit is contained in:
SunCheng
2026-01-28 10:58:15 +08:00
parent 5c9d7c5db1
commit b71eadd4f9
19 changed files with 1433 additions and 730 deletions

View File

@@ -11,7 +11,7 @@ public interface IBudgetSavingsService
public class BudgetSavingsService(
IBudgetRepository budgetRepository,
IBudgetArchiveRepository budgetArchiveRepository,
ITransactionRecordRepository transactionsRepository,
ITransactionStatisticsService transactionStatisticsService,
IConfigService configService,
IDateTimeProvider dateTimeProvider
) : IBudgetSavingsService
@@ -59,7 +59,7 @@ public class BudgetSavingsService(
int year,
int month)
{
var transactionClassify = await transactionsRepository.GetAmountGroupByClassifyAsync(
var transactionClassify = await transactionStatisticsService.GetAmountGroupByClassifyAsync(
new DateTime(year, month, 1),
new DateTime(year, month, 1).AddMonths(1)
);
@@ -412,7 +412,7 @@ public class BudgetSavingsService(
{
// 因为非当前月份的读取归档数据,这边依然是读取当前月份的数据
var currentMonth = dateTimeProvider.Now.Month;
var transactionClassify = await transactionsRepository.GetAmountGroupByClassifyAsync(
var transactionClassify = await transactionStatisticsService.GetAmountGroupByClassifyAsync(
new DateTime(year, currentMonth, 1),
new DateTime(year, currentMonth, 1).AddMonths(1)
);

View File

@@ -29,6 +29,7 @@ public class BudgetService(
IBudgetRepository budgetRepository,
IBudgetArchiveRepository budgetArchiveRepository,
ITransactionRecordRepository transactionRecordRepository,
ITransactionStatisticsService transactionStatisticsService,
IOpenAiService openAiService,
IMessageService messageService,
ILogger<BudgetService> logger,
@@ -133,7 +134,7 @@ public class BudgetService(
.ToHashSet();
// 2. 获取分类统计
var stats = await transactionRecordRepository.GetCategoryStatisticsAsync(date.Year, date.Month, transactionType);
var stats = await transactionStatisticsService.GetCategoryStatisticsAsync(date.Year, date.Month, transactionType);
// 3. 过滤未覆盖的
return stats

View File

@@ -12,7 +12,7 @@ public interface IBudgetStatsService
public class BudgetStatsService(
IBudgetRepository budgetRepository,
IBudgetArchiveRepository budgetArchiveRepository,
ITransactionRecordRepository transactionRecordRepository,
ITransactionStatisticsService transactionStatisticsService,
IDateTimeProvider dateTimeProvider,
ILogger<BudgetStatsService> logger
) : IBudgetStatsService
@@ -118,7 +118,7 @@ public class BudgetStatsService(
// 获取趋势统计数据(仅用于图表展示)
logger.LogDebug("开始获取交易趋势统计数据(用于图表)");
var dailyStats = await transactionRecordRepository.GetFilteredTrendStatisticsAsync(
var dailyStats = await transactionStatisticsService.GetFilteredTrendStatisticsAsync(
startDate,
endDate,
transactionType,
@@ -419,7 +419,7 @@ public class BudgetStatsService(
// 获取趋势统计数据(仅用于图表展示)
logger.LogDebug("开始获取交易趋势统计数据(用于图表)");
var dailyStats = await transactionRecordRepository.GetFilteredTrendStatisticsAsync(
var dailyStats = await transactionStatisticsService.GetFilteredTrendStatisticsAsync(
startDate,
endDate,
transactionType,