Commit 1c149676 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/issue_coin' into develop

parents da3f7d97 c1bc9042
...@@ -193,7 +193,7 @@ class IssueCoinController extends BaseController ...@@ -193,7 +193,7 @@ class IssueCoinController extends BaseController
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]); $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]);
foreach ($models as &$val) { foreach ($models as &$val) {
$val->chain_id = $val->chain->platform; $val->chain_id = $val->chain->platform;
$val->total = (int)$val->total * 1e8; $val->total = (int)$val->total * 1e4;
} }
$data = [ $data = [
'list' => $models, 'list' => $models,
...@@ -231,7 +231,7 @@ class IssueCoinController extends BaseController ...@@ -231,7 +231,7 @@ class IssueCoinController extends BaseController
$code = -1; $code = -1;
goto doEnd; goto doEnd;
} }
$data->total = (int)$data->total * 1e8; $data->total = (int)$data->total * 1e4;
$data->chain_name = $data->chain->platform; $data->chain_name = $data->chain->platform;
$data->issue_charge = rtrim(sprintf('%.3f', floatval($data->charge)), '0'); $data->issue_charge = rtrim(sprintf('%.3f', floatval($data->charge)), '0');
$code = 0; $code = 0;
......
...@@ -28,9 +28,10 @@ class SupportedChainController extends BaseController ...@@ -28,9 +28,10 @@ class SupportedChainController extends BaseController
} }
$data = []; $data = [];
foreach ($supported_chain_model as $key => &$val) { foreach ($supported_chain_model as $key => &$val) {
$data[] = !empty($val->coin) ? $val->coin : ''; $data[$key]['chain'] = isset($val->coin->chain) ? $val->coin->chain : '';
} $data[$key]['icon'] = isset($val->coin->icon) ? $val->coin->icon : '';
}
$msg = 'success'; $msg = 'success';
$code = 0; $code = 0;
doEnd : doEnd :
......
...@@ -41,11 +41,11 @@ class CoinSupportedChain extends BaseActiveRecord ...@@ -41,11 +41,11 @@ class CoinSupportedChain extends BaseActiveRecord
public function attributes() public function attributes()
{ {
return array_merge(parent::attributes(), ['coins']); return array_merge(parent::attributes(), ['chain', 'icon']);
} }
public function getCoin() public function getCoin()
{ {
return $this->hasOne(Coin::className(), ['id' => 'coin_id'])->select('name as chain'); return $this->hasOne(Coin::className(), ['id' => 'coin_id'])->select('name as chain, icon');
} }
} }
...@@ -253,10 +253,10 @@ class ZhaobiBuilder extends FactoryService ...@@ -253,10 +253,10 @@ class ZhaobiBuilder extends FactoryService
$code = $this->code; $code = $this->code;
goto doEnd; goto doEnd;
} }
$low = number_format(1 / $low_currency * $low_base_currency, 6, '.', ''); $low = number_format(1 / ($low_currency * $low_base_currency), 6, '.', '');
$high = number_format(1 / $high_currency * $high_base_currency, 6, '.', ''); $high = number_format(1 / ($high_currency * $high_base_currency), 6, '.', '');
$close = number_format(1 / $close_currency * $close_base_currency, 6, '.', ''); $close = number_format(1 / ($close_currency * $close_base_currency), 6, '.', '');
$open = number_format(1 / $open_currency * $open_base_currency, 6, '.', ''); $open = number_format(1 / ($open_currency * $open_base_currency), 6, '.', '');
$ticker = [ $ticker = [
'low' => $low, 'low' => $low,
'high' => $high, 'high' => $high,
......
...@@ -15,6 +15,26 @@ class BaseController extends Controller ...@@ -15,6 +15,26 @@ class BaseController extends Controller
public $start; public $start;
public $end; public $end;
public $header_list = [];
public $lang;
private static $default_header_list = [];
public function init()
{
if ('cli' !== php_sapi_name()) {
$this->header_list = self::$default_header_list;
$this->fzmCrossHeader();
}
}
public function fzmCrossHeader()
{
$this->lang = \Yii::$app->request->headers->get('lang') ?? 'zh-CN';
if ('en' == strtolower($this->lang)) {
$this->lang = 'en-US';
}
}
/** /**
* @param $action * @param $action
* @return bool * @return bool
......
...@@ -71,6 +71,12 @@ class CoinController extends BaseController ...@@ -71,6 +71,12 @@ class CoinController extends BaseController
} }
$fields = ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain', 'address as contract_address', 'introduce']; $fields = ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain', 'address as contract_address', 'introduce'];
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition, $fields); $result = ExchangeBusiness::getApiListForIndex(1, 999, $condition, $fields);
foreach ($result['data'] as $key => &$val) {
$nickname = json_decode($val['nickname'], true);
$val['nickname'] = isset($nickname[$this->lang]) ? $nickname[$this->lang] : '';
$introduce = json_decode($val['introduce'], true);
$val['introduce'] = isset($introduce[$this->lang]) ? $introduce[$this->lang] : '';
}
if ($result) { if ($result) {
$response_->build(ResponseBuild::STATUS_SUCCEED, '', $result['data']); $response_->build(ResponseBuild::STATUS_SUCCEED, '', $result['data']);
} else { } else {
......
...@@ -6,5 +6,6 @@ ...@@ -6,5 +6,6 @@
* *
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*/
eval('?>' . \file_get_contents('php://stdin')); * eval('?>' . \file_get_contents('php://stdin'));
*/
\ No newline at end of file
...@@ -61,7 +61,7 @@ class IssueCoinController extends BaseController ...@@ -61,7 +61,7 @@ class IssueCoinController extends BaseController
$platform = isset($val->chain->platform) ? $val->chain->platform : ''; $platform = isset($val->chain->platform) ? $val->chain->platform : '';
$val->chain_name = $platform; $val->chain_name = $platform;
$val->url = Yii::$app->redis->hget('platform_brower_info', $platform); $val->url = Yii::$app->redis->hget('platform_brower_info', $platform);
$val->total = (int)$val->total * 1e8; $val->total = (int)$val->total * 1e4;
} }
$data = [ $data = [
'list' => $models, 'list' => $models,
...@@ -95,7 +95,7 @@ class IssueCoinController extends BaseController ...@@ -95,7 +95,7 @@ class IssueCoinController extends BaseController
$data = CoinIssueCoin::find()->where(['id' => $id])->one(); $data = CoinIssueCoin::find()->where(['id' => $id])->one();
$platform = isset($data->chain->platform) ? $data->chain->platform : ''; $platform = isset($data->chain->platform) ? $data->chain->platform : '';
$data->total = (int)$data->total * 1e8; $data->total = (int)$data->total * 1e4;
$data->issue_charge = rtrim(sprintf('%.3f', floatval($data->charge)), '0'); $data->issue_charge = rtrim(sprintf('%.3f', floatval($data->charge)), '0');
$data->url = Yii::$app->redis->hget('platform_brower_info', $platform); $data->url = Yii::$app->redis->hget('platform_brower_info', $platform);
$code = 0; $code = 0;
......
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