Free Shipping, Business Levels correction, Products Buying, Fonts

This commit is contained in:
Kevin Adametz 2023-01-25 12:37:29 +01:00
parent 3f2fbd6d5b
commit 0341c9c189
197 changed files with 9161 additions and 329 deletions

View file

@ -0,0 +1,68 @@
<?php
namespace App\Cron;
use App\User;
use App\Models\UserBusiness;
use App\Services\HTMLHelper;
use App\Models\UserCreditItem;
use App\Mail\MailUserLevelUpdate;
use Illuminate\Support\Facades\Mail;
use App\Repositories\CreditRepository;
class UserLevelUpdate
{
private $month;
private $year;
public function __construct($month, $year)
{
$this->month = $month;
$this->year = $year;
}
public function getUserBusinessByMonthYear(){
return UserBusiness::select('user_businesses.*')
->where('user_businesses.month', '=', $this->month)
->where('user_businesses.year', '=', $this->year)
->where('user_businesses.next_qual_user_level', '!=', NULL)
->get();
}
public function makeUserLevelUpdate(UserBusiness $userBusiness, $send_update_mail){
$ret = false;
$nextQualUserLevel = $userBusiness->next_qual_user_level;
if(!isset($nextQualUserLevel['hasUpdated']) && $userBusiness->user){
$userBusiness->user->m_level = $nextQualUserLevel['id'];
$userBusiness->user->save();
$nextQualUserLevel['hasUpdated'] = 1;
$userBusiness->next_qual_user_level = $nextQualUserLevel;
$userBusiness->save();
$ret = $nextQualUserLevel['id'].' '.$nextQualUserLevel['name'];
if($send_update_mail){
self::sendUpdateMail($userBusiness->user, $userBusiness->total_qual_tp, $nextQualUserLevel['name']);
}
}
return $ret;
}
private function sendUpdateMail(User $user, $tp, $to){
$bcc = [];
$email = $user->email;
if(!$email){
if($user->mode === 'test'){
}else{
$email = config('app.checkout_mail');
}
}
if($user->mode === 'test'){
$bcc[] = config('app.checkout_test_mail');
}else{
$bcc[] = config('app.checkout_mail');
}
Mail::to($email)->bcc($bcc)->send(new MailUserLevelUpdate($tp, $to));
}
}