20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use App\Mail\MailCheckout;
|
||||
use App\Models\ProductBuying;
|
||||
use App\Models\ShoppingOrder;
|
||||
|
|
@ -10,26 +9,22 @@ use App\Models\ShoppingPayment;
|
|||
use App\Models\UserCreditItem;
|
||||
use App\Models\UserLevel;
|
||||
use App\Repositories\InvoiceRepository;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\BusinessPlan\SalesPointsVolume;
|
||||
use App\Services\ShopApiOrderCart;
|
||||
use App\Services\UserUtil;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class Payment
|
||||
{
|
||||
|
||||
public static $txaction_text = [
|
||||
'paid' => 'paid',
|
||||
'appointed' => 'open',
|
||||
'failed' => 'failed',
|
||||
'extern' => 'open', //offen
|
||||
'extern' => 'open', // offen
|
||||
'extern_paid' => 'paid',
|
||||
'invoice_open' => 'open',
|
||||
'invoice_paid' => 'paid',
|
||||
'invoice_non' => 'no_payment',
|
||||
'cancelled' => 'cancelled',
|
||||
'NULL' => 'no_payment',
|
||||
];
|
||||
|
||||
|
|
@ -37,11 +32,12 @@ class Payment
|
|||
'paid' => 'paymend_paid',
|
||||
'appointed' => 'paymend_open',
|
||||
'failed' => 'paymend_failed',
|
||||
'extern' => 'extern_open', //offen
|
||||
'extern' => 'extern_open', // offen
|
||||
'extern_paid' => 'extern_paid',
|
||||
'invoice_open' => 'invoice_open',
|
||||
'invoice_paid' => 'invoice_paid',
|
||||
'invoice_non' => 'invoice_no_payment',
|
||||
'cancelled' => 'cancelled',
|
||||
'NULL' => 'no_payment',
|
||||
];
|
||||
|
||||
|
|
@ -60,15 +56,16 @@ class Payment
|
|||
'invoice_open' => 'warning',
|
||||
'invoice_paid' => 'success',
|
||||
'invoice_non' => 'failed',
|
||||
'cancelled' => 'danger',
|
||||
];
|
||||
|
||||
|
||||
public static function getFormattedTxaction($txaction)
|
||||
{
|
||||
if ($txaction && isset(self::$txaction_text[$txaction])) {
|
||||
return __('payment.' . self::$txaction_text[$txaction]);
|
||||
return __('payment.'.self::$txaction_text[$txaction]);
|
||||
}
|
||||
return __('payment.' . self::$txaction_text['NULL']);
|
||||
|
||||
return __('payment.'.self::$txaction_text['NULL']);
|
||||
}
|
||||
|
||||
public static function getFormattedTxactionColor($txaction)
|
||||
|
|
@ -76,15 +73,17 @@ class Payment
|
|||
if ($txaction && isset(self::$txaction_color[$txaction])) {
|
||||
return self::$txaction_color[$txaction];
|
||||
}
|
||||
return "warning";
|
||||
|
||||
return 'warning';
|
||||
}
|
||||
|
||||
public static function getTransTxactionFilterText()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$txaction_filter_text as $key => $val) {
|
||||
$ret[$key] = trans('payment.' . $val);
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -92,8 +91,9 @@ class Payment
|
|||
{
|
||||
$ret = [];
|
||||
foreach (self::$txaction_invoice as $key => $val) {
|
||||
$ret[$key] = trans('payment.' . $val);
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -101,29 +101,32 @@ class Payment
|
|||
{
|
||||
|
||||
if ($shopping_order->mode === 'test') {
|
||||
return '<span class="badge badge-pill badge-default">' . strtoupper($shopping_order->mode) . ' - ' . self::getFormattedTxaction($shopping_order->txaction) . '</span>';
|
||||
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
||||
}
|
||||
if ($shopping_order->mode === 'dev') {
|
||||
return '<span class="badge badge-pill badge-info">' . strtoupper($shopping_order->mode) . ' - ' . self::getFormattedTxaction($shopping_order->txaction) . '</span>';
|
||||
return '<span class="badge badge-pill badge-info">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
||||
}
|
||||
return '<span class="badge badge-pill badge-' . self::getFormattedTxactionColor($shopping_order->txaction) . '">' . self::getFormattedTxaction($shopping_order->txaction) . '</span>';
|
||||
|
||||
return '<span class="badge badge-pill badge-'.self::getFormattedTxactionColor($shopping_order->txaction).'">'.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
||||
}
|
||||
|
||||
public static function getPaymentForBadge(ShoppingOrder $shopping_order)
|
||||
{
|
||||
$abo = '';
|
||||
if ($shopping_order->is_abo) {
|
||||
$abo = ' <span class="badge badge-pill badge-success">' . __('abo.abo') . '</span>';
|
||||
$abo = ' <span class="badge badge-pill badge-success">'.__('abo.abo').'</span>';
|
||||
}
|
||||
return '<span class="badge badge-pill badge-' . $shopping_order->getPaymentForColor() . '">' . $shopping_order->getPaymentForType() . '</span>' . $abo;
|
||||
|
||||
return '<span class="badge badge-pill badge-'.$shopping_order->getPaymentForColor().'">'.$shopping_order->getPaymentForType().'</span>'.$abo;
|
||||
}
|
||||
|
||||
public static function getShoppingPaymentBadge(ShoppingPayment $shopping_payment)
|
||||
{
|
||||
if ($shopping_payment->mode === 'test') {
|
||||
return '<span class="badge badge-pill badge-default">' . strtoupper($shopping_payment->mode) . ' - ' . self::getFormattedTxaction($shopping_payment->txaction) . '</span>';
|
||||
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_payment->mode).' - '.self::getFormattedTxaction($shopping_payment->txaction).'</span>';
|
||||
}
|
||||
return '<span class="badge badge-pill badge-' . self::getFormattedTxactionColor($shopping_payment->txaction) . '">' . self::getFormattedTxaction($shopping_payment->txaction) . '</span>';
|
||||
|
||||
return '<span class="badge badge-pill badge-'.self::getFormattedTxactionColor($shopping_payment->txaction).'">'.self::getFormattedTxaction($shopping_payment->txaction).'</span>';
|
||||
}
|
||||
|
||||
public static function addUserCreditMargin(User $user, $credit, $status, $message)
|
||||
|
|
@ -133,7 +136,7 @@ class Payment
|
|||
'credit' => $credit,
|
||||
'message' => $message,
|
||||
'from_month' => date('n'),
|
||||
'from_year' => date('Y'),
|
||||
'from_year' => date('Y'),
|
||||
'status' => $status,
|
||||
]);
|
||||
}
|
||||
|
|
@ -143,7 +146,7 @@ class Payment
|
|||
ProductBuying::create([
|
||||
'user_id' => $user->id,
|
||||
'product_id' => $product_id,
|
||||
'amount' => 1
|
||||
'amount' => 1,
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
@ -155,9 +158,9 @@ class Payment
|
|||
'user_id' => $user->user_sponsor->id,
|
||||
'total_net' => 0,
|
||||
'points' => $product->sponsor_buying_points_amount,
|
||||
'info' => 'VP: ' . $user->getFullName(false) . ' | ' . $product->name,
|
||||
'info' => 'VP: '.$user->getFullName(false).' | '.$product->name,
|
||||
'status_points' => 2,
|
||||
'status' => 5
|
||||
'status' => 5,
|
||||
];
|
||||
SalesPointsVolume::addSalesPointsVolume($data);
|
||||
}
|
||||
|
|
@ -165,7 +168,7 @@ class Payment
|
|||
|
||||
public static function updateUserLevel(User $user, $to_level_id)
|
||||
{
|
||||
//nur updaten, wenn der user->m_level kleiner ist als $to_level_id
|
||||
// nur updaten, wenn der user->m_level kleiner ist als $to_level_id
|
||||
if ($user->user_level) {
|
||||
$ToUserLevel = UserLevel::find($to_level_id);
|
||||
if ($user->user_level->pos < $ToUserLevel->pos) {
|
||||
|
|
@ -190,7 +193,7 @@ class Payment
|
|||
$shopping_order->paid = $paid;
|
||||
$shopping_order->save();
|
||||
|
||||
//if product has actions
|
||||
// if product has actions
|
||||
if ($shopping_order->shopping_order_items && $shopping_order->auth_user_id) {
|
||||
foreach ($shopping_order->shopping_order_items as $shopping_order_item) {
|
||||
if ($shopping_order_item->product) {
|
||||
|
|
@ -204,17 +207,19 @@ class Payment
|
|||
}
|
||||
if ($shopping_order_item->product->action) {
|
||||
$send_link = true;
|
||||
//new date
|
||||
// new date
|
||||
$date = \Carbon::now()->modify('1 year');
|
||||
if ($user->payment_account && $user->daysActiveAccount() > 0) {
|
||||
$date = \Carbon::parse($user->payment_account)->modify('1 year');
|
||||
}
|
||||
foreach ($shopping_order_item->product->action as $do) {
|
||||
// bzw. product_id 34 = 0 => payment_for_account => payment_order_id = 35 = 0 => payment_for_account, 1 => payment_for_shop, 2 => payment_for_shop_upgrade
|
||||
// 0 => payment_for_account, 1 => payment_for_shop, 2 => payment_for_shop_upgrade
|
||||
if ($shopping_order_item->product->getActionName($do) === 'payment_for_account') {
|
||||
$user->payment_order_id = $shopping_order_item->product->id; //34
|
||||
$user->payment_order_id = $shopping_order_item->product->id;
|
||||
$user->payment_account = $date;
|
||||
$user->wizard = 100;
|
||||
//only date is > now and acount is deactive.
|
||||
// only date is > now and acount is deactive.
|
||||
if ($date > \Carbon::now()) {
|
||||
if ($user->active === 0) {
|
||||
$user->active = true;
|
||||
|
|
@ -224,19 +229,22 @@ class Payment
|
|||
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
}
|
||||
// 1 => payment_for_shop
|
||||
if ($shopping_order_item->product->getActionName($do) === 'payment_for_shop') {
|
||||
$user->payment_order_id = $shopping_order_item->product->id; //35
|
||||
$user->payment_order_id = $shopping_order_item->product->id; // 35
|
||||
$user->payment_shop = $date;
|
||||
$user->wizard = 100;
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
}
|
||||
// 2 => payment_for_shop_upgrade
|
||||
if ($shopping_order_item->product->getActionName($do) === 'payment_for_shop_upgrade') {
|
||||
if ($shopping_order_item->product->upgrade_to_id) {
|
||||
$user->payment_order_id = $shopping_order_item->product->upgrade_to_id;
|
||||
}
|
||||
$user->payment_shop = $user->payment_account; //same Date, is upgrade
|
||||
$user->payment_shop = $user->payment_account; // same Date, is upgrade
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
}
|
||||
// 4 => payment_for_lead_upgrade
|
||||
if ($shopping_order_item->product->getActionName($do) === 'payment_for_lead_upgrade') {
|
||||
if ($shopping_order_item->product->upgrade_to_id) {
|
||||
self::updateUserLevel($user, $shopping_order_item->product->upgrade_to_id);
|
||||
|
|
@ -259,20 +267,26 @@ class Payment
|
|||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
ShopApiOrderCart::finishOrder($shopping_order->shopping_collect_order);
|
||||
}
|
||||
//the Order is Pay, so we can set the Status in the Abo
|
||||
|
||||
// Set payment link status to paid for all orders
|
||||
if ($shopping_payment) {
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 10); // link_paid
|
||||
$shopping_payment->identifier = null;
|
||||
$shopping_payment->save();
|
||||
}
|
||||
|
||||
// the Order is Pay, so we can set the Status in the Abo
|
||||
if ($shopping_order->is_abo) {
|
||||
if ($shopping_payment) {
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 10); //link_paid
|
||||
$shopping_payment->identifier = null;
|
||||
$shopping_payment->save();
|
||||
}
|
||||
AboHelper::setAboActive($shopping_order, 2, true);
|
||||
}
|
||||
|
||||
//make Invoice is not exist and is live
|
||||
// make Invoice is not exist and is live
|
||||
if ($shopping_order->mode === 'live' || Util::isTestSystem(true)) {
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if (!$shopping_order->isInvoice()) {
|
||||
// Reload the shopping order to check for invoice again (defense against race conditions)
|
||||
$shopping_order->refresh();
|
||||
|
||||
if (! $shopping_order->isInvoice()) {
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
$invoice_repo->createAndSalesVolume();
|
||||
}
|
||||
}
|
||||
|
|
@ -287,15 +301,15 @@ class Payment
|
|||
|
||||
// Überprüfung der Billing-E-Mail-Adresse
|
||||
|
||||
if (!$billing_email) {
|
||||
if (! $billing_email) {
|
||||
if ($data['mode'] === 'test') {
|
||||
$billing_email = config('app.checkout_test_mail');
|
||||
} else {
|
||||
$billing_email = config('app.checkout_mail');
|
||||
}
|
||||
}
|
||||
if (!filter_var($billing_email, FILTER_VALIDATE_EMAIL)) {
|
||||
\Log::channel('payment')->error("Invalid billing email at shopping_order " . $shopping_order->id, ['billing_email' => $billing_email]);
|
||||
if (! filter_var($billing_email, FILTER_VALIDATE_EMAIL)) {
|
||||
\Log::channel('payment')->error('Invalid billing email at shopping_order '.$shopping_order->id, ['billing_email' => $billing_email]);
|
||||
$billing_email = config('app.checkout_mail');
|
||||
}
|
||||
|
||||
|
|
@ -305,7 +319,7 @@ class Payment
|
|||
$bcc[] = config('app.checkout_mail');
|
||||
}
|
||||
|
||||
if (!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member) {
|
||||
if (! $shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member) {
|
||||
$bcc[] = $shopping_order->shopping_user->member->email;
|
||||
}
|
||||
$data['payment_error'] = isset($data['payment_error']) ? $data['payment_error'] : false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue