Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
53037b1d
Commit
53037b1d
authored
Aug 22, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
537d7ee7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
25 deletions
+33
-25
CoinController.php
api/controllers/CoinController.php
+26
-21
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+7
-4
No files found.
api/controllers/CoinController.php
View file @
53037b1d
...
...
@@ -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
];
}
}
...
...
common/business/ExchangeBusiness.php
View file @
53037b1d
...
...
@@ -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
[];
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment