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
568d7a0f
Commit
568d7a0f
authored
Nov 08, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/ticker' into 'master'
Feature/ticker See merge request
!189
parents
88278cd8
b9b9175b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
20 deletions
+49
-20
TickerController.php
api/controllers/TickerController.php
+37
-8
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+4
-4
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+4
-4
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+4
-4
No files found.
api/controllers/TickerController.php
View file @
568d7a0f
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
namespace
api\controllers
;
namespace
api\controllers
;
use
common\components\Tools
;
use
Yii
;
use
Yii
;
use
yii\data\Pagination
;
use
yii\data\Pagination
;
use
linslin\yii2\curl\Curl
;
use
linslin\yii2\curl\Curl
;
...
@@ -22,8 +23,8 @@ class TickerController extends BaseController
...
@@ -22,8 +23,8 @@ class TickerController extends BaseController
$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
(
'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_value
=
Yii
::
$app
->
request
->
get
(
'sort
-
value'
,
''
);
$sort_value
=
Yii
::
$app
->
request
->
get
(
'sort
_
value'
,
''
);
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
$exchange_arr
=
[
'huobi'
,
'binance'
,
'okex'
,
'zhaobi'
];
...
@@ -127,11 +128,22 @@ class TickerController extends BaseController
...
@@ -127,11 +128,22 @@ class TickerController extends BaseController
$msg
=
'参数错误'
;
$msg
=
'参数错误'
;
goto
doEnd
;
goto
doEnd
;
}
}
$data_value
=
Yii
::
$app
->
request
->
get
(
'data_value'
,
''
);
$sort_value
=
Yii
::
$app
->
request
->
get
(
'sort_value'
,
''
);
$condition
=
[];
if
(
false
!=
$data_value
&&
false
!=
$sort_value
)
{
$condition
=
[
'data_value'
=>
$data_value
,
'sort_value'
=>
$sort_value
];
}
$temp
=
[];
$temp
=
[];
$
query
=
CoinOptional
::
find
()
->
select
(
'symbol, platform'
)
$
data
=
CoinOptional
::
find
()
->
select
(
'symbol, platform'
)
->
where
([
'device_code'
=>
$device_code
,
'platform_id'
=>
(
int
)
$platform_id
])
->
where
([
'device_code'
=>
$device_code
,
'platform_id'
=>
(
int
)
$platform_id
])
->
orderBy
(
'update_time desc'
);
->
orderBy
(
'update_time desc'
)
$data
=
$query
->
offset
((
$page
-
1
)
*
50
)
->
limit
(
50
)
->
asArray
()
->
all
();
->
asArray
()
->
all
();
if
(
false
==
$data
)
{
if
(
false
==
$data
)
{
$msg
=
'success'
;
$msg
=
'success'
;
$code
=
0
;
$code
=
0
;
...
@@ -165,8 +177,8 @@ class TickerController extends BaseController
...
@@ -165,8 +177,8 @@ class TickerController extends BaseController
$temp
[
'symbol'
]
=
$val
[
'symbol'
];
$temp
[
'symbol'
]
=
$val
[
'symbol'
];
$temp
[
'currency'
]
=
strtoupper
(
$tag_first
);
$temp
[
'currency'
]
=
strtoupper
(
$tag_first
);
$temp
[
'base_currency'
]
=
strtoupper
(
$tag_second
);
$temp
[
'base_currency'
]
=
strtoupper
(
$tag_second
);
$temp
[
'close'
]
=
number_format
(
$quotation
[
'last'
],
6
,
'.'
,
'
'
);
$temp
[
'close'
]
=
rtrim
(
sprintf
(
'%.8f'
,
floatval
(
$quotation
[
'last'
])),
'0
'
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
]
);
$temp
[
'close_usd'
]
=
rtrim
(
sprintf
(
'%.6f'
,
floatval
(
$quotation
[
'last'
]
*
$this
->
basic_price
[
$tag_second
][
'usd'
])),
'0'
);
$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.2f"
,
(
$quotation
[
'last'
]
-
$quotation
[
'open'
])
/
$quotation
[
'open'
]
*
100
);
$temp
[
'change'
]
=
(
0
==
$quotation
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$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'
]);
...
@@ -189,7 +201,24 @@ class TickerController extends BaseController
...
@@ -189,7 +201,24 @@ class TickerController extends BaseController
}
}
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
if
(
!
empty
(
$condition
))
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price_asc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'close'
,
SORT_ASC
);
}
if
(
'price_desc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'close'
,
SORT_DESC
);
}
}
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change_asc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'change'
,
SORT_ASC
);
}
if
(
'change_desc'
==
$condition
[
'sort_value'
])
{
$ticker
=
Tools
::
arraySort
(
$ticker
,
'change'
,
SORT_DESC
);
}
}
}
}
}
$data
=
[
$data
=
[
...
...
common/service/exchange/factory/BinanceBuilder.php
View file @
568d7a0f
...
@@ -44,18 +44,18 @@ class BinanceBuilder extends FactoryService
...
@@ -44,18 +44,18 @@ class BinanceBuilder extends FactoryService
}
}
if
(
false
!=
$condition
)
{
if
(
false
!=
$condition
)
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price
-
asc'
==
$condition
[
'sort_value'
])
{
if
(
'price
_
asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'price
-
desc'
==
$condition
[
'sort_value'
])
{
if
(
'price
_
desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
}
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change
-
asc'
==
$condition
[
'sort_value'
])
{
if
(
'change
_
asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'change
-
desc'
==
$condition
[
'sort_value'
])
{
if
(
'change
_
desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
}
...
...
common/service/exchange/factory/HuobiBuilder.php
View file @
568d7a0f
...
@@ -64,18 +64,18 @@ class HuobiBuilder extends FactoryService
...
@@ -64,18 +64,18 @@ class HuobiBuilder extends FactoryService
}
}
if
(
false
!=
$condition
)
{
if
(
false
!=
$condition
)
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price
-
asc'
==
$condition
[
'sort_value'
])
{
if
(
'price
_
asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'price
-
desc'
==
$condition
[
'sort_value'
])
{
if
(
'price
_
desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
}
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change
-
asc'
==
$condition
[
'sort_value'
])
{
if
(
'change
_
asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'change
-
desc'
==
$condition
[
'sort_value'
])
{
if
(
'change
_
desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
}
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
568d7a0f
...
@@ -28,18 +28,18 @@ class ZhaobiBuilder extends FactoryService
...
@@ -28,18 +28,18 @@ class ZhaobiBuilder extends FactoryService
$this
->
end
=
50
;
$this
->
end
=
50
;
if
(
false
!=
$condition
)
{
if
(
false
!=
$condition
)
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price'
==
$condition
[
'data_value'
])
{
if
(
'price
-
asc'
==
$condition
[
'sort_value'
])
{
if
(
'price
_
asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_asc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'price
-
desc'
==
$condition
[
'sort_value'
])
{
if
(
'price
_
desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_close_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
}
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change'
==
$condition
[
'data_value'
])
{
if
(
'change
-
asc'
==
$condition
[
'sort_value'
])
{
if
(
'change
_
asc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_asc
,
$this
->
start
,
$this
->
end
);
}
}
if
(
'change
-
desc'
==
$condition
[
'sort_value'
])
{
if
(
'change
_
desc'
==
$condition
[
'sort_value'
])
{
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
$keys
=
$this
->
redis_ticker
->
lrange
(
$this
->
supported_symbol_change_desc
,
$this
->
start
,
$this
->
end
);
}
}
}
}
...
...
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