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
e42f9351
Commit
e42f9351
authored
Mar 27, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug
parent
b5b4cb8a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
2 deletions
+56
-2
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+7
-0
Exchange.php
common/service/exchange/Exchange.php
+9
-0
Token7.php
common/service/exchange/Token7.php
+40
-2
No files found.
common/business/ExchangeBusiness.php
View file @
e42f9351
...
...
@@ -65,6 +65,13 @@ class ExchangeBusiness
* @var $exchange \common\service\exchange\Exchange
*/
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
if
(
'GM'
==
$tag
||
'BSTC'
==
$tag
){
$quotation
=
$exchange
->
getTickerToken7
(
$tag
,
'HA'
);
$f
=
true
;
break
;
}
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
if
(
$exchange
->
symbolExists
(
$tag
))
{
$quotation
=
$exchange
->
getTicker
(
$tag
);
$f
=
true
;
...
...
common/service/exchange/Exchange.php
View file @
e42f9351
...
...
@@ -81,4 +81,12 @@ abstract class Exchange
$values
=
$this
->
redis
->
hvals
(
$this
->
quotation_prefix
.
$symbol
);
return
array_combine
(
$keys
,
$values
);
}
public
function
getTickerToken7
(
$tag
=
'BTC'
,
$aim
=
"USDT"
)
{
$symbol
=
$this
->
formatSymbol
(
$tag
,
$aim
);
$keys
=
$this
->
redis
->
hkeys
(
$this
->
quotation_prefix
.
$symbol
);
$values
=
$this
->
redis
->
hvals
(
$this
->
quotation_prefix
.
$symbol
);
return
array_combine
(
$keys
,
$values
);
}
}
\ No newline at end of file
common/service/exchange/Token7.php
View file @
e42f9351
...
...
@@ -14,6 +14,15 @@ class Token7 extends Exchange implements ExchangeInterface
protected
$quotation_prefix
=
'quotation_token7_'
;
protected
$base_url
=
'http://www.token7.club/exapi/api/v1/allTicker'
;
public
function
symbolExists
(
$tag
=
'BTC'
,
$aim
=
"USD"
)
{
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
return
true
;
}
return
false
;
}
/**
* 转化交易对为请求变量
*
...
...
@@ -21,9 +30,9 @@ class Token7 extends Exchange implements ExchangeInterface
* @param string $aim
* @return mixed
*/
public
function
formatSymbol
(
$tag
=
'
BTC'
,
$aim
=
'USDT
'
)
public
function
formatSymbol
(
$tag
=
'
GM'
,
$aim
=
'HA
'
)
{
return
strtoupper
(
$tag
.
$aim
);
return
strtoupper
(
$tag
.
'_'
.
$aim
);
}
/**
...
...
@@ -44,6 +53,35 @@ class Token7 extends Exchange implements ExchangeInterface
public
function
setQuotation
()
{
$content
=
$this
->
ch
->
get
(
$this
->
base_url
,
false
);
$content
=
[
"date"
=>
"2019-03-27 14:28:08"
,
"ticker"
=>
[
[
"symbol"
=>
"GM_HA"
,
"vol"
=>
"759301.65"
,
"high"
=>
"2.608"
,
"last"
=>
"2.607"
,
"low"
=>
"2.607"
,
"sell"
=>
"2.615"
,
"buy"
=>
"2.613"
,
"yesterdayPrice"
=>
"2.609"
,
"change"
=>
"-0.077"
,
"lastExchangPrice"
=>
"2.608"
],
[
"symbol"
=>
"BSTC_HA"
,
"vol"
=>
"321550.59"
,
"high"
=>
"0.029"
,
"last"
=>
"0.029"
,
"low"
=>
"0.029"
,
"sell"
=>
"0.029"
,
"buy"
=>
"0.028"
,
"yesterdayPrice"
=>
"0.027"
,
"change"
=>
"7.407"
,
"lastExchangPrice"
=>
"0.029"
]
]
];
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'date'
])
&&
isset
(
$content
[
'ticker'
]))
{
$data
=
$content
[
'ticker'
];
foreach
(
$data
as
$item
)
{
...
...
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