From 263cf93a1eb2225e710268d63ce21fc431a930a5 Mon Sep 17 00:00:00 2001 From: Kevin Adametz Date: Thu, 21 Jul 2022 10:37:34 +0200 Subject: [PATCH] #53, #52, #51 change Points --- KasController.php | 111 ------------ .../Controllers/BusinessPointsController.php | 130 ++++++++++++++ app/Http/Controllers/MembershipController.php | 4 +- app/Http/Controllers/ModalController.php | 18 +- .../Controllers/PaymentPointsController.php | 130 ++++++++++++++ app/Http/Controllers/SalesController.php | 44 ++++- app/Http/Controllers/SyS/SysController.php | 16 ++ .../Controllers/User/HomepartyController.php | 2 +- app/Http/Controllers/User/OrderController.php | 19 +- .../Controllers/User/ShopApiController.php | 5 +- .../Controllers/User/ShopSalesController.php | 4 + app/Http/Controllers/WizardController.php | 24 +-- app/Models/Product.php | 15 +- app/Models/ShoppingOrder.php | 15 +- app/Models/UserSalesVolume.php | 52 ++---- app/Repositories/InvoiceRepository.php | 56 +----- .../BusinessPlan/SalesPointsVolume.php | 166 ++++++++++++++++++ app/Services/CustomerPriority.php | 3 +- app/Services/HTMLHelper.php | 2 +- app/Services/Payment.php | 6 +- app/Services/Shop.php | 5 +- app/Services/ShopApiOrderCart.php | 3 +- app/Services/SyS/Correction.php | 3 +- ...102231_create_user_sales_volumes_table.php | 2 + public/js/iq-homeparty-cart.js | 4 +- public/js/iq-shopping-cart.js | 4 +- resources/lang/de/navigation.php | 1 + .../views/admin/modal/change_points.blade.php | 83 +++++++++ resources/views/admin/sales/_detail.blade.php | 52 ++++-- .../admin/sales/_detail_collection.blade.php | 2 +- resources/views/emails/checkout.blade.php | 5 +- .../views/emails/checkout_status.blade.php | 10 +- .../layouts/includes/layout-sidenav.blade.php | 4 + .../pdf/invoice-journal-collection.blade.php | 2 +- resources/views/user/order/detail.blade.php | 2 +- .../user/shop/sales/api_order_list.blade.php | 2 +- .../user/shop/sales/api_orders.blade.php | 6 +- .../modal_api_order_shipping_detail.blade.php | 63 +++++++ .../views/user/shop/sales/orders.blade.php | 17 +- .../views/web/templates/checkout.blade.php | 2 +- routes/web.php | 6 + 41 files changed, 812 insertions(+), 288 deletions(-) delete mode 100644 KasController.php create mode 100644 app/Http/Controllers/BusinessPointsController.php create mode 100644 app/Http/Controllers/PaymentPointsController.php create mode 100644 app/Services/BusinessPlan/SalesPointsVolume.php create mode 100644 resources/views/admin/modal/change_points.blade.php create mode 100644 resources/views/user/shop/sales/modal_api_order_shipping_detail.blade.php diff --git a/KasController.php b/KasController.php deleted file mode 100644 index cf6d450..0000000 --- a/KasController.php +++ /dev/null @@ -1,111 +0,0 @@ - Sekunden ab, bei Y verlängert sich die Session mit jeder Benutzung - private $CredentialToken = false; - private $kas_flood_delay = 2; - - /** - * Create a new controller instance. - * - * @return void - */ - public function __construct() - { - $this->login(); - } - - - public function action($func, $para = array()){ - - $this->checkSession($func); - try - { - $Params = array(); // Parameter für die API-Funktion - $SoapRequest = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl'); - $req = $SoapRequest->KasApi(json_encode(array( - 'KasUser' => $this->kas_user, // KAS-User - 'KasAuthType' => 'session', // Auth per Sessiontoken - 'KasAuthData' => $this->CredentialToken, // Auth-Token - 'KasRequestType' => $func, // API-Funktion - 'KasRequestParams' => $para // Parameter an die API-Funktion - ))); - Session::put('flood_protection.'.$func, time() + $this->kas_flood_delay + 0.2); - - if(isset($req['Response']['ReturnString']) && $req['Response']['ReturnString'] == "TRUE"){ - return $req['Response']['ReturnInfo']; - } - return $req; - } - - // Fehler abfangen und ausgeben - catch (SoapFault $fault) - { - trigger_error(" Fehlernummer: {$fault->faultcode}, - Fehlermeldung: {$fault->faultstring}, - Verursacher: {$fault->faultactor}, - Details: {$fault->detail}", E_USER_ERROR); - } - } - - - private function login(){ - - $this->checkSession('auth'); - try - { - - $SoapLogon = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl'); - $this->CredentialToken = $SoapLogon->KasAuth(json_encode(array( - 'KasUser' => $this->kas_user, - 'KasAuthType' => 'sha1', - 'KasPassword' => sha1($this->kas_pass), - 'SessionLifeTime' => $this->session_lifetime, - 'SessionUpdateLifeTime' => $this->session_update_lifetime - ))); - Session::put('flood_protection.auth', time() + $this->kas_flood_delay + 0.2); - - } - - // Fehler abfangen und ausgeben - catch (SoapFault $fault) - { - trigger_error("Fehlernummer: {$fault->faultcode}, - Fehlermeldung: {$fault->faultstring}, - Verursacher: {$fault->faultactor}, - Details: {$fault->detail}", E_USER_ERROR); - } - - } - - private function checkSession($func) - { - $name = 'flood_protection.'.$func; - - if(Session::exists($name)){ - $time_to_wait = (float)Session::get($name) - time(); - Session::forget($name); - }else { - $time_to_wait = 0; - } - if ( $time_to_wait >= 0 ) { - usleep( intval( $time_to_wait*1000000 ) ); - } - - } -} \ No newline at end of file diff --git a/app/Http/Controllers/BusinessPointsController.php b/app/Http/Controllers/BusinessPointsController.php new file mode 100644 index 0000000..ebd7c90 --- /dev/null +++ b/app/Http/Controllers/BusinessPointsController.php @@ -0,0 +1,130 @@ +middleware('auth'); + } + + public function index() + { + + $this->setFilterVars(); + $data = [ + 'filter_months' => HTMLHelper::$months, + 'filter_years' => HTMLHelper::getYearRange(), + ]; + return view('admin.payment.invoice', $data); + } + + private function setFilterVars(){ + + if(!session('invoice_filter_month')){ + session(['invoice_filter_month' => intval(date('m'))]); + } + if(!session('invoice_filter_year')){ + session(['invoice_filter_year' => intval(date('Y'))]); + } + if(Request::get('invoice_filter_name')){ + session(['invoice_filter_name' => Request::get('invoice_filter_name')]); + } + if(Request::get('invoice_filter_month')){ + session(['invoice_filter_month' => Request::get('invoice_filter_month')]); + } + if(Request::get('invoice_filter_year')){ + session(['invoice_filter_year' => Request::get('invoice_filter_year')]); + } + } + + private function initSearch($archive = false, $request = true) + { + $this->setFilterVars(); + + $query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*') + ->where('user_invoices.month', '=', Request::get('invoice_filter_month')) + ->where('user_invoices.year', '=', Request::get('invoice_filter_year')); + + if(Request::get('invoice_filter_name')){ + $query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%'); + $query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%'); + $query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%'); + } + + //->orderBy('created_at', 'DESC'); + /* $query = FlexHour::leftJoin("flex_hour_items", function($join) { + $join->on("flex_hour_items.flex_hour_id","=","flex_hours.id"); + $join->where("flex_hour_items.date","=", FlexHourItemBot::$date); + })*/ + return $query; + } + + public function datatable(){ + + $query = $this->initSearch(); + return \DataTables::eloquent($query) + ->addColumn('id', function (UserInvoice $UserInvoice) { + if($UserInvoice->shopping_order->auth_user_id){ + return ''; + } + return ''; + + }) + ->addColumn('total_shipping', function (UserInvoice $UserInvoice) { + return ''.$UserInvoice->shopping_order->getFormattedTotalShipping()." €"; + }) + ->addColumn('created_at', function (UserInvoice $UserInvoice) { + return $UserInvoice->created_at->format("d.m.Y"); + }) + /* + ->addColumn('shipping_order', function (UserInvoice $UserInvoice) { + $ret = ""; + foreach($UserInvoice->shopping_order_items as $shopping_order_item){ + $ret .= $shopping_order_item->product->name."
"; + } + return $ret; + }) + */ + ->addColumn('txaction', function (UserInvoice $UserInvoice) { + if($UserInvoice->shopping_order){ + return Payment::getShoppingOrderBadge($UserInvoice->shopping_order); + } + return "-"; + }) + ->addColumn('status', function (UserInvoice $UserInvoice) { + return ' + '.$UserInvoice->getStatusType().' + '; + }) + ->addColumn('invoice', function (UserInvoice $UserInvoice) { + $ret = ""; + $ret .= ' '; + $ret .= ''; + + return $ret; + }) + + ->orderColumn('id', 'id $1') + ->orderColumn('invoice_number', 'invoice_number $1') + ->orderColumn('txaction', 'txaction $1') + ->orderColumn('shipped', 'shipped $1') + ->orderColumn('total_shipping', 'total_shipping $1') + ->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice']) + ->make(true); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/MembershipController.php b/app/Http/Controllers/MembershipController.php index 436400b..c9d7ab2 100755 --- a/app/Http/Controllers/MembershipController.php +++ b/app/Http/Controllers/MembershipController.php @@ -54,8 +54,8 @@ class MembershipController extends Controller $data = [ 'user' => $user, - 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(), - 'upgrade' => Product::where('active', true)->whereJsonContains('show_on', '5')->where('identifier', 'upgrade')->get(), + 'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(), + 'upgrade' => Product::where('active', true)->whereJsonContains('show_on', '8')->where('identifier', 'upgrade')->get(), 'diff_months' => $diff_months, 'userHistoryPaymentOrder' => $userHistoryPaymentOrder, 'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder, diff --git a/app/Http/Controllers/ModalController.php b/app/Http/Controllers/ModalController.php index ccf72a6..42b2399 100644 --- a/app/Http/Controllers/ModalController.php +++ b/app/Http/Controllers/ModalController.php @@ -48,6 +48,11 @@ class ModalController extends Controller } $ret = view("admin.modal.is_like_member", compact('current', 'possibles', 'data'))->render(); } + if($data['action'] === 'shopping-order-change-points'){ + $value = ShoppingOrder::find($data['id']); + $route = route('admin_sales_customers_detail', [$value->id]); + $ret = view("admin.modal.change_points", compact('value', 'data', 'route'))->render(); + } if($data['action'] === 'user-order-show-product'){ $product = Product::find($data['id']); //current user form order $ret = view("admin.modal.show_product", compact('product', 'data'))->render(); @@ -61,13 +66,24 @@ class ModalController extends Controller if($data['action'] === 'shop-user-order-detail'){ $user = \Auth::user(); $shopping_order = ShoppingOrder::findOrFail($data['id']); - if(!$user->isAdmin() || $shopping_order->member_id !== $user->id){ + if(!$user->isAdmin() && $shopping_order->member_id !== $user->id){ abort(404); } $isAdmin = false ; $ret = view("user.shop.sales.modal_api_order_detail", compact('shopping_order', 'isAdmin', 'data'))->render(); } + if($data['action'] === 'shop-user-order-shipping-detail'){ + $user = \Auth::user(); + $shopping_order = ShoppingOrder::findOrFail($data['id']); + if(!$user->isAdmin() && $shopping_order->auth_user_id !== $user->id){ + abort(404); + } + $isAdmin = false ; + $ret = view("user.shop.sales.modal_api_order_shipping_detail", compact('shopping_order', 'isAdmin', 'data'))->render(); + } + + if($data['action'] === 'user-order-my-delivery-show'){ $user = \Auth::user(); $ret = view("admin.modal.show_user_customers", compact('user', 'data'))->render(); diff --git a/app/Http/Controllers/PaymentPointsController.php b/app/Http/Controllers/PaymentPointsController.php new file mode 100644 index 0000000..fe44883 --- /dev/null +++ b/app/Http/Controllers/PaymentPointsController.php @@ -0,0 +1,130 @@ +middleware('auth'); + } + + public function index() + { + + $this->setFilterVars(); + $data = [ + 'filter_months' => HTMLHelper::$months, + 'filter_years' => HTMLHelper::getYearRange(), + ]; + return view('admin.payment.invoice', $data); + } + + private function setFilterVars(){ + + if(!session('invoice_filter_month')){ + session(['invoice_filter_month' => intval(date('m'))]); + } + if(!session('invoice_filter_year')){ + session(['invoice_filter_year' => intval(date('Y'))]); + } + if(Request::get('invoice_filter_name')){ + session(['invoice_filter_name' => Request::get('invoice_filter_name')]); + } + if(Request::get('invoice_filter_month')){ + session(['invoice_filter_month' => Request::get('invoice_filter_month')]); + } + if(Request::get('invoice_filter_year')){ + session(['invoice_filter_year' => Request::get('invoice_filter_year')]); + } + } + + private function initSearch($archive = false, $request = true) + { + $this->setFilterVars(); + + $query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*') + ->where('user_invoices.month', '=', Request::get('invoice_filter_month')) + ->where('user_invoices.year', '=', Request::get('invoice_filter_year')); + + if(Request::get('invoice_filter_name')){ + $query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%'); + $query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%'); + $query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%'); + } + + //->orderBy('created_at', 'DESC'); + /* $query = FlexHour::leftJoin("flex_hour_items", function($join) { + $join->on("flex_hour_items.flex_hour_id","=","flex_hours.id"); + $join->where("flex_hour_items.date","=", FlexHourItemBot::$date); + })*/ + return $query; + } + + public function datatable(){ + + $query = $this->initSearch(); + return \DataTables::eloquent($query) + ->addColumn('id', function (UserInvoice $UserInvoice) { + if($UserInvoice->shopping_order->auth_user_id){ + return ''; + } + return ''; + + }) + ->addColumn('total_shipping', function (UserInvoice $UserInvoice) { + return ''.$UserInvoice->shopping_order->getFormattedTotalShipping()." €"; + }) + ->addColumn('created_at', function (UserInvoice $UserInvoice) { + return $UserInvoice->created_at->format("d.m.Y"); + }) + /* + ->addColumn('shipping_order', function (UserInvoice $UserInvoice) { + $ret = ""; + foreach($UserInvoice->shopping_order_items as $shopping_order_item){ + $ret .= $shopping_order_item->product->name."
"; + } + return $ret; + }) + */ + ->addColumn('txaction', function (UserInvoice $UserInvoice) { + if($UserInvoice->shopping_order){ + return Payment::getShoppingOrderBadge($UserInvoice->shopping_order); + } + return "-"; + }) + ->addColumn('status', function (UserInvoice $UserInvoice) { + return ' + '.$UserInvoice->getStatusType().' + '; + }) + ->addColumn('invoice', function (UserInvoice $UserInvoice) { + $ret = ""; + $ret .= ' '; + $ret .= ''; + + return $ret; + }) + + ->orderColumn('id', 'id $1') + ->orderColumn('invoice_number', 'invoice_number $1') + ->orderColumn('txaction', 'txaction $1') + ->orderColumn('shipped', 'shipped $1') + ->orderColumn('total_shipping', 'total_shipping $1') + ->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice']) + ->make(true); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/SalesController.php b/app/Http/Controllers/SalesController.php index 12ba4f9..fb398d1 100755 --- a/app/Http/Controllers/SalesController.php +++ b/app/Http/Controllers/SalesController.php @@ -11,6 +11,7 @@ use App\Models\ShoppingPayment; use App\Models\PaymentTransaction; use App\Services\CustomerPriority; use App\Repositories\InvoiceRepository; +use App\Services\BusinessPlan\SalesPointsVolume; class SalesController extends Controller { @@ -33,6 +34,10 @@ class SalesController extends Controller public function usersDetail($id) { $ShoppingOrder = ShoppingOrder::find($id); + if( $ShoppingOrder->payment_for === 6 || $ShoppingOrder->payment_for === 7){ + return redirect(route('admin_sales_customers_detail', [$ShoppingOrder->id])); + abort(403, 'Kundenbestellung'); + } if($ShoppingOrder->shipped === 0){ $ShoppingOrder->shipped = 1; $ShoppingOrder->save(); @@ -77,6 +82,15 @@ class SalesController extends Controller return $ShoppingOrder->getLastShoppingPayment('getPaymentType'); }) ->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) { + if($ShoppingOrder->payment_for === 8){ + return ''; + } return ''.$ShoppingOrder->getShippedType().''; }) ->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) { @@ -118,7 +132,7 @@ class SalesController extends Controller set_user_attr('filter_member_id', null); return redirect(route('admin_sales_customers')); } - $filter_user_shops = ShoppingOrder::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->get()->pluck('slug', 'id')->unique()->toArray(); + $filter_user_shops = ShoppingOrder::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->orderBy('slug')->get()->pluck('slug', 'id')->unique()->toArray(); $filter_members = ShoppingOrder::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get(); //->pluck('email', 'id')->unique()->toArray(); $data = [ 'filter_user_shops' => $filter_user_shops, @@ -130,6 +144,10 @@ class SalesController extends Controller public function customersDetail($id) { $ShoppingOrder = ShoppingOrder::find($id); + if( $ShoppingOrder->payment_for !== 6 && $ShoppingOrder->payment_for !== 7){ + return redirect(route('admin_sales_users_detail', [$ShoppingOrder->id])); + abort(403, 'Beraterbestellung'); + } if($ShoppingOrder->shipped === 0){ $ShoppingOrder->shipped = 1; $ShoppingOrder->save(); @@ -176,6 +194,20 @@ class SalesController extends Controller return redirect($data['back']); } } + if($data['action']==='shopping-order-change-points'){ + if(!isset($data['change_member_key']) || $data['change_member_key'] !== config('mivita.edit_data_pass')){ + \Session()->flash('alert-error', 'Das Passwort ist falsch.'); + return back(); + }else{ + if(!isset($data['change_points'])){ + \Session()->flash('alert-error', 'Keine Änderung ausgewählt'); + return back(); + } + $shopping_order = ShoppingOrder::findOrFail($data['id']); + SalesPointsVolume::changeSalesPointsVolumeUser($shopping_order, $data['change_member_id']); + return redirect(route('admin_sales_customers_detail', [$shopping_order->id])); + } + } $data = [ 'change_member_error' => $change_member_error, 'shopping_order' => ShoppingOrder::find($id), @@ -220,6 +252,12 @@ class SalesController extends Controller return ''.$ShoppingOrder->getFormattedTotalShipping()." €"; }) ->addColumn('payment', function (ShoppingOrder $ShoppingOrder) { + if($ShoppingOrder->txaction === 'extern_paid'){ + $shopping_oder_id = isset($ShoppingOrder->api_notice['shopping_order_id']) ? $ShoppingOrder->api_notice['shopping_order_id'] : null; + if($shopping_oder_id){ + return ' '.$shopping_oder_id.''; + } + } return $ShoppingOrder->getLastShoppingPayment('getPaymentType'); }) ->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) { @@ -229,7 +267,7 @@ class SalesController extends Controller return ''.$ShoppingOrder->getPaymentForType().''; }) ->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) { - if($ShoppingOrder->txaction === 'extern' && $ShoppingOrder->wp_invoice_path){ + if(($ShoppingOrder->txaction === 'extern' || $ShoppingOrder->txaction === 'extern_paid') && $ShoppingOrder->wp_invoice_path){ return ' '; } return $ShoppingOrder->isInvoice() ? ' @@ -264,7 +302,7 @@ class SalesController extends Controller ->orderColumn('shipped', 'shipped $1') ->orderColumn('payment_for', 'payment_for $1') ->orderColumn('total_shipping', 'total_shipping $1') - ->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'payment_for', 'total_shipping', 'invoice', 'shipped']) + ->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'payment_for', 'payment', 'total_shipping', 'invoice', 'shipped']) ->make(true); } diff --git a/app/Http/Controllers/SyS/SysController.php b/app/Http/Controllers/SyS/SysController.php index 0c22a9a..738642c 100644 --- a/app/Http/Controllers/SyS/SysController.php +++ b/app/Http/Controllers/SyS/SysController.php @@ -10,6 +10,7 @@ use App\Services\SyS\Cronjobs; use App\Services\SyS\Customers; use App\Services\SyS\DomainSSL; use App\Http\Controllers\Controller; +use App\Models\UserSalesVolume; use App\Services\SyS\Correction; use App\Services\SyS\ShoppingOrders; @@ -25,6 +26,21 @@ class SysController extends Controller public function index() { + $UserSalesVolumes =UserSalesVolume::all(); + + foreach($UserSalesVolumes as $UserSalesVolume){ + if($UserSalesVolume->shopping_order->member_id !== NULL && $UserSalesVolume->user_id !== $UserSalesVolume->shopping_order->member_id){ + if($UserSalesVolume->shopping_order->member_id !== 6){ + dump($UserSalesVolume->shopping_order_id); + dump($UserSalesVolume->shopping_order->member_id); + dump($UserSalesVolume->user_id); + + dump("##"); + } + + } + } + dd("ebd"); return view('sys.index'); } diff --git a/app/Http/Controllers/User/HomepartyController.php b/app/Http/Controllers/User/HomepartyController.php index b4de683..f7c5064 100755 --- a/app/Http/Controllers/User/HomepartyController.php +++ b/app/Http/Controllers/User/HomepartyController.php @@ -564,7 +564,7 @@ class HomepartyController extends Controller public function datatable($homeparty_id){ - $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '3'); + $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '4'); $homeparty = Homeparty::findOrFail($homeparty_id); return \DataTables::eloquent($query) diff --git a/app/Http/Controllers/User/OrderController.php b/app/Http/Controllers/User/OrderController.php index a8efc3a..328575c 100755 --- a/app/Http/Controllers/User/OrderController.php +++ b/app/Http/Controllers/User/OrderController.php @@ -43,6 +43,10 @@ class OrderController extends Controller if($shopping_order->auth_user_id !== $user->id){ abort(404); } + if( $shopping_order->payment_for === 6 || $shopping_order->payment_for === 7){ + return redirect(route('user_shop_order_detail', [$shopping_order->id])); + abort(403, 'Kundenbestellung'); + } $shopping_order->getLastShoppingPayment(); $data = [ @@ -59,7 +63,7 @@ class OrderController extends Controller return \DataTables::eloquent($query) ->addColumn('id', function (ShoppingOrder $ShoppingOrder) { - return ''; + return ''; }) ->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) { return $ShoppingOrder->created_at->format("d.m.Y"); @@ -74,6 +78,15 @@ class OrderController extends Controller return $ShoppingOrder->getLastShoppingPayment('getPaymentType'); }) ->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) { + if($ShoppingOrder->payment_for === 8){ + return ''; + } return ''.$ShoppingOrder->getShippedType().''; }) ->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) { @@ -277,7 +290,7 @@ class OrderController extends Controller if(Request::get('shipping_is_for') === 'me'){ $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '2'); }else{ - $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '1'); + $query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '3'); } return \DataTables::eloquent($query) @@ -465,7 +478,7 @@ class OrderController extends Controller private function getCompProducts($for){ if($for === 'me'){ - return Product::whereActive(true)->whereJsonContains('show_on', ['1', '2', '3'])->where('shipping_addon', true)->orderBy('pos', 'DESC')->get(); + return Product::whereActive(true)->whereJsonContains('show_on', ['1', '2', '3', '4'])->where('shipping_addon', true)->orderBy('pos', 'DESC')->get(); } return null; } diff --git a/app/Http/Controllers/User/ShopApiController.php b/app/Http/Controllers/User/ShopApiController.php index cc010d1..bd1fde3 100644 --- a/app/Http/Controllers/User/ShopApiController.php +++ b/app/Http/Controllers/User/ShopApiController.php @@ -15,8 +15,8 @@ use App\Repositories\ShopApiRepository; class ShopApiController extends Controller { - private $api_action = [0 => 'bitte wählen', 'order' => 'markierte bestellen', 'remove' => 'markierte entfernen', 'reset' => 'markierte zurücksetzen/offen']; - private $filter_show = [10 => 'alle anzeigen', 1 => 'offen', 2 => 'bestellt', 5 => 'entfernt']; + private $api_action = [0 => 'bitte wählen', 'order' => 'markierte bezahlen', 'remove' => 'markierte entfernen', 'reset' => 'markierte zurücksetzen/bestellt']; + private $filter_show = [10 => 'alle anzeigen', 1 => 'bestellt', 2 => 'bezahlt', 5 => 'entfernt']; protected $shopApiRepository; public function __construct(ShopApiRepository $shopApiRepository) @@ -28,7 +28,6 @@ class ShopApiController extends Controller public function orders() { $this->setFilterVars(); - $data = [ 'api_action' => $this->api_action, 'filter_show' => $this->filter_show, diff --git a/app/Http/Controllers/User/ShopSalesController.php b/app/Http/Controllers/User/ShopSalesController.php index 2914278..af7c242 100755 --- a/app/Http/Controllers/User/ShopSalesController.php +++ b/app/Http/Controllers/User/ShopSalesController.php @@ -30,6 +30,10 @@ class ShopSalesController extends Controller if($shopping_order->member_id !== $user->id){ abort(404); } + if( $shopping_order->payment_for !== 6 && $shopping_order->payment_for !== 7){ + return redirect(route('user_order_detail', [$shopping_order->id])); + abort(403, 'Beraterbestellung'); + } $data = [ 'shopping_order' => $shopping_order, 'isAdmin' => false, diff --git a/app/Http/Controllers/WizardController.php b/app/Http/Controllers/WizardController.php index 1ed9b19..d958db2 100755 --- a/app/Http/Controllers/WizardController.php +++ b/app/Http/Controllers/WizardController.php @@ -62,8 +62,8 @@ class WizardController extends Controller $data = [ 'user' => Auth::user(), 'step' => $step, - 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(), - 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(), + 'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(), + 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(), 'userHistoryWizardPayment' => $userHistoryWizardPayment, ]; @@ -97,8 +97,8 @@ class WizardController extends Controller $data = [ 'user' => Auth::user(), 'step' => $step, - 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(), - 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(), + 'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(), + 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(), ]; if($step == 5){ if($user->active){ @@ -139,8 +139,8 @@ class WizardController extends Controller $data = [ 'user' => Auth::user(), 'step' => 0, - 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(), - 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(), + 'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(), + 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(), 'userHistoryWizardPayment' => $userHistoryWizardPayment, 'yard_info' => UserService::getYardInfo(), ]; @@ -192,8 +192,8 @@ class WizardController extends Controller $data = [ 'user' => Auth::user(), 'step' => $step, - 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(), - 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(), + 'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(), + 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(), ]; $user->wizard = 0; $user->save(); @@ -369,8 +369,8 @@ class WizardController extends Controller $data = [ 'user' => Auth::user(), 'step' => $step, - 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(), - 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(), + 'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(), + 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(), ]; $user->wizard = 10; $user->save(); @@ -408,8 +408,8 @@ class WizardController extends Controller $data = [ 'user' => Auth::user(), 'step' => $step, - 'products' => Product::where('active', true)->whereJsonContains('show_on', ['4', '5'])->whereJsonContains('show_on', ['4', '5'])->orderBy('pos', 'ASC')->get(), - 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '6')->orderBy('pos', 'ASC')->get(), + 'products' => Product::where('active', true)->whereJsonContains('show_on', ['7', '8'])->orderBy('pos', 'ASC')->get(), + 'products_on_board' => Product::where('active', true)->whereJsonContains('show_on', '9')->orderBy('pos', 'ASC')->get(), ]; return view('user.wizard.create', $data)->withErrors($validator); } diff --git a/app/Models/Product.php b/app/Models/Product.php index b28a9b2..3080ca4 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -115,6 +115,8 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|Product whereNoCommission($value) * @method static \Illuminate\Database\Eloquent\Builder|Product whereShowOn($value) * @method static \Illuminate\Database\Eloquent\Builder|Product withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug) + * @property string|null $ean + * @method static \Illuminate\Database\Eloquent\Builder|Product whereEan($value) */ class Product extends Model { @@ -208,12 +210,13 @@ class Product extends Model ]; public $showONs = [ - 1 => 'KundenShop', - 2 => 'BeraterShop', - 3 => 'Auszeitparty', - 4 => 'Registrierung Berater', - 5 => 'Mitgliedschaft Berater', - 6 => 'Onboarding Berater', + 1 => 'ShopKunde', + 2 => 'ShopBerater', + 3 => 'ShopBeraterKunden', + 4 => 'Auszeitparty', + 7 => 'Registrierung Berater', + 8 => 'Mitgliedschaft Berater', + 9 => 'Onboarding Berater', 10 => 'zur internen Berechnung', ]; diff --git a/app/Models/ShoppingOrder.php b/app/Models/ShoppingOrder.php index 31d220b..edbd895 100644 --- a/app/Models/ShoppingOrder.php +++ b/app/Models/ShoppingOrder.php @@ -152,9 +152,9 @@ class ShoppingOrder extends Model ]; public static $apiStatusTypes = [ - 0 => 'offen', - 1 => 'offen / pre', - 2 => 'bestellt', + 0 => 'bestellt', + 1 => 'im Prozess', + 2 => 'bezahlt', 5 => 'entfernt', ]; public static $apiStatusColors = [ @@ -180,7 +180,7 @@ class ShoppingOrder extends Model 5 => 'Homeparty', 6 => 'Shop', 7 => 'extern', - 8 => 'Sammelbestellung', + 8 => 'Sammelrechnung', 10 => '', ]; @@ -259,11 +259,11 @@ class ShoppingOrder extends Model } public function user_sales_volume(){ - return $this->hasMany('App\Models\UserSalesVolume', 'shopping_order_id'); + return $this->hasOne('App\Models\UserSalesVolume', 'shopping_order_id'); } public function user_sales_volume_no_userid(){ - return $this->hasMany('App\Models\UserSalesVolume', 'shopping_order_id')->where('user_id', '=', NULL)->first(); + return $this->hasOne('App\Models\UserSalesVolume', 'shopping_order_id')->where('user_id', '=', NULL)->first(); } @@ -318,13 +318,12 @@ class ShoppingOrder extends Model } public function getAPIStatusType(){ - return isset(self::$apiStatusTypes[$this->api_status]) ? self::$apiStatusTypes[$this->api_status] : "offen"; + return isset(self::$apiStatusTypes[$this->api_status]) ? self::$apiStatusTypes[$this->api_status] : "bestellt"; } public function getAPIStatusColor(){ return isset(self::$apiStatusColors[$this->api_status]) ? self::$apiStatusColors[$this->api_status] : "warning"; } - public function getFormattedTotal() { diff --git a/app/Models/UserSalesVolume.php b/app/Models/UserSalesVolume.php index 8b91039..d813631 100644 --- a/app/Models/UserSalesVolume.php +++ b/app/Models/UserSalesVolume.php @@ -73,7 +73,8 @@ class UserSalesVolume extends Model 'total_net' => 'float', 'month_total_net' => 'float', 'month_shop_total_net' => 'float', - 'status' => 'int' + 'status' => 'int', + 'syslog' => 'array' ]; protected $dates = [ @@ -94,15 +95,16 @@ class UserSalesVolume extends Model 'month_total_net', 'month_shop_total_net', 'message', - 'status' + 'status', + 'syslog' ]; public static $statusTypes = [ 0 => 'nicht zugewiesen', - 1 => 'hinzugefügt aus Bestellung', - 2 => 'hinzugefügt aus Shop', - 3 => 'hinzugefügt aus Shop / pending', + 1 => 'hinzugefügt aus Beraterbestellung', + 2 => 'hinzugefügt aus Shopbestellung', + 3 => 'hinzugefügt aus Shopbestellung / pending', 10 => '' ]; @@ -135,42 +137,14 @@ class UserSalesVolume extends Model return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : ""; } - public static function getStatusByOrder($ShoppingOrder){ - if($ShoppingOrder->payment_for){ - if($ShoppingOrder->payment_for === 6){ //Kunde-Shop - if($ShoppingOrder->shopping_user && $ShoppingOrder->shopping_user->is_like){ - return 3; //shop Kunden, berater zuordnen - } - return 2; - } - return 1; - } - return 0; - } - public function getFormatedMonthYear(){ return str_pad($this->month, 2, "0", STR_PAD_LEFT)."/".$this->year; } - public function setToUserAndCalculate($user_id){ - - $month = $this->month; - $year = $this->year; - $month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points'); - $month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net'); - $month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points'); - $month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net'); - - $month_shop_points += $this->points; - $month_shop_total_net += $this->total_net; - - $this->user_id = $user_id; - $this->month_shop_points = $month_shop_points; - $this->month_shop_total_net = $month_shop_total_net; - $this->month_points = $month_points; - $this->month_total_net = $month_total_net; - $this->status = 2; - $this->save(); - + public function isCurrentMonthYear(){ + if($this->month === intval(date('m')) && $this->year === intval(date('Y'))){ + return true; + } + return false; } -} +} \ No newline at end of file diff --git a/app/Repositories/InvoiceRepository.php b/app/Repositories/InvoiceRepository.php index 8c5d5b9..7146649 100644 --- a/app/Repositories/InvoiceRepository.php +++ b/app/Repositories/InvoiceRepository.php @@ -11,6 +11,7 @@ use App\Models\ShoppingOrder; use App\Services\MyPDFMerger; use App\Services\UserService; use App\Models\UserSalesVolume; +use App\Services\BusinessPlan\SalesPointsVolume; class InvoiceRepository extends BaseRepository { @@ -146,63 +147,12 @@ class InvoiceRepository extends BaseRepository { public function userSalesVolume() { - /* - status - 1 => 'hinzugefügt aus Bestellung', - 2 => 'hinzugefügt aus Shop', - 3 => 'hinzugefügt aus Shop / pending', - - */ - $status = UserSalesVolume::getStatusByOrder($this->model); - $user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id; - //akuteller tag / Monat. - $month = date('m'); - $year = date('Y'); - $date = date('d.m.Y'); - - if($status === 3){ //shop bestellung User pending - $user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id; - $month_points = 0; - $month_total_net = 0; - $month_shop_points = 0; - $month_shop_total_net = 0; - }else{ - $month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points'); - $month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net'); - $month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points'); - $month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net'); - } - switch ($status) { - case 1: //Bestellung - $month_points += $this->model->points; - $month_total_net += $this->model->subtotal; - break; - case 2: //Shop - $month_shop_points += $this->model->points; - $month_shop_total_net += $this->model->subtotal; - break; - } - - return UserSalesVolume::create([ - 'user_id' => $user_id, - 'shopping_order_id' => $this->model->id, - 'month' => $month, - 'year' => $year, - 'date' => $date, - 'points' => $this->model->points, - 'month_points' => $month_points, - 'month_shop_points' => $month_shop_points, - 'total_net' => $this->model->subtotal, - 'month_total_net' => $month_total_net, - 'month_shop_total_net' => $month_shop_total_net, - 'message' => '', - 'status' => $status, - ]); + } public function createAndSalesVolume($request = []) { - $this->user_sales_volume = $this->userSalesVolume(); + $this->user_sales_volume = SalesPointsVolume::addSalesPointsVolumeUser($this->model); $user_invoice = $this->create($request); $this->user_sales_volume->user_invoice_id = $user_invoice->id; $this->user_sales_volume->save(); diff --git a/app/Services/BusinessPlan/SalesPointsVolume.php b/app/Services/BusinessPlan/SalesPointsVolume.php new file mode 100644 index 0000000..3f14235 --- /dev/null +++ b/app/Services/BusinessPlan/SalesPointsVolume.php @@ -0,0 +1,166 @@ +user_sales_volume){ + $to_user_id = intval($to_user_id); + if($shoppingOrder->user_sales_volume->user_id === $to_user_id){ + \Session()->flash('alert-error', 'Keine Änderung: selber Berater'); + return; + } + if(!$shoppingOrder->user_sales_volume->isCurrentMonthYear()){ + \Session()->flash('alert-error', 'Änderung muss im selben Monat sein'); + return; + } + + $month = $shoppingOrder->user_sales_volume->month; + $year = $shoppingOrder->user_sales_volume->year; + $form_user_id = $shoppingOrder->user_sales_volume->user_id; + + $to_user = User::find($to_user_id); + $form_user = User::find($form_user_id); + + $shoppingOrder->user_sales_volume->user_id = $to_user_id; + $shoppingOrder->user_sales_volume->message = 'Punkte zugewiesen am: '.date('d.m.Y'); + + $syslog = $shoppingOrder->user_sales_volume->syslog; + $syslog[date('d.m.Y-h:i:s')] = 'change form: #'.$form_user_id.' '.$form_user->email.' to: #'.$to_user_id.' '.$to_user->email; + $shoppingOrder->user_sales_volume->syslog = $syslog; + + $shoppingOrder->user_sales_volume->save(); + + //recalculate + self::reCalculateSalesPointsVolume($to_user_id, $month, $year); + self::reCalculateSalesPointsVolume($form_user_id, $month, $year); + \Session()->flash('alert-save', true); + + } + + } + + public static function reCalculateSalesPointsVolume($user_id, $month, $year){ + + $userSalesVolumes = UserSalesVolume::where('user_id', $user_id)->where('month', $month)->where('year', $year)->orderBy('id', 'ASC')->get(); + $month_points = 0; + $month_total_net = 0; + $month_shop_points = 0; + $month_shop_total_net = 0; + //TDOO Status === 3??? + + foreach($userSalesVolumes as $userSalesVolume){ + switch ($userSalesVolume->status) { + case 1: //Bestellung + $month_points += $userSalesVolume->points; + $month_total_net += $userSalesVolume->total_net; + break; + case 2: //Shop + $month_shop_points += $userSalesVolume->points; + $month_shop_total_net += $userSalesVolume->total_net; + break; + } + $userSalesVolume->month_shop_points = $month_shop_points; + $userSalesVolume->month_shop_total_net = $month_shop_total_net; + $userSalesVolume->month_points = $month_points; + $userSalesVolume->month_total_net = $month_total_net; + $userSalesVolume->save(); + } + } + + + public static function addSalesPointsVolumeUser(ShoppingOrder $shoppingOrder){ + + /* + status + 1 => 'hinzugefügt aus Bestellung', + 2 => 'hinzugefügt aus Shop', + 3 => 'hinzugefügt aus Shop / pending', + */ + $status = self::getStatusByOrderPaymentFor($shoppingOrder); + $user_id = $shoppingOrder->auth_user_id ? $shoppingOrder->auth_user_id : $shoppingOrder->member_id; + //akuteller tag / Monat. + $month = date('m'); + $year = date('Y'); + $date = date('d.m.Y'); + + if($status === 3){ //shop bestellung User pending if is_like + $user_id = NULL;//$shoppingOrder->auth_user_id ? $shoppingOrder->auth_user_id : $shoppingOrder->member_id; + $month_points = 0; + $month_total_net = 0; + $month_shop_points = 0; + $month_shop_total_net = 0; + }else{ + $month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points'); + $month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net'); + $month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points'); + $month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net'); + } + switch ($status) { + case 1: //Bestellung + $month_points += $shoppingOrder->points; + $month_total_net += $shoppingOrder->subtotal; + break; + case 2: //Shop + $month_shop_points += $shoppingOrder->points; + $month_shop_total_net += $shoppingOrder->subtotal; + break; + } + + return UserSalesVolume::create([ + 'user_id' => $user_id, + 'shopping_order_id' => $shoppingOrder->id, + 'month' => $month, + 'year' => $year, + 'date' => $date, + 'points' => $shoppingOrder->points, + 'month_points' => $month_points, + 'month_shop_points' => $month_shop_points, + 'total_net' => $shoppingOrder->subtotal, + 'month_total_net' => $month_total_net, + 'month_shop_total_net' => $month_shop_total_net, + 'message' => '', + 'status' => $status, + ]); + + } + + public static function setToUserAndReCalculate(UserSalesVolume $user_sales_volume, $user_id){ + + //set month year date new, calculate it in the currently month! + //If the month has changed, it can no longer be added to the month before + $month = date('m'); + $year = date('Y'); + $date = date('d.m.Y'); + + $user_sales_volume->user_id = $user_id; + $user_sales_volume->month = $month; + $user_sales_volume->year = $year; + $user_sales_volume->date = $date; + $user_sales_volume->status = 2; //hinzugefügt aus Shop can only Pending + $user_sales_volume->save(); + + self::reCalculateSalesPointsVolume($user_id, $month, $year); + } + + public static function getStatusByOrderPaymentFor(ShoppingOrder $shoppingOrder){ + if($shoppingOrder->payment_for){ + if($shoppingOrder->payment_for === 6){ //Kunde-Shop + if($shoppingOrder->shopping_user && $shoppingOrder->shopping_user->is_like){ + return 3; //shop Kunden, berater zuordnen <- need? + } + return 2; + } + return 1; + } + return 0; + } + + +} diff --git a/app/Services/CustomerPriority.php b/app/Services/CustomerPriority.php index ed8c2bf..34ac614 100644 --- a/app/Services/CustomerPriority.php +++ b/app/Services/CustomerPriority.php @@ -5,6 +5,7 @@ namespace App\Services; use App\Mail\MailCheckout; use App\Mail\MailInfo; use App\Models\ShoppingUser; +use App\Services\BusinessPlan\SalesPointsVolume; use App\Services\Shop; use App\User; use Auth; @@ -79,7 +80,7 @@ class CustomerPriority } //set Points and Volume if ($shopping_user->shopping_order && $user_sales_volume = $shopping_user->shopping_order->user_sales_volume_no_userid()) { - $user_sales_volume->setToUserAndCalculate($shopping_user->member_id); + SalesPointsVolume::setToUserAndReCalculate($user_sales_volume, $shopping_user->member_id); } return true; diff --git a/app/Services/HTMLHelper.php b/app/Services/HTMLHelper.php index b07b87c..fb9f680 100644 --- a/app/Services/HTMLHelper.php +++ b/app/Services/HTMLHelper.php @@ -325,7 +325,7 @@ class HTMLHelper if($value->account){ $to = $value->account->first_name." ".$value->account->last_name." | "; } - $ret .= '\n'; + $ret .= '\n'; } return $ret; diff --git a/app/Services/Payment.php b/app/Services/Payment.php index 706c75b..2bada29 100644 --- a/app/Services/Payment.php +++ b/app/Services/Payment.php @@ -17,7 +17,8 @@ class Payment 'paid' => "bezahlt", 'appointed' => "offen", 'failed' => "abbruch", - 'extern' => "extern", + 'extern' => "offen", //offen + 'extern_paid' => "bezahlt", 'invoice_open' => "offen", 'invoice_paid' => "bezahlt", 'invoice_non' => "keine Zahlung", @@ -34,7 +35,8 @@ class Payment 'paid' => "success", 'appointed' => "warning", 'failed' => "danger", - 'extern' => "success", + 'extern' => "warning", + 'extern_paid' => "success", 'invoice_open' => "warning", 'invoice_paid' => "success", 'invoice_non' => "failed", diff --git a/app/Services/Shop.php b/app/Services/Shop.php index 4d9c3bf..e454e75 100644 --- a/app/Services/Shop.php +++ b/app/Services/Shop.php @@ -36,7 +36,10 @@ class Shop $shopping_users = ShoppingUser::where('number', '=', $number)->get(); $orders = 1; foreach ($shopping_users as $shopping_user) { - if($shopping_user->shopping_order && ($shopping_user->shopping_order->txaction === 'paid' || $shopping_user->shopping_order->txaction === 'appointed' || $shopping_user->shopping_order->txaction === 'extern')){ + if($shopping_user->shopping_order && ($shopping_user->shopping_order->txaction === 'paid' || + $shopping_user->shopping_order->txaction === 'appointed' || + $shopping_user->shopping_order->txaction === 'extern' || + $shopping_user->shopping_order->txaction === 'extern_paid' )){ $shopping_user->orders = $orders++; }else{ diff --git a/app/Services/ShopApiOrderCart.php b/app/Services/ShopApiOrderCart.php index e93783b..ecc3726 100644 --- a/app/Services/ShopApiOrderCart.php +++ b/app/Services/ShopApiOrderCart.php @@ -117,7 +117,7 @@ class ShopApiOrderCart //price brutto calu with private function calcuPriceWith($price, $tax_rate = null, $discount = null){ $tax_dec = ($tax_rate + 100) / 100; - $price / $tax_dec; + $price = $price / $tax_dec; $margin = (($discount -100)*-1) / 100; $price = $price * $margin; return round($price, 2); @@ -199,6 +199,7 @@ class ShopApiOrderCart $api_notice = $ShoppingOrder->api_notice; $api_notice['shopping_order_id'] = $shoppingCollectOrder->shopping_order_id; $ShoppingOrder->api_notice = $api_notice; + $ShoppingOrder->txaction = 'extern_paid'; $ShoppingOrder->save(); } $shoppingCollectOrder->status = 2; //order diff --git a/app/Services/SyS/Correction.php b/app/Services/SyS/Correction.php index 88f899c..8e8699d 100644 --- a/app/Services/SyS/Correction.php +++ b/app/Services/SyS/Correction.php @@ -11,6 +11,7 @@ use App\Models\ShoppingOrder; use App\Models\UserSalesVolume; use App\Models\ShoppingOrderItem; use App\Repositories\ImportRepository; +use App\Services\BusinessPlan\SalesPointsVolume; class Correction { @@ -23,7 +24,7 @@ class Correction 3 => 'hinzugefügt aus Shop / pending', */ - $status = UserSalesVolume::getStatusByOrder($order); + $status = SalesPointsVolume::getStatusByOrderPaymentFor($order); $user_id = $order->auth_user_id ? $order->auth_user_id : $order->member_id; //akuteller tag / Monat. $month = $order->created_at->format('m'); diff --git a/database/migrations/2022_03_08_102231_create_user_sales_volumes_table.php b/database/migrations/2022_03_08_102231_create_user_sales_volumes_table.php index 0b35fad..44152f4 100644 --- a/database/migrations/2022_03_08_102231_create_user_sales_volumes_table.php +++ b/database/migrations/2022_03_08_102231_create_user_sales_volumes_table.php @@ -34,6 +34,8 @@ class CreateUserSalesVolumesTable extends Migration $table->string('message', 255)->nullable(); $table->unsignedTinyInteger('status')->index()->default(0); + $table->text('syslog')->nullable(); + $table->timestamps(); $table->foreign('user_id') diff --git a/public/js/iq-homeparty-cart.js b/public/js/iq-homeparty-cart.js index d6a5967..ad3f6c0 100755 --- a/public/js/iq-homeparty-cart.js +++ b/public/js/iq-homeparty-cart.js @@ -193,8 +193,8 @@ var IqHomepartyCart = { if(number < 1 || isNaN(number)){ return 1; } - if(number >= 100){ - return 100; + if(number >= 999){ + return 999; } return number; } diff --git a/public/js/iq-shopping-cart.js b/public/js/iq-shopping-cart.js index 53d3268..0be2072 100755 --- a/public/js/iq-shopping-cart.js +++ b/public/js/iq-shopping-cart.js @@ -146,8 +146,8 @@ var IqShoppingCart = { if(number < 0 || isNaN(number)){ return 0; } - if(number >= 100){ - return 100; + if(number >= 999){ + return 999; } return number; }, diff --git a/resources/lang/de/navigation.php b/resources/lang/de/navigation.php index 1ffb268..2b2785b 100755 --- a/resources/lang/de/navigation.php +++ b/resources/lang/de/navigation.php @@ -40,6 +40,7 @@ return [ 'payments' => 'Finanzen', 'invoice' => 'Rechnungen', 'credit' => 'Gutschriften', + 'points' => 'Points', 'system_settings' => 'System-E.', 'business' => 'Business', 'structure' => 'Struktur', diff --git a/resources/views/admin/modal/change_points.blade.php b/resources/views/admin/modal/change_points.blade.php new file mode 100644 index 0000000..9d83b40 --- /dev/null +++ b/resources/views/admin/modal/change_points.blade.php @@ -0,0 +1,83 @@ +{!! Form::open(['url' => $route, 'class' => 'modal-content', 'enctype' => 'multipart/form-data']) !!} + + + +{!! Form::close() !!} + + diff --git a/resources/views/admin/sales/_detail.blade.php b/resources/views/admin/sales/_detail.blade.php index b5bc62d..02c2bff 100644 --- a/resources/views/admin/sales/_detail.blade.php +++ b/resources/views/admin/sales/_detail.blade.php @@ -11,18 +11,20 @@
Versand: - @if ($isAdmin) - - @else - - {{ $shopping_order->getShippedType() }} - + @if($shopping_order->payment_for !== 8) + @if ($isAdmin) + + @else + + {{ $shopping_order->getShippedType() }} + + @endif @endif
@@ -59,7 +61,7 @@ target="_blank" class="btn btn-warning btn-sm"> @endif @endif - @if ($shopping_order->txaction === 'extern' && $shopping_order->wp_invoice_path) + @if (($shopping_order->txaction === 'extern' || $shopping_order->txaction === 'extern_paid') && $shopping_order->wp_invoice_path) @endif @@ -99,12 +101,30 @@
Points gesamt
- {{ $shopping_order->points }} + {{ $shopping_order->points }} +
+ + +
+ +
+
+
+
Punkte / Umsatz zugewiesen
+ @if($shopping_order->user_sales_volume && $shopping_order->user_sales_volume->user) + {{ $shopping_order->user_sales_volume->user->getFullName() }} + @endif + @if ($isAdmin) + + @endif +

- @if ($isAdmin) @@ -343,7 +363,7 @@
@endif @if ($shopping_order->shopping_user->is_from === 'collection') -
Berater Sammelbestellung
+
Berater Sammelrechnung

@endif diff --git a/resources/views/admin/sales/_detail_collection.blade.php b/resources/views/admin/sales/_detail_collection.blade.php index 450c2ab..566633a 100644 --- a/resources/views/admin/sales/_detail_collection.blade.php +++ b/resources/views/admin/sales/_detail_collection.blade.php @@ -121,7 +121,7 @@ -
Sammelbestellung behinhaltet folgende Kundenbestellungen
+
Sammelrechnung behinhaltet folgende Kundenbestellungen
diff --git a/resources/views/emails/checkout.blade.php b/resources/views/emails/checkout.blade.php index 97b6341..30f4d64 100644 --- a/resources/views/emails/checkout.blade.php +++ b/resources/views/emails/checkout.blade.php @@ -172,13 +172,16 @@ @if($shopping_order->shopping_user->is_from === 'extern') {{__('email.checkout_mail_order_for_extern')}} @endif + @if($shopping_order->shopping_user->is_from === 'collection') + Berater Sammelrechnung
+ @endif - + diff --git a/resources/views/user/shop/sales/modal_api_order_shipping_detail.blade.php b/resources/views/user/shop/sales/modal_api_order_shipping_detail.blade.php new file mode 100644 index 0000000..9886d83 --- /dev/null +++ b/resources/views/user/shop/sales/modal_api_order_shipping_detail.blade.php @@ -0,0 +1,63 @@ +
@if($shopping_order->shopping_user->is_from === 'homeparty') @include('emails.homeparty_detail') - @elseif($shopping_order->shopping_collect_order) + @elseif($shopping_order->shopping_user->is_from === 'collection' && $shopping_order->shopping_collect_order) @include('emails.collection_detail') @else @include('emails.shopping_order_detail') diff --git a/resources/views/emails/checkout_status.blade.php b/resources/views/emails/checkout_status.blade.php index 3556564..e520bd9 100644 --- a/resources/views/emails/checkout_status.blade.php +++ b/resources/views/emails/checkout_status.blade.php @@ -215,14 +215,20 @@ {{ __('navigation.my_homeparty') }} / {{ $shopping_order->homeparty->name }} - {{ $shopping_order->homeparty->date }}
{{__('email.checkout_mail_hl1')}} @endif + @if($shopping_order->shopping_user->is_from === 'extern') + {{__('email.checkout_mail_order_for_extern')}} + @endif + @if($shopping_order->shopping_user->is_from === 'collection') + Berater Sammelrechnung
+ @endif
@if($shopping_order->shopping_user->is_from === 'homeparty') @include('emails.homeparty_detail') - @elseif($shopping_order->shopping_collect_order) - @include('emails.collection_detail') + @elseif($shopping_order->shopping_user->is_from === 'collection' && $shopping_order->shopping_collect_order) + @include('emails.collection_detail') @else @include('emails.shopping_order_detail') @endif diff --git a/resources/views/layouts/includes/layout-sidenav.blade.php b/resources/views/layouts/includes/layout-sidenav.blade.php index bda3f29..7c10265 100755 --- a/resources/views/layouts/includes/layout-sidenav.blade.php +++ b/resources/views/layouts/includes/layout-sidenav.blade.php @@ -144,6 +144,7 @@
{{ __('navigation.payments') }}
diff --git a/resources/views/pdf/invoice-journal-collection.blade.php b/resources/views/pdf/invoice-journal-collection.blade.php index 8b686d0..8fae7d1 100644 --- a/resources/views/pdf/invoice-journal-collection.blade.php +++ b/resources/views/pdf/invoice-journal-collection.blade.php @@ -59,7 +59,7 @@
-

Sammelbestellung behinhaltet folgende Kundenbestellungen

+

Sammelrechnung behinhaltet folgende Kundenbestellungen

@if($shopping_order->shopping_collect_order) @foreach($shopping_order->shopping_collect_order->orders as $order) @php($order = $shopping_order->shopping_collect_order->initShoppingOrder($order)) diff --git a/resources/views/user/order/detail.blade.php b/resources/views/user/order/detail.blade.php index 54c29ee..003f752 100644 --- a/resources/views/user/order/detail.blade.php +++ b/resources/views/user/order/detail.blade.php @@ -3,7 +3,7 @@ @section('content')

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

@include('admin.sales._detail') zurück diff --git a/resources/views/user/shop/sales/api_order_list.blade.php b/resources/views/user/shop/sales/api_order_list.blade.php index deed175..e5546de 100644 --- a/resources/views/user/shop/sales/api_order_list.blade.php +++ b/resources/views/user/shop/sales/api_order_list.blade.php @@ -15,7 +15,7 @@

-
{{ __('Externe Bestellungen') }} | bestellen
+
{{ __('Externe Bestellungen') }} | Sammelrechnung
zurück

diff --git a/resources/views/user/shop/sales/api_orders.blade.php b/resources/views/user/shop/sales/api_orders.blade.php index 66f92e4..acc774c 100644 --- a/resources/views/user/shop/sales/api_orders.blade.php +++ b/resources/views/user/shop/sales/api_orders.blade.php @@ -30,9 +30,9 @@

- bestellen = Sammelbestellung aufgeben
+ bezahlen = Sammelrechnung erstellen und zum Checkout
entfernen = Bestellungen werden nach entfernt verschoben, für Stornos etc.
- zurücksetzen = Bestellungen werden nur nach offen verschoben, Sammelbestellung werden nicht geändert + zurücksetzen = Bestellungen werden nur nach offen verschoben, Sammelrechnung werden nicht geändert

@@ -43,7 +43,7 @@
#{{__('Status') }}{{__('Zahlung') }} {{__('Versand') }} {{__('First name')}} {{__('Last name')}}
+ + + + + + + + + + + + + + @foreach($shopping_order->shopping_collect_order->orders as $order) + @php($order = $shopping_order->shopping_collect_order->initShoppingOrder($order)) + + + + + + + + + + + @endforeach + +
#{{__('Nummer') }}{{__('Versand') }}{{__('First name')}}{{__('Last name')}}{{__('E-Mail')}}{{__('Datum')}}{{__('Betrag')}}
+ {{ $order['order_id'] }} + {{ $order['shopping_order']->getShippedType() }} + {{ $order['shopping_order']->shopping_user->billing_firstname }}{{ $order['shopping_order']->shopping_user->billing_lastname }}{{ $order['shopping_order']->shopping_user->billing_email }}{{ $order['shopping_order']->created_at->format("d.m.Y") }}{{ $order['shopping_order']->getFormattedTotalShipping() }} €
+
+ + + + + + + \ No newline at end of file diff --git a/resources/views/user/shop/sales/orders.blade.php b/resources/views/user/shop/sales/orders.blade.php index cebc8fa..4a7e511 100644 --- a/resources/views/user/shop/sales/orders.blade.php +++ b/resources/views/user/shop/sales/orders.blade.php @@ -15,13 +15,14 @@ # + {{__('Datum')}} + {{__('Betrag')}} + {{__('Status')}} + {{__('Versand')}} + {{__('First name')}} {{__('Last name')}} {{__('E-Mail')}} - {{__('Datum')}} - {{__('Status')}} - {{__('Betrag')}} - {{__('Versand')}} {{__('Rechnung')}} {{__('Art')}} @@ -39,13 +40,13 @@ "order": [[0, "desc" ]], "columns": [ { data: 'id', searchable: false }, + { data: 'created_at', name: 'created_at' }, + { data: 'total_shipping', name: 'total_shipping' }, + { data: 'txaction', name: 'txaction' }, + { data: 'shipped', name: 'shipped' }, { data: 'shopping_user.billing_firstname', name: 'shopping_user.billing_firstname' }, { data: 'shopping_user.billing_lastname', name: 'shopping_user.billing_lastname' }, { data: 'shopping_user.billing_email', name: 'shopping_user.billing_email' }, - { data: 'created_at', name: 'created_at' }, - { data: 'txaction', name: 'txaction' }, - { data: 'total_shipping', name: 'total_shipping' }, - { data: 'shipped', name: 'shipped' }, { data: 'invoice', name: 'invoice', orderable: false }, { data: 'payment_for', name: 'payment_for' }, ], diff --git a/resources/views/web/templates/checkout.blade.php b/resources/views/web/templates/checkout.blade.php index a480615..f1e5079 100644 --- a/resources/views/web/templates/checkout.blade.php +++ b/resources/views/web/templates/checkout.blade.php @@ -972,7 +972,7 @@ -

Sind alle Deine Angaben vollsätndig ausgefüllt, klicke auf "Jetzt kaufen" und Du wist zu unserem Zahlungsanbieter weitergeleitet, die Verbindung wird ist SSL verschlüsselt.

+

Sind alle Deine Angaben vollständig ausgefüllt, klicke auf "Jetzt kaufen" und Du wirst zu unserem Zahlungsanbieter weitergeleitet, die Verbindung ist SSL verschlüsselt.

diff --git a/routes/web.php b/routes/web.php index 65f5f9f..334b8fe 100755 --- a/routes/web.php +++ b/routes/web.php @@ -392,6 +392,7 @@ Route::domain(config('app.pre_url_crm').config('app.domain').config('app.tld_car Route::post('/admin/payments/invoice', 'PaymentInvoiceController@index')->name('admin_payments_invoice'); Route::get('/admin/payments/invoice/datatable', 'PaymentInvoiceController@datatable')->name('admin_payments_invoice_datatable'); + //payments credit // Gutschriften Route::get('/admin/payments/credit', 'PaymentCreditController@index')->name('admin_payments_credit'); Route::post('/admin/payments/credit', 'PaymentCreditController@store')->name('admin_payments_credit'); @@ -408,6 +409,11 @@ Route::domain(config('app.pre_url_crm').config('app.domain').config('app.tld_car Route::get('/admin/business/user/datatable', 'BusinessController@userDatatable')->name('admin_business_user_datatable'); + //payments points // Gutschreiben + Route::get('/admin/business/points', 'BusinessPointsController@index')->name('admin_business_points'); + Route::post('/admin/business/points', 'BusinessPointsController@index')->name('admin_business_points'); + Route::get('/admin/business/points/datatable', 'BusinessPointsController@datatable')->name('admin_business_points_datatable'); +