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
7c8ae3b7
Commit
7c8ae3b7
authored
Jun 20, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口更新
parent
20e6e1a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
46 deletions
+84
-46
CoinBTYService.php
common/service/coin/CoinBTYService.php
+83
-45
CoinYCCService.php
common/service/coin/CoinYCCService.php
+1
-1
No files found.
common/service/coin/CoinBTYService.php
View file @
7c8ae3b7
...
@@ -31,12 +31,12 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -31,12 +31,12 @@ class CoinBTYService extends Coin implements CoinInterface
public
function
quotation
()
public
function
quotation
()
{
{
$result
=
[
$result
=
[
'price'
=>
''
,
//价格
'price'
=>
$this
->
getPrice
()
,
//价格
'dollar'
=>
''
,
//价格美元
'dollar'
=>
$this
->
getDollar
()
,
//价格美元
'btc'
=>
''
,
//价格btc
'btc'
=>
''
,
//价格btc
'high'
=>
''
,
//最高价
'high'
=>
$this
->
getHigh
()
,
//最高价
'low'
=>
''
,
//最低价
'low'
=>
$this
->
getLow
()
,
//最低价
'change'
=>
''
,
//涨幅(跌幅)
'change'
=>
$this
->
getChange
()
,
//涨幅(跌幅)
'rank'
=>
''
,
//流通市值排名
'rank'
=>
''
,
//流通市值排名
'circulate_value_rmb'
=>
''
,
//流通市值人民币
'circulate_value_rmb'
=>
''
,
//流通市值人民币
'circulate_value_usd'
=>
''
,
//流通市值美元
'circulate_value_usd'
=>
''
,
//流通市值美元
...
@@ -44,27 +44,6 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -44,27 +44,6 @@ class CoinBTYService extends Coin implements CoinInterface
'publish_count'
=>
''
,
//发行总量
'publish_count'
=>
''
,
//发行总量
'circulate_count'
=>
''
,
//流通总量
'circulate_count'
=>
''
,
//流通总量
];
];
$ch
=
curl_init
(
'https://kdata.zhaobi.com:4062/kdata?datafile=db&c=BTYUSDT&p=H1&action=init&count=24&ind=volumes&out=json'
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
0
);
$content
=
curl_exec
(
$ch
);
$content
=
json_decode
(
$content
,
true
);
$content
=
$content
[
'main'
][
'y'
];
$min
=
10e9
;
$max
=
0
;
foreach
(
$content
as
$item
)
{
for
(
$i
=
0
;
$i
<
4
;
$i
++
)
{
$min
=
min
(
$min
,
$item
[
$i
]);
$max
=
max
(
$max
,
$item
[
$i
]);
}
}
$change
=
(
$content
[
23
][
3
]
-
$content
[
0
][
0
])
/
$content
[
0
][
0
]
*
100
;
$result
[
'dollar'
]
=
$content
[
23
][
3
];
$result
[
'low'
]
=
$min
;
$result
[
'high'
]
=
$max
;
$result
[
'change'
]
=
sprintf
(
"%0.2f%%"
,
$change
);
return
$result
;
return
$result
;
}
}
...
@@ -72,14 +51,31 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -72,14 +51,31 @@ class CoinBTYService extends Coin implements CoinInterface
{
{
$this
->
id
=
$id
;
$this
->
id
=
$id
;
$this
->
sid
=
$sid
;
$this
->
sid
=
$sid
;
$this
->
init
();
}
}
public
function
init
()
public
function
init
()
{
{
$url
=
'https://kdata.zhaobi.com:4062/kdata?datafile=db&c=BTYUSDT&p=H1&action=init&count=24&ind=volumes&out=json'
;
$key
=
$this
->
cache_key_prifx
.
$this
->
sid
.
'all'
;
$ch
=
new
Curl
();
$result
=
Yii
::
$app
->
cache
->
get
(
$key
);
$content
=
$ch
->
get
(
$url
,
false
);
if
(
$result
===
false
)
{
$this
->
content
=
$content
;
$url
=
'https://zb2api.licai.cn/api/data/Ticker?sort=cname'
;
$ch
=
new
Curl
();
$content
=
$ch
->
get
(
$url
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'code'
])
&&
$content
[
'code'
]
==
200
)
{
$data
=
$content
[
'data'
][
'USDT'
];
foreach
(
$data
as
$item
)
{
if
(
$item
[
'symbol'
]
==
'BTYUSDT'
)
{
$data
=
$item
;
break
;
}
}
$this
->
content
=
$data
;
Yii
::
$app
->
cache
->
set
(
$key
,
$data
,
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
}
}
else
{
$this
->
content
=
$result
;
}
}
}
public
function
__destruct
()
public
function
__destruct
()
...
@@ -89,30 +85,25 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -89,30 +85,25 @@ class CoinBTYService extends Coin implements CoinInterface
public
function
getPrice
()
public
function
getPrice
()
{
{
return
0
;
if
(
$this
->
content
)
{
$this
->
setPrice
(
$this
->
content
[
'lastrmb'
]);
}
else
{
return
0
;
}
return
$this
->
price
;
}
}
public
function
setPrice
(
$price
)
public
function
setPrice
(
$price
)
{
{
return
0
;
return
$this
->
price
=
"¥
$price
"
;
}
}
public
function
getDollar
()
public
function
getDollar
()
{
{
$key
=
$this
->
cache_key_prifx
.
$this
->
sid
.
'_usd'
;
if
(
$this
->
content
)
{
$result
=
Yii
::
$app
->
cache
->
get
(
$key
);
$this
->
setDollar
(
$this
->
content
[
'last'
]);
if
(
!
$result
)
{
if
(
empty
(
$this
->
content
))
{
$this
->
init
();
}
if
(
is_array
(
$this
->
content
)
&&
isset
(
$this
->
content
[
'main'
][
'y'
][
23
][
3
]))
{
$this
->
setDollar
(
$this
->
content
[
'main'
][
'y'
][
23
][
3
]);
Yii
::
$app
->
cache
->
set
(
$key
,
$this
->
dollar
,
Yii
::
$app
->
params
[
'curl_cache_time'
][
'quotation'
]);
}
else
{
$this
->
setDollar
(
0
);
}
}
else
{
}
else
{
return
$result
;
return
0
;
}
}
return
$this
->
dollar
;
return
$this
->
dollar
;
}
}
...
@@ -122,4 +113,50 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -122,4 +113,50 @@ class CoinBTYService extends Coin implements CoinInterface
$this
->
dollar
=
"≈
\$
$dollar
"
;
$this
->
dollar
=
"≈
\$
$dollar
"
;
}
}
public
function
getHigh
()
{
if
(
$this
->
content
)
{
$this
->
setHigh
(
$this
->
content
[
'high'
]);
}
else
{
return
0
;
}
return
$this
->
high
;
}
public
function
setHigh
(
$high
)
{
return
$this
->
high
=
"
\$
$high
"
;
}
public
function
getLow
()
{
if
(
$this
->
content
)
{
$this
->
setLow
(
$this
->
content
[
'low'
]);
}
else
{
return
0
;
}
return
$this
->
low
;
}
public
function
setLow
(
$low
)
{
$this
->
low
=
"
\$
$low
"
;
}
public
function
getChange
()
{
if
(
$this
->
content
)
{
$this
->
setChange
(
$this
->
content
[
'range'
]);
}
else
{
return
0
;
}
return
$this
->
change
;
}
public
function
setChange
(
$change
)
{
$this
->
change
=
"
$change
%"
;
}
}
}
\ No newline at end of file
common/service/coin/CoinYCCService.php
View file @
7c8ae3b7
...
@@ -66,7 +66,7 @@ class CoinYCCService extends Coin implements CoinInterface
...
@@ -66,7 +66,7 @@ class CoinYCCService extends Coin implements CoinInterface
public
function
getPrice
()
public
function
getPrice
()
{
{
return
0
;
return
"¥0.2"
;
}
}
public
function
setPrice
(
$price
)
public
function
setPrice
(
$price
)
...
...
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