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
176cbc54
Commit
176cbc54
authored
Sep 09, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
筛选交易数据
parent
a735b982
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
CoinCrossChain.php
common/models/psources/CoinCrossChain.php
+1
-0
CrossChainController.php
console/controllers/CrossChainController.php
+19
-15
No files found.
common/models/psources/CoinCrossChain.php
View file @
176cbc54
...
@@ -10,6 +10,7 @@ class CoinCrossChain extends BaseActiveRecord
...
@@ -10,6 +10,7 @@ class CoinCrossChain extends BaseActiveRecord
const
WITHDRAW
=
0
;
const
WITHDRAW
=
0
;
const
RECHARGE
=
1
;
const
RECHARGE
=
1
;
const
CROSS_CHAIN_TRANSFERING
=
'cross_chain_transfering'
;
const
CROSS_CHAIN_CACHE_FAIL
=
'cross_chain_fail'
;
const
CROSS_CHAIN_CACHE_FAIL
=
'cross_chain_fail'
;
public
static
function
getDb
()
public
static
function
getDb
()
...
...
console/controllers/CrossChainController.php
View file @
176cbc54
...
@@ -16,11 +16,13 @@ class CrossChainController extends Controller
...
@@ -16,11 +16,13 @@ class CrossChainController extends Controller
*/
*/
public
function
actionAutoTransfer
(
$step
,
$is_with_draw
)
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
();
$model
=
CoinCrossChain
::
find
()
->
where
([
'send_result'
=>
"0"
,
'step'
=>
(
int
)
$step
,
'is_with_draw'
=>
(
int
)
$is_with_draw
])
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
if
(
empty
(
$model
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'暂无跨链交易计划'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'暂无跨链交易计划'
.
PHP_EOL
;
return
0
;
return
0
;
}
}
$current_time
=
time
();
foreach
(
$model
as
$val
)
{
foreach
(
$model
as
$val
)
{
if
(
$step
>
1
)
{
if
(
$step
>
1
)
{
$isExist
=
CoinCrossChain
::
find
()
$isExist
=
CoinCrossChain
::
find
()
...
@@ -34,8 +36,13 @@ class CrossChainController extends Controller
...
@@ -34,8 +36,13 @@ class CrossChainController extends Controller
continue
;
continue
;
}
}
}
}
$cache_transfering_time
=
$redis
->
hget
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]);
if
(
true
==
$cache_transfering_time
)
{
continue
;
}
$redis
->
hmset
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
],
$current_time
);
go
(
function
()
use
(
$val
)
{
go
(
function
()
use
(
$val
,
$redis
)
{
\Co
::
sleep
(
0.5
);
\Co
::
sleep
(
0.5
);
$transfer_url
=
$val
[
'transfer_url'
];
$transfer_url
=
$val
[
'transfer_url'
];
$transfer_url
=
explode
(
':'
,
$transfer_url
);
$transfer_url
=
explode
(
':'
,
$transfer_url
);
...
@@ -43,29 +50,26 @@ class CrossChainController extends Controller
...
@@ -43,29 +50,26 @@ class CrossChainController extends Controller
$node_params
=
[
$node_params
=
[
'scheme'
=>
$transfer_url
[
0
],
'scheme'
=>
$transfer_url
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$transfer_url
[
1
]),
'host'
=>
str_replace
(
'//'
,
''
,
$transfer_url
[
1
]),
'port'
=>
isset
(
$transfer_url
[
2
])
?
$transfer_url
[
2
]
:
''
'port'
=>
isset
(
$transfer_url
[
2
])
?
$transfer_url
[
2
]
:
''
,
'timeout'
=>
100
];
];
$service
=
new
Chain33Service
(
$node_params
);
$service
=
new
Chain33Service
(
$node_params
);
$sign_str
=
$val
[
'txhex'
];
$sign_str
=
$val
[
'txhex'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
!=
$result
[
'code'
])
{
if
(
0
==
$result
[
'code'
])
{
$msg
=
$result
[
'msg'
];
$send_result
=
$result
[
'result'
];
goto
doEnd
;
$currentModel
=
CoinCrossChain
::
findOne
(
$val
[
'id'
]);
}
$send_result
=
$result
[
'result'
];
doEnd
:
$currentModel
=
CoinCrossChain
::
findOne
(
$val
[
'id'
]);
if
(
isset
(
$msg
))
{
$currentModel
->
msg
=
$msg
;
}
if
(
isset
(
$send_result
))
{
$currentModel
->
send_result
=
$send_result
;
$currentModel
->
send_result
=
$send_result
;
$currentModel
->
msg
=
0
;
$currentModel
->
msg
=
0
;
$currentModel
->
save
();
$redis
->
hdel
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]);
}
if
(
0
!=
$result
&&
(
false
==
strstr
(
$result
[
'msg'
],
'ErrDupTx'
)))
{
$redis
->
hdel
(
CoinCrossChain
::
CROSS_CHAIN_TRANSFERING
,
$val
[
'address'
]
.
':'
.
$val
[
'is_with_draw'
]);
}
}
$currentModel
->
save
();
});
});
}
}
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'跨链交易成功'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
' STEP: '
.
$step
.
'跨链交易成功'
.
PHP_EOL
;
...
...
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