48 lines
No EOL
1.5 KiB
PHP
48 lines
No EOL
1.5 KiB
PHP
<?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,
|
|
]);
|
|
}
|
|
}
|
|
|
|
|
|
} |