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
46373e98
Commit
46373e98
authored
Sep 07, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
3cecfa21
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
25 deletions
+22
-25
CoinCrossChain.php
common/models/psources/CoinCrossChain.php
+2
-0
CrossChainController.php
console/controllers/CrossChainController.php
+20
-13
AutoTransfer.sh
shell/AutoTransfer.sh
+0
-3
BetUpdate.sh
shell/BetUpdate.sh
+0
-3
GameStatus.sh
shell/GameStatus.sh
+0
-3
QueryTransaction.sh
shell/QueryTransaction.sh
+0
-3
No files found.
common/models/psources/CoinCrossChain.php
View file @
46373e98
...
...
@@ -10,6 +10,8 @@ class CoinCrossChain extends BaseActiveRecord
const
WITHDRAW
=
0
;
const
RECHARGE
=
1
;
const
CROSS_CHAIN_CACHE_FAIL
=
'cross_chain_fail'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
...
...
console/controllers/CrossChainController.php
View file @
46373e98
...
...
@@ -14,14 +14,15 @@ class CrossChainController extends Controller
*
* @return array
*/
public
function
actionAutoTransfer
()
public
function
actionAutoTransfer
(
$step
,
$is_with_draw
)
{
$model
=
CoinCrossChain
::
find
()
->
where
([
'send_result'
=>
"0"
])
->
limit
(
20
)
->
groupBy
(
'transfer_number'
)
->
orderBy
(
'id'
)
->
asArray
()
->
all
();
$model
=
CoinCrossChain
::
find
()
->
where
([
'send_result'
=>
"0"
,
'step'
=>
(
int
)
$step
,
'is_with_draw'
=>
(
int
)
$is_with_draw
])
->
limit
(
20
)
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无跨链交易计划'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'
STEP: '
.
$step
.
'
暂无跨链交易计划'
.
PHP_EOL
;
return
0
;
}
foreach
(
$model
as
$val
)
{
if
(
$step
>
1
)
{
$isExist
=
CoinCrossChain
::
find
()
->
where
([
'transfer_number'
=>
$val
[
'transfer_number'
]])
->
andWhere
([
'<'
,
'id'
,
(
int
)
$val
[
'id'
]])
...
...
@@ -32,9 +33,10 @@ class CrossChainController extends Controller
if
(
'success'
!=
$isExist
[
'query_result'
]
&&
!
empty
(
$isExist
))
{
continue
;
}
}
//
go(function () use ($val) {
//
\Co::sleep(0.5);
go
(
function
()
use
(
$val
)
{
\Co
::
sleep
(
0.5
);
$transfer_url
=
$val
[
'transfer_url'
];
$transfer_url
=
explode
(
':'
,
$transfer_url
);
...
...
@@ -63,22 +65,22 @@ class CrossChainController extends Controller
$currentModel
->
send_result
=
$send_result
;
}
$currentModel
->
save
();
//});
});
}
echo
date
(
'Y-m-d H:i:s'
)
.
'跨链交易成功'
.
PHP_EOL
;
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'
])
->
limit
(
20
)
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无跨链交易计划'
.
PHP_EOL
;
return
0
;
}
$current_time
=
time
();
foreach
(
$model
as
$val
)
{
$node_params
=
$val
[
'transfer_url'
];
$node_params
=
explode
(
':'
,
$node_params
);
...
...
@@ -91,12 +93,18 @@ class CrossChainController extends Controller
$send_result
=
$val
[
'send_result'
];
$result
=
$service
->
QueryTransaction
(
$send_result
);
if
(
-
1
==
$result
[
'code'
])
{
if
(
'tx not exist'
==
$result
[
'msg'
])
continue
;
$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
;
}
$msg
=
$result
[
'msg'
];
$query_result
=
$result
[
'code'
];
goto
doEnd
;
// echo date('Y-m-d H:i:s') . 'ID:' . $val['id'] . '查询错误' . PHP_EOL;
// continue;
}
if
(
isset
(
$result
[
'result'
][
'actionName'
])
&&
'unknown'
==
$result
[
'result'
][
'actionName'
])
{
...
...
@@ -121,7 +129,6 @@ class CrossChainController extends Controller
$count
=
CoinCrossChain
::
find
()
->
where
([
'transfer_number'
=>
$val
[
'transfer_number'
]])
->
andWhere
([
'query_result'
=>
'success'
])
->
count
();
if
(
3
==
$count
)
{
$redis
=
Yii
::
$app
->
redis
;
$key
=
$val
[
'address'
]
.
'_'
.
$val
[
'is_with_draw'
];
if
(
$redis
->
exists
(
$key
))
{
$redis
->
del
(
$key
);
...
...
shell/AutoTransfer.sh
deleted
100644 → 0
View file @
3cecfa21
#!/bin/bash
while
true
;
do
php /var/www/html/token_pwallet/yii cross-chain/auto-transfer
>>
/var/www/html/auto-transfer.log 2>&1
;
sleep
15
;
done
&
\ No newline at end of file
shell/BetUpdate.sh
deleted
100644 → 0
View file @
3cecfa21
#!/bin/bash
while
true
;
do
php /var/www/html/token_pwallet/yii game-bet/bet-update
>>
/var/log/bet-update.log 2>&1
;
sleep
2
;
done
&
\ No newline at end of file
shell/GameStatus.sh
deleted
100644 → 0
View file @
3cecfa21
#!/bin/bash
while
true
;
do
php /var/www/html/token_pwallet/yii game-bet/game-status
>>
/var/log/game-status.log 2>&1
;
sleep
5
;
done
&
\ No newline at end of file
shell/QueryTransaction.sh
deleted
100644 → 0
View file @
3cecfa21
#!/bin/bash
while
true
;
do
php /var/www/html/token_pwallet/yii cross-chain/query-transaction
>>
/var/www/html/query-transaction.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