From 351a8f763c357035d5815e494a9ebe9c4cedf107 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Fri, 18 Jun 2021 15:02:34 +0200 Subject: [PATCH] Categories, Netto Homeparty --- app/Http/Controllers/Api/AuthController.php | 9 +++ .../Api/ShoppingUserController.php | 4 +- app/Http/Controllers/CronController.php | 2 +- .../Controllers/User/HomepartyController.php | 8 +-- .../Controllers/UserUpdateEmailController.php | 2 +- .../UserUpdatePasswordController.php | 28 ++++---- app/Models/HomepartyUserOrderItem.php | 20 +++++- app/Services/HomepartyCart.php | 66 ++++++++++++++----- app/Services/HomepartyUserCart.php | 5 ++ .../views/user/homeparty/guests.blade.php | 19 +++++- .../homeparty/show_calc_bonus_host.blade.php | 10 +-- .../homeparty/show_products_order.blade.php | 15 +++-- .../user/homeparty/show_total_order.blade.php | 20 +++--- 13 files changed, 144 insertions(+), 64 deletions(-) diff --git a/app/Http/Controllers/Api/AuthController.php b/app/Http/Controllers/Api/AuthController.php index 3a27d5f..611cb48 100755 --- a/app/Http/Controllers/Api/AuthController.php +++ b/app/Http/Controllers/Api/AuthController.php @@ -45,6 +45,15 @@ class AuthController extends Controller $token->expires_at = Carbon::now()->addDays(1); } + \DB::table('oauth_access_tokens') + ->whereDate('expires_at', '<', now()->addWeeks(1)) + ->delete(); + + \DB::table('oauth_refresh_tokens') + ->whereDate('expires_at', '<', now()->addWeeks(1)) + ->delete(); + + $token->save(); return response()->json([ 'access_token' => $tokenResult->accessToken, diff --git a/app/Http/Controllers/Api/ShoppingUserController.php b/app/Http/Controllers/Api/ShoppingUserController.php index 0cb809d..8298761 100755 --- a/app/Http/Controllers/Api/ShoppingUserController.php +++ b/app/Http/Controllers/Api/ShoppingUserController.php @@ -275,7 +275,7 @@ class ShoppingUserController extends Controller 'user' => $user, 'customer_priority' => $priority, 'customer_number' => $shopping_user->number, - 'member_email' => $shopping_user->member->email + 'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false, ], 'time' => Carbon::now()->toDateTimeString() ], 200); @@ -385,7 +385,7 @@ class ShoppingUserController extends Controller 'user' => $user, 'order' => $order, 'customer_number' => $shopping_user->number, - 'member_email' => $shopping_user->member->email, + 'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false, 'status' => $shopping_user->getAPIShippedType(), ], 'time' => Carbon::now()->toDateTimeString() diff --git a/app/Http/Controllers/CronController.php b/app/Http/Controllers/CronController.php index 9868e83..2a40d49 100644 --- a/app/Http/Controllers/CronController.php +++ b/app/Http/Controllers/CronController.php @@ -105,7 +105,7 @@ class CronController extends Controller dump($user->email." | ".$user->getPaymentAccountDateFormat()); die();*/ foreach ($users as $user){ - // $this->checkReminderPayments($user); + $this->checkReminderPayments($user); $this->userInitAboPayment($user); } return "TOSK"; diff --git a/app/Http/Controllers/User/HomepartyController.php b/app/Http/Controllers/User/HomepartyController.php index 57998d5..897dc57 100755 --- a/app/Http/Controllers/User/HomepartyController.php +++ b/app/Http/Controllers/User/HomepartyController.php @@ -268,8 +268,8 @@ class HomepartyController extends Controller 'points' => $product->points, 'margin' => $margin, 'ek-price' => $product->getPriceWith(false, true), + 'ek-price_net' => $product->getPriceWith(true, true), 'slug' => $product->slug - ]); } @@ -368,7 +368,7 @@ class HomepartyController extends Controller $date = date('d.m.Y H:i:s', $time); $user = User::find(Auth::user()->id); Yard::instance('shopping')->destroy(); - Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$price, ['image' => "", 'slug' => $time, 'weight' => 0]); + Yard::instance('shopping')->add($homeparty->id, 'Bestellung Homeparty '.$date, 1, \App\Services\HomepartyCart::$ek_price, ['image' => "", 'slug' => $time, 'weight' => 0]); do { $identifier = Util::getToken(); } while( ShoppingInstance::where('identifier', $identifier)->count() ); @@ -377,8 +377,8 @@ class HomepartyController extends Controller $data = []; $data['is_from'] = 'homeparty'; - $data['shop_price_net'] = HomepartyCart::getFormattedPriceNet(); - $data['shop_price_tax'] = HomepartyCart::getFormattedPriceTax(); + $data['shop_price_net'] = HomepartyCart::getFormattedEkPriceNet(); + $data['shop_price_tax'] = HomepartyCart::getFormattedEkPriceTax(); $data['homeparty_id'] = $homeparty->id; $data['is_for'] = 'hp'; diff --git a/app/Http/Controllers/UserUpdateEmailController.php b/app/Http/Controllers/UserUpdateEmailController.php index 1a0996e..6db4c76 100755 --- a/app/Http/Controllers/UserUpdateEmailController.php +++ b/app/Http/Controllers/UserUpdateEmailController.php @@ -34,7 +34,7 @@ class UserUpdateEmailController extends Controller } - public function update(Request $request) + public function update() { $user = Auth::user(); diff --git a/app/Http/Controllers/UserUpdatePasswordController.php b/app/Http/Controllers/UserUpdatePasswordController.php index c5acc3f..5c37a74 100755 --- a/app/Http/Controllers/UserUpdatePasswordController.php +++ b/app/Http/Controllers/UserUpdatePasswordController.php @@ -27,11 +27,8 @@ class UserUpdatePasswordController extends Controller } - /** - * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View - */ - public function updatePasswordStore(Request $request) + + public function updatePasswordStore() { $rules = array( 'old_password' => 'required|old_password:' . Auth::user()->password, @@ -54,8 +51,10 @@ class UserUpdatePasswordController extends Controller return view('user.update_password')->withErrors($validator); } - $request->user()->fill([ - 'password' => Hash::make($request->password) + $user = Auth::user(); + $data = Request::all(); + $user->fill([ + 'password' => Hash::make($data['password']) ])->save(); @@ -75,11 +74,8 @@ class UserUpdatePasswordController extends Controller return redirect(route('user_update_password')); } - /** - * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View - */ - public function updatePasswordFirstStore(Request $request) + + public function updatePasswordFirstStore() { $rules = array( 'password' => 'required|string|min:6|confirmed', @@ -96,12 +92,14 @@ class UserUpdatePasswordController extends Controller return view('user.update_password_first')->withErrors($validator); } - - $request->user()->fill([ - 'password' => Hash::make($request->password) + $user = Auth::user(); + $data = Request::all(); + $user->fill([ + 'password' => Hash::make($data['password']) ])->save(); + \Session()->flash('alert-save', '1'); return redirect('/home'); } diff --git a/app/Models/HomepartyUserOrderItem.php b/app/Models/HomepartyUserOrderItem.php index 0fef37c..a1010d4 100644 --- a/app/Models/HomepartyUserOrderItem.php +++ b/app/Models/HomepartyUserOrderItem.php @@ -63,7 +63,9 @@ class HomepartyUserOrderItem extends Model 'tax_rate' => 'float', 'points' => 'int', 'margin' => 'float', - 'ek-price' => 'float' + 'ek-price' => 'float', + 'ek-price_net' => 'float' + ]; protected $fillable = [ @@ -77,6 +79,7 @@ class HomepartyUserOrderItem extends Model 'points', 'margin', 'ek-price', + 'ek-price_net', 'slug' ]; @@ -125,6 +128,16 @@ class HomepartyUserOrderItem extends Model return formatNumber($this->attributes['ek-price'] * $this->attributes['qty']); } + public function getFormattedEKPriceNet() + { + return formatNumber($this->attributes['ek-price_net']); + } + + public function getFormattedTotalEKPriceNet() + { + return formatNumber($this->attributes['ek-price_net'] * $this->attributes['qty']); + } + public function getFormattedIncomePrice() { return formatNumber($this->attributes['price'] - $this->attributes['ek-price']); @@ -161,6 +174,11 @@ class HomepartyUserOrderItem extends Model return (float) ($this->attributes['ek-price'] * $this->attributes['qty']); } + public function geTotalEKPriceNet() + { + return (float) ($this->attributes['ek-price_net'] * $this->attributes['qty']); + } + public function getIncomePrice() { return (float) ($this->attributes['price'] - $this->attributes['ek-price']); diff --git a/app/Services/HomepartyCart.php b/app/Services/HomepartyCart.php index 1adb5c7..9dca0ef 100644 --- a/app/Services/HomepartyCart.php +++ b/app/Services/HomepartyCart.php @@ -26,6 +26,8 @@ class HomepartyCart public static $price = 0; public static $price_net = 0; public static $ek_price = 0; + public static $ek_price_net = 0; + public static $income_price = 0; private static $shipping_total = 0; @@ -52,14 +54,14 @@ class HomepartyCart private static $bonus_coupon_fault = 0; private static $bonus_coupon_next_step = 0; private static $bonus_coupon_next_value = 0; - private static $bonus_start = 200; + private static $bonus_start = 230; private static $bonusTable = [ - 250 => 15, - 300 => 20, - 400 => 30, - 500 => 35, - 600 => 40, - 700 => 50, + 295 => 15, + 350 => 20, + 460 => 30, + 565 => 35, + 670 => 40, + 780 => 50, ]; public static function calculateHomeparty(Homeparty $homeparty){ @@ -82,6 +84,7 @@ class HomepartyCart self::$price += $homepartyUserCart->price; self::$price_net += $homepartyUserCart->price_net; self::$ek_price += $homepartyUserCart->ek_price; + self::$ek_price_net += $homepartyUserCart->ek_price_net; self::$income_price += $homepartyUserCart->income_price; } @@ -98,8 +101,9 @@ class HomepartyCart self::$voucher_price = $proportional_voucher->price; self::$voucher_name = $proportional_voucher->getLang('name'); - self::$price += self::$voucher_price; - self::$price_net += $proportional_voucher->getPriceWith(true, false); + //add voucher to ek + self::$ek_price += self::$voucher_price; + self::$ek_price_net += $proportional_voucher->getPriceWith(true, false); $bonus_tmp = self::$price - self::$bonus_value; @@ -145,12 +149,16 @@ class HomepartyCart self::$bonus_points_diff = round($user_cart->points/100*$bonus_percent); $user_cart->points -= self::$bonus_points_diff; - $user_cart->price -= $bonus_total; + //sub bonus on host + $user_cart->price -= $bonus_total; $user_cart->price_net -= ($bonus_total / config('app.main_tax')); + $user_cart->ek_price -= $bonus_total; + $user_cart->ek_price_net -= ($bonus_total / config('app.main_tax')); + self::$price -= $bonus_total; self::$price_net -= ($bonus_total / config('app.main_tax')); - - + self::$ek_price -= $bonus_total; + self::$ek_price_net -= ($bonus_total / config('app.main_tax')); } } @@ -207,11 +215,25 @@ class HomepartyCart $user_cart->shipping_tax = round($price / (100+$shipping_price->tax_rate) * 100, 2); } - //on the end, add prices for porto - $user_cart->price += $user_cart->shipping_price; - $user_cart->price_net += $user_cart->shipping_price_net; - self::$price += $user_cart->shipping_price; - self::$price_net += $user_cart->shipping_price_net; + if($homeparty_user->is_host){ + //on the end, add prices for porto + //$user_cart->price += $user_cart->shipping_price; + //$user_cart->price_net += $user_cart->shipping_price_net; + }else{ + //on the end, add prices for porto + $user_cart->price += $user_cart->shipping_price; + $user_cart->price_net += $user_cart->shipping_price_net; + self::$price += $user_cart->shipping_price; + self::$price_net += $user_cart->shipping_price_net; + } + + + $user_cart->ek_price += $user_cart->shipping_price; + $user_cart->ek_price_net += $user_cart->shipping_price_net; + + + self::$ek_price += $user_cart->shipping_price; + self::$ek_price_net += $user_cart->shipping_price_net; self::$shipping_total += $user_cart->shipping_price; self::$shipping_net_total += $user_cart->shipping_price_net; @@ -240,6 +262,7 @@ class HomepartyCart 'price' => round(self::$price, 2), 'price_net' => round(self::$price_net, 2), 'ek_price' => round(self::$ek_price, 2), + 'ek_price_net' => round(self::$ek_price_net, 2), 'income_price' => round(self::$income_price, 2), 'user_host_id' => self::$user_host_id, 'is_bonus' => self::$is_bonus, @@ -263,6 +286,7 @@ class HomepartyCart 'price' => round($user_cart->price, 2), 'price_net' => round($user_cart->price_net, 2), 'ek_price' => round($user_cart->ek_price, 2), + 'ek_price_net' => round($user_cart->ek_price_net, 2), 'income_price' => round($user_cart->income_price, 2), 'weight' => $user_cart->weight, 'shipping_weight' => $user_cart->shipping_weight, @@ -302,6 +326,11 @@ class HomepartyCart return formatNumber(self::$ek_price); } + public static function getFormattedEkPriceNet() + { + return formatNumber(self::$ek_price_net); + } + public static function getFormattedIncomePrice() { return formatNumber(self::$income_price); @@ -310,6 +339,9 @@ class HomepartyCart public static function getFormattedPriceTax(){ return formatNumber(self::$price - self::$price_net); } + public static function getFormattedEkPriceTax(){ + return formatNumber(self::$ek_price - self::$ek_price_net); + } public static function getFormattedBonusPrice() { return formatNumber(self::$voucher_price); diff --git a/app/Services/HomepartyUserCart.php b/app/Services/HomepartyUserCart.php index 659fb09..d522e28 100644 --- a/app/Services/HomepartyUserCart.php +++ b/app/Services/HomepartyUserCart.php @@ -30,6 +30,8 @@ class HomepartyUserCart public $price; public $price_net; public $ek_price; + public $ek_price_net; + public $income_price; public $weight; @@ -53,6 +55,8 @@ class HomepartyUserCart $this->price = 0; $this->price_net = 0; $this->ek_price = 0; + $this->ek_price_net = 0; + $this->income_price = 0; $this->weight = 0; $this->shipping_weight = 0; @@ -70,6 +74,7 @@ class HomepartyUserCart $this->price += $order_item->getTotalPrice(); $this->price_net += $order_item->geTotalPriceNet(); $this->ek_price += $order_item->geTotalEKPrice(); + $this->ek_price_net += $order_item->geTotalEKPriceNet(); $this->income_price += $order_item->geTotalIncomePrice(); $this->weight += ($order_item->product->weight * $order_item->qty); } diff --git a/resources/views/user/homeparty/guests.blade.php b/resources/views/user/homeparty/guests.blade.php index cfc085c..56d9506 100644 --- a/resources/views/user/homeparty/guests.blade.php +++ b/resources/views/user/homeparty/guests.blade.php @@ -15,7 +15,10 @@ @foreach($homeparty->homeparty_users as $homeparty_user)
+ + @if(!$homeparty->completed)
+ @if($homeparty_user->is_host) Gastgeber/in: @@ -26,10 +29,7 @@ {{-- offen ... --}}
- @if(!$homeparty->completed) -
- bearbeiten
@if($homeparty_user->is_host) @@ -43,6 +43,19 @@ @endif
+ @else +
+ +
+ @if($homeparty_user->is_host) + Gastgeber/in: + @else + Gast {{$g_count++}}: + @endif + {{$homeparty_user->billing_firstname}} {{$homeparty_user->billing_lastname}} +
+ {{-- offen ... --}} +
@endif
diff --git a/resources/views/user/homeparty/show_calc_bonus_host.blade.php b/resources/views/user/homeparty/show_calc_bonus_host.blade.php index 71fcad9..292ba77 100644 --- a/resources/views/user/homeparty/show_calc_bonus_host.blade.php +++ b/resources/views/user/homeparty/show_calc_bonus_host.blade.php @@ -4,7 +4,7 @@ Gutschrift Homeparty Gutschein   -   + - {{ \App\Services\HomepartyCart::getFormattedBonusValue() }} € - {{ \App\Services\HomepartyCart::getFormattedBonusValue() }} € @endif @@ -12,16 +12,17 @@ Gutschrift Bonus   -   + - {{ \App\Services\HomepartyCart::getFormattedBonusCoupon() }} € - {{ \App\Services\HomepartyCart::getFormattedBonusCoupon() }} € @endif @if(\App\Services\HomepartyCart::$is_bonus) - Abzug Points durch Gutschein + Abzug Points durch Gutschein - {{ \App\Services\HomepartyCart::getFormattedBonusPointsDiff() }}     +   @endif @@ -32,8 +33,9 @@ Gesamt: - {{$user_cart->getFormattedEkPrice()}} € {{$user_cart->getFormattedPoints()}} {{$user_cart->getFormattedIncomePrice()}} € {{$user_cart->getFormattedPrice()}} € + {{$user_cart->getFormattedEkPrice()}} € + diff --git a/resources/views/user/homeparty/show_products_order.blade.php b/resources/views/user/homeparty/show_products_order.blade.php index 241cc45..8552495 100644 --- a/resources/views/user/homeparty/show_products_order.blade.php +++ b/resources/views/user/homeparty/show_products_order.blade.php @@ -7,10 +7,11 @@ {{__('Produkt')}} {{__('Anzahl')}} {{__('Marge')}} - {{__('EK-Preis')}} {{__('Points')}} {{__('Verdienst')}} {{__('VK-Preis')}} + {{__('EK-Preis')}} + @@ -53,9 +54,7 @@ {{ $value->margin }}% - - {{ $value->getFormattedTotalEKPrice() }} € - + {{ $value->getFormattedTotalPoints() }} @@ -65,6 +64,9 @@ {{ $value->getFormattedTotalPrice() }} € + + {{ $value->getFormattedTotalEKPrice() }} € + @endforeach @@ -98,17 +100,18 @@ Versandkosten   -   + {{$user_cart->getFormattedShippingPrice()}} € {{$user_cart->getFormattedShippingPrice()}} € @endif Gesamt: - {{$user_cart->getFormattedEkPrice()}} € {{$user_cart->getFormattedPoints()}} {{$user_cart->getFormattedIncomePrice()}} € {{$user_cart->getFormattedPrice()}} € + {{$user_cart->getFormattedEkPrice()}} € + @else diff --git a/resources/views/user/homeparty/show_total_order.blade.php b/resources/views/user/homeparty/show_total_order.blade.php index 06f245b..7ba002a 100644 --- a/resources/views/user/homeparty/show_total_order.blade.php +++ b/resources/views/user/homeparty/show_total_order.blade.php @@ -3,10 +3,10 @@   - {{__('EK-Preis')}} {{__('Points')}} {{__('Verdienst')}} {{__('VK-Preis')}} + {{__('EK-Preis')}} @@ -16,9 +16,6 @@ Gastgeber/in {{$homeparty->homeparty_host->billing_firstname}} {{$homeparty->homeparty_host->billing_lastname}} - - {{$user_cart->getFormattedEkPrice()}} € - {{$user_cart->getFormattedPoints()}} @@ -28,6 +25,9 @@ {{$user_cart->getFormattedPrice()}} € + + {{$user_cart->getFormattedEkPrice()}} € + @endif @@ -40,9 +40,6 @@ {!! $g_count++ !!}. Gast {{$homeparty_guest->billing_firstname}} {{$homeparty_guest->billing_lastname}} - - {{$user_cart->getFormattedEkPrice()}} € - {{$user_cart->getFormattedPoints()}} @@ -52,6 +49,9 @@ {{$user_cart->getFormattedPrice()}} € + + {{$user_cart->getFormattedEkPrice()}} € + @endforeach @endif @@ -72,10 +72,10 @@ Gesamtsummen: - {{\App\Services\HomepartyCart::getFormattedEkPrice()}} € {{\App\Services\HomepartyCart::getFormattedPoints()}} {{\App\Services\HomepartyCart::getFormattedIncomePrice()}} € {{\App\Services\HomepartyCart::getFormattedPrice()}} € + {{\App\Services\HomepartyCart::getFormattedEkPrice()}} € @@ -83,9 +83,9 @@   -     {{\App\Services\HomepartyCart::getFormattedPriceNet()}} € + {{\App\Services\HomepartyCart::getFormattedEkPriceNet()}} € @@ -93,9 +93,9 @@   -     {{\App\Services\HomepartyCart::getFormattedPriceTax()}} € + {{\App\Services\HomepartyCart::getFormattedEkPriceTax()}} €