request; $id = $request->post('id', 0); if ($id) { $ret = CoinBusiness::getCoinAllById($id); if ($ret) { return $ret[0]; } } return []; } /** * 获取推介币种列表 */ public function actionGetRecList() { $request = Yii::$app->request; $page = $request->post('page', 1); $limit = $request->post('limit', 999); $condition = [['recommend' => '1']]; return ExchangeBusiness::getApiListForIndex($page, $limit, $condition); } /** * 矿工费获取 * * 根据name获取 * @throws Exception */ public function actionGetMinerFeeByName() { $names = Yii::$app->request->post('name'); $coin = Coin::findOne(['name' => $names]); if ($coin) { $miner_fee = $coin->minerFee; if (empty($miner_fee)) { return []; } } else { //如果coin为null,$coin->minerFee会抛出Trying to get property 'minerFee' of non-object",code=>8 throw new Exception('8', '币种不存在'); } $result = (array)$miner_fee->getAttributes(); $result['min'] = (float)$result['min']; $result['max'] = (float)$result['max']; return $result; } /** * app首页接口V2 */ public function actionCoinIndex() { $names = Yii::$app->request->post('names'); $condition = [['in', 'name', $names]]; return ExchangeBusiness::getApiListForIndex(1, 999, $condition); } /** * 按照名称搜索币种 * @return array */ public function actionSearchCoinByName() { $request = Yii::$app->request; $name = $request->post('name', ''); $page = $request->post('page', 1); $limit = $request->post('limit', 10); if ($name) { $condition = [['!=', 'chain', 'other'], ['or', ['like', 'name', $name], ['like', 'nickname', $name]]]; return ExchangeBusiness::SearchByName($page, $limit, $condition); } } /** * 返回交易状态 * * @return mixed */ public function actionTransaction() { $request = Yii::$app->request; $name = $request->post('name', ''); $txhash = $request->post('txhash', ''); if ($name && $txhash) { return BrowerBusiness::getTransStatus($name, $txhash); } return false; } }