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
6784b098
Commit
6784b098
authored
Sep 25, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ws_ticker' into 'master'
自选行情加分页 See merge request
!128
parents
e8227176
1474ccf7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
GameBetController.php
api/controllers/GameBetController.php
+2
-3
TickerController.php
api/controllers/TickerController.php
+35
-9
No files found.
api/controllers/GameBetController.php
View file @
6784b098
...
...
@@ -2,11 +2,10 @@
namespace
api\controllers
;
use
common\business\Chain33Business
;
use
common\models\psources\CoinGameBet
;
use
Yii
;
use
api\base\BaseController
;
use
yii\data\Pagination
;
use
api\base\BaseController
;
use
common\models\psources\CoinGameBet
;
class
GameBetController
extends
BaseController
{
...
...
api/controllers/TickerController.php
View file @
6784b098
...
...
@@ -2,13 +2,14 @@
namespace
api\controllers
;
use
linslin\yii2\curl\Curl
;
use
Yii
;
use
yii\data\Pagination
;
use
linslin\yii2\curl\Curl
;
use
yii\helpers\ArrayHelper
;
use
api\base\BaseController
;
use
common\models\psources\CoinOptional
;
use
common\service\exchange\ExchangeFactory
;
use
common\service\exchange\ExchangeBuilderFactory
;
use
yii\helpers\ArrayHelper
;
class
TickerController
extends
BaseController
{
...
...
@@ -102,14 +103,30 @@ class TickerController extends BaseController
if
(
$request
->
isGet
)
{
$device_code
=
$request
->
get
(
'device_code'
,
''
);
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
if
(
empty
(
$device_code
))
{
$msg
=
'参数错误'
;
goto
doEnd
;
}
$data
=
$temp
=
[];
$model
=
CoinOptional
::
find
()
->
select
(
'symbol, platform'
)
->
where
([
'device_code'
=>
$device_code
])
->
asArray
()
->
all
();
foreach
(
$model
as
$val
)
{
$temp
=
[];
$query
=
CoinOptional
::
find
()
->
select
(
'symbol, platform'
)
->
where
([
'device_code'
=>
$device_code
])
->
orderBy
(
'update_time desc'
);
$data
=
$query
->
offset
((
$page
-
1
)
*
50
)
->
limit
(
50
)
->
asArray
()
->
all
();
if
(
false
==
$data
)
{
$msg
=
'success'
;
$code
=
0
;
$data
=
[
'ticker'
=>
[],
'page'
=>
[
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
]
];
goto
doEnd
;
}
$ticker
=
[];
foreach
(
$data
as
$val
)
{
if
(
'huobi'
==
$val
[
'platform'
])
{
$exchange
=
'HuoBi'
;
}
else
if
(
'binance'
==
$val
[
'platform'
])
{
...
...
@@ -129,7 +146,7 @@ class TickerController extends BaseController
$temp
[
'symbol'
]
=
$val
[
'symbol'
];
$temp
[
'currency'
]
=
strtoupper
(
$tag_first
);
$temp
[
'base_currency'
]
=
strtoupper
(
$tag_second
);
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$quotation
[
'last'
]
);
$temp
[
'close'
]
=
number_format
(
$quotation
[
'last'
],
6
,
'.'
,
''
);
$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
[
'change'
]
=
(
0
==
$quotation
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.4f"
,
(
$quotation
[
'last'
]
-
$quotation
[
'open'
])
/
$quotation
[
'open'
]
*
100
);
...
...
@@ -150,11 +167,20 @@ class TickerController extends BaseController
$temp
[
'platform_zh'
]
=
'币安'
;
$temp
[
'platform_us'
]
=
'binance'
;
}
array_push
(
$data
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
$data
=
[
'ticker'
=>
$ticker
,
'page'
=>
[
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
]
];
$msg
=
'success'
;
$code
=
0
;
}
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
...
...
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