API User Like
This commit is contained in:
parent
80e6540f73
commit
cc5c147c27
9 changed files with 46 additions and 26 deletions
|
|
@ -264,7 +264,7 @@ class ShoppingUserController extends Controller
|
||||||
$shopping_user = ShoppingUser::create($data);
|
$shopping_user = ShoppingUser::create($data);
|
||||||
|
|
||||||
//Kundenhoheit prüfen
|
//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);
|
\App\Services\Shop::newUserOrder($shopping_user->number);
|
||||||
//exists //like //update
|
//exists //like //update
|
||||||
$user = $this->prepareForShow($shopping_user);
|
$user = $this->prepareForShow($shopping_user);
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ class HomepartyController extends Controller
|
||||||
$step = 10;
|
$step = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if($homeparty->homeparty_host){
|
if($homeparty->homeparty_host){
|
||||||
$homeparty_user = $homeparty->homeparty_host;
|
$homeparty_user = $homeparty->homeparty_host;
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ class UserShopController extends Controller
|
||||||
return redirect(route('user_shop'));
|
return redirect(route('user_shop'));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (\Exception $e) {
|
||||||
\Session()->flash('alert-danger', "Fehler".$e);
|
\Session()->flash('alert-danger', "Fehler".$e);
|
||||||
return redirect(route('user_shop'));
|
return redirect(route('user_shop'));
|
||||||
}
|
}
|
||||||
|
|
@ -230,7 +230,7 @@ class UserShopController extends Controller
|
||||||
return redirect(route('user_shop'));
|
return redirect(route('user_shop'));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (\Exception $e) {
|
||||||
\Session()->flash('alert-danger', "Fehler".$e);
|
\Session()->flash('alert-danger', "Fehler".$e);
|
||||||
return redirect(route('user_shop'));
|
return redirect(route('user_shop'));
|
||||||
}
|
}
|
||||||
|
|
@ -262,12 +262,8 @@ class UserShopController extends Controller
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
|
||||||
*/
|
|
||||||
public function userShopRegisterForm(){
|
public function userShopRegisterForm(){
|
||||||
|
|
||||||
|
|
||||||
if(Request::get('shop_submit') == 'check'){
|
if(Request::get('shop_submit') == 'check'){
|
||||||
$rules = array(
|
$rules = array(
|
||||||
'user_shop_name' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
|
'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()) {
|
if ($validator->fails()) {
|
||||||
\Session()->flash('shop-name-error', 'error');
|
\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');
|
\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') {
|
if(Request::get('shop_submit') == 'action') {
|
||||||
|
|
@ -313,16 +309,15 @@ class UserShopController extends Controller
|
||||||
);
|
);
|
||||||
$validator = Validator::make(Request::all(), $rules);
|
$validator = Validator::make(Request::all(), $rules);
|
||||||
if ($validator->fails()) {
|
if ($validator->fails()) {
|
||||||
return redirect()->back()->withErrors($validator)->withRequest();
|
return redirect()->back()->withErrors($validator)->withInput(Request::all());
|
||||||
}
|
}
|
||||||
|
|
||||||
//all is right - save
|
//all is right - save
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
$data = Request::all();
|
$data = Request::all();
|
||||||
|
$slug = SlugService::createSlug(UserShop::class, 'slug', $data['user_shop_name']);
|
||||||
$user_shop = UserShop::create([
|
$user_shop = UserShop::create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'name' => $data['user_shop_name'],
|
'name' => $slug,
|
||||||
'active' => true,
|
'active' => true,
|
||||||
'active_date' => now(),
|
'active_date' => now(),
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ class CardController extends Controller
|
||||||
$image = $product->images->first()->slug;
|
$image = $product->images->first()->slug;
|
||||||
}
|
}
|
||||||
$quantity = Request::get('quantity') ? Request::get('quantity') : 1;
|
$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]);
|
$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()){
|
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||||
Yard::setTax($cartItem->rowId, 0);
|
Yard::setTax($cartItem->rowId, 0);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ class CheckoutController extends Controller
|
||||||
$homeparty_id = isset($shopping_data['homeparty_id']) ? $shopping_data['homeparty_id'] : null;
|
$homeparty_id = isset($shopping_data['homeparty_id']) ? $shopping_data['homeparty_id'] : null;
|
||||||
$shopping_user = null;
|
$shopping_user = null;
|
||||||
|
|
||||||
|
|
||||||
/*if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){//$is_from !== 'shopping' && ){ //
|
/*if(!$this->getPayments('shopping_user_id') && Util::getAuthUser()){//$is_from !== 'shopping' && ){ //
|
||||||
|
|
||||||
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
|
$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 = ShoppingUser::findOrFail($this->getPayments('shopping_user_id'));
|
||||||
$shopping_user->billing_state = Shop::getCountryShippingCountryId($shopping_user->billing_country_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->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){
|
if($shopping_user->same_as_billing === NULL){
|
||||||
$shopping_user->same_as_billing = false;
|
$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['same_as_billing'] = isset($data['same_as_billing']) ? false : true; //reinvert
|
||||||
$data['accepted_data_checkbox'] = isset($data['accepted_data_checkbox']) ? true : false;
|
$data['accepted_data_checkbox'] = isset($data['accepted_data_checkbox']) ? true : false;
|
||||||
|
|
||||||
$shopping_user = false;
|
$shopping_user = false;
|
||||||
if($this->getPayments('shopping_user_id')){
|
if($this->getPayments('shopping_user_id')){
|
||||||
$shopping_user = ShoppingUser::find($this->getPayments('shopping_user_id'));
|
$shopping_user = ShoppingUser::find($this->getPayments('shopping_user_id'));
|
||||||
|
|
|
||||||
|
|
@ -29,11 +29,20 @@ class CustomerPriority
|
||||||
return $shopping_users;
|
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
|
//look for entry
|
||||||
|
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)){
|
if(self::entryExists($shopping_user)){
|
||||||
return 'exists';
|
return 'exists';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if(self::entryLike($shopping_user)){
|
if(self::entryLike($shopping_user)){
|
||||||
if($mail){ //send mail
|
if($mail){ //send mail
|
||||||
Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer'));
|
Mail::to(config('app.info_mail'))->send(new MailInfo($shopping_user, 'check_is_like_customer'));
|
||||||
|
|
@ -117,11 +126,13 @@ class CustomerPriority
|
||||||
$change = [];
|
$change = [];
|
||||||
$ret = 'update';
|
$ret = 'update';
|
||||||
//email geändert
|
//email geändert
|
||||||
|
|
||||||
if(isset($data['billing_email']) && $shopping_user->billing_email != $data['billing_email']){
|
if(isset($data['billing_email']) && $shopping_user->billing_email != $data['billing_email']){
|
||||||
$found = ShoppingUser::where('auth_user_id', '=', NULL)
|
$found = ShoppingUser::where('auth_user_id', '=', NULL)
|
||||||
->where('number', '!=', NULL) //has number
|
->where('number', '!=', NULL) //has number
|
||||||
->where('id', '!=', $shopping_user->id)
|
->where('id', '!=', $shopping_user->id)
|
||||||
->where('billing_email', '=', $data['billing_email'])
|
->where('billing_email', '=', $data['billing_email'])
|
||||||
|
->where('member_id', '!=', $shopping_user->member_id)
|
||||||
->get()->pluck('number', 'id')->unique()->toArray();
|
->get()->pluck('number', 'id')->unique()->toArray();
|
||||||
if($found && count($found)){
|
if($found && count($found)){
|
||||||
foreach ($found as $key=>$val){
|
foreach ($found as $key=>$val){
|
||||||
|
|
@ -139,6 +150,7 @@ class CustomerPriority
|
||||||
->where('id', '!=', $shopping_user->id)
|
->where('id', '!=', $shopping_user->id)
|
||||||
->where('billing_lastname', '=', $data['billing_lastname'])
|
->where('billing_lastname', '=', $data['billing_lastname'])
|
||||||
->where('billing_zipcode', '=', $data['billing_zipcode'])
|
->where('billing_zipcode', '=', $data['billing_zipcode'])
|
||||||
|
->where('member_id', '!=', $shopping_user->member_id)
|
||||||
->get()->pluck('number', 'id')->unique()->toArray();
|
->get()->pluck('number', 'id')->unique()->toArray();
|
||||||
if($found && count($found)){
|
if($found && count($found)){
|
||||||
foreach ($found as $key=>$val){
|
foreach ($found as $key=>$val){
|
||||||
|
|
@ -198,6 +210,23 @@ class CustomerPriority
|
||||||
return false;
|
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){
|
private static function entryLike($shopping_user){
|
||||||
//check same last name und PLZ
|
//check same last name und PLZ
|
||||||
$matches = ShoppingUser::select('*')
|
$matches = ShoppingUser::select('*')
|
||||||
|
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
phpinfo();
|
|
||||||
?>
|
|
||||||
|
|
@ -75,7 +75,8 @@
|
||||||
<p>
|
<p>
|
||||||
<span class="text-muted">#{{$current->member->number}}</span><br>
|
<span class="text-muted">#{{$current->member->number}}</span><br>
|
||||||
{{$current->member->getFullName()}}<br>
|
{{$current->member->getFullName()}}<br>
|
||||||
{{$current->member->account->zipcode}} {{$current->member->account->city}}<br>
|
@if(isset($current->member->account->zipcode)){{$current->member->account->zipcode}} @endif
|
||||||
|
@if(isset($current->member->account->city)){{$current->member->account->city}} @endif <br>
|
||||||
@if($current->member->shop)
|
@if($current->member->shop)
|
||||||
@if($current->member->isActive() && $current->member->isActiveShop())
|
@if($current->member->isActive() && $current->member->isActiveShop())
|
||||||
<a href="{{$current->member->shop->getSubdomain(false)}}" class="badge badge-success" target="_blank">{{$current->member->shop->getSubdomain(false)}}</a>
|
<a href="{{$current->member->shop->getSubdomain(false)}}" class="badge badge-success" target="_blank">{{$current->member->shop->getSubdomain(false)}}</a>
|
||||||
|
|
|
||||||
|
|
@ -419,6 +419,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
|
@if($is_from === 'user_order') {!! Form::hidden('same_as_billing', $shopping_user->same_as_billing) !!} @endif
|
||||||
|
|
||||||
<div class="row" @if($is_from === 'user_order') style="display: none" @endif>
|
<div class="row" @if($is_from === 'user_order') style="display: none" @endif>
|
||||||
<div class="col-lg-12 nomargin clearfix">
|
<div class="col-lg-12 nomargin clearfix">
|
||||||
<hr>
|
<hr>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue