08 2024
This commit is contained in:
parent
04d677d37a
commit
bfa3bb1df4
1191 changed files with 637397 additions and 10619 deletions
48
app/Services/AboHelper.php
Normal file
48
app/Services/AboHelper.php
Normal 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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue