优化账户余额调整功能:新增调整余额的逻辑,更新相关页面以显示账户余额和可用额度,调整路由配置以移除不必要的动画效果。

This commit is contained in:
2026-04-05 18:40:52 +08:00
parent 5fbff39c4f
commit c7c84c74d3
9 changed files with 255 additions and 84 deletions
+3 -1
View File
@@ -544,7 +544,9 @@ func (t *Transaction) ToTransactionInfoResponse(tagIds []int64, editable bool) *
destinationAccountId := int64(0)
destinationAmount := int64(0)
if t.Type == TRANSACTION_DB_TYPE_TRANSFER_OUT {
if t.Type == TRANSACTION_DB_TYPE_MODIFY_BALANCE {
sourceAmount = t.RelatedAccountAmount // always return delta
} else if t.Type == TRANSACTION_DB_TYPE_TRANSFER_OUT {
destinationAccountId = t.RelatedAccountId
destinationAmount = t.RelatedAccountAmount
} else if t.Type == TRANSACTION_DB_TYPE_TRANSFER_IN {
+2 -11
View File
@@ -954,7 +954,7 @@ func (s *TransactionService) ModifyTransaction(c core.Context, transaction *mode
if transaction.Amount != oldTransaction.Amount {
if oldTransaction.Type == models.TRANSACTION_DB_TYPE_MODIFY_BALANCE {
transaction.RelatedAccountAmount = oldTransaction.RelatedAccountAmount + transaction.Amount - oldTransaction.Amount
transaction.RelatedAccountAmount = transaction.Amount // Amount IS the new delta
updateCols = append(updateCols, "related_account_amount")
}
@@ -2251,17 +2251,8 @@ func (s *TransactionService) doCreateTransaction(c core.Context, database *datas
// Verify balance modification transaction and calculate real amount
if transaction.Type == models.TRANSACTION_DB_TYPE_MODIFY_BALANCE {
otherTransactionExists, err := sess.Cols("uid", "deleted", "account_id").Where("uid=? AND deleted=? AND account_id=?", transaction.Uid, false, sourceAccount.AccountId).Limit(1).Exist(&models.Transaction{})
if err != nil {
log.Errorf(c, "[transactions.doCreateTransaction] failed to get whether other transactions exist, because %s", err.Error())
return err
} else if otherTransactionExists {
return errs.ErrBalanceModificationTransactionCannotAddWhenNotEmpty
}
transaction.RelatedAccountId = transaction.AccountId
transaction.RelatedAccountAmount = transaction.Amount - sourceAccount.Balance
transaction.RelatedAccountAmount = transaction.Amount // Amount IS the delta
} else { // Not allow to add transaction before balance modification transaction
otherTransactionExists := false