Commit 53037b1d authored by rlgy's avatar rlgy

init

parent 537d7ee7
......@@ -51,13 +51,13 @@ class CoinController extends BaseController
$condition = [['recommend' => '1']];
$result = ExchangeBusiness::getApiListForIndex($page, $limit, $condition);
if ($result) {
$chains = array_unique(array_column($result['data'], 'chain'));
$chain_quotation=[];
$chains = array_unique(array_column($result['data'], 'chain'));
$chain_quotation = [];
foreach ($chains as $key => $value) {
$chain_quotation[$value]=ExchangeBusiness::getquatation($value);
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
foreach ($result['data'] as $key => &$value) {
$value['chain_quotation']=$chain_quotation[$value['chain']];
$value['chain_quotation'] = $chain_quotation[$value['chain']];
}
return $result;
}
......@@ -97,13 +97,13 @@ class CoinController extends BaseController
$condition = [['in', 'name', $names]];
$result = ExchangeBusiness::getApiListForIndex(1, 999, $condition);
if ($result) {
$chains = array_unique(array_column($result['data'], 'chain'));
$chain_quotation=[];
$chains = array_unique(array_column($result['data'], 'chain'));
$chain_quotation = [];
foreach ($chains as $key => $value) {
$chain_quotation[$value]=ExchangeBusiness::getquatation($value);
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
foreach ($result['data'] as $key => &$value) {
$value['chain_quotation']=$chain_quotation[$value['chain']];
$value['chain_quotation'] = $chain_quotation[$value['chain']];
}
return $result;
}
......@@ -119,20 +119,25 @@ class CoinController extends BaseController
$name = $request->post('name', '');
$page = $request->post('page', 1);
$limit = $request->post('limit', 10);
if ($name) {
$condition = [['!=', 'chain', 'other'], ['or', ['like', 'name', $name], ['like', 'nickname', $name]]];
$result = ExchangeBusiness::SearchByName($page, $limit, $condition);
if ($result) {
$chains = array_unique(array_column($result,'chain'));
$chain_quotation=[];
foreach ($chains as $key => $value) {
$chain_quotation[$value]=ExchangeBusiness::getquatation($value);
}
foreach ($result as $key => $value) {
$result[$key]['chain_quotation']=$chain_quotation[$value['chain']];
}
return $result;
$condition = [['!=', 'chain', 'other']];
if (!empty($name)) {
$condition[] = ['or', ['like', 'name', $name], ['like', 'nickname', $name]];
}
$result = ExchangeBusiness::SearchByName($page, $limit, $condition);
$total = $result['total'];
$result = $result['data'];
if ($result) {
$chains = array_unique(array_column($result, 'chain'));
$chain_quotation = [];
foreach ($chains as $key => $value) {
$chain_quotation[$value] = ExchangeBusiness::getquatation($value);
}
foreach ($result as $key => $value) {
$result[$key]['chain_quotation'] = $chain_quotation[$value['chain']];
}
return ['code' => 0, 'count' => $total, 'data' => $result];
}
}
......
......@@ -121,7 +121,8 @@ class ExchangeBusiness
*/
public static function getApiListForIndex($page = 1, $limit = 999, $condition = [])
{
$rows = Coin::getSelectList($page, $limit, ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain'], $condition);
$rows = Coin::getSelectList($page, $limit, ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain'],
$condition);
$count = 0;
if (!empty($rows) && is_array($rows) && array_key_exists('count', $rows)) {
$count = $rows['count'];
......@@ -166,13 +167,15 @@ class ExchangeBusiness
*/
public static function SearchByName($page = 1, $limit = 10, $condition = [])
{
$rows = Coin::getSelectList($page, $limit, ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain'], $condition);
$rows = Coin::getSelectList($page, $limit, ['id', 'sid', 'icon', 'name', 'nickname', 'platform', 'chain'],
$condition);
if ($rows['count'] > 0) {
$rows = $rows['data'];
$total = $rows['count'];
$rows = $rows['data'];
foreach ($rows as $key => $row) {
$rows[$key]['sid'] = ucfirst($rows[$key]['sid']);
}
return $rows;
return ['total' => $total, 'data' => $rows];
}
return [];
}
......
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