testemich Promotion
This commit is contained in:
parent
38e7fd504a
commit
a0f4eda6ea
83 changed files with 1690 additions and 504 deletions
|
|
@ -121,7 +121,18 @@ class PromotionUser extends Model
|
|||
return $this->hasMany(PromotionUserProduct::class)->where('active', 1);
|
||||
}
|
||||
|
||||
|
||||
public function promotion_user_orders()
|
||||
{
|
||||
return $this->hasMany(PromotionUserOrder::class);
|
||||
}
|
||||
|
||||
public function getPromotionUserOrders($shopping_order_id)
|
||||
{
|
||||
return PromotionUserOrder::where('promotion_user_id', $this->id)->where('shopping_order_id', $shopping_order_id)->get();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getUrlPreview()
|
||||
{
|
||||
return $this->url ? config('app.promo_url')."/".$this->url : "";
|
||||
|
|
@ -182,12 +193,15 @@ class PromotionUser extends Model
|
|||
public function checkPaymentCredit()
|
||||
{
|
||||
if($this->promotion_user_products_active->count() > 0 && $this->getCountOpenItems() > 0){
|
||||
$prices = $this->calculateCart();
|
||||
if(isset($prices['price']) && $prices['price'] == 0){
|
||||
return "okay";
|
||||
}
|
||||
$payment_credit = $this->user->payment_credit;
|
||||
if($payment_credit <= 0){
|
||||
return "empty";
|
||||
}
|
||||
|
||||
$prices = $this->calculateCart();
|
||||
if(isset($prices['price']) && $prices['price'] > 0){
|
||||
if($payment_credit >= $prices['price']){
|
||||
return "okay";
|
||||
|
|
@ -211,8 +225,12 @@ class PromotionUser extends Model
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function preCheckPaymentCredit($values, $user){
|
||||
if($values['count_items'] > 0 && $values['sum_items'] > 0){
|
||||
if(isset($values['price']) && $values['price'] == 0){
|
||||
return "okay";
|
||||
}
|
||||
$payment_credit = $user->payment_credit;
|
||||
if($payment_credit <= 0){
|
||||
return "empty";
|
||||
|
|
@ -227,7 +245,6 @@ class PromotionUser extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function preCalculateCart($value, $by = ''){
|
||||
$price = 0;
|
||||
$price_net = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue