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
e598d212
Commit
e598d212
authored
Jun 04, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/sakura' into 'feature/bet'
Feature/sakura See merge request
!29
parents
6df49191
57f76bcd
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
379 additions
and
27 deletions
+379
-27
BaseController.php
api/base/BaseController.php
+18
-0
CoinController.php
api/controllers/CoinController.php
+16
-1
CoinController.php
backend/controllers/CoinController.php
+36
-0
CoinReleaseCheckController.php
backend/controllers/CoinReleaseCheckController.php
+5
-1
add.php
backend/views/coin/add.php
+28
-4
edit.php
backend/views/coin/edit.php
+28
-4
Chain33Business.php
common/business/Chain33Business.php
+2
-2
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+28
-9
Bty.php
common/service/exchange/Bty.php
+1
-1
Go.php
common/service/exchange/Go.php
+70
-0
Zg.php
common/service/exchange/Zg.php
+75
-0
Zhaobi.php
common/service/exchange/Zhaobi.php
+66
-0
ReleaseCheckController.php
console/controllers/ReleaseCheckController.php
+6
-5
No files found.
api/base/BaseController.php
View file @
e598d212
...
...
@@ -17,6 +17,24 @@ class BaseController extends Controller
public
$start
;
public
$end
;
public
$header_list
=
[];
public
$lang
;
private
static
$default_header_list
=
[];
public
function
init
()
{
if
(
'cli'
!==
php_sapi_name
()){
$this
->
header_list
=
self
::
$default_header_list
;
$this
->
fzmCrossHeader
();
}
}
public
function
fzmCrossHeader
()
{
$this
->
lang
=
\Yii
::
$app
->
request
->
headers
->
get
(
'lang'
)
??
'zh-CN'
;
}
public
function
beforeAction
(
$action
)
{
$this
->
start
=
microtime
(
true
);
...
...
api/controllers/CoinController.php
View file @
e598d212
...
...
@@ -39,7 +39,12 @@ class CoinController extends BaseController
if
(
$id
)
{
$ret
=
CoinBusiness
::
getCoinAllById
(
$id
);
if
(
$ret
)
{
return
$ret
[
0
];
$data
=
$ret
[
0
];
$nickname
=
json_decode
(
$data
[
'nickname'
],
true
);
$introduce
=
json_decode
(
$data
[
'introduce'
],
true
);
$data
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
$data
[
'introduce'
]
=
$introduce
[
$this
->
lang
];
return
$data
;
}
}
return
[];
...
...
@@ -134,6 +139,10 @@ class CoinController extends BaseController
$coin_ids
=
array_column
(
$coin_recommends
,
'cid'
);
//获取币种信息
$coin_infos
=
Coin
::
getCoinInfoByIds
(
$coin_ids
,
$select
,
'id'
);
foreach
(
$coin_infos
as
$key
=>
&
$val
){
$nickname
=
json_decode
(
$val
[
'nickname'
],
true
);
$val
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
}
//获取行情信息
$coin_names
=
array_column
(
$coin_infos
,
'name'
);
$coin_names
=
array_merge
(
$coin_names
,
array_column
(
$coin_infos
,
'chain'
));
...
...
@@ -231,6 +240,8 @@ class CoinController extends BaseController
$chain_quotation
[
$value
]
=
ExchangeBusiness
::
getquatation
(
$value
);
}
foreach
(
$result
[
'data'
]
as
$key
=>
&
$value
)
{
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
$value
[
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]]
?:
null
;
}
return
$result
;
...
...
@@ -279,6 +290,10 @@ class CoinController extends BaseController
foreach
(
$result
as
$key
=>
$value
)
{
$result
[
$key
][
'chain_quotation'
]
=
$chain_quotation
[
$value
[
'chain'
]]
?:
null
;
}
foreach
(
$result
as
$key
=>
&
$value
)
{
$nickname
=
json_decode
(
$value
[
'nickname'
],
true
);
$value
[
'nickname'
]
=
$nickname
[
$this
->
lang
];
}
return
[
'code'
=>
0
,
'count'
=>
$total
,
'data'
=>
$result
];
}
}
...
...
backend/controllers/CoinController.php
View file @
e598d212
...
...
@@ -92,6 +92,24 @@ class CoinController extends BaseController
$data
[
'name'
]
=
strtoupper
(
$data
[
'name'
]);
$data
[
'platform'
]
=
strtolower
(
$data
[
'platform'
]);
$data
[
'chain'
]
=
strtoupper
(
$data
[
'chain'
]);
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$nickname_arr
=
$data
[
'nickname'
];
$introduce_arr
=
$data
[
'introduce'
];
$nickname
=
[];
$introduce
=
[];
foreach
(
$nickname_arr
as
$key
=>
$val
){
$nickname
[
$lang
[
$key
]]
=
$val
;
}
foreach
(
$introduce_arr
as
$key
=>
$val
){
$introduce
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$data
[
'nickname'
]);
$data
[
'nickname'
]
=
$nickname
;
$data
[
'introduce'
]
=
$introduce
;
$result
=
$coin
->
addOne
(
$data
);
if
(
$result
===
true
)
{
$this
->
success
(
'添加成功'
,
'/admin/coin/index'
);
...
...
@@ -142,6 +160,24 @@ class CoinController extends BaseController
$can
=
true
;
}
if
(
$can
)
{
$lang
=
[
'zh-CN'
,
'en-US'
,
'ja'
];
$nickname_arr
=
$data
[
'nickname'
];
$introduce_arr
=
$data
[
'introduce'
];
$nickname
=
[];
$introduce
=
[];
foreach
(
$nickname_arr
as
$key
=>
$val
){
$nickname
[
$lang
[
$key
]]
=
$val
;
}
foreach
(
$introduce_arr
as
$key
=>
$val
){
$introduce
[
$lang
[
$key
]]
=
$val
;
}
unset
(
$data
[
'nickname'
]);
$data
[
'nickname'
]
=
$nickname
;
$data
[
'introduce'
]
=
$introduce
;
$coin
=
Yii
::
createObject
(
Coin
::
className
());
$result
=
$coin
->
updateOne
(
$data
);
if
(
$result
===
true
)
{
...
...
backend/controllers/CoinReleaseCheckController.php
View file @
e598d212
...
...
@@ -109,13 +109,13 @@ class CoinReleaseCheckController extends BaseController
if
(
$model
->
load
(
$get
)
&&
$model
->
validate
())
{
$page
=
$get
[
'page'
]
??
1
;
$limit
=
$get
[
'limit'
]
??
10
;
$mobile
=
$get
[
'mobile'
]
??
''
;
$query
=
CoinReleaseCheck
::
find
()
->
andFilterWhere
([
'!='
,
'status'
,
0
])
->
andFilterWhere
([
'status'
=>
$model
->
status
,
'coin'
=>
$model
->
coin
,
'check_first_uid'
=>
$model
->
check_first_uid
,
'check_second_uid'
=>
$model
->
check_second_uid
,
]);
$user_id
=
Yii
::
$app
->
user
->
identity
->
id
;
$auth
=
Yii
::
$app
->
authManager
;
$user_role
=
current
(
$auth
->
getRolesByUser
(
$user_id
));
...
...
@@ -141,6 +141,10 @@ class CoinReleaseCheckController extends BaseController
if
(
$model
->
end_time
)
{
$query
=
$query
->
andFilterWhere
([
'<='
,
'create_time'
,
$model
->
end_time
]);
}
if
(
$mobile
){
$query
=
$query
->
andFilterWhere
([
'mobile'
=>
$mobile
]);
}
$count
=
$query
->
count
();
$datas
=
$query
->
limit
(
$limit
)
->
offset
((
$page
-
1
)
*
$limit
)
->
orderBy
(
'id desc'
)
->
asArray
()
->
all
();
//获取审核员id
...
...
backend/views/coin/add.php
View file @
e598d212
...
...
@@ -25,8 +25,20 @@
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"nickname"
value=
"
<?=
$model
->
nickname
?>
"
>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'zh-CN'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
英文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'en-US'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
日文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'ja'
]
?>
"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -113,9 +125,21 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
介绍
</label>
<label
class=
"layui-form-label"
>
中文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'zh-CN'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
英文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'en-US'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
日文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce
"
>
<?=
$model
->
introduce
?>
</textarea>
<textarea
class=
"layui-textarea"
name=
"introduce
[]"
>
<?=
$model
->
introduce
[
'ja'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-inline"
>
...
...
backend/views/coin/edit.php
View file @
e598d212
...
...
@@ -25,8 +25,20 @@
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
中文名
</label>
<div
class=
"layui-input-block"
>
<input
class=
"layui-input"
name=
"nickname"
value=
"
<?=
$model
->
nickname
?>
"
>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'zh-CN'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
英文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'en-US'
]
?>
"
>
</div>
</div>
<div
class=
"layui-inline"
>
<label
class=
"layui-form-label"
>
日文名
</label>
<div
class=
"layui-input-block"
style=
"width: 250px"
>
<input
class=
"layui-input"
name=
"nickname[]"
value=
"
<?=
$model
->
nickname
[
'ja'
]
?>
"
>
</div>
</div>
<div
class=
"layui-form-item"
>
...
...
@@ -117,9 +129,21 @@
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
介绍
</label>
<label
class=
"layui-form-label"
>
中文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'zh-CN'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
英文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce[]"
>
<?=
$model
->
introduce
[
'en-US'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
日文介绍
</label>
<div
class=
"layui-input-block"
>
<textarea
class=
"layui-textarea"
name=
"introduce
"
>
<?=
$model
->
introduce
?>
</textarea>
<textarea
class=
"layui-textarea"
name=
"introduce
[]"
>
<?=
$model
->
introduce
[
'ja'
]
?>
</textarea>
</div>
</div>
<div
class=
"layui-inline"
>
...
...
common/business/Chain33Business.php
View file @
e598d212
...
...
@@ -313,9 +313,9 @@ class Chain33Business
* @param array $hashes
* @return array
*/
public
static
function
getTxByHashs
(
$hashes
)
public
static
function
getTxByHashs
(
$hashes
,
$node_params
=
[]
)
{
$service
=
new
Chain33Service
();
$service
=
new
Chain33Service
(
$node_params
);
return
$service
->
getTxByHashes
(
$hashes
);
}
...
...
common/business/ExchangeBusiness.php
View file @
e598d212
...
...
@@ -33,7 +33,10 @@ class ExchangeBusiness
4
=>
'Bittrex'
,
5
=>
'Zb'
,
6
=>
'Token7'
,
7
=>
'S'
7
=>
'S'
,
8
=>
'Zg'
,
9
=>
'Go'
,
10
=>
'Zhaobi'
];
/**
...
...
@@ -96,6 +99,20 @@ class ExchangeBusiness
return
$quotation
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'GHP'
])){
$exchange
=
ExchangeFactory
::
createExchange
(
"Zg"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNZ'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
return
$quotation
;
}
if
(
in_array
(
strtoupper
(
$tag
),[
'SFT'
])){
$exchange
=
ExchangeFactory
::
createExchange
(
"Zhaobi"
);
$quotation
=
$exchange
->
getTicker
(
$tag
,
'CNY'
);
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$quotation
[
'last'
]);
return
$quotation
;
}
foreach
(
self
::
$exchanges
as
$exchange
)
{
/**
* @var $exchange \common\service\exchange\Exchange
...
...
@@ -139,10 +156,14 @@ class ExchangeBusiness
/**
* @var $exchange \common\service\exchange\Exchange
*/
$exchange
=
ExchangeFactory
::
createExchange
(
"Bty"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
$exchange
=
ExchangeFactory
::
createExchange
(
"Go"
);
$rate
=
$exchange
->
getTicker
(
"CNY"
,
"USD"
);
$rate
=
$rate
[
'last'
]
??
''
;
if
(
empty
(
$rate
))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Bty"
);
$rate
=
$exchange
->
getTicker
(
"BTY"
,
"USDT"
);
$rate
=
(
float
)
$rate
[
'rmb'
]
/
$rate
[
'last'
];
}
$quotation
[
'rmb'
]
=
(
float
)
sprintf
(
"%0.2f"
,
$rate
*
$quotation
[
'last'
]);
return
$quotation
;
...
...
@@ -203,8 +224,7 @@ class ExchangeBusiness
$quotation
=
self
::
getquatation
(
$row
[
'name'
]);
if
(
!
$quotation
)
{
$quotation
=
[];
//使用Coin服务
try
{
if
(
in_array
(
$row
[
'name'
],
[
'BTY'
,
'YCC'
])){
$coinServer
=
CoinFactory
::
createCoin
(
$row
[
'name'
],
$row
[
'id'
],
$row
[
'sid'
]);
$rows
[
$key
][
'sid'
]
=
ucfirst
(
$rows
[
$key
][
'sid'
]);
$rows
[
$key
][
'rmb'
]
=
$coinServer
->
getPrice
();
...
...
@@ -212,12 +232,11 @@ class ExchangeBusiness
$rows
[
$key
][
'low'
]
=
$coinServer
->
getLow
();
$rows
[
$key
][
'high'
]
=
$coinServer
->
getHigh
();
$coinServer
->
__destruct
();
}
catch
(
\Exception
$exception
)
{
}
else
{
$rows
[
$key
][
'rmb'
]
=
0
;
$rows
[
$key
][
'last'
]
=
0
;
$rows
[
$key
][
'low'
]
=
0
;
$rows
[
$key
][
'high'
]
=
0
;
\Yii
::
error
(
$exception
->
getMessage
());
}
}
if
(
strtoupper
(
$row
[
'platform'
])
==
'GUODUN'
)
{
...
...
common/service/exchange/Bty.php
View file @
e598d212
...
...
@@ -14,7 +14,7 @@ class Bty extends Exchange implements ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_bty'
;
protected
$quotation_prefix
=
'quotation_bty_'
;
protected
$base_url
=
'https://
zbapi.licai.cn
/api/data/Ticker?sort=cname&platform='
;
protected
$base_url
=
'https://
api.zhaobi.xyz
/api/data/Ticker?sort=cname&platform='
;
/**
* 转化交易对为请求变量
...
...
common/service/exchange/Go.php
0 → 100644
View file @
e598d212
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace
common\service\exchange
;
use
linslin\yii2\curl\Curl
;
class
Go
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_go'
;
protected
$quotation_prefix
=
'quotation_go_'
;
protected
$base_url
=
'https://otc-api.eiijo.cn/v1/data/trade-market?country=37¤cy=1&payMethod=0&currPage=1&coinId=2&tradeType=sell&blockType=general&online=1'
;
public
function
symbolExists
(
$tag
=
'CNY'
,
$aim
=
"USD"
)
{
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
return
true
;
}
return
false
;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public
function
formatSymbol
(
$tag
=
'CNY'
,
$aim
=
'USD'
)
{
return
strtoupper
(
$tag
.
'_'
.
$aim
);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setSupportedSymbol
()
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'CNY_USD'
);
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$content
=
$curl
->
get
(
$this
->
base_url
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'code'
])
&&
(
200
==
$content
[
'code'
]))
{
$data
=
$content
[
'data'
];
foreach
(
$data
as
$item
)
{
$key
=
$this
->
quotation_prefix
.
'CNY_USD'
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$item
[
'price'
],
'high'
,
$item
[
'price'
],
'last'
,
$item
[
'price'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'CNY_USD'
);
break
;
}
}
}
}
\ No newline at end of file
common/service/exchange/Zg.php
0 → 100644
View file @
e598d212
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace
common\service\exchange
;
use
linslin\yii2\curl\Curl
;
class
Zg
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_zg'
;
protected
$quotation_prefix
=
'quotation_zg_'
;
protected
$base_url
=
'https://api1.zg.com/tickers'
;
public
function
symbolExists
(
$tag
=
'HL'
,
$aim
=
"USDT"
)
{
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
return
true
;
}
return
false
;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public
function
formatSymbol
(
$tag
=
'HL'
,
$aim
=
'USDT'
)
{
return
strtoupper
(
$tag
.
'_'
.
$aim
);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setSupportedSymbol
()
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'HL_USDT'
);
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$curl
->
setHeaders
([
'User-Agent'
=>
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
,
]);
$content
=
$curl
->
get
(
$this
->
base_url
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'ticker'
]))
{
$data
=
$content
[
'ticker'
];
foreach
(
$data
as
$item
)
{
if
(
in_array
(
$item
[
'symbol'
],
[
'HL_USDT'
,
'GHP_CNZ'
]))
{
$data
=
$item
;
$key
=
$this
->
quotation_prefix
.
$item
[
'symbol'
];
$this
->
redis
->
hmset
(
$key
,
'low'
,
$data
[
'low'
],
'high'
,
$data
[
'high'
],
'last'
,
$data
[
'last'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
$item
[
'symbol'
]);
}
}
}
}
}
\ No newline at end of file
common/service/exchange/Zhaobi.php
0 → 100644
View file @
e598d212
<?php
/**
* Created by PhpStorm.
* User: rlgyzhcn
* Date: 18-8-7
* Time: 上午11:30
*/
namespace
common\service\exchange
;
use
linslin\yii2\curl\Curl
;
class
Zhaobi
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_zhaobi'
;
protected
$quotation_prefix
=
'quotation_zhaobi_'
;
protected
$base_url
=
'https://api.biqianbao.top/api/data/basecoinprice?base=CNY&coin=SFT&platform=zhaobi'
;
public
function
symbolExists
(
$tag
=
'SFT'
,
$aim
=
"CNY"
)
{
$supported
=
$this
->
redis
->
smembers
(
$this
->
supported_symbol
);
if
(
is_array
(
$supported
)
&&
in_array
(
$this
->
formatSymbol
(
$tag
,
$aim
),
$supported
))
{
return
true
;
}
return
false
;
}
/**
* 转化交易对为请求变量
*
* @param string $tag
* @param string $aim
* @return mixed
*/
public
function
formatSymbol
(
$tag
=
'SFT'
,
$aim
=
'CNY'
)
{
return
strtoupper
(
$tag
.
'_'
.
$aim
);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setSupportedSymbol
()
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'SFT_CNY'
);
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$content
=
$curl
->
get
(
$this
->
base_url
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'code'
])
&&
(
200
==
$content
[
'code'
]))
{
$data
=
$content
[
'data'
][
0
];
$key
=
$this
->
quotation_prefix
.
'SFT_CNY'
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$data
[
'value'
],
'high'
,
$data
[
'value'
],
'last'
,
$data
[
'value'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'SFT_CNY'
);
}
}
}
\ No newline at end of file
console/controllers/ReleaseCheckController.php
View file @
e598d212
...
...
@@ -74,12 +74,12 @@ class ReleaseCheckController extends Controller
$walletpasswd
=
Yii
::
$app
->
redis
->
get
(
'wallet_passwd'
);
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'secondary'
];
Chain33Business
::
unLockWallet
(
$walletpasswd
,
$node_params
);
$result
=
Chain33Business
::
transToken
(
trim
(
$from
),
trim
(
$coin_release_check
->
to_address
),
$result
=
Chain33Business
::
tradeToken
(
(
int
)
$coin_release_check
->
amount
,
"锁仓释放"
,
''
,
1000
,
$isToken
,
trim
(
$coin_release_check
->
to_address
),
$coin_release_check
->
coin
,
$node_params
);
...
...
@@ -124,7 +124,8 @@ class ReleaseCheckController extends Controller
foreach
(
$coin_release_checkItems
as
$coin_release_check
){
$coin_release_list
=
CoinReleaseList
::
findOne
(
$coin_release_check
->
list_id
);
if
(
$coin_release_list
)
{
$result
=
Chain33Business
::
getTxByHashs
([
$coin_release_check
->
txhash
]);
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'secondary'
];
$result
=
Chain33Business
::
getTxByHashs
([
$coin_release_check
->
txhash
],
$node_params
);
if
(
$result
[
'code'
]
==
0
)
{
$result
=
$result
[
'result'
][
'txs'
][
0
][
'receipt'
][
'ty'
]
??
0
;
if
(
$result
==
1
)
{
...
...
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