Categories, Netto Homeparty

This commit is contained in:
Kevin Adametz 2021-06-18 15:02:34 +02:00
parent 7d1ee844eb
commit 351a8f763c
13 changed files with 144 additions and 64 deletions

View file

@ -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,

View file

@ -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()

View file

@ -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";

View file

@ -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';

View file

@ -34,7 +34,7 @@ class UserUpdateEmailController extends Controller
}
public function update(Request $request)
public function update()
{
$user = Auth::user();

View file

@ -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');
}

View file

@ -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']);

View file

@ -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;
//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);
}
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);

View file

@ -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);
}

View file

@ -15,7 +15,10 @@
@foreach($homeparty->homeparty_users as $homeparty_user)
<div class="card mb-3">
<div class="card-body d-flex justify-content-between align-items-start pb-2">
@if(!$homeparty->completed)
<div>
<a href="{{route('user_homeparty_guest_detail', [$homeparty->id, $homeparty_user->id])}}" class="text-body text-big font-weight-semibold">
@if($homeparty_user->is_host)
<span class="text-muted">Gastgeber/in: </span>
@ -26,10 +29,7 @@
</a>
{{-- <span class="badge badge-success align-text-bottom ml-1">offen ...</span> --}}
</div>
@if(!$homeparty->completed)
<div>
<a href="{{route('user_homeparty_guest_detail', [$homeparty->id, $homeparty_user->id])}}" class="btn btn-sm btn-secondary mr-2"><i class="fa fa-edit"></i> bearbeiten</a>
<div class="btn-group project-actions">
@if($homeparty_user->is_host)
@ -43,6 +43,19 @@
@endif
</div>
</div>
@else
<div>
<div class="text-body text-big font-weight-semibold">
@if($homeparty_user->is_host)
<span class="text-muted">Gastgeber/in: </span>
@else
<span class="text-muted">Gast {{$g_count++}}: </span>
@endif
{{$homeparty_user->billing_firstname}} {{$homeparty_user->billing_lastname}}
</div>
{{-- <span class="badge badge-success align-text-bottom ml-1">offen ...</span> --}}
</div>
@endif
</div>
<div class="progress rounded-0" style="height: 2px;">

View file

@ -4,7 +4,7 @@
<tr class="foot-small">
<td colspan="5" class="text-left">Gutschrift Homeparty Gutschein</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="text-right">- {{ \App\Services\HomepartyCart::getFormattedBonusValue() }} &euro;</td>
<td class="text-right">- {{ \App\Services\HomepartyCart::getFormattedBonusValue() }} &euro;</td>
</tr>
@endif
@ -12,16 +12,17 @@
<tr class="foot-small">
<td colspan="5" class="text-left">Gutschrift Bonus</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td class="text-right">- {{ \App\Services\HomepartyCart::getFormattedBonusCoupon() }} &euro;</td>
<td class="text-right">- {{ \App\Services\HomepartyCart::getFormattedBonusCoupon() }} &euro;</td>
</tr>
@endif
@if(\App\Services\HomepartyCart::$is_bonus)
<tr class="foot-small">
<td colspan="5" class="text-left">Abzug Points durch Gutschein</td>
<td colspan="4" class="text-left">Abzug Points durch Gutschein</td>
<td class="text-right">- {{ \App\Services\HomepartyCart::getFormattedBonusPointsDiff() }} </td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
@endif
<tr class="foot-small">
@ -32,8 +33,9 @@
</tr>
<tr>
<td colspan="4" class="border-top"><strong>Gesamt:</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedEkPrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedPoints()}}</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedIncomePrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedPrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedEkPrice()}} &euro;</strong></td>
</tr>

View file

@ -7,10 +7,11 @@
<th>{{__('Produkt')}}</th>
<th>{{__('Anzahl')}}</th>
<th>{{__('Marge')}}</th>
<th class="text-right">{{__('EK-Preis')}}</th>
<th class="text-right">{{__('Points')}}</th>
<th class="text-right">{{__('Verdienst')}}</th>
<th class="text-right">{{__('VK-Preis')}}</th>
<th class="text-right">{{__('EK-Preis')}}</th>
</tr>
</thead>
<tbody>
@ -53,9 +54,7 @@
<td>
{{ $value->margin }}%
</td>
<td class="text-right">
{{ $value->getFormattedTotalEKPrice() }} &euro;
</td>
<td class="text-right">
{{ $value->getFormattedTotalPoints() }}
</td>
@ -65,6 +64,9 @@
<td class="text-right">
{{ $value->getFormattedTotalPrice() }} &euro;
</td>
<td class="text-right">
{{ $value->getFormattedTotalEKPrice() }} &euro;
</td>
</tr>
@endforeach
@ -98,17 +100,18 @@
<tr>
<td colspan="5" class="text-left">Versandkosten</td>
<td>&nbsp;</td>
<td class="text-right">&nbsp;</td>
<td class="text-right">{{$user_cart->getFormattedShippingPrice()}} &euro;</td>
<td class="text-right">{{$user_cart->getFormattedShippingPrice()}} &euro;</td>
</tr>
@endif
<tr>
<td colspan="4" class="border-top"><strong>Gesamt:</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedEkPrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedPoints()}}</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedIncomePrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedPrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{$user_cart->getFormattedEkPrice()}} &euro;</strong></td>
</tr>
@else

View file

@ -3,10 +3,10 @@
<thead>
<tr>
<th>&nbsp;</th>
<th class="text-right">{{__('EK-Preis')}}</th>
<th class="text-right">{{__('Points')}}</th>
<th class="text-right">{{__('Verdienst')}}</th>
<th class="text-right">{{__('VK-Preis')}}</th>
<th class="text-right">{{__('EK-Preis')}}</th>
</tr>
</thead>
<tbody>
@ -16,9 +16,6 @@
<td>
<strong>Gastgeber/in {{$homeparty->homeparty_host->billing_firstname}} {{$homeparty->homeparty_host->billing_lastname}}</strong>
</td>
<td class="text-right">
{{$user_cart->getFormattedEkPrice()}} &euro;
</td>
<td class="text-right">
{{$user_cart->getFormattedPoints()}}
</td>
@ -28,6 +25,9 @@
<td class="text-right">
{{$user_cart->getFormattedPrice()}} &euro;
</td>
<td class="text-right">
{{$user_cart->getFormattedEkPrice()}} &euro;
</td>
</tr>
@endif
@ -40,9 +40,6 @@
<td>
<strong> {!! $g_count++ !!}. Gast {{$homeparty_guest->billing_firstname}} {{$homeparty_guest->billing_lastname}}</strong>
</td>
<td class="text-right">
{{$user_cart->getFormattedEkPrice()}} &euro;
</td>
<td class="text-right">
{{$user_cart->getFormattedPoints()}}
</td>
@ -52,6 +49,9 @@
<td class="text-right">
{{$user_cart->getFormattedPrice()}} &euro;
</td>
<td class="text-right">
{{$user_cart->getFormattedEkPrice()}} &euro;
</td>
</tr>
@endforeach
@endif
@ -72,10 +72,10 @@
<td colspan="1" class="border-top">
<strong>Gesamtsummen:</strong>
</td>
<td class="border-top text-right"><strong>{{\App\Services\HomepartyCart::getFormattedEkPrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{\App\Services\HomepartyCart::getFormattedPoints()}}</strong></td>
<td class="border-top text-right"><strong>{{\App\Services\HomepartyCart::getFormattedIncomePrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{\App\Services\HomepartyCart::getFormattedPrice()}} &euro;</strong></td>
<td class="border-top text-right"><strong>{{\App\Services\HomepartyCart::getFormattedEkPrice()}} &euro;</strong></td>
</tr>
<tr class="foot-small">
<td colspan="1" class="text-muted">
@ -83,9 +83,9 @@
</td>
<td class="">&nbsp;</td>
<td class="">&nbsp;</td>
<td class="">&nbsp;</td>
<td class="text-muted text-right">{{\App\Services\HomepartyCart::getFormattedPriceNet()}} &euro;</td>
<td class="text-muted text-right">{{\App\Services\HomepartyCart::getFormattedEkPriceNet()}} &euro;</td>
</tr>
<tr class="foot-small">
<td colspan="1" class="text-muted">
@ -93,9 +93,9 @@
</td>
<td class="">&nbsp;</td>
<td class="">&nbsp;</td>
<td class="">&nbsp;</td>
<td class="text-muted text-right">{{\App\Services\HomepartyCart::getFormattedPriceTax()}} &euro;</td>
<td class="text-muted text-right">{{\App\Services\HomepartyCart::getFormattedEkPriceTax()}} &euro;</td>
</tr>
</tfoot>
</table>