Commit 7a15756a authored by shajiaiming's avatar shajiaiming

游戏

parent e98655fe
...@@ -13,14 +13,16 @@ use api\base\BaseController; ...@@ -13,14 +13,16 @@ use api\base\BaseController;
use common\models\pwallet\GameUser; use common\models\pwallet\GameUser;
use common\models\pwallet\GameUserAddress; use common\models\pwallet\GameUserAddress;
class GameController extends BaseController { class GameController extends BaseController
{
/** /**
* 保存地址与昵称 * 保存地址与昵称
*/ */
public function actionSaveAddressAndNickname(){ public function actionSaveAddressAndNickname()
{
$post = Yii::$app->request->post(); $post = Yii::$app->request->post();
$address = $post['address']??''; $address = $post['address'] ?? '';
$nickname = $post['nickname']??''; $nickname = $post['nickname'] ?? '';
if (empty($address) || empty($nickname)) { if (empty($address) || empty($nickname)) {
return ['code' => -1, 'msg' => '地址和昵称不能为空', 'data' => '']; return ['code' => -1, 'msg' => '地址和昵称不能为空', 'data' => ''];
} }
...@@ -42,7 +44,8 @@ class GameController extends BaseController { ...@@ -42,7 +44,8 @@ class GameController extends BaseController {
/** /**
* 根据地址获取昵称 * 根据地址获取昵称
*/ */
public function actionGetNicknameByAddress(){ public function actionGetNicknameByAddress()
{
$address = Yii::$app->request->post('address', ''); $address = Yii::$app->request->post('address', '');
if (empty($address)) { if (empty($address)) {
return ['code' => -1, 'msg' => '地址不能为空', 'data' => '']; return ['code' => -1, 'msg' => '地址不能为空', 'data' => ''];
...@@ -50,12 +53,13 @@ class GameController extends BaseController { ...@@ -50,12 +53,13 @@ class GameController extends BaseController {
//todo 获取地址 //todo 获取地址
$address = GameUser::find()->select(['nickname'])->where(['address' => $address])->one(); $address = GameUser::find()->select(['nickname'])->where(['address' => $address])->one();
if (!empty($address)) { if (!empty($address)) {
return ['code' => 0, 'msg'=> 'Succeed', 'data' => $address]; return ['code' => 0, 'msg' => 'Succeed', 'data' => $address];
} }
return ['code' => -1, 'msg' => 'Failed']; return ['code' => -1, 'msg' => 'Failed'];
} }
public function actionSaveGameInfo(){ public function actionSaveGameInfo()
{
$post = Yii::$app->request->post(); $post = Yii::$app->request->post();
$address = $post['address'] ?? ''; $address = $post['address'] ?? '';
$nickname = $post['nickname'] ?? ''; $nickname = $post['nickname'] ?? '';
...@@ -77,7 +81,8 @@ class GameController extends BaseController { ...@@ -77,7 +81,8 @@ class GameController extends BaseController {
return ['code' => -1, 'msg' => 'Failed', 'data' => null]; return ['code' => -1, 'msg' => 'Failed', 'data' => null];
} }
public function actionGetNicknameByAddressArr(){ public function actionGetNicknameByAddressArr()
{
$address = Yii::$app->request->post('address', ''); $address = Yii::$app->request->post('address', '');
if (empty($address)) { if (empty($address)) {
return ['code' => -1, 'msg' => '地址不能为空', 'data' => '']; return ['code' => -1, 'msg' => '地址不能为空', 'data' => ''];
...@@ -85,10 +90,10 @@ class GameController extends BaseController { ...@@ -85,10 +90,10 @@ class GameController extends BaseController {
//todo 获取地址 //todo 获取地址
$address = GameUserAddress::find() $address = GameUserAddress::find()
->select(['nickname', 'address']) ->select(['nickname', 'address'])
->where(['in','address',$address]) ->where(['in', 'address', $address])
->asArray()->all(); ->asArray()->all();
if (!empty($address)) { if (!empty($address)) {
return ['code' => 0, 'msg'=> 'Succeed', 'data' => $address]; return ['code' => 0, 'msg' => 'Succeed', 'data' => $address];
} }
return ['code' => -1, 'msg' => 'Failed']; 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