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
d345981e
Commit
d345981e
authored
Sep 26, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
merge master
parents
b179154f
fd6cfca8
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
409 additions
and
57 deletions
+409
-57
CoinDogController.php
api/controllers/CoinDogController.php
+69
-15
GameBetController.php
api/controllers/GameBetController.php
+2
-3
TickerController.php
api/controllers/TickerController.php
+41
-14
ArticleForm.php
backend/models/coin/ArticleForm.php
+5
-3
_form-article.php
backend/views/source/_form-article.php
+33
-3
BishijieService.php
common/service/bishijie/BishijieService.php
+194
-0
BinanceBuilder.php
common/service/exchange/factory/BinanceBuilder.php
+30
-5
FactoryService.php
common/service/exchange/factory/FactoryService.php
+4
-1
HuobiBuilder.php
common/service/exchange/factory/HuobiBuilder.php
+19
-9
ZhaobiBuilder.php
common/service/exchange/factory/ZhaobiBuilder.php
+10
-3
GameBetController.php
console/controllers/GameBetController.php
+1
-1
Connection.php
vendor/yiisoft/yii2-elasticsearch/Connection.php
+1
-0
No files found.
api/controllers/CoinDogController.php
View file @
d345981e
...
...
@@ -2,32 +2,68 @@
namespace
api\controllers
;
use
backend\models\coin\ArticleForm
;
use
common\models\pwallet\Article
;
use
common\service\bishijie\BishijieService
;
use
linslin\yii2\curl\Curl
;
use
Yii
;
use
api\base\BaseController
;
use
yii\data\Pagination
;
class
CoinDogController
extends
BaseController
{
public
function
actionArticle
()
{
$coindog
=
Yii
::
$app
->
params
[
'coindog'
];
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
20
);
$accessKey
=
$coindog
[
'accessKey'
];
$secretKey
=
$coindog
[
'secretKey'
];
$httpParams
=
array
(
'access_key'
=>
$accessKey
,
'date'
=>
time
()
);
$signParams
=
array_merge
(
$httpParams
,
array
(
'secret_key'
=>
$secretKey
));
$bishijie
=
Yii
::
$app
->
params
[
'bishijie'
];
$appid
=
$bishijie
[
'Appid'
];
$appSecret
=
$bishijie
[
'AppSecret'
];
$bishijie_service
=
new
BishijieService
(
$appid
,
$appSecret
);
$article
=
$bishijie_service
->
getArticleList
(
$page
,
$size
);
ksort
(
$signParams
);
$signString
=
http_build_query
(
$signParams
);
$data
=
[
'list'
=>
isset
(
$article
[
'list'
])
?
$article
[
'list'
]
:
[],
'page'
=>
[
'pageCount'
=>
isset
(
$article
[
'allPage'
])
?
$article
[
'allPage'
]
:
0
,
'pageSize'
=>
$size
,
'currentPage'
=>
$page
,
]
];
$httpParams
[
'sign'
]
=
strtolower
(
md5
(
$signString
));
$url
=
$coindog
[
'article'
]
.
'?'
.
http_build_query
(
$httpParams
);
$curl
=
new
Curl
();
$resp
=
$curl
->
get
(
$url
,
false
);
return
[
'code'
=>
200
,
'data'
=>
$resp
,
'msg'
=>
'ok'
];
return
[
'code'
=>
200
,
'data'
=>
$data
,
'msg'
=>
'ok'
];
}
public
function
actionArticleInfo
()
{
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
0
);
if
(
false
==
$id
)
{
$msg
=
'参数错误'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$bishijie
=
Yii
::
$app
->
params
[
'bishijie'
];
$appid
=
$bishijie
[
'Appid'
];
$appSecret
=
$bishijie
[
'AppSecret'
];
$bishijie_service
=
new
BishijieService
(
$appid
,
$appSecret
);
$article
=
$bishijie_service
->
getArticleDetail
(
$id
);
if
(
@
$article
[
'code'
])
{
$msg
=
$article
[
'message'
];
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$data
=
$article
;
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'data'
=>
$data
,
'msg'
=>
$msg
];
}
public
function
actionLive
()
...
...
@@ -78,4 +114,21 @@ class CoinDogController extends BaseController
return
[
'code'
=>
$code
,
'data'
=>
$list
,
'msg'
=>
$msg
];
}
public
function
actionArticleBanner
()
{
$data
=
Article
::
find
()
->
select
(
'id, image_url ,title, url'
)
->
limit
(
5
)
->
orderBy
(
'update_at desc'
)
->
asArray
()
->
all
();
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'data'
=>
$data
,
'msg'
=>
$msg
];
}
}
\ No newline at end of file
api/controllers/GameBetController.php
View file @
d345981e
...
...
@@ -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 @
d345981e
...
...
@@ -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
{
...
...
@@ -17,6 +18,7 @@ class TickerController extends BaseController
public
function
actionIndex
()
{
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$device_code
=
Yii
::
$app
->
request
->
get
(
'device_code'
,
''
);
$exchange
=
Yii
::
$app
->
request
->
get
(
'exchange'
,
'zhaobi'
);
...
...
@@ -28,14 +30,14 @@ class TickerController extends BaseController
goto
doEnd
;
}
$builder
=
ExchangeBuilderFactory
::
create
(
$exchange
);
$result
=
$builder
->
getTickerFromCache
();
$result
=
$builder
->
getTickerFromCache
(
$page
);
$code
=
$result
[
'code'
];
$data
=
$result
[
'
ticker
'
];
$data
=
$result
[
'
data
'
];
if
(
false
!=
$device_code
)
{
$coin_optional
=
CoinOptional
::
find
()
->
select
(
'symbol'
)
->
where
([
'platform'
=>
$exchange
,
'device_code'
=>
$device_code
])
->
asArray
()
->
all
();
$coin_optional
=
ArrayHelper
::
getColumn
(
$coin_optional
,
'symbol'
);
foreach
(
$data
as
&
$val
)
{
foreach
(
$data
[
'ticker'
]
as
&
$val
)
{
if
(
in_array
(
$val
[
'symbol'
],
$coin_optional
))
{
$val
[
'optional'
]
=
true
;
}
...
...
@@ -101,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'
])
{
...
...
@@ -124,11 +142,11 @@ class TickerController extends BaseController
$exchange
=
ExchangeFactory
::
createExchange
(
$exchange
);
$quotation
=
$exchange
->
getTicker
(
strtolower
(
$tag_first
),
strtolower
(
$tag_second
));
if
(
empty
(
$quotation
))
continue
;
$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
);
...
...
@@ -149,12 +167,21 @@ class TickerController extends BaseController
$temp
[
'platform_zh'
]
=
'币安'
;
$temp
[
'platform_us'
]
=
'binance'
;
}
array_push
(
$
data
,
$temp
);
array_push
(
$
ticker
,
$temp
);
}
$msg
=
'success'
;
$code
=
0
;
}
$data
=
[
'ticker'
=>
$ticker
,
'page'
=>
[
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
]
];
$msg
=
'success'
;
$code
=
0
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
...
...
backend/models/coin/ArticleForm.php
View file @
d345981e
...
...
@@ -16,6 +16,7 @@ class ArticleForm extends Model
public
$title
;
public
$url
;
public
$status
;
public
$image_url
;
public
function
formName
()
{
...
...
@@ -25,15 +26,16 @@ class ArticleForm extends Model
public
function
rules
()
{
return
[
[[
'title'
,
'url'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'title'
,
'url'
],
'required'
,
'on'
=>
'edit'
],
[[
'title'
,
'image_url'
],
'required'
,
'on'
=>
'add'
],
[[
'id'
,
'title'
],
'required'
,
'on'
=>
'edit'
],
[[
'url'
],
'safe'
]
];
}
public
function
scenarios
()
{
return
[
'add'
=>
[
'title'
,
'url'
,
'status'
],
'add'
=>
[
'title'
,
'url'
,
'status'
,
'image_url'
],
'edit'
=>
[
'id'
,
'title'
,
'url'
,
'status'
],
];
}
...
...
backend/views/source/_form-article.php
View file @
d345981e
...
...
@@ -26,8 +26,7 @@
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
style=
"margin-bottom: 0; width: 100px;"
>
外链地址
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
type=
"text"
value=
"
<?=
$model
->
url
?>
"
lay-verify=
"required|url"
name=
"url"
>
<input
class=
"layui-input"
type=
"text"
value=
"
<?=
$model
->
url
?>
"
name=
"url"
>
</div>
</div>
...
...
@@ -40,7 +39,20 @@
</select>
</div>
</div>
<div
class=
"layui-form-item"
>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
图片
</label>
<div
class=
"layui-input-block"
>
<img
src=
""
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"
>
</div>
<div
class=
"layui-inline"
style=
"margin-left: 50px;"
>
<button
type=
"button"
class=
"layui-btn"
id=
"upload1"
style=
""
>
<i
class=
"layui-icon"
>

</i>
上传新图片
</button>
</div>
</div>
<div
class=
"layui-form-item"
>
<button
class=
"layui-btn"
lay-submit
>
保存
</button>
</div>
...
...
@@ -50,4 +62,21 @@
<script>
var
form
=
layui
.
form
;
form
.
render
(
null
,
'form1'
);
//图片上传
var
uploader
=
layui
.
upload
;
$_csrf
=
$
(
"input[name='_csrf']"
).
val
();
uploader
.
render
({
elem
:
"#upload1"
,
url
:
'/admin/image/upload'
,
data
:
{
_csrf
:
$_csrf
,
image_type
:
2
},
done
:
function
(
res
)
{
if
(
res
.
code
==
0
)
{
$
(
"input[name='image_url']"
).
val
(
res
.
data
.
image_src
);
$
(
"#icon1"
).
attr
(
'src'
,
res
.
data
.
image_src
);
}
},
error
:
function
(
res
)
{
}
});
</script>
\ No newline at end of file
common/service/bishijie/BishijieService.php
0 → 100644
View file @
d345981e
<?php
namespace
common\service\bishijie
;
const
BISHIJIE_LANGUAGE_CN
=
1
;
const
BISHIJIE_LANGUAGE_EN
=
3
;
const
BISHIJIE_LANGUAGE_KO
=
4
;
class
BishijieService
{
// CURL requests the relevant parameters
public
$useragent
=
'BiShiJie PHPSDK v1.x'
;
public
$connecttimeout
=
2
;
public
$timeout
=
30
;
public
$ssl_verifypeer
=
FALSE
;
// CURL requests state-related data
public
$http_header
=
array
();
public
$http_code
;
public
$http_info
;
public
$curl_error
;
public
$curl_response
;
public
$url
;
protected
$app_id
,
$app_sercet
;
public
static
$base_url
=
'https://iapi.bishijie.com/'
;
public
function
__construct
(
$app_id
,
$app_sercet
)
{
$this
->
app_id
=
$app_id
;
$this
->
app_sercet
=
$app_sercet
;
}
/**
* Get Newsflash List
*
* @param int $language BISHIJIE_LANGUAGE_*
* @param number $start_time
* @param number $end_time
* @param number $size count of newsflash, max is 500
* @return
*/
public
function
getNewsflashList
(
$language
,
$start_time
=
0
,
$end_time
=
0
,
$size
=
150
)
{
$params
=
array
(
'language'
=>
$language
);
$start_time
&&
$params
[
'start_time'
]
=
$start_time
;
$end_time
&&
$params
[
'end_time'
]
=
$end_time
;
$size
&&
$params
[
'size'
]
=
$size
;
return
$this
->
get
(
'newsflash/list'
,
$params
);
}
/**
* Gets the last 8 hours of messages that have been modified or deleted
*
* @param int $language BISHIJIE_LANGUAGE_*
* @return mixed
*/
public
function
getNewsflashUpdated
(
$language
)
{
$params
=
array
(
'language'
=>
$language
);
return
$this
->
get
(
'newsflash/update_list'
,
$params
);
}
/**
* Gets the Article List ,Without Content field.
*
* @param number $page
* @param number $page_size
* @param string $language
* @return mixed
*/
public
function
getArticleList
(
$page
=
1
,
$page_size
=
20
,
$language
=
BISHIJIE_LANGUAGE_CN
)
{
$params
=
array
(
'language'
=>
$language
,
'page'
=>
$page
,
'size'
=>
$page_size
);
return
$this
->
get
(
'article/list'
,
$params
);
}
/**
* Get Article detail(with content field)
*
* @param number $news_id
* @param string $language
* @return mixed
*/
public
function
getArticleDetail
(
$article_id
,
$language
=
BISHIJIE_LANGUAGE_CN
)
{
$params
=
array
(
'language'
=>
$language
,
'id'
=>
$article_id
);
return
$this
->
get
(
'article/detail'
,
$params
);
}
protected
function
get
(
$method
,
$params
)
{
$params
=
$this
->
buildRequest
(
$params
);
$url
=
self
::
$base_url
.
$method
.
'?'
.
http_build_query
(
$params
);
$data
=
$this
->
http
(
$url
,
'GET'
);
if
(
$this
->
http_info
[
'http_code'
]
==
405
)
throw
new
BishijieException
(
'This interface does not support GET method requests'
,
1003
);
return
$data
;
}
protected
function
post
(
$method
,
$params
)
{
$request
=
$this
->
buildRequest
(
$params
);
$url
=
self
::
$base_url
.
$method
;
$data
=
$this
->
http
(
$url
,
'POST'
,
http_build_query
(
$request
));
if
(
$this
->
http_info
[
'http_code'
]
==
405
)
throw
new
BishijieException
(
'This interface does not support POST method requests'
,
1004
);
return
$data
;
}
protected
function
buildRequest
(
array
$params
)
{
$params
[
'app_id'
]
=
$this
->
app_id
;
$params
[
'timestamp'
]
=
time
();
ksort
(
$params
);
$params
[
'sign'
]
=
md5
(
http_build_query
(
$params
)
.
$this
->
app_sercet
);
return
$params
;
}
/**
*
* @param string $url
* @param string $method
* @param string $postfields
* @return mixed
*/
protected
function
http
(
$url
,
$method
,
$postfields
=
NULL
)
{
$this
->
http_info
=
array
();
$ci
=
curl_init
();
curl_setopt
(
$ci
,
CURLOPT_USERAGENT
,
$this
->
useragent
);
curl_setopt
(
$ci
,
CURLOPT_CONNECTTIMEOUT
,
$this
->
connecttimeout
);
curl_setopt
(
$ci
,
CURLOPT_TIMEOUT
,
$this
->
timeout
);
curl_setopt
(
$ci
,
CURLOPT_RETURNTRANSFER
,
TRUE
);
curl_setopt
(
$ci
,
CURLOPT_HTTPHEADER
,
array
(
'Expect:'
));
curl_setopt
(
$ci
,
CURLOPT_SSL_VERIFYPEER
,
$this
->
ssl_verifypeer
);
curl_setopt
(
$ci
,
CURLOPT_HEADERFUNCTION
,
array
(
$this
,
'getHeader'
));
curl_setopt
(
$ci
,
CURLOPT_HEADER
,
FALSE
);
curl_setopt
(
$ci
,
CURLOPT_SSL_VERIFYHOST
,
false
);
$method
=
strtoupper
(
$method
);
switch
(
$method
)
{
case
'POST'
:
curl_setopt
(
$ci
,
CURLOPT_POST
,
TRUE
);
if
(
!
empty
(
$postfields
))
curl_setopt
(
$ci
,
CURLOPT_POSTFIELDS
,
$postfields
);
break
;
case
'DELETE'
:
curl_setopt
(
$ci
,
CURLOPT_CUSTOMREQUEST
,
'DELETE'
);
if
(
!
empty
(
$postfields
))
$url
=
"
{
$url
}
?
{
$postfields
}
"
;
}
curl_setopt
(
$ci
,
CURLOPT_URL
,
$url
);
$response
=
curl_exec
(
$ci
);
$this
->
http_code
=
curl_getinfo
(
$ci
,
CURLINFO_HTTP_CODE
);
$this
->
http_info
=
array_merge
(
$this
->
http_info
,
curl_getinfo
(
$ci
));
$this
->
url
=
$url
;
if
(
$response
==
false
)
$this
->
curl_error
=
curl_error
(
$ci
);
$this
->
curl_response
=
$response
;
curl_close
(
$ci
);
$response
=
json_decode
(
$response
,
true
);
return
$response
;
}
/**
* Get the header info to store.
*/
public
function
getHeader
(
$ch
,
$header
)
{
$i
=
strpos
(
$header
,
':'
);
if
(
!
empty
(
$i
))
{
$key
=
str_replace
(
'-'
,
'_'
,
strtolower
(
substr
(
$header
,
0
,
$i
)));
$value
=
trim
(
substr
(
$header
,
$i
+
2
));
$this
->
http_header
[
$key
]
=
$value
;
}
return
strlen
(
$header
);
}
}
class
BishijieException
extends
\Exception
{
}
\ No newline at end of file
common/service/exchange/factory/BinanceBuilder.php
View file @
d345981e
...
...
@@ -14,6 +14,7 @@ class BinanceBuilder extends FactoryService
{
protected
$base_url
=
'https://api.binance.com'
;
protected
$supported_symbol
=
'supported_symbol_binance'
;
protected
$supported_symbol_list
=
'supported_symbol_binance_list'
;
protected
$quotation_prefix
=
'quotation_binance_'
;
public
function
getTicker
()
...
...
@@ -53,9 +54,27 @@ class BinanceBuilder extends FactoryService
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
public
function
getTickerFromCache
()
public
function
getTickerFromCache
(
$page
=
1
)
{
$size
=
0
;
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
$size
+=
50
;
$this
->
end
=
$size
;
}
$this
->
start
=
$this
->
end
-
50
;
$this
->
end
=
$this
->
end
-
1
;
$keys
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
false
==
$this
->
redis
->
exists
(
$this
->
supported_symbol_list
))
{
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
$explode_arr
=
explode
(
$coin
,
$val
);
if
(
2
==
count
(
$explode_arr
)
&&
empty
(
$explode_arr
[
1
]))
{
$this
->
redis
->
lpush
(
$this
->
supported_symbol_list
,
$val
);
}
}
}
}
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
$this
->
start
,
$this
->
end
);
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
...
...
@@ -82,9 +101,14 @@ class BinanceBuilder extends FactoryService
}
}
}
if
(
count
(
$ticker
)
>
0
)
{
$this
->
code
=
0
;
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
$this
->
code
=
0
;
$data
=
[
'ticker'
=>
$ticker
,
'page'
=>
[
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
]
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
}
}
\ No newline at end of file
common/service/exchange/factory/FactoryService.php
View file @
d345981e
...
...
@@ -18,6 +18,9 @@ abstract class FactoryService
protected
$basic_price
=
[];
protected
$redis
;
protected
$start
;
protected
$end
;
public
function
__construct
()
{
$curl
=
new
Curl
();
...
...
@@ -32,7 +35,7 @@ abstract class FactoryService
$params
=
json_encode
(
$data
);
$curl
->
setHeader
(
'Content-Type'
,
'application/json'
);
$curl
->
setRawPostData
(
$params
);
$res
=
$curl
->
post
(
'http
s://b.biqianbao.net
/interface/coin/coin-index'
,
true
);
$res
=
$curl
->
post
(
'http
://127.0.0.1:8082
/interface/coin/coin-index'
,
true
);
$res
=
json_decode
(
$res
,
true
);
foreach
(
$res
[
'data'
]
as
$val
)
{
...
...
common/service/exchange/factory/HuobiBuilder.php
View file @
d345981e
...
...
@@ -54,8 +54,15 @@ class HuobiBuilder extends FactoryService
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
public
function
getTickerFromCache
()
public
function
getTickerFromCache
(
$page
=
1
)
{
$size
=
0
;
for
(
$i
=
0
;
$i
<
$page
;
$i
++
)
{
$size
+=
50
;
$this
->
end
=
$size
;
}
$this
->
start
=
$this
->
end
-
50
;
$this
->
end
=
$this
->
end
-
1
;
$keys
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
false
==
$this
->
redis
->
exists
(
$this
->
supported_symbol_list
))
{
foreach
(
$keys
as
$val
)
{
...
...
@@ -67,8 +74,7 @@ class HuobiBuilder extends FactoryService
}
}
}
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
0
,
50
);
$keys
=
$this
->
redis
->
lrange
(
$this
->
supported_symbol_list
,
$this
->
start
,
$this
->
end
);
$ticker
=
[];
foreach
(
$keys
as
$val
)
{
foreach
(
$this
->
basic_coin
as
$k
=>
$coin
)
{
...
...
@@ -95,10 +101,15 @@ class HuobiBuilder extends FactoryService
}
}
}
if
(
count
(
$ticker
)
>
0
)
{
$this
->
code
=
0
;
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
$this
->
code
=
0
;
$data
=
[
'ticker'
=>
$ticker
,
'page'
=>
[
'pageSize'
=>
50
,
'currentPage'
=>
(
int
)
$page
,
]
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
}
public
function
getHotTicker
()
...
...
@@ -132,4 +143,4 @@ class HuobiBuilder extends FactoryService
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
}
}
\ No newline at end of file
}
common/service/exchange/factory/ZhaobiBuilder.php
View file @
d345981e
...
...
@@ -21,7 +21,6 @@ class ZhaobiBuilder extends FactoryService
$res
=
$curl
->
get
(
$api
,
false
);
$ticker
=
[];
if
(
isset
(
$res
[
'message'
])
&&
'OK'
==
$res
[
'message'
])
{
$this
->
code
=
0
;
$ticker_temp
=
[];
foreach
(
$res
[
'data'
]
as
$val
)
{
$ticker_temp
=
array_merge
(
$ticker_temp
,
$val
);
...
...
@@ -34,7 +33,7 @@ class ZhaobiBuilder extends FactoryService
$temp
[
'symbol'
]
=
strtoupper
(
$explode_arr
[
0
])
.
'/'
.
$coin
;
$temp
[
'currency'
]
=
strtoupper
(
$explode_arr
[
0
]);
$temp
[
'base_currency'
]
=
strtoupper
(
$coin
);
$temp
[
'close'
]
=
(
float
)
sprintf
(
"%0.6f"
,
$val
[
'last'
]
);
$temp
[
'close'
]
=
number_format
(
$val
[
'last'
],
6
,
'.'
,
''
);
$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.4f"
,
(
$val
[
'last'
]
-
$val
[
'open'
])
/
$val
[
'open'
]
*
100
);
...
...
@@ -51,7 +50,15 @@ class ZhaobiBuilder extends FactoryService
}
}
}
return
[
'code'
=>
$this
->
code
,
'ticker'
=>
$ticker
];
$this
->
code
=
0
;
$data
=
[
'ticker'
=>
$ticker
,
'page'
=>
[
'pageSize'
=>
50
,
'currentPage'
=>
1
,
]
];
return
[
'code'
=>
$this
->
code
,
'data'
=>
$data
];
}
public
function
getNotice
(
$params
=
[])
...
...
console/controllers/GameBetController.php
View file @
d345981e
...
...
@@ -110,7 +110,7 @@ class GameBetController extends Controller
$models
=
CoinGameBet
::
find
()
->
select
(
'round'
)
->
where
([
'and'
,
[
'valid'
=>
CoinGameBet
::
VAILD_FALSE
],
[
'<'
,
'height'
,
$safe_height
],
[
'<
=
'
,
'height'
,
$safe_height
],
[
'platform'
=>
$key
]
])
->
all
();
if
(
empty
(
$models
))
{
...
...
vendor/yiisoft/yii2-elasticsearch/Connection.php
View file @
d345981e
...
...
@@ -495,6 +495,7 @@ class Connection extends Component
}
$this
->
resetCurlHandle
();
$url
=
'http://47.100.218.222:9200/_nodes'
;
curl_setopt
(
$this
->
_curl
,
CURLOPT_URL
,
$url
);
curl_setopt_array
(
$this
->
_curl
,
$options
);
if
(
curl_exec
(
$this
->
_curl
)
===
false
)
{
...
...
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