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
b0cf3615
Commit
b0cf3615
authored
Jun 19, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
单币种简介
parent
ede31a11
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
1 deletion
+30
-1
CoinController.php
api/controllers/CoinController.php
+13
-0
CoinBusiness.php
common/business/CoinBusiness.php
+16
-0
CoinService.php
common/service/CoinService.php
+1
-1
No files found.
api/controllers/CoinController.php
View file @
b0cf3615
...
...
@@ -84,6 +84,16 @@ class CoinController extends BaseController
Yii
::
$app
->
response
->
data
=
$data
;
}
public
function
actionGetCoinById
()
{
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
post
(
'id'
,
0
);
if
(
$id
)
{
return
CoinBusiness
::
getCoinAllById
(
$id
);
}
return
[];
}
/**
* 获取推介币种列表
*/
...
...
@@ -129,4 +139,6 @@ class CoinController extends BaseController
$condition
=
[[
'in'
,
'name'
,
$names
]];
Yii
::
$app
->
response
->
data
=
CoinBusiness
::
getApiListForIndex
(
$condition
);
}
}
\ No newline at end of file
common/business/CoinBusiness.php
View file @
b0cf3615
...
...
@@ -103,4 +103,19 @@ class CoinBusiness
}
return
[];
}
/**
* 获取币种的所有信息
*/
public
static
function
getCoinAllById
(
$id
)
{
$row
=
Coin
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
One
();
if
(
$row
)
{
//TODO 获取行情
$row
[
'quotation'
]
=
CoinService
::
quotation
(
$row
[
'sid'
]);
//TODO 获取交易所详情
$row
[
'exchange'
]
=
CoinService
::
exchange
(
$row
[
'sid'
]);
}
return
$row
?
$row
:
[];
}
}
\ No newline at end of file
common/service/CoinService.php
View file @
b0cf3615
...
...
@@ -577,7 +577,7 @@ class CoinService
$result
=
array_map
(
function
(
$value
)
{
return
trim
(
$value
);
},
$result
);
Yii
::
$app
->
cache
->
set
(
$key
,
$result
,
60
);
//set cache
Yii
::
$app
->
cache
->
set
(
$key
,
$result
,
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]
);
//set cache
return
$result
;
}
catch
(
\Exception
$exception
)
{
return
new
\stdClass
();
...
...
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