Commit 1644a806 authored by hujun's avatar hujun

用户注册并发处理

parent 93e0de32
......@@ -231,8 +231,9 @@ class Member extends Basic
$data['status'] = 101;
$data['data'] = array();
$this->user->startTrans();
if ($phone) {
$user_data = $this->user->get(['user_phone' => $phone]);
$user_data = $this->user->findUserByPhone('*', $phone, true);
} else {
$user_data = $this->user->get($this->userId);
}
......@@ -317,9 +318,11 @@ class Member extends Basic
}
if (empty($id)) {
$this->user->rollback();
$data['status'] = 101;
$data['msg'] = '注册失败';
} else {
$this->user->commit();
$jwt_data['id'] = $id;
$jwt_data['userNick'] = $insert_data['user_nick'];
$jwt_data['phone'] = $insert_data['user_phone'];
......
......@@ -302,4 +302,30 @@ class Users extends Model
{
return db('u_users')->update($conditions);
}
/**
* 跟进用户手机号查询信息
*
* @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