23-01-2026
This commit is contained in:
parent
a939cd51ef
commit
a8b395e20d
248 changed files with 29342 additions and 4805 deletions
|
|
@ -1,20 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use App\User;
|
||||
use App\Models\UserLevel;
|
||||
use App\Mail\MailCheckout;
|
||||
use App\Services\UserUtil;
|
||||
use App\Services\AboHelper;
|
||||
use App\Models\ProductBuying;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserCreditItem;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\ShopApiOrderCart;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
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
|
||||
{
|
||||
|
|
@ -61,63 +63,71 @@ class Payment
|
|||
];
|
||||
|
||||
|
||||
public static function getFormattedTxaction($txaction){
|
||||
if($txaction && isset(self::$txaction_text[$txaction])){
|
||||
return __('payment.'.self::$txaction_text[$txaction]);
|
||||
public static function getFormattedTxaction($txaction)
|
||||
{
|
||||
if ($txaction && isset(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){
|
||||
if($txaction && isset(self::$txaction_color[$txaction])){
|
||||
public static function getFormattedTxactionColor($txaction)
|
||||
{
|
||||
if ($txaction && isset(self::$txaction_color[$txaction])) {
|
||||
return self::$txaction_color[$txaction];
|
||||
}
|
||||
return "warning";
|
||||
}
|
||||
|
||||
public static function getTransTxactionFilterText(){
|
||||
$ret = [];
|
||||
foreach(self::$txaction_filter_text as $key=>$val){
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getTransTxactionInvoice(){
|
||||
$ret = [];
|
||||
foreach(self::$txaction_invoice as $key=>$val){
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getShoppingOrderBadge(ShoppingOrder $shopping_order){
|
||||
|
||||
if($shopping_order->mode === 'test'){
|
||||
return '<span class="badge badge-pill badge-default">'.strtoupper($shopping_order->mode).' - '.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
||||
public static function getTransTxactionFilterText()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$txaction_filter_text as $key => $val) {
|
||||
$ret[$key] = trans('payment.' . $val);
|
||||
}
|
||||
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-'.self::getFormattedTxactionColor($shopping_order->txaction).'">'.self::getFormattedTxaction($shopping_order->txaction).'</span>';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getPaymentForBadge(ShoppingOrder $shopping_order){
|
||||
public static function getTransTxactionInvoice()
|
||||
{
|
||||
$ret = [];
|
||||
foreach (self::$txaction_invoice as $key => $val) {
|
||||
$ret[$key] = trans('payment.' . $val);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getShoppingOrderBadge(ShoppingOrder $shopping_order)
|
||||
{
|
||||
|
||||
if ($shopping_order->mode === 'test') {
|
||||
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-' . 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>';
|
||||
if ($shopping_order->is_abo) {
|
||||
$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>';
|
||||
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-'.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){
|
||||
public static function addUserCreditMargin(User $user, $credit, $status, $message)
|
||||
{
|
||||
UserCreditItem::create([
|
||||
'user_id' => $user->id,
|
||||
'credit' => $credit,
|
||||
|
|
@ -128,22 +138,24 @@ class Payment
|
|||
]);
|
||||
}
|
||||
|
||||
public static function addBuyingRestriction(User $user, $product_id){
|
||||
public static function addBuyingRestriction(User $user, $product_id)
|
||||
{
|
||||
ProductBuying::create([
|
||||
'user_id' => $user->id,
|
||||
'product_id' => $product_id,
|
||||
'amount' => 1
|
||||
'product_id' => $product_id,
|
||||
'amount' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
public static function addSponsorBuyingPoints(User $user, $product){
|
||||
public static function addSponsorBuyingPoints(User $user, $product)
|
||||
{
|
||||
|
||||
if($user->user_sponsor){
|
||||
if ($user->user_sponsor) {
|
||||
$data = [
|
||||
'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
|
||||
];
|
||||
|
|
@ -151,14 +163,15 @@ class Payment
|
|||
}
|
||||
}
|
||||
|
||||
public static function updateUserLevel(User $user, $to_level_id){
|
||||
public static function updateUserLevel(User $user, $to_level_id)
|
||||
{
|
||||
//nur updaten, wenn der user->m_level kleiner ist als $to_level_id
|
||||
if($user->user_level){
|
||||
if ($user->user_level) {
|
||||
$ToUserLevel = UserLevel::find($to_level_id);
|
||||
if($user->user_level->pos < $ToUserLevel->pos){
|
||||
if ($user->user_level->pos < $ToUserLevel->pos) {
|
||||
$user->m_level = $to_level_id;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
$user->m_level = $to_level_id;
|
||||
}
|
||||
$user->save();
|
||||
|
|
@ -169,7 +182,8 @@ class Payment
|
|||
$paid = Status der Zahlung, Payone = true, MIVITA Rechnung = false damit kann später die rechnung auf bezahlt gesetzt werden.
|
||||
*/
|
||||
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid, $shopping_payment = null){
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid, $shopping_payment = null)
|
||||
{
|
||||
$send_link = false;
|
||||
$shopping_order->setUserHistoryValue(['status' => 8]);
|
||||
ShoppingUserService::snycOrdersByShoppingOrder($shopping_order);
|
||||
|
|
@ -177,32 +191,32 @@ class Payment
|
|||
$shopping_order->save();
|
||||
|
||||
//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){
|
||||
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) {
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
$user->save();
|
||||
if($shopping_order_item->product->buying_restriction){
|
||||
if ($shopping_order_item->product->buying_restriction) {
|
||||
self::addBuyingRestriction($user, $shopping_order_item->product->id);
|
||||
}
|
||||
if($shopping_order_item->product->sponsor_buying_points){
|
||||
if ($shopping_order_item->product->sponsor_buying_points) {
|
||||
self::addSponsorBuyingPoints($user, $shopping_order_item->product);
|
||||
}
|
||||
if($shopping_order_item->product->action){
|
||||
if ($shopping_order_item->product->action) {
|
||||
$send_link = true;
|
||||
//new date
|
||||
$date = \Carbon::now()->modify('1 year');
|
||||
if($user->payment_account && $user->daysActiveAccount()>0){
|
||||
if ($user->payment_account && $user->daysActiveAccount() > 0) {
|
||||
$date = \Carbon::parse($user->payment_account)->modify('1 year');
|
||||
}
|
||||
foreach ($shopping_order_item->product->action as $do){
|
||||
if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){
|
||||
foreach ($shopping_order_item->product->action as $do) {
|
||||
if ($shopping_order_item->product->getActionName($do) === 'payment_for_account') {
|
||||
$user->payment_order_id = $shopping_order_item->product->id; //34
|
||||
$user->payment_account = $date;
|
||||
$user->wizard = 100;
|
||||
//only date is > now and acount is deactive.
|
||||
if($date > \Carbon::now()){
|
||||
if($user->active === 0){
|
||||
if ($date > \Carbon::now()) {
|
||||
if ($user->active === 0) {
|
||||
$user->active = true;
|
||||
UserUtil::reactiveUserResetChilds($user->id, 'on payment_for_account Payment');
|
||||
}
|
||||
|
|
@ -210,21 +224,21 @@ class Payment
|
|||
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
}
|
||||
if($shopping_order_item->product->getActionName($do) === '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_shop = $date;
|
||||
$user->wizard = 100;
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
}
|
||||
if($shopping_order_item->product->getActionName($do) === 'payment_for_shop_upgrade'){
|
||||
if($shopping_order_item->product->upgrade_to_id){
|
||||
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
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
}
|
||||
if($shopping_order_item->product->getActionName($do) === 'payment_for_lead_upgrade'){
|
||||
if($shopping_order_item->product->upgrade_to_id){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -232,66 +246,66 @@ class Payment
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($shopping_order->homeparty){
|
||||
if ($shopping_order->homeparty) {
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
$shopping_order->homeparty->completed = 1;
|
||||
$shopping_order->homeparty->save();
|
||||
}
|
||||
|
||||
if($shopping_order->shopping_collect_order){
|
||||
|
||||
if ($shopping_order->shopping_collect_order) {
|
||||
$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
|
||||
if($shopping_order->is_abo){
|
||||
if($shopping_payment){
|
||||
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);
|
||||
AboHelper::setAboActive($shopping_order, 2, true);
|
||||
}
|
||||
|
||||
//make Invoice is not exist and is live
|
||||
if($shopping_order->mode === 'live'){
|
||||
if ($shopping_order->mode === 'live' || Util::isTestSystem(true)) {
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if(!$shopping_order->isInvoice()){
|
||||
if (!$shopping_order->isInvoice()) {
|
||||
$invoice_repo->createAndSalesVolume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $send_link;
|
||||
}
|
||||
|
||||
public static function paymentStatusSendMail(ShoppingOrder $shopping_order, $shopping_payment, $data){
|
||||
public static function paymentStatusSendMail(ShoppingOrder $shopping_order, $shopping_payment, $data)
|
||||
{
|
||||
$bcc = [];
|
||||
$billing_email = $shopping_order->shopping_user->billing_email;
|
||||
|
||||
|
||||
// Überprüfung der Billing-E-Mail-Adresse
|
||||
|
||||
if(!$billing_email){
|
||||
if($data['mode'] === 'test'){
|
||||
|
||||
if (!$billing_email) {
|
||||
if ($data['mode'] === 'test') {
|
||||
$billing_email = config('app.checkout_test_mail');
|
||||
}else{
|
||||
} 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');
|
||||
}
|
||||
|
||||
if($data['mode'] === 'test'){
|
||||
|
||||
if ($data['mode'] === 'test') {
|
||||
$bcc[] = config('app.checkout_test_mail');
|
||||
}else{
|
||||
} else {
|
||||
$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