diff --git a/app/Http/Controllers/Api/ShoppingUserController.php b/app/Http/Controllers/Api/ShoppingUserController.php index 8298761..264cd31 100755 --- a/app/Http/Controllers/Api/ShoppingUserController.php +++ b/app/Http/Controllers/Api/ShoppingUserController.php @@ -264,7 +264,7 @@ class ShoppingUserController extends Controller $shopping_user = ShoppingUser::create($data); //Kundenhoheit prüfen - $priority = CustomerPriority::checkOne($shopping_user, true, false); + $priority = CustomerPriority::checkOne($shopping_user, true, false, true); \App\Services\Shop::newUserOrder($shopping_user->number); //exists //like //update $user = $this->prepareForShow($shopping_user); diff --git a/app/Http/Controllers/User/HomepartyController.php b/app/Http/Controllers/User/HomepartyController.php index 0ca5176..c6b0b87 100755 --- a/app/Http/Controllers/User/HomepartyController.php +++ b/app/Http/Controllers/User/HomepartyController.php @@ -52,7 +52,6 @@ class HomepartyController extends Controller $step = 10; } } - } if($homeparty->homeparty_host){ $homeparty_user = $homeparty->homeparty_host; diff --git a/app/Http/Controllers/UserShopController.php b/app/Http/Controllers/UserShopController.php index 569ee04..b8a9a6c 100755 --- a/app/Http/Controllers/UserShopController.php +++ b/app/Http/Controllers/UserShopController.php @@ -145,7 +145,7 @@ class UserShopController extends Controller return redirect(route('user_shop')); } - catch (Exception $e) { + catch (\Exception $e) { \Session()->flash('alert-danger', "Fehler".$e); return redirect(route('user_shop')); } @@ -230,7 +230,7 @@ class UserShopController extends Controller return redirect(route('user_shop')); } - catch (Exception $e) { + catch (\Exception $e) { \Session()->flash('alert-danger', "Fehler".$e); return redirect(route('user_shop')); } @@ -262,12 +262,8 @@ class UserShopController extends Controller - /** - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector - */ public function userShopRegisterForm(){ - if(Request::get('shop_submit') == 'check'){ $rules = array( 'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check', @@ -282,10 +278,10 @@ class UserShopController extends Controller if ($validator->fails()) { \Session()->flash('shop-name-error', 'error'); - return redirect()->back()->withErrors($validator)->withRequest(); + return redirect()->back()->withErrors($validator)->withInput(Request::all()); } \Session()->flash('shop-name-error', 'check'); - return redirect(route('user_shop'))->withRequest(); + return redirect(route('user_shop'))->withInput(Request::all()); } if(Request::get('shop_submit') == 'action') { @@ -313,16 +309,15 @@ class UserShopController extends Controller ); $validator = Validator::make(Request::all(), $rules); if ($validator->fails()) { - return redirect()->back()->withErrors($validator)->withRequest(); + return redirect()->back()->withErrors($validator)->withInput(Request::all()); } - //all is right - save $user = Auth::user(); $data = Request::all(); - + $slug = SlugService::createSlug(UserShop::class, 'slug', $data['user_shop_name']); $user_shop = UserShop::create([ 'user_id' => $user->id, - 'name' => $data['user_shop_name'], + 'name' => $slug, 'active' => true, 'active_date' => now(), ] diff --git a/app/Http/Controllers/Web/CardController.php b/app/Http/Controllers/Web/CardController.php index b1e15f5..0d5eb5c 100755 --- a/app/Http/Controllers/Web/CardController.php +++ b/app/Http/Controllers/Web/CardController.php @@ -59,7 +59,6 @@ class CardController extends Controller $image = $product->images->first()->slug; } $quantity = Request::get('quantity') ? Request::get('quantity') : 1; - $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]); $cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $quantity, $product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]); if(Yard::instance('shopping')->getUserTaxFree()){ Yard::setTax($cartItem->rowId, 0); diff --git a/app/Http/Controllers/Web/CheckoutController.php b/app/Http/Controllers/Web/CheckoutController.php index f977ec7..3af29ec 100755 --- a/app/Http/Controllers/Web/CheckoutController.php +++ b/app/Http/Controllers/Web/CheckoutController.php @@ -50,8 +50,7 @@ class CheckoutController extends Controller $is_for = isset($shopping_data['is_for']) ? $shopping_data['is_for'] : false; $homeparty_id = isset($shopping_data['homeparty_id']) ? $shopping_data['homeparty_id'] : null; $shopping_user = null; - - + /*if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){//$is_from !== 'shopping' && ){ // $shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data); @@ -84,6 +83,7 @@ class CheckoutController extends Controller $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); + $shopping_user->same_as_billing = $shopping_user->same_as_billing ? false : true; //reinvert } if($shopping_user->same_as_billing === NULL){ $shopping_user->same_as_billing = false; @@ -446,7 +446,6 @@ class CheckoutController extends Controller $data['same_as_billing'] = isset($data['same_as_billing']) ? false : true; //reinvert $data['accepted_data_checkbox'] = isset($data['accepted_data_checkbox']) ? true : false; - $shopping_user = false; if($this->getPayments('shopping_user_id')){ $shopping_user = ShoppingUser::find($this->getPayments('shopping_user_id')); diff --git a/app/Services/CustomerPriority.php b/app/Services/CustomerPriority.php index d042a8e..91328bd 100644 --- a/app/Services/CustomerPriority.php +++ b/app/Services/CustomerPriority.php @@ -29,10 +29,19 @@ class CustomerPriority return $shopping_users; } - public static function checkOne($shopping_user, $mail=false, $newCustomer = true){ + public static function checkOne($shopping_user, $mail=false, $newCustomer = true, $entryExistsLike = false){ //look for entry - if(self::entryExists($shopping_user)){ - return 'exists'; + if($entryExistsLike){ + if(self::entryExistsLike($shopping_user)){ + if($mail){ //send mail + Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer')); + } + return 'exists'; + } + }else{ + if(self::entryExists($shopping_user)){ + return 'exists'; + } } if(self::entryLike($shopping_user)){ if($mail){ //send mail @@ -117,11 +126,13 @@ class CustomerPriority $change = []; $ret = 'update'; //email geändert + if(isset($data['billing_email']) && $shopping_user->billing_email != $data['billing_email']){ $found = ShoppingUser::where('auth_user_id', '=', NULL) ->where('number', '!=', NULL) //has number ->where('id', '!=', $shopping_user->id) ->where('billing_email', '=', $data['billing_email']) + ->where('member_id', '!=', $shopping_user->member_id) ->get()->pluck('number', 'id')->unique()->toArray(); if($found && count($found)){ foreach ($found as $key=>$val){ @@ -139,6 +150,7 @@ class CustomerPriority ->where('id', '!=', $shopping_user->id) ->where('billing_lastname', '=', $data['billing_lastname']) ->where('billing_zipcode', '=', $data['billing_zipcode']) + ->where('member_id', '!=', $shopping_user->member_id) ->get()->pluck('number', 'id')->unique()->toArray(); if($found && count($found)){ foreach ($found as $key=>$val){ @@ -198,6 +210,23 @@ class CustomerPriority return false; } + private static function entryExistsLike($shopping_user) + { + $matches = ShoppingUser::where('auth_user_id', '=', NULL) + ->where('number', '!=', NULL) //has number + ->where('id', '!=', $shopping_user->id) + ->where('member_id', '!=', $shopping_user->member_id) + ->where('billing_email', '=', $shopping_user->billing_email) + ->get()->pluck('number', 'id')->unique()->toArray(); + + if($matches && count($matches)){ + $shopping_user->is_like = true; + $shopping_user->setNotice(self::$user_notice_key, $matches); + $shopping_user->save(); + return true; + } + return false; + } private static function entryLike($shopping_user){ //check same last name und PLZ $matches = ShoppingUser::select('*') diff --git a/public/phpinfo.php b/public/phpinfo.php deleted file mode 100644 index d7c3469..0000000 --- a/public/phpinfo.php +++ /dev/null @@ -1,4 +0,0 @@ - \ No newline at end of file diff --git a/resources/views/admin/modal/is_like_member.blade.php b/resources/views/admin/modal/is_like_member.blade.php index c8bb4a4..e807247 100644 --- a/resources/views/admin/modal/is_like_member.blade.php +++ b/resources/views/admin/modal/is_like_member.blade.php @@ -75,7 +75,8 @@
#{{$current->member->number}}
{{$current->member->getFullName()}}
- {{$current->member->account->zipcode}} {{$current->member->account->city}}
+ @if(isset($current->member->account->zipcode)){{$current->member->account->zipcode}} @endif
+ @if(isset($current->member->account->city)){{$current->member->account->city}} @endif
@if($current->member->shop)
@if($current->member->isActive() && $current->member->isActiveShop())
{{$current->member->shop->getSubdomain(false)}}
diff --git a/resources/views/web/templates/checkout.blade.php b/resources/views/web/templates/checkout.blade.php
index 6987903..dbeaf62 100644
--- a/resources/views/web/templates/checkout.blade.php
+++ b/resources/views/web/templates/checkout.blade.php
@@ -419,6 +419,8 @@
@else
+ @if($is_from === 'user_order') {!! Form::hidden('same_as_billing', $shopping_user->same_as_billing) !!} @endif
+