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
b804c441
Commit
b804c441
authored
Jun 28, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页接口v2
parent
c4a45aed
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
6 deletions
+29
-6
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+14
-0
CoinBTYService.php
common/service/coin/CoinBTYService.php
+2
-2
Bitfinex.php
common/service/exchange/Bitfinex.php
+9
-0
Exchange.php
common/service/exchange/Exchange.php
+2
-2
ExchangeController.php
console/controllers/ExchangeController.php
+2
-2
No files found.
common/business/ExchangeBusiness.php
View file @
b804c441
...
@@ -10,6 +10,7 @@ namespace common\business;
...
@@ -10,6 +10,7 @@ namespace common\business;
use
common\models\pwallet\Coin
;
use
common\models\pwallet\Coin
;
use
common\service\exchange\ExchangeFactory
;
use
common\service\exchange\ExchangeFactory
;
use
common\service\coin\CoinFactory
;
/**
/**
* Class ExchangeBusiness
* Class ExchangeBusiness
...
@@ -22,6 +23,8 @@ class ExchangeBusiness
...
@@ -22,6 +23,8 @@ class ExchangeBusiness
0
=>
'HuoBi'
,
0
=>
'HuoBi'
,
1
=>
'Hadax'
,
1
=>
'Hadax'
,
2
=>
'Bitfinex'
,
2
=>
'Bitfinex'
,
3
=>
'Bittrex'
,
4
=>
'Zb'
,
];
];
/**
/**
...
@@ -96,10 +99,21 @@ class ExchangeBusiness
...
@@ -96,10 +99,21 @@ class ExchangeBusiness
},
$price_btc
,
$btc_usd
);
},
$price_btc
,
$btc_usd
);
$rows
[
$key
]
=
array_merge
(
$rows
[
$key
],
$rows
[
$key
]
=
array_merge
(
$rows
[
$key
],
[
'low'
=>
$result
[
0
],
'high'
=>
$result
[
1
],
'last'
=>
$result
[
2
]]);
[
'low'
=>
$result
[
0
],
'high'
=>
$result
[
1
],
'last'
=>
$result
[
2
]]);
$f
=
true
;
break
;
break
;
}
}
}
}
}
}
if
(
!
$f
)
{
//使用Coin服务
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$rows
[
$key
][
'rmb'
]
=
$coinServer
->
getPrice
();
$rows
[
$key
][
'last'
]
=
$coinServer
->
getDollar
();
$rows
[
$key
][
'low'
]
=
$coinServer
->
getLow
();
$rows
[
$key
][
'high'
]
=
$coinServer
->
getHigh
();
$coinServer
->
__destruct
();
}
}
}
return
$rows
;
return
$rows
;
}
}
...
...
common/service/coin/CoinBTYService.php
View file @
b804c441
...
@@ -125,7 +125,7 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -125,7 +125,7 @@ class CoinBTYService extends Coin implements CoinInterface
public
function
setHigh
(
$high
)
public
function
setHigh
(
$high
)
{
{
return
$this
->
high
=
"
\$
$high
"
;
return
$this
->
high
=
$high
;
}
}
public
function
getLow
()
public
function
getLow
()
...
@@ -140,7 +140,7 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -140,7 +140,7 @@ class CoinBTYService extends Coin implements CoinInterface
public
function
setLow
(
$low
)
public
function
setLow
(
$low
)
{
{
$this
->
low
=
"
\$
$low
"
;
$this
->
low
=
$low
;
}
}
public
function
getChange
()
public
function
getChange
()
...
...
common/service/exchange/Bitfinex.php
View file @
b804c441
...
@@ -16,6 +16,15 @@ class Bitfinex extends Exchange implements ExchangeInterface
...
@@ -16,6 +16,15 @@ class Bitfinex extends Exchange implements ExchangeInterface
protected
$supported_symbol
=
'supported_symbol_bitfinex'
;
protected
$supported_symbol
=
'supported_symbol_bitfinex'
;
protected
$quotation_prefix
=
'quotation_bitfinex_'
;
protected
$quotation_prefix
=
'quotation_bitfinex_'
;
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
;
}
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USD'
)
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USD'
)
{
{
return
't'
.
strtoupper
(
trim
(
$tag
)
.
trim
(
$aim
));
return
't'
.
strtoupper
(
trim
(
$tag
)
.
trim
(
$aim
));
...
...
common/service/exchange/Exchange.php
View file @
b804c441
...
@@ -49,7 +49,7 @@ abstract class Exchange
...
@@ -49,7 +49,7 @@ abstract class Exchange
* @param string $aim
* @param string $aim
* @return mixed
* @return mixed
*/
*/
abstract
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USD'
);
abstract
public
function
formatSymbol
(
$tag
=
'BTC'
,
$aim
=
'USD
T
'
);
/**
/**
* 获取支持查询行情的交易对
* 获取支持查询行情的交易对
...
@@ -58,7 +58,7 @@ abstract class Exchange
...
@@ -58,7 +58,7 @@ abstract class Exchange
* @param string $aim
* @param string $aim
* @return bool
* @return bool
*/
*/
public
function
symbolExists
(
$tag
=
'BTC'
,
$aim
=
"USD"
)
public
function
symbolExists
(
$tag
=
'BTC'
,
$aim
=
"USD
T
"
)
{
{
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
...
...
console/controllers/ExchangeController.php
View file @
b804c441
...
@@ -37,8 +37,8 @@ class ExchangeController extends Controller
...
@@ -37,8 +37,8 @@ class ExchangeController extends Controller
public
function
actionTest
()
public
function
actionTest
()
{
{
$a
=
new
\common\service\exchange\
Bittrex
();
$a
=
new
\common\service\exchange\
Zb
();
//
$a->setSupportedSymbol();
$a
->
setSupportedSymbol
();
$a
->
setQuotation
();
$a
->
setQuotation
();
}
}
...
...
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