20
This commit is contained in:
+30
-7
@@ -21,8 +21,8 @@ class User extends Command
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this->addOption('user_id','u', InputArgument::OPTIONAL, 'user_id');
|
||||
$this->addOption('action','a', InputArgument::OPTIONAL, '操作类型');
|
||||
$this->addOption('user_id','u', InputOption::VALUE_OPTIONAL, 'user_id');
|
||||
$this->addOption('action','a', InputOption::VALUE_OPTIONAL, '操作类型','test');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +38,28 @@ class User extends Command
|
||||
}
|
||||
cp('操作不存在:'.$action);
|
||||
return 0;
|
||||
}
|
||||
function test(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$user_id = 104864;
|
||||
$_user = Db::name('user')->where('id',$user_id)->find();
|
||||
Db::query('delete FROM `wa_user_team` WHERE descendant_id='.$user_id.' or ancestor_id='.$user_id.';');
|
||||
Hook('user.register_successed',$_user);
|
||||
//管理团队人数
|
||||
// $team_user_ids = Db::name('user_team')->where('descendant_id',$_user['id'])
|
||||
// ->where('depth','>',0)
|
||||
// ->order('depth','ASC')
|
||||
// ->column('ancestor_id');
|
||||
|
||||
// Db::name('user_extend')->whereIn('user_id',$team_user_ids)->data([
|
||||
// 'team_total'=> Db::raw('team_total+1')
|
||||
// ])->save();
|
||||
// $list = Db::name('user_extend')->whereIn('user_id',$team_user_ids)->field('user_id,team_total')->select();
|
||||
// foreach($list as $v){
|
||||
// cache('team_user_count_'.$v['user_id'],$v['team_total']);
|
||||
// }
|
||||
// cp($team_user_ids);
|
||||
return 0;
|
||||
}
|
||||
function login(InputInterface $input, OutputInterface $output){
|
||||
// $IM = new \support\OpenImSdk\Client([
|
||||
@@ -59,19 +80,20 @@ class User extends Command
|
||||
}
|
||||
function build_team(InputInterface $input, OutputInterface $output){
|
||||
$list = Db::name('user')->field('id')->order('id','asc')->select();
|
||||
//$list = [['id'=>100006]];
|
||||
foreach($list as $k=>$user){
|
||||
//team_total
|
||||
$team_user_ids = Db::name('user_team')->where('descendant_id',$user['id'])
|
||||
$team_user_ids = Db::name('user_team')->where('ancestor_id',$user['id'])
|
||||
->where('depth','>',0)
|
||||
->order('depth','ASC')
|
||||
->column('ancestor_id');
|
||||
->column('descendant_id');
|
||||
Db::name('user_extend')->where('user_id',$user['id'])->data([
|
||||
'team_total'=> count($team_user_ids)
|
||||
])->save();
|
||||
cache('team_user_count_'.$user['id'],count($team_user_ids));
|
||||
|
||||
$direct_use_count = Db::name('user')->where('parent_id',$user['id'])->count('id');
|
||||
$vip_user_count = Db::name('user')->whereIn('id',$team_user_ids)->where('role_id','>',0)->count('id');
|
||||
$vip_user_count = Db::name('user')->whereIn('id',$team_user_ids)->where('role_id','>',1)->count('id');
|
||||
|
||||
Db::name('user_extend')->where('user_id',$user['id'])->data([
|
||||
'direct_total'=> $direct_use_count,
|
||||
@@ -80,6 +102,7 @@ class User extends Command
|
||||
cache('team_direct_total_'.$user['id'],$direct_use_count);
|
||||
cache('team_vip_total_'.$user['id'],$vip_user_count);
|
||||
$this->level_up($user['id'],$vip_user_count);
|
||||
cp($user['id'].'完成');
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -87,10 +110,10 @@ class User extends Command
|
||||
protected function level_up($user_id,$count=0){
|
||||
$levels = [
|
||||
0,
|
||||
500,
|
||||
50,
|
||||
100,
|
||||
1000,
|
||||
5000,
|
||||
10000,
|
||||
20000,
|
||||
];
|
||||
$level = 0;
|
||||
|
||||
Reference in New Issue
Block a user