Next Member Shopping
This commit is contained in:
parent
fb27009339
commit
16fe2fa363
23 changed files with 619 additions and 334 deletions
|
|
@ -5,12 +5,16 @@ namespace App\Http\Controllers\Web;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Pay\PayoneController;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Shop;
|
||||
use App\User;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Support\Collection;
|
||||
|
|
@ -37,7 +41,10 @@ class CheckoutController extends Controller
|
|||
|
||||
public function checkout(){
|
||||
|
||||
// dd("back");
|
||||
//TODO ZAHLDIENSTE FORM USER !!!
|
||||
|
||||
// dump(Request::all());
|
||||
// dd("back");
|
||||
// $user_shop = Util::getUserShop();
|
||||
$shopping_data = Yard::instance('shopping')->getYardExtra('shopping_data');
|
||||
|
||||
|
|
@ -45,35 +52,50 @@ class CheckoutController extends Controller
|
|||
$is_for = isset($shopping_data['is_for']) ? $shopping_data['is_for'] : false;
|
||||
$shopping_user = null;
|
||||
|
||||
if($shopping_data && $is_from !== 'shopping'){
|
||||
//$shopping_user_id = isset($shopping_data['shopping_user_id']) ? $shopping_data['shopping_user_id'] : false;
|
||||
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
|
||||
|
||||
}elseif($is_from === 'shopping') {
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->is_for = $is_for;
|
||||
$shopping_user->is_from = $is_from;
|
||||
}
|
||||
/*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
|
||||
//$shopping_user_id = isset($shopping_data['shopping_user_id']) ? $shopping_data['shopping_user_id'] : false;
|
||||
$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') {
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->is_for = $is_for;
|
||||
$shopping_user->is_from = $is_from;
|
||||
$shopping_user->mode = 'prev';
|
||||
}
|
||||
}else{
|
||||
$shopping_user = ShoppingUser::findOrFail($this->getPayments('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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(Request::get('selected_country')){
|
||||
//Yard::instance('shopping')->setShippingCountryWithPrice(Request::get('selected_country'), $is_for);
|
||||
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('shopping')->getShippingCountryId();
|
||||
$shopping_user->shipping_state = Yard::instance('shopping')->getShippingCountryId();
|
||||
// $ShippingCountry = ShippingCountry::where('country_id', 1)->first();
|
||||
// $selected_country = $ShippingCountry->id;
|
||||
}
|
||||
|
||||
if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){
|
||||
//$user->email;
|
||||
|
||||
// $shopping_user->save();
|
||||
// $this->putPayments('shopping_user_id', $shopping_user->id);
|
||||
}else{
|
||||
//$shopping_user = ShoppingUser::findOrNew($this->getPayments('shopping_user_id'));
|
||||
}
|
||||
|
||||
if(Util::getAuthUser()){
|
||||
|
|
@ -84,12 +106,24 @@ class CheckoutController extends Controller
|
|||
if($shopping_user->same_as_billing === NULL){
|
||||
$shopping_user->same_as_billing = true;
|
||||
}
|
||||
|
||||
if($is_from !== 'shopping' && Util::getAuthUser()){
|
||||
$user = Util::getAuthUser();
|
||||
$payment_methods = $user->payment_methods;
|
||||
}else{
|
||||
$payment_methods = PaymentMethod::getDefaultAsArray();
|
||||
}
|
||||
|
||||
$payment_methods_active = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
|
||||
|
||||
$data = [
|
||||
'is_from' => $is_from,
|
||||
'is_for' => $is_for,
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'shopping_user' => $shopping_user,
|
||||
'shopping_mode' => Util::getUserShoppingMode(),
|
||||
'payment_methods' => $payment_methods,
|
||||
'payment_methods_active' => $payment_methods_active,
|
||||
];
|
||||
return view('web.templates.checkout', $data);
|
||||
}
|
||||
|
|
@ -99,6 +133,7 @@ class CheckoutController extends Controller
|
|||
$user = Util::getAuthUser();
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->auth_user_id = $user->id;
|
||||
$shopping_user->mode = 'prev';
|
||||
|
||||
$shopping_user->billing_salutation = $user->account->salutation;
|
||||
$shopping_user->billing_company = $user->account->company;
|
||||
|
|
@ -168,9 +203,8 @@ class CheckoutController extends Controller
|
|||
|
||||
|
||||
$data = Request::all();
|
||||
|
||||
//change selected Country
|
||||
if(isset($data['selected_country']) && $data['selected_country'] === 'change'){
|
||||
|
||||
if(Request::get('same_as_billing')){
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($data['billing_state'], $data['is_for']);
|
||||
}else{
|
||||
|
|
@ -180,7 +214,6 @@ class CheckoutController extends Controller
|
|||
|
||||
}
|
||||
|
||||
dd('ads');
|
||||
$rules = array(
|
||||
'billing_salutation' => 'required',
|
||||
'billing_firstname'=>'required',
|
||||
|
|
@ -214,13 +247,19 @@ class CheckoutController extends Controller
|
|||
//make Order and Items
|
||||
$shopping_order = $this->makeShoppingOrder($shopping_user);
|
||||
//CustomerPriority
|
||||
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
|
||||
if($shopping_user->is_from === 'shopping'){
|
||||
CustomerPriority::checkOne(ShoppingUser::find($shopping_user->id), true);
|
||||
}
|
||||
Util::setUserHistoryValue(['status'=>2, 'shopping_order_id'=>$shopping_order->id]);
|
||||
|
||||
//check credit Card
|
||||
if(Request::get('payment_method')){
|
||||
|
||||
$ret = [];
|
||||
//Rechnungskauf ohne PAYONE
|
||||
if(Request::get('payment_method') === 'fnc#MIV'){
|
||||
|
||||
}
|
||||
//need precheck the card
|
||||
if(Request::get('payment_method') === 'cc'){
|
||||
$pay = new PayoneController();
|
||||
|
|
@ -249,7 +288,7 @@ class CheckoutController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
//need precheck the card
|
||||
//need precheck the SEPA
|
||||
if(Request::get('payment_method') === 'elv' && is_null(Request::get('mandate_identification'))){
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
|
|
@ -270,6 +309,7 @@ class CheckoutController extends Controller
|
|||
\Session::flash('customermessage', $ret['elv']['customermessage']);
|
||||
return redirect(route('checkout.checkout_card'))->withInput(Request::all());
|
||||
}
|
||||
// mandate_status active
|
||||
if($ret['elv']['status'] === 'APPROVED' && $ret['elv']['mandate_status'] !== "active"){
|
||||
\Session::flash('elv-managemandate', 1);
|
||||
\Session::flash('elv-mandate_identification', $ret['elv']['mandate_identification']);
|
||||
|
|
@ -294,7 +334,6 @@ class CheckoutController extends Controller
|
|||
$ret['elv']['bankaccountholder'] = $data['elv_bankaccountholder'];
|
||||
//check abo and save the mandate
|
||||
$this->storeUserPaymentsData($shopping_user, $ret);
|
||||
|
||||
}
|
||||
//other
|
||||
$pay = new PayoneController();
|
||||
|
|
@ -359,9 +398,15 @@ class CheckoutController extends Controller
|
|||
if($payt->shopping_payment->reference != $reference){
|
||||
abort(404);
|
||||
}
|
||||
|
||||
Yard::instance('shopping')->destroy();
|
||||
$this->destroy();
|
||||
//vor
|
||||
|
||||
//Rechnung MIV
|
||||
if($payt->status === 'FNCMIV'){
|
||||
$this->directPaymentStatus($payt);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_shop' => Util::getUserShop(),
|
||||
'order_reference' => $payt->shopping_payment->reference,
|
||||
|
|
@ -392,6 +437,7 @@ class CheckoutController extends Controller
|
|||
$shopping_user = ShoppingUser::find($this->getPayments('shopping_user_id'));
|
||||
if($shopping_user){
|
||||
$shopping_user->fill($data);
|
||||
$shopping_user->mode = null;
|
||||
$shopping_user->save();
|
||||
}
|
||||
}
|
||||
|
|
@ -420,6 +466,7 @@ class CheckoutController extends Controller
|
|||
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'weight' => Yard::instance('shopping')->weight(),
|
||||
'txaction' => 'prev',
|
||||
'mode' => Util::getUserShoppingMode(),
|
||||
];
|
||||
$shopping_order= false;
|
||||
|
|
@ -500,4 +547,24 @@ class CheckoutController extends Controller
|
|||
$this->session->remove($this->instance);
|
||||
}
|
||||
|
||||
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();
|
||||
$shopping_payment->txaction = 'invoice_open';
|
||||
$shopping_payment->save();
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
|
||||
$data = [
|
||||
'mode' => $payt->transmitted_data['mode'],
|
||||
'txaction' => $payt->txaction,
|
||||
'send_link' => $send_link,
|
||||
];
|
||||
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue