last changes since 6-2023
This commit is contained in:
parent
0341c9c189
commit
04d677d37a
142 changed files with 7895 additions and 2855 deletions
|
|
@ -31,7 +31,7 @@ class BusinessStore extends Command
|
|||
private $year;
|
||||
|
||||
private $sendCreditMail = false;
|
||||
private $sendUpdateMail = true;
|
||||
private $sendUpdateMail = false;
|
||||
|
||||
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ class BusinessStore extends Command
|
|||
//$this->storeBusinessStructureUsersDetailPeriod(1, 6);
|
||||
|
||||
//erstellt die Gutschriften
|
||||
//$this->userBusinessCommissionsToCredit();
|
||||
$this->userBusinessCommissionsToCredit();
|
||||
|
||||
//erstellt aus den Gutschriften die PDFs
|
||||
//$this->userCreatePaymentCreditsPDF();
|
||||
|
|
@ -119,7 +119,7 @@ class BusinessStore extends Command
|
|||
|
||||
foreach($userBusinesses as $userBusiness){
|
||||
$ret = $userPaymentCredits->addUserCreditItem($userBusiness);
|
||||
$this->info('userBusinessCredit: '.$ret->user_id.' : Team: '.$ret->commission_team_total.' | Shop: '.$ret->commission_shop_sales);
|
||||
$this->info('userBusinessCredit: '.$ret->user_id.' : Team: '.$ret->commission_pp_total.' | Shop: '.$ret->commission_shop_sales);
|
||||
}
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
|
|
|
|||
|
|
@ -47,17 +47,20 @@ class BusinessUsersStore
|
|||
}
|
||||
foreach($this->user_business_structure->users as $user_id=>$completed){
|
||||
if($completed === 0){
|
||||
$user = User::findOrFail($user_id);
|
||||
$TreeCalcBot = new TreeCalcBot($this->month, $this->year, 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
abort(403, 'not found TreeCalcBot->business_user');
|
||||
$user = User::find($user_id);
|
||||
if($user){
|
||||
$TreeCalcBot = new TreeCalcBot($this->month, $this->year, 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
abort(403, 'not found TreeCalcBot->business_user');
|
||||
}
|
||||
$this->storeBusinesslUser($TreeCalcBot->business_user);
|
||||
$users = $this->user_business_structure->users;
|
||||
$users[$user_id] = 1;
|
||||
$this->user_business_structure->users = $users;
|
||||
$this->user_business_structure->save();
|
||||
}
|
||||
$this->storeBusinesslUser($TreeCalcBot->business_user);
|
||||
$users = $this->user_business_structure->users;
|
||||
$users[$user_id] = 1;
|
||||
$this->user_business_structure->users = $users;
|
||||
$this->user_business_structure->save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class UserLevelUpdate
|
|||
$userBusiness->save();
|
||||
$ret = $nextQualUserLevel['id'].' '.$nextQualUserLevel['name'];
|
||||
if($send_update_mail){
|
||||
self::sendUpdateMail($userBusiness->user, $userBusiness->total_qual_tp, $nextQualUserLevel['name']);
|
||||
self::sendUpdateMail($userBusiness->user, $userBusiness->total_qual_pp, $nextQualUserLevel['name']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class UserPaymentCredits
|
|||
->where('user_businesses.month', '=', $this->month)
|
||||
->where('user_businesses.year', '=', $this->year)
|
||||
->where(function($q) {
|
||||
return $q->where('user_businesses.commission_team_total', '>', 0)
|
||||
return $q->where('user_businesses.commission_pp_total', '>', 0)
|
||||
->orWhere('user_businesses.commission_shop_sales', '>', 0);
|
||||
})
|
||||
->get();
|
||||
|
|
@ -46,17 +46,28 @@ class UserPaymentCredits
|
|||
]);
|
||||
}
|
||||
}
|
||||
if($userBusiness->commission_team_total > 0){
|
||||
if($userBusiness->commission_pp_total > 0){
|
||||
if($this->hasNotUserCreditItem($userBusiness, 2)){
|
||||
UserCreditItem::create([
|
||||
'user_id' => $userBusiness->user_id,
|
||||
'user_business_id' => $userBusiness->id,
|
||||
'credit' => $userBusiness->commission_team_total,
|
||||
'message' => 'Provision Team '.$date,
|
||||
'credit' => $userBusiness->commission_pp_total,
|
||||
'message' => 'Provision Payline '.$date,
|
||||
'status' => 2,
|
||||
]);
|
||||
}
|
||||
}
|
||||
if($userBusiness->commission_growth_total > 0){
|
||||
if($this->hasNotUserCreditItem($userBusiness, 5)){
|
||||
UserCreditItem::create([
|
||||
'user_id' => $userBusiness->user_id,
|
||||
'user_business_id' => $userBusiness->id,
|
||||
'credit' => $userBusiness->commission_growth_total,
|
||||
'message' => 'Provision Wachstumsbonus '.$date,
|
||||
'status' => 5,
|
||||
]);
|
||||
}
|
||||
}
|
||||
return $userBusiness;
|
||||
|
||||
}
|
||||
|
|
@ -74,7 +85,7 @@ class UserPaymentCredits
|
|||
$user = User::findOrFail($user_id);
|
||||
$data = [];
|
||||
if($credit_send_mail){
|
||||
$data['credit_send_mail'] = true;
|
||||
$data['credit_send_mail'] = false;
|
||||
}
|
||||
$credit_repo = new CreditRepository($user);
|
||||
return $credit_repo->create($data);
|
||||
|
|
|
|||
33
app/Exports/UserTeamExport.php
Normal file
33
app/Exports/UserTeamExport.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
namespace App\Exports;
|
||||
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\Exportable;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
|
||||
class UserTeamExport implements FromCollection, WithHeadings
|
||||
{
|
||||
protected $collection;
|
||||
protected $headings;
|
||||
|
||||
use Exportable;
|
||||
|
||||
|
||||
public function __construct($data,$header)
|
||||
{
|
||||
$this->collection = $data;
|
||||
$this->headings = $header;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->collection);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [$this->headings];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ class BusinessCommissionController extends Controller
|
|||
|
||||
if(intval(Request::get('commissions_filter_show')) === 1){
|
||||
$query->where(function($q) {
|
||||
return $q->where('user_businesses.commission_team_total', '>', 0)
|
||||
return $q->where('user_businesses.commission_pp_total', '>', 0)
|
||||
->orWhere('user_businesses.commission_shop_sales', '>', 0);
|
||||
});
|
||||
}
|
||||
|
|
@ -113,15 +113,15 @@ class BusinessCommissionController extends Controller
|
|||
|
||||
|
||||
->addColumn('commission_total', function (UserBusiness $UserBusiness) {
|
||||
$commission_total = $UserBusiness->commission_team_total + $UserBusiness->commission_shop_sales;
|
||||
$commission_total = $UserBusiness->commission_pp_total + $UserBusiness->commission_shop_sales;
|
||||
return $commission_total > 0 ?
|
||||
'<span class="badge badge-outline-info">'.formatNumber($commission_total).' €</span>'
|
||||
: $commission_total.' €';
|
||||
})
|
||||
->addColumn('commission_team_total', function (UserBusiness $UserBusiness) {
|
||||
return $UserBusiness->commission_team_total > 0 ?
|
||||
'<span class="badge badge-outline-success">'.formatNumber($UserBusiness->commission_team_total).' €</span>'
|
||||
: $UserBusiness->commission_team_total.' €';
|
||||
->addColumn('commission_pp_total', function (UserBusiness $UserBusiness) {
|
||||
return $UserBusiness->commission_pp_total > 0 ?
|
||||
'<span class="badge badge-outline-success">'.formatNumber($UserBusiness->commission_pp_total).' €</span>'
|
||||
: $UserBusiness->commission_pp_total.' €';
|
||||
})
|
||||
->addColumn('commission_shop_sales', function (UserBusiness $UserBusiness) {
|
||||
return $UserBusiness->commission_shop_sales > 0 ?
|
||||
|
|
@ -157,13 +157,13 @@ class BusinessCommissionController extends Controller
|
|||
})*/
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('commission_team_total', 'commission_team_total $1')
|
||||
->orderColumn('commission_pp_total', 'commission_pp_total $1')
|
||||
->orderColumn('commission_shop_sales', 'commission_shop_sales $1')
|
||||
->orderColumn('email', 'users.email $1')
|
||||
->orderColumn('m_account', 'm_account $1')
|
||||
->orderColumn('first_name', 'first_name $1')
|
||||
->orderColumn('last_name', 'last_name $1')
|
||||
->rawColumns(['id', 'commission_total', 'commission_team_total', 'commission_shop_sales', 'active_account'])
|
||||
->rawColumns(['id', 'commission_total', 'commission_pp_total', 'commission_shop_sales', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +60,6 @@ class BusinessController extends Controller
|
|||
$data = [];
|
||||
$data['month'] = session('business_user_filter_month');
|
||||
$data['year'] = session('business_user_filter_year');
|
||||
|
||||
$TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
|
|
@ -117,7 +116,7 @@ class BusinessController extends Controller
|
|||
$this->year = Request::get('business_user_filter_year');
|
||||
|
||||
//only the currently month get from Users -> older month from UserBusiness
|
||||
//return $this->userCurrentlyDatatable();
|
||||
return $this->userCurrentlyDatatable();
|
||||
if(TreeCalcBot::isFromStored($this->month, $this->year)){
|
||||
return $this->userStoredDatatable();
|
||||
}else{
|
||||
|
|
@ -155,8 +154,8 @@ class BusinessController extends Controller
|
|||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>';
|
||||
//.'<a href="' . route('admin_business_user_detail', [$userBusiness->user_id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="far fa-calculator"></span></a>';
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button>'.
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$userBusiness->user_id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
})
|
||||
->addColumn('m_account', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->m_account;
|
||||
|
|
@ -167,13 +166,13 @@ class BusinessController extends Controller
|
|||
->addColumn('is_qual_kp', function (UserBusiness $userBusiness) {
|
||||
if($userBusiness->m_level_id){
|
||||
$isQualKP = ($userBusiness->sales_volume_points_sum >= $userBusiness->qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KD '.$userBusiness->qual_kp.'</span>';
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KP '.$userBusiness->qual_kp.'</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_points', function (UserBusiness $userBusiness) {
|
||||
->addColumn('sales_volume_KP_points', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.$userBusiness->sales_volume_points_sum.'</div>'.
|
||||
'<span class="small no-line-break">E: '.$userBusiness->sales_volume_points.' | S: '.$userBusiness->sales_volume_points_shop.'</span>';
|
||||
'<span class="small no-line-break">E: '.$userBusiness->sales_volume_KP_points.' | S: '.$userBusiness->sales_volume_points_shop.'</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.formatNumber($userBusiness->sales_volume_total_sum).' €</div>'.
|
||||
|
|
@ -199,7 +198,7 @@ class BusinessController extends Controller
|
|||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button><br>';
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button><br>';
|
||||
|
||||
$sponsor .= '<span class="small no-line-break">'.$userBusiness->sponsor->email;
|
||||
$sponsor .= ' | '.$userBusiness->sponsor->m_account;
|
||||
|
|
@ -246,7 +245,7 @@ class BusinessController extends Controller
|
|||
->orderColumn('first_name', 'first_name $1')
|
||||
->orderColumn('last_name', 'last_name $1')
|
||||
->orderColumn('active_account', 'payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
|
@ -289,8 +288,8 @@ class BusinessController extends Controller
|
|||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>';
|
||||
//.'<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-sm btn-info"><span class="far fa-calculator"></span></a>';
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button>'.
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
})
|
||||
->addColumn('m_account', function (User $user) {
|
||||
return $user->account ? $user->account->m_account : '';
|
||||
|
|
@ -301,15 +300,15 @@ class BusinessController extends Controller
|
|||
->addColumn('is_qual_kp', function (User $user) {
|
||||
if($user->user_level){
|
||||
$qual_kp = $user->user_level->qual_kp;
|
||||
$sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum');
|
||||
$sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum');
|
||||
$isQualKP = ($sales_volume_points_sum >= $qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KD '.$qual_kp.'</span>';
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-warning-dark').'"> KP '.$qual_kp.'</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_points', function (User $user) {
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_sum').'</div>'.
|
||||
'<span class="small no-line-break">E: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop').'</span>';
|
||||
->addColumn('sales_volume_KP_points', function (User $user) {
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum').'</div>'.
|
||||
'<span class="small no-line-break">E: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_KP_points').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop').'</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (User $user) {
|
||||
return '<div class="no-line-break">'.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum')).' €</div>'.
|
||||
|
|
@ -335,7 +334,7 @@ class BusinessController extends Controller
|
|||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button><br>';
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button><br>';
|
||||
}
|
||||
$sponsor .= '<span class="small no-line-break">'.$user->user_sponsor->email;
|
||||
if($user->user_sponsor->account){
|
||||
|
|
@ -381,7 +380,7 @@ class BusinessController extends Controller
|
|||
->orderColumn('email', 'email $1')
|
||||
->orderColumn('last_name', 'last_name $1')
|
||||
->orderColumn('active_account', 'payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -131,6 +131,9 @@ class BusinessPointsController extends Controller
|
|||
->addColumn('status', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="badge badge-pill badge-'.$UserSalesVolume->getStatusColor().'">'.$UserSalesVolume->getStatusType().'</span>';
|
||||
})
|
||||
->addColumn('status_points', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="badge badge-pill badge-'.$UserSalesVolume->getStatusPointsColor().'">'.$UserSalesVolume->getStatusPointsType().'</span>';
|
||||
})
|
||||
->addColumn('message', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="no-line-break">'.$UserSalesVolume->message.'</span>';
|
||||
})
|
||||
|
|
@ -169,7 +172,7 @@ class BusinessPointsController extends Controller
|
|||
->orderColumn('m_account', 'm_account $1')
|
||||
->orderColumn('first_name', 'first_name $1')
|
||||
->orderColumn('last_name', 'last_name $1')
|
||||
->rawColumns(['id', 'order', 'status', 'message', 'info', 'total_net'])
|
||||
->rawColumns(['id', 'order', 'status', 'status_points', 'message', 'info', 'total_net'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ class HomeController extends Controller
|
|||
//login / Dashboard
|
||||
public function show()
|
||||
{
|
||||
|
||||
if(!Auth::check()){
|
||||
return redirect('login');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,15 +145,16 @@ class ModalController extends Controller
|
|||
|
||||
private function getForBusinessUserDetail(User $user, $data){
|
||||
|
||||
$auth_user = \Auth::user();
|
||||
if($auth_user->isAdmin() || $auth_user->id === $user->id){
|
||||
//$auth_user = \Auth::user();
|
||||
//if($auth_user->isAdmin() || $auth_user->id === $user->id){
|
||||
$TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], $data['init_from']);
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
//TODO is not Admin, read is user in Parent tree ...
|
||||
if(!$TreeCalcBot->business_user){
|
||||
abort(403, 'no user found');
|
||||
}
|
||||
return $TreeCalcBot;
|
||||
}
|
||||
//}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,25 +23,14 @@ use stdClass;
|
|||
class PaymentCreditController extends Controller
|
||||
{
|
||||
|
||||
private $startYear;
|
||||
private $endYear;
|
||||
private $rangeYears;
|
||||
private $activeYear;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->startYear = 2022;
|
||||
$this->endYear = date('Y');
|
||||
$this->rangeYears = range($this->startYear, $this->endYear);
|
||||
$this->activeYear = $this->endYear;
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::$months,
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
|
|
@ -59,7 +48,7 @@ class PaymentCreditController extends Controller
|
|||
return back();
|
||||
}
|
||||
if(!isset($data['credit'])){
|
||||
\Session()->flash('alert-error', 'Bitte Betrag eingebe');
|
||||
\Session()->flash('alert-error', 'Bitte Betrag eingeben');
|
||||
return back();
|
||||
}
|
||||
if(!isset($data['message'])){
|
||||
|
|
@ -153,17 +142,31 @@ class PaymentCreditController extends Controller
|
|||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
|
||||
|
||||
$date_start = Carbon::parse('01.'.Request::get('credit_filter_month').'.'.Request::get('credit_filter_year'))->format('Y-m-d');
|
||||
$date_end = Carbon::parse('01.'.Request::get('credit_filter_month').'.'.Request::get('credit_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
$query = UserCredit::with('user', 'user.account')->select('user_credits.*')
|
||||
->whereBetween('date', [$date_start, $date_end]);
|
||||
|
||||
if(Request::get('credit_filter_name')){
|
||||
$query->whereHas('user.account', function ($query) {
|
||||
return $query->where('first_name', 'LIKE', '%'.Request::get('credit_filter_name').'%')->orWhere('last_name', 'LIKE', '%'.Request::get('credit_filter_name').'%');
|
||||
})->get();
|
||||
$query->whereHas('user', function ($query) {
|
||||
return $query->where('email', 'LIKE', '%'.Request::get('credit_filter_name').'%');
|
||||
})->get();
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$this->setFilterVars();
|
||||
$date1 = Carbon::parse('01.01.'.$this->activeYear)->format('Y-m-d');
|
||||
$date2 = Carbon::parse('31.12.'.$this->activeYear)->format('Y-m-d');
|
||||
|
||||
$query = UserCredit::with('user', 'user.account')->select('user_credits.*')
|
||||
//::with('shopping_user', )->select('shopping_orders.*')
|
||||
//->where('paid', '=', 1)
|
||||
->whereBetween('date', [$date1, $date2]);
|
||||
//->orderBy('created_at', 'DESC');
|
||||
$query = $this->initSearch();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('view', function (UserCredit $UserCredit) {
|
||||
|
|
@ -178,7 +181,7 @@ class PaymentCreditController extends Controller
|
|||
})
|
||||
|
||||
->addColumn('total', function (UserCredit $UserCredit) {
|
||||
return $UserCredit->getFormattedTotal()." €";
|
||||
return '<span class="no-line-break">'.$UserCredit->getFormattedTotal()." €</span>";
|
||||
})
|
||||
->addColumn('credits', function (UserCredit $UserCredit) {
|
||||
$ret = "";
|
||||
|
|
@ -197,7 +200,6 @@ class PaymentCreditController extends Controller
|
|||
</a>';
|
||||
})
|
||||
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
->orderColumn('total', 'total $1')
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ use App\Services\HTMLHelper;
|
|||
class PaymentInvoiceController extends Controller
|
||||
{
|
||||
|
||||
private $startYear;
|
||||
private $endYear;
|
||||
private $rangeYears;
|
||||
private $activeYear;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
@ -60,22 +56,17 @@ class PaymentInvoiceController extends Controller
|
|||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if(Request::get('invoice_filter_name')){
|
||||
$query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->whereHas('shopping_order.shopping_user', function ($query) {
|
||||
return $query->where('billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
})->get();
|
||||
}
|
||||
|
||||
//->orderBy('created_at', 'DESC');
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
$join->on("flex_hour_items.flex_hour_id","=","flex_hours.id");
|
||||
$join->where("flex_hour_items.date","=", FlexHourItemBot::$date);
|
||||
})*/
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$query = $this->initSearch();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order->auth_user_id){
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class PaymentPointsController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
|
||||
dd("function?");
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::$months,
|
||||
|
|
|
|||
151
app/Http/Controllers/ProductsSalesController.php
Normal file
151
app/Http/Controllers/ProductsSalesController.php
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Exports\UserTeamExport;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\BusinessPlan\ExportBot;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class ProductsSalesController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::$months,
|
||||
'filter_years' => HTMLHelper::getYearRange(2022),
|
||||
];
|
||||
return view('admin.product.salesvolume', $data);
|
||||
}
|
||||
|
||||
public function download(){
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
$objects = $this->initSearch(false);
|
||||
$columns = [];
|
||||
$filename = "mivita-absatzmengen-".session('product_sales_vol_filter_month').'_'.session('product_sales_vol_filter_year')."-export";
|
||||
$headers = array(
|
||||
'#',
|
||||
'Produkt',
|
||||
'Artikelnummer',
|
||||
'Menge',
|
||||
|
||||
);
|
||||
if($objects){
|
||||
foreach ($objects as $key => $obj){
|
||||
$columns[] = array(
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function setFilterVars(){
|
||||
|
||||
if(!session('product_sales_vol_filter_month')){
|
||||
session(['product_sales_vol_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('product_sales_vol_filter_year')){
|
||||
session(['product_sales_vol_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
if(Request::get('product_sales_vol_filter_month')){
|
||||
session(['product_sales_vol_filter_month' => Request::get('product_sales_vol_filter_month')]);
|
||||
}
|
||||
if(Request::get('product_sales_vol_filter_year')){
|
||||
session(['product_sales_vol_filter_year' => Request::get('product_sales_vol_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function initSearch($returnColl = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$date_start = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->format('Y-m-d');
|
||||
$date_end = Carbon::parse('01.'.session('product_sales_vol_filter_month').'.'.session('product_sales_vol_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
|
||||
$ShoppingOrders = ShoppingOrder::where('paid', 1)->where('mode', 'live')->whereBetween('created_at', [$date_start, $date_end])->get();
|
||||
|
||||
$objects = [];
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
foreach($ShoppingOrder->shopping_order_items as $shopping_order_item){
|
||||
|
||||
if($shopping_order_item->product){
|
||||
if(isset($objects[$shopping_order_item->product->id])){
|
||||
$value = intval($objects[$shopping_order_item->product->id]['value'] + $shopping_order_item->qty);
|
||||
$objects[$shopping_order_item->product->id]['value'] = $value;
|
||||
}else{
|
||||
$objects[$shopping_order_item->product->id] = [
|
||||
'name' => $shopping_order_item->product->name,
|
||||
'number' => $shopping_order_item->product->number,
|
||||
'value' => $shopping_order_item->qty
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($returnColl){
|
||||
$collection = collect();
|
||||
|
||||
foreach($objects as $key => $obj){
|
||||
$collection->push([
|
||||
'id' => $key,
|
||||
'name' => $obj['name'],
|
||||
'number' => $obj['number'],
|
||||
'value' => $obj['value'],
|
||||
]);
|
||||
}
|
||||
return $collection;
|
||||
}
|
||||
return $objects;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$collection = $this->initSearch(true);
|
||||
|
||||
$collect = collect([
|
||||
['id' => 1, 'name' => 'John', 'number'=>92012, 'value'=>123],
|
||||
['id' => 2, 'name' => 'Jane', 'number'=>92012, 'value'=>123],
|
||||
['id' => 3, 'name' => 'James', 'number'=>92012, 'value'=>123],
|
||||
]);
|
||||
|
||||
return \DataTables::of($collection)->toJson();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -38,10 +38,10 @@ class SalesController extends Controller
|
|||
return redirect(route('admin_sales_customers_detail', [$ShoppingOrder->id]));
|
||||
abort(403, 'Kundenbestellung');
|
||||
}
|
||||
if($ShoppingOrder->shipped === 0){
|
||||
/*if($ShoppingOrder->shipped === 0){
|
||||
$ShoppingOrder->shipped = 1;
|
||||
$ShoppingOrder->save();
|
||||
}
|
||||
}*/
|
||||
|
||||
$data = [
|
||||
'shopping_order' => $ShoppingOrder,
|
||||
|
|
@ -149,10 +149,12 @@ class SalesController extends Controller
|
|||
return redirect(route('admin_sales_users_detail', [$ShoppingOrder->id]));
|
||||
abort(403, 'Beraterbestellung');
|
||||
}
|
||||
/*
|
||||
if($ShoppingOrder->shipped === 0){
|
||||
$ShoppingOrder->shipped = 1;
|
||||
$ShoppingOrder->save();
|
||||
}
|
||||
*/
|
||||
$data = [
|
||||
'shopping_order' => $ShoppingOrder,
|
||||
'isAdmin' => true,
|
||||
|
|
@ -278,7 +280,7 @@ class SalesController extends Controller
|
|||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
})
|
||||
->addColumn('member_id', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->member_id) {
|
||||
if($ShoppingOrder->member_id && $ShoppingOrder->member) {
|
||||
return $ShoppingOrder->member ? '<a href="' . route('admin_lead_edit', [$ShoppingOrder->member_id]) . '">' . $ShoppingOrder->member->getFullName() . '</a>' : 'gelöscht';
|
||||
}
|
||||
if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Services\SyS\ShoppingOrders;
|
||||
use App\Services\SyS\BuyingsProducts;
|
||||
use App\Services\SyS\BusinessStructur;
|
||||
use App\Services\SyS\ChangeUserBusinesses;
|
||||
|
||||
class SysController extends Controller
|
||||
{
|
||||
|
|
@ -62,6 +63,10 @@ class SysController extends Controller
|
|||
case 'corrections':
|
||||
return Correction::show();
|
||||
break;
|
||||
case 'change_user_businesses':
|
||||
return ChangeUserBusinesses::show();
|
||||
break;
|
||||
|
||||
}
|
||||
abort(403, 'not found tool');
|
||||
}
|
||||
|
|
@ -96,6 +101,9 @@ class SysController extends Controller
|
|||
case 'corrections':
|
||||
return Correction::store();
|
||||
break;
|
||||
case 'change_user_businesses':
|
||||
return ChangeUserBusinesses::store();
|
||||
break;
|
||||
}
|
||||
abort(403, 'not found tool');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,7 +189,6 @@ class CustomerController extends Controller
|
|||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
}
|
||||
|
||||
$data['faker_mail'] = isset($data['faker_mail']) ? true : false;
|
||||
$data['has_buyed'] = isset($data['has_buyed']) ? true : false;
|
||||
$data['subscribed'] = isset($data['subscribed']) ? true : false;
|
||||
|
|
|
|||
|
|
@ -2,13 +2,16 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Exports\UserTeamExport;
|
||||
use App\Models\UserSalesVolume;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Services\BusinessPlan\ExportBot;
|
||||
use App\Services\BusinessPlan\TreeCalcBot;
|
||||
use Auth;
|
||||
|
||||
class TeamController extends Controller
|
||||
{
|
||||
|
|
@ -49,7 +52,6 @@ class TeamController extends Controller
|
|||
return view('user.team.structure', $data);
|
||||
}
|
||||
|
||||
|
||||
public function points()
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
|
@ -63,6 +65,69 @@ class TeamController extends Controller
|
|||
return view('user.team.points', $data);
|
||||
}
|
||||
|
||||
public function export()
|
||||
{
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$ExportBot = new ExportBot('member');
|
||||
$ExportBot->initStructureUser($user, 'list'); //tree or list
|
||||
$data = [
|
||||
'ExportBot' => $ExportBot,
|
||||
];
|
||||
return view('user.team.export', $data);
|
||||
}
|
||||
|
||||
public function userTeamExport(){
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$ExportBot = new ExportBot('member');
|
||||
$ExportBot->initStructureUser($user, 'list'); //tree or list
|
||||
$columns = [];
|
||||
$filename = "mivita-mein-team-export-".date('Y-m-d-H-i-s');
|
||||
$headers = array(
|
||||
'Line',
|
||||
'Level',
|
||||
'E-Mail',
|
||||
'Vorname',
|
||||
'Nachname',
|
||||
'Adresse',
|
||||
'Zusatz',
|
||||
'PLZ',
|
||||
'Ort',
|
||||
'Land',
|
||||
'Tel',
|
||||
'Mobil',
|
||||
'Geburtstag',
|
||||
'Account',
|
||||
'Account bis',
|
||||
'Sponsor',
|
||||
);
|
||||
if(isset($ExportBot->user_list->childs)){
|
||||
foreach ($ExportBot->user_list->childs as $child){
|
||||
$columns[] = array(
|
||||
'Line' => $child->line,
|
||||
'Level' => $child->level_name,
|
||||
'E-Mail' => $child->email,
|
||||
'Vorname' => $child->first_name,
|
||||
'Nachname' => $child->last_name,
|
||||
'Adresse' => $child->address,
|
||||
'Zusatz' => $child->address_2,
|
||||
'PLZ' => $child->zipcode,
|
||||
'Ort' => $child->city,
|
||||
'Land' => $child->country_id,
|
||||
'Tel' => $child->phone,
|
||||
'Mobil' => $child->mobil,
|
||||
'Geburtstag' => $child->birthday,
|
||||
'Account' => ($child->active_account == 1 ? 'JA' : 'NEIN'),
|
||||
'Account bis' => $child->payment_account_date,
|
||||
'Sponsor' => $child->sponsor_name,
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename.'.xls');
|
||||
}
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
|
||||
|
|
@ -72,7 +137,6 @@ class TeamController extends Controller
|
|||
if(!session('team_user_filter_year')){
|
||||
session(['team_user_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
if(!session('team_user_points_filter_month')){
|
||||
session(['team_user_points_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,12 @@ class UserLevelController extends Controller
|
|||
$value->save();
|
||||
}
|
||||
}
|
||||
|
||||
//set paylines //pr_line_1
|
||||
for ($i=1; $i <=8; $i++) {
|
||||
if(isset($data['pr_line_'.$i])){
|
||||
$data['paylines'] = $i;
|
||||
}
|
||||
}
|
||||
if($data['id'] == "new"){
|
||||
$model = UserLevel::create($data);
|
||||
}else{
|
||||
|
|
@ -47,23 +52,8 @@ class UserLevelController extends Controller
|
|||
$model->save();
|
||||
}
|
||||
|
||||
/*if(!empty($data['trans'])){
|
||||
$trans = [];
|
||||
foreach ($data['trans'] as $lang => $value){
|
||||
if($value && $value != null){
|
||||
$trans[$lang] = $value;
|
||||
}
|
||||
}
|
||||
if(count($trans)){
|
||||
$model->trans_name = $trans;
|
||||
$model->save();
|
||||
}
|
||||
}*/
|
||||
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('admin_levels'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -150,12 +150,13 @@ class CardController extends Controller
|
|||
|
||||
public function deleteCard(){
|
||||
|
||||
Yard::instance('shopping')->destroy();
|
||||
return back();
|
||||
$setCode = Shop::getUserShopLang();
|
||||
$mylangs = Shop::getLangChange();
|
||||
foreach($mylangs as $code => $country){
|
||||
if(strtolower($setCode) === strtolower($code)){
|
||||
Shop::initUserShopLang($country);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -283,7 +283,7 @@ class CheckoutController extends Controller
|
|||
$shopping_order = $this->makeShoppingOrder($shopping_user);
|
||||
//CustomerPriority
|
||||
if($shopping_user->is_from === 'shopping'){
|
||||
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
|
||||
$ret = CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
|
||||
}
|
||||
Util::setUserHistoryValue(['status'=>2, 'shopping_order_id'=>$shopping_order->id]);
|
||||
|
||||
|
|
@ -402,6 +402,8 @@ class CheckoutController extends Controller
|
|||
Yard::instance('shopping')->destroy();
|
||||
$this->destroy();
|
||||
|
||||
|
||||
|
||||
$payt = $ShoppingPayment->payment_transactions->last();
|
||||
|
||||
$data = [
|
||||
|
|
@ -678,6 +680,7 @@ class CheckoutController extends Controller
|
|||
{
|
||||
$this->session->remove($this->instance);
|
||||
}
|
||||
|
||||
//is for Rechnung MIV
|
||||
private function directPaymentStatus(PaymentTransaction $payt){
|
||||
|
||||
|
|
|
|||
|
|
@ -79,8 +79,6 @@ class SiteController extends Controller
|
|||
$headline_image = $category->iq_image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$product_categories = ProductCategory::where('category_id', $category->id)->whereHas('product', function ($query) use ($category) {
|
||||
$query->where('active', true)->whereJsonContains('show_on', '1');
|
||||
})->orderBy('pos', 'DESC')->get();
|
||||
|
|
|
|||
|
|
@ -29,9 +29,12 @@ class MailCredit extends Mailable
|
|||
|
||||
public function build()
|
||||
{
|
||||
$title = __('email.credit_title');
|
||||
$title = 'Hallo ';
|
||||
$copy1line = __('email.credit_copy1line');
|
||||
|
||||
if(isset($this->user_credit->user->account)){
|
||||
$title .= $this->user_credit->user->account->m_first_name.",";
|
||||
}
|
||||
$filename = $this->user_credit->filename;
|
||||
$disk = $this->user_credit->disk;
|
||||
$path = $this->user_credit->getDownloadPath();
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Attribute query()
|
||||
* @property-read int|null $childrens_count
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Attribute extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ProductCategory[] $product_categories
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Category findSimilarSlugs($attribute, $config, $slug)
|
||||
|
|
@ -46,6 +45,7 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @property-read \App\Models\IqImage|null $iq_image
|
||||
* @property-read int|null $product_categories_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ use PHPUnit\Framework\Constraint\Count;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereIt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country wherePhone($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country whereRu($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Country query()
|
||||
|
|
@ -61,6 +60,7 @@ use PHPUnit\Framework\Constraint\Count;
|
|||
* @property bool|null $supply_country
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Country whereEuCountry($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Country whereSupplyCountry($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Country extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\CountryPrice whereCCurrency($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class CountryPrice extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Homeparty whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $token
|
||||
* @property bool|null $token_active
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUser[] $homeparty_guests
|
||||
|
|
@ -72,6 +71,7 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereOrder($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereSettings($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereStep($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Homeparty extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -102,13 +102,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUser whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\HomepartyUser withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\HomepartyUser withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\HomepartyUserOrderItem[] $homeparty_user_order_items
|
||||
* @property-read int|null $homeparty_user_order_items_count
|
||||
* @property string|null $delivery
|
||||
* @property array|null $settings
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereDelivery($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUser whereSettings($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class HomepartyUser extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereTaxRate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\HomepartyUserOrderItem whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property float|null $ek_price_net
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|HomepartyUserOrderItem whereEkPriceNet($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class HomepartyUserOrderItem extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
|
||||
|
|
@ -39,6 +38,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\IqImage wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|IqImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class IqImage extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShort($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereShowAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $show_on
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereShowOn($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,9 +39,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereTxid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereUserid($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $mode
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentTransaction whereMode($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PaymentTransaction extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereUsage($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\Product withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Product whereSlug($value)
|
||||
|
|
@ -123,6 +122,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereBuyingRestriction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereBuyingRestrictionAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Product whereNoFreeShipping($value)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductBuying> $product_buyings
|
||||
* @property-read int|null $product_buyings_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ProductBuying> $product_buyings
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Product extends Model
|
||||
{
|
||||
|
|
@ -152,6 +155,10 @@ class Product extends Model
|
|||
'no_free_shipping' => 'bool',
|
||||
'buying_restriction' => 'bool',
|
||||
'buying_restriction_amount' => 'int',
|
||||
'sponsor_buying_points' => 'bool',
|
||||
'sponsor_buying_points_amount' => 'int',
|
||||
|
||||
|
||||
];
|
||||
use Sluggable;
|
||||
|
||||
|
|
@ -189,6 +196,8 @@ class Product extends Model
|
|||
'shipping_addon',
|
||||
'buying_restriction',
|
||||
'buying_restriction_amount',
|
||||
'sponsor_buying_points',
|
||||
'sponsor_buying_points_amount',
|
||||
'identifier',
|
||||
'action',
|
||||
'upgrade_to_id'
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductAttribute query()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ProductAttribute extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductCategory query()
|
||||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductCategory wherePos($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ProductCategory extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $slug
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage findSimilarSlugs($attribute, $config, $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage whereSlug($value)
|
||||
|
|
@ -39,6 +38,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int|null $pos
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ProductImage wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ProductImage withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ProductImage extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Shipping whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShippingPrice[] $shipping_prices
|
||||
* @property-read int|null $shipping_prices_count
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Shipping extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereShippingId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingCountry whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
|
||||
* @property-read int|null $shopping_orders_count
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShippingCountry extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightFrom($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereWeightTo($value)
|
||||
* @mixin \Eloquent
|
||||
* @property-write mixed $tax
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereTaxRate($value)
|
||||
* @property float|null $price_comp
|
||||
* @property int|null $num_comp
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice whereNumComp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShippingPrice wherePriceComp($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShippingPrice extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ use App\User;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereTaxTotal($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereUserId($value)
|
||||
* @property array|null $net_split
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingCollectOrder whereNetSplit($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingCollectOrder extends Model
|
||||
|
|
@ -73,6 +75,7 @@ class ShoppingCollectOrder extends Model
|
|||
'points' => 'int',
|
||||
'status' => 'int',
|
||||
'tax_split' => 'array',
|
||||
'net_split' => 'array',
|
||||
'orders' => AsArrayObject::class,
|
||||
'shop_items' => AsArrayObject::class,
|
||||
];
|
||||
|
|
@ -90,6 +93,7 @@ class ShoppingCollectOrder extends Model
|
|||
'qty_total',
|
||||
'points',
|
||||
'tax_split',
|
||||
'net_split',
|
||||
'orders',
|
||||
'shop_items',
|
||||
'status'
|
||||
|
|
@ -115,11 +119,31 @@ class ShoppingCollectOrder extends Model
|
|||
{
|
||||
$tax_split = $this->tax_split;
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ? round($tax_split[$tax_rate] += $add_tax, 2) : round($add_tax, 2);
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key] = number_format($value, 2);
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
}
|
||||
|
||||
public function addNetToSplit($tax_rate, $add_net)
|
||||
{
|
||||
$net_split = $this->net_split;
|
||||
$net_split[$tax_rate] = isset($net_split[$tax_rate]) ? round($net_split[$tax_rate] += $add_net, 2) : round($add_net, 2);
|
||||
|
||||
foreach($net_split as $key=>$value){
|
||||
$net_split[$key] = number_format($value, 2);
|
||||
}
|
||||
$this->net_split = $net_split;
|
||||
}
|
||||
|
||||
public function addShopItem($shop_item_id, $shop_item)
|
||||
{
|
||||
$shop_item->user_price_net = number_format($shop_item->user_price_net, 2);
|
||||
$shop_item->user_price_total_net = number_format($shop_item->user_price_total_net, 2);
|
||||
$shop_item->user_tax = number_format($shop_item->user_tax, 2);
|
||||
$shop_item->user_tax_total = number_format($shop_item->user_tax_total, 2);
|
||||
|
||||
$this->shop_items[$shop_item_id] = $shop_item;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereSubdomain($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereUserShopId($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $payment
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance wherePayment($value)
|
||||
* @property array|null $shopping_data
|
||||
* @property string|null $back
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereBack($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereShoppingData($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingInstance extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereUserShopId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder whereWeight($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $payment_for
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrder wherePaymentFor($value)
|
||||
* @property int|null $member_id
|
||||
|
|
@ -94,6 +93,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiNotice($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereApiStatus($value)
|
||||
* @property-read \App\Models\ShoppingCollectOrder|null $shopping_collect_order
|
||||
* @property array|null $net_split
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereNetSplit($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
{
|
||||
|
|
@ -117,6 +119,7 @@ class ShoppingOrder extends Model
|
|||
'subtotal_ws',
|
||||
'tax',
|
||||
'tax_split',
|
||||
'net_split',
|
||||
'total_shipping',
|
||||
'points',
|
||||
'weight',
|
||||
|
|
@ -133,6 +136,8 @@ class ShoppingOrder extends Model
|
|||
protected $casts = [
|
||||
'api_notice' => 'array',
|
||||
'tax_split' => 'array',
|
||||
'net_split' => 'array',
|
||||
|
||||
];
|
||||
|
||||
public static $shippedTypes = [
|
||||
|
|
@ -419,107 +424,158 @@ class ShoppingOrder extends Model
|
|||
public function makeHomepartyTaxSplit()
|
||||
{
|
||||
$tax_split = [];
|
||||
$net_split = [];
|
||||
|
||||
if($this->homeparty){
|
||||
foreach($this->homeparty->homeparty_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$vk_tax = round((($item->price - $item->price_net) * $item->qty), 2);
|
||||
$ek_tax = round((($item->ek_price - $item->ek_price_net) * $item->qty), 2);
|
||||
$vk_net = round(($item->price_net * $item->qty), 2);
|
||||
$ek_net = round(($item->ek_price_net * $item->qty), 2);
|
||||
if(isset($tax_split[$tax_rate])){
|
||||
$tax_split[$tax_rate]['vk_tax'] = round($tax_split[$tax_rate]['vk_tax'] + $vk_tax, 2);
|
||||
$tax_split[$tax_rate]['ek_tax'] = round($tax_split[$tax_rate]['ek_tax'] + $ek_tax, 2);
|
||||
|
||||
$net_split[$tax_rate]['vk_net'] = round($net_split[$tax_rate]['vk_net'] + $vk_net, 2);
|
||||
$net_split[$tax_rate]['ek_net'] = round($net_split[$tax_rate]['ek_net'] + $ek_net, 2);
|
||||
}else{
|
||||
$tax_split[$tax_rate] = ['vk_tax' => $vk_tax, 'ek_tax' => $ek_tax];
|
||||
$net_split[$tax_rate] = ['vk_net' => $vk_net, 'ek_net' => $ek_net];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$order_vk_tax = 0;
|
||||
$order_ek_tax = 0;
|
||||
$order_vk_net = 0;
|
||||
$order_ek_net = 0;
|
||||
|
||||
if($this->homeparty->order){
|
||||
if(isset($this->homeparty->order['ek_price_net'])){
|
||||
$order_vk_tax = round((($this->homeparty->order['price'] - $this->homeparty->order['price_net'])), 2);
|
||||
$order_ek_tax = round((($this->homeparty->order['ek_price'] - $this->homeparty->order['ek_price_net'])), 2);
|
||||
$order_vk_net = $this->homeparty->order['price_net'];
|
||||
$order_ek_net = $this->homeparty->order['ek_price_net'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[16] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[19] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[16] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
$tax_split[16]['vk_tax'] = round($tax_split[16]['vk_tax'] - $tax_split[5]['vk_tax'], 2);
|
||||
$tax_split[16]['ek_tax'] = round($tax_split[16]['ek_tax'] - $tax_split[5]['ek_tax'], 2);
|
||||
$net_split[16]['vk_net'] = round($net_split[16]['vk_net'] - $net_split[5]['vk_net'], 2);
|
||||
$net_split[16]['ek_net'] = round($net_split[16]['ek_net'] - $net_split[5]['ek_net'], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = ['vk_tax' => $order_vk_tax, 'ek_tax' => $order_ek_tax];
|
||||
$net_split[19] = ['vk_net' => $order_vk_net, 'ek_net' => $order_ek_net];
|
||||
}
|
||||
$tax_split[19]['vk_tax'] = round($tax_split[19]['vk_tax'] - $tax_split[7]['vk_tax'], 2);
|
||||
$tax_split[19]['ek_tax'] = round($tax_split[19]['ek_tax'] - $tax_split[7]['ek_tax'], 2);
|
||||
$net_split[19]['vk_net'] = round($net_split[19]['vk_net'] - $net_split[7]['vk_net'], 2);
|
||||
$net_split[19]['ek_net'] = round($net_split[19]['ek_net'] - $net_split[7]['ek_net'], 2);
|
||||
}
|
||||
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key]['vk_tax'] = number_format($value['vk_tax'], 2);
|
||||
$tax_split[$key]['ek_tax'] = number_format($value['ek_tax'], 2);
|
||||
}
|
||||
|
||||
foreach($net_split as $key=>$value){
|
||||
$net_split[$key]['vk_net'] = number_format($value['vk_net'], 2);
|
||||
$net_split[$key]['ek_net'] = number_format($value['ek_net'], 2);
|
||||
}
|
||||
}
|
||||
if(!isset($tax_split[16]) && !isset($tax_split[19])){
|
||||
$tax_split = NULL;
|
||||
}
|
||||
}
|
||||
if(!isset($net_split[16]) && !isset($net_split[19])){
|
||||
$net_split = NULL;
|
||||
}
|
||||
|
||||
|
||||
$this->tax_split = $tax_split;
|
||||
$this->net_split = $net_split;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
public function makeTaxSplit()
|
||||
{
|
||||
$tax_split = NULL;
|
||||
$net_split = NULL;
|
||||
|
||||
if($this->tax > 0){
|
||||
$tax_split = [];
|
||||
$net_split = [];
|
||||
|
||||
foreach($this->shopping_order_items as $item){
|
||||
$tax_rate = intval($item->tax_rate);
|
||||
if($tax_rate > 0){
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ?
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ?
|
||||
round($tax_split[$tax_rate] + ($item->tax * $item->qty), 2) :
|
||||
round(($item->tax * $item->qty), 2);
|
||||
|
||||
$net_split[$tax_rate] = isset($net_split[$tax_rate]) ?
|
||||
round($net_split[$tax_rate] + ($item->price_net * $item->qty), 2) :
|
||||
round(($item->price_net * $item->qty), 2);
|
||||
|
||||
}
|
||||
}
|
||||
if(isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
$net_split[16] = $this->subtotal_ws;
|
||||
|
||||
}
|
||||
if(isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
$net_split[19] = $this->subtotal_ws;
|
||||
}
|
||||
|
||||
if(isset($tax_split[5])){
|
||||
if(!isset($tax_split[16])){
|
||||
$tax_split[16] = $this->tax;
|
||||
$net_split[16] = $this->subtotal_ws;
|
||||
|
||||
}
|
||||
$tax_split[16] = round($tax_split[16] - $tax_split[5], 2);
|
||||
$net_split[16] = round($net_split[16] - $net_split[5], 2);
|
||||
}
|
||||
if(isset($tax_split[7])){
|
||||
if(!isset($tax_split[19])){
|
||||
$tax_split[19] = $this->tax;
|
||||
$net_split[19] = $this->subtotal_ws;
|
||||
|
||||
}
|
||||
$tax_split[19] = round($tax_split[19] - $tax_split[7], 2);
|
||||
|
||||
$net_split[19] = round($net_split[19] - $net_split[7], 2);
|
||||
}
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
$tax_split[$key] = number_format($value, 2);
|
||||
}
|
||||
foreach($net_split as $key=>$value){
|
||||
$net_split[$key] = number_format($value, 2);
|
||||
}
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
$this->net_split = $net_split;
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereShoppingOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingOrderItem whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property float|null $tax_rate
|
||||
* @property \Illuminate\Support\Carbon|null $deleted_at
|
||||
* @property string|null $user_deleted_at
|
||||
|
|
@ -58,6 +57,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereTax($value)
|
||||
* @property int|null $shopping_collect_order_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrderItem whereShoppingCollectOrderId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingOrderItem extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereTxaction($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereWallettype($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $mode
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereMode($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingPayment extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingSalutation($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereShippingZipcode($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingUser whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $orders
|
||||
* @property-read \App\Models\ShoppingOrder $shopping_order
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\ShoppingOrder[] $shopping_orders
|
||||
|
|
@ -117,6 +116,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereHomepartyId($value)
|
||||
* @property int|null $shopping_collect_order_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereShoppingCollectOrderId($value)
|
||||
* @property string|null $remarks
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingUser whereRemarks($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingUser extends Model
|
||||
{
|
||||
|
|
@ -160,6 +162,7 @@ class ShoppingUser extends Model
|
|||
'has_buyed',
|
||||
'subscribed',
|
||||
'notice',
|
||||
'remarks',
|
||||
'mode',
|
||||
'is_for',
|
||||
'is_from',
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\SySetting whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|SySetting withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class SySetting extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ use Carbon\Carbon;
|
|||
* @method static bool|null restore()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserAccount withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @property int $id
|
||||
* @property string|null $salutation
|
||||
* @property string|null $first_name
|
||||
|
|
@ -131,6 +130,7 @@ use Carbon\Carbon;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereBankBic($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereBankIban($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAccount whereBankOwner($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserAccount extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
|||
* @property int|null $margin
|
||||
* @property int|null $margin_shop
|
||||
* @property int|null $qual_kp
|
||||
* @property int|null $qual_tp
|
||||
* @property int|null $total_tp
|
||||
* @property int|null $total_qual_tp
|
||||
* @property int|null $qual_pp
|
||||
* @property int|null $total_pp
|
||||
* @property int|null $total_qual_pp
|
||||
* @property string|null $commission_lines_total
|
||||
* @property float|null $commission_shop_sales
|
||||
* @property float|null $commission_team_total
|
||||
* @property float|null $commission_pp_total
|
||||
* @property mixed|null $business_lines
|
||||
* @property mixed|null $user_items
|
||||
* @property array|null $qual_user_level
|
||||
|
|
@ -92,9 +92,13 @@ use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserItems($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserLevelName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereYear($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $next_qual_user_level
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereNextQualUserLevel($value)
|
||||
* @property-read User $user
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereQualPp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereTotalPp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereTotalQualPp($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserBusiness extends Model
|
||||
{
|
||||
|
|
@ -108,25 +112,33 @@ class UserBusiness extends Model
|
|||
'm_level_id' => 'int',
|
||||
'active_account' => 'bool',
|
||||
'm_account' => 'int',
|
||||
'sales_volume_points' => 'int',
|
||||
'sales_volume_KP_points' => 'int',
|
||||
'sales_volume_TP_points' => 'int',
|
||||
'sales_volume_points_shop' => 'int',
|
||||
'sales_volume_points_sum' => 'int',
|
||||
'sales_volume_points_KP_sum' => 'int',
|
||||
'sales_volume_points_TP_sum' => 'int',
|
||||
'sales_volume_total' => 'float',
|
||||
'sales_volume_total_shop' => 'float',
|
||||
'sales_volume_total_sum' => 'float',
|
||||
'payline_points' => 'int',
|
||||
'payline_points_qual_kp' => 'int',
|
||||
'margin' => 'float',
|
||||
'margin_shop' => 'float',
|
||||
'qual_kp' => 'int',
|
||||
'qual_tp' => 'int',
|
||||
'total_tp' => 'int',
|
||||
'total_qual_tp' => 'int',
|
||||
'commission_team_total' => 'float',
|
||||
'qual_pp' => 'int',
|
||||
'total_pp' => 'int',
|
||||
'total_qual_pp' => 'int',
|
||||
'commission_pp_total' => 'float',
|
||||
'commission_growth_total' => 'float',
|
||||
'commission_shop_sales' => 'float',
|
||||
'qual_user_level' => 'array',
|
||||
'qual_user_level_next' => 'array',
|
||||
'next_qual_user_level' => 'array',
|
||||
'next_can_user_level' => 'array',
|
||||
'sponsor' => 'object',
|
||||
'business_lines' => AsArrayObject::class,
|
||||
'user_items' => AsArrayObject::class
|
||||
'user_items' => AsArrayObject::class,
|
||||
'version' => 'int',
|
||||
];
|
||||
|
||||
protected $dates = [
|
||||
|
|
@ -149,24 +161,32 @@ class UserBusiness extends Model
|
|||
'email',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'sales_volume_points',
|
||||
'sales_volume_KP_points',
|
||||
'sales_volume_TP_points',
|
||||
'sales_volume_points_shop',
|
||||
'sales_volume_points_sum',
|
||||
'sales_volume_points_KP_sum',
|
||||
'sales_volume_points_TP_sum',
|
||||
'sales_volume_total',
|
||||
'sales_volume_total_shop',
|
||||
'sales_volume_total_sum',
|
||||
'payline_points',
|
||||
'payline_points_qual_kp',
|
||||
'margin',
|
||||
'margin_shop',
|
||||
'qual_kp',
|
||||
'qual_tp',
|
||||
'qual_pp',
|
||||
'qual_user_level',
|
||||
'qual_user_level_next',
|
||||
'next_qual_user_level',
|
||||
'total_tp',
|
||||
'total_qual_tp',
|
||||
'commission_team_total',
|
||||
'next_can_user_level',
|
||||
'total_pp',
|
||||
'total_qual_pp',
|
||||
'commission_shop_sales',
|
||||
'commission_pp_total',
|
||||
'commission_growth_total',
|
||||
'business_lines',
|
||||
'user_items',
|
||||
'version',
|
||||
];
|
||||
|
||||
public function user()
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ class UserCredit extends Model
|
|||
'net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'taxable' => 'bool',
|
||||
'taxable' => 'int',
|
||||
'total' => 'float',
|
||||
'paid_out' => 'bool',
|
||||
'cancellation' => 'bool',
|
||||
|
|
@ -143,6 +143,13 @@ class UserCredit extends Model
|
|||
10 => 'danger',
|
||||
];
|
||||
|
||||
public static $taxableTypes = [
|
||||
0 => '',
|
||||
1 => 'umsatzsteuerpflichtig / DE',
|
||||
2 => 'nicht umsatzsteuerpflichtig / DE',
|
||||
3 => 'nicht umsatzsteuerpflichtig / Ausland'
|
||||
];
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,9 +47,11 @@ class UserCreditItem extends Model
|
|||
|
||||
public static $statusTypes = [
|
||||
1 => 'Provision Shop',
|
||||
2 => 'Provision Team',
|
||||
2 => 'Provision Payline',
|
||||
3 => 'Guthaben hinzugefügt',
|
||||
4 => 'commission ...',
|
||||
5 => 'Provision Wachstumsbonus',
|
||||
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
|
|
@ -58,6 +60,7 @@ class UserCreditItem extends Model
|
|||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'info',
|
||||
5 => 'secondary',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -38,11 +38,11 @@ use App\User;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereUserId($value)
|
||||
* @mixin \Eloquent
|
||||
* @property string|null $identifier
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereIdentifier($value)
|
||||
* @property int|null $abo_options
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereAboOptions($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserHistory extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,11 +30,10 @@ use App\Models\UserLevel as ModelsUserLevel;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereTransName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserLevel whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int|null $next_id
|
||||
* @property int|null $margin_shop
|
||||
* @property int|null $qual_kp
|
||||
* @property int|null $qual_tp
|
||||
* @property int|null $qual_pp
|
||||
* @property string|null $growth_bonus
|
||||
* @property int|null $pr_line_1
|
||||
* @property int|null $pr_line_2
|
||||
|
|
@ -42,6 +41,8 @@ use App\Models\UserLevel as ModelsUserLevel;
|
|||
* @property int|null $pr_line_4
|
||||
* @property int|null $pr_line_5
|
||||
* @property int|null $pr_line_6
|
||||
* @property int|null $pr_line_7
|
||||
* @property int|null $pr_line_8
|
||||
* @property-read UserLevel|null $next_user_level
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereGrowthBonus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereMarginShop($value)
|
||||
|
|
@ -54,6 +55,10 @@ use App\Models\UserLevel as ModelsUserLevel;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine6($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualKp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualTp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine7($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel wherePrLine8($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserLevel whereQualPp($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserLevel extends Model
|
||||
{
|
||||
|
|
@ -62,7 +67,7 @@ class UserLevel extends Model
|
|||
protected $casts = ['trans_name' => 'array'];
|
||||
|
||||
protected $fillable = [
|
||||
'next_id', 'name', 'margin', 'margin_shop', 'qual_kp', 'qual_tp', 'growth_bonus', 'pr_line_1', 'pr_line_2', 'pr_line_3', 'pr_line_4', 'pr_line_5', 'pr_line_6', 'pos', 'active', 'default',
|
||||
'next_id', 'name', 'margin', 'margin_shop', 'qual_kp', 'qual_pp', 'growth_bonus', 'pr_line_1', 'pr_line_2', 'pr_line_3', 'pr_line_4', 'pr_line_5', 'pr_line_6', 'pr_line_7', 'pr_line_8', 'paylines', 'pos', 'active', 'default',
|
||||
];
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use App\User;
|
|||
* @property Carbon|null $date
|
||||
* @property int|null $points
|
||||
* @property int|null $month_points
|
||||
* @property int $status_points
|
||||
* @property float|null $total_net
|
||||
* @property float|null $month_total_net
|
||||
* @property string|null $message
|
||||
|
|
@ -56,10 +57,11 @@ use App\User;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereUserInvoiceId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereYear($value)
|
||||
* @mixin \Eloquent
|
||||
* @property array|null $syslog
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereSyslog($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereInfo($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserSalesVolume whereStatusPoints($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserSalesVolume extends Model
|
||||
{
|
||||
|
|
@ -72,8 +74,10 @@ class UserSalesVolume extends Model
|
|||
'month' => 'int',
|
||||
'year' => 'int',
|
||||
'points' => 'int',
|
||||
'month_points' => 'int',
|
||||
'month_KP_points' => 'int',
|
||||
'month_TP_points' => 'int',
|
||||
'month_shop_points' => 'int',
|
||||
'status_points' => 'int',
|
||||
'total_net' => 'float',
|
||||
'month_total_net' => 'float',
|
||||
'month_shop_total_net' => 'float',
|
||||
|
|
@ -93,8 +97,10 @@ class UserSalesVolume extends Model
|
|||
'year',
|
||||
'date',
|
||||
'points',
|
||||
'month_points',
|
||||
'month_KP_points',
|
||||
'month_TP_points',
|
||||
'month_shop_points',
|
||||
'status_points',
|
||||
'total_net',
|
||||
'month_total_net',
|
||||
'month_shop_total_net',
|
||||
|
|
@ -105,12 +111,18 @@ class UserSalesVolume extends Model
|
|||
];
|
||||
|
||||
|
||||
public static $statusPointsTypes = [
|
||||
1 => 'KP + TP', //Eigene + Team
|
||||
2 => 'KP', //nur Eigene nicht Team
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'nicht zugewiesen',
|
||||
1 => 'Beraterbestellung', //hinzugefügt aus
|
||||
2 => 'Shopbestellung', //hinzugefügt aus
|
||||
3 => 'Shopbestellung / pending', //hinzugefügt aus
|
||||
4 => 'Gutschrift', //hinzugefügt aus
|
||||
5 => 'Registrierung', //hinzugefügt aus
|
||||
10 => ''
|
||||
];
|
||||
|
||||
|
|
@ -120,6 +132,7 @@ class UserSalesVolume extends Model
|
|||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'info',
|
||||
5 => 'info',
|
||||
10 => 'danger',
|
||||
];
|
||||
|
||||
|
|
@ -148,9 +161,13 @@ class UserSalesVolume extends Model
|
|||
return isset($this->attributes['date']) ? $this->attributes['date'] : NULL;
|
||||
}
|
||||
|
||||
public function getPointsSum(){
|
||||
return $this->month_points + $this->month_shop_points;
|
||||
public function getPointsKPSum(){
|
||||
return $this->month_KP_points + $this->month_shop_points; //only KP für SUM - KP is for User
|
||||
}
|
||||
public function getPointsTPSum(){
|
||||
return $this->month_TP_points + $this->month_shop_points; //only TP für SUM - TP is only for Payline
|
||||
}
|
||||
|
||||
public function getTotalNetSum(){
|
||||
return $this->month_total_net + $this->month_shop_total_net;
|
||||
}
|
||||
|
|
@ -163,6 +180,13 @@ class UserSalesVolume extends Model
|
|||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
public function getStatusPointsType(){
|
||||
return isset(self::$statusPointsTypes[$this->status_points]) ? self::$statusPointsTypes[$this->status_points] : "";
|
||||
}
|
||||
public function getStatusPointsColor(){
|
||||
return isset(self::$statusColors[$this->status_points]) ? self::$statusColors[$this->status_points] : "default";
|
||||
}
|
||||
|
||||
public function getFormatedMonthYear(){
|
||||
return str_pad($this->month, 2, "0", STR_PAD_LEFT)."/".$this->year;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShop whereUserId($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShop withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserShop extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserShopOnSite whereUserShopId($value)
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShopOnSite withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserShopOnSite extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* App\Models\UserUpdateEmail
|
||||
*
|
||||
* @property-read \App\User $user
|
||||
* @mixin \Eloquent
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail query()
|
||||
|
|
@ -20,6 +19,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserUpdateEmail whereUserId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserUpdateEmail extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,15 +5,7 @@ namespace App\Repositories;
|
|||
use App\Libraries\ContractPDF;
|
||||
use App\Models\File;
|
||||
use App\User;
|
||||
use Request;
|
||||
use Response;
|
||||
use Storage;
|
||||
use Util;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ContractPDFRepository extends BaseRepository {
|
||||
|
||||
|
|
@ -35,7 +27,10 @@ class ContractPDFRepository extends BaseRepository {
|
|||
}
|
||||
|
||||
private function convert($str){
|
||||
return iconv('UTF-8', 'windows-1252', $str);
|
||||
$search = array('Ő', 'ő', 'Ű', 'ű');
|
||||
$replace = array('Ö', 'ö', 'Ü', 'ü');
|
||||
$str = str_replace($search, $replace, $str);
|
||||
return iconv('UTF-8', 'windows-1252//IGNORE', $str);
|
||||
}
|
||||
|
||||
public function createContractPDF() {
|
||||
|
|
|
|||
|
|
@ -103,12 +103,16 @@ class CreditRepository extends BaseRepository {
|
|||
$this->user_credit->net += $userCreditItem->credit;
|
||||
}
|
||||
/* taxable_sales //user tax
|
||||
1 //umsatzsteuerpflichtig
|
||||
2 // nicht umsatzsteuerpflichtig
|
||||
1 //umsatzsteuerpflichtig / DE
|
||||
2 // nicht umsatzsteuerpflichtig /DE
|
||||
3 // nicht umsatzsteuerpflichtig / Ausland
|
||||
*/
|
||||
if($this->model->account){
|
||||
$this->user_credit->taxable = $this->model->account->taxable_sales == 2 ? false : true;
|
||||
if($this->user_credit->taxable){
|
||||
$this->user_credit->taxable = $this->model->account->taxable_sales;
|
||||
if($this->model->account->country_id !== 1){
|
||||
$this->user_credit->taxable = 3;
|
||||
}
|
||||
if($this->user_credit->taxable === 1){
|
||||
$this->user_credit->tax_rate = config('app.main_tax_rate');
|
||||
$this->user_credit->total = round($this->user_credit->net * config('app.main_tax'), 2);
|
||||
$this->user_credit->tax = $this->user_credit->total - $this->user_credit->net;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ class ProductRepository extends BaseRepository {
|
|||
$data['no_commission'] = isset($data['no_commission']) ? 1 : 0;
|
||||
$data['no_free_shipping'] = isset($data['no_free_shipping']) ? 1 : 0;
|
||||
$data['buying_restriction'] = isset($data['buying_restriction']) ? 1 : 0;
|
||||
$data['sponsor_buying_points'] = isset($data['sponsor_buying_points']) ? 1 : 0;
|
||||
$data['show_on'] = isset($data['show_on']) ? $data['show_on'] : null;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ class BusinessUserItem
|
|||
}
|
||||
//read User here, can delete in stored data.
|
||||
$user = User::find($user_id);
|
||||
if(!$user){
|
||||
return;
|
||||
}
|
||||
$user_level_active = $user->user_level ? $user->user_level : null;
|
||||
$this->user_level_active_pos = $user_level_active ? $user_level_active->pos : 0;
|
||||
$this->b_user = new UserBusiness();
|
||||
|
|
@ -50,18 +53,28 @@ class BusinessUserItem
|
|||
'email' => $user->email,
|
||||
'first_name' => $user->account->first_name,
|
||||
'last_name' => $user->account->last_name,
|
||||
'sales_volume_points' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points'),
|
||||
|
||||
'sales_volume_KP_points' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_KP_points'),
|
||||
'sales_volume_TP_points' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_TP_points'),
|
||||
'sales_volume_points_shop' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points_shop'),
|
||||
'sales_volume_points_sum' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points_sum'),
|
||||
|
||||
'sales_volume_points_KP_sum' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points_KP_sum'), //KP + Shop Points
|
||||
'sales_volume_points_TP_sum' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_points_TP_sum'), //TP + Shop Points
|
||||
|
||||
'sales_volume_total' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_total'),
|
||||
'sales_volume_total_shop' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_total_shop'),
|
||||
'sales_volume_total_sum' => $user->getUserSalesVolumeBy($this->date->month, $this->date->year, 'sales_volume_total_sum'),
|
||||
'margin' => $user_level_active ? $user_level_active->margin : 0,
|
||||
'margin_shop' => $user_level_active ? $user_level_active->margin_shop : 0,
|
||||
'qual_kp' => $user_level_active ? $user_level_active->qual_kp : 0,
|
||||
'qual_tp' => $user_level_active ? $user_level_active->qual_tp : 0,
|
||||
'commission_team_total' => 0,
|
||||
|
||||
'margin' => $user_level_active ? $user_level_active->margin : 0, //is fix Rabatt für Kundenbestellungen
|
||||
'margin_shop' => $user_level_active ? $user_level_active->margin_shop : 0, //is fix Rabatt für Shopbestellungen
|
||||
'qual_kp' => $user_level_active ? $user_level_active->qual_kp : 0, //KP Kundenpoints from level
|
||||
'qual_pp' => $user_level_active ? $user_level_active->qual_pp : 0, //PP Payline Points from level
|
||||
|
||||
'payline_points' => 0,
|
||||
'commission_pp_total' => 0,
|
||||
'commission_shop_sales' => 0,
|
||||
'commission_growth_total' => 0,
|
||||
'version' => 2,
|
||||
];
|
||||
$this->b_user->fill($fill);
|
||||
$this->b_user->business_lines = [];
|
||||
|
|
@ -73,6 +86,7 @@ class BusinessUserItem
|
|||
public function addUserID(){
|
||||
TreeCalcBot::addUserID($this->b_user->user_id);
|
||||
}
|
||||
|
||||
public function getBUser(){
|
||||
return $this->b_user;
|
||||
}
|
||||
|
|
@ -88,43 +102,160 @@ class BusinessUserItem
|
|||
}
|
||||
|
||||
public function addTotalTP($points){
|
||||
$this->b_user->total_tp += $points;
|
||||
|
||||
$this->b_user->total_pp += $points;
|
||||
}
|
||||
|
||||
public function isQualKP(){
|
||||
return ($this->sales_volume_points_sum >= $this->qual_kp) ? true : false;
|
||||
return ($this->sales_volume_points_KP_sum >= $this->qual_kp) ? true : false;
|
||||
}
|
||||
|
||||
public function isQualLevel(){
|
||||
return ($this->qual_user_level) ? true : false;
|
||||
}
|
||||
|
||||
public function isQualEqualLevel(){
|
||||
if($this->qual_user_level){
|
||||
return ($this->m_level_id == $this->qual_user_level['id']) ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getQualLevelPaylines(){
|
||||
if($this->qual_user_level){
|
||||
return $this->qual_user_level['paylines'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function isQualLevelGrowth($line){
|
||||
if(isset($this->business_lines[$line])){
|
||||
$object = $this->business_lines[$line];
|
||||
if(isset($object->growth_bonus)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getRestQualKP(){
|
||||
return $this->sales_volume_points_sum - $this->qual_kp;
|
||||
$ret = $this->sales_volume_points_KP_sum - $this->qual_kp;
|
||||
return $ret > 0 ? $ret : 0;
|
||||
}
|
||||
|
||||
public function getCommissionTotal(){
|
||||
return round($this->commission_shop_sales + $this->commission_team_total, 2);
|
||||
return round($this->commission_shop_sales + $this->commission_pp_total + $this->commission_growth_total, 2);
|
||||
}
|
||||
//Provisierungslevel brechnen, Berechnung der Provisionen nach Level
|
||||
public function calcQualPP(){
|
||||
|
||||
public function calcQualTP(){
|
||||
if($this->isQualKP()){
|
||||
$this->b_user->total_qual_tp = $this->total_tp + $this->getRestQualKP();
|
||||
$commission_total = 0;
|
||||
$qualUserLevel = UserLevel::where('qual_tp', '<=', $this->total_qual_tp)->where('pos', '<=', $this->user_level_active_pos)->orderBy('qual_tp', 'desc')->first();
|
||||
$nextQualUserLevel = UserLevel::where('qual_tp', '<=', $this->total_qual_tp)->where('pos', '>', $this->user_level_active_pos)->orderBy('qual_tp', 'desc')->first();
|
||||
if($nextQualUserLevel){
|
||||
$this->b_user->next_qual_user_level = $nextQualUserLevel->toArray();
|
||||
}
|
||||
if($qualUserLevel){
|
||||
$this->b_user->qual_user_level = $qualUserLevel->toArray();
|
||||
foreach($this->business_lines as $line => $object){
|
||||
//growth_bonus = ab ebene 6 wachstumsbonus
|
||||
$object->margin = ($line <= 6) ? $this->qual_user_level['pr_line_'.$line] : $this->qual_user_level['growth_bonus'];
|
||||
$object->commission = round($object->points / 100 * $object->margin, 2);
|
||||
$commission_total += $object->commission;
|
||||
$this->b_user->business_lines[$line] = $object;
|
||||
//das ist der erreichte Provisierungslevel, nach paylinePoints und KP
|
||||
$qualUserLevel = $this->calcuQualLevel();
|
||||
if($qualUserLevel !== NULL){
|
||||
//prüfe einen Aufsieg im KarriereLevel
|
||||
$this->setNextUserLevel();
|
||||
$this->b_user->qual_user_level = $qualUserLevel->toArray();
|
||||
//setzen nächsten ProvisionsLevel wenn not isQualEqualLevel
|
||||
$this->setQualNextLevel();
|
||||
//Berechnung der Provisionen in der Payline
|
||||
$commission_pp_total = 0;
|
||||
$commission_growth_total = 0;
|
||||
for ($i=1; $i <= $qualUserLevel->paylines ; $i++) {
|
||||
if(isset($this->business_lines[$i])){
|
||||
$object = $this->business_lines[$i];
|
||||
$object->margin = $this->qual_user_level['pr_line_'.$i]; //provision in %
|
||||
$object->commission = round($object->points / 100 * $object->margin, 2); //provision in points/euro
|
||||
$object->payline = true;
|
||||
$commission_pp_total += $object->commission;
|
||||
$this->b_user->business_lines[$i] = $object;
|
||||
}
|
||||
}
|
||||
$this->b_user->commission_team_total = $commission_total;
|
||||
//Berechnung der Provisionen nach WB
|
||||
if($qualUserLevel->growth_bonus){
|
||||
//['growth_bonus'] //
|
||||
$payline = (int) $this->b_user->qual_user_level['paylines'] + 1;
|
||||
$maxlines = count($this->business_lines) + 1;
|
||||
$growth_bonus = (float) $this->b_user->qual_user_level['growth_bonus'];
|
||||
|
||||
for ($i=$payline; $i <= $maxlines ; $i++) {
|
||||
if(isset($this->business_lines[$i])){
|
||||
$object = $this->business_lines[$i];
|
||||
$object->margin = $growth_bonus; //provision in %
|
||||
$object->commission = round($object->points / 100 * $object->margin, 2); //provision in points/euro
|
||||
$object->growth_bonus = true;
|
||||
$commission_growth_total += $object->commission;
|
||||
$this->b_user->business_lines[$i] = $object;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$this->b_user->commission_pp_total = $commission_pp_total;
|
||||
$this->b_user->commission_growth_total = $commission_growth_total;
|
||||
|
||||
}else{
|
||||
//erste Provisierungslevel als next setzen, hat keine oder wenig points
|
||||
$qualUserLevelNext = UserLevel::where('pos', '=', 1)->orderBy('qual_pp', 'asc')->first();
|
||||
if($qualUserLevelNext){
|
||||
$this->b_user->qual_user_level_next = $qualUserLevelNext->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//qualifikation nach qual_kp (KundenPoints) und qual_pp (PaylinePoints)
|
||||
public function calcuQualLevel(){
|
||||
//alle levels wo die qual_kp erreicht ist, sortiert nach Rang >
|
||||
$qualUserLevels = UserLevel::where('qual_kp', '<=', $this->sales_volume_points_KP_sum)->where('pos', '<=', $this->user_level_active_pos)->orderBy('qual_pp', 'desc')->get();
|
||||
foreach($qualUserLevels as $qualUserLevel){
|
||||
//brechnet die Points nach der Payline
|
||||
$payline_points = $this->getPointsforPayline($qualUserLevel->paylines);
|
||||
$payline_points_qual_kp = $payline_points + $this->getRestQualKP();
|
||||
if($payline_points_qual_kp >= $qualUserLevel->qual_pp){
|
||||
//match payline_points erreicht, ist der akutelle Level für die Provision
|
||||
$this->b_user->payline_points = $payline_points;
|
||||
$this->b_user->payline_points_qual_kp = $payline_points_qual_kp;
|
||||
|
||||
return $qualUserLevel;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// PaylinePoints nach paylines / welche ebenen gezählt werden, 3,4,5,6 ...
|
||||
private function getPointsforPayline($paylines){
|
||||
$payline_points = 0;
|
||||
for ($i=1; $i <= $paylines ; $i++) {
|
||||
if(isset($this->business_lines[$i])){
|
||||
$payline_points += $this->business_lines[$i]->points;
|
||||
}
|
||||
}
|
||||
return $payline_points;
|
||||
}
|
||||
//wenn nicht erreicht, was wäre der nächste Provisionslevel?
|
||||
private function setQualNextLevel(){
|
||||
if(!$this->isQualEqualLevel()){
|
||||
$qualUserLevelNext = UserLevel::where('id', '=', $this->b_user->qual_user_level['next_id'])->orderBy('qual_pp', 'asc')->first();
|
||||
if($qualUserLevelNext){
|
||||
$this->b_user->qual_user_level_next = $qualUserLevelNext->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function setNextUserLevel(){
|
||||
dd($this->b_user->payline_points_qual_kp);
|
||||
$this->b_user->total_qual_pp = $this->total_pp + $this->getRestQualKP();
|
||||
$nextQualUserLevel = UserLevel::where('qual_pp', '<=', $this->total_qual_pp)->where('pos', '>', $this->user_level_active_pos)->orderBy('qual_pp', 'desc')->first();
|
||||
if($nextQualUserLevel && $this->isQualKP()){
|
||||
$this->b_user->next_qual_user_level = $nextQualUserLevel->toArray();
|
||||
}else{
|
||||
//wenn nicht erreicht, was wäre der nächste Karrierelevel?
|
||||
$nextCanUserLevel = UserLevel::where('pos', '>', $this->user_level_active_pos)->orderBy('qual_pp', 'asc')->first();
|
||||
if($nextCanUserLevel){
|
||||
$this->b_user->next_can_user_level = $nextCanUserLevel->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*public function storeUser(){
|
||||
|
|
@ -174,7 +305,6 @@ class BusinessUserItem
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function readStoredParentsBusinessUsers($structure){
|
||||
|
||||
$parents = $this->findParentsBusinessOnStored($this->b_user->user_id, $structure);
|
||||
|
|
|
|||
120
app/Services/BusinessPlan/ExportBot.php
Normal file
120
app/Services/BusinessPlan/ExportBot.php
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\User;
|
||||
use stdClass;
|
||||
use Carbon;
|
||||
|
||||
class ExportBot
|
||||
{
|
||||
public $date;
|
||||
private $init_from;
|
||||
private $order;
|
||||
|
||||
public $user_tree;
|
||||
public $user_list;
|
||||
|
||||
private $root_user;
|
||||
|
||||
|
||||
public function __construct($init_from = 'member')
|
||||
{
|
||||
$this->date = Carbon::now();
|
||||
$this->init_from = $init_from;
|
||||
}
|
||||
|
||||
public function initStructureUser(User $user, $order='list') //tree or list
|
||||
{
|
||||
$line = 0;
|
||||
$this->order = $order;
|
||||
$this->root_user = $user;
|
||||
|
||||
if($this->order === 'tree'){
|
||||
$this->user_tree = $this->setUserValues($user, $line);
|
||||
$this->user_tree->childs = $this->readChildUsers($this->user_tree, $line+1);
|
||||
}
|
||||
if($this->order === 'list'){
|
||||
$this->user_list = $this->setUserValues($user, $line);
|
||||
$this->readChildUsers($this->user_list, $line+1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function readChildUsers($parent_user, $line){
|
||||
|
||||
$childUsers = [];
|
||||
$users = User::with('account')->select('users.*')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
->where('users.admin', "<", 4)
|
||||
->where('users.m_level', "!=", null)
|
||||
->where('users.m_sponsor', "=", $parent_user->user_id) //<- need the id for childs / sponsors
|
||||
->where('users.payment_account', "!=", null)
|
||||
->where('users.active', "=", 1)
|
||||
->get();
|
||||
|
||||
if($users){
|
||||
foreach($users as $user){
|
||||
$user_values = $this->setUserValues($user, $line);
|
||||
$childUsers[] = $user_values;
|
||||
if($this->order === 'list'){
|
||||
$this->user_list->childs[] = $user_values;
|
||||
$this->readChildUsers($user_values, $line+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $childUsers;
|
||||
}
|
||||
|
||||
private function setUserValues(User $user, $line){
|
||||
|
||||
$sponsor_name = "";
|
||||
if($user->m_sponsor && $user->user_sponsor->account){
|
||||
$sponsor_name = $user->user_sponsor->account->m_first_name." ".$user->user_sponsor->account->m_last_name;
|
||||
}
|
||||
$obj = new stdClass();
|
||||
$obj->line = $line;
|
||||
|
||||
$obj->user_id = $user->id;
|
||||
$obj->m_level = $user->m_level;
|
||||
$obj->level_name = $user->user_level ? $user->user_level->name : '';
|
||||
$obj->m_sponsor = $user->m_sponsor;
|
||||
$obj->sponsor_name = $sponsor_name;
|
||||
$obj->m_account = $user->m_account;
|
||||
$obj->email = $user->email;
|
||||
$obj->active_account = $user->payment_account ? Carbon::parse($user->payment_account)->gt(Carbon::parse($this->date->format('Y-m-d H:i:s'))) : 0;
|
||||
$obj->payment_account_date = $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "";
|
||||
$obj->first_name = $user->account->first_name;
|
||||
$obj->last_name = $user->account->last_name;
|
||||
$obj->address = $user->account->address;
|
||||
$obj->address_2 = $user->account->address_2;
|
||||
$obj->zipcode = $user->account->zipcode;
|
||||
$obj->city = $user->account->city;
|
||||
$obj->country_id = $user->account->country_id ? $user->account->country->de : "";
|
||||
$pre_phone = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone." " : "";
|
||||
$pre_mobil = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone." " : "";
|
||||
$obj->phone = $pre_phone.$user->account->phone;
|
||||
$obj->mobil = $pre_mobil.$user->account->mobil;
|
||||
$obj->birthday = $user->account->birthday;
|
||||
|
||||
if($this->order === 'tree'){
|
||||
$obj->childs = $this->readChildUsers($obj, $line+1);
|
||||
}
|
||||
if($this->order === 'list'){
|
||||
$obj->childs = [];
|
||||
}
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getUser(){
|
||||
return $this->root_user;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\User;
|
||||
use stdClass;
|
||||
use App\Services\Util;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserSalesVolume;
|
||||
|
|
@ -33,7 +34,9 @@ class SalesPointsVolume
|
|||
$shoppingOrder->user_sales_volume->message = 'zugewiesen: '.date('d.m.Y');
|
||||
|
||||
$syslog = $shoppingOrder->user_sales_volume->syslog;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'change form: #'.$form_user_id.' '.$form_user->email.' to: #'.$to_user_id.' '.$to_user->email;
|
||||
$from_email = $form_user ? $form_user->email : '';
|
||||
$to_email = $to_user ? $to_user->email : '';
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'change form: #'.$form_user_id.' '.$from_email.' to: #'.$to_user_id.' '.$to_email;
|
||||
$shoppingOrder->user_sales_volume->syslog = $syslog;
|
||||
|
||||
$shoppingOrder->user_sales_volume->save();
|
||||
|
|
@ -47,10 +50,23 @@ class SalesPointsVolume
|
|||
|
||||
}
|
||||
|
||||
private static function add_KP_TP_Points($userSalesVolume, $month_points){
|
||||
if($userSalesVolume->status_points === 2) { //KP
|
||||
$month_points->KP += $userSalesVolume->points;
|
||||
}else{
|
||||
// === 1 //TP + KP
|
||||
$month_points->KP += $userSalesVolume->points;
|
||||
$month_points->TP += $userSalesVolume->points;
|
||||
}
|
||||
return $month_points;
|
||||
}
|
||||
|
||||
public static function reCalculateSalesPointsVolume($user_id, $month, $year){
|
||||
|
||||
$userSalesVolumes = UserSalesVolume::where('user_id', $user_id)->where('month', $month)->where('year', $year)->orderBy('id', 'ASC')->get();
|
||||
$month_points = 0;
|
||||
$month_points = new stdClass();
|
||||
$month_points->KP = 0;
|
||||
$month_points->TP = 0;
|
||||
$month_total_net = 0;
|
||||
$month_shop_points = 0;
|
||||
$month_shop_total_net = 0;
|
||||
|
|
@ -59,21 +75,26 @@ class SalesPointsVolume
|
|||
foreach($userSalesVolumes as $userSalesVolume){
|
||||
switch ($userSalesVolume->status) {
|
||||
case 1: //Bestellung Berater
|
||||
$month_points += $userSalesVolume->points;
|
||||
$month_points = self::add_KP_TP_Points($userSalesVolume, $month_points);
|
||||
$month_total_net += $userSalesVolume->total_net;
|
||||
break;
|
||||
case 2: //Shop
|
||||
$month_shop_points += $userSalesVolume->points;
|
||||
$month_shop_total_net += $userSalesVolume->total_net;
|
||||
break;
|
||||
case 4: //add Berater
|
||||
$month_points += $userSalesVolume->points;
|
||||
case 4: //Gutschrift
|
||||
$month_points = self::add_KP_TP_Points($userSalesVolume, $month_points);
|
||||
$month_total_net += $userSalesVolume->total_net;
|
||||
break;
|
||||
case 4: //Registrierung
|
||||
$month_points = self::add_KP_TP_Points($userSalesVolume, $month_points);
|
||||
$month_total_net += $userSalesVolume->total_net;
|
||||
break;
|
||||
}
|
||||
$userSalesVolume->month_shop_points = $month_shop_points;
|
||||
$userSalesVolume->month_shop_total_net = $month_shop_total_net;
|
||||
$userSalesVolume->month_points = $month_points;
|
||||
$userSalesVolume->month_KP_points = $month_points->KP;
|
||||
$userSalesVolume->month_TP_points = $month_points->TP;
|
||||
$userSalesVolume->month_total_net = $month_total_net;
|
||||
$userSalesVolume->save();
|
||||
}
|
||||
|
|
@ -88,6 +109,7 @@ class SalesPointsVolume
|
|||
2 => 'hinzugefügt aus Shop',
|
||||
3 => 'hinzugefügt aus Shop / pending',
|
||||
*/
|
||||
|
||||
$status = self::getStatusByOrderPaymentFor($shoppingOrder);
|
||||
$user_id = $shoppingOrder->auth_user_id ? $shoppingOrder->auth_user_id : $shoppingOrder->member_id;
|
||||
//akuteller tag / Monat.
|
||||
|
|
@ -95,45 +117,27 @@ class SalesPointsVolume
|
|||
$year = date('Y');
|
||||
$date = date('d.m.Y');
|
||||
|
||||
if($status === 3){ //shop bestellung User pending if is_like
|
||||
$user_id = NULL;//$shoppingOrder->auth_user_id ? $shoppingOrder->auth_user_id : $shoppingOrder->member_id;
|
||||
$month_points = 0;
|
||||
$month_total_net = 0;
|
||||
$month_shop_points = 0;
|
||||
$month_shop_total_net = 0;
|
||||
}else{
|
||||
$month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
$month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
}
|
||||
switch ($status) {
|
||||
case 1: //Bestellung
|
||||
$month_points += $shoppingOrder->points;
|
||||
$month_total_net += $shoppingOrder->subtotal;
|
||||
break;
|
||||
case 2: //Shop
|
||||
$month_shop_points += $shoppingOrder->points;
|
||||
$month_shop_total_net += $shoppingOrder->subtotal;
|
||||
break;
|
||||
}
|
||||
|
||||
return UserSalesVolume::create([
|
||||
if($status === 3){ //shop bestellung User pending if is_like
|
||||
$user_id = NULL;
|
||||
}
|
||||
$user_sales_volume = UserSalesVolume::create([
|
||||
'user_id' => $user_id,
|
||||
'shopping_order_id' => $shoppingOrder->id,
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'date' => $date,
|
||||
'points' => $shoppingOrder->points,
|
||||
'month_points' => $month_points,
|
||||
'month_shop_points' => $month_shop_points,
|
||||
'total_net' => $shoppingOrder->subtotal,
|
||||
'month_total_net' => $month_total_net,
|
||||
'month_shop_total_net' => $month_shop_total_net,
|
||||
'total_net' => $shoppingOrder->subtotal,
|
||||
'status_points' => 1, //KP + TP
|
||||
'message' => '',
|
||||
'status' => $status,
|
||||
]);
|
||||
|
||||
if($status !== 3){
|
||||
self::reCalculateSalesPointsVolume($user_sales_volume->user_id, $user_sales_volume->month, $user_sales_volume->year);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function setToUserAndReCalculate(UserSalesVolume $user_sales_volume, $user_id){
|
||||
|
|
@ -181,6 +185,7 @@ class SalesPointsVolume
|
|||
|
||||
$user_sales_volume->message = 'geändert: '.date('d.m.Y');
|
||||
$user_sales_volume->info = $data['info'];
|
||||
$user_sales_volume->status_points = $data['status_points'];
|
||||
|
||||
$syslog = $user_sales_volume->syslog;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'edit points: #'.$old_points.' '.$user_sales_volume->points .' total: #'.$old_total_net.' '.$user_sales_volume->total_ne;
|
||||
|
|
@ -198,7 +203,6 @@ class SalesPointsVolume
|
|||
|
||||
public static function addSalesPointsVolume($data){
|
||||
|
||||
|
||||
if(!isset($data['user_id'])){
|
||||
\Session()->flash('alert-error', 'Kein Berater ausgewählt');
|
||||
return;
|
||||
|
|
@ -211,7 +215,7 @@ class SalesPointsVolume
|
|||
$total_net = isset($data['total_net']) ? Util::reFormatNumber($data['total_net']) : 0;
|
||||
$points = isset($data['points']) ? intval($data['points']) : 0;
|
||||
$syslog[date('d.m.Y-h:i:s')] = 'add points: #'.$points.' total: #'.$total_net;
|
||||
|
||||
$status = isset($data['status']) ? intval($data['status']) : 4;
|
||||
|
||||
$user_sales_volume = UserSalesVolume::create([
|
||||
'user_id' => $user->id,
|
||||
|
|
@ -220,11 +224,12 @@ class SalesPointsVolume
|
|||
'year' => $year,
|
||||
'date' => $date,
|
||||
'points' => $points,
|
||||
'status_points' => $data['status_points'],
|
||||
'total_net' => $total_net,
|
||||
'message' => 'hinzugefügt: '.date('d.m.Y'),
|
||||
'info' => $data['info'],
|
||||
'syslog' => $syslog,
|
||||
'status' => 4,
|
||||
'status' => $status,
|
||||
]);
|
||||
|
||||
|
||||
|
|
|
|||
12
app/Services/BusinessPlan/SalesPointsVolumeHelper.php
Normal file
12
app/Services/BusinessPlan/SalesPointsVolumeHelper.php
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\Models\UserSalesVolume;
|
||||
|
||||
|
||||
|
||||
class SalesPointsVolumeHelper
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\Models\UserBusinessStructure;
|
||||
use App\User;
|
||||
use stdClass;
|
||||
use Carbon;
|
||||
use App\Models\UserBusinessStructure;
|
||||
|
||||
class TreeCalcBot
|
||||
{
|
||||
|
|
@ -24,7 +25,7 @@ class TreeCalcBot
|
|||
public function __construct($month, $year, $init_from = 'member')
|
||||
{
|
||||
$this->date = new stdClass();
|
||||
$date = \Carbon::parse($year.'-'.$month.'-1');
|
||||
$date = Carbon::parse($year.'-'.$month.'-1');
|
||||
$this->date->month = $month;
|
||||
$this->date->year = $year;
|
||||
$this->date->start_date = $date->format('Y-m-d H:i:s');
|
||||
|
|
@ -49,7 +50,7 @@ class TreeCalcBot
|
|||
|
||||
public function initStructureUser($user_id)
|
||||
{
|
||||
|
||||
|
||||
$BusinessUserItem = new BusinessUserItem($this->date);
|
||||
$BusinessUserItem->makeUser($user_id);
|
||||
$BusinessUserItem->addUserID();
|
||||
|
|
@ -63,13 +64,10 @@ class TreeCalcBot
|
|||
$this->readStoredSponsorUser($this->business_users[0]->sponsor->user_id);
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
$this->readParentsUsers();
|
||||
$this->readSponsorUser($user_id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -79,12 +77,14 @@ class TreeCalcBot
|
|||
$this->business_user->makeUser($user->id);
|
||||
$this->business_user->checkSponsor($user);
|
||||
if(!$this->business_user->isSave()){
|
||||
//Aufbau der Struktur für den User in die unendliche Tiefe.
|
||||
$this->business_user->readParentsBusinessUsers();
|
||||
//calculate Lines
|
||||
//calculate Points in Lines
|
||||
if(count($this->business_user->businessUserItems) > 0){
|
||||
$this->calcUserTP($this->business_user->businessUserItems, 1);
|
||||
$this->calcUserPoints($this->business_user->businessUserItems, 1);
|
||||
}
|
||||
$this->business_user->calcQualTP();
|
||||
//qualifikation nach qual_kp (KundenPoints) und qual_pp (PaylinePoints)
|
||||
$this->business_user->calcQualPP();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ class TreeCalcBot
|
|||
return false;
|
||||
}
|
||||
|
||||
private function calcUserTP($businessUserItems, $line){
|
||||
private function calcUserPoints($businessUserItems, $line){
|
||||
if(!isset($this->business_user->business_lines[$line])){
|
||||
$obj = new stdClass();
|
||||
$obj->points = 0;
|
||||
|
|
@ -110,10 +110,12 @@ class TreeCalcBot
|
|||
}
|
||||
foreach($businessUserItems as $business_user_item){
|
||||
if(count($business_user_item->businessUserItems) > 0){
|
||||
$this->calcUserTP($business_user_item->businessUserItems, $line+1);
|
||||
$this->calcUserPoints($business_user_item->businessUserItems, $line+1);
|
||||
}
|
||||
$this->business_user->addBusinessLinePoints($line, $business_user_item->sales_volume_points_sum);
|
||||
$this->business_user->addTotalTP($business_user_item->sales_volume_points_sum);
|
||||
//business_lines points nach line
|
||||
$this->business_user->addBusinessLinePoints($line, $business_user_item->sales_volume_points_TP_sum); //TP + Shop Points
|
||||
//total_pp gesamte Punkte
|
||||
$this->business_user->addTotalTP($business_user_item->sales_volume_points_TP_sum); //TP + Shop Points
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +261,8 @@ class TreeCalcBot
|
|||
private function addItem($item, $deep){
|
||||
|
||||
$button = '';
|
||||
if(($this->init_from === 'admin' && \Auth::user()->isAdmin()) || ($this->init_from === 'member' && \Auth::user()->id === $item->user_id)){
|
||||
|
||||
if(($this->init_from === 'admin' && \Auth::user()->isAdmin()) || ($this->init_from === 'member')){ // && \Auth::user()->id === $item->user_id
|
||||
$button = ' | <button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$item->user_id.'"
|
||||
data-action="business-user-detail"
|
||||
|
|
@ -280,7 +283,7 @@ class TreeCalcBot
|
|||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level_name.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_KP_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | E: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
$button
|
||||
:
|
||||
|
|
@ -324,7 +327,7 @@ class TreeCalcBot
|
|||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level_name.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_KP_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | E: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
' | <button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$item->user_id.'"
|
||||
|
|
@ -356,7 +359,7 @@ class TreeCalcBot
|
|||
if($this->init_from === 'admin'){
|
||||
$ret .= '<br><span class="small">'.
|
||||
($this->sponsor->active_account ?
|
||||
'<strong>Gesamte Points: '.$this->sponsor->sales_volume_points_sum.'</strong> | E: '.$this->sponsor->sales_volume_points.' | S: '.$this->sponsor->sales_volume_points_shop.' <strong>
|
||||
'<strong>Gesamte Points: '.$this->sponsor->sales_volume_points_sum.'</strong> | E: '.$this->sponsor->sales_volume_KP_points.' | S: '.$this->sponsor->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($this->sponsor->sales_volume_total_sum).' €</strong> | E: '.formatNumber($this->sponsor->sales_volume_total).' € | S: '.formatNumber($this->sponsor->sales_volume_total_shop).' €'
|
||||
:
|
||||
'Account bis: '.$this->sponsor->payment_account_date).
|
||||
|
|
|
|||
379
app/Services/BusinessPlan/TreeExportBot.php
Normal file
379
app/Services/BusinessPlan/TreeExportBot.php
Normal file
|
|
@ -0,0 +1,379 @@
|
|||
<?php
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\User;
|
||||
use stdClass;
|
||||
use Carbon;
|
||||
use App\Models\UserBusinessStructure;
|
||||
|
||||
class ExportBot
|
||||
{
|
||||
public $date;
|
||||
public $business_user;
|
||||
|
||||
public $business_users = [];
|
||||
public $parentless = [];
|
||||
|
||||
private $sponsor;
|
||||
private $init_from;
|
||||
private static $userIDs = [];
|
||||
|
||||
public static function addUserID($id){
|
||||
self::$userIDs[$id] = $id;
|
||||
}
|
||||
|
||||
public function __construct($month, $year, $init_from = 'member')
|
||||
{
|
||||
$this->date = new stdClass();
|
||||
$date = Carbon::parse($year.'-'.$month.'-1');
|
||||
$this->date->month = $month;
|
||||
$this->date->year = $year;
|
||||
$this->date->start_date = $date->format('Y-m-d H:i:s');
|
||||
$this->date->end_date = $date->endOfMonth()->format('Y-m-d H:i:s');
|
||||
$this->init_from = $init_from;
|
||||
}
|
||||
|
||||
public function initStructureAdmin($check = true)
|
||||
{
|
||||
//check is month is saved.
|
||||
if($check && $UserBusinessStructure = self::isFromStored($this->date->month, $this->date->year)){
|
||||
$this->readStoredRootUsers($UserBusinessStructure);
|
||||
$this->readStoredParentsUsers($UserBusinessStructure);
|
||||
$this->readStoredParentlessUser($UserBusinessStructure);
|
||||
}else{
|
||||
$this->readRootUsers();
|
||||
$this->readParentsUsers();
|
||||
$this->readParentlessUser();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function initStructureUser($user_id)
|
||||
{
|
||||
|
||||
$BusinessUserItem = new BusinessUserItem($this->date);
|
||||
$BusinessUserItem->makeUser($user_id);
|
||||
$BusinessUserItem->addUserID();
|
||||
$this->business_users[] = $BusinessUserItem;
|
||||
|
||||
//check is month is saved.
|
||||
if($UserBusinessStructure = self::isFromStored($this->date->month, $this->date->year)){
|
||||
$this->readStoredParentsUsers($UserBusinessStructure);
|
||||
|
||||
if(isset($this->business_users[0]) && $this->business_users[0]->sponsor){
|
||||
$this->readStoredSponsorUser($this->business_users[0]->sponsor->user_id);
|
||||
}
|
||||
|
||||
}else{
|
||||
$this->readParentsUsers();
|
||||
$this->readSponsorUser($user_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function initBusinesslUserDetail($user)
|
||||
{
|
||||
$this->business_user = new BusinessUserItem($this->date);
|
||||
$this->business_user->makeUser($user->id);
|
||||
$this->business_user->checkSponsor($user);
|
||||
if(!$this->business_user->isSave()){
|
||||
//Aufbau der Struktur für den User in die unendliche Tiefe.
|
||||
$this->business_user->readParentsBusinessUsers();
|
||||
//calculate Points in Lines
|
||||
if(count($this->business_user->businessUserItems) > 0){
|
||||
$this->calcUserPoints($this->business_user->businessUserItems, 1);
|
||||
}
|
||||
//qualifikation nach qual_kp (KundenPoints) und qual_pp (PaylinePoints)
|
||||
$this->business_user->calcQualPP();
|
||||
}
|
||||
}
|
||||
|
||||
/*public function storeBusinesslUser()
|
||||
{
|
||||
$this->business_user->storeUser();
|
||||
}*/
|
||||
|
||||
public static function isFromStored($month, $year){
|
||||
//when is stored an completed
|
||||
$UserBusinessStructure = UserBusinessStructure::where('year', $year)->where('month', $month)->first();
|
||||
if($UserBusinessStructure && $UserBusinessStructure->completed){
|
||||
return $UserBusinessStructure;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function calcUserPoints($businessUserItems, $line){
|
||||
if(!isset($this->business_user->business_lines[$line])){
|
||||
$obj = new stdClass();
|
||||
$obj->points = 0;
|
||||
$this->business_user->addBusinessLineToUser($line, $obj);
|
||||
}
|
||||
foreach($businessUserItems as $business_user_item){
|
||||
if(count($business_user_item->businessUserItems) > 0){
|
||||
$this->calcUserPoints($business_user_item->businessUserItems, $line+1);
|
||||
}
|
||||
//business_lines points nach line
|
||||
$this->business_user->addBusinessLinePoints($line, $business_user_item->sales_volume_points_TP_sum); //TP + Shop Points
|
||||
//total_pp gesamte Punkte
|
||||
$this->business_user->addTotalTP($business_user_item->sales_volume_points_TP_sum); //TP + Shop Points
|
||||
}
|
||||
}
|
||||
|
||||
public function getGrowthBonus(){
|
||||
if(count($this->business_user->business_lines) > 6){
|
||||
$b_lines = $this->business_user->business_lines->toArray();
|
||||
return array_slice($b_lines, 6);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
public function getKeybyLine($line, $key){
|
||||
if($this->business_user->business_lines){
|
||||
$b_lines = $this->business_user->business_lines;
|
||||
if(isset($b_lines[$line])){
|
||||
if($b_lines[$line] instanceof stdClass){
|
||||
if(isset($b_lines[$line]->{$key})){
|
||||
return $b_lines[$line]->{$key};
|
||||
}
|
||||
}else{
|
||||
if(isset($b_lines[$line][$key])){
|
||||
return $b_lines[$line][$key];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//* reading from current*//
|
||||
private function readRootUsers(){
|
||||
$users = User::with('account')->select('users.*')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
->where('users.admin', "<", 4)
|
||||
->where('users.m_level', "!=", null)
|
||||
->where('users.m_sponsor', "=", null)
|
||||
->where('users.payment_account', "!=", null)
|
||||
->where('users.active_date', "<=", $this->date->end_date)
|
||||
->get();
|
||||
if($users){
|
||||
foreach($users as $user){
|
||||
$BusinessUserItem = new BusinessUserItem($this->date);
|
||||
$BusinessUserItem->makeUser($user->id);
|
||||
$BusinessUserItem->addUserID();
|
||||
$this->business_users[] = $BusinessUserItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function readParentsUsers(){
|
||||
foreach($this->business_users as $business_user){
|
||||
$business_user->readParentsBusinessUsers();
|
||||
}
|
||||
}
|
||||
|
||||
private function readParentlessUser(){
|
||||
$users = User::with('account')->select('users.*')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
->where('users.admin', "<", 4)
|
||||
->where('users.payment_account', "!=", null)
|
||||
->where('users.active_date', "<=", $this->date->end_date)
|
||||
->get();
|
||||
|
||||
foreach($users as $user){
|
||||
if(!isset(self::$userIDs[$user->id])){
|
||||
$BusinessUserItem = new BusinessUserItem($this->date);
|
||||
$BusinessUserItem->makeUser($user->id);
|
||||
$this->parentless[] = $BusinessUserItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//* reading from stored*//
|
||||
private function readStoredRootUsers(UserBusinessStructure $userBusinessStructure){
|
||||
//first level is root
|
||||
if($userBusinessStructure->structure){
|
||||
foreach($userBusinessStructure->structure as $obj){
|
||||
$BusinessUserItem = new BusinessUserItem($this->date);
|
||||
$BusinessUserItem->makeUser($obj->user_id);
|
||||
$BusinessUserItem->addUserID();
|
||||
$this->business_users[] = $BusinessUserItem;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function readStoredParentsUsers(UserBusinessStructure $userBusinessStructure){
|
||||
foreach($this->business_users as $business_user){
|
||||
$business_user->readStoredParentsBusinessUsers($userBusinessStructure->structure);
|
||||
}
|
||||
}
|
||||
|
||||
private function readStoredParentlessUser(UserBusinessStructure $userBusinessStructure){
|
||||
if($userBusinessStructure->parentless){
|
||||
foreach($userBusinessStructure->parentless as $obj){
|
||||
if(!isset(self::$userIDs[$obj->user_id])){
|
||||
$BusinessUserItem = new BusinessUserItem($this->date);
|
||||
$BusinessUserItem->makeUser($obj->user_id);
|
||||
$this->parentless[] = $BusinessUserItem;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function readSponsorUser($user_id){
|
||||
$user = User::find($user_id);
|
||||
$userSponsor = User::find($user->m_sponsor);
|
||||
if($userSponsor){
|
||||
$this->sponsor = new BusinessUserItem($this->date);
|
||||
$this->sponsor->makeUser($userSponsor->id);
|
||||
}
|
||||
}
|
||||
|
||||
public function readStoredSponsorUser($user_id){
|
||||
|
||||
$this->sponsor = new BusinessUserItem($this->date);
|
||||
$this->sponsor->makeUser($user_id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getItems(){
|
||||
return $this->business_users;
|
||||
}
|
||||
|
||||
public function makeHtmlTree(){
|
||||
$deep = 0;
|
||||
$ret = '<ol class="dd-list">';
|
||||
foreach($this->business_users as $business_user){
|
||||
$ret .= $this->addItem($business_user, $deep);
|
||||
}
|
||||
$ret .= '</ol>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function addItem($item, $deep){
|
||||
|
||||
$button = '';
|
||||
|
||||
if(($this->init_from === 'admin' && \Auth::user()->isAdmin()) || ($this->init_from === 'member')){ // && \Auth::user()->id === $item->user_id
|
||||
$button = ' | <button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$item->user_id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="'.$this->init_from .'"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>';
|
||||
}
|
||||
return '<li class="dd-item dd-nodrag" data-id="'.$item->user_id.'">'.
|
||||
'<div class="dd-handle">
|
||||
<div class="media align-items-center">
|
||||
<div class="d-flex flex-column justify-content-center align-items-center">
|
||||
'.(($deep > 0) ? '<div class="text-large font-weight-bolder line-height-1 my-2 text-secondary badge badge-outline-secondary">'.$deep.'</div>' : '').'
|
||||
</div>
|
||||
<div class="media-body ml-2">
|
||||
<span class="'.($item->active_account ? '' : 'text-muted').'">
|
||||
<span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>
|
||||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level_name.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_KP_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | E: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
$button
|
||||
:
|
||||
'Account bis: '.$item->payment_account_date).
|
||||
'</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>'.
|
||||
$this->addParentItem($item, $deep).
|
||||
'</li>';
|
||||
|
||||
}
|
||||
|
||||
private function addParentItem($item, $deep){
|
||||
if($item->businessUserItems){
|
||||
$ret = '<ol class="dd-list dd-nodrag">';
|
||||
foreach($item->businessUserItems as $parent){
|
||||
$ret .= $this->addItem($parent, $deep+1);
|
||||
}
|
||||
$ret .='</ol>';
|
||||
return $ret;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
public function isParentless(){
|
||||
return $this->parentless ? true : false;
|
||||
}
|
||||
|
||||
public function makeParentlessHtml(){
|
||||
$ret = "";
|
||||
foreach($this->parentless as $item){
|
||||
$ret .= '<li class="dd-item dd-nodrag" data-id="'.$item->user_id.'">'.
|
||||
'<div class="dd-handle">
|
||||
<span class="'.($item->active_account ? '' : 'text-muted').'">
|
||||
<span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>
|
||||
<strong>'.$item->first_name.' '.$item->last_name.'</strong> <a href="mailto: '.$item->email.'">'.$item->email.'</a> <span class="badge badge-outline-default '.($item->active_account ? '' : 'text-muted').'">'.$item->user_level_name.' | '.$item->m_account.'</span>
|
||||
<br><span class="small">'.
|
||||
($item->active_account ?
|
||||
'<strong>Gesamte Points: '.$item->sales_volume_points_sum.'</strong> | E: '.$item->sales_volume_KP_points.' | S: '.$item->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($item->sales_volume_total_sum).' €</strong> | E: '.formatNumber($item->sales_volume_total).' € | S: '.formatNumber($item->sales_volume_total_shop).' €'.
|
||||
' | <button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$item->user_id.'"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-route="'.route('modal_load').'"><span class="far fa-calculator"></span></button>'
|
||||
:
|
||||
'Account bis: '.$item->payment_account_date).
|
||||
'<br>'.$item->m_sponsor_name.
|
||||
'</span>
|
||||
</span>
|
||||
</div>'.
|
||||
'</li>';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function makeSponsorHtml(){
|
||||
|
||||
if($this->sponsor){
|
||||
//' | <a href="' . route('admin_business_user_detail', [$this->sponsor->id]) . '" class="btn icon-btn btn-xs btn-secondary"><span class="far fa-calculator"></span></a>'
|
||||
$ret = '<li class="dd-item dd-nodrag" data-id="">'.
|
||||
'<div class="dd-handle">
|
||||
<span class="'.($this->sponsor->active_account ? '' : 'text-muted').'">
|
||||
<span class="mr-1 ion ion-ios-contact '.($this->sponsor->active_account ? 'text-primary' : 'text-danger').'"></span>
|
||||
<strong>'.$this->sponsor->first_name.' '.$this->sponsor->last_name.'</strong> <a href="mailto: '.$this->sponsor->email.'">'.$this->sponsor->email.'</a> <span class="badge badge-outline-default '.($this->sponsor->active_account ? '' : 'text-muted').'">'.$this->sponsor->user_level_name.' | '.$this->sponsor->m_account.'</span>';
|
||||
|
||||
if($this->init_from === 'admin'){
|
||||
$ret .= '<br><span class="small">'.
|
||||
($this->sponsor->active_account ?
|
||||
'<strong>Gesamte Points: '.$this->sponsor->sales_volume_points_sum.'</strong> | E: '.$this->sponsor->sales_volume_KP_points.' | S: '.$this->sponsor->sales_volume_points_shop.' <strong>
|
||||
| Umsatz netto: '.formatNumber($this->sponsor->sales_volume_total_sum).' €</strong> | E: '.formatNumber($this->sponsor->sales_volume_total).' € | S: '.formatNumber($this->sponsor->sales_volume_total_shop).' €'
|
||||
:
|
||||
'Account bis: '.$this->sponsor->payment_account_date).
|
||||
'</span>';
|
||||
}
|
||||
$ret .= '</span>
|
||||
</div>
|
||||
</li>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
return 'Keinen Sponsor zugewiesen';
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -11,14 +11,16 @@ class Credit
|
|||
{
|
||||
|
||||
public static function getCreditNumber(){
|
||||
return (int) Setting::getContentBySlug('credit-number');
|
||||
//return (int) Setting::getContentBySlug('credit-number');
|
||||
return (int) Setting::getContentBySlug('invoice-number');
|
||||
}
|
||||
|
||||
|
||||
public static function makeNextCreditNumber(){
|
||||
$credit_number = self::getCreditNumber();
|
||||
$credit_number = $credit_number+1;
|
||||
Setting::setContentBySlug('credit-number', $credit_number, 'int');
|
||||
//Setting::setContentBySlug('credit-number', $credit_number, 'int');
|
||||
Setting::setContentBySlug('invoice-number', $credit_number, 'int');
|
||||
return $credit_number;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ class CustomerPriority
|
|||
}
|
||||
|
||||
public static function entryIsMember($shopping_user){
|
||||
if($user = User::whereEmail($shopping_user->billing_email)->first()){
|
||||
if($user = User::whereEmail($shopping_user->billing_email)->whereActive(1)->first()){
|
||||
$member_id = $user->id;
|
||||
$shopping_user->member_id = $member_id;
|
||||
$shopping_user->number = self::nextNumber();
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ class HomepartyUserCart
|
|||
public $ek_price;
|
||||
public $ek_price_net;
|
||||
|
||||
public $real_price;
|
||||
|
||||
public $income_price;
|
||||
|
||||
public $weight;
|
||||
|
|
@ -49,6 +51,8 @@ class HomepartyUserCart
|
|||
$this->ek_price = 0;
|
||||
$this->ek_price_net = 0;
|
||||
|
||||
$this->real_price = 0;
|
||||
|
||||
$this->income_price = 0;
|
||||
$this->weight = 0;
|
||||
$this->shipping_weight = 0;
|
||||
|
|
@ -64,6 +68,7 @@ class HomepartyUserCart
|
|||
foreach ($this->homepartyUser->homeparty_user_order_items as $order_item) {
|
||||
$this->points += $order_item->getTotalPoints();
|
||||
$this->price += $order_item->getTotalPrice();
|
||||
$this->real_price += $order_item->getTotalPrice();
|
||||
$this->price_net += $order_item->geTotalPriceNet();
|
||||
$this->ek_price += $order_item->geTotalEKPrice();
|
||||
$this->ek_price_net += $order_item->geTotalEKPriceNet();
|
||||
|
|
@ -72,7 +77,9 @@ class HomepartyUserCart
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function isPrice(){
|
||||
return ($this->real_price) > 0 ? true : false;
|
||||
}
|
||||
public function getFormattedPoints()
|
||||
{
|
||||
return formatNumber($this->points, 0);
|
||||
|
|
@ -83,6 +90,11 @@ class HomepartyUserCart
|
|||
return formatNumber($this->price);
|
||||
}
|
||||
|
||||
public function getFormattedPriceWithout()
|
||||
{
|
||||
return formatNumber($this->price - $this->shipping_price);
|
||||
}
|
||||
|
||||
public function getFormattedPriceNet()
|
||||
{
|
||||
return formatNumber($this->price_net);
|
||||
|
|
@ -140,6 +152,9 @@ class HomepartyUserCart
|
|||
case 'Price':
|
||||
$rNumber = $this->price * $faktor;
|
||||
break;
|
||||
case 'PriceWithout':
|
||||
$rNumber = ($this->price - $this->shipping_price) * $faktor;
|
||||
break;
|
||||
case 'EkPrice':
|
||||
$rNumber = $this->ek_price * $faktor;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use App\Models\ShoppingPayment;
|
|||
use App\Services\ShopApiOrderCart;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use App\Services\BusinessPlan\SalesPointsVolume;
|
||||
|
||||
class Payment
|
||||
{
|
||||
|
|
@ -106,6 +107,21 @@ class Payment
|
|||
]);
|
||||
}
|
||||
|
||||
public static function addSponsorBuyingPoints(User $user, $product){
|
||||
|
||||
if($user->user_sponsor){
|
||||
$data = [
|
||||
'user_id' => $user->user_sponsor->id,
|
||||
'total_net' => 0,
|
||||
'points' => $product->sponsor_buying_points_amount,
|
||||
'info' => 'VP: '.$user->getFullName(false).' | '.$product->name,
|
||||
'status_points' => 2,
|
||||
'status' => 5
|
||||
];
|
||||
SalesPointsVolume::addSalesPointsVolume($data);
|
||||
}
|
||||
}
|
||||
|
||||
public static function updateUserLevel(User $user, $to_level_id){
|
||||
//nur updaten, wenn der user->m_level kleiner ist als $to_level_id
|
||||
if($user->user_level){
|
||||
|
|
@ -140,6 +156,9 @@ class Payment
|
|||
if($shopping_order_item->product->buying_restriction){
|
||||
self::addBuyingRestriction($user, $shopping_order_item->product->id);
|
||||
}
|
||||
if($shopping_order_item->product->sponsor_buying_points){
|
||||
self::addSponsorBuyingPoints($user, $shopping_order_item->product);
|
||||
}
|
||||
if($shopping_order_item->product->action){
|
||||
$send_link = true;
|
||||
//new date
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ class ShopApiOrderCart
|
|||
//only for tax split / tax and price on calculate function
|
||||
|
||||
$this->shoppingCollectOrder->addTaxToSplit($tax_rate, $user_tax_qty);
|
||||
$this->shoppingCollectOrder->addNetToSplit($tax_rate, $user_price_net_qty);
|
||||
$this->shoppingCollectOrder->tax_total += $user_tax_qty;
|
||||
$this->shoppingCollectOrder->price_total_net += $user_price_net_qty;
|
||||
$this->shoppingCollectOrder->points += ($item->points * $item->qty);
|
||||
|
|
@ -96,6 +97,7 @@ class ShopApiOrderCart
|
|||
$this->shoppingCollectOrder->tax_total += $this->shoppingCollectOrder->shipping_tax;
|
||||
//add shipping tax to split
|
||||
$this->shoppingCollectOrder->addTaxToSplit(config('app.main_tax_rate'), $this->shoppingCollectOrder->shipping_tax);
|
||||
$this->shoppingCollectOrder->addNetToSplit(config('app.main_tax_rate'), $this->shoppingCollectOrder->shipping_net);
|
||||
|
||||
$this->shoppingCollectOrder->price_total_net += $this->shoppingCollectOrder->shipping_net;
|
||||
$this->shoppingCollectOrder->price_total = round($this->shoppingCollectOrder->tax_total + $this->shoppingCollectOrder->price_total_net, 2);
|
||||
|
|
|
|||
67
app/Services/SyS/ChangeUserBusinesses.php
Normal file
67
app/Services/SyS/ChangeUserBusinesses.php
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
namespace App\Services\SyS;
|
||||
|
||||
use Request;
|
||||
use App\Models\UserBusiness;
|
||||
|
||||
|
||||
class ChangeUserBusinesses
|
||||
{
|
||||
|
||||
public static function show()
|
||||
{
|
||||
|
||||
dump("ChangeUserBusinesses");
|
||||
dd('check function');
|
||||
$UserBusiness = UserBusiness::all();
|
||||
$c = 0;
|
||||
foreach($UserBusiness as $user_business){
|
||||
|
||||
if($user_business->qual_user_level){
|
||||
$qual_user_level = $user_business->qual_user_level;
|
||||
if(isset($qual_user_level['qual_tp'])){
|
||||
$qual_user_level['qual_pp'] = $qual_user_level['qual_tp'];
|
||||
unset($qual_user_level['qual_tp']);
|
||||
}
|
||||
if(!isset($qual_user_level['paylines'])){
|
||||
$qual_user_level['paylines'] = 6;
|
||||
|
||||
}
|
||||
$user_business->qual_user_level = $qual_user_level;
|
||||
$c ++;
|
||||
$user_business->save();
|
||||
}
|
||||
|
||||
if($user_business->next_qual_user_level){
|
||||
$next_qual_user_level = $user_business->next_qual_user_level;
|
||||
if(isset($next_qual_user_level['qual_tp'])){
|
||||
$next_qual_user_level['qual_pp'] = $next_qual_user_level['qual_tp'];
|
||||
unset($next_qual_user_level['qual_tp']);
|
||||
}
|
||||
if(!isset($next_qual_user_level['paylines'])){
|
||||
$next_qual_user_level['paylines'] = 6;
|
||||
}
|
||||
$user_business->next_qual_user_level = $next_qual_user_level;
|
||||
|
||||
$c ++;
|
||||
$user_business->save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
dump("counter");
|
||||
dd($c);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
\Session()->flash('alert-save', true);
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -16,7 +16,7 @@ use App\Services\BusinessPlan\SalesPointsVolume;
|
|||
class Correction
|
||||
{
|
||||
|
||||
private static function userSalesVolume($order){
|
||||
private static function calcuUserSalesVolume($order){
|
||||
/*
|
||||
status
|
||||
1 => 'hinzugefügt aus Bestellung',
|
||||
|
|
@ -78,9 +78,9 @@ class Correction
|
|||
|
||||
$c = 0;
|
||||
|
||||
if(true){ //11
|
||||
if(false){ //11
|
||||
dump("calculate user_sales_volumes from Orders");
|
||||
//dd('check function');
|
||||
dd('check function');
|
||||
$year = 21;
|
||||
$months = range(1, 12);
|
||||
foreach($months as $month){
|
||||
|
|
@ -89,7 +89,7 @@ class Correction
|
|||
|
||||
if(UserSalesVolume::whereShoppingOrderId($item->id)->count() === 0){
|
||||
dump($item->id);
|
||||
self::userSalesVolume($item);
|
||||
self::calcuUserSalesVolume($item);
|
||||
}
|
||||
$c ++;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ class Correction
|
|||
}
|
||||
|
||||
if(false){ //9
|
||||
dump("make homeparty tax_split in shopping_order");
|
||||
dump("make getOrderPaymentFor in shopping_order");
|
||||
dd('check function');
|
||||
$ShoppingOrders = ShoppingOrder::where('payment_for', '=', NULL)->get();
|
||||
|
||||
|
|
@ -160,6 +160,7 @@ class Correction
|
|||
if(false){ //8
|
||||
dump("make homeparty tax_split in shopping_order");
|
||||
dd('check function');
|
||||
|
||||
$ShoppingOrders = ShoppingOrder::where('homeparty_id', '!=', NULL)->get();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
|
|
@ -198,9 +199,10 @@ class Correction
|
|||
if(false){ //6
|
||||
dump("make tax_split in shopping_order");
|
||||
dd('check function');
|
||||
$ShoppingOrders = ShoppingOrder::where('homeparty_id', '=', NULL)->get();
|
||||
//->skip(0)->take(500)->get();
|
||||
//->skip(500)->take(500)->get();
|
||||
|
||||
$ShoppingOrders = ShoppingOrder::where('homeparty_id', '=', NULL)//->get();
|
||||
->skip(0)->take(3000)->get();
|
||||
//->skip(3000)->take(5000)->get();
|
||||
foreach($ShoppingOrders as $ShoppingOrder){
|
||||
$ShoppingOrder->makeTaxSplit();
|
||||
$c ++;
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ class Util
|
|||
}
|
||||
|
||||
public static function formatNumber($value, $dec=2){
|
||||
$value = floatval(str_replace(',', '', $value));
|
||||
return number_format($value, $dec, self::_decimal_separator(), self::_thousands_separator());
|
||||
|
||||
}
|
||||
|
|
|
|||
19
app/User.php
19
app/User.php
|
|
@ -32,7 +32,6 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereRememberToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereToken($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
* @property int $confirmed
|
||||
* @property string|null $confirmation_code
|
||||
* @property string|null $confirmation_date
|
||||
|
|
@ -116,6 +115,7 @@ use Laravel\Passport\HasApiTokens;
|
|||
* @property-read int|null $tokens_count
|
||||
* @property array|null $payment_methods
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\User wherePaymentMethods($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
|
|
@ -482,18 +482,23 @@ class User extends Authenticatable
|
|||
}
|
||||
if($this->userSalesVolume){
|
||||
switch ($key) {
|
||||
case 'sales_volume_points':
|
||||
return $this->userSalesVolume->month_points;
|
||||
case 'sales_volume_KP_points':
|
||||
return $this->userSalesVolume->month_KP_points;
|
||||
break;
|
||||
case 'sales_volume_TP_points':
|
||||
return $this->userSalesVolume->month_TP_points;
|
||||
break;
|
||||
|
||||
case 'sales_volume_points_shop':
|
||||
return $this->userSalesVolume->month_shop_points;
|
||||
break;
|
||||
|
||||
case 'sales_volume_points_sum':
|
||||
return $this->userSalesVolume->getPointsSum();
|
||||
case 'sales_volume_points_KP_sum':
|
||||
return $this->userSalesVolume->getPointsKPSum();
|
||||
break;
|
||||
|
||||
case 'sales_volume_points_TP_sum':
|
||||
return $this->userSalesVolume->getPointsTPSum();
|
||||
break;
|
||||
//price net
|
||||
case 'sales_volume_total':
|
||||
return $this->userSalesVolume->month_total_net;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue