Commit 2b8fd3a5 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

fix See merge request !308
parents 22a47a6e e954209e
...@@ -41,17 +41,11 @@ class WalletCoinController extends BaseController ...@@ -41,17 +41,11 @@ class WalletCoinController extends BaseController
} }
$this->data = []; $this->data = [];
$relation_model = WalletCoinRelation::find()->select('coin_id')->where(['platform_id' => (int)$platform_id])->asArray()->all();
if (empty($relation_model)) {
goto doEnd;
}
$relation_ids = array_column($relation_model, 'coin_id');
foreach ($condition as $val) { foreach ($condition as $val) {
if (is_array($val)) { if (is_array($val)) {
$model = WalletCoin::find()->select('id,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty') $model = WalletCoin::find()->select('id,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty')
->where(['name' => $val[0], 'platform' => $val[1]]) ->where(['name' => $val[0], 'platform' => $val[1]])
->andWhere(['in', 'id', $relation_ids]) ->andWhere(['>', "find_in_set($platform_id, platform_id)", 0])
->asArray() ->asArray()
->one(); ->one();
} }
...@@ -59,7 +53,7 @@ class WalletCoinController extends BaseController ...@@ -59,7 +53,7 @@ class WalletCoinController extends BaseController
if (is_string($val)) { if (is_string($val)) {
$model = WalletCoin::find()->select('id,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty') $model = WalletCoin::find()->select('id,icon,name,nickname,introduce,platform,chain,address as contract_address,treaty')
->where(['name' => $val]) ->where(['name' => $val])
->andWhere(['in', 'id', $relation_ids]) ->andWhere(['>', "find_in_set($platform_id, platform_id)", 0])
->asArray() ->asArray()
->one(); ->one();
} }
...@@ -129,15 +123,9 @@ class WalletCoinController extends BaseController ...@@ -129,15 +123,9 @@ class WalletCoinController extends BaseController
$page = empty($params['page']) ? 1 : $params['page']; $page = empty($params['page']) ? 1 : $params['page'];
$limit = empty($params['limit']) ? 10 : $params['limit']; $limit = empty($params['limit']) ? 10 : $params['limit'];
$relation_model = WalletCoinRelation::find()->select('coin_id')->where(['platform_id' => (int)$platform_id])->asArray()->all();
if (empty($relation_model)) {
goto doEnd;
}
$relation_ids = array_column($relation_model, 'coin_id');
$query = WalletCoin::find() $query = WalletCoin::find()
->select('id, icon, name, nickname, platform, chain, address as contract_address, treaty') ->select('id, icon, name, nickname, platform, chain, address as contract_address, treaty')
->where(['in', 'id', $relation_ids]) ->where(['>', "find_in_set($platform_id, platform_id)", 0])
->orderBy('id'); ->orderBy('id');
if (false != $chain) { if (false != $chain) {
...@@ -187,12 +175,14 @@ class WalletCoinController extends BaseController ...@@ -187,12 +175,14 @@ class WalletCoinController extends BaseController
$this->msg = '参数错误'; $this->msg = '参数错误';
goto doEnd; goto doEnd;
} }
$relation = WalletCoinRelation::find()->where(['coin_id' => $id, 'platform_id' => (int)$platform_id])->one(); $this->data = WalletCoin::find()
if (empty($relation)) { ->where(['id' => $id])
->andWhere(['>', "find_in_set($platform_id, platform_id)", 0])
->one();
if (empty($this->data)) {
goto doEnd; goto doEnd;
} }
$this->data = $relation->coin;
$quotation = ExchangeBusiness::getquatation($this->data->name); $quotation = ExchangeBusiness::getquatation($this->data->name);
$tikerdata = [ $tikerdata = [
'publish_count' => $this->data->publish_count, 'publish_count' => $this->data->publish_count,
......
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