Add transfer tracking and secure admin access
This commit is contained in:
@@ -358,17 +358,21 @@ public class ChatController(
|
||||
if (transactions.Count == 1)
|
||||
{
|
||||
var transaction = transactions[0];
|
||||
var type = transaction.Type == TransactionType.Income
|
||||
? "收入"
|
||||
: "支出";
|
||||
var type = transaction.Type switch
|
||||
{
|
||||
TransactionType.Income => "收入",
|
||||
TransactionType.Transfer when transaction.TransferDirection == TransferDirection.In => "转入",
|
||||
TransactionType.Transfer => "转出",
|
||||
_ => "支出",
|
||||
};
|
||||
return $"已记录{type}:{transaction.Category.Name} ¥{transaction.Amount:F2}{tic}";
|
||||
}
|
||||
|
||||
var income = transactions
|
||||
.Where(t => t.Type == TransactionType.Income)
|
||||
.Where(t => t.Type.IsIncome(t.TransferDirection))
|
||||
.Sum(t => t.Amount);
|
||||
var expense = transactions
|
||||
.Where(t => t.Type == TransactionType.Expense)
|
||||
.Where(t => t.Type.IsExpense(t.TransferDirection))
|
||||
.Sum(t => t.Amount);
|
||||
return $"已记录 {transactions.Count} 笔,其中收入 ¥{income:F2}、支出 ¥{expense:F2}{tic}";
|
||||
}
|
||||
@@ -530,4 +534,4 @@ public class ChatController(
|
||||
transaction,
|
||||
message.CreatedAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user