Free Shipping, Business Levels correction, Products Buying, Fonts
This commit is contained in:
parent
3f2fbd6d5b
commit
0341c9c189
197 changed files with 9161 additions and 329 deletions
|
|
@ -5,10 +5,13 @@ namespace App\Console\Commands;
|
|||
use App\Models\Setting;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Cron\BusinessUsersStore;
|
||||
use App\Cron\UserLevelUpdate;
|
||||
use App\Cron\UserPaymentCredits;
|
||||
|
||||
class BusinessStore extends Command
|
||||
{
|
||||
/**
|
||||
* ln -sfv /usr/bin/php73 /usr/bin/php
|
||||
* php artisan business:store month year
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
|
|
@ -23,6 +26,15 @@ class BusinessStore extends Command
|
|||
*/
|
||||
protected $description = 'Create Business Structur and UserDetails';
|
||||
|
||||
private $timeStart;
|
||||
private $month;
|
||||
private $year;
|
||||
|
||||
private $sendCreditMail = false;
|
||||
private $sendUpdateMail = true;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
|
|
@ -40,39 +52,139 @@ class BusinessStore extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
$day = (int) Setting::getContentBySlug('day-exectute-business-structur');
|
||||
$this->info('RUN Command BusinessStore on Day '. $day);
|
||||
$executeDay = (int) Setting::getContentBySlug('day-exectute-business-structur');
|
||||
$this->info('RUN Command BusinessStore on Day: '. $executeDay);
|
||||
|
||||
$timeStart = microtime(true);
|
||||
$this->info('RUN Command BusinessStore');
|
||||
$presentDay = (int) date('d');
|
||||
$this->info('RUN Command BusinessStore present Day: '. $presentDay);
|
||||
|
||||
$month = $this->argument('month');
|
||||
$year = $this->argument('year');
|
||||
if(!$month || !$year){
|
||||
$this->info('need arguments month & year');
|
||||
if($executeDay !== $presentDay){
|
||||
$this->info('NOT RUN Command BusinessStore is not present Day: '. $presentDay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//$this->info('month: '.$month.' year:'.$year);
|
||||
for($i = 1; $i<=6; $i++){
|
||||
$this->timeStart = microtime(true);
|
||||
//$this->info('RUN Command BusinessStore');
|
||||
$this->month = $this->argument('month');
|
||||
$this->year = $this->argument('year');
|
||||
|
||||
|
||||
if(!$this->month || !$this->year){
|
||||
$this->month = (int) date("m", strtotime("-1 month", time()));
|
||||
$this->year = (int) date("Y", strtotime("-1 month", time()));
|
||||
}
|
||||
|
||||
$this->info('RUN Command BusinessStore on month: '.$this->month.' | year: '.$this->year);
|
||||
|
||||
//erstellt die Business Struktur und die Details
|
||||
$this->storeBusinessStructureUsersDetailMonth();
|
||||
|
||||
//Struktur und die Details für mehrere Montate for / to month
|
||||
//$this->storeBusinessStructureUsersDetailPeriod(1, 6);
|
||||
|
||||
//erstellt die Gutschriften
|
||||
//$this->userBusinessCommissionsToCredit();
|
||||
|
||||
//erstellt aus den Gutschriften die PDFs
|
||||
//$this->userCreatePaymentCreditsPDF();
|
||||
|
||||
//update user Level
|
||||
//$this->userLevelUpdate();
|
||||
return 0;
|
||||
|
||||
//\Log::info('Cron is running');
|
||||
//return 0;
|
||||
}
|
||||
|
||||
private function storeBusinessStructureUsersDetailMonth(){
|
||||
|
||||
$this->info('storeBusinessStructureUsersDetailMonth month: '.$this->month.' year:'.$this->year);
|
||||
$businessUsersStore = new BusinessUsersStore($this->month, $this->year);
|
||||
$businessUsersStore->storeUserBusinessStructure();
|
||||
$businessUsersStore->storeBusinessUsersDetail();
|
||||
$bool = $businessUsersStore->storeBusinessCompleted();
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command storeBusinessStructureUsersDetailMonth: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
private function userBusinessCommissionsToCredit(){
|
||||
|
||||
$this->info('userBusinessCommissionsToCredit month: '.$this->month.' year:'.$this->year);
|
||||
$userPaymentCredits = new UserPaymentCredits($this->month, $this->year);
|
||||
$userBusinesses = $userPaymentCredits->getUserBusinessByMonthYear();
|
||||
|
||||
foreach($userBusinesses as $userBusiness){
|
||||
$ret = $userPaymentCredits->addUserCreditItem($userBusiness);
|
||||
$this->info('userBusinessCredit: '.$ret->user_id.' : Team: '.$ret->commission_team_total.' | Shop: '.$ret->commission_shop_sales);
|
||||
}
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command userBusinessCommissionsToCredit: | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
private function userCreatePaymentCreditsPDF(){
|
||||
|
||||
$this->info('userCreatePaymentCreditsPDF month: '.$this->month.' year:'.$this->year);
|
||||
$userPaymentCredits = new UserPaymentCredits($this->month, $this->year);
|
||||
$creditItemUsers = $userPaymentCredits->getUserCreditItemUsersByMonthYear();
|
||||
|
||||
foreach($creditItemUsers as $creditItemUser){
|
||||
$bool = $userPaymentCredits->makeCreditPaymentPDF($creditItemUser->user_id, $this->sendCreditMail);
|
||||
$this->info('creditsPDF: '.$bool.' user_id: '.$creditItemUser->user_id);
|
||||
}
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command userCreatePaymentCreditsPDF: | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
private function userLevelUpdate(){
|
||||
|
||||
$this->info('userLevelUpdate month: '.$this->month.' year:'.$this->year);
|
||||
|
||||
$userLevelUpdate = new UserLevelUpdate($this->month, $this->year);
|
||||
$levelUpdateUsers = $userLevelUpdate->getUserBusinessByMonthYear();
|
||||
|
||||
foreach($levelUpdateUsers as $userBusiness){
|
||||
$ret = $userLevelUpdate->makeUserLevelUpdate($userBusiness, $this->sendUpdateMail);
|
||||
if($ret){
|
||||
$this->info('updateLevel: '.$userBusiness->user->id.' | '.$userBusiness->user->email.' | '.
|
||||
'from: '.$userBusiness->m_level_id.' '.$userBusiness->user_level_name.' | '.
|
||||
'to: '.$ret);
|
||||
}
|
||||
|
||||
}
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command userLevelUpdate: | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
|
||||
private function storeBusinessStructureUsersDetailPeriod($for, $to){
|
||||
for($i = $for; $i<=$to; $i++){
|
||||
$month = $i;
|
||||
$this->info('month: '.$month.' year:'.$year);
|
||||
$businessUsersStore = new BusinessUsersStore($month, $year);
|
||||
$this->info('Store Business Structure Users Detail month: '.$month.' year:'.$this->year);
|
||||
$businessUsersStore = new BusinessUsersStore($month, $this->year);
|
||||
$businessUsersStore->storeUserBusinessStructure();
|
||||
$businessUsersStore->storeBusinessUsersDetail();
|
||||
$bool = $businessUsersStore->storeBusinessCompleted();
|
||||
|
||||
$diff = microtime(true) - $timeStart;
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
$this->info('BusinessStore: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
$this->info('Period BusinessStore: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//$this->info('END Command BusinessStore: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
|
||||
// \Log::info('Cron is running');
|
||||
//return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue