Commit 7a15756a authored by shajiaiming's avatar shajiaiming

游戏

parent e98655fe
......@@ -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'];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment