移除对账功能 后期从长计议
Some checks failed
Docker Build & Deploy / Build Docker Image (push) Failing after 1m57s
Docker Build & Deploy / Deploy to Production (push) Has been skipped
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s
Docker Build & Deploy / WeChat Notification (push) Successful in 1s

This commit is contained in:
SunCheng
2026-01-27 15:29:25 +08:00
parent bade93ad57
commit 4aa7e82429
29 changed files with 716 additions and 328 deletions

View File

@@ -1,4 +1,4 @@
namespace Repository;
namespace Repository;
public interface ITransactionRecordRepository : IBaseRepository<TransactionRecord>
{
@@ -176,16 +176,7 @@ public interface ITransactionRecordRepository : IBaseRepository<TransactionRecor
/// <param name="minMatchRate">最小匹配率0.0-1.0默认0.3表示至少匹配30%的关键词</param>
/// <param name="limit">返回结果数量限制</param>
/// <returns>带相关度分数的已分类账单列表</returns>
Task<List<(TransactionRecord record, double relevanceScore)>> GetClassifiedByKeywordsWithScoreAsync(List<string> keywords, double minMatchRate = 0.3, int limit = 10);
/// <summary>
/// 获取抵账候选列表
/// </summary>
/// <param name="currentId">当前交易ID</param>
/// <param name="amount">当前交易金额</param>
/// <param name="currentType">当前交易类型</param>
/// <returns>候选交易列表</returns>
Task<List<TransactionRecord>> GetCandidatesForOffsetAsync(long currentId, decimal amount, TransactionType currentType);
Task<List<(TransactionRecord record, double relevanceScore)>> GetClassifiedByKeywordsWithScoreAsync(List<string> keywords, double minMatchRate = 0.3, int limit = 10);
/// <summary>
/// 获取待确认分类的账单列表
@@ -673,34 +664,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
.Take(limit)
.ToList();
return scoredResults;
}
public async Task<List<TransactionRecord>> GetCandidatesForOffsetAsync(long currentId, decimal amount, TransactionType currentType)
{
var absAmount = Math.Abs(amount);
var minAmount = absAmount - 5;
var maxAmount = absAmount + 5;
var currentRecord = await FreeSql.Select<TransactionRecord>()
.Where(t => t.Id == currentId)
.FirstAsync();
if (currentRecord == null)
{
return [];
}
var list = await FreeSql.Select<TransactionRecord>()
.Where(t => t.Id != currentId)
.Where(t => t.Type != currentType)
.Where(t => Math.Abs(t.Amount) >= minAmount && Math.Abs(t.Amount) <= maxAmount)
.Take(50)
.ToListAsync();
return list.OrderBy(t => Math.Abs(Math.Abs(t.Amount) - absAmount))
.ThenBy(x => Math.Abs((x.OccurredAt - currentRecord.OccurredAt).TotalSeconds))
.ToList();
return scoredResults;
}
public async Task<int> UpdateCategoryNameAsync(string oldName, string newName, TransactionType type)
@@ -769,7 +733,7 @@ public class TransactionRecordRepository(IFreeSql freeSql) : BaseRepository<Tran
{
g.Key.Classify,
g.Key.Type,
TotalAmount = g.Sum(g.Value.Amount - g.Value.RefundAmount)
TotalAmount = g.Sum(g.Value.Amount)
});
return result.ToDictionary(x => (x.Classify, x.Type), x => x.TotalAmount);