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
339e6ff5
Commit
339e6ff5
authored
Sep 10, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into feature/ws_ticker
parents
b35924a8
80f2bde6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
687 additions
and
72 deletions
+687
-72
CoinDogController.php
api/controllers/CoinDogController.php
+82
-0
CoinPlatformBannerController.php
api/controllers/CoinPlatformBannerController.php
+4
-3
CrossChainController.php
api/controllers/CrossChainController.php
+210
-0
GameBetController.php
api/controllers/GameBetController.php
+2
-2
CoinPlatformBannerController.php
backend/controllers/CoinPlatformBannerController.php
+20
-17
index.php
backend/views/coin-platform-banner/index.php
+12
-3
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+10
-2
Curl.php
common/helpers/Curl.php
+0
-0
CoinCrossChain.php
common/models/psources/CoinCrossChain.php
+45
-0
Chain33Service.php
common/service/chain33/Chain33Service.php
+61
-41
Ceohk.php
common/service/exchange/Ceohk.php
+62
-0
CrossChainController.php
console/controllers/CrossChainController.php
+175
-0
GameBetController.php
console/controllers/GameBetController.php
+4
-1
GameBet.sh
shell/GameBet.sh
+0
-3
No files found.
api/controllers/CoinDogController.php
0 → 100644
View file @
339e6ff5
<?php
namespace
api\controllers
;
use
linslin\yii2\curl\Curl
;
use
Yii
;
use
api\base\BaseController
;
class
CoinDogController
extends
BaseController
{
public
function
actionArticle
()
{
$coindog
=
Yii
::
$app
->
params
[
'coindog'
];
$accessKey
=
$coindog
[
'accessKey'
];
$secretKey
=
$coindog
[
'secretKey'
];
$httpParams
=
array
(
'access_key'
=>
$accessKey
,
'date'
=>
time
()
);
$signParams
=
array_merge
(
$httpParams
,
array
(
'secret_key'
=>
$secretKey
));
ksort
(
$signParams
);
$signString
=
http_build_query
(
$signParams
);
$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'
];
}
public
function
actionLive
()
{
$limit
=
Yii
::
$app
->
request
->
get
(
'limit'
,
20
);
$id
=
Yii
::
$app
->
request
->
get
(
'id'
,
0
);
$flag
=
Yii
::
$app
->
request
->
get
(
'flag'
,
'down'
);
$coindog
=
Yii
::
$app
->
params
[
'coindog'
];
$accessKey
=
$coindog
[
'accessKey'
];
$secretKey
=
$coindog
[
'secretKey'
];
$httpParams
=
array
(
'access_key'
=>
$accessKey
,
'date'
=>
time
()
);
$signParams
=
array_merge
(
$httpParams
,
array
(
'secret_key'
=>
$secretKey
));
ksort
(
$signParams
);
$signString
=
http_build_query
(
$signParams
);
$httpParams
=
[
'sign'
=>
strtolower
(
md5
(
$signString
)),
'limit'
=>
$limit
,
'id'
=>
$id
,
'flag'
=>
$flag
];
$url
=
$coindog
[
'live'
]
.
'?'
.
http_build_query
(
$httpParams
);
$curl
=
new
Curl
();
$resp
=
$curl
->
get
(
$url
,
false
);
if
(
!
isset
(
$resp
[
'list'
]))
{
$msg
=
'数据不存在'
;
$code
=
-
1
;
$data
=
null
;
goto
doEnd
;
}
$list
=
$resp
[
'list'
][
0
][
'lives'
];
foreach
(
$list
as
&
$item
)
{
preg_match_all
(
"/\【(.+?)\】/"
,
$item
[
'content'
],
$match
);
$item
[
'title'
]
=
$match
[
1
][
0
];
}
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'data'
=>
$list
,
'msg'
=>
$msg
];
}
}
\ No newline at end of file
api/controllers/CoinPlatformBannerController.php
View file @
339e6ff5
...
@@ -13,14 +13,15 @@ class CoinPlatformBannerController extends BaseController
...
@@ -13,14 +13,15 @@ class CoinPlatformBannerController extends BaseController
$code
=
0
;
$code
=
0
;
$msg
=
'success'
;
$msg
=
'success'
;
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
''
);
$platform_id
=
Yii
::
$app
->
request
->
get
(
'platform_id'
,
''
);
if
(
empty
(
$platform_id
)){
$type
=
Yii
::
$app
->
request
->
get
(
'type'
,
''
);
$msg
=
'参数不能为空'
;
if
(
empty
(
$platform_id
)
||
empty
(
$type
))
{
$msg
=
'参数错误'
;
$code
=
-
1
;
$code
=
-
1
;
$data
=
null
;
$data
=
null
;
goto
doEnd
;
goto
doEnd
;
}
}
$data
=
CoinPlatformBanner
::
find
()
->
where
([
'platform_id'
=>
$platform_id
])
->
asArray
()
->
all
();
$data
=
CoinPlatformBanner
::
find
()
->
where
([
'platform_id'
=>
$platform_id
,
'type'
=>
$type
])
->
asArray
()
->
all
();
doEnd
:
doEnd
:
return
[
'code'
=>
$code
,
'data'
=>
$data
,
'msg'
=>
$msg
];
return
[
'code'
=>
$code
,
'data'
=>
$data
,
'msg'
=>
$msg
];
...
...
api/controllers/CrossChainController.php
0 → 100644
View file @
339e6ff5
<?php
namespace
api\controllers
;
use
api\base\BaseController
;
use
common\models\psources\CoinAirDropTrade
;
use
common\models\psources\CoinCrossChain
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
use
yii\db\Exception
;
class
CrossChainController
extends
BaseController
{
public
function
actionTransfer
()
{
$code
=
-
1
;
$request
=
Yii
::
$app
->
request
;
if
(
!
$request
->
isPost
)
{
$msg
=
'请求错误!'
;
goto
doEnd
;
}
$post
=
$request
->
post
();
if
(
3
!=
count
(
$post
[
'txs'
]))
{
$msg
=
'交易笔数错误!'
;
goto
doEnd
;
}
$data
[
'is_with_draw'
]
=
(
false
==
$post
[
'isWithdraw'
])
?
0
:
1
;
$data
[
'address'
]
=
$post
[
'address'
];
$data
[
'transfer_number'
]
=
date
(
'YmdHis'
)
.
self
::
getrandnums
();
$redis
=
Yii
::
$app
->
redis
;
if
(
$redis
->
exists
(
$post
[
'address'
]
.
'_'
.
$data
[
'is_with_draw'
]))
{
$msg
=
'存在未完成的交易!'
;
goto
doEnd
;
}
$redis
->
set
(
$post
[
'address'
]
.
'_'
.
$data
[
'is_with_draw'
],
$post
[
'address'
]
.
'_'
.
$data
[
'is_with_draw'
]);
// $isExist = CoinCrossChain::find()
// ->where(['address' => $post['address'], 'is_with_draw' => $data['is_with_draw']])
// ->andWhere(['<>', 'query_result', 'success'])
// ->asArray()->all();
//
// if ($isExist) {
// $msg = '存在未完成的交易!';
// goto doEnd;
// }
foreach
(
$post
[
'txs'
]
as
$key
=>
$val
)
{
$model
=
new
CoinCrossChain
();
$data
[
'txhex'
]
=
$val
[
'tx'
];
$data
[
'transfer_url'
]
=
$val
[
'url'
];
$data
[
'step'
]
=
$val
[
'step'
];
$data
[
'amount'
]
=
isset
(
$val
[
'amount'
])
?
$val
[
'amount'
]
:
0
;
$model
->
load
(
$data
,
''
);
$model
->
save
();
}
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
public
function
actionFixTransfer
()
{
$code
=
-
1
;
$request
=
Yii
::
$app
->
request
;
if
(
!
$request
->
isPost
)
{
$msg
=
'请求错误!'
;
goto
doEnd
;
}
$post
=
$request
->
post
();
$data
[
'is_with_draw'
]
=
(
false
==
$post
[
'isWithdraw'
])
?
0
:
1
;
$data
[
'address'
]
=
$post
[
'address'
];
foreach
(
$post
[
'txs'
]
as
$key
=>
$val
)
{
$model
=
CoinCrossChain
::
find
()
->
where
([
'is_with_draw'
=>
$data
[
'is_with_draw'
]])
->
andWhere
([
'address'
=>
$data
[
'address'
]])
->
andWhere
([
'step'
=>
$val
[
'step'
]])
->
andWhere
([
'<>'
,
'msg'
,
'success'
])
->
one
();
if
(
false
==
$model
)
continue
;
$node_params
=
$model
->
transfer_url
;
$node_params
=
explode
(
':'
,
$node_params
);
$node_params
=
[
'scheme'
=>
$node_params
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$node_params
[
1
]),
'port'
=>
isset
(
$node_params
[
2
])
?
$node_params
[
2
]
:
''
];
$service
=
new
Chain33Service
(
$node_params
);
$send_result
=
$model
->
send_result
;
$result
=
$service
->
QueryTransaction
(
$send_result
);
if
(
isset
(
$result
[
'result'
][
'actionName'
])
&&
'unknown'
==
$result
[
'result'
][
'actionName'
])
{
$model
->
query_result
=
'success'
;
$model
->
msg
=
'success'
;
$model
->
save
();
continue
;
}
else
if
(
isset
(
$result
[
'result'
][
'receipt'
][
'ty'
])
&&
2
==
$result
[
'result'
][
'receipt'
][
'ty'
])
{
$model
->
query_result
=
'success'
;
$model
->
msg
=
'success'
;
$model
->
save
();
continue
;
}
else
{
$model
->
txhex
=
$val
[
'tx'
];
$model
->
transfer_url
=
$val
[
'url'
];
$model
->
send_result
=
0
;
$model
->
query_result
=
0
;
$model
->
msg
=
0
;
$model
->
save
();
continue
;
}
}
$code
=
0
;
$msg
=
'success'
;
doEnd
:
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
}
public
function
actionTransferStatus
()
{
$code
=
-
1
;
$msg
=
'fail'
;
$data
=
null
;
$step
=
$amount
=
0
;
$request
=
Yii
::
$app
->
request
;
if
(
!
$request
->
isGet
)
{
$msg
=
'请求错误!'
;
goto
doEnd
;
}
$address
=
$request
->
get
(
'address'
,
''
);
$is_with_draw
=
$request
->
get
(
'isWithdraw'
,
''
);
if
(
empty
(
$address
))
{
$msg
=
'参数错误!'
;
goto
doEnd
;
}
$model
=
CoinCrossChain
::
find
()
->
where
([
'address'
=>
$address
,
'is_with_draw'
=>
$is_with_draw
])
->
orderBy
(
"id desc"
)
->
limit
(
3
)
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
$msg
=
'数据不存在!'
;
$code
=
0
;
goto
doEnd
;
}
sort
(
$model
);
foreach
(
$model
as
$key
=>
$val
)
{
$amount
=
$val
[
'amount'
];
//未交易
if
(
'0'
==
$val
[
'send_result'
]
&&
'0'
==
$val
[
'query_result'
]
&&
'0'
==
$val
[
'msg'
])
{
$step
=
$key
+
1
;
$code
=
0
;
$msg
=
'第'
.
(
$key
+
1
)
.
'笔交易尚未执行'
;
goto
doEnd
;
}
//交易报错
if
(
'0'
==
$val
[
'send_result'
]
&&
'0'
==
$val
[
'query_result'
]
&&
true
==
$val
[
'msg'
])
{
$step
=
$key
+
1
;
$code
=
-
1
;
$msg
=
$val
[
'msg'
];
goto
doEnd
;
}
//交易成功
if
(
true
==
$val
[
'send_result'
]
&&
'0'
==
$val
[
'query_result'
]
&&
'0'
==
$val
[
'msg'
])
{
$step
=
$key
+
1
;
$code
=
0
;
$msg
=
$val
[
'send_result'
];
goto
doEnd
;
}
//交易成功,查询失败
if
(
true
==
$val
[
'send_result'
]
&&
'success'
!=
$val
[
'query_result'
])
{
$step
=
$key
+
1
;
$code
=
-
1
;
$msg
=
$val
[
'msg'
];
goto
doEnd
;
}
//交易成功,查询成功
if
(
true
==
$val
[
'send_result'
]
&&
'success'
==
$val
[
'query_result'
]
&&
'success'
==
$val
[
'msg'
])
{
if
(
2
==
$key
)
{
$step
=
(
2
==
$key
)
?
4
:
(
$key
+
2
);
$code
=
0
;
$msg
=
$val
[
'send_result'
];
goto
doEnd
;
}
continue
;
}
}
doEnd
:
$data
=
[
'step'
=>
$step
,
'amount'
=>
(
int
)
$amount
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
public
static
function
getrandnums
()
{
$arr
=
array
();
while
(
count
(
$arr
)
<
6
)
{
$arr
[]
=
rand
(
0
,
9
);
$arr
=
array_unique
(
$arr
);
}
return
implode
(
""
,
$arr
);
}
}
\ No newline at end of file
api/controllers/GameBetController.php
View file @
339e6ff5
...
@@ -23,10 +23,10 @@ class GameBetController extends BaseController
...
@@ -23,10 +23,10 @@ class GameBetController extends BaseController
}
}
$query
=
CoinGameBet
::
find
()
$query
=
CoinGameBet
::
find
()
->
select
(
'round, player, amount, height, guess_num,
guess_num
, rand_num, player_win, platform'
)
->
select
(
'round, player, amount, height, guess_num,
valid
, rand_num, player_win, platform'
)
->
where
(
'player= :player'
,[
':player'
=>
$player
])
->
where
(
'player= :player'
,[
':player'
=>
$player
])
->
andWhere
([
'platform'
=>
$platform
])
->
andWhere
([
'platform'
=>
$platform
])
#
->andWhere(['valid' => CoinGameBet::VAILD_TRUE])
//
->andWhere(['valid' => CoinGameBet::VAILD_TRUE])
->
orderBy
(
'update_time desc'
);
->
orderBy
(
'update_time desc'
);
$count
=
$query
->
count
();
$count
=
$query
->
count
();
...
...
backend/controllers/CoinPlatformBannerController.php
View file @
339e6ff5
...
@@ -13,15 +13,17 @@ class CoinPlatformBannerController extends BaseController
...
@@ -13,15 +13,17 @@ class CoinPlatformBannerController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
$image_url
=
$request
->
post
(
'image_url'
,
''
);
$image_url
=
$request
->
post
(
'image_url'
,
''
);
if
(
$image_url
){
$type
=
$request
->
post
(
'banner_type'
,
1
);
if
(
$image_url
)
{
$banner_item
=
new
CoinPlatformBanner
();
$banner_item
=
new
CoinPlatformBanner
();
$banner_item
->
image_url
=
$image_url
;
$banner_item
->
image_url
=
$image_url
;
$banner_item
->
platform_id
=
$user_platform_id
;
$banner_item
->
platform_id
=
$user_platform_id
;
$banner_item
->
type
=
$type
;
$banner_item
->
save
();
$banner_item
->
save
();
return
[
'code'
=>
0
,
'msg'
=>
'banner添加成功'
];
return
[
'code'
=>
0
,
'msg'
=>
'banner添加成功'
];
}
else
{
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'banner添加加失败'
];
return
[
'code'
=>
1
,
'msg'
=>
'banner添加加失败'
];
}
}
}
}
}
}
...
@@ -35,16 +37,16 @@ class CoinPlatformBannerController extends BaseController
...
@@ -35,16 +37,16 @@ class CoinPlatformBannerController extends BaseController
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
$request
=
Yii
::
$app
->
request
;
$request
=
Yii
::
$app
->
request
;
$id
=
$request
->
get
(
'id'
,
''
);
$id
=
$request
->
get
(
'id'
,
''
);
if
(
$id
)
{
if
(
$id
)
{
$banner
=
CoinPlatformBanner
::
getBanner
(
$id
);
$banner
=
CoinPlatformBanner
::
getBanner
(
$id
);
if
(
!
$banner
)
{
if
(
!
$banner
)
{
return
[
'code'
=>
1
,
'msg'
=>
'banner不存在,不能删除'
];
return
[
'code'
=>
1
,
'msg'
=>
'banner不存在,不能删除'
];
}
}
$banner
->
delete
();
$banner
->
delete
();
return
[
'code'
=>
0
,
'msg'
=>
'banner删除成功'
];
return
[
'code'
=>
0
,
'msg'
=>
'banner删除成功'
];
}
else
{
}
else
{
return
[
'code'
=>
1
,
'msg'
=>
'banner删除失败'
];
return
[
'code'
=>
1
,
'msg'
=>
'banner删除失败'
];
}
}
}
}
}
}
...
@@ -55,19 +57,19 @@ class CoinPlatformBannerController extends BaseController
...
@@ -55,19 +57,19 @@ class CoinPlatformBannerController extends BaseController
public
function
actionIndex
()
public
function
actionIndex
()
{
{
$user_platform_id
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
$user_platform_id
=
Yii
::
$app
->
user
->
identity
->
platform_id
;
if
(
Yii
::
$app
->
request
->
isAjax
)
{
if
(
Yii
::
$app
->
request
->
isAjax
)
{
Yii
::
$app
->
response
->
format
=
'json'
;
Yii
::
$app
->
response
->
format
=
'json'
;
$condition
=
[];
$condition
=
[];
if
(
1
!==
$user_platform_id
)
{
if
(
1
!==
$user_platform_id
)
{
$condition
=
[
'platform_id'
=>
$user_platform_id
];
$condition
=
[
'platform_id'
=>
$user_platform_id
];
}
}
$data
=
CoinPlatformBanner
::
getItems
(
$condition
);
$data
=
CoinPlatformBanner
::
getItems
(
$condition
);
foreach
(
$data
as
$key
=>
&
$val
){
foreach
(
$data
as
$key
=>
&
$val
)
{
$val
[
'coin_name'
]
=
isset
(
$val
[
'platform'
][
'name'
])
?
$val
[
'platform'
][
'name'
]
:
''
;
$val
[
'coin_name'
]
=
isset
(
$val
[
'platform'
][
'name'
])
?
$val
[
'platform'
][
'name'
]
:
''
;
}
}
return
[
'data'
=>
$data
,
'code'
=>
0
];
return
[
'data'
=>
$data
,
'code'
=>
0
];
}
}
return
$this
->
render
(
'index'
);
return
$this
->
render
(
'index'
);
}
}
}
}
\ No newline at end of file
backend/views/coin-platform-banner/index.php
View file @
339e6ff5
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<div
class=
"layui-col-md9"
>
<div
class=
"layui-col-md9"
>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
<table
class=
"layui-table"
id=
"table1"
lay-filter=
"table1"
></table>
</div>
</div>
<div
class=
"layui-row add"
style=
"display: none;padding: 5px;"
id=
"_form"
>
<div
class=
"layui-row add"
style=
"display: none;padding: 5
0
px;"
id=
"_form"
>
<div
class=
"layui-col-xs6 layui-col-sm6 layui-col-md11"
>
<div
class=
"layui-col-xs6 layui-col-sm6 layui-col-md11"
>
<form
class=
"layui-form"
action=
"javascript:void(0)"
id=
"form1"
method=
"post"
lay-filter=
"form1"
>
<form
class=
"layui-form"
action=
"javascript:void(0)"
id=
"form1"
method=
"post"
lay-filter=
"form1"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
<input
type=
"hidden"
name=
"_csrf"
value=
"
<?=
Yii
::
$app
->
request
->
getCsrfToken
()
?>
"
>
...
@@ -31,6 +31,15 @@
...
@@ -31,6 +31,15 @@
</button>
</button>
</div>
</div>
</div>
</div>
<div
class=
"layui-form-item"
>
<label
class=
"layui-form-label"
>
图片类型
</label>
<div
class=
"layui-input-block"
>
<select
name=
"banner_type"
>
<option
value=
"1"
>
banner
</option>
<option
value=
"2"
>
海报
</option>
</select>
</div>
</div>
</form>
</form>
</div>
</div>
</div>
</div>
...
@@ -54,7 +63,7 @@
...
@@ -54,7 +63,7 @@
},
},
{
{
field
:
'image_url'
,
field
:
'image_url'
,
title
:
'图片
跳转
地址'
,
title
:
'图片地址'
,
width
:
600
width
:
600
},
},
{
{
...
@@ -87,7 +96,7 @@
...
@@ -87,7 +96,7 @@
$
(
'#add'
).
click
(
function
()
{
$
(
'#add'
).
click
(
function
()
{
var
index
=
layer
.
open
({
var
index
=
layer
.
open
({
title
:
'添加banner'
,
title
:
'添加banner'
,
area
:
'
80
0px'
,
area
:
'
75
0px'
,
type
:
1
,
type
:
1
,
content
:
$
(
"#_form"
),
content
:
$
(
"#_form"
),
btn
:
[
'保存'
,
'取消'
],
btn
:
[
'保存'
,
'取消'
],
...
...
common/business/ExchangeBusiness.php
View file @
339e6ff5
...
@@ -42,7 +42,8 @@ class ExchangeBusiness
...
@@ -42,7 +42,8 @@ class ExchangeBusiness
13
=>
'Ex'
,
13
=>
'Ex'
,
14
=>
'Zt'
,
14
=>
'Zt'
,
15
=>
'Tsc'
,
15
=>
'Tsc'
,
16
=>
'Binance'
16
=>
'Binance'
,
17
=>
'Ceohk'
];
];
/**
/**
...
@@ -85,7 +86,7 @@ class ExchangeBusiness
...
@@ -85,7 +86,7 @@ class ExchangeBusiness
goto
doEnd
;
goto
doEnd
;
}
}
if
(
strtoupper
(
$tag
)
==
'RYH'
||
strtoupper
(
$tag
)
==
'WL'
||
strtoupper
(
$tag
)
==
'ETS'
||
strtoupper
(
$tag
)
==
'LIMS'
||
strtoupper
(
$tag
)
==
'AT'
||
strtoupper
(
$tag
)
==
'BTJ'
)
{
if
(
strtoupper
(
$tag
)
==
'RYH'
||
strtoupper
(
$tag
)
==
'
CNDT'
||
strtoupper
(
$tag
)
==
'
WL'
||
strtoupper
(
$tag
)
==
'ETS'
||
strtoupper
(
$tag
)
==
'LIMS'
||
strtoupper
(
$tag
)
==
'AT'
||
strtoupper
(
$tag
)
==
'BTJ'
)
{
$quotation
=
[
$quotation
=
[
'low'
=>
0
,
'low'
=>
0
,
'high'
=>
0
,
'high'
=>
0
,
...
@@ -173,6 +174,13 @@ class ExchangeBusiness
...
@@ -173,6 +174,13 @@ class ExchangeBusiness
goto
doEnd
;
goto
doEnd
;
}
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'TIX'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Ceohk"
);
$quotation
=
$exchange
->
getTicker
(
'TIX'
,
'QC'
);
$quotation
[
'rmb'
]
=
$quotation
[
'last'
];
goto
doEnd
;
}
if
(
in_array
(
strtoupper
(
$tag
),
[
'SJPY'
]))
{
if
(
in_array
(
strtoupper
(
$tag
),
[
'SJPY'
]))
{
$exchange
=
ExchangeFactory
::
createExchange
(
"Boc"
);
$exchange
=
ExchangeFactory
::
createExchange
(
"Boc"
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'JPY'
);
$quotation
=
$exchange
->
getTicker
(
'CNY'
,
'JPY'
);
...
...
common/helpers/Curl.php
View file @
339e6ff5
This diff is collapsed.
Click to expand it.
common/models/psources/CoinCrossChain.php
0 → 100644
View file @
339e6ff5
<?php
namespace
common\models\psources
;
use
Yii
;
use
common\core\BaseActiveRecord
;
class
CoinCrossChain
extends
BaseActiveRecord
{
const
WITHDRAW
=
0
;
const
RECHARGE
=
1
;
const
CROSS_CHAIN_TRANSFERING
=
'cross_chain_transfering'
;
const
CROSS_CHAIN_CACHE_FAIL
=
'cross_chain_fail'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%coin_cross_chain_transfer}}'
;
}
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
public
function
rules
()
{
return
[
[[
'is_with_draw'
,
'address'
,
'txhex'
,
'transfer_url'
],
'required'
],
[[
'transfer_number'
,
'amount'
,
'step'
,
'send_result'
,
'query_result'
,
'msg'
],
'safe'
]
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'is_with_draw'
,
'address'
,
'txhex'
,
'transfer_url'
,
'transfer_number'
,
'amount'
,
'step'
,
'send_result'
,
'query_result'
,
'msg'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
}
common/service/chain33/Chain33Service.php
View file @
339e6ff5
...
@@ -20,7 +20,7 @@ class Chain33Service
...
@@ -20,7 +20,7 @@ class Chain33Service
public
function
__construct
(
$parameter
=
[])
public
function
__construct
(
$parameter
=
[])
{
{
if
(
empty
(
$parameter
))
{
if
(
empty
(
$parameter
))
{
$this
->
node_params
=
Yii
::
$app
->
params
[
'chain33'
];
$this
->
node_params
=
Yii
::
$app
->
params
[
'chain33'
];
}
else
{
}
else
{
$this
->
node_params
=
$parameter
;
$this
->
node_params
=
$parameter
;
...
@@ -31,8 +31,8 @@ class Chain33Service
...
@@ -31,8 +31,8 @@ class Chain33Service
{
{
$config
=
$this
->
node_params
;
$config
=
$this
->
node_params
;
$scheme
=
$config
[
'scheme'
]
??
'http'
;
$scheme
=
$config
[
'scheme'
]
??
'http'
;
$host
=
$config
[
'host'
]
??
'127.0.0.1'
;
$host
=
$config
[
'host'
]
??
'127.0.0.1'
;
$port
=
(
string
)
$config
[
'port'
]
??
''
;
$port
=
(
string
)
$config
[
'port'
]
??
''
;
if
(
$port
)
{
if
(
$port
)
{
return
$scheme
.
'://'
.
$host
.
':'
.
$port
;
return
$scheme
.
'://'
.
$host
.
':'
.
$port
;
}
else
{
}
else
{
...
@@ -44,9 +44,9 @@ class Chain33Service
...
@@ -44,9 +44,9 @@ class Chain33Service
{
{
$data
=
[
$data
=
[
'jsonrpc'
=>
'2.0'
,
'jsonrpc'
=>
'2.0'
,
'id'
=>
0
,
'id'
=>
0
,
'method'
=>
$method
,
'method'
=>
$method
,
'params'
=>
[],
'params'
=>
[],
];
];
if
(
!
empty
(
$params
))
{
if
(
!
empty
(
$params
))
{
$data
[
'params'
][]
=
$params
;
$data
[
'params'
][]
=
$params
;
...
@@ -56,7 +56,11 @@ class Chain33Service
...
@@ -56,7 +56,11 @@ class Chain33Service
public
function
send
(
$params
=
[],
$method
=
'Chain33.Query'
)
public
function
send
(
$params
=
[],
$method
=
'Chain33.Query'
)
{
{
$ch
=
new
Curl
();
$timeout
=
[
'connect_timeout'
=>
50000
,
'timeout_ms'
=>
40000
];
$ch
=
new
Curl
(
$timeout
);
$jsonrpc
=
self
::
jsonRpcBuild
(
$params
,
$method
);
$jsonrpc
=
self
::
jsonRpcBuild
(
$params
,
$method
);
$ch
->
setHeader
(
'Content-Type'
,
'application/json'
);
$ch
->
setHeader
(
'Content-Type'
,
'application/json'
);
$ch
->
setRawPostData
(
$jsonrpc
);
$ch
->
setRawPostData
(
$jsonrpc
);
...
@@ -124,7 +128,7 @@ class Chain33Service
...
@@ -124,7 +128,7 @@ class Chain33Service
* 获取地址下的所有token资产
* 获取地址下的所有token资产
*
*
* @param string|array $address
* @param string|array $address
* @param string
$symbol
* @param string $symbol
* @return array
* @return array
*/
*/
public
function
getAccountTokenAssets
(
$address
,
$symbol
)
public
function
getAccountTokenAssets
(
$address
,
$symbol
)
...
@@ -133,8 +137,8 @@ class Chain33Service
...
@@ -133,8 +137,8 @@ class Chain33Service
$address
=
[
$address
];
$address
=
[
$address
];
}
}
$params
=
[
$params
=
[
"addresses"
=>
$address
,
"addresses"
=>
$address
,
"execer"
=>
"user.p.guodun.token"
,
"execer"
=>
"user.p.guodun.token"
,
"tokenSymbol"
=>
$symbol
"tokenSymbol"
=>
$symbol
];
];
return
$this
->
send
(
$params
,
'token.GetTokenBalance'
);
return
$this
->
send
(
$params
,
'token.GetTokenBalance'
);
...
@@ -147,18 +151,18 @@ class Chain33Service
...
@@ -147,18 +151,18 @@ class Chain33Service
* @param $to
* @param $to
* @param $amount
* @param $amount
* @param string $note
* @param string $note
* @param bool
$isToken
* @param bool $isToken
* @param string $tokenSymbol
* @param string $tokenSymbol
* @return array
* @return array
*/
*/
public
function
extractToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
public
function
extractToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
{
{
$params
=
[
$params
=
[
"from"
=>
$to
,
"from"
=>
$to
,
"to"
=>
$from
,
"to"
=>
$from
,
"amount"
=>
-
$amount
,
"amount"
=>
-
$amount
,
"note"
=>
$note
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"isToken"
=>
$isToken
?
true
:
false
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
];
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
...
@@ -171,18 +175,18 @@ class Chain33Service
...
@@ -171,18 +175,18 @@ class Chain33Service
* @param $to
* @param $to
* @param $amount
* @param $amount
* @param string $note
* @param string $note
* @param bool
$isToken
* @param bool $isToken
* @param string $tokenSymbol
* @param string $tokenSymbol
* @return array
* @return array
*/
*/
public
function
transToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
public
function
transToken
(
$from
,
$to
,
$amount
,
$note
=
''
,
$isToken
=
true
,
$tokenSymbol
=
''
)
{
{
$params
=
[
$params
=
[
"from"
=>
$from
,
"from"
=>
$from
,
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"note"
=>
$note
,
"note"
=>
$note
,
"isToken"
=>
$isToken
?
true
:
false
,
"isToken"
=>
$isToken
?
true
:
false
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
];
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
return
$this
->
send
(
$params
,
'Chain33.SendToAddress'
);
...
@@ -191,25 +195,25 @@ class Chain33Service
...
@@ -191,25 +195,25 @@ class Chain33Service
public
function
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
)
public
function
createTokenRawTransaction
(
$to
,
$amount
,
$isToken
,
$tokenSymbol
,
$fee
,
$note
,
$execer
)
{
{
$params
=
[
$params
=
[
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"isToken"
=>
$isToken
,
"isToken"
=>
$isToken
,
"tokenSymbol"
=>
$tokenSymbol
,
"tokenSymbol"
=>
$tokenSymbol
,
"fee"
=>
$fee
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"note"
=>
$note
,
"execer"
=>
$execer
,
"execer"
=>
$execer
,
];
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
}
}
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
public
function
createRawTransaction
(
$to
,
$amount
,
$fee
,
$note
,
$execer
)
{
{
$params
=
[
$params
=
[
"to"
=>
$to
,
"to"
=>
$to
,
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"fee"
=>
$fee
,
"fee"
=>
$fee
,
"note"
=>
$note
,
"note"
=>
$note
,
"execer"
=>
$execer
,
"execer"
=>
$execer
,
];
];
...
@@ -234,6 +238,14 @@ class Chain33Service
...
@@ -234,6 +238,14 @@ class Chain33Service
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
}
}
public
function
QueryTransaction
(
$data
)
{
$params
=
[
'hash'
=>
$data
];
return
$this
->
send
(
$params
,
'Chain33.QueryTransaction'
);
}
public
function
getBalance
(
$address
,
$execer
)
public
function
getBalance
(
$address
,
$execer
)
{
{
$params
=
[
$params
=
[
...
@@ -266,11 +278,11 @@ class Chain33Service
...
@@ -266,11 +278,11 @@ class Chain33Service
public
function
structureTrade
(
$amount
,
$execName
,
$fee
,
$isToken
=
True
,
$to
,
$tokenSymbol
=
''
)
public
function
structureTrade
(
$amount
,
$execName
,
$fee
,
$isToken
=
True
,
$to
,
$tokenSymbol
=
''
)
{
{
$params
=
[
$params
=
[
"amount"
=>
$amount
,
"amount"
=>
$amount
,
"execName"
=>
$execName
,
"execName"
=>
$execName
,
"fee"
=>
$fee
,
"fee"
=>
$fee
,
"isToken"
=>
$isToken
?
true
:
false
,
"isToken"
=>
$isToken
?
true
:
false
,
"to"
=>
$to
,
"to"
=>
$to
,
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
"tokenSymbol"
=>
strtoupper
(
$tokenSymbol
)
];
];
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
return
$this
->
send
(
$params
,
'Chain33.CreateRawTransaction'
);
...
@@ -279,9 +291,9 @@ class Chain33Service
...
@@ -279,9 +291,9 @@ class Chain33Service
public
function
signTrade
(
$addr
,
$expire
=
'2h'
,
$txHex
)
public
function
signTrade
(
$addr
,
$expire
=
'2h'
,
$txHex
)
{
{
$params
=
[
$params
=
[
"addr"
=>
$addr
,
"addr"
=>
$addr
,
"expire"
=>
$expire
,
"expire"
=>
$expire
,
"txHex"
=>
$txHex
"txHex"
=>
$txHex
];
];
return
$this
->
send
(
$params
,
'Chain33.SignRawTx'
);
return
$this
->
send
(
$params
,
'Chain33.SignRawTx'
);
}
}
...
@@ -289,11 +301,19 @@ class Chain33Service
...
@@ -289,11 +301,19 @@ class Chain33Service
public
function
sendTrade
(
$data
)
public
function
sendTrade
(
$data
)
{
{
$params
=
[
$params
=
[
"data"
=>
$data
,
"data"
=>
$data
,
];
];
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
return
$this
->
send
(
$params
,
'Chain33.SendTransaction'
);
}
}
public
function
getHeight
(
$params
=
[])
{
$params
=
[
"data"
=>
'user.p.game.'
,
];
return
$this
->
send
(
$params
,
'paracross.GetHeight'
);
}
/**
/**
* 获取最新的区块
* 获取最新的区块
*/
*/
...
@@ -321,12 +341,12 @@ class Chain33Service
...
@@ -321,12 +341,12 @@ class Chain33Service
public
function
getTxByAddr
(
$addr
,
$flag
,
$count
,
$direction
,
$height
,
$index
)
public
function
getTxByAddr
(
$addr
,
$flag
,
$count
,
$direction
,
$height
,
$index
)
{
{
$params
=
[
$params
=
[
'addr'
=>
$addr
,
'addr'
=>
$addr
,
'flag'
=>
$flag
,
'flag'
=>
$flag
,
'count'
=>
$count
,
'count'
=>
$count
,
'direction'
=>
$direction
,
'direction'
=>
$direction
,
'height'
=>
$height
,
'height'
=>
$height
,
'index'
=>
$index
'index'
=>
$index
];
];
return
$this
->
send
(
$params
,
'Chain33.GetTxByAddr'
);
return
$this
->
send
(
$params
,
'Chain33.GetTxByAddr'
);
}
}
...
@@ -351,9 +371,9 @@ class Chain33Service
...
@@ -351,9 +371,9 @@ class Chain33Service
public
function
unLockWallet
(
$password
)
public
function
unLockWallet
(
$password
)
{
{
$params
=
[
$params
=
[
'passwd'
=>
$password
,
'passwd'
=>
$password
,
'walletorticket'
=>
false
,
'walletorticket'
=>
false
,
'timeout'
=>
30
'timeout'
=>
30
];
];
return
$this
->
send
(
$params
,
'Chain33.UnLock'
);
return
$this
->
send
(
$params
,
'Chain33.UnLock'
);
}
}
...
...
common/service/exchange/Ceohk.php
0 → 100644
View file @
339e6ff5
<?php
namespace
common\service\exchange
;
use
linslin\yii2\curl\Curl
;
class
Ceohk
extends
Exchange
implements
ExchangeInterface
{
protected
$supported_symbol
=
'supported_symbol_ceohk'
;
protected
$quotation_prefix
=
'quotation_ceohk_'
;
protected
$base_url
=
'https://ceohk.bi/api/market/ticker?market=tix_qc'
;
public
function
symbolExists
(
$tag
=
'TIX'
,
$aim
=
"QC"
)
{
$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
=
'TIX'
,
$aim
=
'QC'
)
{
return
strtoupper
(
$tag
.
'_'
.
$aim
);
}
/**
* 保存支持的交易对到redis数据库,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setSupportedSymbol
()
{
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'TIX_QC'
);
}
/**
* 更新交易对行情保存到redis,使用crontab定时更新
*
* @return mixed|void
*/
public
function
setQuotation
()
{
$curl
=
new
Curl
();
$content
=
$curl
->
get
(
$this
->
base_url
,
false
);
if
(
is_array
(
$content
)
&&
isset
(
$content
[
'data'
]))
{
$data
=
$content
[
'data'
];
$key
=
$this
->
quotation_prefix
.
'TIX_QC'
;
$this
->
redis
->
hmset
(
$key
,
'low'
,
$data
[
'low'
],
'high'
,
$data
[
'high'
],
'last'
,
$data
[
'last'
]);
$this
->
redis
->
sadd
(
$this
->
supported_symbol
,
'TIX_QC'
);
}
}
}
\ No newline at end of file
console/controllers/CrossChainController.php
0 → 100644
View file @
339e6ff5
<?php
namespace
console\controllers
;
use
common\models\psources\CoinCrossChain
;
use
Yii
;
use
yii\console\Controller
;
use
common\service\chain33\Chain33Service
;
class
CrossChainController
extends
Controller
{
/**
* 自动交易
*
* @return array
*/
public
function
actionAutoTransfer
(
$step
,
$is_with_draw
)
{
$redis
=
Yii
::
$app
->
redis
;
$model
=
CoinCrossChain
::
find
()
->
where
([
'send_result'
=>
"0"
,
'step'
=>
(
int
)
$step
,
'is_with_draw'
=>
(
int
)
$is_with_draw
])
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'暂无跨链交易计划'
.
PHP_EOL
;
return
0
;
}
$current_time
=
time
();
foreach
(
$model
as
$val
)
{
if
(
$step
>
1
)
{
$isExist
=
CoinCrossChain
::
find
()
->
where
([
'transfer_number'
=>
$val
[
'transfer_number'
]])
->
andWhere
([
'<'
,
'id'
,
(
int
)
$val
[
'id'
]])
->
orderBy
(
'id desc'
)
->
asArray
()
->
one
();
//上一步发送成功,未查询
if
(
'success'
!=
$isExist
[
'query_result'
]
&&
!
empty
(
$isExist
))
{
continue
;
}
}
$cache_transfering_time
=
$redis
->
hget
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]
.
':'
.
$val
[
'id'
]);
if
(
true
==
$cache_transfering_time
)
{
continue
;
}
$redis
->
hmset
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]
.
':'
.
$val
[
'id'
],
$current_time
);
go
(
function
()
use
(
$val
,
$redis
)
{
\Co
::
sleep
(
0.5
);
$transfer_url
=
$val
[
'transfer_url'
];
$transfer_url
=
explode
(
':'
,
$transfer_url
);
$node_params
=
[
'scheme'
=>
$transfer_url
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$transfer_url
[
1
]),
'port'
=>
isset
(
$transfer_url
[
2
])
?
$transfer_url
[
2
]
:
''
,
];
$service
=
new
Chain33Service
(
$node_params
);
$sign_str
=
$val
[
'txhex'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
==
$result
[
'code'
])
{
$send_result
=
$result
[
'result'
];
$currentModel
=
CoinCrossChain
::
findOne
(
$val
[
'id'
]);
$currentModel
->
send_result
=
$send_result
;
$currentModel
->
msg
=
0
;
$currentModel
->
save
();
$redis
->
hdel
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]
.
':'
.
$val
[
'id'
]);
}
if
(
0
!=
$result
[
'code'
]
&&
(
false
==
strstr
(
$result
[
'msg'
],
'ErrDupTx'
)))
{
$redis
->
hdel
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]
.
':'
.
$val
[
'id'
]);
}
});
}
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'跨链交易成功'
.
PHP_EOL
;
return
0
;
}
public
function
actionQueryTransaction
()
{
$redis
=
Yii
::
$app
->
redis
;
$model
=
CoinCrossChain
::
find
()
->
where
([
'<>'
,
'send_result'
,
'0'
])
->
andWhere
([
'msg'
=>
'0'
])
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无跨链交易计划'
.
PHP_EOL
;
return
0
;
}
//查询共识高度
$node_params
=
[
'scheme'
=>
'https'
,
'host'
=>
'jiedian1.bityuan.com'
,
'port'
=>
8801
];
$service
=
new
Chain33Service
(
$node_params
);
$result
=
$service
->
getHeight
();
$consensHeight
=
$result
[
'result'
][
'consensHeight'
];
$current_time
=
time
();
foreach
(
$model
as
$val
)
{
$node_params
=
$val
[
'transfer_url'
];
$node_params
=
explode
(
':'
,
$node_params
);
$node_params
=
[
'scheme'
=>
$node_params
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$node_params
[
1
]),
'port'
=>
isset
(
$node_params
[
2
])
?
$node_params
[
2
]
:
''
];
$service
=
new
Chain33Service
(
$node_params
);
$send_result
=
$val
[
'send_result'
];
$result
=
$service
->
QueryTransaction
(
$send_result
);
$switch
=
true
;
if
(
isset
(
$result
[
'result'
][
'actionName'
])
&&
'unknown'
==
$result
[
'result'
][
'actionName'
])
{
$redis
->
hdel
(
CoinCrossChain
::
CROSS_CHAIN_CACHE_FAIL
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]);
$query_result
=
'success'
;
$msg
=
'success'
;
$height
=
isset
(
$result
[
'result'
][
'height'
])
?
$result
[
'result'
][
'height'
]
:
0
;
goto
doEnd
;
}
else
if
(
isset
(
$result
[
'result'
][
'receipt'
][
'ty'
])
&&
2
==
$result
[
'result'
][
'receipt'
][
'ty'
])
{
$redis
->
hdel
(
CoinCrossChain
::
CROSS_CHAIN_CACHE_FAIL
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]);
$query_result
=
'success'
;
$msg
=
'success'
;
$height
=
isset
(
$result
[
'result'
][
'height'
])
?
$result
[
'result'
][
'height'
]
:
0
;
goto
doEnd
;
}
else
{
$cache_error_time
=
$redis
->
hget
(
CoinCrossChain
::
CROSS_CHAIN_CACHE_FAIL
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]);
if
(
false
==
$cache_error_time
)
{
$redis
->
hmset
(
CoinCrossChain
::
CROSS_CHAIN_CACHE_FAIL
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
],
$current_time
);
continue
;
}
if
((
$current_time
-
$cache_error_time
)
<
60
)
{
continue
;
}
$redis
->
hdel
(
CoinCrossChain
::
CROSS_CHAIN_CACHE_FAIL
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]);
if
(
-
1
==
$result
[
'code'
])
{
$msg
=
$result
[
'msg'
];
$query_result
=
$result
[
'code'
];
$switch
=
false
;
goto
doEnd
;
}
else
{
$query_result
=
'fail'
;
foreach
(
$result
[
'result'
][
'receipt'
][
'logs'
]
as
$log
)
{
if
(
is_array
(
$log
[
'log'
]))
continue
;
$msg
=
isset
(
$log
[
'log'
])
?
$log
[
'log'
]
:
'查询错误'
;
}
$switch
=
false
;
goto
doEnd
;
}
}
doEnd
:
if
(
CoinCrossChain
::
RECHARGE
==
$val
[
'is_with_draw'
]
&&
$val
[
'step'
]
==
2
&&
$switch
&&
isset
(
$height
)
&&
(
$consensHeight
<
$height
))
{
continue
;
}
$currentModel
=
CoinCrossChain
::
findOne
(
$val
[
'id'
]);
$currentModel
->
query_result
=
$query_result
;
$currentModel
->
msg
=
$msg
;
$currentModel
->
save
();
$count
=
CoinCrossChain
::
find
()
->
where
([
'transfer_number'
=>
$val
[
'transfer_number'
]])
->
andWhere
([
'query_result'
=>
'success'
])
->
count
();
if
(
3
==
$count
)
{
$key
=
$val
[
'address'
]
.
'_'
.
$val
[
'is_with_draw'
];
if
(
$redis
->
exists
(
$key
))
{
$redis
->
del
(
$key
);
}
}
}
echo
date
(
'Y-m-d H:i:s'
)
.
'查询完毕'
.
PHP_EOL
;
return
0
;
}
}
\ No newline at end of file
console/controllers/GameBetController.php
View file @
339e6ff5
...
@@ -37,6 +37,7 @@ class GameBetController extends Controller
...
@@ -37,6 +37,7 @@ class GameBetController extends Controller
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$resultJSON
=
json_decode
(
$queryResultItems
[
'queryResultItems'
][
0
][
'resultJSON'
],
true
);
$current_round
=
$resultJSON
[
'current_round'
];
$current_round
=
$resultJSON
[
'current_round'
];
$current_height
=
$resultJSON
[
'height'
];
$cache_current_round
=
Yii
::
$app
->
redis
->
get
(
'chain33_game_bet_status_'
.
$key
);
$cache_current_round
=
Yii
::
$app
->
redis
->
get
(
'chain33_game_bet_status_'
.
$key
);
if
(
empty
(
$cache_current_round
))
{
if
(
empty
(
$cache_current_round
))
{
$cache_current_round
=
CoinGameBet
::
find
()
->
where
([
'platform'
=>
$key
])
->
max
(
'round'
);
$cache_current_round
=
CoinGameBet
::
find
()
->
where
([
'platform'
=>
$key
])
->
max
(
'round'
);
...
@@ -48,7 +49,7 @@ class GameBetController extends Controller
...
@@ -48,7 +49,7 @@ class GameBetController extends Controller
continue
;
continue
;
}
}
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status_'
.
$key
,
$current_round
,
'EX'
,
300
);
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status_'
.
$key
,
$current_round
,
'EX'
,
300
);
Yii
::
$app
->
redis
->
set
(
'chain33_game_bet_status_height_'
.
$key
,
$current_height
,
'EX'
,
300
);
$result
=
$service
->
getBetStatus
(
$cache_current_round
,
$current_round
,
''
,
$node
);
$result
=
$service
->
getBetStatus
(
$cache_current_round
,
$current_round
,
''
,
$node
);
if
(
0
!==
$result
[
'code'
])
{
if
(
0
!==
$result
[
'code'
])
{
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
echo
$key
.
':'
.
date
(
'Y-m-d H:i:s'
)
.
'数据错误'
.
PHP_EOL
;
...
@@ -132,4 +133,5 @@ class GameBetController extends Controller
...
@@ -132,4 +133,5 @@ class GameBetController extends Controller
}
}
return
0
;
return
0
;
}
}
}
}
\ No newline at end of file
shell/GameBet.sh
deleted
100644 → 0
View file @
b35924a8
#!/bin/bash
while
true
;
do
php /var/www/html/token_pwallet/yii game-bet/game-status
>>
/var/log/game-bet.log 2>&1
;
sleep
5
;
done
&
\ 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