Commit 60971b5e authored by shajiaiming's avatar shajiaiming

采用新表

parent e553cb92
......@@ -11,6 +11,7 @@ namespace api\controllers;
use Yii;
use api\base\BaseController;
use common\models\pwallet\GameUser;
use common\models\pwallet\GameUserAddress;
class GameController extends BaseController {
/**
......@@ -54,13 +55,35 @@ class GameController extends BaseController {
return ['code' => -1, 'msg' => 'Failed'];
}
public function actionSaveGameInfo(){
$post = Yii::$app->request->post();
$address = $post['address'] ?? '';
$nickname = $post['nickname'] ?? '';
if (empty($address) || empty($nickname)) {
return ['code' => -1, 'msg' => '地址和昵称不能为空', 'data' => null];
}
//判断重复
$count = GameUserAddress::find()->where(['address' => $address])->count();
if ($count > 0) {
return ['code' => -1, 'msg' => '地址已存在', 'data' => null];
}
// todo 保存
$models = new GameUserAddress();
$models->nickname = $nickname;
$models->address = $address;
if ($models->save()) {
return ['code' => 0, 'msg' => 'Succeed', 'data' => $models->id];
}
return ['code' => -1, 'msg' => 'Failed', 'data' => null];
}
public function actionGetNicknameByAddressArr(){
$address = Yii::$app->request->post('address', '');
if (empty($address)) {
return ['code' => -1, 'msg' => '地址不能为空', 'data' => ''];
}
//todo 获取地址
$address = GameUser::find()
$address = GameUserAddress::find()
->select(['nickname', 'address'])
->where(['in','address',$address])
->asArray()->all();
......
<?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 GameUserAddress extends BaseActiveRecord{
public static function getDb(){
return Yii::$app->get('db_pwallet');
}
public function formName()
{
return '';
}
}
\ No newline at end of file
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