🐛 Fix bugs

This commit is contained in:
2025-09-08 02:22:03 +08:00
parent 92e4988114
commit ad062828ff

View File

@@ -130,11 +130,11 @@ public class PaymentService(
}; };
Wallet? payerWallet = null, payeeWallet = null; Wallet? payerWallet = null, payeeWallet = null;
if (payerWalletId.HasValue) if (payerWalletId.HasValue)
{ {
payerWallet = await db.Wallets.FirstOrDefaultAsync(e => e.AccountId == payerWalletId.Value); payerWallet = await db.Wallets.FirstOrDefaultAsync(e => e.AccountId == payerWalletId.Value);
var (payerPocket, isNewlyCreated) = var (payerPocket, isNewlyCreated) =
await wat.GetOrCreateWalletPocketAsync(payerWalletId.Value, currency); await wat.GetOrCreateWalletPocketAsync(payerWalletId.Value, currency);
@@ -150,7 +150,7 @@ public class PaymentService(
if (payeeWalletId.HasValue) if (payeeWalletId.HasValue)
{ {
payeeWallet = await db.Wallets.FirstOrDefaultAsync(e => e.AccountId == payeeWalletId.Value); payeeWallet = await db.Wallets.FirstOrDefaultAsync(e => e.AccountId == payeeWalletId.Value);
var (payeePocket, isNewlyCreated) = var (payeePocket, isNewlyCreated) =
await wat.GetOrCreateWalletPocketAsync(payeeWalletId.Value, currency, amount); await wat.GetOrCreateWalletPocketAsync(payeeWalletId.Value, currency, amount);
@@ -166,10 +166,10 @@ public class PaymentService(
if (!silent) if (!silent)
await NotifyNewTransaction(transaction, payerWallet, payeeWallet); await NotifyNewTransaction(transaction, payerWallet, payeeWallet);
return transaction; return transaction;
} }
private async Task NotifyNewTransaction(Transaction transaction, Wallet? payerWallet, Wallet? payeeWallet) private async Task NotifyNewTransaction(Transaction transaction, Wallet? payerWallet, Wallet? payeeWallet)
{ {
if (payerWallet is not null) if (payerWallet is not null)
@@ -192,18 +192,20 @@ public class PaymentService(
Notification = new PushNotification Notification = new PushNotification
{ {
Topic = "wallets.transactions", Topic = "wallets.transactions",
Title = transaction.Amount > 0 Title = localizer["TransactionNewTitle", readableTransactionRemark],
? localizer["TransactionNewBodyMinus", readableTransactionRemark] Body = transaction.Amount > 0
: localizer["TransactionNewBodyPlus", readableTransactionRemark], ? localizer["TransactionNewBodyMinus",
Body = localizer["TransactionNewTitle", transaction.Amount.ToString(CultureInfo.InvariantCulture),
transaction.Amount.ToString(CultureInfo.InvariantCulture), transaction.Currency]
transaction.Currency], : localizer["TransactionNewBodyPlus",
transaction.Amount.ToString(CultureInfo.InvariantCulture),
transaction.Currency],
IsSavable = true IsSavable = true
} }
} }
); );
} }
if (payeeWallet is not null) if (payeeWallet is not null)
{ {
var account = await db.Accounts var account = await db.Accounts
@@ -224,12 +226,14 @@ public class PaymentService(
Notification = new PushNotification Notification = new PushNotification
{ {
Topic = "wallets.transactions", Topic = "wallets.transactions",
Title = transaction.Amount > 0 Title = localizer["TransactionNewTitle", readableTransactionRemark],
? localizer["TransactionNewBodyPlus", readableTransactionRemark] Body = transaction.Amount > 0
: localizer["TransactionNewBodyMinus", readableTransactionRemark], ? localizer["TransactionNewBodyPlus",
Body = localizer["TransactionNewTitle", transaction.Amount.ToString(CultureInfo.InvariantCulture),
transaction.Amount.ToString(CultureInfo.InvariantCulture), transaction.Currency]
transaction.Currency], : localizer["TransactionNewBodyMinus",
transaction.Amount.ToString(CultureInfo.InvariantCulture),
transaction.Currency],
IsSavable = true IsSavable = true
} }
} }