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
0abb42af
Commit
0abb42af
authored
6 years ago
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
找币api更新
parent
7fd2bcba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
BaseResponse.php
api/base/BaseResponse.php
+4
-1
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+7
-4
No files found.
api/base/BaseResponse.php
View file @
0abb42af
...
...
@@ -17,7 +17,10 @@ class BaseResponse extends Response
//错误处理
$excpetion
=
\Yii
::
$app
->
errorHandler
->
exception
;
if
(
$excpetion
!==
null
)
{
$this
->
data
=
[
'code'
=>
$excpetion
->
getCode
(),
'msg'
=>
$excpetion
->
getMessage
()];
$this
->
data
=
[
'code'
=>
$excpetion
->
getCode
(),
'msg'
=>
$excpetion
->
getMessage
(),
];
}
//TODO 在这里对数据进行format,这样控制器中可以直接return一个array,保存到数据域data中即可,eg:['code'=>0,'data'=>$data]
$data
=
\Yii
::
$app
->
response
->
data
;
...
...
This diff is collapsed.
Click to expand it.
common/business/ExchangeBusiness.php
View file @
0abb42af
...
...
@@ -121,7 +121,10 @@ class ExchangeBusiness
public
static
function
getApiListForIndex
(
$page
=
1
,
$limit
=
999
,
$condition
=
[])
{
$rows
=
Coin
::
getSelectList
(
$page
,
$limit
,
[
'id'
,
'sid'
,
'icon'
,
'name'
,
'nickname'
,
'platform'
,
'chain'
],
$condition
);
$count
=
$rows
[
'count'
]
??
0
;
$count
=
0
;
if
(
!
empty
(
$rows
)
&&
is_array
(
$rows
)
&&
array_key_exists
(
'count'
,
$rows
))
{
$count
=
$rows
[
'count'
];
}
if
(
$rows
[
'count'
]
>
0
)
{
$rows
=
$rows
[
'data'
];
foreach
(
$rows
as
$key
=>
$row
)
{
...
...
@@ -130,13 +133,14 @@ class ExchangeBusiness
if
(
!
$quotation
)
{
$quotation
=
[];
//使用Coin服务
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
try
{
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$rows
[
$key
][
'rmb'
]
=
$coinServer
->
getPrice
();
$rows
[
$key
][
'last'
]
=
$coinServer
->
getDollar
();
$rows
[
$key
][
'low'
]
=
$coinServer
->
getLow
();
$rows
[
$key
][
'high'
]
=
$coinServer
->
getHigh
();
$coinServer
->
__destruct
();
}
catch
(
\Exception
$exception
)
{
$rows
[
$key
][
'rmb'
]
=
0
;
$rows
[
$key
][
'last'
]
=
0
;
...
...
@@ -144,7 +148,6 @@ class ExchangeBusiness
$rows
[
$key
][
'high'
]
=
0
;
\Yii
::
error
(
$exception
->
getMessage
());
}
$coinServer
->
__destruct
();
}
$rows
[
$key
]
=
array_merge
(
$rows
[
$key
],
$quotation
);
}
...
...
This diff is collapsed.
Click to expand it.
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