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
014c24e6
Commit
014c24e6
authored
Sep 10, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
逻辑调整
parent
7bb31ae7
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
16 deletions
+20
-16
TickerController.php
api/controllers/TickerController.php
+2
-13
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+6
-1
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+6
-1
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+6
-1
No files found.
api/controllers/TickerController.php
View file @
014c24e6
...
@@ -37,8 +37,7 @@ class TickerController extends BaseController
...
@@ -37,8 +37,7 @@ class TickerController extends BaseController
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$request
=
Yii
::
$app
->
request
;
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$device_code
=
$request
->
get
(
'device_code'
,
''
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
...
@@ -49,19 +48,9 @@ class TickerController extends BaseController
...
@@ -49,19 +48,9 @@ class TickerController extends BaseController
goto
doEnd
;
goto
doEnd
;
}
}
$builder
=
ExchangeBuilderFactory
::
create
(
$exchange
);
$builder
=
ExchangeBuilderFactory
::
create
(
$exchange
);
$result
=
$builder
->
getTicker
();
$result
=
$builder
->
getTicker
(
$device_code
);
$code
=
$result
[
'code'
];
$code
=
$result
[
'code'
];
$data
=
$result
[
'ticker'
];
$data
=
$result
[
'ticker'
];
if
(
false
!=
$device_code
&&
Yii
::
$app
->
redis_app
->
exists
(
$device_code
.
'_'
.
$exchange
))
{
foreach
(
$data
as
&
$val
)
{
if
(
Yii
::
$app
->
redis_app
->
sismember
(
$device_code
.
'_'
.
$exchange
,
$val
[
'symbol'
]))
{
$val
[
'optional'
]
=
true
;
}
else
{
$val
[
'optional'
]
=
false
;
}
}
}
$msg
=
'success'
;
$msg
=
'success'
;
doEnd
:
doEnd
:
...
...
common/service/exchange/factory/BinanceBuilder.php
View file @
014c24e6
...
@@ -14,7 +14,7 @@ class BinanceBuilder extends FactoryService
...
@@ -14,7 +14,7 @@ class BinanceBuilder extends FactoryService
{
{
protected
$base_url
=
'https://api.binance.com'
;
protected
$base_url
=
'https://api.binance.com'
;
public
function
getTicker
()
public
function
getTicker
(
$device_code
=
''
)
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/v1/ticker/24hr'
;
$api
=
$this
->
base_url
.
'/api/v1/ticker/24hr'
;
...
@@ -36,6 +36,11 @@ class BinanceBuilder extends FactoryService
...
@@ -36,6 +36,11 @@ class BinanceBuilder extends FactoryService
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'highPrice'
]);
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'highPrice'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'lowPrice'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'lowPrice'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'volume'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'volume'
]);
if
(
\Yii
::
$app
->
redis_app
->
sismember
(
$device_code
.
'_binance'
,
$val
[
'symbol'
]))
{
$temp
[
'optional'
]
=
true
;
}
else
{
$temp
[
'optional'
]
=
false
;
}
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
break
;
break
;
}
}
...
...
common/service/exchange/factory/HuobiBuilder.php
View file @
014c24e6
...
@@ -14,7 +14,7 @@ class HuobiBuilder extends FactoryService
...
@@ -14,7 +14,7 @@ class HuobiBuilder extends FactoryService
{
{
protected
$base_url
=
'https://api.huobi.pro'
;
protected
$base_url
=
'https://api.huobi.pro'
;
public
function
getTicker
()
public
function
getTicker
(
$device_code
=
''
)
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/market/tickers'
;
$api
=
$this
->
base_url
.
'/market/tickers'
;
...
@@ -36,6 +36,11 @@ class HuobiBuilder extends FactoryService
...
@@ -36,6 +36,11 @@ class HuobiBuilder extends FactoryService
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]);
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
if
(
\Yii
::
$app
->
redis_app
->
sismember
(
$device_code
.
'_huobi'
,
$val
[
'symbol'
]))
{
$temp
[
'optional'
]
=
true
;
}
else
{
$temp
[
'optional'
]
=
false
;
}
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
break
;
break
;
}
}
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
014c24e6
...
@@ -14,7 +14,7 @@ class ZhaobiBuilder extends FactoryService
...
@@ -14,7 +14,7 @@ class ZhaobiBuilder extends FactoryService
{
{
protected
$base_url
=
'https://api.biqianbao.top'
;
protected
$base_url
=
'https://api.biqianbao.top'
;
public
function
getTicker
()
public
function
getTicker
(
$device_code
=
''
)
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/api/data/Ticker?sort=cname'
;
$api
=
$this
->
base_url
.
'/api/data/Ticker?sort=cname'
;
...
@@ -40,6 +40,11 @@ class ZhaobiBuilder extends FactoryService
...
@@ -40,6 +40,11 @@ class ZhaobiBuilder extends FactoryService
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]);
$temp
[
'high'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]);
$temp
[
'low'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
if
(
\Yii
::
$app
->
redis_app
->
sismember
(
$device_code
.
'_zhaobi'
,
$val
[
'symbol'
]))
{
$temp
[
'optional'
]
=
true
;
}
else
{
$temp
[
'optional'
]
=
false
;
}
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
break
;
break
;
}
}
...
...
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