Cron Jobs, Reminder, Fonts, Members / Wizard / Price, Credit and Promotion
This commit is contained in:
parent
a0f4eda6ea
commit
6167273a48
204 changed files with 8746 additions and 215 deletions
120
app/Console/Commands/PaymentsAccounts.php
Normal file
120
app/Console/Commands/PaymentsAccounts.php
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Cron\UserCheckPaymentsAccounts;
|
||||
|
||||
class PaymentsAccounts extends Command
|
||||
{
|
||||
/**
|
||||
* ln -sfv /usr/bin/php73 /usr/bin/php
|
||||
* php artisan payments:accounts
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'payments:accounts';
|
||||
protected $description = 'Check Payments Accounts';
|
||||
|
||||
private $timeStart;
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('RUN Command Payments Account: '.date('d.m.Y H:i'));
|
||||
$this->timeStart = microtime(true);
|
||||
|
||||
$this->updateUserNextLevel();
|
||||
$this->updatePaymentsAccountsFree();
|
||||
$this->reminderPaymentsAccounts();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
private function updateUserNextLevel(){
|
||||
// now date - renewal_days
|
||||
$count = 0;
|
||||
$renewalDate = Carbon::now()->modify('+'.(config('main.renewal_days')).' days');
|
||||
$users = User::where('payment_account', '!=', NULL)
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $renewalDate)
|
||||
->whereColumn('m_level', '!=', 'next_m_level')
|
||||
->get();
|
||||
|
||||
foreach($users as $user){
|
||||
$user->m_level = $user->next_m_level;
|
||||
$user->save();
|
||||
$count ++;
|
||||
}
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
$this->info('END Command updateUserNextLevel: '.$count.' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
|
||||
private function updatePaymentsAccountsFree(){
|
||||
// now date - renewal_days -1 / user_levels.payment_year false is no payment
|
||||
$count = 0;
|
||||
$renewalDate = Carbon::now()->modify('+'.(config('main.renewal_days')-1).' days');
|
||||
$users = User::join('user_levels', 'm_level', '=', 'user_levels.id')->select('users.*')
|
||||
->where('users.payment_account', '!=', NULL)
|
||||
->where('users.active', '=', 1)
|
||||
->where('users.blocked', '!=', 1)
|
||||
->where('users.payment_account', '<', $renewalDate)
|
||||
->where('user_levels.payment_year', '=', 0)
|
||||
->get();
|
||||
|
||||
foreach($users as $user){
|
||||
$user->payment_account = Carbon::parse($user->payment_account)->modify('1 year');
|
||||
$user->save();
|
||||
$count ++;
|
||||
}
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
$this->info('END Command updatePaymentsAccountsFree: '.$count.' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
private function reminderPaymentsAccounts()
|
||||
{
|
||||
|
||||
$count = 0;
|
||||
$max_reminder_date = Carbon::now()->modify('+'.(config('main.remind_first_days')).' days');
|
||||
$users = User::where('payment_account', '!=', NULL)
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $max_reminder_date)
|
||||
->get();
|
||||
|
||||
foreach ($users as $user){
|
||||
$status = UserCheckPaymentsAccounts::userReminderPayments($user);
|
||||
$this->info('reminderPaymentsAccounts Status: '.$status.' | User: '.$user->id.' '.$user->email.' | Date :' . $user->getPaymentAccountDateFormat() . "");
|
||||
$count ++;
|
||||
}
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
$this->info('END Command reminderPaymentsAccounts: '.$count.' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -24,8 +24,10 @@ class Kernel extends ConsoleKernel
|
|||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
$schedule->command('payments:accounts')
|
||||
->sendOutputTo("cron.log");
|
||||
//->hourly();
|
||||
// ->emailOutputTo('kevin@adametz.media');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue