Commit f616f67f authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/optimize' into 'master'

优化币种搜索条件 See merge request !445
parents 1ad2d8a6 5e1d66cf
......@@ -301,7 +301,7 @@ class CoinController extends BaseController
$query = Coin::find()
->select('id, sid, icon, name, optional_name, nickname, platform, chain, address as contract_address, treaty')
->where(['>', "find_in_set($platform_id, platform_id)", 0])
->where("JSON_CONTAINS(platform_id,'$platform_id')")
->orderBy('id');
if (false != $chain) {
......@@ -355,13 +355,7 @@ class CoinController extends BaseController
$condition[] = ['or', ['address' => $name], ['or', ['like', 'name', $name], ['like', 'nickname', $name]]];
}
if ($platform_ids) {
/* $platform_id_arr = explode(',', $platform_ids);
$condition_arr = ['OR'];
foreach ($platform_id_arr as $key => $value) {
array_push($condition_arr, ['=', 'platform_id', $value]);
}
$condition[] = $condition_arr;*/
$condition[] = ['>', "find_in_set($platform_ids, platform_id)", 0];
$condition[] = ("JSON_CONTAINS(platform_id,'$platform_ids')");
}
$result = ExchangeBusiness::SearchByName($page, $limit, $condition);
......
......@@ -51,7 +51,7 @@ class WalletCoinController extends BaseController
if (is_array($val)) {
$model = WalletCoin::find()->select('id,icon,name,nickname,optional_name,introduce,platform,chain,address as contract_address,treaty')
->where(['name' => $val[0], 'platform' => $val[1]])
->andWhere(['>', "find_in_set($platform_id, platform_id)", 0])
->andWhere("JSON_CONTAINS(platform_id,'$platform_id')")
->asArray()
->one();
}
......@@ -59,7 +59,7 @@ class WalletCoinController extends BaseController
if (is_string($val)) {
$model = WalletCoin::find()->select('id,icon,name,nickname,optional_name,introduce,platform,chain,address as contract_address,treaty')
->where(['name' => $val])
->andWhere(['>', "find_in_set($platform_id, platform_id)", 0])
->andWhere("JSON_CONTAINS(platform_id,'$platform_id')")
->asArray()
->one();
}
......@@ -134,7 +134,7 @@ class WalletCoinController extends BaseController
$query = WalletCoin::find()
->select('id, icon, name, nickname, platform, chain, address as contract_address, treaty')
->where(['>', "find_in_set($platform_id, platform_id)", 0])
->where("JSON_CONTAINS(platform_id,'$platform_id')")
->orderBy('id');
if (false != $chain) {
......@@ -186,7 +186,7 @@ class WalletCoinController extends BaseController
}
$this->data = WalletCoin::find()
->where(['id' => $id])
->andWhere(['>', "find_in_set($platform_id, platform_id)", 0])
->andWhere("JSON_CONTAINS(platform_id,'$platform_id')")
->one();
if (empty($this->data)) {
goto doEnd;
......
......@@ -53,7 +53,7 @@ class CoinController extends BaseController
}
if (Yii::$app->user->id != Yii::$app->params['admin']) {
$platform_id = Yii::$app->user->identity->platform_id;
$condition[] = ['>', "find_in_set($platform_id, platform_id)", 0];
$condition[] = ("JSON_CONTAINS(platform_id,'$platform_id')");
}
if (!empty($recommend)) {
//使用连表查询推荐币种
......@@ -156,7 +156,7 @@ class CoinController extends BaseController
$can = false;
if (Yii::$app->params['admin'] != Yii::$app->user->id) {
$coin = Coin::find()->where(['id' => $req->post('id')])->andWhere(['>', "find_in_set($platform_id, platform_id)", 0])->createCommand()->getRawSql();
$coin = Coin::find()->where(['id' => $req->post('id')])->andWhere("JSON_CONTAINS(platform_id,'$platform_id')");
if ($coin) {
$can = true;
}
......@@ -325,7 +325,7 @@ class CoinController extends BaseController
}
if ($platform_id) {
$condition[] = ['>', "find_in_set($platform_id, platform_id)", 0];
$condition[] = ("JSON_CONTAINS(platform_id,'$platform_id')");
}
$data = Coin::getSelectList($page, $limit, ['id', 'name', 'nickname', 'platform', 'chain'], $condition);
......
......@@ -170,7 +170,7 @@ class Coin extends BaseActiveRecord
if (!ctype_alnum($id)) {
return false;
}
$query = self::find()->andWhere(['>', "find_in_set($id, platform_id)", 0]);
$query = self::find()->andWhere("JSON_CONTAINS(platform_id,'$id')");
$count = $query->count();
if ($count) {
$data = $query->limit($limit)->offset(($page - 1) * $limit)->asArray()->all();
......
......@@ -19,7 +19,7 @@ class CoinRelationController extends BaseController
$platform_id = \Yii::$app->request->get('platform_id', '');
$query = WalletCoin::find()
->select('id, name, nickname, icon, introduce, official, paper, platform, chain, release, area_search, publish_count, circulate_count, decimals, address, treaty, platform_id')
->where(['>', "find_in_set($platform_id, platform_id)", 0]);
->where("JSON_CONTAINS(platform_id,'$platform_id')");
if (false != $name) {
$query->andWhere(['name' => $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