|
|
@@ -2601,18 +2601,26 @@ class User extends BaseController
|
|
2601
|
2601
|
$type = $this->request->param('type');
|
|
2602
|
2602
|
$uid = $this->request->uid();
|
|
2603
|
2603
|
makeLock()->lock();
|
|
|
2604
|
+ Db::startTrans();
|
|
2604
|
2605
|
try {
|
|
2605
|
2606
|
if ($type == 1) {
|
|
2606
|
2607
|
$data = ["wechat_user_id" => 0];
|
|
|
2608
|
+ $user_extract_openid = Db::name('user_extract_openid')->where('uid',$uid)->find();
|
|
|
2609
|
+ if (!empty($user_extract_openid)) {
|
|
|
2610
|
+ Db::name('log')->insert(['data' => '三方授权解绑(' . $uid . ')' . json_encode($user_extract_openid)]);
|
|
|
2611
|
+ Db::name('user_extract_openid')->where('uid', $uid)->delete(); // 使用 Db 对象删除
|
|
|
2612
|
+ }
|
|
2607
|
2613
|
} else {
|
|
2608
|
2614
|
$data = ["ali_user_id" => 0];
|
|
2609
|
2615
|
}
|
|
2610
|
2616
|
$result = $this->repository->updateUser($uid, $data);
|
|
2611
|
2617
|
if (!$result) throw new \Exception("修改失败");
|
|
2612
|
2618
|
} catch (\Throwable $e) {
|
|
|
2619
|
+ Db::rollback();
|
|
2613
|
2620
|
makeLock()->unlock();
|
|
2614
|
2621
|
return app("json")->fail("失败" . $e->getMessage());
|
|
2615
|
2622
|
}
|
|
|
2623
|
+ Db::commit();
|
|
2616
|
2624
|
makeLock()->unlock();
|
|
2617
|
2625
|
return app("json")->success("解绑成功", $data);
|
|
2618
|
2626
|
}
|
|
|
@@ -2639,8 +2647,14 @@ class User extends BaseController
|
|
2639
|
2647
|
if ($type == 1) {
|
|
2640
|
2648
|
$data = ["wechat_user_id" => $openid];
|
|
2641
|
2649
|
$unionId = $openid;
|
|
|
2650
|
+ $check = Db::name('user_extract_openid')->where('openid',$openid)->value('uid');
|
|
|
2651
|
+ if (!empty($check) && $check != $uid){
|
|
|
2652
|
+ throw new \Exception("此微信号已被其他用户绑定");
|
|
|
2653
|
+ }
|
|
2642
|
2654
|
$check = Db::name('user_extract_openid')->where('uid',$uid)->value('openid');
|
|
2643
|
|
- if ($check) throw new \Exception("此微信号已被绑定");
|
|
|
2655
|
+ if (!empty($check) && $check != $openid){
|
|
|
2656
|
+ throw new \Exception("您已绑定其他微信号");
|
|
|
2657
|
+ }
|
|
2644
|
2658
|
} else {
|
|
2645
|
2659
|
$alinfo = json_decode($alinfo, true);
|
|
2646
|
2660
|
if (!$alinfo) throw new \Exception("参数异常");
|