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
64ae6e97
Commit
64ae6e97
authored
Mar 27, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
6641b1bd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
211 additions
and
25 deletions
+211
-25
AirDropController.php
api/controllers/AirDropController.php
+103
-5
ExchangeBusiness.php
common/business/ExchangeBusiness.php
+15
-15
AirDrop.php
common/models/psources/AirDrop.php
+8
-5
AirDropApplyRecord.php
common/models/psources/AirDropApplyRecord.php
+59
-0
AirDropController.php
console/controllers/AirDropController.php
+26
-0
No files found.
api/controllers/AirDropController.php
View file @
64ae6e97
...
...
@@ -4,6 +4,7 @@ namespace api\controllers;
use
api\base\BaseController
;
use
common\models\psources\AirDrop
;
use
common\models\psources\AirDropApplyRecord
;
use
common\models\psources\CoinAirDropTrade
;
use
common\service\chain33\Chain33Service
;
use
Yii
;
...
...
@@ -20,18 +21,115 @@ class AirDropController extends BaseController
if
(
$model
->
load
(
$data
,
''
)
&&
$model
->
save
())
{
goto
doEnd
;
}
$this
->
code
=
-
1
;
$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
;
}
if
(
Yii
::
$app
->
request
->
isGet
)
{
$page
=
\Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
\Yii
::
$app
->
request
->
get
(
'size'
,
10
);
$data
=
Yii
::
$app
->
request
->
get
();
$identifier
=
$data
[
'identifier'
]
??
''
;
$miner_address
=
$data
[
'miner_address'
]
??
''
;
if
(
false
==
$identifier
||
false
==
$miner_address
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'Validation failed.'
;
goto
doEnd
;
}
$model
=
AirDrop
::
find
()
->
select
(
'id'
)
->
where
([
'identifier'
=>
$identifier
,
'miner_address'
=>
$miner_address
])
->
one
();
$total
=
0
;
$items
=
[];
if
(
empty
(
$model
)
||
empty
(
$model
->
record
))
{
goto
doEnd
;
}
$query
=
AirDropApplyRecord
::
find
()
->
select
(
'id, reach, bonus_token, draw_status, create_time'
)
->
where
([
'apply_id'
=>
$model
[
'id'
]]);
$items
=
$query
->
offset
((
$page
-
1
)
*
$size
)
->
orderBy
(
'id desc'
)
->
limit
(
$size
)
->
all
();
$countQuery
=
clone
$query
;
$total
=
(
int
)
$countQuery
->
count
();
$this
->
data
=
[
'items'
=>
$items
,
'total'
=>
$total
];
}
if
(
Yii
::
$app
->
request
->
isPut
)
{
$data
=
Yii
::
$app
->
request
->
post
();
$id
=
$data
[
'id'
]
??
''
;
$identifier
=
$data
[
'identifier'
]
??
''
;
$miner_address
=
$data
[
'miner_address'
]
??
''
;
if
(
false
==
$id
||
false
==
$identifier
||
false
==
$miner_address
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'Validation failed.'
;
goto
doEnd
;
}
$model
=
AirDrop
::
find
()
->
select
(
'id'
)
->
where
([
'identifier'
=>
$identifier
,
'miner_address'
=>
$miner_address
])
->
one
();
if
(
empty
(
$model
)
||
empty
(
$model
->
record
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'暂无符合条件的空投申请记录'
;
goto
doEnd
;
}
$record
=
AirDropApplyRecord
::
find
()
->
where
([
'id'
=>
$id
,
'reach'
=>
AirDropApplyRecord
::
REACH_YES
,
'draw_status'
=>
AirDropApplyRecord
::
STATUS_UNDRAW
])
->
one
();
if
(
empty
(
$record
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'暂无符合条件的领取记录'
;
goto
doEnd
;
}
$record
->
draw_status
=
AirDropApplyRecord
::
STATUS_DRAWING
;
if
(
false
==
$record
->
save
())
{
$this
->
code
=
-
1
;
$this
->
msg
=
$record
->
errors
;
goto
doEnd
;
}
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
public
function
actionDraw
()
{
if
(
Yii
::
$app
->
request
->
isPost
)
{
$data
=
Yii
::
$app
->
request
->
post
();
$identifier
=
$data
[
'identifier'
]
??
''
;
$miner_address
=
$data
[
'miner_address'
]
??
''
;
if
(
false
==
$identifier
||
false
==
$miner_address
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'Validation failed.'
;
goto
doEnd
;
}
$model
=
AirDrop
::
find
()
->
select
(
'id'
)
->
where
([
'identifier'
=>
$identifier
,
'miner_address'
=>
$miner_address
])
->
one
();
if
(
empty
(
$model
)
||
empty
(
$model
->
record
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'暂无符合条件的空投申请记录'
;
goto
doEnd
;
}
$record
=
AirDropApplyRecord
::
find
()
->
where
([
'apply_id'
=>
$model
[
'id'
],
'reach'
=>
AirDropApplyRecord
::
REACH_YES
,
'draw_status'
=>
AirDropApplyRecord
::
STATUS_UNDRAW
])
->
all
();
if
(
empty
(
$record
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'暂无符合条件的领取记录'
;
goto
doEnd
;
}
foreach
(
$record
as
$val
)
{
$val
->
draw_status
=
AirDropApplyRecord
::
STATUS_DRAWING
;
$val
->
save
();
}
}
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
...
...
common/business/ExchangeBusiness.php
View file @
64ae6e97
...
...
@@ -26,21 +26,21 @@ class ExchangeBusiness
* @var array
*/
private
static
$exchanges
=
[
0
=>
'Bty'
,
1
=>
'HuoBi'
,
2
=>
'Hadax'
,
3
=>
'Bitfinex'
,
4
=>
'Bittrex'
,
5
=>
'Zb'
,
6
=>
'Token7'
,
7
=>
'Zg'
,
8
=>
'Go'
,
9
=>
'Zhaobi'
,
10
=>
'Ex'
,
11
=>
'Zt'
,
12
=>
'Tsc'
,
13
=>
'Binance'
,
14
=>
'Bilaxy'
,
//
0 => 'Bty',
//
1 => 'HuoBi',
//
2 => 'Hadax',
//
3 => 'Bitfinex',
//
4 => 'Bittrex',
//
5 => 'Zb',
//
6 => 'Token7',
//
7 => 'Zg',
//
8 => 'Go',
//
9 => 'Zhaobi',
//
10 => 'Ex',
//
11 => 'Zt',
//
12 => 'Tsc',
//
13 => 'Binance',
//
14 => 'Bilaxy',
15
=>
'Bitnasdaq'
,
16
=>
'Dag'
,
17
=>
'Coinka'
,
...
...
common/models/psources/AirDrop.php
View file @
64ae6e97
...
...
@@ -7,9 +7,6 @@ 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'
;
...
...
@@ -28,7 +25,7 @@ class AirDrop extends CommonActiveRecord
{
return
[
[[
'identifier'
,
'wallet_address'
,
'miner_address'
],
'required'
],
[[
'
checked
_times'
],
'integer'
],
[[
'
reach
_times'
],
'integer'
],
[[
'identifier'
],
'string'
,
'length'
=>
[
5
,
50
]],
[[
'wallet_address'
,
'miner_address'
],
'string'
,
'length'
=>
[
10
,
50
]],
];
...
...
@@ -49,9 +46,14 @@ class AirDrop extends CommonActiveRecord
'identifier'
=>
'树莓派编号'
,
'wallet_address'
=>
'矿主地址'
,
'miner_address'
=>
'矿工地址'
,
'
checked
_times'
=>
'达标次数'
,
'
reach
_times'
=>
'达标次数'
,
'create_time'
=>
'开始时间'
,
'finish_time'
=>
'结束时间'
];
}
public
function
getRecord
()
{
return
$this
->
hasMany
(
AirDropApplyRecord
::
className
(),
[
'apply_id'
=>
'id'
])
->
all
();
}
}
\ No newline at end of file
common/models/psources/AirDropApplyRecord.php
0 → 100644
View file @
64ae6e97
<?php
namespace
common\models\psources
;
use
Yii
;
use
yii\db\Expression
;
class
AirDropApplyRecord
extends
CommonActiveRecord
{
const
REACH_NO
=
0
;
//未达标
const
REACH_YES
=
1
;
//已达标
const
STATUS_UNDRAW
=
0
;
//未领取
const
STATUS_DRAWING
=
1
;
// 领取中
const
STATUS_DRAW_SUEEESS
=
2
;
//领取成功
const
STATUS_DRAW_FAIL
=
3
;
// 领取失败
//定义场景
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_record}}'
;
}
public
function
rules
()
{
return
[
];
}
public
function
scenarios
()
{
$scenarios
=
[
];
return
array_merge
(
parent
::
scenarios
(),
$scenarios
);
}
public
function
attributeLabels
()
{
return
[
'apply_id'
=>
'申请ID'
,
'reach'
=>
'达标情况'
,
'bonus_token'
=>
'奖励单位'
,
'draw_status'
=>
'领取情况'
,
'create_time'
=>
'创建时间'
,
'finish_time'
=>
'更新时间'
];
}
}
\ No newline at end of file
console/controllers/AirDropController.php
View file @
64ae6e97
...
...
@@ -2,6 +2,7 @@
namespace
console\controllers
;
use
common\models\psources\AirDrop
;
use
Yii
;
use
yii\console\Controller
;
use
common\service\chain33\Chain33Service
;
...
...
@@ -9,6 +10,31 @@ use common\models\psources\CoinAirDropTransfer;
class
AirDropController
extends
Controller
{
public
function
actionMinerSourceList
()
{
$model
=
AirDrop
::
find
()
->
where
([
'wallet_address'
=>
''
])
->
asArray
()
->
all
();
if
(
empty
(
$model
))
{
return
0
;
}
$service
=
new
Chain33Service
();
foreach
(
$model
as
$key
=>
$val
)
{
$playload
=
[
'data'
=>
$val
[
'miner_address'
]
];
$result
=
$service
->
chainQuery
(
'ticket'
,
'MinerSourceList'
,
$playload
);
if
(
0
!=
$result
[
'code'
])
{
continue
;
}
$wallet_address
=
isset
(
$result
[
'result'
][
'datas'
][
0
])
?
$result
[
'result'
][
'datas'
][
0
]
:
''
;
if
(
empty
(
$wallet_address
))
{
continue
;
}
$current_model
=
AirDrop
::
findOne
(
$val
[
'id'
]);
$current_model
->
wallet_address
=
$wallet_address
;
$current_model
->
save
();
}
}
/**
* 获取游戏状态
*
...
...
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