Commit 94d60b51 authored by hujun's avatar hujun

用户注册并发处理

parent 363e1365
...@@ -217,8 +217,9 @@ class Member extends Basic ...@@ -217,8 +217,9 @@ class Member extends Basic
$data['status'] = 101; $data['status'] = 101;
$data['data'] = array(); $data['data'] = array();
$this->user->startTrans();
if ($phone) { if ($phone) {
$user_data = $this->user->get(['user_phone' => $phone]); $user_data = $this->user->findUserByPhone('*', $phone, true);
} else { } else {
$user_data = $this->user->get($this->userId); $user_data = $this->user->get($this->userId);
} }
...@@ -304,9 +305,11 @@ class Member extends Basic ...@@ -304,9 +305,11 @@ class Member extends Basic
} }
if (empty($id)) { if (empty($id)) {
$this->user->rollback();
$data['status'] = 101; $data['status'] = 101;
$data['msg'] = '注册失败'; $data['msg'] = '注册失败';
} else { } else {
$this->user->commit();
$jwt_data['id'] = $id; $jwt_data['id'] = $id;
$jwt_data['userNick'] = $insert_data['user_nick']; $jwt_data['userNick'] = $insert_data['user_nick'];
$jwt_data['phone'] = $insert_data['user_phone']; $jwt_data['phone'] = $insert_data['user_phone'];
......
...@@ -428,4 +428,30 @@ class Users extends Model ...@@ -428,4 +428,30 @@ class Users extends Model
->where($params) ->where($params)
->select(); ->select();
} }
/**
* 跟进用户手机号查询信息
*
* @param string $field
* @param $phone
* @param bool $lock
* @return $this|array|false|\PDOStatement|string|Model
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function findUserByPhone($field = '*', $phone, $lock = false) {
if ($lock) {
$data = $this->field($field)
->where('user_phone',$phone)
->lock(true)
->find();
} else {
$data = $this->field($field)
->where('user_phone',$phone)
->find();
}
return $data;
}
} }
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