|
@@ -2671,7 +2671,15 @@ class User extends BaseController
|
|
2671
|
$data = ["wechat_user_id" => $openid];
|
2671
|
$data = ["wechat_user_id" => $openid];
|
|
2672
|
$unionId = $openid;
|
2672
|
$unionId = $openid;
|
|
2673
|
$existUid = Db::name('user_extract_openid')->where('openid',$unionId)->value('uid');
|
2673
|
$existUid = Db::name('user_extract_openid')->where('openid',$unionId)->value('uid');
|
|
2674
|
- if (!empty($existUid) && $existUid != $uid) throw new \Exception("此微信号已被绑定");
|
|
|
|
|
|
2674
|
+ if (!empty($existUid) && $existUid != $uid) {
|
|
|
|
2675
|
+ $existUserData = Db::name("user")->where("uid", $existUid)->find();
|
|
|
|
2676
|
+ if ($existUserData['is_del'] != 1) {
|
|
|
|
2677
|
+ throw new \Exception("此微信号已被绑定");
|
|
|
|
2678
|
+ } else {
|
|
|
|
2679
|
+ Db::name('user_extract_openid')->where('openid',$unionId)->delete();
|
|
|
|
2680
|
+ Db::name("user")->where(['uid' => $existUid])->update(["wechat_user_id" => 0]);
|
|
|
|
2681
|
+ }
|
|
|
|
2682
|
+ }
|
|
2675
|
$check = Db::name('user_extract_openid')->where('uid',$uid)->value('openid');
|
2683
|
$check = Db::name('user_extract_openid')->where('uid',$uid)->value('openid');
|
|
2676
|
if (!empty($check)){
|
2684
|
if (!empty($check)){
|
|
2677
|
if ($check != $unionId) throw new \Exception("当前用户已绑定其他微信号");
|
2685
|
if ($check != $unionId) throw new \Exception("当前用户已绑定其他微信号");
|