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
7a15756a
Commit
7a15756a
authored
Aug 01, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
游戏
parent
e98655fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
44 deletions
+49
-44
GameController.php
api/controllers/GameController.php
+49
-44
No files found.
api/controllers/GameController.php
View file @
7a15756a
...
...
@@ -13,49 +13,53 @@ use api\base\BaseController;
use
common\models\pwallet\GameUser
;
use
common\models\pwallet\GameUserAddress
;
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'
];
}
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'
];
}
/**
* 根据地址获取昵称
*/
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'
];
}
public
function
actionSaveGameInfo
(){
public
function
actionSaveGameInfo
()
{
$post
=
Yii
::
$app
->
request
->
post
();
$address
=
$post
[
'address'
]
??
''
;
$nickname
=
$post
[
'nickname'
]
??
''
;
...
...
@@ -77,7 +81,8 @@ class GameController extends BaseController {
return
[
'code'
=>
-
1
,
'msg'
=>
'Failed'
,
'data'
=>
null
];
}
public
function
actionGetNicknameByAddressArr
(){
public
function
actionGetNicknameByAddressArr
()
{
$address
=
Yii
::
$app
->
request
->
post
(
'address'
,
''
);
if
(
empty
(
$address
))
{
return
[
'code'
=>
-
1
,
'msg'
=>
'地址不能为空'
,
'data'
=>
''
];
...
...
@@ -85,10 +90,10 @@ class GameController extends BaseController {
//todo 获取地址
$address
=
GameUserAddress
::
find
()
->
select
([
'nickname'
,
'address'
])
->
where
([
'in'
,
'address'
,
$address
])
->
where
([
'in'
,
'address'
,
$address
])
->
asArray
()
->
all
();
if
(
!
empty
(
$address
))
{
return
[
'code'
=>
0
,
'msg'
=>
'Succeed'
,
'data'
=>
$address
];
return
[
'code'
=>
0
,
'msg'
=>
'Succeed'
,
'data'
=>
$address
];
}
return
[
'code'
=>
-
1
,
'msg'
=>
'Failed'
];
}
...
...
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