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
a702c826
Commit
a702c826
authored
Dec 05, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
Feature/ticker See merge request
!240
parents
aa0b2219
9fc97892
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
0 deletions
+59
-0
MarketController.php
api/controllers/MarketController.php
+34
-0
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+16
-0
TickerController.php
console/controllers/TickerController.php
+9
-0
No files found.
api/controllers/MarketController.php
0 → 100644
View file @
a702c826
<?php
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\service\exchange\ExchangeBuilderFactory
;
class
MarketController
extends
BaseController
{
public
function
actionDetail
()
{
$symbol
=
Yii
::
$app
->
request
->
get
(
'symbol'
,
''
);
if
(
false
==
$symbol
)
{
$msg
=
'invalid symbol'
;
$code
=
-
1
;
goto
doEnd
;
}
$builder
=
ExchangeBuilderFactory
::
create
(
'Zhaobi'
);
$result
=
$builder
->
getDetail
(
$symbol
);
if
(
-
1
==
$result
[
'code'
]){
$msg
=
'invalid symbol'
;
$code
=
-
1
;
goto
doEnd
;
}
$code
=
0
;
$msg
=
'ok'
;
$ticker
=
$result
[
'ticker'
];
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'tick'
=>
$ticker
??
[]];
}
}
\ No newline at end of file
common/service/exchange/factory/ZhaobiBuilder.php
View file @
a702c826
...
...
@@ -167,6 +167,22 @@ class ZhaobiBuilder extends FactoryService
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$data
];
}
public
function
getDetail
(
$symbol
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$symbol
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
if
(
empty
(
$low
)
&&
empty
(
$high
)
&&
empty
(
$close
)
&&
empty
(
$open
)
&&
empty
(
$vol
))
{
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
[]];
}
$ticker
=
[
'vol'
=>
$vol
,
'low'
=>
$low
,
'open'
=>
$open
,
'high'
=>
$high
,
'close'
=>
$close
];
return
[
'code'
=>
0
,
'ticker'
=>
$ticker
];
}
public
function
getHotTicker
(
$symbol
=
[])
{
if
(
empty
(
$symbol
))
{
...
...
console/controllers/TickerController.php
View file @
a702c826
...
...
@@ -2,6 +2,7 @@
namespace
console\controllers
;
use
common\service\exchange\ExchangeFactory
;
use
Yii
;
use
linslin\yii2\curl\Curl
;
use
yii\console\Controller
;
...
...
@@ -33,6 +34,14 @@ class TickerController extends Controller
return
0
;
}
public
function
actionExchange
(
$exchange
)
{
$ticker_builder
=
ExchangeFactory
::
createExchange
(
$exchange
);
$ticker_builder
->
setQuotation
();
echo
date
(
'Y-m-d H:i:s'
)
.
$exchange
.
'更新成功'
.
PHP_EOL
;
return
0
;
}
public
function
actionCurrency
()
{
$currency_model
=
CoinSupportedCurrency
::
find
()
->
groupBy
(
'currency_id'
)
->
all
();
...
...
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