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
7ec15521
Commit
7ec15521
authored
Oct 18, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into develop
parents
1906776e
d7d3ac16
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
56 deletions
+37
-56
OssController.php
backend/controllers/OssController.php
+1
-1
ApplicationBusiness.php
common/business/ApplicationBusiness.php
+5
-1
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+3
-3
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+1
-1
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+18
-33
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+1
-1
TickerController.php
console/controllers/TickerController.php
+8
-16
No files found.
backend/controllers/OssController.php
View file @
7ec15521
...
@@ -28,7 +28,7 @@ class OssController extends BaseController
...
@@ -28,7 +28,7 @@ class OssController extends BaseController
return
[
'code'
=>
1
,
'msg'
=>
'上传失败'
];
return
[
'code'
=>
1
,
'msg'
=>
'上传失败'
];
}
}
if
(
in_array
(
$type
,
[
'coin'
,
'banner'
,
'h5_banner'
,
'h5_icon'
,
'application'
,
'h5_application'
]))
{
if
(
in_array
(
$type
,
[
'coin'
,
'banner'
,
'h5_banner'
,
'h5_icon'
,
'application'
,
'h5_application'
]))
{
$file_url
=
explode
(
'http://bqbwallet.oss-cn-shanghai.aliyuncs.com'
,
$result
[
"info"
][
'url'
]);
$file_url
=
explode
(
'http://bqbwallet.oss-cn-shanghai.aliyuncs.com
/upload
'
,
$result
[
"info"
][
'url'
]);
$image_id
=
CoinImage
::
addOneRecord
(
$file_url
[
1
]);
$image_id
=
CoinImage
::
addOneRecord
(
$file_url
[
1
]);
}
}
...
...
common/business/ApplicationBusiness.php
View file @
7ec15521
...
@@ -64,7 +64,11 @@ class ApplicationBusiness
...
@@ -64,7 +64,11 @@ class ApplicationBusiness
$image_Items
=
array_merge
(
$icon_Items
,
$banner_Items
);
$image_Items
=
array_merge
(
$icon_Items
,
$banner_Items
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$image_Items
);
$icon_Infos
=
CoinImage
::
getItemsByIds
(
$image_Items
);
unset
(
$condition
[
'enable'
]);
unset
(
$condition
[
'enable'
]);
$cate_app_Infos
=
self
::
getCateAppInfo
(
$limit
=
5
,
$condition
);
$limit
=
5
;
if
(
isset
(
$condition
[
'platform_id'
])
&&
26
==
$condition
[
'platform_id'
])
{
$limit
=
15
;
}
$cate_app_Infos
=
self
::
getCateAppInfo
(
$limit
,
$condition
);
foreach
(
$data
as
$value
)
{
foreach
(
$data
as
$value
)
{
$cate_app_item
[
'id'
]
=
$value
[
'id'
];
$cate_app_item
[
'id'
]
=
$value
[
'id'
];
$cate_app_item
[
'name'
]
=
$value
[
'name'
];
$cate_app_item
[
'name'
]
=
$value
[
'name'
];
...
...
common/business/ExchangeBusiness.php
View file @
7ec15521
...
@@ -27,7 +27,7 @@ class ExchangeBusiness
...
@@ -27,7 +27,7 @@ class ExchangeBusiness
*/
*/
private
static
$exchanges
=
[
private
static
$exchanges
=
[
0
=>
'Bty'
,
0
=>
'Bty'
,
#
1 => 'HuoBi',
1
=>
'HuoBi'
,
2
=>
'Hadax'
,
2
=>
'Hadax'
,
3
=>
'Bitfinex'
,
3
=>
'Bitfinex'
,
4
=>
'Bittrex'
,
4
=>
'Bittrex'
,
...
@@ -36,12 +36,12 @@ class ExchangeBusiness
...
@@ -36,12 +36,12 @@ class ExchangeBusiness
7
=>
'S'
,
7
=>
'S'
,
8
=>
'Zg'
,
8
=>
'Zg'
,
9
=>
'Go'
,
9
=>
'Go'
,
#
10 => 'Zhaobi',
10
=>
'Zhaobi'
,
11
=>
'Gdpro'
,
11
=>
'Gdpro'
,
12
=>
'Ex'
,
12
=>
'Ex'
,
13
=>
'Zt'
,
13
=>
'Zt'
,
14
=>
'Tsc'
,
14
=>
'Tsc'
,
#
15 => 'Binance',
15
=>
'Binance'
,
16
=>
'Ceohk'
,
16
=>
'Ceohk'
,
17
=>
'Biki'
,
17
=>
'Biki'
,
18
=>
'Bilaxy'
,
18
=>
'Bilaxy'
,
...
...
common/service/exchange/factory/BinanceBuilder.php
View file @
7ec15521
...
@@ -124,7 +124,7 @@ class BinanceBuilder extends FactoryService
...
@@ -124,7 +124,7 @@ class BinanceBuilder extends FactoryService
$temp
=
[];
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$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
);
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
...
...
common/service/exchange/factory/HuobiBuilder.php
View file @
7ec15521
...
@@ -19,47 +19,31 @@ class HuobiBuilder extends FactoryService
...
@@ -19,47 +19,31 @@ class HuobiBuilder extends FactoryService
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_huobi_list'
;
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_huobi_list'
;
protected
$quotation_prefix
=
'quotation_huobi_'
;
protected
$quotation_prefix
=
'quotation_huobi_'
;
public
function
getTicker
()
public
function
hotTickerUpdate
()
{
{
$curl
=
new
Curl
();
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/market/tickers'
;
$symbols
=
[
'btcusdt'
,
'ethusdt'
,
'eosusdt'
];
foreach
(
$symbols
as
$symbol
)
{
$api
=
$this
->
base_url
.
'/market/detail?symbol='
.
$symbol
;
$res
=
$curl
->
get
(
$api
,
false
);
$res
=
$curl
->
get
(
$api
,
false
);
$ticker
=
[];
if
(
isset
(
$res
[
'status'
])
&&
'ok'
==
$res
[
'status'
])
{
if
(
isset
(
$res
[
'status'
])
&&
'ok'
==
$res
[
'status'
])
{
$this
->
code
=
0
;
$key
=
$this
->
quotation_prefix
.
$symbol
;
foreach
(
$res
[
'data'
]
as
$val
)
{
$this
->
redis
->
hmset
(
$key
,
'low'
,
$res
[
'tick'
][
'low'
],
'high'
,
$res
[
'tick'
][
'high'
],
'last'
,
$res
[
'tick'
][
'close'
],
'open'
,
$res
[
'tick'
][
'open'
],
'vol'
,
$res
[
'tick'
][
'
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
vol'
]);
$explode_arr
=
explode
(
strtolower
(
$coin
),
$val
[
'symbol'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$symbol
);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
number_format
(
$val
[
'close'
],
6
,
'.'
,
''
);
$temp
[
'close_usd'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$val
[
'close'
]
*
$this
->
basic_price
[
$coin
][
'usd'
]);
$temp
[
'close_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'close'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'change'
]
=
(
false
==
$val
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.4f"
,
(
$val
[
'close'
]
-
$val
[
'open'
])
/
$val
[
'open'
]
*
100
);
$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
[
'high_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'high'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'low_rmb'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'low'
]
*
$this
->
basic_price
[
$coin
][
'rmb'
]);
$temp
[
'vol'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$val
[
'vol'
]);
$temp
[
'optional'
]
=
false
;
$temp
[
'platform_zh'
]
=
'火币'
;
$temp
[
'platform_us'
]
=
'huobi'
;
array_push
(
$ticker
,
$temp
);
break
;
}
}
}
}
}
}
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
public
function
getTickerFromCache
(
$page
=
1
)
public
function
getTickerFromCache
(
$page
=
1
)
{
{
$size
=
0
;
$size
=
0
;
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
$size
+=
50
;
$size
+=
50
;
$this
->
end
=
$size
;
$this
->
end
=
$size
;
}
}
...
@@ -113,6 +97,7 @@ class HuobiBuilder extends FactoryService
...
@@ -113,6 +97,7 @@ class HuobiBuilder extends FactoryService
];
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
}
}
public
function
TickerSort
()
public
function
TickerSort
()
{
{
$len
=
$this
->
redis
->
llen
(
$this
->
supported_symbol_list
);
$len
=
$this
->
redis
->
llen
(
$this
->
supported_symbol_list
);
...
@@ -123,14 +108,14 @@ class HuobiBuilder extends FactoryService
...
@@ -123,14 +108,14 @@ class HuobiBuilder extends FactoryService
$temp
=
[];
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$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
);
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
foreach
(
$ticker_sort_close
as
$val
)
{
foreach
(
$ticker_sort_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_close_sort_list
,
$val
[
'symbol'
]);
$this
->
redis
->
lpush
(
$this
->
supported_symbol_close_sort_list
,
$val
[
'symbol'
]);
}
}
$ticker_change_close
=
$this
->
arraySort
(
$ticker
,
'change'
);
$ticker_change_close
=
$this
->
arraySort
(
$ticker
,
'change'
);
foreach
(
$ticker_change_close
as
$val
)
{
foreach
(
$ticker_change_close
as
$val
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
}
}
...
...
common/service/exchange/factory/ZhaobiBuilder.php
View file @
7ec15521
...
@@ -82,7 +82,7 @@ class ZhaobiBuilder extends FactoryService
...
@@ -82,7 +82,7 @@ class ZhaobiBuilder extends FactoryService
$temp
=
[];
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$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
);
array_push
(
$ticker
,
$temp
);
array_push
(
$ticker
,
$temp
);
}
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
...
...
console/controllers/Ticker
Update
Controller.php
→
console/controllers/TickerController.php
View file @
7ec15521
...
@@ -10,23 +10,8 @@ use common\service\exchange\ExchangeFactory;
...
@@ -10,23 +10,8 @@ use common\service\exchange\ExchangeFactory;
use
yii\console\Controller
;
use
yii\console\Controller
;
use
Yii
;
use
Yii
;
class
Ticker
Update
Controller
extends
Controller
class
TickerController
extends
Controller
{
{
/**
* 行情排序
*/
public
function
actionIndex
()
{
$class
=
[
'Binance'
,
'HuoBi'
,
'Zhaobi'
];
foreach
(
$class
as
$val
)
{
go
(
function
()
use
(
$val
)
{
\Co
::
sleep
(
0.5
);
$exchange
=
ExchangeFactory
::
createExchange
(
$val
);
$exchange
->
setQuotation
();
});
}
}
public
function
actionSort
()
public
function
actionSort
()
{
{
$class
=
[
'Binance'
,
'Huobi'
,
'Zhaobi'
];
$class
=
[
'Binance'
,
'Huobi'
,
'Zhaobi'
];
...
@@ -38,4 +23,10 @@ class TickerUpdateController extends Controller
...
@@ -38,4 +23,10 @@ class TickerUpdateController extends Controller
});
});
}
}
}
}
public
function
actionHot
()
{
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
'Huobi'
);
$ticker_builder
->
hotTickerUpdate
();
}
}
}
\ 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