2025-11-07 09:56:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\command;
|
|
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
|
use plugin\admin\app\model\Config;
|
|
|
|
|
use app\model\User as UserModel;
|
|
|
|
|
use support\Request;
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
use support\think\Db;
|
|
|
|
|
use support\Mattermost;
|
|
|
|
|
use app\model\User;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Tongji extends Command
|
|
|
|
|
{
|
|
|
|
|
protected static $defaultName = 'Tongji';
|
|
|
|
|
protected static $defaultDescription = 'Tongji';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function configure()
|
|
|
|
|
{
|
|
|
|
|
$this->addOption('action','a', InputArgument::OPTIONAL, '要做什么操作');
|
|
|
|
|
$this->addOption('user_id','uid', InputArgument::OPTIONAL, 'user_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param InputInterface $input
|
|
|
|
|
* @param OutputInterface $output
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
|
|
{
|
2026-04-06 03:10:44 +08:00
|
|
|
$action = $input->getOption('action');
|
|
|
|
|
if(method_exists($this, $action)){
|
|
|
|
|
return $this->$action($input, $output);
|
|
|
|
|
}
|
|
|
|
|
cp('操作不存在:'.$action);
|
2025-11-07 09:56:20 +08:00
|
|
|
return self::SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 修复充值统计
|
|
|
|
|
*/
|
|
|
|
|
function recharge(InputInterface $input, OutputInterface $output) {
|
|
|
|
|
//购买金额统计
|
|
|
|
|
$recharge = \app\model\Recharge::where('status',\app\enum\RechargeStatus::COMPLETE->value)->select();
|
|
|
|
|
$recharge_result = [];
|
|
|
|
|
$statistics_recharge_times_result = [];
|
|
|
|
|
$user_recharge_total_result = [];
|
|
|
|
|
$team_recharge_total_result = [];
|
|
|
|
|
/**
|
|
|
|
|
* @var \app\model\Recharge $vo
|
|
|
|
|
*/
|
|
|
|
|
foreach($recharge as $vo){
|
|
|
|
|
$date = explode(' ',$vo->created_at)[0];
|
|
|
|
|
$recharge_result[$date] += abs($vo->amount);
|
|
|
|
|
$statistics_recharge_times_result[$date] += 1;
|
|
|
|
|
$user_recharge_total_result[$vo->user_id.''] +=abs($vo->amount);
|
|
|
|
|
$parent_id = get_parent_id($vo->user_id);
|
|
|
|
|
if($parent_id){
|
|
|
|
|
//团队提现统计
|
|
|
|
|
$team_recharge_total_result[$parent_id.''] +=abs($vo->amount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach($recharge_result as $date => $value){
|
|
|
|
|
cache('statistics_recharge_amount_'.$date,$value);
|
|
|
|
|
}
|
|
|
|
|
foreach($statistics_recharge_times_result as $date => $value){
|
|
|
|
|
cache('statistics_recharge_times_'.$date,$value);
|
|
|
|
|
}
|
|
|
|
|
foreach($user_recharge_total_result as $user_id => $value){
|
|
|
|
|
cache('user_recharge_total_'.$user_id,$value);
|
|
|
|
|
}
|
|
|
|
|
foreach($team_recharge_total_result as $user_id => $value){
|
|
|
|
|
cache('team_recharge_total_'.$user_id,$value);
|
|
|
|
|
}
|
|
|
|
|
cp($recharge_result);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 修复提现统计
|
|
|
|
|
*/
|
|
|
|
|
function withdrawl(InputInterface $input, OutputInterface $output) {
|
|
|
|
|
//购买金额统计
|
|
|
|
|
$withdrawl = \app\model\Withdrawl::where('status',\app\enum\WithdrawlStatus::COMPLETE->value)->select();
|
|
|
|
|
$withdrawl_result = [];
|
|
|
|
|
$statistics_withdrawl_times_result = [];
|
|
|
|
|
$user_withdrawl_total_result = [];
|
|
|
|
|
$team_withdrawl_total_result = [];
|
|
|
|
|
/**
|
|
|
|
|
* @var \app\model\Withdrawl $vo
|
|
|
|
|
*/
|
|
|
|
|
foreach($withdrawl as $vo){
|
|
|
|
|
$date = explode(' ',$vo->created_at)[0];
|
|
|
|
|
$withdrawl_result[$date] += abs($vo->recive_amount);
|
|
|
|
|
$statistics_withdrawl_times_result[$date] += 1;
|
|
|
|
|
$user_withdrawl_total_result[$vo->user_id.''] +=abs($vo->recive_amount);
|
|
|
|
|
$parent_id = get_parent_id($vo->user_id);
|
|
|
|
|
if($parent_id){
|
|
|
|
|
//团队提现统计
|
|
|
|
|
$team_withdrawl_total_result[$parent_id.''] +=abs($vo->recive_amount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach($withdrawl_result as $date => $value){
|
|
|
|
|
cache('statistics_withdrawl_amount_'.$date,$value);
|
|
|
|
|
}
|
|
|
|
|
foreach($statistics_withdrawl_times_result as $date => $value){
|
|
|
|
|
cache('statistics_withdrawl_times_'.$date,$value);
|
|
|
|
|
}
|
|
|
|
|
foreach($user_withdrawl_total_result as $user_id => $value){
|
|
|
|
|
cache('user_withdrawl_total_'.$user_id,$value);
|
|
|
|
|
}
|
|
|
|
|
foreach($team_withdrawl_total_result as $user_id => $value){
|
|
|
|
|
cache('team_withdrawl_total_'.$user_id,$value);
|
|
|
|
|
}
|
|
|
|
|
cp($withdrawl_result);
|
|
|
|
|
}
|
|
|
|
|
/**
|
2026-04-06 03:10:44 +08:00
|
|
|
* 修复团队统计数据
|
|
|
|
|
* @param InputInterface $input
|
|
|
|
|
* @param OutputInterface $output
|
|
|
|
|
* @return int
|
2025-11-07 09:56:20 +08:00
|
|
|
*/
|
2026-04-06 03:10:44 +08:00
|
|
|
function build_team(InputInterface $input, OutputInterface $output){
|
|
|
|
|
$list = Db::name('user')->order('id','asc')->column('id');
|
|
|
|
|
//$list = [['id'=>100006]];
|
|
|
|
|
foreach($list as $k=>$user_id){
|
|
|
|
|
//team_total
|
|
|
|
|
$team_user_ids = Db::name('user_team')->where('ancestor_id',$user_id)
|
|
|
|
|
->where('depth','>',0)
|
|
|
|
|
->order('depth','ASC')
|
|
|
|
|
->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','>',1)->count('id');
|
|
|
|
|
|
|
|
|
|
Db::name('user_extend')->where('user_id',$user_id)->data([
|
|
|
|
|
'direct_total'=> $direct_use_count,
|
|
|
|
|
'vip_total'=> $vip_user_count
|
|
|
|
|
])->save();
|
|
|
|
|
cache('team_direct_total_'.$user_id,$direct_use_count);
|
|
|
|
|
cache('team_vip_total_'.$user_id,$vip_user_count);
|
|
|
|
|
update_user_level($user_id,$vip_user_count);
|
|
|
|
|
cp($user_id.'完成');
|
2025-11-07 09:56:20 +08:00
|
|
|
}
|
2026-04-06 03:10:44 +08:00
|
|
|
|
|
|
|
|
return self::SUCCESS;
|
2025-11-07 09:56:20 +08:00
|
|
|
}
|
|
|
|
|
}
|