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
f3e46067
Commit
f3e46067
authored
Apr 01, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backend airdrop api
parent
ec71026d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
0 deletions
+83
-0
AirDropController.php
wallet/controllers/AirDropController.php
+83
-0
No files found.
wallet/controllers/AirDropController.php
0 → 100644
View file @
f3e46067
<?php
namespace
wallet\controllers
;
use
common\models\psources\AirDropApplyRecord
;
use
Yii
;
use
wallet\base\BaseController
;
use
common\models\psources\AirDrop
;
class
AirDropController
extends
BaseController
{
public
function
actionIndex
()
{
$page
=
Yii
::
$app
->
request
->
get
(
'page'
,
1
);
$size
=
Yii
::
$app
->
request
->
get
(
'size'
,
10
);
if
(
!
Yii
::
$app
->
request
->
isGet
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'错误的请求方式.'
;
goto
doEnd
;
}
$query
=
AirDrop
::
find
()
->
select
(
'identifier, wallet_address,miner_address,create_time, finish_time'
);
$model
=
$query
->
offset
((
$page
-
1
)
*
$size
)
->
orderBy
(
'id desc'
)
->
limit
(
$size
)
->
all
();
if
(
empty
(
$model
))
{
goto
doEnd
;
}
$countQuery
=
clone
$query
;
$this
->
data
=
[
'items'
=>
$model
,
'total'
=>
(
int
)
$countQuery
->
count
()
];
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
public
function
actionApply
()
{
$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'
]
??
''
;
$apply_ids
=
isset
(
$data
[
'apply_ids'
])
?
$data
[
'apply_ids'
]
:
''
;
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
(
'reach, draw_status, create_time, update_time'
)
->
where
([
'apply_id'
=>
$model
[
'id'
]]);
if
(
!
empty
(
$apply_ids
))
{
$apply_ids
=
rtrim
(
$apply_ids
,
','
);
$apply_id_arr
=
explode
(
','
,
$apply_ids
);
$query
->
andWhere
([
'in'
,
'id'
,
$apply_id_arr
]);
}
$expiry_date
=
date
(
"Y-m-d"
,
strtotime
(
"+1 day"
));
$query
->
andWhere
([
'<'
,
'create_time'
,
$expiry_date
]);
$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
,
];
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
}
\ 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