promotion 1.0
This commit is contained in:
parent
1cc8e025a1
commit
570d428b1c
60 changed files with 1596 additions and 272 deletions
|
|
@ -11,6 +11,7 @@ use App\Models\ShoppingOrder;
|
|||
use App\Models\UserPayCredit;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\UserCreditMargin;
|
||||
use App\Models\PromotionUserOrder;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class Payment
|
||||
|
|
@ -135,7 +136,7 @@ class Payment
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**/
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
|
||||
$send_link = false;
|
||||
|
||||
|
|
@ -197,7 +198,6 @@ class Payment
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
//if the order has action
|
||||
if($shopping_order->shopping_user->is_from === 'user_order'){
|
||||
//is margin -> set paid
|
||||
|
|
@ -209,10 +209,44 @@ class Payment
|
|||
return $send_link;
|
||||
}
|
||||
|
||||
public static function handelPromotionProduct(ShoppingOrder $shopping_order){
|
||||
//add the Promotion Product to Order
|
||||
$shopping_order = ShoppingOrder::find($shopping_order->id);
|
||||
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
||||
if($shopping_order_item->isFreeProduct()){
|
||||
if($promotion_user_product = $shopping_order_item->promotion_user_product){
|
||||
$promotion_admin_product = $promotion_user_product->promotion_admin_product;
|
||||
$PromotionUserOrder = PromotionUserOrder::create([
|
||||
'promotion_admin_id' => $promotion_user_product->promotion_admin_id,
|
||||
'promotion_user_id' => $shopping_order->promotion_user_id,
|
||||
'promotion_user_product_id' => $promotion_user_product->id,
|
||||
'product_id' => $promotion_user_product->product_id,
|
||||
'shopping_order_item_id' => $shopping_order_item->id,
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'shopping_user_id' => $shopping_order->shopping_user_id,
|
||||
'qty' => $shopping_order_item->qty,
|
||||
'price' => $promotion_admin_product->getPriceWith(false),
|
||||
'price_net' => $promotion_admin_product->getPriceWith(true),
|
||||
'tax_rate' => $promotion_admin_product->product->tax,
|
||||
]);
|
||||
|
||||
$promotion_user_product->open_items -= $PromotionUserOrder->qty;
|
||||
$promotion_user_product->sell_items += $PromotionUserOrder->qty;
|
||||
$promotion_user_product->used_budget_total += $PromotionUserOrder->price;
|
||||
$promotion_user_product->save();
|
||||
|
||||
//TODO Guthaben abziehen
|
||||
self::addUserPayCredits($promotion_user_product->promotion_user->user, ($PromotionUserOrder->price*-1), 5, 'promotion_order_deduction', $shopping_order->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//remove form credit, every sale fnc / vor / etc from CheckoutController
|
||||
//when stone, put it back SalesController
|
||||
public static function handelUserPayCredits(ShoppingOrder $shopping_order, $do){
|
||||
//is payment credit, reduce Sae
|
||||
//is payment credit, deduction or return
|
||||
if(!$shopping_order->shopping_order_margin){
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue