['price' => '', 'dollar' => '', 'btc' => '', 'high' => '', 'low' => '', 'change' => ''] * 对应:价格 价格美元 价格btc 最高价 最低价 涨幅(跌幅) */ public function actionQuotationList() { $request = Yii::$app->request; $page = $request->post('page', 1); $limit = $request->post('limit', 10); $condition = []; $post = $request->post(); //过滤字段 $post = array_filter($post, function ($item, $key) { if ($key == 'id' && is_numeric($item)) { return true; } return $key; }, ARRAY_FILTER_USE_BOTH); //id筛选 if (isset($post['id'])) { if (is_array($post['id'])) { $condition[] = ['in', 'id', $post['id']]; } elseif (is_numeric($post['id'])) { $condition[] = ['id' => $post['id']]; } } //名称模糊查询 if (isset($post['name'])) { if (is_array($post['name'])) { $condition[] = ['in', 'name', $post['name']]; } else { $condition[] = ['like', 'name', $post['name']]; } } //昵称模糊查询 if (isset($post['nickname'])) { $condition[] = ['like', 'nickname', $post['nickname']]; } //平台筛选 if (isset($post['platform'])) { $condition[] = ['platform' => $post['platform']]; } $data = CoinBusiness::getApiList($page, $limit, $condition); Yii::$app->response->data = $data; } /** * 获取推介币种列表 */ public function actionGetRecList() { $request = Yii::$app->request; $page = $request->post('page', 1); $limit = $request->post('limit', 999); $condition = [['recommend' => '1']]; $data = CoinBusiness::getApiList($page, $limit, $condition); Yii::$app->response->data = $data; } /** * 矿工费获取 * * 根据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 ['code' => 1, 'msg' => '数据为空']; } } else { //如果coin为null,$coin->minerFee会抛出Trying to get property 'minerFee' of non-object",code=>8 throw new Exception('8', '币种不存在'); } return ['code' => 0, 'data' => $miner_fee]; } }