|
|
@ -10,6 +10,7 @@ use common\models\OrderT; |
|
|
|
use common\models\OrderUserT; |
|
|
|
use common\models\OrderUserT; |
|
|
|
use common\models\PermissionsT; |
|
|
|
use common\models\PermissionsT; |
|
|
|
use common\models\SendLogT; |
|
|
|
use common\models\SendLogT; |
|
|
|
|
|
|
|
use common\models\UserLogT; |
|
|
|
use common\models\UserT; |
|
|
|
use common\models\UserT; |
|
|
|
use Yii; |
|
|
|
use Yii; |
|
|
|
use yii\db\Exception; |
|
|
|
use yii\db\Exception; |
|
|
@ -834,6 +835,10 @@ class ApiController extends \yii\web\Controller |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 游客注册接口 |
|
|
|
|
|
|
|
* @return array |
|
|
|
|
|
|
|
*/ |
|
|
|
public function actionRegister(){ |
|
|
|
public function actionRegister(){ |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
Yii::$app->response->format = Response::FORMAT_JSON; |
|
|
|
$request = Yii::$app->request; |
|
|
|
$request = Yii::$app->request; |
|
|
@ -841,10 +846,10 @@ class ApiController extends \yii\web\Controller |
|
|
|
'code' => 0, |
|
|
|
'code' => 0, |
|
|
|
'msg' => '请求成功', |
|
|
|
'msg' => '请求成功', |
|
|
|
); |
|
|
|
); |
|
|
|
$name = trim($request->get('name','')); |
|
|
|
$name = trim($request->post('name','')); |
|
|
|
$mobile = trim($request->get('mobile','')); |
|
|
|
$mobile = trim($request->post('mobile','')); |
|
|
|
$user = UserT::findOne(['name' => $name, 'phone' => $mobile]); |
|
|
|
$user = UserT::findOne(['name' => $name, 'phone' => $mobile]); |
|
|
|
if($name == '' || !preg_match_all("/^1[345789]\d{9}$/", $mobile)){ |
|
|
|
if($name == '' || !preg_match('/^1[345789]\d{9}$/', $mobile)){ |
|
|
|
$result['code'] = -1; |
|
|
|
$result['code'] = -1; |
|
|
|
$result['msg'] = '参数错误'; |
|
|
|
$result['msg'] = '参数错误'; |
|
|
|
return $result; |
|
|
|
return $result; |
|
|
@ -881,7 +886,7 @@ class ApiController extends \yii\web\Controller |
|
|
|
$tran = UserT::getDb()->beginTransaction(); |
|
|
|
$tran = UserT::getDb()->beginTransaction(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (!$user->save()) { |
|
|
|
if (!$user->save()) { |
|
|
|
throw new Exception(json_encode($user->getErrors())); |
|
|
|
throw new \Exception(json_encode($user->getErrors())); |
|
|
|
} |
|
|
|
} |
|
|
|
//处理权限 |
|
|
|
//处理权限 |
|
|
|
$user->unlinkAll('permissions', true); |
|
|
|
$user->unlinkAll('permissions', true); |
|
|
@ -891,8 +896,13 @@ class ApiController extends \yii\web\Controller |
|
|
|
foreach ($permission_info->menus as $item) { |
|
|
|
foreach ($permission_info->menus as $item) { |
|
|
|
$user->link('menus', $item); |
|
|
|
$user->link('menus', $item); |
|
|
|
} |
|
|
|
} |
|
|
|
$content = "游客{$name}(${mobile})注册"; |
|
|
|
$user_log_info = new UserLogT(); |
|
|
|
Yii::$app->runAction('new_controller/new_action', $user->id, $content); |
|
|
|
$user_log_info->user_id = $user->id; |
|
|
|
|
|
|
|
$user_log_info->content = "游客{$name}(${mobile})注册"; |
|
|
|
|
|
|
|
$user_log_info->ip = MyLib::getIP(); |
|
|
|
|
|
|
|
if(!$user_log_info->save()){ |
|
|
|
|
|
|
|
throw new \Exception(json_encode($user_log_info->getErrors())); |
|
|
|
|
|
|
|
} |
|
|
|
$tran->commit(); |
|
|
|
$tran->commit(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
} catch (\Exception $e) { |
|
|
|
$tran->rollBack(); |
|
|
|
$tran->rollBack(); |
|
|
|