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
a3cbf302
Commit
a3cbf302
authored
Jan 15, 2019
by
ZhuChunYang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
85290268
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
0 deletions
+178
-0
CoinReleaseCheck.php
common/models/psources/CoinReleaseCheck.php
+3
-0
ReleaseCheckController.php
console/controllers/ReleaseCheckController.php
+175
-0
No files found.
common/models/psources/CoinReleaseCheck.php
View file @
a3cbf302
...
@@ -50,6 +50,9 @@ class CoinReleaseCheck extends BaseActiveRecord
...
@@ -50,6 +50,9 @@ class CoinReleaseCheck extends BaseActiveRecord
const
STATUS_CANCEL
=
2
;
// 提币申请被撤提
const
STATUS_CANCEL
=
2
;
// 提币申请被撤提
const
STATUS_FAILD
=
3
;
// 提币失败
const
STATUS_FAILD
=
3
;
// 提币失败
const
STATUS_SUCCEED
=
4
;
// 提币成功
const
STATUS_SUCCEED
=
4
;
// 提币成功
const
STATUS_AUTO_CHECKING
=
5
;
//自动审核中
const
STATUS_AUTO_FAILD
=
6
;
//自动审核失败
const
STATUS_AUTO_EXCEPTION
=
7
;
//自动审核异常(区块链异常)
public
$start_time
=
''
;
public
$start_time
=
''
;
public
$end_time
=
''
;
public
$end_time
=
''
;
...
...
console/controllers/ReleaseCheckController.php
0 → 100644
View file @
a3cbf302
<?php
/**
* Created by PhpStorm.
* User: ZCY
* Date: 2019/1/15
* Time: 10:35
*/
namespace
console\controllers
;
use
common\business\Chain33Business
;
use
common\models\psources\CoinPublish
;
use
common\models\psources\CoinPublishRule
;
use
common\models\psources\CoinReleaseCheck
;
use
common\models\psources\CoinReleaseList
;
use
common\models\psources\CoinReleaseMember
;
use
yii\console\Controller
;
use
Yii
;
class
ReleaseCheckController
extends
Controller
{
//自动审核
public
function
actionCheck
()
{
$coin_release_checkItems
=
$this
->
getAutoCheckList
();
if
(
!
$coin_release_checkItems
){
echo
date
(
'Y-m-d H:i:s'
)
.
':has no need auto check items'
.
PHP_EOL
;
exit
;
}
foreach
(
$coin_release_checkItems
as
$coin_release_check
){
$from
=
''
;
$member
=
CoinReleaseMember
::
findOne
(
$coin_release_check
->
mid
);
if
(
$member
)
{
$coin_publish_rule
=
CoinPublishRule
::
findOne
(
$member
->
rule_id
);
if
(
$coin_publish_rule
)
{
$coin_publish
=
CoinPublish
::
findOne
(
$coin_publish_rule
->
pid
);
if
(
$coin_publish
)
{
$from
=
$coin_publish
->
address
;
}
}
}
if
(
empty
(
$from
))
{
echo
date
(
'Y-m-d H:i:s'
)
.
':获取提币地址失败!'
.
PHP_EOL
;
$coin_release_check
->
memo
=
'获取提币地址失败'
;
$coin_release_check
->
status
=
CoinReleaseCheck
::
STATUS_AUTO_FAILD
;
//自动审核失败
$coin_release_check
->
save
();
exit
;
}
$auto_check_limit
=
$coin_publish
->
auto_check_limit
;
if
(
$auto_check_limit
*
1e8
<
$coin_release_check
->
amount
){
echo
date
(
'Y-m-d H:i:s'
)
.
':check_id['
.
$coin_release_check
->
id
.
'],coin['
.
$coin_release_check
->
coin
.
'],amount['
.
$coin_release_check
->
amount
/
1e8
.
']提币额度大于自动审核额度,不能自动审核'
.
PHP_EOL
;
exit
;
}
$res
=
CoinReleaseCheck
::
updateAll
([
'status'
=>
CoinReleaseCheck
::
STATUS_AUTO_CHECKING
],
'id=:id'
,
[
':id'
=>
$coin_release_check
->
id
]);
if
(
$res
){
//开启事务
$trans
=
CoinReleaseCheck
::
getDb
()
->
beginTransaction
();
$isBlockFalse
=
false
;
try
{
$coin_release_check
->
check_first_uid
=
1
;
$coin_release_check
->
check_first_status
=
2
;
$coin_release_check
->
check_second_uid
=
1
;
$coin_release_check
->
check_second_status
=
2
;
$coin_release_check
->
status
=
CoinReleaseCheck
::
STATUS_PADDING
;
//区块链转币
if
(
strtoupper
(
$coin_release_check
->
coin
)
==
'BTY'
)
{
$isToken
=
false
;
}
else
{
$isToken
=
true
;
}
$walletpasswd
=
Yii
::
$app
->
redis
->
get
(
'wallet_passwd'
);
Chain33Business
::
unLockWallet
(
$walletpasswd
);
$result
=
Chain33Business
::
transToken
(
trim
(
$from
),
trim
(
$coin_release_check
->
to_address
),
(
int
)
$coin_release_check
->
amount
,
"锁仓释放"
,
$isToken
,
$coin_release_check
->
coin
);
if
(
is_array
(
$result
))
{
$isBlockFalse
=
true
;
//区块链报错
throw
new
\Exception
(
$result
[
'msg'
]);
}
$coin_release_check
->
txhash
=
$result
;
$coin_release_check
->
memo
=
'自动审核成功!'
;
$coin_release_check
->
save
();
$trans
->
commit
();
echo
date
(
'Y-m-d H:i:s'
)
.
':check_id['
.
$coin_release_check
->
id
.
'],coin['
.
$coin_release_check
->
coin
.
'],amount['
.
$coin_release_check
->
amount
/
1e8
.
']提币成功'
.
PHP_EOL
;
}
catch
(
\Exception
$exception
)
{
$trans
->
rollBack
();
echo
date
(
'Y-m-d H:i:s'
)
.
':'
.
$exception
->
getMessage
()
.
PHP_EOL
;
if
(
$isBlockFalse
){
CoinReleaseCheck
::
updateAll
([
'status'
=>
CoinReleaseCheck
::
STATUS_AUTO_EXCEPTION
,
'memo'
=>
$exception
->
getMessage
()],
'id=:id'
,
[
':id'
=>
$coin_release_check
->
id
]);
}
else
{
CoinReleaseCheck
::
updateAll
([
'memo'
=>
$exception
->
getMessage
()],
'id=:id'
,
[
':id'
=>
$coin_release_check
->
id
]);
}
}
}
else
{
echo
date
(
'Y-m-d H:i:s'
)
.
':数据库异常,无法自动审核!'
.
PHP_EOL
;
}
}
}
private
function
getAutoCheckList
()
{
return
CoinReleaseCheck
::
find
()
->
where
([
'status'
=>
0
,
'check_first_status'
=>
1
])
->
all
();
}
public
function
actionConfirmHash
()
{
$coin_release_checkItems
=
$this
->
getConfirmList
();
if
(
!
$coin_release_checkItems
){
echo
date
(
'Y-m-d H:i:s'
)
.
':has no need confirm hash items'
.
PHP_EOL
;
exit
;
}
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
]);
if
(
$result
[
'code'
]
==
0
)
{
$result
=
$result
[
'result'
][
'txs'
][
0
][
'receipt'
][
'ty'
]
??
0
;
if
(
$result
==
1
)
{
//转账失败
echo
date
(
'Y-m-d H:i:s'
)
.
':check_id['
.
$coin_release_check
->
id
.
'],coin['
.
$coin_release_check
->
coin
.
'],amount['
.
$coin_release_check
->
amount
/
1e8
.
']转账失败'
.
PHP_EOL
;
$coin_release_list
->
status
=
2
;
$coin_release_check
->
status
=
3
;
$trans
=
CoinReleaseCheck
::
getDb
()
->
beginTransaction
();
try
{
if
(
$coin_release_check
->
save
()
&&
$coin_release_list
->
save
())
{
//退换资产
$coin_release_member
=
CoinReleaseMember
::
findOne
(
$coin_release_list
->
mid
);
if
(
$coin_release_member
)
{
$coin_release_member
->
release
+=
$coin_release_list
->
amount
;
$coin_release_member
->
output
-=
$coin_release_list
->
amount
;
if
(
$coin_release_member
->
save
())
{
$trans
->
commit
();
return
0
;
}
}
}
$trans
->
rollBack
();
}
catch
(
\Exception
$exception
)
{
echo
date
(
'Y-m-d H:i:s'
)
.
':'
.
$exception
->
getMessage
()
.
PHP_EOL
;
}
}
elseif
(
$result
==
2
)
{
//转账成功
echo
date
(
'Y-m-d H:i:s'
)
.
':check_id['
.
$coin_release_check
->
id
.
'],coin['
.
$coin_release_check
->
coin
.
'],amount['
.
$coin_release_check
->
amount
/
1e8
.
']转账成功'
.
PHP_EOL
;
$coin_release_list
->
status
=
1
;
$coin_release_check
->
status
=
4
;
$trans
=
CoinReleaseCheck
::
getDb
()
->
beginTransaction
();
try
{
if
(
$coin_release_check
->
save
()
&&
$coin_release_list
->
save
())
{
$trans
->
commit
();
}
$trans
->
rollBack
();
}
catch
(
\Exception
$exception
)
{
echo
date
(
'Y-m-d H:i:s'
)
.
':'
.
$exception
->
getMessage
()
.
PHP_EOL
;
}
}
}
}
}
}
private
function
getConfirmList
()
{
return
CoinReleaseCheck
::
find
()
->
where
([
'status'
=>
1
,
'check_first_status'
=>
2
])
->
all
();
}
}
\ 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