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
6a441a56
Commit
6a441a56
authored
Aug 14, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
game
parent
c546baff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
0 deletions
+82
-0
GameController.php
api/controllers/GameController.php
+57
-0
GameUser.php
common/models/pwallet/GameUser.php
+25
-0
No files found.
api/controllers/GameController.php
0 → 100644
View file @
6a441a56
<?php
/**
* Created By Sublime text 3
* User: rlgyzhcn
* Date: 18-08-14
* Time: 上午10:09
*/
namespace
api\controllers
;
use
Yii
;
use
api\base\BaseController
;
use
common\models\pwallet\GameUser
;
class
GameController
extends
BaseController
{
/**
* 保存地址与昵称
*/
public
function
actionSaveAddressAndNickname
(){
$post
=
Yii
::
$app
->
request
->
post
();
$address
=
$post
[
'address'
]
??
''
;
$nickname
=
$post
[
'nickname'
]
??
''
;
if
(
empty
(
$address
)
||
empty
(
$nickname
))
{
return
[
'code'
=>
-
1
,
'msg'
=>
'地址和昵称不能为空'
,
'data'
=>
''
];
}
//判断重复
$count
=
GameUser
::
find
()
->
where
([
'nickname'
=>
$nickname
])
->
count
();
if
(
$count
>
0
)
{
return
[
'code'
=>
-
1
,
'msg'
=>
'昵称重复'
];
}
// todo 保存
$models
=
new
GameUser
();
$models
->
nickname
=
$nickname
;
$models
->
address
=
$address
;
if
(
$models
->
save
())
{
return
[
'code'
=>
0
,
'msg'
=>
'Succeed'
,
'data'
=>
$models
->
id
];
}
return
[
'code'
=>
-
1
,
'msg'
=>
'Failed'
];
}
/**
* 根据地址获取昵称
*/
public
function
actionGetNicknameByAddress
(){
$address
=
Yii
::
$app
->
request
->
post
(
'address'
,
''
);
if
(
empty
(
$address
))
{
return
[
'code'
=>
-
1
,
'msg'
=>
'地址不能为空'
,
'data'
=>
''
];
}
//todo 获取地址
$address
=
GameUser
::
find
()
->
select
([
'nickname'
])
->
where
([
'address'
=>
$address
])
->
one
();
if
(
!
empty
(
$address
))
{
return
[
'code'
=>
0
,
'msg'
=>
'Succeed'
,
'data'
=>
$address
];
}
return
[
'code'
=>
-
1
,
'msg'
=>
'Failed'
];
}
}
\ No newline at end of file
common/models/pwallet/GameUser.php
0 → 100644
View file @
6a441a56
<?php
/**
* Created By Sublime text 3
* User: rlgyzhcn
* Date: 18-08-12
* Time: 下午14:17
*/
namespace
common\models\pwallet
;
use
common\core\BaseActiveRecord
;
use
Yii
;
class
GameUser
extends
BaseActiveRecord
{
public
static
function
getDb
(){
return
Yii
::
$app
->
get
(
'db_pwallet'
);
}
public
function
formName
()
{
return
''
;
}
}
\ 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