Exemplo n.º 1
0
 /**
  * @author Tuzki
  * @param integer
  * @desc 将改组账号的配置设置到对象的属性中,new 出账号组的账号对象
  */
 private function init()
 {
     Logger::Log("Initialize account group from db.");
     $this->accounts = array();
     $this->config = null;
     $this->name = null;
     $this->holding_btc_weight_total = 0;
     $account_dao = new AccountDao();
     $account_group_dao = new AccountGroupDao();
     $account_group = $account_group_dao->get($this->id);
     if ($account_group) {
         $this->name = $account_group['name'];
     } else {
         throw new Exception('Account Group is not found.');
     }
     $this->id = $account_group['id'];
     $this->config = new ConfigModel($this->id);
     $accounts = $account_dao->getAccountListByAccountGroupId($this->id);
     foreach ($accounts as $account) {
         $account = new AccountModel($account['id']);
         //持币权重之和(后面用于计算交易类型)
         $this->holding_btc_weight_total += $account->market->holding_btc_weight;
         $this->accounts[] = $account;
     }
 }
Exemplo n.º 2
0
 public function getAction()
 {
     $account_dao = new AccountDao();
     $account_group_dao = new AccountGroupDao('account-group');
     $params = $this->getRequest()->getParams();
     $param_id = array_search('edit', $params);
     if (!empty($param_id) && $params[$param_id] === 'edit') {
         $account_dao = new AccountDao();
         $market_dao = new MarketDao();
         $account_config_dao = new AccountConfigDao('account_config');
         $account_group_list = $account_group_dao->getList();
         $account = $account_dao->get($param_id);
         $market = $market_dao->get($account['market_id']);
         //account config
         $account_config_list = $account_config_dao->getConfigListByAccountId($param_id);
         $this->getView()->assign('account', $account);
         $this->getView()->assign('account_group_list', $account_group_list);
         $this->getView()->assign('account_config_list', $account_config_list);
         $this->getView()->assign('market', $market);
         $this->getView()->display('accounts-edit.phtml');
         exit;
     }
     if (array_key_exists('new', $params)) {
         $account_group_dao = new AccountGroupDao('account-group');
         $market_dao = new MarketDao();
         $account_group_list = $account_group_dao->getList();
         $market_list = $market_dao->getList();
         //account config
         $account_config_list = array();
         foreach ($market_list as $market) {
             $account_config_list[$market['name']] = get_account_config_keys($market['name']);
         }
         $this->getView()->assign('account_group_list', $account_group_list);
         $this->getView()->assign('account_config_list', $account_config_list);
         $this->getView()->assign('market_list', $market_list);
         $this->getView()->display('accounts-new.phtml');
         exit;
     }
     $this->getView()->assign('account_list', $account_dao->getAccountList());
     $this->getView()->display('accounts.phtml');
 }
Exemplo n.º 3
0
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     $account_group_model = new AccountGroupDao('account_group');
     $account_group_model->delete($id);
     $this->redirect('/account-group');
 }