08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
|
|
@ -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(),
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue