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
e35b485c
Commit
e35b485c
authored
Oct 21, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/issue_coin
parents
9a4eff4e
3030c9c5
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
66 additions
and
61 deletions
+66
-61
CoinController.php
api/controllers/CoinController.php
+1
-1
CoinDogController.php
api/controllers/CoinDogController.php
+3
-0
OssController.php
backend/controllers/OssController.php
+1
-1
_form-article.php
backend/views/source/_form-article.php
+1
-1
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+1
-1
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+14
-2
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+31
-37
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+4
-2
TickerController.php
console/controllers/TickerController.php
+10
-16
No files found.
api/controllers/CoinController.php
View file @
e35b485c
...
...
@@ -374,7 +374,7 @@ class CoinController extends BaseController
$service
=
new
Chain33Business
();
$result
=
$service
->
getProperFee
();
if
(
0
===
$result
[
'code'
])
{
$platform_with_hold
[
'bty_fee'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$result
[
'result'
][
'properFee'
]
/
1e8
);
$platform_with_hold
[
'bty_fee'
]
=
(
float
)
sprintf
(
"%0.4f"
,
$result
[
'result'
][
'properFee'
]
/
1e8
)
>
0.01
?
0.01
:
(
float
)
sprintf
(
"%0.4f"
,
$result
[
'result'
][
'properFee'
]
/
1e8
)
;
}
else
{
$platform_with_hold
[
'bty_fee'
]
=
(
float
)
sprintf
(
"%0.4f"
,
Yii
::
$app
->
params
[
'bty_fee'
]);
}
...
...
api/controllers/CoinDogController.php
View file @
e35b485c
...
...
@@ -27,6 +27,7 @@ class CoinDogController extends BaseController
$val
[
'id'
]
=
$val
[
'news_id'
];
}
$val
[
'share_url'
]
=
$bishijie
[
'Url'
]
.
'/shendu_'
.
$val
[
'id'
];
$val
[
'source'
]
=
'币世界'
;
}
$data
=
[
'list'
=>
isset
(
$article
[
'list'
])
?
$article
[
'list'
]
:
[],
...
...
@@ -56,6 +57,7 @@ class CoinDogController extends BaseController
$bishijie_service
=
new
BishijieService
(
$appid
,
$appSecret
);
$article
=
$bishijie_service
->
getArticleDetail
(
$id
);
$article
[
'share_url'
]
=
$bishijie
[
'Url'
]
.
'/shendu_'
.
$id
;
$article
[
'source'
]
=
'币世界'
;
if
(
@
$article
[
'code'
])
{
$msg
=
$article
[
'message'
];
$code
=
-
1
;
...
...
@@ -113,6 +115,7 @@ class CoinDogController extends BaseController
preg_match_all
(
"/\【(.+?)\】/"
,
$item
[
'content'
],
$match
);
$item
[
'title'
]
=
$match
[
1
][
0
];
$item
[
'content'
]
=
str_replace
(
'【'
.
$item
[
'title'
]
.
'】'
,
''
,
$item
[
'content'
]);
$item
[
'source'
]
=
'金色财经'
;
}
$code
=
0
;
$msg
=
'success'
;
...
...
backend/controllers/OssController.php
View file @
e35b485c
...
...
@@ -28,7 +28,7 @@ class OssController extends BaseController
return
[
'code'
=>
1
,
'msg'
=>
'上传失败'
];
}
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
]);
}
...
...
backend/views/source/_form-article.php
View file @
e35b485c
...
...
@@ -45,7 +45,7 @@
<div
class=
"layui-input-block"
>
<img
src=
"
<?=
$model
->
image_url
?>
"
style=
"margin-top: 11px; max-width: 32px; max-height: 32px"
id=
"icon1"
>
</div>
<input
type=
"hidden"
name=
"image_url"
value=
""
lay-verify=
"required|image_url"
>
<input
type=
"hidden"
name=
"image_url"
value=
""
>
</div>
<div
class=
"layui-inline"
style=
"margin-left: 50px;"
>
<button
type=
"button"
class=
"layui-btn"
id=
"upload1"
style=
""
>
...
...
common/business/ExchangeBusiness.php
View file @
e35b485c
...
...
@@ -98,7 +98,7 @@ class ExchangeBusiness
goto
doEnd
;
}
if
(
strtoupper
(
$tag
)
==
'STO'
||
strtoupper
(
$tag
)
==
'GM'
||
strtoupper
(
$tag
)
==
'BSTC'
||
strtoupper
(
$tag
)
==
'RYH'
||
strtoupper
(
$tag
)
==
'CNDT'
||
strtoupper
(
$tag
)
==
'WL'
||
strtoupper
(
$tag
)
==
'ETS'
||
strtoupper
(
$tag
)
==
'LIMS'
||
strtoupper
(
$tag
)
==
'AT'
||
strtoupper
(
$tag
)
==
'BTJ'
)
{
if
(
strtoupper
(
$tag
)
==
'
GST'
||
strtoupper
(
$tag
)
==
'JNTK'
||
strtoupper
(
$tag
)
==
'SPT'
||
strtoupper
(
$tag
)
==
'
STO'
||
strtoupper
(
$tag
)
==
'GM'
||
strtoupper
(
$tag
)
==
'BSTC'
||
strtoupper
(
$tag
)
==
'RYH'
||
strtoupper
(
$tag
)
==
'CNDT'
||
strtoupper
(
$tag
)
==
'WL'
||
strtoupper
(
$tag
)
==
'ETS'
||
strtoupper
(
$tag
)
==
'LIMS'
||
strtoupper
(
$tag
)
==
'AT'
||
strtoupper
(
$tag
)
==
'BTJ'
)
{
$quotation
=
[
'low'
=>
0
,
'high'
=>
0
,
...
...
common/service/exchange/factory/BinanceBuilder.php
View file @
e35b485c
...
...
@@ -85,9 +85,10 @@ class BinanceBuilder extends FactoryService
list
(
$low
,
$high
,
$close
,
$open
,
$vol
)
=
$this
->
redis
->
hmget
(
$this
->
quotation_prefix
.
strtolower
(
$val
),
'low'
,
'high'
,
'last'
,
'open'
,
'vol'
);
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
#if ('BCC/USDT' != $temp['symbol']) continue;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
$this
->
sctonum
(
$close
,
8
);
$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
[
'change'
]
=
(
0
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
...
...
@@ -124,7 +125,7 @@ class BinanceBuilder extends FactoryService
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$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
);
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
...
...
@@ -146,4 +147,14 @@ class BinanceBuilder extends FactoryService
array_multisort
(
$keysValue
,
$sort
,
$array
);
return
$array
;
}
protected
function
sctonum
(
$num
,
$double
=
5
)
{
if
(
false
!==
strpos
(
$num
,
"e"
))
{
$a
=
explode
(
"e"
,
strtolower
(
$num
));
return
bcmul
(
$a
[
0
],
bcpow
(
10
,
$a
[
1
],
$double
),
$double
);
}
else
{
return
number_format
(
$num
,
6
,
'.'
,
''
);
}
}
}
\ No newline at end of file
common/service/exchange/factory/HuobiBuilder.php
View file @
e35b485c
...
...
@@ -19,47 +19,30 @@ class HuobiBuilder extends FactoryService
protected
$supported_symbol_change_sort_list
=
'supported_symbol_change_sort_huobi_list'
;
protected
$quotation_prefix
=
'quotation_huobi_'
;
public
function
getTicker
()
public
function
hotTickerUpdate
()
{
$curl
=
new
Curl
();
$api
=
$this
->
base_url
.
'/market/tickers'
;
$res
=
$curl
->
get
(
$api
,
false
);
$ticker
=
[];
if
(
isset
(
$res
[
'status'
])
&&
'ok'
==
$res
[
'status'
])
{
$this
->
code
=
0
;
foreach
(
$res
[
'data'
]
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
strtolower
(
$coin
),
$val
[
'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
;
}
}
$symbols
=
[
'btcusdt'
,
'ethusdt'
,
'eosusdt'
];
foreach
(
$symbols
as
$symbol
)
{
$api
=
$this
->
base_url
.
'/market/detail?symbol='
.
$symbol
;
$res
=
$curl
->
get
(
$api
,
false
);
if
(
isset
(
$res
[
'status'
])
&&
'ok'
==
$res
[
'status'
])
{
$key
=
$this
->
quotation_prefix
.
$symbol
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$res
[
'tick'
][
'low'
],
'high'
,
$res
[
'tick'
][
'high'
],
'last'
,
$res
[
'tick'
][
'close'
],
'open'
,
$res
[
'tick'
][
'open'
],
'vol'
,
$res
[
'tick'
][
'vol'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$symbol
);
}
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
public
function
getTickerFromCache
(
$page
=
1
)
{
$size
=
0
;
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
$size
+=
50
;
$this
->
end
=
$size
;
}
...
...
@@ -87,7 +70,7 @@ class HuobiBuilder extends FactoryService
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
number_format
(
$close
,
6
,
'.'
,
''
);
$temp
[
'close'
]
=
$this
->
sctonum
(
$close
,
8
);
$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
[
'change'
]
=
(
false
==
$open
)
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$close
-
$open
)
/
$open
*
100
);
...
...
@@ -107,12 +90,13 @@ class HuobiBuilder extends FactoryService
$data
=
[
'ticker'
=>
$ticker
,
'page'
=>
[
'pageSize'
=>
50
,
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
]
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
}
public
function
TickerSort
()
{
$len
=
$this
->
redis
->
llen
(
$this
->
supported_symbol_list
);
...
...
@@ -123,14 +107,14 @@ class HuobiBuilder extends FactoryService
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$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
);
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
foreach
(
$ticker_sort_close
as
$val
)
{
$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
)
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_change_sort_list
,
$val
[
'symbol'
]);
}
...
...
@@ -177,4 +161,14 @@ class HuobiBuilder extends FactoryService
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
protected
function
sctonum
(
$num
,
$double
=
5
)
{
if
(
false
!==
stripos
(
$num
,
"e"
))
{
$a
=
explode
(
"e"
,
strtolower
(
$num
));
return
bcmul
(
$a
[
0
],
bcpow
(
10
,
$a
[
1
],
$double
),
$double
);
}
else
{
return
number_format
(
$num
,
6
,
'.'
,
''
);
}
}
}
common/service/exchange/factory/ZhaobiBuilder.php
View file @
e35b485c
...
...
@@ -39,6 +39,7 @@ class ZhaobiBuilder extends FactoryService
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
number_format
(
$val
[
'last'
],
6
,
'.'
,
''
);
if
(
'0.000000'
==
$temp
[
'close'
])
continue
;
$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
[
'change'
]
=
(
0
==
$val
[
'open'
])
?
0
:
(
float
)
sprintf
(
"%0.2f"
,
(
$val
[
'last'
]
-
$val
[
'open'
])
/
$val
[
'open'
]
*
100
);
...
...
@@ -82,7 +83,7 @@ class ZhaobiBuilder extends FactoryService
$temp
=
[];
$temp
[
'symbol'
]
=
strtoupper
(
$symbol
);
$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
);
}
$ticker_sort_close
=
$this
->
arraySort
(
$ticker
,
'close'
);
...
...
@@ -105,7 +106,8 @@ class ZhaobiBuilder extends FactoryService
$this
->
code
=
0
;
$res
[
'data'
][
'abstract'
]
=
str_replace
(
' '
,
''
,
str_replace
(
' '
,
''
,
$res
[
'data'
][
'abstract'
]));
$res
[
'data'
][
'content'
]
=
str_replace
(
' '
,
''
,
str_replace
(
' '
,
''
,
$res
[
'data'
][
'content'
]));
$res
[
'data'
][
'share_url'
]
=
\Yii
::
$app
->
params
[
'service'
][
'ZhaobiService'
][
'url'
]
.
'/help/notice/'
.
$params
[
'id'
];
$res
[
'data'
][
'source'
]
=
'找币'
;
$res
[
'data'
][
'share_url'
]
=
\Yii
::
$app
->
params
[
'service'
][
'ZhaobiService'
][
'h5_url'
]
.
'/account/help/'
.
$params
[
'id'
];
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$res
[
'data'
]];
}
else
{
return
[
'code'
=>
$this
->
code
,
'notice'
=>
$res
[
'data'
],
'msg'
=>
$res
[
'message'
]];
...
...
console/controllers/Ticker
Update
Controller.php
→
console/controllers/TickerController.php
View file @
e35b485c
...
...
@@ -10,23 +10,8 @@ use common\service\exchange\ExchangeFactory;
use
yii\console\Controller
;
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
()
{
$class
=
[
'Binance'
,
'Huobi'
,
'Zhaobi'
];
...
...
@@ -38,4 +23,12 @@ class TickerUpdateController extends Controller
});
}
}
public
function
actionHot
()
{
$ticker_builder
=
ExchangeBuilderFactory
::
create
(
'Huobi'
);
$ticker_builder
->
hotTickerUpdate
();
echo
date
(
'Y-m-d H:i:s'
)
.
'更新成功'
.
PHP_EOL
;
return
0
;
}
}
\ 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