20
This commit is contained in:
+23
-25
@@ -17,12 +17,23 @@ class User{
|
||||
'invite_code' => \support\Encrypt::userIDencode($_user['id']),
|
||||
'userID' => \support\Encrypt::userIDencode($_user['id'])
|
||||
];
|
||||
|
||||
\app\model\User::where('id',$_user['id'])->update($saveData);
|
||||
//创建扩展数据
|
||||
Db::name('user_extend')->replace()->insert([
|
||||
'user_id' => $_user['id'],
|
||||
'consume' => 0,
|
||||
// 'profile_banner' => '',
|
||||
// 'moments_banner' => '',
|
||||
// 'moments_allow_view_days'=>0,
|
||||
]);
|
||||
//管理直推人数和团队人数
|
||||
if($_user['parent_id']){
|
||||
parent_info( $_user['id'],[
|
||||
'id' => $_user['parent_id'],
|
||||
'username' => Db::name('user')->where('id',$_user['parent_id'])->value('username')
|
||||
]);
|
||||
$this->buildTeam($_user);
|
||||
//直属团队人数
|
||||
Db::name('user_extend')->where('user_id',$_user['parent_id'])
|
||||
->data([
|
||||
@@ -31,7 +42,7 @@ class User{
|
||||
cache_add('team_direct_total_'.$_user['parent_id'],1);
|
||||
|
||||
//管理团队人数
|
||||
$team_user_ids = Db::name('user_team')->where('descendant_id',$user['id'])
|
||||
$team_user_ids = Db::name('user_team')->where('descendant_id',$_user['id'])
|
||||
->where('depth','>',0)
|
||||
->order('depth','ASC')
|
||||
->column('ancestor_id');
|
||||
@@ -44,19 +55,6 @@ class User{
|
||||
cache('team_user_count_'.$v['user_id'],$v['team_total']);
|
||||
}
|
||||
}
|
||||
|
||||
\app\model\User::where('id',$_user['id'])->update($saveData);
|
||||
//创建扩展数据
|
||||
Db::name('user_extend')->replace()->insert([
|
||||
'user_id' => $_user['id'],
|
||||
'consume' => 0,
|
||||
// 'profile_banner' => '',
|
||||
// 'moments_banner' => '',
|
||||
// 'moments_allow_view_days'=>0,
|
||||
]);
|
||||
|
||||
|
||||
$this->buildTeam($user);
|
||||
}
|
||||
function login_successed($data=[]){
|
||||
$data = $this->profile($data);
|
||||
@@ -71,10 +69,10 @@ class User{
|
||||
protected function level_up($user_id,$count=0){
|
||||
$levels = [
|
||||
0,
|
||||
500,
|
||||
50,
|
||||
100,
|
||||
1000,
|
||||
5000,
|
||||
10000,
|
||||
20000,
|
||||
];
|
||||
$level = 0;
|
||||
@@ -100,7 +98,7 @@ class User{
|
||||
'userHeadImg' => null,
|
||||
];
|
||||
try {
|
||||
$ff = Db::name('user_extend')->where('user_id',$user->id)->field('moments_allow_view_days,profile_banner,moments_banner')->find();
|
||||
$ff = Db::name('user_extend')->where('user_id',$user['id'])->field('moments_allow_view_days,profile_banner,moments_banner')->find();
|
||||
$data['moments_allow_view_days'] = $ff['moments_allow_view_days'];
|
||||
$data['moments_banner'] = $ff['moments_banner'];
|
||||
$data['profile_banner'] = $ff['profile_banner'];
|
||||
@@ -170,29 +168,29 @@ class User{
|
||||
// 插入自己的团队关系 (自己是自己的后代)
|
||||
$teamData = [
|
||||
[
|
||||
'ancestor_id' => $user->id,
|
||||
'descendant_id' => $user->id,
|
||||
'ancestor_id' => $user['id'],
|
||||
'descendant_id' => $user['id'],
|
||||
'depth' => 0,
|
||||
'status' => 0,
|
||||
]
|
||||
];
|
||||
// 2. 处理团队关系(如果有推荐人)
|
||||
if ($user->parent_id) {
|
||||
if ($user['parent_id']) {
|
||||
|
||||
parent_info( $user->id,[
|
||||
'id' => $user->parent_id,
|
||||
'username' => Db::name('user')->where('id',$user->parent_id)->value('username')
|
||||
parent_info( $user['id'],[
|
||||
'id' => $user['parent_id'],
|
||||
'username' => Db::name('user')->where('id',$user['parent_id'])->value('username')
|
||||
]);
|
||||
// 获取推荐人所有的上级关系,生成新用户的团队关系
|
||||
$ancestors = Db::name('user_team')
|
||||
->where('descendant_id', $user->parent_id)
|
||||
->where('descendant_id', $user['parent_id'])
|
||||
->select();
|
||||
/** @var \app\model\UserTeam $ancestor */
|
||||
// 插入新用户与祖先的关系
|
||||
foreach ($ancestors as $ancestor) {
|
||||
$teamData[] = [
|
||||
'ancestor_id' => $ancestor['ancestor_id'],
|
||||
'descendant_id' => $user->id,
|
||||
'descendant_id' => $user['id'],
|
||||
'depth' => $ancestor['depth'] + 1,
|
||||
'status' => 1, // 默认状态为 0,表示无效
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user