Commit 389584e1 authored by shajiaiming's avatar shajiaiming

fix

parent d1c75b1f
......@@ -219,23 +219,13 @@ class CoinController extends BaseController
public function actionCoinIndex()
{
$names = Yii::$app->request->post('names');
$platforms = [];
$newNames = [];
if (!$names) {
return ['code' => 0, 'data' => []];
}
foreach ($names as $item) {
$item_array = explode(',', $item);
$newNames [] = $item_array[0];
if (isset($item_array[1])) {
if (!in_array($item_array[1], $platforms)) {
$platforms [] = $item_array[1];
}
}
}
$condition = [['in', 'name', $newNames]];
if ($platforms) {
$condition[] = ['in', 'platform', $platforms];
foreach ($names as $key => $val) {
$val_array = explode(',', $val);
if(count($val_array) < 2) continue;
$condition[] = [$val_array[0], $val_array[1]];
}
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition);
if ($result) {
......
......@@ -252,10 +252,18 @@ class ExchangeBusiness
*/
public static function getApiListForIndex($page = 1, $limit = 999, $condition = [], $fields = [])
{
if (!$fields) {
$fields = ['id', 'sid', 'icon', 'name', 'optional_name', 'nickname', 'platform', 'chain', 'address as contract_address', 'treaty'];
foreach ($condition as $val) {
$data[] = Coin::find()->select('id,sid,icon,name,optional_name,nickname,platform,chain,address as contract_address,treaty')
->where(['name' => $val[0]])
->andWhere(['platform' => $val[1]])
->asArray()
->one();
}
$rows = Coin::getSelectList($page, $limit, $fields, $condition);
$rows = [
'count' => count($data),
'data' => $data
];
$count = 0;
if (!empty($rows) && is_array($rows) && array_key_exists('count', $rows)) {
$count = $rows['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