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
21ef0982
Commit
21ef0982
authored
Nov 19, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
热门行情可自定义
parent
536399a2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
23 deletions
+73
-23
TickerController.php
api/controllers/TickerController.php
+38
-5
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+7
-12
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+28
-6
No files found.
api/controllers/TickerController.php
View file @
21ef0982
...
@@ -21,7 +21,7 @@ class TickerController extends BaseController
...
@@ -21,7 +21,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
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'
platform_id
'
,
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_value
=
Yii
::
$app
->
request
->
get
(
'sort_value'
,
''
);
$sort_value
=
Yii
::
$app
->
request
->
get
(
'sort_value'
,
''
);
...
@@ -283,10 +283,43 @@ class TickerController extends BaseController
...
@@ -283,10 +283,43 @@ class TickerController extends BaseController
public
function
actionHotTicker
()
public
function
actionHotTicker
()
{
{
$builder
=
ExchangeBuilderFactory
::
create
(
'huobi'
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
0
);
$result
=
$builder
->
getHotTicker
();
if
(
17
==
$platform_id
)
{
$code
=
$result
[
'code'
];
$datas
=
[
$data
=
$result
[
'ticker'
];
[
'exchange'
=>
'huobi'
,
'symbol'
=>
[
'btcusdt'
,
'ethusdt'
,
'eosusdt'
]
]
];
}
else
{
$datas
=
[
[
'exchange'
=>
'huobi'
,
'symbol'
=>
[
'btcusdt'
,
'ethusdt'
]
],[
'exchange'
=>
'zhaobi'
,
'symbol'
=>
[
'btyusdt'
]
]
];
}
$ticker
=
[];
foreach
(
$datas
as
$data
)
{
$builder
=
ExchangeBuilderFactory
::
create
(
$data
[
'exchange'
]);
$result
=
$builder
->
getHotTicker
(
$data
[
'symbol'
]);
if
(
0
!=
$result
[
'code'
])
continue
;
$ticker
=
array_merge
(
$ticker
,
$result
[
'ticker'
]);
}
$code
=
0
;
$data
=
$ticker
;
$msg
=
'success'
;
$msg
=
'success'
;
doEnd
:
doEnd
:
...
...
common/service/exchange/factory/HuobiBuilder.php
View file @
21ef0982
...
@@ -97,8 +97,8 @@ class HuobiBuilder extends FactoryService
...
@@ -97,8 +97,8 @@ class HuobiBuilder extends FactoryService
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$close
)),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$close
*
$this
->
basic_price
[
$coin
][
'usd'
])),
'0'
);
$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.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'change'
]
=
(
false
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$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'
]);
...
@@ -168,20 +168,15 @@ class HuobiBuilder extends FactoryService
...
@@ -168,20 +168,15 @@ class HuobiBuilder extends FactoryService
}
}
}
}
public
function
getHotTicker
()
public
function
getHotTicker
(
$symbol
=
[]
)
{
{
$symbol
=
[
if
(
empty
(
$symbol
))
{
'btcusdt'
,
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
[]];
'ethusdt'
,
}
'btyusdt'
];
$ticker
=
[];
$ticker
=
[];
foreach
(
$symbol
as
$val
)
{
foreach
(
$symbol
as
$val
)
{
if
(
'btyusdt'
==
$val
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
'quotation_zhaobi_'
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
else
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
}
$explode_arr
=
explode
(
'usdt'
,
$val
);
$explode_arr
=
explode
(
'usdt'
,
$val
);
$temp
=
[];
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/USDT'
;
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/USDT'
;
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
21ef0982
...
@@ -167,13 +167,34 @@ class ZhaobiBuilder extends FactoryService
...
@@ -167,13 +167,34 @@ class ZhaobiBuilder extends FactoryService
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$data
];
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$data
];
}
}
p
rotected
function
arraySort
(
$array
,
$keys
,
$sort
=
SORT_DESC
)
p
ublic
function
getHotTicker
(
$symbol
=
[]
)
{
{
$keysValue
=
[];
if
(
empty
(
$symbol
))
{
foreach
(
$array
as
$k
=>
$v
)
{
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
[]];
$keysValue
[
$k
]
=
$v
[
$keys
];
}
}
array_multisort
(
$keysValue
,
$sort
,
$array
);
return
$array
;
$ticker
=
[];
foreach
(
$symbol
as
$val
)
{
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
$explode_arr
=
explode
(
'usdt'
,
$val
);
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/USDT'
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
'USDT'
;
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$close
*
$this
->
basic_price
[
'USDT'
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$close
*
$this
->
basic_price
[
'USDT'
][
'rmb'
]);
$temp
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
$temp
[
'high_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
'USDT'
][
'usd'
]);
$temp
[
'low_usd'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
'USDT'
][
'usd'
]);
$temp
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$high
*
$this
->
basic_price
[
'USDT'
][
'rmb'
]);
$temp
[
'low_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$low
*
$this
->
basic_price
[
'USDT'
][
'rmb'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$vol
);
array_push
(
$ticker
,
$temp
);
}
if
(
count
(
$ticker
)
>
0
)
{
$this
->
code
=
0
;
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
}
}
}
\ 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