Commit b0cf3615 authored by rlgy's avatar rlgy

单币种简介

parent ede31a11
...@@ -84,6 +84,16 @@ class CoinController extends BaseController ...@@ -84,6 +84,16 @@ class CoinController extends BaseController
Yii::$app->response->data = $data; Yii::$app->response->data = $data;
} }
public function actionGetCoinById()
{
$request = Yii::$app->request;
$id = $request->post('id', 0);
if ($id) {
return CoinBusiness::getCoinAllById($id);
}
return [];
}
/** /**
* 获取推介币种列表 * 获取推介币种列表
*/ */
...@@ -129,4 +139,6 @@ class CoinController extends BaseController ...@@ -129,4 +139,6 @@ class CoinController extends BaseController
$condition = [['in', 'name', $names]]; $condition = [['in', 'name', $names]];
Yii::$app->response->data = CoinBusiness::getApiListForIndex($condition); Yii::$app->response->data = CoinBusiness::getApiListForIndex($condition);
} }
} }
\ No newline at end of file
...@@ -103,4 +103,19 @@ class CoinBusiness ...@@ -103,4 +103,19 @@ class CoinBusiness
} }
return []; return [];
} }
/**
* 获取币种的所有信息
*/
public static function getCoinAllById($id)
{
$row = Coin::find()->where(['id' => $id])->asArray()->One();
if ($row) {
//TODO 获取行情
$row['quotation'] = CoinService::quotation($row['sid']);
//TODO 获取交易所详情
$row['exchange'] = CoinService::exchange($row['sid']);
}
return $row ? $row : [];
}
} }
\ No newline at end of file
...@@ -577,7 +577,7 @@ class CoinService ...@@ -577,7 +577,7 @@ class CoinService
$result = array_map(function ($value) { $result = array_map(function ($value) {
return trim($value); return trim($value);
}, $result); }, $result);
Yii::$app->cache->set($key, $result, 60);//set cache Yii::$app->cache->set($key, $result, Yii::$app->params['curl_cache_time']['quotation']);//set cache
return $result; return $result;
} catch (\Exception $exception) { } catch (\Exception $exception) {
return new \stdClass(); return new \stdClass();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment