API User Like
This commit is contained in:
parent
80e6540f73
commit
cc5c147c27
9 changed files with 46 additions and 26 deletions
|
|
@ -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('*')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue