This commit is contained in:
Kevin Adametz 2024-08-05 12:05:24 +02:00
parent 04d677d37a
commit bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions

View file

@ -33,7 +33,10 @@ class CardController extends Controller
if($product->images->count()){
$image = $product->images->first()->slug;
}
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
$cartItem = Yard::instance('shopping')
->add($product->id, $product->getLang('name'), $quantity,
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
if(Yard::instance('shopping')->getUserTaxFree()){
Yard::setTax($cartItem->rowId, 0);
}else{
@ -59,7 +62,10 @@ class CardController extends Controller
$image = $product->images->first()->slug;
}
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
$cartItem = Yard::instance('shopping')
->add($product->id, $product->getLang('name'), $quantity,
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
if(Yard::instance('shopping')->getUserTaxFree()){
Yard::setTax($cartItem->rowId, 0);
}else{
@ -117,17 +123,18 @@ class CardController extends Controller
$data['is_from'] = 'shopping';
$data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
ShoppingInstance::create([
'identifier' => $identifier,
'user_shop_id' => $user_shop->id,
'payment' => 1,
'payment' => 1, //Customer Shop Payment
'subdomain' => url('/'),
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'language' => \App::getLocale(),
'shopping_data' => $data,
'back' => url()->previous(),
]);
Yard::instance('shopping')->store($identifier);
//add to DB
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);

View file

@ -11,6 +11,7 @@ use App\Services\Shop;
use App\Services\Util;
use App\Models\Homeparty;
use App\Services\Payment;
use App\Services\AboHelper;
use App\Models\ShoppingUser;
use App\Models\PaymentMethod;
use App\Models\ShoppingOrder;
@ -49,23 +50,19 @@ class CheckoutController extends Controller
$is_from = isset($shopping_data['is_from']) ? $shopping_data['is_from'] : 'shopping';
$is_for = isset($shopping_data['is_for']) ? $shopping_data['is_for'] : false;
$is_abo = isset($shopping_data['is_abo']) ? (bool) $shopping_data['is_abo'] : false;
$abo_interval = isset($shopping_data['abo_interval']) ? $shopping_data['abo_interval'] : 0;
if($is_for === 'ot-customer' || $is_for === 'abo-ot-customer'){
$is_from = 'shopping';
}
$homeparty_id = isset($shopping_data['homeparty_id']) ? $shopping_data['homeparty_id'] : null;
$shopping_user = null;
/*if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){//$is_from !== 'shopping' && ){ //
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
// $shopping_user->save();
// $this->putPayments('shopping_user_id', $shopping_user->id);
}else{
$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
}*/
if(\Session::has('new_session')){
$this->destroy();
\Session::forget('new_session');
}
if(!$this->getPayments('shopping_user_id')){
if($shopping_data && $is_from !== 'shopping'){
//can wizard membership user_order
@ -73,12 +70,19 @@ class CheckoutController extends Controller
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
$shopping_user->save();
$this->putPayments('shopping_user_id', $shopping_user->id);
}elseif($is_from === 'shopping') {
}elseif($is_from === 'shopping' && ($is_for !== 'ot-customer' || $is_for !== 'abo-ot-customer')){
$shopping_user = new ShoppingUser();
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
$shopping_user->homeparty_id = $homeparty_id;
$shopping_user->mode = 'prev';
$shopping_user->language = \App::getLocale();
}elseif($is_from === 'shopping' && ($is_for === 'ot-customer' || $is_for === 'abo-ot-customer')){
$shopping_user = $this->makeCustomerShoppingUser($shopping_data);
$shopping_user->is_for = $is_for;
$shopping_user->is_from = $is_from;
$shopping_user->mode = 'prev';
$shopping_user->language = \App::getLocale();
}
}else{
$shopping_user = ShoppingUser::findOrFail($this->getPayments('shopping_user_id'));
@ -105,16 +109,12 @@ class CheckoutController extends Controller
$shopping_user->billing_state = Yard::instance('shopping')->getShippingCountryId();
$shopping_user->shipping_state = Yard::instance('shopping')->getShippingCountryId();
}
if(Util::getAuthUser()){
$shopping_user->abo_options = Util::getUserHistoryValue('abo_options');
//$shopping_user->save();
}
$payment_methods = $this->getPaymentsMethods($is_from);
$payment_methods = $this->getPaymentsMethods($is_from, $is_abo);
$data = [
'is_from' => $is_from,
'is_for' => $is_for,
'is_abo' => $is_abo,
'abo_interval' => $abo_interval,
'shopping_data' => $shopping_data,
'user_shop' => Util::getUserShop(),
'shopping_user' => $shopping_user,
@ -126,24 +126,27 @@ class CheckoutController extends Controller
return view('web.templates.checkout', $data);
}
private function getPaymentsMethods($is_from){
private function getPaymentsMethods($is_from, $is_abo = false){
$payment_methods = [];
if($is_from !== 'shopping' && Util::getAuthUser()){
$user = Util::getAuthUser();
$payment_methods['default'] = $user->payment_methods;
$payment_methods['data'] = $user->account->payment_data;
}else{
$payment_methods['default'] = PaymentMethod::getDefaultAsArray()->toArray();
$payment_methods['default'] = PaymentMethod::getDefaultAsArray($is_abo)->toArray();
$payment_methods['data'] = false;
}
$payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
if($is_abo){
$payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->where('is_abo', true)->get()->pluck( 'id', 'short')->toArray();
}else{
$payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
}
return $payment_methods;
}
private function isPaymentsMethodsActive($payment_method, $is_from){
private function isPaymentsMethodsActive($payment_method, $is_from, $is_abo = false){
$payment_names = ['wlt#PPE' => 'PP', 'cc' => 'CC', 'sb#PNT' => 'SB', 'elv' => 'SEPA', 'vor' => 'VOR', 'fnc#MIV' => 'FNC'];
$payment_methods = $this->getPaymentsMethods($is_from);
$payment_methods = $this->getPaymentsMethods($is_from, $is_abo);
if(isset($payment_names[$payment_method])){
$payment_with = $payment_names[$payment_method];
if(array_key_exists($payment_with, $payment_methods['active']) && in_array($payment_methods['active'][$payment_with], $payment_methods['default'])){
@ -159,7 +162,8 @@ class CheckoutController extends Controller
$shopping_user = new ShoppingUser();
$shopping_user->auth_user_id = $user->id;
$shopping_user->mode = 'prev';
$shopping_user->language = \App::getLocale();
$shopping_user->billing_salutation = $user->account->salutation;
$shopping_user->billing_company = $user->account->company;
$shopping_user->billing_firstname = $user->account->first_name;
@ -182,7 +186,7 @@ class CheckoutController extends Controller
//Lieferadresse
if($is_from === 'user_order'){
if(isset($data['shopping_user_id']) && $data['is_for'] === 'ot'){
if(isset($data['shopping_user_id']) && strpos($data['is_for'], 'ot') !== false){
$s_user = ShoppingUser::findOrFail($data['shopping_user_id']);
/* $shopping_user->billing_salutation = $s_user->billing_salutation;
$shopping_user->billing_company = $s_user->billing_company;
@ -236,7 +240,7 @@ class CheckoutController extends Controller
$data = Request::all();
if(isset($data['payment_method'])){
$this->isPaymentsMethodsActive($data['payment_method'], $data['is_from']);
$this->isPaymentsMethodsActive($data['payment_method'], $data['is_from'], $data['is_abo']);
}
//change selected Country
@ -280,7 +284,15 @@ class CheckoutController extends Controller
$shopping_user = $this->makeShoppingUser($data);
//make Order and Items
$shopping_order = $this->makeShoppingOrder($shopping_user);
$shopping_order = $this->makeShoppingOrder($shopping_user, $data);
//delete session
if(\Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6){
$user_shop_identifier = \Session::get('user_shop_identifier');
Yard::instance('shopping')->deleteStoredCart($user_shop_identifier);
\App\Models\ShoppingInstance::where('identifier', $user_shop_identifier)->delete();
}
//CustomerPriority
if($shopping_user->is_from === 'shopping'){
$ret = CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
@ -390,7 +402,6 @@ class CheckoutController extends Controller
if(!$ShoppingPayment){
//TODO log this
Util::setUserHistoryValue(['status'=>21]);
\Session::flash('checkout-error', 'Der Zahlungsvorgang konnte nicht abgeschlossen werden, die Zahlung wurde nicht gefunden: '.$reference);
return redirect(route('checkout.checkout_card'));
}
@ -402,10 +413,8 @@ class CheckoutController extends Controller
Yard::instance('shopping')->destroy();
$this->destroy();
$payt = $ShoppingPayment->payment_transactions->last();
AboHelper::createNewAbo($ShoppingPayment);
$data = [
'user_shop' => Util::getUserShop(),
'order_reference' => $reference,
@ -483,7 +492,22 @@ class CheckoutController extends Controller
return $shopping_user;
}
private function makeShoppingOrder($shopping_user){
private function makeCustomerShoppingUser($shopping_data){
// $shopping_user = ShoppingUser::findOrFail($shopping_data['shopping_user_id']);
$shopping_user = new ShoppingUser();
$shopping_user->fill($shopping_data);
$shopping_user->faker_mail = false;
$shopping_user->auth_user_id = null;
$shopping_user->homeparty_id = null;
$shopping_user->same_as_billing = $shopping_user->same_as_billing ? false : true; //reinvert
// $shopping_user->id = null;
$shopping_user->accepted_data_checkbox = 1;
return $shopping_user;
}
private function makeShoppingOrder($shopping_user, $data){
$user_shop = Util::getUserShop();
@ -496,6 +520,7 @@ class CheckoutController extends Controller
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'language' => \App::getLocale(),
'user_shop_id' => $user_shop->id,
'payment_for' => $shopping_user->getOrderPaymentFor(),
'homeparty_id' => $shopping_user->homeparty_id,
@ -520,6 +545,7 @@ class CheckoutController extends Controller
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'language' => \App::getLocale(),
'user_shop_id' => $user_shop->id,
'payment_for' => $shopping_user->getOrderPaymentFor(),
'total' => $total,
@ -540,6 +566,7 @@ class CheckoutController extends Controller
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'language' => \App::getLocale(),
'user_shop_id' => $user_shop->id,
'payment_for' => $shopping_user->getOrderPaymentFor(),
'total' => Yard::instance('shopping')->total(2, '.', ''),
@ -551,6 +578,8 @@ class CheckoutController extends Controller
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
'points' => Yard::instance('shopping')->points(),
'weight' => Yard::instance('shopping')->weight(),
'is_abo' => isset($data['is_abo']) ? $data['is_abo'] : false,
'abo_interval' => isset($data['abo_interval']) ? $data['abo_interval'] : null,
'txaction' => 'prev',
'mode' => Util::getUserShoppingMode(),
];

View file

@ -88,9 +88,9 @@ class ContactController extends Controller
$contact_mail = config('app.contact_mail');
if($user_shop){
Mail::to($contact['email'])->bcc([$user_shop->user->email, $contact_mail])->send(new MailContact($contact));
Mail::to($contact['email'])->bcc([$user_shop->user->email, $contact_mail])->locale(\App::getLocale())->send(new MailContact($contact));
}else{
Mail::to($contact['email'])->bcc($contact_mail)->send(new MailContact($contact));
Mail::to($contact['email'])->bcc($contact_mail)->locale(\App::getLocale())->send(new MailContact($contact));
}
$data = [

View file

@ -33,7 +33,7 @@ class HomepartyController extends Controller
$homeparty = Homeparty::where('token', $token)->where('token_active', true)->first();
if(!$homeparty){
abort(403, 'Link für die Homeparty wurde nicht gefunden, oder ist nicht mehr aktiv.');
abort(403, __('msg.link_for_homeparty_not_found'));
}
$homeparty_user = null;
if($gid){
@ -45,11 +45,11 @@ class HomepartyController extends Controller
}else{
//no edit
abort(403, 'Link für die Homeparty wurde nicht gefunden, oder ist nicht mehr aktiv.');
abort(403, __('msg.link_for_homeparty_not_found'));
$homeparty_user = HomepartyUser::find($gid);
if(!$homeparty_user || $homeparty_user->homeparty_id !== $homeparty->id){
abort(403, 'Link für die Homeparty wurde nicht gefunden, oder ist nicht mehr aktiv.');
abort(403, __('msg.link_for_homeparty_not_found'));
}
}
}
@ -70,7 +70,7 @@ class HomepartyController extends Controller
}
$homeparty = Homeparty::where('token', $token)->where('token_active', true)->first();
if(!$homeparty){
abort(403, 'Link für die Homeparty wurde nicht gefunden, oder ist nicht mehr aktiv.');
abort(403, __('msg.link_for_homeparty_not_found'));
}
$rules = array(
@ -110,15 +110,15 @@ class HomepartyController extends Controller
]);
}else{
//no edit
abort(403, 'Link für die Homeparty wurde nicht gefunden, oder ist nicht mehr aktiv.');
abort(403, __('msg.link_for_homeparty_not_found'));
$homeparty_user = HomepartyUser::find($gid);
if(!$homeparty_user || $homeparty_user->homeparty_id !== $homeparty->id){
abort(403, 'Link für die Homeparty wurde nicht gefunden, oder ist nicht mehr aktiv.');
abort(403, __('msg.link_for_homeparty_not_found'));
}
}
if(!$homeparty_user){
abort(403, 'Link für die Homeparty wurde nicht gefunden, oder ist nicht mehr aktiv.');
abort(403, __('msg.link_for_homeparty_not_found'));
}
$data = Request::all();

View file

@ -79,7 +79,7 @@ class RegisterController extends Controller
);
Validator::extend('recaptcha', function($attribute, $value, $parameters, $validator) {
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
});
$validator = Validator::make(Request::all(), $rules);
@ -119,7 +119,7 @@ class RegisterController extends Controller
$user->account->data_protection = now();
$user->account->save();
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($confirmation_code, $user));
return redirect('/registrierung/finish');

View file

@ -18,6 +18,7 @@ class SiteController extends Controller
public function index()
{
$this->setIPInfo();
$products = ['aloe-vera-gel-99', 'aloe-vera-saft-500-ml', 'aloe-vera-lippenbalsam'];
// $set_products = ['aloe-vera-cleaner-set', 'aloe-vera-koerper-set', 'aloe-vera-repair-set'];
$set_products = ['aloe-vera-koerper-set', 'baby-set', 'aloe-vera-gel-set'];
@ -41,6 +42,9 @@ class SiteController extends Controller
$mylangs = Shop::getLangChange();
foreach($mylangs as $code => $country){
if(strtolower($data['change_country_id']) === strtolower($code)){
\Session::put('user_init_country', strtolower($code));
\Session::forget('user_init_country_options');
\Session::put('locale', strtolower($data['change_locale_id']));
Shop::initUserShopLang($country);
return back();
}
@ -48,8 +52,54 @@ class SiteController extends Controller
}
}
private function setIPinfo()
{
//wurde schon gesetzt //cache
$country = strtolower(Shop::getIPDatabaseInfo());
if(\Session::has('user_init_country')){
return;
}
if(config('app.ipinfo')){
$country = strtolower(Shop::getIPDatabaseInfo());
if($country === 'de'){ //$locale de - init AT
\Session::put('user_init_country', $country);
return;
}
if($country === 'error'){ //$locale at - init AT
$country = 'de';
}
}else{
$country = 'de';
}
//$locale = strtolower(\App::getLocale());
//ist default
//sprache
if(array_key_exists($country, \App\Services\UserService::getTransChange())){
\Session::put('user_init_country', $country);
\Session::put('locale', $country);
\App::setLocale($country);
}else{
//default EN
\Session::put('user_init_country', 'de');
\Session::put('locale', 'de');
\App::setLocale('de');
}
//bestelland / versandland
if(array_key_exists($country, Shop::getLangChange())){
\Session::put('user_init_country_options', $country);
}else{
\Session::put('user_init_country_options', 'de');
}
return redirect(route('home'));
}
public function site($site, $subsite = false, $product_slug = false)
{
$this->setIPInfo();
$subsite = trim($subsite, '/');
$product_slug = trim($product_slug, '/');
if($product_slug){
@ -106,7 +156,7 @@ class SiteController extends Controller
'products' => Product::where('active', true)->whereJsonContains('show_on', '1')->orderBy('pos', 'DESC')->get(),
'product_categories' => false,
'p_count' => Product::where('active', true)->whereJsonContains('show_on', '1')->count(),
'headline' => 'Produktwelt',
'headline' => __('website.productworld'),
'headline_image' => false,
];
return view('web.templates.'.$site, $data);
@ -126,6 +176,4 @@ class SiteController extends Controller
}
return view('web.templates.'.$site, $data);
}
}