update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
232
dev/app-bak/Http/Controllers/Web/CardController.php
Executable file
232
dev/app-bak/Http/Controllers/Web/CardController.php
Executable file
|
|
@ -0,0 +1,232 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use Yard;
|
||||
use Request;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CardController extends Controller
|
||||
{
|
||||
private $instance = 'webshop';
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {}
|
||||
|
||||
|
||||
|
||||
//Cart::instance('wishlist')->add('sdjk922', 'Product 2', 1, 19.95, ['size' => 'medium']);
|
||||
public function addToCardGet($id, $quantity = 1, $product_slug = false)
|
||||
{
|
||||
$product = Product::find($id);
|
||||
if ($product) {
|
||||
$image = "";
|
||||
if ($product->images->count()) {
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance($this->instance)
|
||||
->add(
|
||||
$product->id,
|
||||
$product->getLang('name'),
|
||||
$quantity,
|
||||
$product->getPriceWith(Yard::instance($this->instance)->getUserTaxFree(), false, Yard::instance($this->instance)->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, 'show_on' => $product->show_on]
|
||||
);
|
||||
if (Yard::instance($this->instance)->getUserTaxFree()) {
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
} else {
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance($this->instance)->getUserCountry()));
|
||||
}
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
|
||||
// Debug: Yard-Status nach Hinzufügen
|
||||
$yardCount = \Yard::instance($this->instance)->count();
|
||||
$yardTotal = \Yard::instance($this->instance)->total();
|
||||
|
||||
\Log::info('✅ Product added to Yard successfully', [
|
||||
'product_id' => $product->id,
|
||||
'product_name' => $product->getLang('name'),
|
||||
'quantity' => $quantity,
|
||||
'instance' => $this->instance,
|
||||
'yard_total_items' => $yardCount,
|
||||
'yard_total_price' => $yardTotal,
|
||||
'session_id' => \Session::getId()
|
||||
]);
|
||||
|
||||
\Session()->flash('show-card-after-add', true);
|
||||
|
||||
// CRITICAL: Error-Messages bereinigen und Session für Redirect vorbereiten
|
||||
\App\Services\SessionCleaner::cleanAndSave('CardController::addToCardGet');
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function addToCardPost($id)
|
||||
{
|
||||
|
||||
$product = Product::find($id);
|
||||
if ($product) {
|
||||
$image = "";
|
||||
if ($product->images->count()) {
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
|
||||
$cartItem = Yard::instance($this->instance)
|
||||
->add(
|
||||
$product->id,
|
||||
$product->getLang('name'),
|
||||
$quantity,
|
||||
$product->getPriceWith(Yard::instance($this->instance)->getUserTaxFree(), false, Yard::instance($this->instance)->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, 'show_on' => $product->show_on]
|
||||
);
|
||||
if (Yard::instance($this->instance)->getUserTaxFree()) {
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
} else {
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance($this->instance)->getUserCountry()));
|
||||
}
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
|
||||
\Session()->flash('show-card-after-add', true);
|
||||
\App\Services\SessionCleaner::cleanAndSave('CardController::addToCardPost');
|
||||
}
|
||||
|
||||
return back();
|
||||
}
|
||||
|
||||
public function showCard()
|
||||
{
|
||||
|
||||
if (Request::get('selected_country')) {
|
||||
Yard::instance($this->instance)->setShippingCountryWithPrice(Request::get('selected_country'));
|
||||
} else {
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
}
|
||||
|
||||
//show konflikt wenn user eingeloggt ist und country nicht gesetzt ist
|
||||
$shipping_error = $this->checkShippingError();
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange($this->instance),
|
||||
'yard_instance' => $this->instance,
|
||||
'shipping_error' => $shipping_error ?? false,
|
||||
];
|
||||
return view('web.templates.card', $data);
|
||||
}
|
||||
|
||||
public function updateCard()
|
||||
{
|
||||
|
||||
$data = Request::all();
|
||||
if (isset($data['quantity'])) {
|
||||
foreach ($data['quantity'] as $rowId => $qty) {
|
||||
Yard::instance($this->instance)->update($rowId, $qty);
|
||||
Yard::instance($this->instance)->reCalculateShippingPrice();
|
||||
}
|
||||
} else {
|
||||
$this->deleteCard();
|
||||
}
|
||||
\App\Services\SessionCleaner::cleanAndSave('CardController::updateCard');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function checkoutServer()
|
||||
{
|
||||
|
||||
$user_shop = Util::getUserShop();
|
||||
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while (ShoppingInstance::where('identifier', $identifier)->count());
|
||||
|
||||
$data = [];
|
||||
$data['is_from'] = 'shopping';
|
||||
$data['user_price_infos'] = Yard::instance($this->instance)->getUserPriceInfos();
|
||||
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment' => 1, //Customer Shop Payment
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => Yard::instance($this->instance)->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
|
||||
Yard::instance($this->instance)->store($identifier);
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier' => $identifier]);
|
||||
if (strpos($path, 'https') === false) {
|
||||
$path = str_replace('http', 'https', $path);
|
||||
}
|
||||
return redirect()->secure($path);
|
||||
}
|
||||
|
||||
public function backToShop()
|
||||
{
|
||||
$this->deleteCard();
|
||||
return redirect(url('/'));
|
||||
}
|
||||
public function removeCard($rowId)
|
||||
{
|
||||
Yard::instance($this->instance)->remove($rowId);
|
||||
\App\Services\SessionCleaner::cleanAndSave('CardController::removeCard');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function deleteCard()
|
||||
{
|
||||
|
||||
$setCode = Shop::getUserShopLang(null, $this->instance);
|
||||
$mylangs = Shop::getLangChange($this->instance);
|
||||
foreach ($mylangs as $code => $country) {
|
||||
if (strtolower($setCode) === strtolower($code)) {
|
||||
Shop::initUserShopLang($country, $this->instance);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function checkShippingError()
|
||||
{
|
||||
$shipping_error = false;
|
||||
if (\Auth::guard('customers')->check()) {
|
||||
$user = \Auth::guard('customers')->user();
|
||||
if ($user->shopping_user_id) {
|
||||
$shopping_user = ShoppingUser::find($user->shopping_user_id);
|
||||
if ($shopping_user->same_as_billing) {
|
||||
if ($shopping_user->billing_country_id != Yard::instance($this->instance)->getUserCountryId()) {
|
||||
$user_country = Yard::instance($this->instance)->getUserCountry();
|
||||
$user_country_name = $user_country ? $user_country->getLocated() : '';
|
||||
$billing_country = $shopping_user->billing_country;
|
||||
$country_name = $billing_country ? $billing_country->getLocated() : '';
|
||||
$shipping_error = __('website.shipping_error_billing', ['shipping_country' => $user_country_name, 'billing_country' => $country_name]);
|
||||
}
|
||||
} else {
|
||||
if ($shopping_user->shipping_country_id != Yard::instance($this->instance)->getUserCountryId()) {
|
||||
$user_country = Yard::instance($this->instance)->getUserCountry();
|
||||
$user_country_name = $user_country ? $user_country->getLocated() : '';
|
||||
$shipping_country = $shopping_user->shipping_country;
|
||||
$country_name = $shipping_country ? $shipping_country->getLocated() : '';
|
||||
$shipping_error = __('website.shipping_error_delivery', ['shipping_country' => $user_country_name, 'billing_country' => $country_name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $shipping_error;
|
||||
}
|
||||
}
|
||||
568
dev/app-bak/Http/Controllers/Web/CheckoutController.php
Executable file
568
dev/app-bak/Http/Controllers/Web/CheckoutController.php
Executable file
|
|
@ -0,0 +1,568 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Pay\PayoneController;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Repositories\CheckoutRepository;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\OrderPaymentService;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Request;
|
||||
use Validator;
|
||||
use Yard;
|
||||
|
||||
class CheckoutController extends Controller
|
||||
{
|
||||
private $checkoutRepo;
|
||||
private $instance = 'checkout';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(CheckoutRepository $checkoutRepository)
|
||||
{
|
||||
$this->checkoutRepo = $checkoutRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeigt die Checkout-Seite an
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function checkout()
|
||||
{
|
||||
/*
|
||||
@if(Auth::guard('customers')->check())
|
||||
<a href="{{ route('portal.logout') }}" class="btn btn-sm btn-default mt-3"><i class="fa fa-power-off"></i> {{ __('navigation.logout') }} </a>
|
||||
@else
|
||||
<a href="{{ Util::getMyMivitaPortalUrl() }}" class="btn btn-primary btn-block mt-3 faa-parent animated-hover"><i class="fa fa-sign-in"></i> {{ __('website.to_customer_portal') }} </a>
|
||||
@endif
|
||||
@if(Auth::guard('user')->check())
|
||||
*/
|
||||
$shopping_data = Yard::instance($this->instance)->getYardExtra('shopping_data');
|
||||
$is_from = $shopping_data['is_from'] ?? 'shopping';
|
||||
$is_for = $shopping_data['is_for'] ?? false;
|
||||
$is_abo = isset($shopping_data['is_abo']) ? (bool) $shopping_data['is_abo'] : false;
|
||||
$abo_interval = $shopping_data['abo_interval'] ?? 0;
|
||||
$homeparty_id = $shopping_data['homeparty_id'] ?? null;
|
||||
$shopping_user = null;
|
||||
|
||||
if ($is_for === 'ot-customer' || $is_for === 'abo-ot-customer') {
|
||||
$is_from = 'shopping';
|
||||
}
|
||||
Util::setInstanceStatus(1, true); // link_check
|
||||
if ($is_abo) {
|
||||
$instance_status = Util::getInstanceStatus();
|
||||
if ($instance_status === 'link_paid') {
|
||||
return $this->redirectToIsFinal($instance_status);
|
||||
}
|
||||
}
|
||||
if (Session::has('new_session')) {
|
||||
$this->checkoutRepo->sessionDestroy();
|
||||
Session::forget('new_session');
|
||||
}
|
||||
$shopping_user = $this->initializeShoppingUserSession($is_from, $is_for, $shopping_data, $homeparty_id);
|
||||
|
||||
$this->prepareShoppingUserData($shopping_user);
|
||||
$payment_methods = $this->checkoutRepo->getPaymentsMethods($is_from, $is_abo);
|
||||
|
||||
if ($shopping_user === null) {
|
||||
abort(403, 'ShoppingUser not found');
|
||||
}
|
||||
$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,
|
||||
'shopping_mode' => Util::getUserShoppingMode(),
|
||||
'payment_methods' => $payment_methods['default'],
|
||||
'payment_methods_active' => $payment_methods['active'],
|
||||
'payment_data' => $payment_methods['data'],
|
||||
'instance_status' => $instance_status ?? false,
|
||||
'is_checkout' => true,
|
||||
'yard_instance' => $this->instance,
|
||||
];
|
||||
return view('web.templates.checkout', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Bereitet die ShoppingUser-Daten vor
|
||||
*
|
||||
* @param ShoppingUser $shopping_user
|
||||
* @return void
|
||||
*/
|
||||
private function prepareShoppingUserData(ShoppingUser $shopping_user)
|
||||
{
|
||||
if ($shopping_user->same_as_billing === NULL) {
|
||||
$shopping_user->same_as_billing = false;
|
||||
}
|
||||
if (!$shopping_user->billing_country_id) {
|
||||
$shopping_user->billing_country_id = Yard::instance($this->instance)->getUserCountryId();
|
||||
// Die Zeile unten entfernen, da die Relation automatisch geladen wird
|
||||
// $shopping_user->billing_country = Yard::instance($this->instance)->getUserCountry();
|
||||
}
|
||||
if (!$shopping_user->shipping_country_id) {
|
||||
$shopping_user->shipping_country_id = Yard::instance($this->instance)->getUserCountryId();
|
||||
// Die Zeile unten entfernen, da die Relation automatisch geladen wird
|
||||
// $shopping_user->shipping_country = Yard::instance($this->instance)->getUserCountry();
|
||||
}
|
||||
if (old('selected_country') && old('selected_country') === 'change') {
|
||||
Session::forget('_old_input.selected_country');
|
||||
$shopping_user->billing_state = old('billing_state');
|
||||
$shopping_user->shipping_state = old('shipping_state');
|
||||
} else {
|
||||
$shopping_user->billing_state = Yard::instance($this->instance)->getShippingCountryId();
|
||||
$shopping_user->shipping_state = Yard::instance($this->instance)->getShippingCountryId();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet den Checkout-Prozess
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function checkoutFinal()
|
||||
{
|
||||
dd("checkoutFinal");
|
||||
$data = Request::all();
|
||||
if (isset($data['payment_method'])) {
|
||||
$this->checkoutRepo->isPaymentsMethodsActive($data['payment_method'], $data['is_from'], $data['is_abo']);
|
||||
}
|
||||
|
||||
Util::setInstanceStatus(2, true); // link_check
|
||||
|
||||
// Länderwechsel verarbeiten
|
||||
if (isset($data['selected_country']) && $data['selected_country'] === 'change') {
|
||||
return $this->handleCountryChange($data);
|
||||
}
|
||||
|
||||
// Validierung
|
||||
$validator = $this->validateCheckoutData();
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
// Benutzer und Bestellung erstellen
|
||||
$shopping_user = $this->checkoutRepo->makeShoppingUser($data);
|
||||
$shopping_order = $this->checkoutRepo->makeShoppingOrder($shopping_user, $data);
|
||||
|
||||
// CustomerPriority prüfen
|
||||
if ($shopping_user->is_from === 'shopping') {
|
||||
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
|
||||
}
|
||||
|
||||
Util::setUserHistoryValue(['status' => 2, 'shopping_order_id' => $shopping_order->id]);
|
||||
|
||||
// Zahlungsmethode verarbeiten
|
||||
if (Request::get('payment_method')) {
|
||||
return $this->processPaymentMethod($data, $shopping_user, $shopping_order);
|
||||
}
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet den Länderwechsel
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
private function handleCountryChange($data)
|
||||
{
|
||||
if (!Request::get('same_as_billing')) {
|
||||
Yard::instance($this->instance)->setShippingCountryWithPrice($data['billing_state'], $data['is_for']);
|
||||
} else {
|
||||
Yard::instance($this->instance)->setShippingCountryWithPrice($data['shipping_state'], $data['is_for']);
|
||||
}
|
||||
|
||||
return back()->withInput(Request::all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validiert die Checkout-Daten
|
||||
*
|
||||
* @return \Illuminate\Validation\Validator
|
||||
*/
|
||||
private function validateCheckoutData()
|
||||
{
|
||||
$rules = [
|
||||
'billing_salutation' => 'required',
|
||||
'billing_firstname' => 'required',
|
||||
'billing_lastname' => 'required',
|
||||
'billing_email' => 'required|email',
|
||||
'billing_address' => 'required',
|
||||
'billing_zipcode' => 'required',
|
||||
'billing_city' => 'required',
|
||||
'accepted_data_checkbox' => 'accepted',
|
||||
];
|
||||
|
||||
if (Request::get('same_as_billing')) {
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
'shipping_address' => 'required',
|
||||
'shipping_zipcode' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required'
|
||||
]);
|
||||
}
|
||||
|
||||
return Validator::make(Request::all(), $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet die Zahlungsmethode
|
||||
*
|
||||
* @param array $data
|
||||
* @param ShoppingUser $shopping_user
|
||||
* @param ShoppingOrder $shopping_order
|
||||
* @return mixed
|
||||
*/
|
||||
private function processPaymentMethod($data, $shopping_user, $shopping_order)
|
||||
{
|
||||
$result = [];
|
||||
$payment_method = Request::get('payment_method');
|
||||
|
||||
// Kreditkarte prüfen
|
||||
if ($payment_method === 'cc') {
|
||||
$result = $this->checkCreditCard($data, $shopping_user, $shopping_order);
|
||||
if (!isset($result['returnstatus']) || $result['returnstatus'] !== 'VALID') {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// SEPA prüfen
|
||||
if ($payment_method === 'elv') {
|
||||
$result = $this->checkSepaAccount($data, $shopping_user, $shopping_order);
|
||||
if (!isset($result['returnstatus']) || $result['returnstatus'] !== 'VALID') {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
// Zahlung vorbereiten
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$amount = Yard::instance($this->instance)->totalWithShipping(2, '.', '') * 100;
|
||||
$reference = $pay->setPrePayment($payment_method, $amount, 'EUR', $result);
|
||||
$this->checkoutRepo->putSessionPayments('payment_reference', $reference);
|
||||
$pay->setPersonalData();
|
||||
|
||||
return $pay->ResponseData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft die Kreditkartendaten
|
||||
*
|
||||
* @param array $data
|
||||
* @param ShoppingUser $shopping_user
|
||||
* @param ShoppingOrder $shopping_order
|
||||
* @return bool|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
private function checkCreditCard($data, $shopping_user, $shopping_order)
|
||||
{
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$ret['cc'] = $pay->checkCreditCard($data);
|
||||
|
||||
if ($ret['cc']['status'] === 'ERROR' || $ret['cc']['status'] === 'INVALID') {
|
||||
Session::flash('cc-error', 1);
|
||||
Session::flash('errormessage', $ret['cc']['errormessage']);
|
||||
Session::flash('customermessage', $ret['cc']['customermessage']);
|
||||
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
|
||||
}
|
||||
$ret['returnstatus'] = 'VALID';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft die SEPA-Kontodaten
|
||||
*
|
||||
* @param array $data
|
||||
* @param ShoppingUser $shopping_user
|
||||
* @param ShoppingOrder $shopping_order
|
||||
* @return bool|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
private function checkSepaAccount($data, $shopping_user, $shopping_order)
|
||||
{
|
||||
if (is_null(Request::get('mandate_identification'))) {
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$amount = Yard::instance($this->instance)->totalWithShipping(2, '.', '') * 100;
|
||||
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
|
||||
|
||||
if ($ret['elv']['status'] === 'ERROR' || $ret['elv']['status'] === 'INVALID') {
|
||||
Session::flash('elv-error', 1);
|
||||
Session::flash('errormessage', $ret['elv']['errormessage']);
|
||||
Session::flash('customermessage', $ret['elv']['customermessage']);
|
||||
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
|
||||
}
|
||||
|
||||
if ($ret['elv']['status'] === 'APPROVED' && $ret['elv']['mandate_status'] !== "active") {
|
||||
Session::flash('elv-managemandate', 1);
|
||||
Session::flash('elv-mandate_identification', $ret['elv']['mandate_identification']);
|
||||
Session::flash('elv-mandate_text', $ret['elv']['mandate_text']);
|
||||
Session::flash('elv-creditor_identifier', $ret['elv']['creditor_identifier']);
|
||||
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
|
||||
}
|
||||
|
||||
$ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder'];
|
||||
} else {
|
||||
$ret['elv'] = [
|
||||
'mandate_identification' => Request::get('mandate_identification'),
|
||||
'creditor_identifier' => Request::get('creditor_identifier'),
|
||||
'iban' => $data['elv_iban'],
|
||||
'bic' => $data['elv_bic'],
|
||||
'bankaccountholder' => $data['elv_bankaccountholder']
|
||||
];
|
||||
|
||||
$this->storeUserPaymentsData($shopping_user, $ret);
|
||||
}
|
||||
$ret['returnstatus'] = 'VALID';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Leitet zur Abschlussseite weiter
|
||||
*
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function redirectToIsFinal()
|
||||
{
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'is_checkout' => true,
|
||||
'yard_instance' => $this->instance,
|
||||
];
|
||||
|
||||
return view('web.templates.checkout-is-final', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet den Transaktionsstatus
|
||||
*
|
||||
* @param string $status
|
||||
* @param string $reference
|
||||
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function transactionStatus($status, $reference)
|
||||
{
|
||||
$shopping_order_id = $this->checkoutRepo->getSessionPayments('shopping_order_id');
|
||||
$ShoppingPayment = ShoppingPayment::where('shopping_order_id', $shopping_order_id)
|
||||
->where('reference', $reference)
|
||||
->first();
|
||||
|
||||
if (!$ShoppingPayment) {
|
||||
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'));
|
||||
}
|
||||
|
||||
$ShoppingPayment->status = $status;
|
||||
$ShoppingPayment->save();
|
||||
|
||||
if ($status === "success") {
|
||||
return $this->handleSuccessfulTransaction($ShoppingPayment, $reference);
|
||||
}
|
||||
|
||||
if ($status === "cancel") {
|
||||
Util::setUserHistoryValue(['status' => 22]);
|
||||
Util::setInstanceStatus(5); // link_canceled
|
||||
Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
|
||||
return redirect(route('checkout.checkout_card'));
|
||||
}
|
||||
|
||||
if ($status === "error") {
|
||||
Util::setUserHistoryValue(['status' => 23]);
|
||||
Util::setInstanceStatus(6); // link_failed
|
||||
Session::flash('checkout-error', 'Der Zahlungsvorgang wurde abgebrochen, die Bestellung konnte nicht ausgeführt werden.');
|
||||
return redirect(route('checkout.checkout_card'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet eine erfolgreiche Transaktion
|
||||
*
|
||||
* @param ShoppingPayment $ShoppingPayment
|
||||
* @param string $reference
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
private function handleSuccessfulTransaction($ShoppingPayment, $reference)
|
||||
{
|
||||
Yard::instance($this->instance)->destroy();
|
||||
$this->checkoutRepo->sessionDestroy(true);
|
||||
Util::setInstanceStatus(3, true); // link_pending
|
||||
|
||||
// Abo erstellen, falls nötig
|
||||
if ($ShoppingPayment->shopping_order->is_abo) {
|
||||
AboHelper::createNewAbo($ShoppingPayment);
|
||||
}
|
||||
|
||||
$payt = $ShoppingPayment->payment_transactions->last();
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'order_reference' => $reference,
|
||||
'pay_trans' => $payt,
|
||||
'is_checkout' => true,
|
||||
'yard_instance' => $this->instance,
|
||||
];
|
||||
|
||||
return view('web.templates.checkout-final', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet eine genehmigte Transaktion
|
||||
*
|
||||
* @param int $transactionId
|
||||
* @param string $reference
|
||||
* @return \Illuminate\View\View
|
||||
*/
|
||||
public function transactionApproved($transactionId, $reference)
|
||||
{
|
||||
$payt = PaymentTransaction::findOrFail($transactionId);
|
||||
if ($payt->shopping_payment->reference != $reference) {
|
||||
abort(404);
|
||||
}
|
||||
Yard::instance($this->instance)->destroy();
|
||||
$this->checkoutRepo->sessionDestroy(true);
|
||||
Util::setInstanceStatus(3, true); // link_pending
|
||||
|
||||
// Abo erstellen, falls nötig
|
||||
if ($payt->shopping_payment->shopping_order->is_abo) {
|
||||
AboHelper::createNewAbo($payt->shopping_payment);
|
||||
}
|
||||
|
||||
// Rechnung MIV
|
||||
if ($payt->status === 'FNCMIV') {
|
||||
$this->directPaymentStatus($payt);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'order_reference' => $payt->shopping_payment->reference,
|
||||
'pay_trans' => $payt,
|
||||
'is_checkout' => true,
|
||||
'yard_instance' => $this->instance,
|
||||
];
|
||||
|
||||
return view('web.templates.checkout-final', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Speichert die Zahlungsdaten des Benutzers
|
||||
*
|
||||
* @param ShoppingUser $shopping_user
|
||||
* @param array $ret
|
||||
* @return void
|
||||
*/
|
||||
private function storeUserPaymentsData($shopping_user, $ret)
|
||||
{
|
||||
if ($shopping_user->auth_user_id) {
|
||||
$user = User::find($shopping_user->auth_user_id);
|
||||
if ($user && $user->account) {
|
||||
if (isset($ret['elv']) && is_array($ret['elv'])) {
|
||||
$user->account->payment_data = $ret['elv'];
|
||||
$user->account->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet den direkten Zahlungsstatus (Rechnung MIV)
|
||||
*
|
||||
* @param PaymentTransaction $payt
|
||||
* @return void
|
||||
*/
|
||||
private function directPaymentStatus(PaymentTransaction $payt)
|
||||
{
|
||||
if (isset($payt->transmitted_data['param'])) {
|
||||
$shopping_order = ShoppingOrder::find($payt->transmitted_data['param']);
|
||||
$shopping_order->txaction = 'invoice_open';
|
||||
$shopping_order->save();
|
||||
|
||||
$shopping_payment = ShoppingPayment::where('reference', $payt->transmitted_data['reference'])->first();
|
||||
if ($shopping_payment) {
|
||||
$shopping_payment->txaction = 'invoice_open';
|
||||
$shopping_payment->save();
|
||||
}
|
||||
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, false, $shopping_payment);
|
||||
$data = [
|
||||
'mode' => $payt->transmitted_data['mode'],
|
||||
'txaction' => $payt->txaction,
|
||||
'send_link' => $send_link,
|
||||
];
|
||||
|
||||
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialisiert oder ruft einen Shopping-Benutzer ab
|
||||
*
|
||||
* @param string|null $is_from = shopping | user_order | user_order_ot | user_order_abo | user_order_abo_ot | user_order_ot_customer | user_order_abo_ot_customer
|
||||
* @param string|null $is_for = me | ot | abo-me | abo-ot | ot-customer | abo-ot-customer
|
||||
* @param array|null $shopping_data
|
||||
* @param int|null $homeparty_id
|
||||
* @return \App\Models\ShoppingUser
|
||||
*/
|
||||
private function initializeShoppingUserSession($is_from, $is_for, $shopping_data = null, $homeparty_id = null)
|
||||
{
|
||||
//check if shopping_user_id is set - der user ist bereits angelegt
|
||||
if ($this->checkoutRepo->getSessionPayments('shopping_user_id')) {
|
||||
return $this->getExistingShoppingUser();
|
||||
}
|
||||
//kommt vom Salescenter
|
||||
if ($shopping_data && $is_from !== 'shopping') {
|
||||
$shopping_user = $this->checkoutRepo->shoppingUserAuthData($is_from, $is_for, $shopping_data);
|
||||
$shopping_user->save();
|
||||
$this->checkoutRepo->putSessionPayments('shopping_user_id', $shopping_user->id);
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
//kommt aus dem Salescenter mit bestelllink oder aus dem Webshop
|
||||
if ($is_from === 'shopping') {
|
||||
//Bestelllink
|
||||
if ($is_for === 'ot-customer' || $is_for === 'abo-ot-customer') {
|
||||
//customer shop mit den Daten aus dem Salescenter shopping_data
|
||||
return $this->checkoutRepo->makeCustomerShoppingUser($shopping_data, $is_for, $is_from);
|
||||
}
|
||||
//Webshop
|
||||
return $this->checkoutRepo->initShoppingUser($is_for, $is_from, $homeparty_id);
|
||||
}
|
||||
|
||||
return $this->getExistingShoppingUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt den existierenden ShoppingUser und bereitet ihn vor
|
||||
*
|
||||
* @return ShoppingUser
|
||||
*/
|
||||
private function getExistingShoppingUser()
|
||||
{
|
||||
$shopping_user = ShoppingUser::findOrFail($this->checkoutRepo->getSessionPayments('shopping_user_id'));
|
||||
$shopping_user->billing_state = Shop::getCountryShippingCountryId($shopping_user->billing_country_id);
|
||||
$shopping_user->shipping_state = Shop::getCountryShippingCountryId($shopping_user->shipping_country_id);
|
||||
$shopping_user->same_as_billing = $shopping_user->same_as_billing ? false : true; // reinvert
|
||||
|
||||
return $shopping_user;
|
||||
}
|
||||
}
|
||||
127
dev/app-bak/Http/Controllers/Web/ContactController.php
Executable file
127
dev/app-bak/Http/Controllers/Web/ContactController.php
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use Request;
|
||||
use Validator;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Mail\MailContact;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class ContactController extends Controller
|
||||
{
|
||||
private $GOOGLE_ReCAPTCHA_KEY = "6LeeZosUAAAAAG907fMMqO4BFgsiR4ANDodd8FlU";
|
||||
private $GOOGLE_ReCAPTCHA_SECRET = "6LeeZosUAAAAADIy2fyR4RG3EuM-Zdz7Pa2Qmb1J";
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = [
|
||||
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'yard_instance' => 'webshop',
|
||||
|
||||
];
|
||||
return view('web.templates.kontakt', $data);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
|
||||
$user_shop = Util::getUserShop();
|
||||
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'message' => 'required',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
'accepted_data_protection' => 'required',
|
||||
);
|
||||
if (!$user_shop || $user_shop->id === 22) {
|
||||
$rules['sales_partnership'] = 'required';
|
||||
if (Request::get('sales_partnership') === 'JA') {
|
||||
$rules['sales_partnership_message'] = 'required';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Validator::extend('recaptcha', function ($attribute, $value, $parameters, $validator) {
|
||||
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
|
||||
});
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
|
||||
$contact = [];
|
||||
$contact['salutation'] = Request::get('salutation');
|
||||
$contact['first_name'] = Request::get('first_name');
|
||||
$contact['last_name'] = Request::get('last_name');
|
||||
$contact['email'] = Request::get('email');
|
||||
$contact['phone'] = Request::get('phone');
|
||||
$contact['message'] = Request::get('message');
|
||||
if (!$user_shop){
|
||||
$contact['sales_partnership'] = Request::get('sales_partnership');
|
||||
$contact['sales_partnership_message'] = Request::get('sales_partnership_message');
|
||||
}
|
||||
|
||||
|
||||
$contact_mail = config('app.contact_mail');
|
||||
if($user_shop){
|
||||
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)->locale(\App::getLocale())->send(new MailContact($contact));
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.contact-final', $data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function reCaptcha_validate($attribute, $value, $parameters, $validator)
|
||||
{
|
||||
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->post(
|
||||
'https://www.google.com/recaptcha/api/siteverify',
|
||||
['form_params' =>
|
||||
[
|
||||
'secret' => $this->GOOGLE_ReCAPTCHA_SECRET,
|
||||
'response' => $value
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$body = json_decode((string)$response->getBody());
|
||||
return $body->success;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
131
dev/app-bak/Http/Controllers/Web/HomepartyController.php
Executable file
131
dev/app-bak/Http/Controllers/Web/HomepartyController.php
Executable file
|
|
@ -0,0 +1,131 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailContact;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\HomepartyUser;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use GuzzleHttp\Client;
|
||||
use Request;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Services\Util;
|
||||
use Validator;
|
||||
|
||||
|
||||
class HomepartyController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
public function detail($token = null, $gid = null)
|
||||
{
|
||||
if(!$token){
|
||||
abort(404);
|
||||
}
|
||||
|
||||
$homeparty = Homeparty::where('token', $token)->where('token_active', true)->first();
|
||||
if(!$homeparty){
|
||||
abort(403, __('msg.link_for_homeparty_not_found'));
|
||||
}
|
||||
$homeparty_user = null;
|
||||
if($gid){
|
||||
if($gid === 'new'){
|
||||
$homeparty_user = new HomepartyUser();
|
||||
$homeparty_user->same_as_billing = true;
|
||||
$homeparty_user->billing_country_id = $homeparty->country_id;
|
||||
$homeparty_user->shipping_country_id = $homeparty->country_id;
|
||||
|
||||
}else{
|
||||
//no edit
|
||||
abort(403, __('msg.link_for_homeparty_not_found'));
|
||||
|
||||
$homeparty_user = HomepartyUser::find($gid);
|
||||
if(!$homeparty_user || $homeparty_user->homeparty_id !== $homeparty->id){
|
||||
abort(403, __('msg.link_for_homeparty_not_found'));
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'homeparty' => $homeparty,
|
||||
'homeparty_user' => $homeparty_user,
|
||||
'homeparty_host' => $homeparty->homeparty_host,
|
||||
'mivita_member' => $homeparty->auth_user
|
||||
];
|
||||
return view('user.homeparty.self_guest_detail', $data);
|
||||
}
|
||||
|
||||
|
||||
public function detailStore($token = null, $gid = null)
|
||||
{
|
||||
if(!$token){
|
||||
abort(404);
|
||||
}
|
||||
$homeparty = Homeparty::where('token', $token)->where('token_active', true)->first();
|
||||
if(!$homeparty){
|
||||
abort(403, __('msg.link_for_homeparty_not_found'));
|
||||
}
|
||||
|
||||
$rules = array(
|
||||
'billing_salutation' => 'required',
|
||||
'billing_firstname' => 'required',
|
||||
'billing_lastname' => 'required',
|
||||
'billing_address' => 'required',
|
||||
'billing_zipcode' => 'required',
|
||||
'billing_city' => 'required',
|
||||
'billing_country_id' => 'required',
|
||||
'checkbox_datenverarbeitung' => 'required',
|
||||
'checkbox_daten_completely' => 'required'
|
||||
);
|
||||
|
||||
if (!Request::get('same_as_billing')) {
|
||||
$rules = array_merge($rules, [
|
||||
'shipping_firstname' => 'required',
|
||||
'shipping_lastname' => 'required',
|
||||
'shipping_address' => 'required',
|
||||
'shipping_zipcode' => 'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_salutation' => 'required',
|
||||
'shipping_country_id' => 'required'
|
||||
]);
|
||||
}
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
if($gid === null){
|
||||
$homeparty_user = HomepartyUser::create([
|
||||
'homeparty_id' => $homeparty->id,
|
||||
'auth_user_id' => $homeparty->auth_user_id,
|
||||
'is_host' => false,
|
||||
]);
|
||||
}else{
|
||||
//no edit
|
||||
abort(403, __('msg.link_for_homeparty_not_found'));
|
||||
$homeparty_user = HomepartyUser::find($gid);
|
||||
if(!$homeparty_user || $homeparty_user->homeparty_id !== $homeparty->id){
|
||||
abort(403, __('msg.link_for_homeparty_not_found'));
|
||||
}
|
||||
}
|
||||
|
||||
if(!$homeparty_user){
|
||||
abort(403, __('msg.link_for_homeparty_not_found'));
|
||||
}
|
||||
|
||||
$data = Request::all();
|
||||
$data['same_as_billing'] = isset($data['same_as_billing']) ? true : false;
|
||||
$data['shipping_country_id'] = isset($data['shipping_country_id']) ? $data['shipping_country_id'] : $data['billing_country_id'];
|
||||
$homeparty_user->fill($data)->save();
|
||||
\Session()->flash('alert-save', '1');
|
||||
return redirect(route('homeparty', [$token]));
|
||||
}
|
||||
}
|
||||
168
dev/app-bak/Http/Controllers/Web/RegisterController.php
Executable file
168
dev/app-bak/Http/Controllers/Web/RegisterController.php
Executable file
|
|
@ -0,0 +1,168 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use Request;
|
||||
use App\User;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Mail\MailContact;
|
||||
use App\Models\UserLevel;
|
||||
use App\Services\UserService;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
|
||||
private $GOOGLE_ReCAPTCHA_KEY = "6LeeZosUAAAAAG907fMMqO4BFgsiR4ANDodd8FlU";
|
||||
private $GOOGLE_ReCAPTCHA_SECRET = "6LeeZosUAAAAADIy2fyR4RG3EuM-Zdz7Pa2Qmb1J";
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (config('app.debug')) {
|
||||
\Log::channel('domain')->debug('RegisterController: index - Session user_shop', [
|
||||
'session_user_shop_id' => \Session::get('user_shop')?->id,
|
||||
'session_user_shop_name' => \Session::get('user_shop')?->name,
|
||||
'session_user_shop_user_id' => \Session::get('user_shop')?->user_id,
|
||||
'session_id' => \Session::getId(),
|
||||
'session_domain' => config('session.domain'),
|
||||
'request_host' => request()->getHost(),
|
||||
'all_session_keys' => array_keys(\Session::all())
|
||||
]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.registrierung', $data);
|
||||
}
|
||||
|
||||
public function member($member_id = false)
|
||||
{
|
||||
if (!$member_id) {
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
$user_id = (int) str_replace('m', '', $member_id) - config('mivita.add_number_id');
|
||||
$user = User::find($user_id);
|
||||
if (!$user || !$user->isActive() || !$user->isActiveAccount()) {
|
||||
return redirect('/registrierung');
|
||||
}
|
||||
$data = [
|
||||
'GOOGLE_ReCAPTCHA_KEY' => $this->GOOGLE_ReCAPTCHA_KEY,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'from_member_id' => $member_id,
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.registrierung', $data);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
|
||||
$rules = array(
|
||||
'salutation' => 'required',
|
||||
'first_name' => 'required',
|
||||
'last_name' => 'required',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'email-confirm' => 'required|same:email',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
'password_confirmation' => 'required|string|min:6',
|
||||
'g-recaptcha-response' => 'required|recaptcha',
|
||||
'accepted_data_protection' => 'required',
|
||||
);
|
||||
|
||||
Validator::extend('recaptcha', function ($attribute, $value, $parameters, $validator) {
|
||||
return $this->reCaptcha_validate($attribute, $value, $parameters, $validator);
|
||||
});
|
||||
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
|
||||
$user_shop = Util::getUserShop();
|
||||
|
||||
$data = Request::all();
|
||||
$user = $this->userRepo->create($data);
|
||||
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
$m_sponsor_id = 1;
|
||||
if ($user_shop) {
|
||||
$m_sponsor_id = $user_shop->user->id;
|
||||
}
|
||||
if (isset($data['from_member_id'])) {
|
||||
$m_sponsor_id = (int) str_replace('m', '', $data['from_member_id']) - config('mivita.add_number_id');
|
||||
}
|
||||
$user->lang = !empty(\App::getLocale()) ? \App::getLocale() : "de";
|
||||
$user->confirmation_code = $confirmation_code;
|
||||
$user->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->m_sponsor = $m_sponsor_id;
|
||||
|
||||
$UserLevel = UserLevel::where('default', 1)->first();
|
||||
if ($UserLevel) {
|
||||
$user->m_level = $UserLevel->id;
|
||||
} else {
|
||||
$user->m_level = 10;
|
||||
}
|
||||
|
||||
$user->save();
|
||||
|
||||
$user->account->data_protection = now();
|
||||
$user->account->save();
|
||||
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($confirmation_code, User::find($user->id)));
|
||||
return redirect('/registrierung/finish');
|
||||
}
|
||||
|
||||
public function finish()
|
||||
{
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.registrierung_finish', $data);
|
||||
}
|
||||
|
||||
private function reCaptcha_validate($attribute, $value, $parameters, $validator)
|
||||
{
|
||||
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->post(
|
||||
'https://www.google.com/recaptcha/api/siteverify',
|
||||
[
|
||||
'form_params' =>
|
||||
[
|
||||
'secret' => $this->GOOGLE_ReCAPTCHA_SECRET,
|
||||
'response' => $value
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$body = json_decode((string)$response->getBody());
|
||||
return $body->success;
|
||||
}
|
||||
}
|
||||
239
dev/app-bak/Http/Controllers/Web/SiteController.php
Executable file
239
dev/app-bak/Http/Controllers/Web/SiteController.php
Executable file
|
|
@ -0,0 +1,239 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Web;
|
||||
|
||||
|
||||
use Yard;
|
||||
use Request;
|
||||
use App\Models\IqSite;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use App\Models\Product;
|
||||
use App\Models\Category;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
// GPT-5 v3.1: Optimiertes Session-Debug-Logging
|
||||
if (config('app.debug')) {
|
||||
\Log::info('SiteController: index() - GPT-5 v3.1 Session Status', [
|
||||
'session_id' => \Session::getId(),
|
||||
'user_shop_id' => session('shop.id'),
|
||||
'user_shop_slug' => session('shop.slug'),
|
||||
'user_init_country' => session('user_init_country'),
|
||||
'locale' => session('locale'),
|
||||
'request_host' => request()->getHost(),
|
||||
'domain_context' => request()->attributes->get('domain_context')?->type,
|
||||
'gpt5_v3_status' => 'active'
|
||||
]);
|
||||
}
|
||||
|
||||
$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'];
|
||||
$data = [
|
||||
'products' => Product::whereIn('slug', $products)->where('active', true)->whereJsonContains('show_on', '1')->get(),
|
||||
'set_products' => Product::whereIn('slug', $set_products)->where('active', true)->whereJsonContains('show_on', '1')->get(),
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'site' => IqSite::find(1),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
|
||||
return view('web.index', $data);
|
||||
}
|
||||
|
||||
public function domainCheck()
|
||||
{
|
||||
die("checked");
|
||||
}
|
||||
|
||||
public function changeLang()
|
||||
{
|
||||
$data = Request::all();
|
||||
|
||||
if (isset($data['change_country_id'])) {
|
||||
$mylangs = Shop::getLangChange('webshop');
|
||||
|
||||
foreach ($mylangs as $code => $country) {
|
||||
if (strtolower($data['change_country_id']) === strtolower($code)) {
|
||||
$countryCode = strtolower($code); //lieferland
|
||||
$localeCode = strtolower($data['change_locale_id'] ?? $countryCode); //sprache
|
||||
|
||||
// Optimierte Session-Schreibvorgänge
|
||||
\Session::put('user_init_country', $countryCode); //lieferland
|
||||
\Session::forget('user_init_country_options'); // Land löschen, da es vom User gesetzt wurde
|
||||
\Session::put('locale', $localeCode); //sprache
|
||||
|
||||
|
||||
// Sprache für Laravel setzen
|
||||
\App::setLocale($localeCode);
|
||||
// UserShop-Sprache initialisieren für Checkout
|
||||
Shop::initUserShopLang($country, 'webshop');
|
||||
|
||||
// Session bereinigen und speichern (wichtig für Domain-Wechsel)
|
||||
\App\Services\SessionCleaner::cleanAndSave('SiteController::changeLang');
|
||||
|
||||
// Debug-Logging für changeLang
|
||||
if (config('app.debug')) {
|
||||
\Log::info('SiteController: changeLang() - Sprache/Land geändert', [
|
||||
'country_code' => $countryCode,
|
||||
'locale_code' => $localeCode,
|
||||
'session_id' => \Session::getId(),
|
||||
'user_shop_id' => session('shop.id'),
|
||||
'checkout_ready' => true,
|
||||
'request_host' => request()->getHost()
|
||||
]);
|
||||
}
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return back()->withError('Ungültiges Land/Sprache ausgewählt');
|
||||
}
|
||||
|
||||
private function setIPInfo()
|
||||
{
|
||||
// GPT-5 v3.1: Cache-Check - wurde schon gesetzt?
|
||||
if (\Session::has('user_init_country')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$country = 'de'; // Default-Wert für DACH-Region
|
||||
|
||||
// IP-basierte Länder-Erkennung
|
||||
if (config('app.ipinfo')) {
|
||||
$ipCountry = strtolower(Shop::getIPDatabaseInfo());
|
||||
if ($ipCountry === 'error') {
|
||||
$country = 'de'; // Fallback bei IP-Service-Fehlern
|
||||
} else {
|
||||
$country = $ipCountry;
|
||||
}
|
||||
}
|
||||
|
||||
// Sprache setzen (mit Validation)
|
||||
if (array_key_exists($country, \App\Services\UserService::getTransChange())) {
|
||||
\Session::put('user_init_country', $country);
|
||||
\Session::put('locale', $country);
|
||||
\App::setLocale($country);
|
||||
} else {
|
||||
// Default: Deutschland
|
||||
\Session::put('user_init_country', 'de');
|
||||
\Session::put('locale', 'de');
|
||||
\App::setLocale('de');
|
||||
$country = 'de'; // Für nachfolgende Logik
|
||||
}
|
||||
|
||||
// Option für den Init setzen, hier wird das Lieferland für die Auswahl im Sidepanel gesetzt
|
||||
if (array_key_exists($country, Shop::getLangChange('webshop'))) {
|
||||
\Session::put('user_init_country_options', $country);
|
||||
} else {
|
||||
\Session::put('user_init_country_options', 'de');
|
||||
}
|
||||
|
||||
// GPT-5 v3.1: Session bereinigen und speichern für Domain-Wechsel-Stabilität
|
||||
\App\Services\SessionCleaner::cleanAndSave('SiteController::setIPInfo');
|
||||
|
||||
// GPT-5 v3.1: Optimiertes Debug-Logging
|
||||
if (config('app.debug')) {
|
||||
\Log::info('SiteController: setIPInfo() - Länder/Sprache initialisiert', [
|
||||
'detected_country' => $country,
|
||||
'user_init_country' => \Session::get('user_init_country'),
|
||||
'locale' => \Session::get('locale'),
|
||||
'delivery_country' => \Session::get('user_init_country_options'),
|
||||
'session_id' => \Session::getId(),
|
||||
'user_shop_id' => session('shop.id'),
|
||||
'user_shop_slug' => session('shop.slug'),
|
||||
'checkout_ready' => true,
|
||||
'ip_detection' => config('app.ipinfo') ? 'enabled' : 'disabled'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function site($site, $subsite = false, $product_slug = false)
|
||||
{
|
||||
$this->setIPInfo();
|
||||
$subsite = trim($subsite, '/');
|
||||
$product_slug = trim($product_slug, '/');
|
||||
if ($product_slug) {
|
||||
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
||||
$product = Product::where('slug', $product_slug)->where('active', true)->whereJsonContains('show_on', '1')->first();
|
||||
if ($category && $product) {
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'subsite' => $subsite,
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'ASC')->get(),
|
||||
'product' => $product,
|
||||
'p_count' => Product::where('active', true)->whereJsonContains('show_on', '1')->count(),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.produkte-show', $data);
|
||||
}
|
||||
}
|
||||
if ($site == 'produkte') {
|
||||
if ($subsite && $subsite !== 'alle-produkte') {
|
||||
$category = Category::where('slug', $subsite)->where('active', true)->first();
|
||||
if ($category) {
|
||||
$headline_image = false;
|
||||
if ($category->headline_image_id && $category->iq_image && $category->iq_image->active) {
|
||||
$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();
|
||||
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'subsite' => $subsite,
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'products' => false,
|
||||
'product_categories' => $product_categories,
|
||||
'p_count' => Product::where('active', true)->whereJsonContains('show_on', '1')->count(),
|
||||
'headline' => $category->getLang('headline'),
|
||||
'headline_image' => $headline_image,
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.' . $site, $data);
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'subsite' => 'alle-produkte',
|
||||
'categories' => Category::where('active', true)->orderBy('pos', 'DESC')->get(),
|
||||
'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' => __('website.productworld'),
|
||||
'headline_image' => false,
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
return view('web.templates.' . $site, $data);
|
||||
}
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'mylangs' => Shop::getLangChange('webshop'),
|
||||
'yard_instance' => 'webshop',
|
||||
];
|
||||
if ($subsite) {
|
||||
if (!view()->exists('web.templates.' . $subsite)) {
|
||||
abort(404);
|
||||
}
|
||||
return view('web.templates.' . $subsite, $data);
|
||||
}
|
||||
if (!view()->exists('web.templates.' . $site)) {
|
||||
abort(404);
|
||||
}
|
||||
return view('web.templates.' . $site, $data);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue