Commit 038e8419 authored by shajiaiming's avatar shajiaiming

fix

parent 4a48da50
...@@ -19,6 +19,7 @@ use common\models\psources\CoinPlatformWithHold; ...@@ -19,6 +19,7 @@ use common\models\psources\CoinPlatformWithHold;
use common\models\psources\CoinRecommend; use common\models\psources\CoinRecommend;
use common\models\psources\MinerFee; use common\models\psources\MinerFee;
use Yii; use Yii;
use yii\data\Pagination;
/** /**
* 币种信息管理控制器 * 币种信息管理控制器
...@@ -257,6 +258,75 @@ class CoinController extends BaseController ...@@ -257,6 +258,75 @@ class CoinController extends BaseController
} }
} }
public function actionSearch()
{
$params = Yii::$app->request->post();
$chain = isset($params['chain']) ? $params['chain'] : '';
$keyword = isset($params['keyword']) ? $params['keyword'] : '';
$platform = isset($params['platform']) ? $params['platform'] : '';
$platform_id = isset($params['platform_id']) ? $params['platform_id'] : '';
$page = isset($params['page']) ? $params['page'] : 1;
$size = isset($params['size']) ? $params['size'] : 10;
if (false == $platform_id) {
$msg = '参数错误';
$code = -1;
$data = null;
goto doEnd;
}
$query = Coin::find()
->select('id, sid, icon, name, optional_name, nickname, platform, chain, address as contract_address, treaty')
->where(['platform_id' => (int)$platform_id])
->orderBy('id');
if (false != $chain) {
$query->andWhere(['chain' => $chain]);
}
if (false != $platform) {
$query->andWhere(['platform' => $platform]);
}
if (false != $keyword) {
$query->andWhere(['or', ['like', 'address', $keyword], ['like', 'name', $keyword], ['like', 'nickname', $keyword]]);
}
$data = $query->offset(($page - 1) * $size)->limit($size)->asArray()->all();
if (false != $data) {
$chains = array_unique(array_column($data, 'chain'));
$chain_quotation = [];
foreach ($chains as $key => $value) {
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
foreach ($data as $key => $value) {
$data[$key]['chain_quotation'] = $chain_quotation[$value['chain']] ?: null;
}
foreach ($data as $key => &$value) {
$nickname = json_decode($value['nickname'], true);
$value['nickname'] = $nickname[$this->lang];
$value['chain_rmb'] = isset($value['chain_quotation']['rmb']) ? $value['chain_quotation']['rmb'] : 0;
$value['chain_usd'] = isset($value['chain_quotation']['usd']) ? $value['chain_quotation']['usd'] : 0;
}
}
$countQuery = clone $query;
$pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $size]);
$data = [
'list' => $data,
'page' => [
'pageCount' => $pages->pageCount,
'pageSize' => $size,
'currentPage' => $page,
]
];
$code = 1;
$msg = 'success';
doEnd :
return ['code' => $code, 'data' => $data, 'msg' => $msg];
}
/** /**
* 按照名称搜索币种 * 按照名称搜索币种
* *
...@@ -365,7 +435,7 @@ class CoinController extends BaseController ...@@ -365,7 +435,7 @@ class CoinController extends BaseController
if (1 == $coin_info['treaty']) { if (1 == $coin_info['treaty']) {
$platform_with_hold['exer'] = 'user.p.' . $platform . '.token'; $platform_with_hold['exer'] = 'user.p.' . $platform . '.token';
if ('BTY' !== strtoupper($platform)) { if ('BTY' !== strtoupper($platform)) {
$platform_with_hold['tokensymbol'] = $platform.'.'.$coin_name; $platform_with_hold['tokensymbol'] = $platform . '.' . $coin_name;
} else { } else {
$platform_with_hold['tokensymbol'] = $coin_name; $platform_with_hold['tokensymbol'] = $coin_name;
} }
......
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