update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
|
|
@ -46,22 +46,24 @@ class UserCleanUp extends Command
|
|||
{
|
||||
|
||||
$this->info('RUN Command user:cleanup');
|
||||
\Log::channel('cleanup')->info('COMMAND [user:cleanup] started.');
|
||||
|
||||
$this->timeStart = microtime(true);
|
||||
|
||||
$this->deleteInavtiveUsers();
|
||||
//alle inaktive User werden deaktivert, die childs werden dem nächsten aktiven Berater (parent) zugewiesen.
|
||||
$this->cleanUpInActiveUser();
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
//\Log::info('Cron is running');
|
||||
|
||||
\Log::channel('cleanup')->info('COMMAND [user:cleanup] finished.');
|
||||
//return 0;
|
||||
}
|
||||
|
||||
|
||||
//gibt es gelöschte Berater mit Kunden und childs???
|
||||
|
||||
private function deleteInavtiveUsers(){
|
||||
private function deleteInavtiveUsers()
|
||||
{
|
||||
|
||||
$this->info('START Command deleteInavtiveUsers');
|
||||
$count = 0;
|
||||
|
|
@ -69,20 +71,20 @@ class UserCleanUp extends Command
|
|||
$date = Carbon::now()->modify('-2 month');
|
||||
$delete_users = User::where('admin', 0)->where('payment_account', '<', $date)->get();
|
||||
|
||||
foreach($delete_users as $delete_user){
|
||||
foreach ($delete_users as $delete_user) {
|
||||
/*
|
||||
dump('delete_users ---------- ');
|
||||
dump($delete_user->id);
|
||||
dump($delete_user->email);
|
||||
*/
|
||||
//finde nächsten aktiven Sponsor $delete_user->id kann sponsor oder pre sponsor sein
|
||||
$active_sponsor = UserUtil::findNextActiveSponsor($delete_user->id);
|
||||
if($active_sponsor){
|
||||
$active_sponsor = UserUtil::findNextActiveSponsor($delete_user->id);
|
||||
if ($active_sponsor) {
|
||||
//setze alle Berater vom Sponsor für alle childs
|
||||
UserUtil::setNewSponsorToChilds($delete_user->id, $active_sponsor->id);
|
||||
UserUtil::setNewSponsorToChilds($delete_user->id, $active_sponsor->id);
|
||||
UserUtil::setShoppingUserToNewMember($delete_user->id, $active_sponsor->id);
|
||||
}else{
|
||||
\Log::channel('cleanup')->error('deleteInavtiveUsers find no active_sponsor by delete_user_id:'.$delete_user->id);
|
||||
} else {
|
||||
\Log::channel('cleanup')->error('deleteInavtiveUsers find no active_sponsor by delete_user_id:' . $delete_user->id);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
|
|
@ -99,8 +101,8 @@ class UserCleanUp extends Command
|
|||
'm_first_name' => $delete_user->account ? $delete_user->account->m_first_name : '',
|
||||
'm_last_name' => $delete_user->account ? $delete_user->account->m_last_name : '',
|
||||
];
|
||||
$count ++;
|
||||
\Log::channel('cleanup')->info('deleteUser: '.json_encode($data));
|
||||
$count++;
|
||||
\Log::channel('cleanup')->info('deleteUser: ' . json_encode($data));
|
||||
UserUtil::deleteUser($delete_user);
|
||||
}
|
||||
|
||||
|
|
@ -108,52 +110,52 @@ class UserCleanUp extends Command
|
|||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command deleteInavtiveUsers: '.$count. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
|
||||
$this->info('END Command deleteInavtiveUsers: ' . $count . ' | Time: ' . $sec . 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
private function cleanUpInActiveUser(){
|
||||
private function cleanUpInActiveUser()
|
||||
{
|
||||
|
||||
$this->info('START Command cleanUpInActiveUser');
|
||||
$count = 0;
|
||||
|
||||
|
||||
//clean up user where inactive since 2 weeks
|
||||
$date = Carbon::now()->modify('-2 weeks');
|
||||
|
||||
$inactive_users = User::where('active', true)->where('m_sponsor', '!=', null)->where('payment_account', '<', $date)->get();
|
||||
foreach($inactive_users as $inactive_user){
|
||||
foreach ($inactive_users as $inactive_user) {
|
||||
/*
|
||||
dump('inactive_user ---------- ');
|
||||
dump($inactive_user->id);
|
||||
dump($inactive_user->email);
|
||||
*/
|
||||
$active_sponsor = UserUtil::findNextActiveSponsor($inactive_user->m_sponsor);
|
||||
if($active_sponsor){
|
||||
if ($active_sponsor) {
|
||||
UserUtil::setNewSponsorToChilds($inactive_user->id, $active_sponsor->id);
|
||||
}else{
|
||||
\Log::channel('cleanup')->error('cleanUpInActiveUser find no active_sponsor by inactive_user:'.$inactive_user->id);
|
||||
} else {
|
||||
\Log::channel('cleanup')->error('cleanUpInActiveUser find no active_sponsor by inactive_user:' . $inactive_user->id);
|
||||
}
|
||||
/*
|
||||
dump('findNextActiveSponsor');
|
||||
dump($active_sponsor->email);
|
||||
*/
|
||||
$data = [
|
||||
'user_id' => $inactive_user->id,
|
||||
'user_id' => $inactive_user->id,
|
||||
'email' => $inactive_user->email,
|
||||
'm_account' => $inactive_user->account ? $inactive_user->account->m_account : '',
|
||||
'm_first_name' => $inactive_user->account ? $inactive_user->account->m_first_name : '',
|
||||
'm_last_name' => $inactive_user->account ? $inactive_user->account->m_last_name : '',
|
||||
];
|
||||
$count ++;
|
||||
$count++;
|
||||
|
||||
\Log::channel('cleanup')->info('inactive_user: '.json_encode($data));
|
||||
\Log::channel('cleanup')->info('inactive_user: ' . json_encode($data));
|
||||
UserUtil::deactiveUser($inactive_user);
|
||||
}
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command cleanUpInActiveUser: '.$count. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command cleanUpInActiveUser: ' . $count . ' | Time: ' . $sec . 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue