Categories, Netto Homeparty
This commit is contained in:
parent
7d1ee844eb
commit
351a8f763c
13 changed files with 144 additions and 64 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class UserUpdateEmailController extends Controller
|
|||
|
||||
}
|
||||
|
||||
public function update(Request $request)
|
||||
public function update()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue