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
da76d9eb
Commit
da76d9eb
authored
Mar 27, 2020
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
64ae6e97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
53 deletions
+69
-53
AirDropController.php
api/controllers/AirDropController.php
+67
-53
AirDrop.php
common/models/psources/AirDrop.php
+2
-0
No files found.
api/controllers/AirDropController.php
View file @
da76d9eb
...
...
@@ -62,37 +62,43 @@ class AirDropController extends BaseController
];
}
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
();
doEnd
:
return
[
'code'
=>
$this
->
code
,
'msg'
=>
$this
->
msg
,
'data'
=>
$this
->
data
];
}
if
(
empty
(
$model
)
||
empty
(
$model
->
record
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'暂无符合条件的空投申请记录'
;
goto
doEnd
;
}
public
function
actionBatchDraw
()
{
if
(
!
Yii
::
$app
->
request
->
isPost
)
{
$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
;
}
$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
();
$record
->
draw_status
=
AirDropApplyRecord
::
STATUS_DRAWING
;
if
(
false
==
$record
->
save
())
{
$this
->
code
=
-
1
;
$this
->
msg
=
$record
->
errors
;
goto
doEnd
;
}
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
:
...
...
@@ -101,33 +107,41 @@ class AirDropController extends BaseController
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
(
!
Yii
::
$app
->
request
->
isPost
)
{
$this
->
code
=
-
1
;
$this
->
msg
=
'请求方式错误!'
;
goto
doEnd
;
}
if
(
empty
(
$model
)
||
empty
(
$model
->
record
))
{
$this
->
code
=
-
1
;
$this
->
msg
=
'暂无符合条件的空投申请记录'
;
goto
doEnd
;
}
$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
();
$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
();
}
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
:
...
...
common/models/psources/AirDrop.php
View file @
da76d9eb
...
...
@@ -28,6 +28,8 @@ class AirDrop extends CommonActiveRecord
[[
'reach_times'
],
'integer'
],
[[
'identifier'
],
'string'
,
'length'
=>
[
5
,
50
]],
[[
'wallet_address'
,
'miner_address'
],
'string'
,
'length'
=>
[
10
,
50
]],
[
'identifier'
,
'unique'
,
'message'
=>
'树莓派编号已存在'
],
[
'miner_address'
,
'unique'
,
'message'
=>
'矿工地址已存在'
],
];
}
...
...
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