Updates to 03-2025

This commit is contained in:
Kevin Adametz 2025-04-01 10:39:21 +02:00
parent 6167273a48
commit 9b54eb0512
348 changed files with 34535 additions and 5774 deletions

View file

@ -1,7 +1,10 @@
<?php
namespace App\Services;
use App\Models\Country;
use App\Models\Product;
use App\Models\Setting;
use App\Services\UserMarign;
use App\Services\UserService;
use App\Services\Yard\Margin;
use App\Models\ShippingCountry;
@ -49,6 +52,13 @@ class Yard extends Cart
private $global_tax_rate = 0;
private $shipping_option; //pick_up//dhl_shipping
private $user_tax_free;
private $shipping_free;
private $user_reverse_charge;
private $user_country_id;
private $user_country;
private $events;
public function __construct(SessionManager $session, Dispatcher $events)
{
$this->ysession = $session;
@ -105,6 +115,24 @@ class Yard extends Cart
$this->shipping_option = $this->getYardExtra('shipping_option');
}
if($this->getYardExtra('user_tax_free')){
$this->user_tax_free = $this->getYardExtra('user_tax_free');
}
if($this->getYardExtra('shipping_free')){
$this->shipping_free = $this->getYardExtra('shipping_free');
}
if($this->getYardExtra('user_reverse_charge')){
$this->user_reverse_charge = $this->getYardExtra('user_reverse_charge');
}
if($this->getYardExtra('user_country_id')){
$this->user_country_id = $this->getYardExtra('user_country_id');
}
if($this->getYardExtra('user_country')){
$this->user_country = $this->getYardExtra('user_country');
}
$this->events = $events;
parent::__construct($session, $events);
@ -194,6 +222,11 @@ class Yard extends Cart
{
return $this->shipping_country_id;
}
public function getShippingPrice()
{
return $this->shipping_price;
}
public function getYContent()
{
@ -203,6 +236,10 @@ class Yard extends Cart
return $this->ysession->get($this->yinstance);
}
public function getCartContent(){
return $this->getContent();
}
public function reCalculateShippingPrice(){
$this->calculateShippingPrice();
}
@ -314,6 +351,15 @@ class Yard extends Cart
//dump($margin);
}
public function setUser($user){
$this->user = $user;
$this->putYardExtra('user', $user);
}
public function sponsorHasCommisson(){
return $this->user->sponsorHasCommisson();
}
public function getYardMargin(){
return $this->yard_margin;
}
@ -330,7 +376,24 @@ class Yard extends Cart
$this->putYardExtra('shipping_is_for', $shipping_is_for);
$this->calculateShippingPrice();
}
public function setUserPriceInfos($setUserPriceInfos = [])
{
$this->shipping_free = isset($setUserPriceInfos['shipping_free']) ? $setUserPriceInfos['shipping_free'] : false;
$this->putYardExtra('shipping_free', $this->shipping_free);
$this->user_tax_free = $setUserPriceInfos['user_tax_free'];
$this->putYardExtra('user_tax_free', $this->user_tax_free);
$this->user_reverse_charge = $setUserPriceInfos['user_reverse_charge'];
$this->putYardExtra('user_reverse_charge', $this->user_reverse_charge);
$this->user_country_id = $setUserPriceInfos['user_country_id'];
$this->putYardExtra('user_country_id', $this->user_country_id);
$this->user_country = Country::findOrFail($setUserPriceInfos['user_country_id']);
$this->putYardExtra('user_country', $this->user_country);
}
public function setShoppingUser($user, $use_payment_credit = false){
@ -345,6 +408,45 @@ class Yard extends Cart
}
public function getUserPriceInfos(){
return [
'user_tax_free' =>$this->user_tax_free,
'user_reverse_charge' =>$this->user_reverse_charge,
'user_country_id' =>$this->user_country_id,
'shipping_free' => $this->shipping_free,
];
}
public function getUserCountryId()
{
return $this->user_country_id;
}
public function getUserCountry()
{
return $this->user_country;
}
public function getUserTaxFree()
{
return $this->user_tax_free ? true : false;
}
public function getShippingFree()
{
return $this->shipping_free;
}
public function getShippingFreeMissingValue()
{
if($this->shipping_free && $this->total(2, '.', '') < $this->shipping_free){
return $this->shipping_free - $this->total(2, '.', '');
}
return 0;
}
public function setReducePaymentCredit($reduce_payment_credit){
$this->reduce_payment_credit = $reduce_payment_credit;
$this->putYardExtra('reduce_payment_credit', $reduce_payment_credit);
@ -405,9 +507,12 @@ class Yard extends Cart
if($this->shipping_is_for === 'me' || $this->shipping_is_for === 'ot'){
$shipping_price_for = 1;
}
if($this->shipping_is_for === 'shop'){
if($this->shipping_is_for === 'prom'){
$shipping_price_for = 2;
}
if($this->shipping_is_for === 'shop'){
$shipping_price_for = 3;
}
if($this->weight() == 0){
$shipping_price = $shipping->getShippingPricesBy($shipping_price_for)->first();
if(!$shipping_price){
@ -459,9 +564,12 @@ class Yard extends Cart
}
$shipping = $shippingCountry->shipping;
$shipping_price_for = 1;
if($this->shipping_is_for === 'shop'){
if($this->shipping_is_for === 'prom'){
$shipping_price_for = 2;
}
if($this->shipping_is_for === 'shop'){
$shipping_price_for = 3;
}
if($this->weight() == 0){
$shipping_price = $shipping->getShippingPricesBy($shipping_price_for)->first();
if(!$shipping_price){