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
01ec0d92
Commit
01ec0d92
authored
Dec 05, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
找币行情单独获取
parent
7902a899
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
0 deletions
+60
-0
MarketController.php
api/controllers/MarketController.php
+34
-0
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+1
-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 @
01ec0d92
<?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/business/ExchangeBusiness.php
View file @
01ec0d92
...
...
@@ -344,6 +344,7 @@ class ExchangeBusiness
public
static
function
setQuotation
()
{
foreach
(
self
::
$exchanges
as
$exchange
)
{
if
(
'ZHAOBI'
==
strtoupper
(
$exchange
))
continue
;
/**
* @var $exchange \common\service\exchange\ExchangeInterface
*/
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
01ec0d92
...
...
@@ -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 @
01ec0d92
...
...
@@ -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