|
@@ -98,7 +98,7 @@ class Base
|
|
|
if (isset($data['unionid']) && $data['unionid']) {
|
|
|
$wechat['unionid'] = $data['unionid'];
|
|
|
# 判断用户是否存在,是否需要合并
|
|
|
- $wechat['uid'] = $this->combine($uid, $data['unionid']);
|
|
|
+ //$wechat['uid'] = $this->combine($uid, $data['unionid']);
|
|
|
}
|
|
|
|
|
|
$wechat['access_token'] = $data['access_token'];
|
|
@@ -111,7 +111,7 @@ class Base
|
|
|
$wechat['system_id'] = $system;
|
|
|
}
|
|
|
$id = $info['id'];
|
|
|
- Dever::db('passport/wechat')->update($wechat);
|
|
|
+ //Dever::db('passport/wechat')->update($wechat);
|
|
|
|
|
|
$user['where_id'] = $uid;
|
|
|
//Dever::load('passport/user-update', $user);
|
|
@@ -195,7 +195,7 @@ class Base
|
|
|
if ($col == 'mobile' || $col == 'id') {
|
|
|
$user_wechat = Dever::load('passport/user-all', array($col => $unionid));
|
|
|
} else {
|
|
|
- $user_wechat = Dever::load('passport/wechat-state', array($col => $unionid));
|
|
|
+ $user_wechat = Dever::load('passport/wechat-getByUnionid', array($col => $unionid));
|
|
|
}
|
|
|
|
|
|
if ($user_wechat) {
|
|
@@ -213,26 +213,23 @@ class Base
|
|
|
$user = $v;
|
|
|
} else {
|
|
|
$user = Dever::db('passport/user')->one($v['uid']);
|
|
|
+ $user['uid'] = $user['id'];
|
|
|
}
|
|
|
|
|
|
if (!$new) {
|
|
|
if ($user['bind'] == 1 && !strstr($user['username'], '****')) {
|
|
|
- $new = $v['uid'];
|
|
|
+ $new = $user;
|
|
|
} elseif ($user['temp'] == 2 && $user['source_type'] == 'applet') {
|
|
|
- $new = $v['uid'];
|
|
|
+ $new = $user;
|
|
|
} elseif ($user['avatar']) {
|
|
|
- $new = $v['uid'];
|
|
|
+ $new = $user;
|
|
|
} elseif ($user['mobile']) {
|
|
|
- $new = $v['uid'];
|
|
|
- } elseif ($user['temp'] == 2) {
|
|
|
- $new = $v['uid'];
|
|
|
- } elseif ($v['uid'] < $cur) {
|
|
|
- $cur = $new = $v['uid'];
|
|
|
+ $new = $user;
|
|
|
} else {
|
|
|
- $drop[$v['uid']] = $v['uid'];
|
|
|
+ $drop[$user['uid']] = $user;
|
|
|
}
|
|
|
} else {
|
|
|
- $drop[$v['uid']] = $v['uid'];
|
|
|
+ $drop[$user['uid']] = $user;
|
|
|
}
|
|
|
}
|
|
|
$cur = $new;
|
|
@@ -241,59 +238,75 @@ class Base
|
|
|
print_r($cur);
|
|
|
print_r($drop);die;
|
|
|
}
|
|
|
- $new = Dever::db('passport/user')->one($cur);
|
|
|
- if ($drop) {
|
|
|
- foreach ($drop as $k => $v) {
|
|
|
- if ($cur == $v) {
|
|
|
- unset($drop[$k]);
|
|
|
- continue;
|
|
|
- }
|
|
|
- $old = Dever::db('passport/user')->one($v);
|
|
|
|
|
|
- $update = array();
|
|
|
- if ($new['temp'] == 1) {
|
|
|
- $update['username'] = $old['username'];
|
|
|
- }
|
|
|
+ # 异步处理
|
|
|
+ $this->updateCombine($cur, $drop);
|
|
|
|
|
|
- if (strstr($new['username'], '****')) {
|
|
|
- $update['username'] = $old['username'];
|
|
|
- }
|
|
|
+ $cur = $new['uid'];
|
|
|
+ }
|
|
|
|
|
|
- if (!$new['avatar']) {
|
|
|
- $update['avatar'] = $old['avatar'];
|
|
|
- }
|
|
|
+ return $cur;
|
|
|
+ }
|
|
|
|
|
|
- if (!$new['mobile']) {
|
|
|
- $update['mobile'] = $old['mobile'];
|
|
|
- }
|
|
|
+ private function updateCombine($new, $drop)
|
|
|
+ {
|
|
|
+ # 队列
|
|
|
+ //Dever::queue();
|
|
|
+ if (isset($drop[$new['uid']])) {
|
|
|
+ unset($drop[$new['uid']]);
|
|
|
+ }
|
|
|
+ $drops = array();
|
|
|
+ if ($drop) {
|
|
|
+ foreach ($drop as $k => $v) {
|
|
|
+ $drops[] = $k;
|
|
|
+ $update = array();
|
|
|
+ if (!$new['username'] && $v['username']) {
|
|
|
+ $update['username'] = $v['username'];
|
|
|
+ } elseif (strstr($new['username'], '****') && $v['username']) {
|
|
|
+ $update['username'] = $v['username'];
|
|
|
+ }
|
|
|
|
|
|
- if (!$new['area']) {
|
|
|
- $update['area'] = $old['area'];
|
|
|
- }
|
|
|
+ if (!$new['avatar'] && $v['avatar']) {
|
|
|
+ $update['avatar'] = $v['avatar'];
|
|
|
+ }
|
|
|
|
|
|
- if (isset($update) && $update) {
|
|
|
- $update['where_id'] = $cur;
|
|
|
- Dever::load('passport/user-update', $update);
|
|
|
- }
|
|
|
+ if (!$new['mobile'] && $v['mobile']) {
|
|
|
+ $update['mobile'] = $v['mobile'];
|
|
|
}
|
|
|
|
|
|
- if ($drop) {
|
|
|
- ksort($drop);
|
|
|
- $combine = array();
|
|
|
- $combine['status'] = 1;
|
|
|
- $combine['new_uid'] = $cur;
|
|
|
- $combine['old_uid'] = implode(',', $drop);
|
|
|
- $info = Dever::db('passport/combine')->one($combine);
|
|
|
- if (!$info) {
|
|
|
- Dever::db('passport/combine')->insert($combine);
|
|
|
- }
|
|
|
+ if (!$new['area'] && $v['area']) {
|
|
|
+ $update['area'] = $v['area'];
|
|
|
+ }
|
|
|
|
|
|
- Dever::load('passport/user-updates', array('set_state' => 2, 'where_id' => $combine['old_uid']));
|
|
|
+ if (isset($update) && $update) {
|
|
|
+ $update['where_id'] = $new['uid'];
|
|
|
+ //Dever::load('passport/user-update', $update);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if ($drops) {
|
|
|
+ asort($drops);
|
|
|
+ $drop_uid = implode(',', $drops);
|
|
|
+ Dever::load('passport/lib/base.handleCombine?new_uid=' . $new['uid'] . '&old_uid=' . $drop_uid);
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- return $cur;
|
|
|
+ public function handleCombine()
|
|
|
+ {
|
|
|
+ $combine = array();
|
|
|
+ $combine['status'] = 1;
|
|
|
+ $combine['new_uid'] = Dever::input('new_uid');
|
|
|
+ $combine['old_uid'] = Dever::input('old_uid');
|
|
|
+
|
|
|
+ $info = Dever::db('passport/combine')->one($combine);
|
|
|
+ if (!$info) {
|
|
|
+ Dever::db('passport/combine')->insert($combine);
|
|
|
+ }
|
|
|
+
|
|
|
+ Dever::load('passport/user-updates', array('set_state' => 2, 'where_id' => $combine['old_uid']));
|
|
|
+
|
|
|
+ Dever::load('passport/wechat-updates', array('set_uid' => $combine['new_uid'], 'where_uid' => $combine['old_uid']));
|
|
|
}
|
|
|
|
|
|
/**
|