Cron Jobs, Reminder, Fonts, Members / Wizard / Price, Credit and Promotion
This commit is contained in:
parent
a0f4eda6ea
commit
6167273a48
204 changed files with 8746 additions and 215 deletions
|
|
@ -3,6 +3,7 @@ namespace App\Services;
|
|||
|
||||
|
||||
use App\User;
|
||||
use App\Models\PromotionUser;
|
||||
|
||||
class UserService
|
||||
{
|
||||
|
|
@ -18,4 +19,15 @@ class UserService
|
|||
return $confirmation_code;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function hasActivePromotion($user) {
|
||||
$promotion_users = PromotionUser::where('user_id', $user->id)->where('active', 1)->whereNull('user_deleted_at')->get();
|
||||
foreach($promotion_users as $promotion_user){
|
||||
if($promotion_user->promotion_admin->isActive()){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,16 +2,17 @@
|
|||
namespace App\Services;
|
||||
|
||||
use App\Models\Product;
|
||||
use App\Services\UserService;
|
||||
use App\Services\Yard\Margin;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Services\Yard\Commission;
|
||||
use App\Services\Yard\Margin;
|
||||
use App\Services\Yard\MarginItems;
|
||||
use Gloudemans\Shoppingcart\Cart;
|
||||
use App\Services\Yard\MarginItems;
|
||||
use Illuminate\Support\Collection;
|
||||
use Gloudemans\Shoppingcart\CartItem;
|
||||
use Gloudemans\Shoppingcart\Contracts\Buyable;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Support\Collection;
|
||||
use Gloudemans\Shoppingcart\Contracts\Buyable;
|
||||
|
||||
/*
|
||||
|
||||
|
|
@ -38,7 +39,9 @@ class Yard extends Cart
|
|||
private $yinstance;
|
||||
private $shopping_data = [];
|
||||
private $user;
|
||||
private $payment_credit;
|
||||
private $use_payment_credit;
|
||||
private $has_active_promotion;
|
||||
private $reduce_payment_credit;
|
||||
|
||||
private $yard_commission;
|
||||
private $yard_margin;
|
||||
|
|
@ -75,8 +78,14 @@ class Yard extends Cart
|
|||
if($this->getYardExtra('user')){
|
||||
$this->user = $this->getYardExtra('user');
|
||||
}
|
||||
if($this->getYardExtra('payment_credit')){
|
||||
$this->payment_credit = $this->getYardExtra('payment_credit');
|
||||
if($this->getYardExtra('use_payment_credit')){
|
||||
$this->use_payment_credit = $this->getYardExtra('use_payment_credit');
|
||||
}
|
||||
if($this->getYardExtra('has_active_promotion')){
|
||||
$this->has_active_promotion = $this->getYardExtra('has_active_promotion');
|
||||
}
|
||||
if($this->getYardExtra('reduce_payment_credit')){
|
||||
$this->reduce_payment_credit = $this->getYardExtra('reduce_payment_credit');
|
||||
}
|
||||
if($this->getYardExtra('yard_commission')){
|
||||
$this->yard_commission = $this->getYardExtra('yard_commission');
|
||||
|
|
@ -268,14 +277,17 @@ class Yard extends Cart
|
|||
$rest_amount = $end_monthy_amount - ($start_monthy_amount + $balance);
|
||||
}
|
||||
}else{
|
||||
$range = $last_limit-$user_level_margin->price_from;
|
||||
if($rest_amount >= $range){
|
||||
$balance = $range;
|
||||
}else{
|
||||
$balance = $rest_amount;
|
||||
if(isset($last_limit)){
|
||||
$range = $last_limit - $user_level_margin->price_from;
|
||||
if($rest_amount >= $range){
|
||||
$balance = $range;
|
||||
}else{
|
||||
$balance = $rest_amount;
|
||||
}
|
||||
$rest_amount = $rest_amount - $balance;
|
||||
}
|
||||
$rest_amount = $rest_amount-$balance;
|
||||
}
|
||||
|
||||
$last_limit = $user_level_margin->price_from;
|
||||
if($balance != 0){
|
||||
$commission = 0;
|
||||
|
|
@ -287,8 +299,8 @@ class Yard extends Cart
|
|||
'range' => $range,
|
||||
'rest_amount' => $rest_amount,
|
||||
'balance' => $balance,
|
||||
'trading_margin'=> $user_level_margin->trading_margin,
|
||||
'commission'=> $commission,
|
||||
'trading_margin' => $user_level_margin->trading_margin,
|
||||
'commission' => $commission,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -299,7 +311,6 @@ class Yard extends Cart
|
|||
$margin->calculate();
|
||||
$this->yard_margin = $margin;
|
||||
$this->putYardExtra('yard_margin', $this->yard_margin);
|
||||
|
||||
//dump($margin);
|
||||
}
|
||||
|
||||
|
|
@ -322,20 +333,49 @@ class Yard extends Cart
|
|||
|
||||
}
|
||||
|
||||
public function setShoppingUser($user, $payment_credit = false){
|
||||
public function setShoppingUser($user, $use_payment_credit = false){
|
||||
$this->user = $user;
|
||||
$this->payment_credit = $payment_credit;
|
||||
$this->use_payment_credit = $use_payment_credit;
|
||||
$this->has_active_promotion = UserService::hasActivePromotion($user);
|
||||
$this->reduce_payment_credit = true; //default set true, checkbox on yard_view_from ist checked
|
||||
$this->putYardExtra('user', $user);
|
||||
$this->putYardExtra('payment_credit', $payment_credit);
|
||||
$this->putYardExtra('use_payment_credit', $use_payment_credit);
|
||||
$this->putYardExtra('has_active_promotion', $this->has_active_promotion);
|
||||
$this->putYardExtra('reduce_payment_credit', $this->reduce_payment_credit);
|
||||
|
||||
}
|
||||
|
||||
public function setReducePaymentCredit($reduce_payment_credit){
|
||||
$this->reduce_payment_credit = $reduce_payment_credit;
|
||||
$this->putYardExtra('reduce_payment_credit', $reduce_payment_credit);
|
||||
}
|
||||
|
||||
public function getReducePaymentCredit(){
|
||||
return $this->reduce_payment_credit;
|
||||
}
|
||||
|
||||
|
||||
public function getPaymentCredit(){
|
||||
if($this->payment_credit && $this->user->payment_credit > 0){
|
||||
if($this->use_payment_credit && $this->user->payment_credit > 0){
|
||||
return $this->user->payment_credit;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasActivePromotion(){
|
||||
return $this->has_active_promotion;
|
||||
}
|
||||
|
||||
public function reducePaymentCredit(){
|
||||
if(!$this->reduce_payment_credit){
|
||||
return false;
|
||||
}
|
||||
if($this->has_active_promotion){
|
||||
return false;
|
||||
}
|
||||
return $this->getPaymentCredit();
|
||||
}
|
||||
|
||||
private function calculateShippingPrice(){
|
||||
//keine Verandkosten
|
||||
if($this->shipping_option && $this->shipping_option === 'pick_up'){
|
||||
|
|
@ -527,7 +567,7 @@ class Yard extends Cart
|
|||
$subtotal_shipping = $this->subtotalWithShipping(2, '.', '');
|
||||
$tax = $subtotal_shipping / 100 * $this->global_tax_rate;
|
||||
$total = ($subtotal_shipping + $tax);
|
||||
if($PaymentCredit = $this->getPaymentCredit()){
|
||||
if($PaymentCredit = $this->reducePaymentCredit()){
|
||||
$total = $total - $PaymentCredit;
|
||||
if($total < 0){
|
||||
$total = 0;
|
||||
|
|
@ -549,7 +589,7 @@ class Yard extends Cart
|
|||
public function totalfromCredit($decimals = null, $decimalPoint = null, $thousandSeperator = null)
|
||||
{
|
||||
$rest = 0;
|
||||
if ($PaymentCredit = $this->getPaymentCredit()) {
|
||||
if ($PaymentCredit = $this->reducePaymentCredit()) {
|
||||
$subtotal_shipping= $this->subtotalWithShipping(2, '.', '');
|
||||
$tax = $subtotal_shipping/ 100 * $this->global_tax_rate;
|
||||
$total = ($subtotal_shipping+ $tax);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue