Ejemplo n.º 1
0
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     $market_dao = new MarketDao();
     $market_dao->delete($id);
     $this->redirect('/markets');
 }
Ejemplo n.º 2
0
 public function getAction()
 {
     $account_group_dao = new AccountGroupDao('account_group');
     $params = $this->getRequest()->getParams();
     $handle = array_search('edit', $params);
     if (!empty($handle) && $params[$handle] === 'edit') {
         $account_group = $account_group_dao->get($handle);
         if (empty($account_group)) {
             $this->redirect('/account-group');
             exit;
         }
         $config_dao = new ConfigDao();
         $config_list = $config_dao->getConfigListByAccountGroupId($account_group['id']);
         $this->getView()->assign('config_list', $config_list);
         $this->getView()->assign('account_group', $account_group);
         $this->getView()->display('account-group-edit.phtml');
         exit;
     }
     if (array_key_exists('new', $params)) {
         $config_list = get_config_keys();
         $this->getView()->assign('config_list', $config_list);
         $this->getView()->display('account-group-new.phtml');
         exit;
     }
     $redis = Yaf\Registry::get('redis');
     if (!empty($params) && count($params) === 1) {
         $id = array_keys($params)[0];
         $config_dao = new ConfigDao();
         $config_list = $config_dao->getConfigListByAccountGroupId($id);
         $account_group_config = array();
         foreach ($config_list as $row) {
             $account_group_config[$row['name']] = $row['value'];
         }
         $account_dao = new AccountDao();
         $account_list = $account_dao->getAccountListByAccountGroupId($id);
         $market_dao = new MarketDao();
         $account_info_list = array();
         foreach ($account_list as $account) {
             $key = 'AccountInfo_' . $account['id'];
             $market = $market_dao->get($account['market_id']);
             $account_info_list[] = array_merge(json_decode($redis->get($key), true), array('market_name' => $market['name']));
         }
         $btc_price = json_decode($redis->get('Market\\HuoLPrice'), true)['buy'][0][0];
         $this->getView()->assign('btc_price', $btc_price);
         $this->getView()->assign('account_group_config', $account_group_config);
         $this->getView()->assign('account_info_list', $account_info_list);
         $this->getView()->display('account-group-view.phtml');
         exit;
     }
     $this->getView()->assign('account_group_list', $account_group_dao->getList());
     $this->getView()->display('account-group.phtml');
 }
Ejemplo n.º 3
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');
 }