|
|
@@ -1291,6 +1291,10 @@ class User extends BaseController
|
|
1291
|
1291
|
// 需求描述说:更换用户手机号时,同步更新 商户申请表、商户表、商户管理员表
|
|
1292
|
1292
|
$data['phone'] = $this->request->param('phone', null);
|
|
1293
|
1293
|
$sms_code = $this->request->param('sms_code', null);
|
|
|
1294
|
+ $data = array_filter($data, function ($value) {
|
|
|
1295
|
+ return !is_null($value);
|
|
|
1296
|
+ });
|
|
|
1297
|
+
|
|
1294
|
1298
|
if (!empty($data['phone'])) {
|
|
1295
|
1299
|
$changeUserData = $this->repository->getOne(['phone' => $data['phone']]);
|
|
1296
|
1300
|
if (!empty($changeUserData)) {
|
|
|
@@ -2597,20 +2601,29 @@ class User extends BaseController
|
|
2597
|
2601
|
$type = $this->request->param('type');
|
|
2598
|
2602
|
$uid = $this->request->uid();
|
|
2599
|
2603
|
makeLock()->lock();
|
|
|
2604
|
+ Db::startTrans();
|
|
2600
|
2605
|
try {
|
|
|
2606
|
+ $user_data = Db::name("user")->where(['uid' => $uid])->find();
|
|
2601
|
2607
|
if ($type == 1) {
|
|
2602
|
|
- $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
|
+ }
|
|
|
2613
|
+ Db::name("user")->where(['uid' => $uid])->update(["wechat_user_id" => 0]);
|
|
|
2614
|
+ Db::name('user_account')->where('uid', $uid)->where('type', 1)->delete();
|
|
2603
|
2615
|
} else {
|
|
2604
|
|
- $data = ["ali_user_id" => 0];
|
|
|
2616
|
+ Db::name("user")->where(['uid' => $uid])->update(["ali_user_id" => 0]);
|
|
|
2617
|
+ Db::name('user_account')->where('uid', $uid)->where('type', 2)->delete();
|
|
2605
|
2618
|
}
|
|
2606
|
|
- $result = $this->repository->updateUser($uid, $data);
|
|
2607
|
|
- if (!$result) throw new \Exception("修改失败");
|
|
2608
|
2619
|
} catch (\Throwable $e) {
|
|
|
2620
|
+ Db::rollback();
|
|
2609
|
2621
|
makeLock()->unlock();
|
|
2610
|
2622
|
return app("json")->fail("失败" . $e->getMessage());
|
|
2611
|
2623
|
}
|
|
|
2624
|
+ Db::commit();
|
|
2612
|
2625
|
makeLock()->unlock();
|
|
2613
|
|
- return app("json")->success("解绑成功", $data);
|
|
|
2626
|
+ return app("json")->success("解绑成功", []);
|
|
2614
|
2627
|
}
|
|
2615
|
2628
|
|
|
2616
|
2629
|
/**
|
|
|
@@ -2635,8 +2648,14 @@ class User extends BaseController
|
|
2635
|
2648
|
if ($type == 1) {
|
|
2636
|
2649
|
$data = ["wechat_user_id" => $openid];
|
|
2637
|
2650
|
$unionId = $openid;
|
|
|
2651
|
+ $check = Db::name('user_extract_openid')->where('openid',$openid)->value('uid');
|
|
|
2652
|
+ if (!empty($check) && $check != $uid){
|
|
|
2653
|
+ throw new \Exception("此微信号已被其他用户绑定");
|
|
|
2654
|
+ }
|
|
2638
|
2655
|
$check = Db::name('user_extract_openid')->where('uid',$uid)->value('openid');
|
|
2639
|
|
- if ($check) throw new \Exception("此微信号已被绑定");
|
|
|
2656
|
+ if (!empty($check) && $check != $openid){
|
|
|
2657
|
+ throw new \Exception("您已绑定其他微信号");
|
|
|
2658
|
+ }
|
|
2640
|
2659
|
} else {
|
|
2641
|
2660
|
$alinfo = json_decode($alinfo, true);
|
|
2642
|
2661
|
if (!$alinfo) throw new \Exception("参数异常");
|