08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use Yard;
|
||||
use App\User;
|
||||
use App\Models\ShippingCountry;
|
||||
|
||||
|
|
@ -9,18 +9,57 @@ class UserService
|
|||
{
|
||||
public static $user_country;
|
||||
public static $shipping_country;
|
||||
public static $user_tax_free;
|
||||
public static $shipping_free = false;
|
||||
public static $user_tax_free = false;
|
||||
public static $user_reverse_charge = false;
|
||||
|
||||
|
||||
|
||||
public static function getTransChange(){
|
||||
|
||||
$langs = config('localization.supportedLocales');
|
||||
$ret = [];
|
||||
foreach($langs as $code => $lang){
|
||||
$ret[strtolower($code)] = strtolower($lang['native']);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
public static function initCustomerYard($shopping_user, $for){
|
||||
self::$user_tax_free = false;
|
||||
if($shopping_user->same_as_billing){
|
||||
self::$user_country = $shopping_user->billing_country;
|
||||
self::$shipping_country = $shopping_user->billing_country;
|
||||
}else{
|
||||
self::$user_country = $shopping_user->billing_country;
|
||||
self::$shipping_country = $shopping_user->shipping_country;
|
||||
}
|
||||
if(self::$user_country->supply_country && self::$shipping_country->supply_country){
|
||||
self::$user_tax_free = true;
|
||||
}
|
||||
$ShippingCountry = ShippingCountry::whereCountryId(self::$shipping_country->id)->first();
|
||||
self::$shipping_free = $ShippingCountry->shipping ? $ShippingCountry->shipping->free : false;
|
||||
self::$shipping_free = self::$shipping_free !== null ? self::$shipping_free : false;
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id, $for);
|
||||
Yard::instance('shopping')->setUserPriceInfos(self::getYardInfo());
|
||||
}
|
||||
|
||||
public static function initUserYard(User $user, $shipping_country_id, $for){
|
||||
self::$shipping_free = false;
|
||||
self::checkUserTaxShippingCountry($user, $shipping_country_id,);
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id, $for);
|
||||
Yard::instance('shopping')->setUserPriceInfos(self::getYardInfo());
|
||||
}
|
||||
|
||||
|
||||
public static function checkUserTaxShippingCountry(User $user, $shipping_country_id) {
|
||||
|
||||
if(!$user->account && !$user->account->country_id){
|
||||
if(!$user->account || !$user->account->country_id){
|
||||
abort(403, 'Error: User hat kein Land!');
|
||||
}
|
||||
$ShippingCountry = ShippingCountry::findOrFail($shipping_country_id);
|
||||
self::$user_tax_free = self::performUserTaxShippingCountry($user, $ShippingCountry);
|
||||
|
||||
return $ShippingCountry;
|
||||
/*
|
||||
dump( self::$user_price_code );
|
||||
dump( self::$user_tax_free );
|
||||
|
|
@ -54,13 +93,12 @@ class UserService
|
|||
}
|
||||
}
|
||||
//Lieferland ohne RSV
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getYardInfo(){
|
||||
return [
|
||||
'shipping_free' => false,
|
||||
'shipping_free' => self::$shipping_free,
|
||||
'user_tax_free' => self::$user_tax_free,
|
||||
'user_reverse_charge' => self::$user_reverse_charge,
|
||||
'user_country_id' => self::$user_country->id,
|
||||
|
|
@ -81,7 +119,9 @@ class UserService
|
|||
}
|
||||
|
||||
public static function getOrderInfo($key = false){
|
||||
|
||||
if(!self::$user_country){
|
||||
return '';
|
||||
}
|
||||
switch ($key) {
|
||||
case 'billing_state':
|
||||
return self::$user_country->getLocated();
|
||||
|
|
@ -90,10 +130,10 @@ class UserService
|
|||
return self::$shipping_country->getLocated();
|
||||
break;
|
||||
case 'tax_free':
|
||||
return self::$user_tax_free ? 'Nein' : 'Ja';
|
||||
return self::$user_tax_free ? __('no') : __('yes');
|
||||
break;
|
||||
case 'user_reverse_charge':
|
||||
return self::$user_reverse_charge ? 'Ja' : 'Nein';
|
||||
return self::$user_reverse_charge ? __('yes') : __('no');
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue