diff --git a/.env b/.env index 42c533f..9c6a223 100644 --- a/.env +++ b/.env @@ -14,8 +14,8 @@ APP_URL_CRM=my. #APP_CHECKOUT_MAIL=no-reply@mivita.care APP_CHECKOUT_MAIL=kevin.adametz@me.com -APP_INFO_MAIL=info@adametz.media -APP_DEFAULT_MAIL=info@mivita.care +APP_INFO_MAIL=kevin.adametz@me.com +APP_DEFAULT_MAIL=kevin.adametz@me.com APP_CHECKOUT_TEST_MAIL=kevin.adametz@me.com APP_INFO_TEST_MAIL=kevin.adametz@me.com diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2471186..6b08db8 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,23 +5,28 @@ + - + + + + + - + - - - - - - - - - + + + + + + + + + - + + + + + + + + @@ -274,13 +286,6 @@ - - - - - - - @@ -526,6 +531,9 @@ + + + @@ -562,10 +570,10 @@ - + - + @@ -614,12 +622,11 @@ - + - - + diff --git a/app/Http/Controllers/Api/PayoneController.php b/app/Http/Controllers/Api/PayoneController.php index 980b5ca..cd44b7c 100755 --- a/app/Http/Controllers/Api/PayoneController.php +++ b/app/Http/Controllers/Api/PayoneController.php @@ -8,6 +8,7 @@ use App\Mail\MailCheckout; use App\Models\PaymentTransaction; use App\Models\ShoppingOrder; use App\Models\ShoppingPayment; +use App\Services\Payment; use App\Services\Shop; use App\Services\Util; use App\User; @@ -137,76 +138,10 @@ class PayoneController extends Controller } if($data['txaction'] === 'paid'){ - $shopping_order->setUserHistoryValue(['status' => 8]); - Shop::userOrders(); - $shopping_order->paid = true; - $shopping_order->save(); - - //if product has actions - if($shopping_order->shopping_order_items && $shopping_order->auth_user_id){ - foreach($shopping_order->shopping_order_items as $shopping_order_item){ - if($shopping_order_item->product){ - if($shopping_order_item->product->action){ - $user = User::findOrFail($shopping_order->auth_user_id); - $user->save(); - $send_link = true; - - //new date - $date = \Carbon::now()->modify('1 year'); - if($user->payment_account && $user->daysActiveAccount()>0){ - $date = \Carbon::parse($user->payment_account)->modify('1 year'); - } - foreach ($shopping_order_item->product->action as $do){ - if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){ - $user->payment_order_id = $shopping_order_item->product->id; //34 - $user->payment_account = $date; - $user->wizard = 100; - $shopping_order->setUserHistoryValue(['status' => 9]); - } - if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){ - $user->payment_order_id = $shopping_order_item->product->id; //35 - $user->payment_shop = $date; - $user->wizard = 100; - $shopping_order->setUserHistoryValue(['status' => 9]); - } - if($shopping_order_item->product->getActionName($do) === 'payment_for_shop_upgrade'){ - if($shopping_order_item->product->upgrade_to_id){ - $user->payment_order_id = $shopping_order_item->product->upgrade_to_id; - } - $user->payment_shop = $user->payment_account; //same Date, is upgrade - $shopping_order->setUserHistoryValue(['status' => 9]); - } - if($shopping_order_item->product->getActionName($do) === 'payment_for_lead_upgrade'){ - if($shopping_order_item->product->upgrade_to_id){ - $user->m_level = $shopping_order_item->product->upgrade_to_id; - } - } - $user->save(); - } - } - } - } - } + $send_link = Payment::paymentStatusPaidAction($shopping_order, true); } - $bcc = []; - $billing_email = $shopping_order->shopping_user->billing_email; - if(!$billing_email){ - if($data['mode'] === 'test'){ - $billing_email = config('app.checkout_test_mail'); - }else{ - $billing_email = config('app.checkout_mail'); - } - } - if($data['mode'] === 'test'){ - $bcc[] = config('app.checkout_test_mail'); - }else{ - $bcc[] = config('app.checkout_mail'); - } - - if(!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member){ - $bcc[] = $shopping_order->shopping_user->member->email; - } - Mail::to($billing_email)->bcc($bcc)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $send_link, $data['mode'])); + $data['send_link'] = $send_link; + Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data); print("TSOK"); exit; } diff --git a/app/Http/Controllers/DataTableController.php b/app/Http/Controllers/DataTableController.php index 0efbcbe..adfc9b9 100644 --- a/app/Http/Controllers/DataTableController.php +++ b/app/Http/Controllers/DataTableController.php @@ -79,8 +79,6 @@ class DataTableController extends Controller } return $link.' '.$user->getPaymentMethodsShort().''; - - }) ->addColumn('action_delete', function (User $user) { return ' diff --git a/app/Http/Controllers/LeadController.php b/app/Http/Controllers/LeadController.php index fc7dfc3..4767fbb 100755 --- a/app/Http/Controllers/LeadController.php +++ b/app/Http/Controllers/LeadController.php @@ -97,6 +97,10 @@ class LeadController extends Controller } } $next_account_id = UserAccount::max('m_account') +1; + if($user->account->m_account === null){ + $user->account->m_account = $next_account_id; + } + $data = [ 'show' => 'check_lead', 'user' => $user, diff --git a/app/Http/Controllers/MembershipController.php b/app/Http/Controllers/MembershipController.php index f52d6d7..65ca030 100755 --- a/app/Http/Controllers/MembershipController.php +++ b/app/Http/Controllers/MembershipController.php @@ -103,6 +103,10 @@ class MembershipController extends Controller $identifier = Util::getToken(); } while( ShoppingInstance::where('identifier', $identifier)->count() ); + $data = []; + $data['is_from'] = 'membership'; + $data['is_for'] = 'me'; + ShoppingInstance::create([ 'identifier' => $identifier, 'user_shop_id' => 1, //is first faker shop for nuy intern @@ -110,6 +114,8 @@ class MembershipController extends Controller 'payment' => 3, //Berater Membership 'subdomain' => url('/'), 'country_id' => Yard::instance('shopping')->getShippingCountryId(), + 'shopping_data' => $data, + 'back' => url()->previous(), ]); Yard::instance('shopping')->store($identifier); diff --git a/app/Http/Controllers/Pay/PayoneController.php b/app/Http/Controllers/Pay/PayoneController.php index 8054ffc..f09d377 100644 --- a/app/Http/Controllers/Pay/PayoneController.php +++ b/app/Http/Controllers/Pay/PayoneController.php @@ -166,8 +166,18 @@ class PayoneController extends Controller } //Rechnungskauf - /* if($payment_method[0]=== 'fnc'){ - $this->method = [ + if($payment_method[0] === 'fnc'){ + //MIVITA + if(isset($payment_method[1]) && $payment_method[1] === 'MIV'){ + $this->method = [ + "clearingtype" => "fnc", + "wallettype" => "", + 'onlinebanktransfertype' => "MIV", + "request" => "authorization", + ]; + } + //PAYONE + /* $this->method = [ "clearingtype" => "fnc", "wallettype" => "", 'onlinebanktransfertype' => "", @@ -175,9 +185,9 @@ class PayoneController extends Controller "request" => "genericpayment", "add_paydata[action]" => "pre_check", "add_paydata[payment_type]" => "Payolution-Invoicing", - ]; + ];*/ } - */ + } //vorkasse if($payment_method === 'elv'){ @@ -223,6 +233,24 @@ class PayoneController extends Controller $request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls); + //RECHNUNG MIV + if($this->shopping_payment->clearingtype === 'fnc' && $this->shopping_payment->onlinebanktransfertype === 'MIV'){ + + $payt = PaymentTransaction::create([ + 'shopping_payment_id' => $this->shopping_payment->id, + 'request' => $this->method['request'], + 'txid' => 0, + 'userid' => 0, + 'status' => 'FNCMIV', + 'transmitted_data' => $request, + 'txaction' => 'invoice_open', + 'mode' => $this->shopping_payment->mode, + ]); + Util::setUserHistoryValue(['status'=>5]); + return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference])); + exit; + } + $response = Payone::sendRequest($request); /* * status APPROVED / REDIRECT / ERROR / PENDING @@ -273,6 +301,7 @@ class PayoneController extends Controller ]); Util::setUserHistoryValue(['status'=>5]); + if($payt->shopping_payment->clearingtype === "vor"){ //vorkasse return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference])); diff --git a/app/Http/Controllers/User/OrderController.php b/app/Http/Controllers/User/OrderController.php index d763507..e8cb3ba 100755 --- a/app/Http/Controllers/User/OrderController.php +++ b/app/Http/Controllers/User/OrderController.php @@ -9,6 +9,8 @@ use App\Models\ShoppingInstance; use App\Models\ShoppingOrder; use App\Models\ShoppingUser; use App\Models\UserHistory; +use App\Models\UserShop; +use App\Services\Payment; use App\Services\Util; use App\User; use Auth; @@ -36,14 +38,46 @@ class OrderController extends Controller { $user = User::find(\Auth::user()->id); $shopping_order = ShoppingOrder::findOrFail($id); - if($shopping_order->member_id !== $user->id){ + if($shopping_order->auth_user_id !== $user->id){ abort(404); } $data = [ 'shopping_order' => $shopping_order, 'isAdmin' => false, ]; - return view('user.shop.sales.order_detail', $data); + return view('user.order.detail', $data); + } + + public function ordersDatatable(){ + + $user = User::find(\Auth::user()->id); + $query = ShoppingOrder::with('shopping_user')->select('shopping_orders.*')->where('auth_user_id', '=', $user->id)->where('txaction', '!=', NULL); + + return \DataTables::eloquent($query) + ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { + return ''; + }) + ->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) { + return $ShoppingOrder->created_at->format("d.m.Y"); + }) + ->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) { + return Payment::getShoppingOrderBadge($ShoppingOrder); + }) + ->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) { + return $ShoppingOrder->getFormattedTotalShipping(); + }) + ->addColumn('orders', function (ShoppingOrder $ShoppingOrder) { + return $ShoppingOrder->shopping_user ? $ShoppingOrder->shopping_user->orders : ''; + }) + ->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) { + return $ShoppingOrder->user_shop ? ''.$ShoppingOrder->user_shop->getSubdomain(false).'' : ''; + }) + ->orderColumn('id', 'id $1') + ->orderColumn('txaction', 'txaction $1') + ->orderColumn('user_shop_id', 'user_shop_id $1') + + ->rawColumns(['id', 'txaction', 'user_shop_id']) + ->make(true); } diff --git a/app/Http/Controllers/Web/CheckoutController.php b/app/Http/Controllers/Web/CheckoutController.php index b432ba1..1eff5e8 100755 --- a/app/Http/Controllers/Web/CheckoutController.php +++ b/app/Http/Controllers/Web/CheckoutController.php @@ -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); + } + + } + } \ No newline at end of file diff --git a/app/Http/Controllers/WizardController.php b/app/Http/Controllers/WizardController.php index f2c967e..75577f9 100755 --- a/app/Http/Controllers/WizardController.php +++ b/app/Http/Controllers/WizardController.php @@ -457,6 +457,12 @@ class WizardController extends Controller $identifier = Util::getToken(); } while( ShoppingInstance::where('identifier', $identifier)->count() ); + + $data = []; + $data['is_from'] = 'wizard'; + $data['is_for'] = 'me'; + + ShoppingInstance::create([ 'identifier' => $identifier, 'user_shop_id' => 1, //is first faker shop for buy intern @@ -464,6 +470,8 @@ class WizardController extends Controller 'payment' => 4, //Berater Wizard 'subdomain' => url('/'), 'country_id' => Yard::instance('shopping')->getShippingCountryId(), + 'shopping_data' => $data, + 'back' => url()->previous(), ]); Yard::instance('shopping')->store($identifier); diff --git a/app/Http/Middleware/Checkout.php b/app/Http/Middleware/Checkout.php index 6e24735..2344613 100755 --- a/app/Http/Middleware/Checkout.php +++ b/app/Http/Middleware/Checkout.php @@ -38,7 +38,10 @@ class Checkout } if($shopping_instance->back){ \Session::put('back_link', $shopping_instance->back); + } + \Session::put('new_session', true); + Yard::instance('shopping')->destroy(); //restore yard Yard::instance('shopping')->restore($request->route('identifier')); diff --git a/app/Models/PaymentMethod.php b/app/Models/PaymentMethod.php index 2542756..1eaef29 100644 --- a/app/Models/PaymentMethod.php +++ b/app/Models/PaymentMethod.php @@ -71,7 +71,7 @@ class PaymentMethod extends Model return isset(self::$showATs[$this->show_at]) ? self::$showATs[$this->show_at] : '-'; } - public static function getDefaultAsArray(){ + public static function getDefaultAsArray($short=false){ return PaymentMethod::where('active', true)->where('default', true)->pluck('id'); } } diff --git a/app/Models/ShoppingPayment.php b/app/Models/ShoppingPayment.php index 1df1eef..5613dfd 100644 --- a/app/Models/ShoppingPayment.php +++ b/app/Models/ShoppingPayment.php @@ -89,6 +89,11 @@ class ShoppingPayment extends Model return 'Sofort Überweisung'; } } + if($this->clearingtype === 'fnc') { + if ($this->onlinebanktransfertype === 'MIV') { + return 'Rechnung'; + } + } } public function getPaymentAmount(){ diff --git a/app/Services/Payment.php b/app/Services/Payment.php index 339cd4f..d7e7ebc 100644 --- a/app/Services/Payment.php +++ b/app/Services/Payment.php @@ -2,9 +2,11 @@ namespace App\Services; +use App\Mail\MailCheckout; use App\Models\ShoppingOrder; use App\Models\ShoppingPayment; use App\User; +use Illuminate\Support\Facades\Mail; class Payment { @@ -14,6 +16,7 @@ class Payment 'appointed' => "offen", 'failed' => "abbruch", 'extern' => "extern", + 'invoice_open' => "Re. offen", 'NULL' => 'keine Zahlung', ]; @@ -22,6 +25,7 @@ class Payment 'appointed' => "warning", 'failed' => "danger", 'extern' => "success", + 'invoice_open' => "warning", ]; @@ -44,7 +48,7 @@ class Payment return ''.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).''; } if($shopping_order->mode === 'dev'){ - return ''.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).''; + return ''.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).''; } return ''.self::getFormattedTxaction($shopping_order->txaction).''; } @@ -57,4 +61,79 @@ class Payment } + public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){ + $send_link = false; + $shopping_order->setUserHistoryValue(['status' => 8]); + Shop::userOrders(); + $shopping_order->paid = $paid; + $shopping_order->save(); + + //if product has actions + if($shopping_order->shopping_order_items && $shopping_order->auth_user_id){ + foreach($shopping_order->shopping_order_items as $shopping_order_item){ + if($shopping_order_item->product){ + if($shopping_order_item->product->action){ + $user = User::findOrFail($shopping_order->auth_user_id); + $user->save(); + $send_link = true; + //new date + $date = \Carbon::now()->modify('1 year'); + if($user->payment_account && $user->daysActiveAccount()>0){ + $date = \Carbon::parse($user->payment_account)->modify('1 year'); + } + foreach ($shopping_order_item->product->action as $do){ + if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){ + $user->payment_order_id = $shopping_order_item->product->id; //34 + $user->payment_account = $date; + $user->wizard = 100; + $shopping_order->setUserHistoryValue(['status' => 9]); + } + if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){ + $user->payment_order_id = $shopping_order_item->product->id; //35 + $user->payment_shop = $date; + $user->wizard = 100; + $shopping_order->setUserHistoryValue(['status' => 9]); + } + if($shopping_order_item->product->getActionName($do) === 'payment_for_shop_upgrade'){ + if($shopping_order_item->product->upgrade_to_id){ + $user->payment_order_id = $shopping_order_item->product->upgrade_to_id; + } + $user->payment_shop = $user->payment_account; //same Date, is upgrade + $shopping_order->setUserHistoryValue(['status' => 9]); + } + if($shopping_order_item->product->getActionName($do) === 'payment_for_lead_upgrade'){ + if($shopping_order_item->product->upgrade_to_id){ + $user->m_level = $shopping_order_item->product->upgrade_to_id; + } + } + $user->save(); + } + } + } + } + } + return $send_link; + } + + public static function paymentStatusSendMail(ShoppingOrder $shopping_order, $shopping_payment, $data){ + $bcc = []; + $billing_email = $shopping_order->shopping_user->billing_email; + if(!$billing_email){ + if($data['mode'] === 'test'){ + $billing_email = config('app.checkout_test_mail'); + }else{ + $billing_email = config('app.checkout_mail'); + } + } + if($data['mode'] === 'test'){ + $bcc[] = config('app.checkout_test_mail'); + }else{ + $bcc[] = config('app.checkout_mail'); + } + + if(!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member){ + $bcc[] = $shopping_order->shopping_user->member->email; + } + Mail::to($billing_email)->bcc($bcc)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $data['send_link'], $data['mode'])); + } } diff --git a/app/Services/Shop.php b/app/Services/Shop.php index f9b7fee..bba7526 100644 --- a/app/Services/Shop.php +++ b/app/Services/Shop.php @@ -2,6 +2,8 @@ namespace App\Services; +use App\Models\Country; +use App\Models\ShippingCountry; use App\Models\ShoppingUser; use Gloudemans\Shoppingcart\CartItem; @@ -40,4 +42,22 @@ class Shop } } } + + + public static function getShippingCountryCountryId($shipping_country_id){ + $shippingCountry = ShippingCountry::find($shipping_country_id); + if($shippingCountry && $shippingCountry->country){ + return $shippingCountry->country->id; + } + return 1; //default DE + } + + public static function getCountryShippingCountryId($country_id){ + $shippingCountry = ShippingCountry::whereCountryId($country_id)->first(); + if($shippingCountry){ + return $shippingCountry->id; + } + return ShippingCountry::all()->first()->id; + } + } \ No newline at end of file diff --git a/public/images/payments-assets/fnc.png b/public/images/payments-assets/fnc.png new file mode 100644 index 0000000..d858a43 Binary files /dev/null and b/public/images/payments-assets/fnc.png differ diff --git a/resources/lang/de/email.php b/resources/lang/de/email.php index d9f779e..3510c1b 100644 --- a/resources/lang/de/email.php +++ b/resources/lang/de/email.php @@ -70,5 +70,6 @@ 'checkout_mail_bank_total' => 'Gesamtbetrag', 'checkout_mail_bank_code' => 'Verwendungszweck', 'checkout_mail_pay_approved' => 'Deine Zahlung wurde genehmigt, eine Bestätigung der Zahlung wird automatisch erstellt.', + 'checkout_mail_pay_invoice_open' => 'Deine Zahlung per Rechnung wurde genehmigt.', 'checkout_mail_system_status' => 'SystemStatus:', ); \ No newline at end of file diff --git a/resources/views/emails/checkout_status.blade.php b/resources/views/emails/checkout_status.blade.php index dafa8ab..78485b4 100644 --- a/resources/views/emails/checkout_status.blade.php +++ b/resources/views/emails/checkout_status.blade.php @@ -156,11 +156,11 @@
- @if($txaction == 'failed') + @if($txaction === 'failed') {{__('email.checkout_mail_pay_error')}}
- @elseif($txaction == 'appointed') + @elseif($txaction === 'appointed') - @if($shopping_payment->clearingtype == "vor") + @if($shopping_payment->clearingtype === "vor") {{__('email.checkout_mail_pay_pre')}}
{{__('email.checkout_mail_pay_pre_c1')}} {{ number_format( floatval($shopping_payment->amount/100), 2, ",", ".") }} {{__('email.checkout_mail_pay_pre_c2')}}

@@ -176,6 +176,8 @@ @else {{__('email.checkout_mail_pay_approved')}}
@endif + @elseif($txaction === 'invoice_open') + {{__('email.checkout_mail_pay_invoice_open')}}
@else {{__('email.checkout_mail_system_status')}} {{$txaction}}
diff --git a/resources/views/user/shop/sales/order_detail.blade.php b/resources/views/user/order/detail.blade.php similarity index 54% rename from resources/views/user/shop/sales/order_detail.blade.php rename to resources/views/user/order/detail.blade.php index 81c48fd..54c29ee 100644 --- a/resources/views/user/shop/sales/order_detail.blade.php +++ b/resources/views/user/order/detail.blade.php @@ -2,10 +2,10 @@ @section('content')

- zurück + zurück {{ __('Bestellung Kunde') }} #{{$shopping_order->id}}

@include('admin.sales._detail') - zurück + zurück @endsection \ No newline at end of file diff --git a/resources/views/user/order/index.blade.php b/resources/views/user/order/index.blade.php index a066886..d026934 100644 --- a/resources/views/user/order/index.blade.php +++ b/resources/views/user/order/index.blade.php @@ -7,83 +7,47 @@
-
- -
- +
+ + + - - - - - - - + + + - - - - - - -
#{{__('First name')}}{{__('Last name')}} {{__('E-Mail')}}{{__('Anrede')}}{{__('Firma')}}{{__('Vorname')}}{{__('Nachname')}}{{__('PLZ')}}{{__('Stadt')}}{{__('Land')}}{{__('Datum')}}{{__('Status')}}{{__('Betrag')}} {{__('Käufe')}}{{__('Newsletter')}}{{__('erstellt')}}{{__('ID Kunden')}}WP
-
- -
- -@endsection - +@endsection \ No newline at end of file diff --git a/resources/views/web/templates/checkout-final.blade.php b/resources/views/web/templates/checkout-final.blade.php index 9d60089..bfb624b 100644 --- a/resources/views/web/templates/checkout-final.blade.php +++ b/resources/views/web/templates/checkout-final.blade.php @@ -126,6 +126,12 @@

Deine Zahlung wird bearbeitet, eine Bestätigung zur Zahlungsabwicklung wird automatisch erstellt.


@endif + + @if($pay_trans->shopping_payment->clearingtype === "fnc" && $pay_trans->shopping_payment->onlinebanktransfertype === 'MIV') +

Bezahlung per Rechnung:

+

Deine Bestellung wird bearbeitet, eine Bestätigung zur Bestellungsabwicklung wird automatisch erstellt.

+
+ @endif @endif

Dein Team von mivita.care diff --git a/resources/views/web/templates/checkout.blade.php b/resources/views/web/templates/checkout.blade.php index 235662d..bbe87e1 100644 --- a/resources/views/web/templates/checkout.blade.php +++ b/resources/views/web/templates/checkout.blade.php @@ -148,7 +148,7 @@

{!! Form::open(['url' => route('checkout.checkout_card_final'), 'class' => 'row clearfix', 'id'=>'checkout_card_final']) !!} - {!! Form::hidden('selected_country') !!} + {!! Form::hidden('selected_country', '') !!} {!! Form::hidden('is_for', $shopping_user->is_for) !!} {!! Form::hidden('is_from', $shopping_user->is_from) !!} @@ -177,114 +177,204 @@

Rechnung & Versand


-
-
-
- - {!! Form::text('billing_company', $shopping_user->billing_company, ['class' => 'form-control', 'id'=>'billing_company']) !!} + @if($is_from === 'shopping') +
+
+
+
+ + {!! Form::text('billing_company', $shopping_user->billing_company, ['class' => 'form-control', 'id'=>'billing_company']) !!} +
-
-
-
-
- - + {!! HTMLHelper::getSalutation(($shopping_user->billing_salutation ? $shopping_user->billing_salutation : old('billing_salutation'))) !!} + + @if ($errors->has('billing_salutation')) + + @endif +
+
+
+
+
+
+ + {!! Form::text('billing_firstname', $shopping_user->billing_firstname, ['class' => 'form-control '.($errors->has('billing_firstname') ? 'error' : ''), 'id'=>'billing_firstname']) !!} + @if ($errors->has('billing_firstname')) + + @endif +
+
+
+
+ + {!! Form::text('billing_lastname', $shopping_user->billing_lastname, ['class' => 'form-control '.($errors->has('billing_lastname') ? 'error' : ''), 'id'=>'billing_lastname']) !!} + @if ($errors->has('billing_lastname')) + + @endif +
+
+
+ +
+
+
+ + {!! Form::text('billing_address', $shopping_user->billing_address, ['class' => 'form-control '.($errors->has('billing_address') ? 'error' : ''), 'id'=>'billing_address']) !!} + @if ($errors->has('billing_address')) + + @endif +
+
+
+
+ + {!! Form::text('billing_address_2', $shopping_user->billing_address_2, ['class' => 'form-control '.($errors->has('billing_address_2') ? 'error' : ''), 'id'=>'billing_address_2']) !!} + @if ($errors->has('billing_address_2')) + + @endif +
+
+
+ +
+
+ + {!! Form::text('billing_zipcode', $shopping_user->billing_zipcode, ['class' => 'form-control '.($errors->has('billing_zipcode') ? 'error' : ''), 'id'=>'billing_zipcode']) !!} + @if ($errors->has('billing_zipcode')) + + @endif +
+
+ + {!! Form::text('billing_city', $shopping_user->billing_city, ['class' => 'form-control '.($errors->has('billing_city') ? 'error' : ''), 'id'=>'billing_city']) !!} + @if ($errors->has('billing_city')) + + @endif +
+
+
+
+ + - @if ($errors->has('billing_salutation')) - - @endif + + Bei der Änderung des Versandlandes werden die Versandkosten neu berechnet.
-
-
-
-
- - {!! Form::text('billing_firstname', $shopping_user->billing_firstname, ['class' => 'form-control '.($errors->has('billing_firstname') ? 'error' : ''), 'id'=>'billing_firstname']) !!} - @if ($errors->has('billing_firstname')) - - @endif -
-
-
-
- - {!! Form::text('billing_lastname', $shopping_user->billing_lastname, ['class' => 'form-control '.($errors->has('billing_lastname') ? 'error' : ''), 'id'=>'billing_lastname']) !!} - @if ($errors->has('billing_lastname')) - - @endif -
-
-
-
-
-
- - {!! Form::text('billing_address', $shopping_user->billing_address, ['class' => 'form-control '.($errors->has('billing_address') ? 'error' : ''), 'id'=>'billing_address']) !!} - @if ($errors->has('billing_address')) - +
+
+ + {!! Form::text('billing_phone', $shopping_user->billing_phone, ['class' => 'form-control '.($errors->has('billing_phone') ? 'error' : ''), 'id'=>'billing_phone']) !!} + @if ($errors->has('billing_phone')) + @endif
-
-
- - {!! Form::text('billing_address_2', $shopping_user->billing_address_2, ['class' => 'form-control '.($errors->has('billing_address_2') ? 'error' : ''), 'id'=>'billing_address_2']) !!} - @if ($errors->has('billing_address_2')) - +
+
+ + {!! Form::email('billing_email', $shopping_user->billing_email, ['class' => 'form-control '.($errors->has('billing_email') ? 'error' : ''), 'id'=>'billing_email']) !!} + @if ($errors->has('billing_email')) + + @endif +
+
+ +
+
+
+ + @if ($errors->has('accepted_data_checkbox')) + @endif
+ @else +
-
-
- - {!! Form::text('billing_zipcode', $shopping_user->billing_zipcode, ['class' => 'form-control '.($errors->has('billing_zipcode') ? 'error' : ''), 'id'=>'billing_zipcode']) !!} - @if ($errors->has('billing_zipcode')) - - @endif -
-
- - {!! Form::text('billing_city', $shopping_user->billing_city, ['class' => 'form-control '.($errors->has('billing_city') ? 'error' : ''), 'id'=>'billing_city']) !!} - @if ($errors->has('billing_city')) - - @endif -
-
-
-
- - - - Bei der Änderung des Versandlandes werden die Versandkosten neu berechnet. -
-
+ {!! Form::hidden('billing_company', $shopping_user->billing_company) !!} + {!! Form::hidden('billing_salutation', $shopping_user->billing_salutation) !!} + {!! Form::hidden('billing_firstname', $shopping_user->billing_firstname) !!} + {!! Form::hidden('billing_lastname', $shopping_user->billing_lastname) !!} + {!! Form::hidden('billing_address', $shopping_user->billing_address) !!} + {!! Form::hidden('billing_address_2', $shopping_user->billing_address_2) !!} + {!! Form::hidden('billing_zipcode', $shopping_user->billing_zipcode) !!} + {!! Form::hidden('billing_city', $shopping_user->billing_city) !!} + {!! Form::hidden('billing_phone', $shopping_user->billing_phone) !!} + {!! Form::hidden('billing_email', $shopping_user->billing_email) !!} + {!! Form::hidden('billing_state', $shopping_user->billing_state) !!} + {!! Form::hidden('billing_country_id', \App\Services\Shop::getShippingCountryCountryId($shopping_user->billing_state)) !!} -
-
- - {!! Form::text('billing_phone', $shopping_user->billing_phone, ['class' => 'form-control '.($errors->has('billing_phone') ? 'error' : ''), 'id'=>'billing_phone']) !!} - @if ($errors->has('billing_phone')) - +
+ @if($shopping_user->billing_company) +
+
Firma
+ {{ $shopping_user->billing_company }} +
@endif +
+
Anrede
+ {{ \App\Services\HTMLHelper::getSalutationLang($shopping_user->billing_salutation) }} +
+
+
Vorname
+ {{ $shopping_user->billing_firstname }} +
+
+
Nachname
+ {{ $shopping_user->billing_lastname }} +
-
-
-
- - {!! Form::email('billing_email', $shopping_user->billing_email, ['class' => 'form-control '.($errors->has('billing_email') ? 'error' : ''), 'id'=>'billing_email']) !!} - @if ($errors->has('billing_email')) - - @endif +
+
+
Straße
+ {{ $shopping_user->billing_address }} +
+
+
Zusatz
+ {{ $shopping_user->billing_address_2 }} +
+
+
PLZ
+ {{ $shopping_user->billing_zipcode }} +
+
+
Stadt
+ {{ $shopping_user->billing_city }} +
+
+
Land
+ {{ $shopping_user->billing_country->getLocated() }} +
+
+
Telefon
+ {{ $shopping_user->billing_phone }} +
+
+
E-Mail
+ {{ $shopping_user->billing_email }} +
+

Hinterlegte Rechnungsdaten von Beratern können nur im Salescenter geändert werden.

+ @endif
@@ -303,8 +393,6 @@ @endif
- -
@@ -414,11 +502,11 @@
- + - + Bei der Änderung des Landes werden die Versandkosten neu berechnet.
@@ -437,11 +525,11 @@ @if(isset($order_reference)) - + zurück zum Shop @else - + @if(Util::getUserPaymentFor() > 1) zurück {{ Util::getMyMivitaUrl(false) }} @else @@ -463,55 +551,80 @@
- @if(($shopping_user->abo_options === 1) && (Util::getUserPaymentFor() >= 3)) + + + @if(($shopping_user->abo_options === 1) && (Util::getUserPaymentFor() >= 3)) + + @if(array_key_exists('SEPA', $payment_methods_active) && in_array($payment_methods_active['SEPA'], $payment_methods)) +
+ +
+ @else +

Zahlungsmethode nicht freigeschaltet, bitte wende dich an {{ config('app.default_mail') }}

+ @endif + @else + @if(array_key_exists('PP', $payment_methods_active) && in_array($payment_methods_active['PP'], $payment_methods)) +
+ +
+ @endif + @if(array_key_exists('CC', $payment_methods_active) && in_array($payment_methods_active['CC'], $payment_methods)) +
+ +
+ @endif + @if(array_key_exists('SB', $payment_methods_active) && in_array($payment_methods_active['SB'], $payment_methods))
+
+ @endif + @if(array_key_exists('SEPA', $payment_methods_active) && in_array($payment_methods_active['SEPA'], $payment_methods)) +
+
- @else -
- -
-
- -
-
- -
-
- -
-
- -
- @endif - - {{--
+ {{-- +