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
9b1035ad
Commit
9b1035ad
authored
Jun 19, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
结构规范
parent
4f70fb8a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
151 deletions
+46
-151
CoinBusiness.php
common/business/CoinBusiness.php
+7
-4
CoinBTYService.php
common/service/coin/CoinBTYService.php
+39
-103
CoinService.php
common/service/coin/CoinService.php
+0
-44
No files found.
common/business/CoinBusiness.php
View file @
9b1035ad
...
@@ -35,6 +35,7 @@ class CoinBusiness
...
@@ -35,6 +35,7 @@ class CoinBusiness
//获取交易所信息
//获取交易所信息
$coin
=
CoinFactory
::
createCoin
(
$value
[
'name'
],
$value
[
'id'
],
$value
[
'sid'
]);
$coin
=
CoinFactory
::
createCoin
(
$value
[
'name'
],
$value
[
'id'
],
$value
[
'sid'
]);
$rows
[
'data'
][
$key
][
'exchange'
]
=
$coin
->
exchange_count
();
$rows
[
'data'
][
$key
][
'exchange'
]
=
$coin
->
exchange_count
();
$coin
->
__destruct
();
}
}
}
}
return
$rows
;
return
$rows
;
...
@@ -53,6 +54,7 @@ class CoinBusiness
...
@@ -53,6 +54,7 @@ class CoinBusiness
if
(
$coin
)
{
if
(
$coin
)
{
$model
=
CoinFactory
::
createCoin
(
$coin
->
name
,
$coin
->
id
,
$coin
->
sid
);
$model
=
CoinFactory
::
createCoin
(
$coin
->
name
,
$coin
->
id
,
$coin
->
sid
);
$datas
=
$model
->
exchange
();
$datas
=
$model
->
exchange
();
$model
->
__destruct
();
if
(
$datas
[
'count'
]
>
0
)
{
if
(
$datas
[
'count'
]
>
0
)
{
return
$datas
[
'data'
];
return
$datas
[
'data'
];
}
}
...
@@ -76,6 +78,7 @@ class CoinBusiness
...
@@ -76,6 +78,7 @@ class CoinBusiness
foreach
(
$rows
as
$key
=>
$value
)
{
foreach
(
$rows
as
$key
=>
$value
)
{
$coin
=
CoinFactory
::
createCoin
(
$value
[
'name'
],
$value
[
'id'
],
$value
[
'sid'
]);
$coin
=
CoinFactory
::
createCoin
(
$value
[
'name'
],
$value
[
'id'
],
$value
[
'sid'
]);
$rows
[
$key
][
'quotation'
]
=
$coin
->
quotation
();
$rows
[
$key
][
'quotation'
]
=
$coin
->
quotation
();
$coin
->
__destruct
();
}
}
}
}
return
$rows
;
return
$rows
;
...
@@ -129,6 +132,7 @@ class CoinBusiness
...
@@ -129,6 +132,7 @@ class CoinBusiness
/**
/**
* 获取币种的所有信息
* 获取币种的所有信息
* @param integer $id
* @return array
* @return array
*/
*/
public
static
function
getCoinAllById
(
$id
)
public
static
function
getCoinAllById
(
$id
)
...
@@ -136,10 +140,9 @@ class CoinBusiness
...
@@ -136,10 +140,9 @@ class CoinBusiness
$row
=
Coin
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
One
();
$row
=
Coin
::
find
()
->
where
([
'id'
=>
$id
])
->
asArray
()
->
One
();
if
(
$row
)
{
if
(
$row
)
{
$coin
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$coin
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
//TODO 获取行情
$row
[
'quotation'
]
=
$coin
->
quotation
();
$row
[
'quotation'
]
=
$coin
->
quotation
(
$row
[
'sid'
]);
$row
[
'exchange'
]
=
$coin
->
exchange
();
//TODO 获取交易所详情
$coin
->
__destruct
();
$row
[
'exchange'
]
=
$coin
->
exchange
(
$row
[
'sid'
]);
}
}
return
$row
?
[
$row
]
:
[];
return
$row
?
[
$row
]
:
[];
}
}
...
...
common/service/coin/CoinBTYService.php
View file @
9b1035ad
...
@@ -22,9 +22,47 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -22,9 +22,47 @@ class CoinBTYService extends Coin implements CoinInterface
return
0
;
return
0
;
}
}
/**
* 行情获取
*/
public
function
quotation
()
public
function
quotation
()
{
{
// TODO: Implement quotation() method.
$result
=
[
'price'
=>
''
,
//价格
'dollar'
=>
''
,
//价格美元
'btc'
=>
''
,
//价格btc
'high'
=>
''
,
//最高价
'low'
=>
''
,
//最低价
'change'
=>
''
,
//涨幅(跌幅)
'rank'
=>
''
,
//流通市值排名
'circulate_value_rmb'
=>
''
,
//流通市值人民币
'circulate_value_usd'
=>
''
,
//流通市值美元
'circulate_value_btc'
=>
''
,
//流通市值btc
'publish_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
;
}
}
public
function
__construct
(
$id
,
$sid
)
public
function
__construct
(
$id
,
$sid
)
...
@@ -62,105 +100,4 @@ class CoinBTYService extends Coin implements CoinInterface
...
@@ -62,105 +100,4 @@ class CoinBTYService extends Coin implements CoinInterface
parent
::
setDollar
(
$dollar
);
// TODO: Change the autogenerated stub
parent
::
setDollar
(
$dollar
);
// TODO: Change the autogenerated stub
}
}
public
function
getBtc
()
{
return
parent
::
getBtc
();
// TODO: Change the autogenerated stub
}
public
function
setBtc
(
$btc
)
{
parent
::
setBtc
(
$btc
);
// TODO: Change the autogenerated stub
}
public
function
getHigh
()
{
return
parent
::
getHigh
();
// TODO: Change the autogenerated stub
}
public
function
setHigh
(
$high
)
{
parent
::
setHigh
(
$high
);
// TODO: Change the autogenerated stub
}
public
function
getLow
()
{
return
parent
::
getLow
();
// TODO: Change the autogenerated stub
}
public
function
setLow
(
$low
)
{
parent
::
setLow
(
$low
);
// TODO: Change the autogenerated stub
}
public
function
getChange
()
{
return
parent
::
getChange
();
// TODO: Change the autogenerated stub
}
public
function
setChange
(
$change
)
{
parent
::
setChange
(
$change
);
// TODO: Change the autogenerated stub
}
public
function
getRank
()
{
return
parent
::
getRank
();
// TODO: Change the autogenerated stub
}
public
function
setRank
(
$rank
)
{
parent
::
setRank
(
$rank
);
// TODO: Change the autogenerated stub
}
public
function
getCirculateValueRmb
()
{
return
parent
::
getCirculateValueRmb
();
// TODO: Change the autogenerated stub
}
public
function
setCirculateValueRmb
(
$circulate_value_rmb
)
{
parent
::
setCirculateValueRmb
(
$circulate_value_rmb
);
// TODO: Change the autogenerated stub
}
public
function
getCirculateValueUsd
()
{
return
parent
::
getCirculateValueUsd
();
// TODO: Change the autogenerated stub
}
public
function
setCirculateValueUsd
(
$circulate_value_usd
)
{
parent
::
setCirculateValueUsd
(
$circulate_value_usd
);
// TODO: Change the autogenerated stub
}
public
function
getCirculateValueBtc
()
{
return
parent
::
getCirculateValueBtc
();
// TODO: Change the autogenerated stub
}
public
function
setCirculateValueBtc
(
$circulate_value_btc
)
{
parent
::
setCirculateValueBtc
(
$circulate_value_btc
);
// TODO: Change the autogenerated stub
}
public
function
getPublishCount
()
{
return
parent
::
getPublishCount
();
// TODO: Change the autogenerated stub
}
public
function
setPublishCount
(
$publish_count
)
{
parent
::
setPublishCount
(
$publish_count
);
// TODO: Change the autogenerated stub
}
public
function
getCirculateCount
()
{
return
parent
::
getCirculateCount
();
// TODO: Change the autogenerated stub
}
public
function
setCirculateCount
(
$circulate_count
)
{
parent
::
setCirculateCount
(
$circulate_count
);
// TODO: Change the autogenerated stub
}
}
}
\ No newline at end of file
common/service/coin/CoinService.php
View file @
9b1035ad
...
@@ -564,47 +564,4 @@ class CoinService extends Coin implements CoinInterface
...
@@ -564,47 +564,4 @@ class CoinService extends Coin implements CoinInterface
}
}
return
$result
;
return
$result
;
}
}
/**
* 快速修复方法,之后再改
*/
public
static
function
quotationBTY
()
{
$result
=
[
'price'
=>
''
,
//价格
'dollar'
=>
''
,
//价格美元
'btc'
=>
''
,
//价格btc
'high'
=>
''
,
//最高价
'low'
=>
''
,
//最低价
'change'
=>
''
,
//涨幅(跌幅)
'rank'
=>
''
,
//流通市值排名
'circulate_value_rmb'
=>
''
,
//流通市值人民币
'circulate_value_usd'
=>
''
,
//流通市值美元
'circulate_value_btc'
=>
''
,
//流通市值btc
'publish_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
;
}
}
}
\ No newline at end of file
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