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
12b7c8a8
Commit
12b7c8a8
authored
Oct 18, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
Feature/ticker See merge request
!161
parents
680470cd
59d36a31
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
8 deletions
+14
-8
TickerController.php
api/controllers/TickerController.php
+10
-4
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+1
-1
FactoryService.php
common/service/exchange/factory/FactoryService.php
+1
-1
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+1
-1
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+1
-1
No files found.
api/controllers/TickerController.php
View file @
12b7c8a8
...
@@ -20,6 +20,7 @@ class TickerController extends BaseController
...
@@ -20,6 +20,7 @@ class TickerController extends BaseController
{
{
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
0
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data-value'
,
''
);
$data_value
=
Yii
::
$app
->
request
->
get
(
'data-value'
,
''
);
$sort
=
Yii
::
$app
->
request
->
get
(
'sort'
,
''
);
$sort
=
Yii
::
$app
->
request
->
get
(
'sort'
,
''
);
...
@@ -38,7 +39,12 @@ class TickerController extends BaseController
...
@@ -38,7 +39,12 @@ class TickerController extends BaseController
$data
=
$result
[
'data'
];
$data
=
$result
[
'data'
];
if
(
false
!=
$device_code
)
{
if
(
false
!=
$device_code
)
{
$coin_optional
=
CoinOptional
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform'
=>
$exchange
,
'device_code'
=>
$device_code
])
->
asArray
()
->
all
();
if
(
false
!=
$platform_id
)
{
$coin_optional
=
CoinOptional
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform'
=>
$exchange
,
'device_code'
=>
$device_code
])
->
asArray
()
->
all
();
}
else
{
$coin_optional
=
CoinOptional
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform'
=>
$exchange
,
'device_code'
=>
$device_code
,
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
}
$coin_optional
=
ArrayHelper
::
getColumn
(
$coin_optional
,
'symbol'
);
$coin_optional
=
ArrayHelper
::
getColumn
(
$coin_optional
,
'symbol'
);
foreach
(
$data
[
'ticker'
]
as
&
$val
)
{
foreach
(
$data
[
'ticker'
]
as
&
$val
)
{
if
(
in_array
(
$val
[
'symbol'
],
$coin_optional
))
{
if
(
in_array
(
$val
[
'symbol'
],
$coin_optional
))
{
...
@@ -67,7 +73,7 @@ class TickerController extends BaseController
...
@@ -67,7 +73,7 @@ class TickerController extends BaseController
$params
=
json_encode
(
$data
);
$params
=
json_encode
(
$data
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setRawPostData
(
$params
);
$curl
->
setRawPostData
(
$params
);
$res
=
$curl
->
post
(
'https://b.biqianbao.net
/interface/coin/coin-index'
,
true
);
$res
=
$curl
->
post
(
Yii
::
$app
->
params
[
'biqianbao'
]
.
'
/interface/coin/coin-index'
,
true
);
$res
=
json_decode
(
$res
,
true
);
$res
=
json_decode
(
$res
,
true
);
foreach
(
$res
[
'data'
]
as
$val
)
{
foreach
(
$res
[
'data'
]
as
$val
)
{
$this
->
basic_price
[
$val
[
'name'
]][
'rmb'
]
=
$val
[
'rmb'
];
$this
->
basic_price
[
$val
[
'name'
]][
'rmb'
]
=
$val
[
'rmb'
];
...
@@ -89,7 +95,7 @@ class TickerController extends BaseController
...
@@ -89,7 +95,7 @@ class TickerController extends BaseController
$msg
=
'参数错误'
;
$msg
=
'参数错误'
;
goto
doEnd
;
goto
doEnd
;
}
}
$model
=
CoinOptional
::
find
()
->
where
([
'device_code'
=>
$device_code
,
'symbol'
=>
$symbol
])
->
one
();
$model
=
CoinOptional
::
find
()
->
where
([
'device_code'
=>
$device_code
,
'symbol'
=>
$symbol
,
'platform_id'
=>
(
int
)
$platform_id
])
->
one
();
if
(
$model
)
{
if
(
$model
)
{
$msg
=
'数据已存在!'
;
$msg
=
'数据已存在!'
;
goto
doEnd
;
goto
doEnd
;
...
@@ -155,7 +161,7 @@ class TickerController extends BaseController
...
@@ -155,7 +161,7 @@ class TickerController extends BaseController
$temp
[
'close'
]
=
number_format
(
$quotation
[
'last'
],
6
,
'.'
,
''
);
$temp
[
'close'
]
=
number_format
(
$quotation
[
'last'
],
6
,
'.'
,
''
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'rmb'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$quotation
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.
4
f"
,
(
$quotation
[
'last'
]
-
$quotation
[
'open'
])
/
$quotation
[
'open'
]
*
100
);
$temp
[
'change'
]
=
(
0
==
$quotation
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.
2
f"
,
(
$quotation
[
'last'
]
-
$quotation
[
'open'
])
/
$quotation
[
'open'
]
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'low'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
*
$this
->
basic_price
[
$tag_second
][
'rmb'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$quotation
[
'high'
]
*
$this
->
basic_price
[
$tag_second
][
'rmb'
]);
...
...
common/service/exchange/factory/BinanceBuilder.php
View file @
12b7c8a8
...
@@ -90,7 +90,7 @@ class BinanceBuilder extends FactoryService
...
@@ -90,7 +90,7 @@ class BinanceBuilder extends FactoryService
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.
4
f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.
2
f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
...
...
common/service/exchange/factory/FactoryService.php
View file @
12b7c8a8
...
@@ -35,7 +35,7 @@ abstract class FactoryService
...
@@ -35,7 +35,7 @@ abstract class FactoryService
$params
=
json_encode
(
$data
);
$params
=
json_encode
(
$data
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setRawPostData
(
$params
);
$curl
->
setRawPostData
(
$params
);
$res
=
$curl
->
post
(
'http://127.0.0.1:8082
/interface/coin/coin-index'
,
true
);
$res
=
$curl
->
post
(
\Yii
::
$app
->
params
[
'biqianbao'
]
.
'
/interface/coin/coin-index'
,
true
);
$res
=
json_decode
(
$res
,
true
);
$res
=
json_decode
(
$res
,
true
);
foreach
(
$res
[
'data'
]
as
$val
)
{
foreach
(
$res
[
'data'
]
as
$val
)
{
...
...
common/service/exchange/factory/HuobiBuilder.php
View file @
12b7c8a8
...
@@ -90,7 +90,7 @@ class HuobiBuilder extends FactoryService
...
@@ -90,7 +90,7 @@ class HuobiBuilder extends FactoryService
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
false
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.
4
f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
false
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.
2
f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
12b7c8a8
...
@@ -41,7 +41,7 @@ class ZhaobiBuilder extends FactoryService
...
@@ -41,7 +41,7 @@ class ZhaobiBuilder extends FactoryService
$temp
[
'close'
]
=
number_format
(
$val
[
'last'
],
6
,
'.'
,
''
);
$temp
[
'close'
]
=
number_format
(
$val
[
'last'
],
6
,
'.'
,
''
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$val
[
'last'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$val
[
'last'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'last'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'last'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$val
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.
4
f"
,
(
$val
[
'last'
]
-
$val
[
'open'
])
/
$val
[
'open'
]
*
100
);
$temp
[
'change'
]
=
(
0
==
$val
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.
2
f"
,
(
$val
[
'last'
]
-
$val
[
'open'
])
/
$val
[
'open'
]
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
...
...
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