|
@@ -4,6 +4,7 @@ namespace app\common\library;
|
|
|
|
|
|
|
|
use app\common\model\Users;
|
|
use app\common\model\Users;
|
|
|
use app\common\model\UserRule;
|
|
use app\common\model\UserRule;
|
|
|
|
|
+use app\common\model\UsersPath;
|
|
|
use fast\Random;
|
|
use fast\Random;
|
|
|
use think\Config;
|
|
use think\Config;
|
|
|
use think\Db;
|
|
use think\Db;
|
|
@@ -166,34 +167,38 @@ class Auth
|
|
|
$ip = request()->ip();
|
|
$ip = request()->ip();
|
|
|
$time = time();
|
|
$time = time();
|
|
|
|
|
|
|
|
- $data = [
|
|
|
|
|
|
|
+ $user_data = [
|
|
|
//'username' => $username,
|
|
//'username' => $username,
|
|
|
//'email' => $email,
|
|
//'email' => $email,
|
|
|
'mobile' => $mobile,
|
|
'mobile' => $mobile,
|
|
|
'code' => $code,
|
|
'code' => $code,
|
|
|
'login_pwd'=> $password,
|
|
'login_pwd'=> $password,
|
|
|
'parent_id'=> $parent_info['id'],
|
|
'parent_id'=> $parent_info['id'],
|
|
|
-// 'level' => 1,
|
|
|
|
|
-// 'score' => 0,
|
|
|
|
|
-// 'avatar' => '',
|
|
|
|
|
|
|
+ 'agent_id' => $parent_info['agent_id'],
|
|
|
];
|
|
];
|
|
|
- $params = array_merge($data, [
|
|
|
|
|
|
|
+ $user_data = array_merge($user_data, [
|
|
|
'nickname' => preg_match("/^1[3-9]{1}\d{9}$/", $mobile) ? substr_replace($mobile, '****', 3, 4) : $mobile,
|
|
'nickname' => preg_match("/^1[3-9]{1}\d{9}$/", $mobile) ? substr_replace($mobile, '****', 3, 4) : $mobile,
|
|
|
'salt' => Random::alnum(),
|
|
'salt' => Random::alnum(),
|
|
|
'join_time' => $time,
|
|
'join_time' => $time,
|
|
|
'login_ip' => $ip,
|
|
'login_ip' => $ip,
|
|
|
'login_time'=> $time,
|
|
'login_time'=> $time,
|
|
|
]);
|
|
]);
|
|
|
- $params['login_pwd'] = $this->getEncryptPassword($password, $params['salt']);
|
|
|
|
|
|
|
+ $user_data['login_pwd'] = $this->getEncryptPassword($password, $user_data['salt']);
|
|
|
//$params = array_merge($params, $extend);
|
|
//$params = array_merge($params, $extend);
|
|
|
|
|
|
|
|
//账号注册时需要开启事务,避免出现垃圾数据
|
|
//账号注册时需要开启事务,避免出现垃圾数据
|
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
|
try {
|
|
try {
|
|
|
- $user = Users::create($params, true);
|
|
|
|
|
|
|
+ $user = Users::create($user_data, true);
|
|
|
|
|
|
|
|
$this->_user = Users::get($user->id);
|
|
$this->_user = Users::get($user->id);
|
|
|
|
|
|
|
|
|
|
+ // 创建网体
|
|
|
|
|
+ (new UsersPath())->createPath($user->id, $parent_info['id']);
|
|
|
|
|
+
|
|
|
|
|
+ //上级人数+1
|
|
|
|
|
+ (new Users())->where('id', $parent_info['id'])->setInc('team_num');
|
|
|
|
|
+
|
|
|
//设置Token
|
|
//设置Token
|
|
|
$this->_token = Random::uuid();
|
|
$this->_token = Random::uuid();
|
|
|
Token::set($this->_token, $user->id, $this->keeptime);
|
|
Token::set($this->_token, $user->id, $this->keeptime);
|
|
@@ -202,7 +207,7 @@ class Auth
|
|
|
$this->_logined = true;
|
|
$this->_logined = true;
|
|
|
|
|
|
|
|
//注册成功的事件
|
|
//注册成功的事件
|
|
|
- Hook::listen("user_register_successed", $this->_user, $data);
|
|
|
|
|
|
|
+ Hook::listen("user_register_successed", $this->_user, $user_data);
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
$this->setError($e->getMessage());
|
|
$this->setError($e->getMessage());
|