response->data = Coin::getList(); } /** * 获取行情列表,可簺选(coin.id,coin.name),可分页 * * @var int $id coin.id * @var string $name coin.name * @var int $page 第几页 * @var int $limit 多少条数据 * * @return array 格式 [code,msg,count,data] * * 返回data数组格式[coin.id coin.name coin.nickname coin.quotation] * coin.quatation=>['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']]; } //平台saixuan if (isset($post['platform'])) { $condition[] = ['platform' => $post['platform']]; } $data = CoinBusiness::getApiList($page, $limit, $condition); Yii::$app->response->data = $data; } }