fix
This commit is contained in:
@@ -19,9 +19,9 @@ public interface ITransactionRecordRepository : IBaseRepository<TransactionRecor
|
||||
/// <param name="month">筛选月份</param>
|
||||
/// <returns>交易记录列表、最后发生时间和最后ID</returns>
|
||||
Task<(List<TransactionRecord> list, DateTime? lastOccurredAt, long lastId)> GetPagedListAsync(
|
||||
DateTime? lastOccurredAt,
|
||||
long? lastId,
|
||||
int pageSize = 20,
|
||||
DateTime? lastOccurredAt,
|
||||
long? lastId,
|
||||
int pageSize = 20,
|
||||
string? searchKeyword = null,
|
||||
string? classify = null,
|
||||
TransactionType? type = null,
|
||||
@@ -130,7 +130,7 @@ public interface ITransactionRecordRepository : IBaseRepository<TransactionRecor
|
||||
/// <param name="keyword">关键词</param>
|
||||
/// <returns>匹配的交易记录列表</returns>
|
||||
Task<List<TransactionRecord>> QueryByWhereAsync(string sql);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 执行完整的SQL查询
|
||||
/// </summary>
|
||||
@@ -163,9 +163,9 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
}
|
||||
|
||||
public async Task<(List<TransactionRecord> list, DateTime? lastOccurredAt, long lastId)> GetPagedListAsync(
|
||||
DateTime? lastOccurredAt,
|
||||
long? lastId,
|
||||
int pageSize = 20,
|
||||
DateTime? lastOccurredAt,
|
||||
long? lastId,
|
||||
int pageSize = 20,
|
||||
string? searchKeyword = null,
|
||||
string? classify = null,
|
||||
TransactionType? type = null,
|
||||
@@ -175,25 +175,24 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
var query = FreeSql.Select<TransactionRecord>();
|
||||
|
||||
// 如果提供了搜索关键词,则添加搜索条件
|
||||
if (!string.IsNullOrWhiteSpace(searchKeyword))
|
||||
{
|
||||
query = query.Where(t => t.Reason.Contains(searchKeyword) ||
|
||||
t.Classify.Contains(searchKeyword) ||
|
||||
t.Card.Contains(searchKeyword) ||
|
||||
t.ImportFrom.Contains(searchKeyword));
|
||||
}
|
||||
query = query.WhereIf(!string.IsNullOrWhiteSpace(searchKeyword),
|
||||
t => t.Reason.Contains(searchKeyword!) ||
|
||||
t.Classify.Contains(searchKeyword!) ||
|
||||
t.Card.Contains(searchKeyword!) ||
|
||||
t.ImportFrom.Contains(searchKeyword!));
|
||||
|
||||
// 按分类筛选
|
||||
if (!string.IsNullOrWhiteSpace(classify))
|
||||
{
|
||||
if (classify == "未分类")
|
||||
{
|
||||
classify = string.Empty;
|
||||
}
|
||||
query = query.Where(t => t.Classify == classify);
|
||||
}
|
||||
|
||||
// 按交易类型筛选
|
||||
if (type.HasValue)
|
||||
{
|
||||
query = query.Where(t => t.Type == type.Value);
|
||||
}
|
||||
query = query.WhereIf(type.HasValue, t => t.Type == type!.Value);
|
||||
|
||||
// 按年月筛选
|
||||
if (year.HasValue && month.HasValue)
|
||||
@@ -370,7 +369,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
{
|
||||
var dt = await FreeSql.Ado.ExecuteDataTableAsync(completeSql);
|
||||
var result = new List<dynamic>();
|
||||
|
||||
|
||||
foreach (System.Data.DataRow row in dt.Rows)
|
||||
{
|
||||
var expando = new System.Dynamic.ExpandoObject() as IDictionary<string, object>;
|
||||
@@ -380,7 +379,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
}
|
||||
result.Add(expando);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
public async Task<MonthlyStatistics> GetMonthlyStatisticsAsync(int year, int month)
|
||||
@@ -401,7 +400,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
|
||||
foreach (var record in records)
|
||||
{
|
||||
var amount = Math.Abs(record.Amount);
|
||||
|
||||
|
||||
if (record.Type == TransactionType.Expense)
|
||||
{
|
||||
statistics.TotalExpense += amount;
|
||||
|
||||
Reference in New Issue
Block a user