Class BalanceTable

java.lang.Object
com.reve.balancemanager.db.BalanceTable

public class BalanceTable extends Object
  • Field Details

    • CLIENT_BALANCE_TABLE

      public static final String CLIENT_BALANCE_TABLE
      MySQL table name where balance information can be found
      See Also:
    • BALANCE_FIELD

      public static final String BALANCE_FIELD
      Redis cluster balance field constant key.
      See Also:
  • Constructor Details

    • BalanceTable

      public BalanceTable()
  • Method Details

    • getMysqlBalance

      public static double getMysqlBalance(long accountId)
      If the given accountId is not present in redis then it will be loaded from mysql database and be saved in redis cluster.
      Parameters:
      accountId - Account ID for which balance information will be loaded into redis.
      Returns:
      Total available balance in mysql that can be used in calling or other purpose. = (cbBalance + cbCreditLimit - cbThresholdAmount)
    • setMysqlBalance

      public static boolean setMysqlBalance(long accountId, double balance, double credit)
      If the given accountId is not present in redis then it will be loaded from mysql database and be saved in redis cluster.
      Parameters:
      accountId - Account ID for which balance information will be loaded into redis.
      balance - Amount to be set in BALANCE_FIELD in CLIENT_BALANCE_TABLE table
      credit - Amount to be set in CREDIT_FIELD in CLIENT_BALANCE_TABLE table
      Returns:
      Total available balance in mysql that can be used in calling or other purpose. = (cbBalance + cbCreditLimit - cbThresholdAmount)
    • loadMysqlBalance

      public static void loadMysqlBalance(Map<Long,Double> balanceMap)
      Load the full list of client and their balance from mysql CLIENT_BALANCE_TABLE table into the given map.
      Parameters:
      balanceMap - ClientID vs usable balance map, which will be updated according to CLIENT_BALANCE_TABLE
    • getAllAccounts

      public static List<Long> getAllAccounts()
      Get all the account id from CLIENT_BALANCE_TABLE which are active.
      Returns:
      the list of account id