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
9529ea23
Commit
9529ea23
authored
Mar 26, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
cf41cb88
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
17 deletions
+102
-17
AirDropController.php
api/controllers/AirDropController.php
+44
-17
AirDrop.php
common/models/psources/AirDrop.php
+58
-0
No files found.
api/controllers/AirDropController.php
View file @
9529ea23
...
...
@@ -3,6 +3,7 @@
namespace
api\controllers
;
use
api\base\BaseController
;
use
common\models\psources\AirDrop
;
use
common\models\psources\CoinAirDropTrade
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
...
...
@@ -10,16 +11,42 @@ use Yii;
class
AirDropController
extends
BaseController
{
public
function
actionApply
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
$data
=
Yii
::
$app
->
request
->
post
();
$model
=
new
AirDrop
();
$model
->
setScenario
(
AirDrop
::
SCENARIOS_CREATE
);
if
(
$model
->
load
(
$data
,
''
)
&&
$model
->
save
())
{
goto
doEnd
;
}
$this
->
msg
=
$model
->
errors
;
if
(
empty
(
$this
->
msg
))
{
$this
->
msg
=
'Validation failed.'
;
}
$service
=
new
Chain33Service
();
$result
=
$service
->
chainQuery
(
'ticket'
,
'MinerSourceList'
,
$data
[
'miner_address'
]);
echo
json_encode
(
$result
);
exit
;
$this
->
code
=
-
1
;
goto
doEnd
;
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
public
function
actionGameTrade
()
{
$coins_address
=
Yii
::
$app
->
request
->
post
(
'coins_address'
,
''
);
if
(
empty
(
$coins_address
))
{
if
(
empty
(
$coins_address
))
{
return
[
'code'
=>
-
1
,
'msg'
=>
'参数不能为空'
];
}
$coinTokenTransfer
=
CoinAirDropTrade
::
find
()
->
where
([
'coins_address'
=>
$coins_address
,
'type'
=>
CoinAirDropTrade
::
TYPE_GAME
])
->
one
();
if
(
$coinTokenTransfer
)
{
if
(
$coinTokenTransfer
)
{
return
[
'code'
=>
-
1
,
'data'
=>
null
,
'msg'
=>
'record already exists'
];
}
...
...
@@ -29,8 +56,8 @@ class AirDropController extends BaseController
$note
=
''
;
$service
=
new
Chain33Service
();
$createRawTransaction
=
$service
->
createRawTransaction
(
$coins_address
,
$amount
,
$fee
,
$note
,
$execer
);
if
(
0
!=
$createRawTransaction
[
'code'
])
{
$createRawTransaction
=
$service
->
createRawTransaction
(
$coins_address
,
$amount
,
$fee
,
$note
,
$execer
);
if
(
0
!=
$createRawTransaction
[
'code'
])
{
$msg
=
$createRawTransaction
[
'msg'
];
$code
=
-
1
;
goto
doEnd
;
...
...
@@ -41,7 +68,7 @@ class AirDropController extends BaseController
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
if
(
0
!=
$signRawTx
[
'code'
])
{
if
(
0
!=
$signRawTx
[
'code'
])
{
$msg
=
$signRawTx
[
'msg'
];
$code
=
-
1
;
goto
doEnd
;
...
...
@@ -49,7 +76,7 @@ class AirDropController extends BaseController
$sign_str
=
$signRawTx
[
'result'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
!=
$result
[
'code'
])
{
if
(
0
!=
$result
[
'code'
])
{
$msg
=
$result
[
'msg'
];
$code
=
-
1
;
goto
doEnd
;
...
...
@@ -72,16 +99,16 @@ class AirDropController extends BaseController
public
function
actionGameTradeUpdate
()
{
$coinAirDropTrade
=
CoinAirDropTrade
::
find
()
->
where
([
'attach'
=>
2
,
'msg'
=>
'0'
])
->
limit
(
30
)
->
all
();
foreach
(
$coinAirDropTrade
as
$val
){
$coinAirDropTrade
=
CoinAirDropTrade
::
find
()
->
where
([
'attach'
=>
2
,
'msg'
=>
'0'
])
->
limit
(
30
)
->
all
();
foreach
(
$coinAirDropTrade
as
$val
)
{
$fee
=
100000
;
$amount
=
1
*
1e8
;
$execer
=
'coins'
;
$note
=
''
;
$service
=
new
Chain33Service
();
$createRawTransaction
=
$service
->
createRawTransaction
(
$val
->
coins_address
,
$amount
,
$fee
,
$note
,
$execer
);
if
(
0
!=
$createRawTransaction
[
'code'
])
{
$createRawTransaction
=
$service
->
createRawTransaction
(
$val
->
coins_address
,
$amount
,
$fee
,
$note
,
$execer
);
if
(
0
!=
$createRawTransaction
[
'code'
])
{
continue
;
}
...
...
@@ -90,13 +117,13 @@ class AirDropController extends BaseController
$expire
=
'1m'
;
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
if
(
0
!=
$signRawTx
[
'code'
])
{
if
(
0
!=
$signRawTx
[
'code'
])
{
continue
;
}
$sign_str
=
$signRawTx
[
'result'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
!=
$result
[
'code'
])
{
if
(
0
!=
$result
[
'code'
])
{
continue
;
}
$currentModel
=
CoinAirDropTrade
::
findOne
(
$val
->
id
);
...
...
@@ -112,17 +139,17 @@ class AirDropController extends BaseController
{
$coinAirDropTrade
=
CoinAirDropTrade
::
find
()
->
where
([
'balance'
=>
0
])
->
limit
(
60
)
->
all
();
$address
=
[];
foreach
(
$coinAirDropTrade
as
$val
){
foreach
(
$coinAirDropTrade
as
$val
)
{
$address
[]
=
$val
->
coins_address
;
}
$service
=
new
Chain33Service
();
$execer
=
'coins'
;
$result
=
$service
->
getBalance
(
$address
,
$execer
);
if
(
0
==
$result
[
'code'
])
{
$result
=
$service
->
getBalance
(
$address
,
$execer
);
if
(
0
==
$result
[
'code'
])
{
$result_balance
=
$result
[
'result'
];
foreach
(
$result_balance
as
$val
){
foreach
(
$result_balance
as
$val
)
{
$coinAirDropTrade
=
CoinAirDropTrade
::
find
()
->
where
([
'coins_address'
=>
$val
[
'addr'
]])
->
one
();
if
(
empty
(
$coinAirDropTrade
))
continue
;
if
(
empty
(
$coinAirDropTrade
))
continue
;
$coinAirDropTrade
->
balance
=
$val
[
'balance'
];
$coinAirDropTrade
->
save
();
}
...
...
common/models/psources/AirDrop.php
0 → 100644
View file @
9529ea23
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
class
AirDrop
extends
CommonActiveRecord
{
const
ISSUE_TOKEN
=
'issue_token'
;
const
REVOKE_TOKEN
=
'revoke_token'
;
//定义场景
const
SCENARIOS_CREATE
=
'create'
;
const
SCENARIOS_UPDATE
=
'update'
;
public
static
function
getDb
()
{
return
Yii
::
$app
->
get
(
'p_sources'
);
}
public
static
function
tableName
()
{
return
'{{%wallet_airdrop_apply}}'
;
}
public
function
rules
()
{
return
[
[[
'identifier'
,
'wallet_address'
,
'miner_address'
],
'required'
],
[[
'checked_times'
],
'integer'
],
[[
'identifier'
],
'string'
,
'length'
=>
[
5
,
50
]],
[[
'wallet_address'
,
'miner_address'
],
'string'
,
'length'
=>
[
10
,
50
]],
];
}
public
function
scenarios
()
{
$scenarios
=
[
self
::
SCENARIOS_CREATE
=>
[
'identifier'
,
'miner_address'
],
self
::
SCENARIOS_UPDATE
=>
[
'wallet_address'
],
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
attributeLabels
()
{
return
[
'identifier'
=>
'树莓派编号'
,
'wallet_address'
=>
'矿主地址'
,
'miner_address'
=>
'矿工地址'
,
'checked_times'
=>
'达标次数'
,
'create_time'
=>
'开始时间'
,
'finish_time'
=>
'结束时间'
];
}
}
\ 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