This commit is contained in:
Kevin Adametz 2024-08-05 12:05:24 +02:00
parent 04d677d37a
commit bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions

View file

@ -0,0 +1,48 @@
<?php
namespace App\Services;
use Yard;
use App\User;
use App\Models\UserAbo;
use App\Models\UserAboOrder;
use App\Models\ShoppingPayment;
class AboHelper
{
public static function createNewAbo(ShoppingPayment $shopping_payment){
$payment_transaction = $shopping_payment->payment_transactions->last();
$user_abo = UserAbo::create([
'user_id' => $shopping_payment->shopping_order->auth_user_id,
'shopping_user_id' => $shopping_payment->shopping_order->shopping_user_id,
'is_for' => $shopping_payment->shopping_order->shopping_user->is_for,
'payone_userid' => $payment_transaction->userid,
'clearingtype' => $shopping_payment->clearingtype,
'wallettype' => $shopping_payment->wallettype,
'amount' => $shopping_payment->amount,
'currency' => $shopping_payment->currency,
'status' => 1,
'abo_interval' => $shopping_payment->abo_interval,
'start_date' => now(),
'last_date' => now(),
'next_date' => now()->addWeeks($shopping_payment->abo_interval),
'next_abo_date' => $shopping_payment->created_at->addMonths($shopping_payment->abo_interval),
'count' => 1,
]);
if($user_abo){
UserAboOrder::create([
'user_abo_id' => $user_abo->id,
'shopping_order_id' => $shopping_payment->shopping_order_id,
'status' => 1,
]);
}
}
}