Commit e640593a authored by jianghaiming's avatar jianghaiming

update:修改主库查询

parent 84a733dc
...@@ -22,5 +22,6 @@ class UserException extends BaseException ...@@ -22,5 +22,6 @@ class UserException extends BaseException
8 => '绑定手机号失败', 8 => '绑定手机号失败',
9 => '该手机号已绑定其他用户不能重复绑定', 9 => '该手机号已绑定其他用户不能重复绑定',
10 => 'mysql 异常', 10 => 'mysql 异常',
11 => '头像昵称更新失败',
]; ];
} }
\ No newline at end of file
...@@ -26,6 +26,14 @@ class UserWechatBind extends MysqlBase ...@@ -26,6 +26,14 @@ class UserWechatBind extends MysqlBase
return self::get($columns, $where); return self::get($columns, $where);
} }
public static function getRecordMaster($where, $columns = [])
{
if (empty($columns)) {
$columns = '*';
}
return self::getMaster($columns, $where);
}
public static function getRecords($where, $columns = []) public static function getRecords($where, $columns = [])
{ {
if (empty($columns)) { if (empty($columns)) {
...@@ -34,7 +42,7 @@ class UserWechatBind extends MysqlBase ...@@ -34,7 +42,7 @@ class UserWechatBind extends MysqlBase
return self::select($columns, $where); return self::select($columns, $where);
} }
public static function getRecordMaster($where, $columns = []) public static function getRecordsMaster ($where, $columns = [])
{ {
if (empty($columns)) { if (empty($columns)) {
$columns = '*'; $columns = '*';
......
...@@ -58,7 +58,7 @@ class UserService ...@@ -58,7 +58,7 @@ class UserService
//} //}
$user = UserWechatBind::getRecord(['openid' => $openid]); $user = UserWechatBind::getRecordMaster(['openid' => $openid]);
//如果系统不存在,用户信息,则注册新用户 //如果系统不存在,用户信息,则注册新用户
if (empty($user) && !empty($response)) { if (empty($user) && !empty($response)) {
$insert = [ $insert = [
...@@ -211,10 +211,15 @@ class UserService ...@@ -211,10 +211,15 @@ class UserService
"city" => !empty($params['city']) ? $params['city'] : '', "city" => !empty($params['city']) ? $params['city'] : '',
"language" => !empty($params['language']) ? $params['language'] : '', "language" => !empty($params['language']) ? $params['language'] : '',
]; ];
$user = UserWechatBind::getRecordMaster(['openid' => $params['openid']]);
$bindStatus = UserWechatBind::save($update,['openid' => $params['openid']]); if (empty($user)){
$update['openid'] = $params['openid'];
$bindStatus = UserWechatBind::save($update);
}else{
$bindStatus = UserWechatBind::save($update,['openid' => $params['openid']]);
}
if (!$bindStatus) { if (!$bindStatus) {
throw new UserException(['cus' => 8]); throw new UserException(['cus' => 11]);
} }
return $update; return $update;
} }
......
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