Updates to 03-2025
This commit is contained in:
parent
bfa3bb1df4
commit
9ae662f63e
243 changed files with 12580 additions and 12018 deletions
|
|
@ -52,48 +52,36 @@ class BusinessStore extends Command
|
|||
*/
|
||||
public function handle()
|
||||
{
|
||||
|
||||
$executeDay = (int) Setting::getContentBySlug('day-exectute-business-structur');
|
||||
$this->info('RUN Command BusinessStore on Day: '. $executeDay);
|
||||
|
||||
$presentDay = (int) date('d');
|
||||
|
||||
$this->info('RUN Command BusinessStore on Day: '. $executeDay);
|
||||
$this->info('RUN Command BusinessStore present Day: '. $presentDay);
|
||||
|
||||
|
||||
if($executeDay !== $presentDay){
|
||||
$this->info('NOT RUN Command BusinessStore is not present Day: '. $presentDay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
$this->timeStart = microtime(true);
|
||||
//$this->info('RUN Command BusinessStore');
|
||||
$this->month = $this->argument('month');
|
||||
$this->year = $this->argument('year');
|
||||
|
||||
|
||||
if(!$this->month || !$this->year){
|
||||
$this->month = (int) date("m", strtotime("-1 month", time()));
|
||||
$this->year = (int) date("Y", strtotime("-1 month", time()));
|
||||
}
|
||||
|
||||
$this->info('RUN Command BusinessStore on month: '.$this->month.' | year: '.$this->year);
|
||||
|
||||
//erstellt die Business Struktur und die Details
|
||||
$this->storeBusinessStructureUsersDetailMonth();
|
||||
|
||||
//Struktur und die Details für mehrere Montate for / to month
|
||||
//$this->storeBusinessStructureUsersDetailPeriod(1, 6);
|
||||
|
||||
//erstellt die Gutschriften
|
||||
// Argumente mit Standardwerten für den Vormonat
|
||||
$this->month = $this->argument('month') ?: (int) date("m", strtotime("-1 month"));
|
||||
$this->year = $this->argument('year') ?: (int) date("Y", strtotime("-1 month"));
|
||||
|
||||
$this->info('RUN Command BusinessStore on month: '.$this->month.' | year: '.$this->year);
|
||||
|
||||
// Prozesse ausführen
|
||||
$this->storeBusinessStructureUsersDetailMonth();
|
||||
$this->userBusinessCommissionsToCredit();
|
||||
|
||||
//erstellt aus den Gutschriften die PDFs
|
||||
//$this->userCreatePaymentCreditsPDF();
|
||||
|
||||
//update user Level
|
||||
//$this->userLevelUpdate();
|
||||
|
||||
// Auskommentierte Prozesse
|
||||
// $this->userCreatePaymentCreditsPDF();
|
||||
// $this->userLevelUpdate();
|
||||
// $this->storeBusinessStructureUsersDetailPeriod(1, 6);
|
||||
|
||||
return 0;
|
||||
|
||||
//\Log::info('Cron is running');
|
||||
//return 0;
|
||||
}
|
||||
|
||||
private function storeBusinessStructureUsersDetailMonth(){
|
||||
|
|
@ -104,11 +92,8 @@ class BusinessStore extends Command
|
|||
$businessUsersStore->storeBusinessUsersDetail();
|
||||
$bool = $businessUsersStore->storeBusinessCompleted();
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command storeBusinessStructureUsersDetailMonth: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
$this->logExecutionTime('END Command storeBusinessStructureUsersDetailMonth: '.$bool);
|
||||
|
||||
}
|
||||
|
||||
private function userBusinessCommissionsToCredit(){
|
||||
|
|
@ -121,11 +106,8 @@ class BusinessStore extends Command
|
|||
$ret = $userPaymentCredits->addUserCreditItem($userBusiness);
|
||||
$this->info('userBusinessCredit: '.$ret->user_id.' : Team: '.$ret->commission_pp_total.' | Shop: '.$ret->commission_shop_sales);
|
||||
}
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command userBusinessCommissionsToCredit: | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
$this->logExecutionTime('END Command userBusinessCommissionsToCredit:');
|
||||
|
||||
}
|
||||
|
||||
private function userCreatePaymentCreditsPDF(){
|
||||
|
|
@ -139,11 +121,8 @@ class BusinessStore extends Command
|
|||
$this->info('creditsPDF: '.$bool.' user_id: '.$creditItemUser->user_id);
|
||||
}
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command userCreatePaymentCreditsPDF: | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
$this->logExecutionTime('END Command userCreatePaymentCreditsPDF:');
|
||||
|
||||
}
|
||||
|
||||
private function userLevelUpdate(){
|
||||
|
|
@ -162,29 +141,32 @@ class BusinessStore extends Command
|
|||
}
|
||||
|
||||
}
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info('END Command userLevelUpdate: | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
$this->logExecutionTime('END Command userLevelUpdate:');
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function storeBusinessStructureUsersDetailPeriod($for, $to){
|
||||
for($i = $for; $i<=$to; $i++){
|
||||
$month = $i;
|
||||
$this->info('Store Business Structure Users Detail month: '.$month.' year:'.$this->year);
|
||||
$businessUsersStore = new BusinessUsersStore($month, $this->year);
|
||||
|
||||
private function storeBusinessStructureUsersDetailPeriod($from, $to)
|
||||
{
|
||||
for($i = $from; $i <= $to; $i++){
|
||||
$this->info('Store Business Structure Users Detail month: '.$i.' year:'.$this->year);
|
||||
$businessUsersStore = new BusinessUsersStore($i, $this->year);
|
||||
$businessUsersStore->storeUserBusinessStructure();
|
||||
$businessUsersStore->storeBusinessUsersDetail();
|
||||
$bool = $businessUsersStore->storeBusinessCompleted();
|
||||
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
$this->info('Period BusinessStore: '.$bool. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
|
||||
$this->logExecutionTime('Period BusinessStore: '.$bool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function logExecutionTime($message)
|
||||
{
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info($message. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
664
app/Console/Commands/SubDomains.php
Normal file
664
app/Console/Commands/SubDomains.php
Normal file
|
|
@ -0,0 +1,664 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
use App\Models\UserShop;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SubDomains extends Command
|
||||
{
|
||||
/**
|
||||
* Die Signatur des Konsolenbefehls.
|
||||
*
|
||||
* Aufruf: php artisan subdomains:action --force --start=4 --debug
|
||||
* /usr/bin/php82 artisan subdomains:action --force --start=4 --create-missing --debug
|
||||
* /usr/bin/php82 artisan subdomains:action --force --debug
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'subdomains:action {user_id?} {--force} {--start=1} {--create-missing} {--debug}';
|
||||
|
||||
/**
|
||||
* Die Beschreibung des Konsolenbefehls.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Passt Parameter für die User-Subdomains an (PHP-Version, SSL)';
|
||||
|
||||
/**
|
||||
* Zeitstempel für die Ausführungszeit-Messung
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $timeStart;
|
||||
|
||||
/**
|
||||
* Standard-Domain für alle Subdomains
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $domain = 'mivita.care';
|
||||
|
||||
/**
|
||||
* Zu überspringende Subdomain-Präfixe
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $skipPrefixes = ['www.', 'api.', 'checkout.', 'preview.'];
|
||||
|
||||
/**
|
||||
* Erstellt eine neue Befehlsinstanz.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Führt den Konsolenbefehl aus.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->timeStart = microtime(true);
|
||||
|
||||
$userId = $this->argument('user_id');
|
||||
$force = $this->option('force');
|
||||
$startId = $this->option('start');
|
||||
$createMissing = $this->option('create-missing');
|
||||
$debug = $this->option('debug');
|
||||
|
||||
if ($debug) {
|
||||
$this->warn("DEBUG-MODUS (DRY-RUN): Es werden keine tatsächlichen Änderungen vorgenommen!");
|
||||
}
|
||||
|
||||
$this->info("Starte Subdomain-Verwaltung" . ($force ? " (erzwungener Modus)" : ""));
|
||||
|
||||
try {
|
||||
if ($userId) {
|
||||
$this->info("Verarbeite einzelnen Benutzer mit ID: {$userId}");
|
||||
$result = $this->syncSingleUser($userId, $force, $createMissing, $debug);
|
||||
|
||||
if ($result) {
|
||||
$this->info("Benutzer {$userId} erfolgreich synchronisiert" . ($debug ? " (simuliert)" : ""));
|
||||
} else {
|
||||
$this->warn("Benutzer {$userId} konnte nicht vollständig synchronisiert werden" . ($debug ? " (simuliert)" : ""));
|
||||
}
|
||||
} else {
|
||||
$this->info("Verarbeite alle Benutzer ab ID: {$startId}");
|
||||
$result = $this->syncAllUsers($force, $startId, $createMissing, $debug);
|
||||
|
||||
// Zusammenfassung der Ergebnisse
|
||||
$this->displaySummary($result, $debug);
|
||||
}
|
||||
|
||||
$this->logExecutionTime("Subdomain-Verwaltung abgeschlossen" . ($debug ? " (DEBUG-MODUS)" : ""));
|
||||
return 0;
|
||||
} catch (Exception $e) {
|
||||
$this->error("Ein Fehler ist aufgetreten: " . $e->getMessage());
|
||||
Log::error("Shopping User Sync Fehler: ", [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'user_id' => $userId,
|
||||
'force' => $force,
|
||||
'start_id' => $startId,
|
||||
'debug' => $debug
|
||||
]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Zeigt eine Zusammenfassung der Synchronisationsergebnisse an
|
||||
*
|
||||
* @param array $result Ergebnisdaten der Synchronisation
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return void
|
||||
*/
|
||||
private function displaySummary($result, $debug = false)
|
||||
{
|
||||
$this->line("");
|
||||
$this->info("=== Zusammenfassung " . ($debug ? "(DEBUG-MODUS)" : "") . " ===");
|
||||
$this->info("Verarbeitete Shops: " . count($result['shops']));
|
||||
$this->info("Aktualisierte PHP-Versionen: " . $result['updatedCount'] . ($debug ? " (simuliert)" : ""));
|
||||
$this->info("Aktivierte SSL-Zertifikate: " . $result['sslEnabledCount'] . ($debug ? " (simuliert)" : ""));
|
||||
$this->info("Aktualisierte SSL-Konfigurationen: " . $result['sslConfiguredCount'] . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if (!empty($result['createdSubdomains'])) {
|
||||
$this->info("Neu erstellte Subdomains: " . count($result['createdSubdomains']) . ($debug ? " (simuliert)" : ""));
|
||||
}
|
||||
|
||||
if (!empty($result['missingSubdomains'])) {
|
||||
$this->warn("Fehlende Subdomains: " . count($result['missingSubdomains']));
|
||||
}
|
||||
|
||||
if (!empty($result['unusedSubdomains'])) {
|
||||
$this->warn("Ungenutzte Subdomains: " . count($result['unusedSubdomains']));
|
||||
}
|
||||
|
||||
if (!empty($result['doubleDomains'])) {
|
||||
$this->warn("Benutzer mit mehreren Shops: " . count($result['doubleDomains']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronisiert einen einzelnen Benutzer und seine Shops
|
||||
*
|
||||
* @param int $userId Benutzer-ID
|
||||
* @param bool $force Erzwingt die Aktualisierung aller Subdomains
|
||||
* @param bool $createMissing Erstellt fehlende Subdomains
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return bool Erfolg der Operation
|
||||
*/
|
||||
private function syncSingleUser($userId, $force = false, $createMissing = false, $debug = false)
|
||||
{
|
||||
$this->info("Synchronisiere Benutzer mit ID: {$userId}");
|
||||
|
||||
// Benutzer-Shops abrufen
|
||||
$userShops = UserShop::where('user_id', $userId)->get();
|
||||
|
||||
if ($userShops->isEmpty()) {
|
||||
$this->warn("Keine Shops für Benutzer {$userId} gefunden");
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->info("Gefundene Shops für Benutzer {$userId}: " . $userShops->count());
|
||||
|
||||
// Subdomains abrufen und filtern
|
||||
$subdomains = $this->getFilteredSubdomains();
|
||||
$success = true;
|
||||
|
||||
// Benutzer-Shops durchlaufen und mit Subdomains abgleichen
|
||||
foreach ($userShops as $userShop) {
|
||||
$fullDomainName = $userShop->slug . '.' . $this->domain;
|
||||
$this->info("Verarbeite Shop: {$fullDomainName}");
|
||||
|
||||
// Prüfen, ob Subdomain existiert
|
||||
if (array_key_exists($fullDomainName, $subdomains)) {
|
||||
$success = $this->processExistingSubdomain($userShop, $subdomains[$fullDomainName], $force, $debug) && $success;
|
||||
} else {
|
||||
// Subdomain fehlt
|
||||
$this->warn("Shop {$userShop->slug}: Keine Subdomain gefunden");
|
||||
|
||||
// Optional: Neue Subdomain erstellen
|
||||
if ($createMissing) {
|
||||
$this->info("Erstelle fehlende Subdomain für Shop {$userShop->slug}" . ($debug ? " (simuliert)" : ""));
|
||||
$success = $this->createSubdomain($userShop->slug, $debug) && $success;
|
||||
} else {
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verarbeitet eine existierende Subdomain und aktualisiert sie bei Bedarf
|
||||
*
|
||||
* @param UserShop $userShop Shop-Objekt
|
||||
* @param array $subdomainInfo Subdomain-Informationen
|
||||
* @param bool $force Erzwingt die Aktualisierung
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return bool Erfolg der Operation
|
||||
*/
|
||||
private function processExistingSubdomain($userShop, $subdomainInfo, $force, $debug = false)
|
||||
{
|
||||
$success = true;
|
||||
$hasSSL = ($subdomainInfo['ssl_certificate_sni'] === 'Y' ||
|
||||
$subdomainInfo['ssl_proxy'] === 'Y');
|
||||
$sslActive = ($subdomainInfo['ssl_certificate_sni_is_active'] ?? 'N') === 'Y';
|
||||
$phpVersion = $subdomainInfo['php_version'];
|
||||
|
||||
$this->info("Shop {$userShop->slug}: PHP-Version: {$phpVersion}, SSL: " .
|
||||
($hasSSL ? "Aktiviert" : "Nicht aktiviert") .
|
||||
($hasSSL ? ", SSL aktiv: " . ($sslActive ? "Ja" : "Nein") : ""));
|
||||
|
||||
// Prüfen, ob PHP-Version aktualisiert werden muss
|
||||
$requiredPhpVersion = config('app.php_version');
|
||||
if ($force || $phpVersion !== $requiredPhpVersion) {
|
||||
$this->info("Shop {$userShop->slug}: PHP-Version aktualisieren von {$phpVersion} auf {$requiredPhpVersion}" . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if (!$debug && !$this->updateSubdomainParams($userShop->slug, $requiredPhpVersion)) {
|
||||
$this->error("PHP-Version für {$userShop->slug}.{$this->domain} konnte nicht aktualisiert werden");
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Prüfen, ob SSL aktiviert werden muss
|
||||
if ($force || !$hasSSL) {
|
||||
$this->info("Shop {$userShop->slug}: SSL aktivieren" . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if (!$debug && !$this->enableSSL($userShop->slug)) {
|
||||
$this->error("SSL für {$userShop->slug}.{$this->domain} konnte nicht aktiviert werden");
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
// Prüfen, ob SSL-Konfiguration aktualisiert werden muss
|
||||
else if ($force || ($hasSSL && !$sslActive)) {
|
||||
$this->info("Shop {$userShop->slug}: SSL-Konfiguration aktualisieren" . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if (!$debug && !$this->updateSSL($userShop->slug . '.' . $this->domain)) {
|
||||
$this->error("SSL-Konfiguration für {$userShop->slug}.{$this->domain} konnte nicht aktualisiert werden");
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronisiert alle Benutzer-Shops
|
||||
*
|
||||
* @param bool $force Erzwingt die Aktualisierung aller Subdomains
|
||||
* @param int $startId Beginnt die Synchronisation ab dieser ID
|
||||
* @param bool $createMissing Erstellt fehlende Subdomains
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return array Ergebnisdaten der Synchronisation
|
||||
*/
|
||||
private function syncAllUsers($force, $startId, $createMissing = false, $debug = false)
|
||||
{
|
||||
$this->info("Starte Synchronisation aller Benutzer-Shops ab ID: {$startId}");
|
||||
|
||||
// Benutzer-Shops abrufen
|
||||
$userShopsQuery = UserShop::query();
|
||||
|
||||
if ($startId > 1) {
|
||||
$userShopsQuery->where('id', '>=', $startId);
|
||||
}
|
||||
|
||||
$userShops = $userShopsQuery->limit(1000)->get();
|
||||
$this->info("Gefundene Benutzer-Shops: " . $userShops->count());
|
||||
|
||||
// Subdomains abrufen und filtern
|
||||
$subdomains = $this->getFilteredSubdomains();
|
||||
$this->info("Gefilterte Subdomains: " . count($subdomains));
|
||||
|
||||
// Ergebnis-Arrays initialisieren
|
||||
$doubleDomains = [];
|
||||
$missingSubdomains = [];
|
||||
$outdatedPhpVersions = [];
|
||||
$missingSSL = [];
|
||||
$sslConfigurationNeeded = [];
|
||||
$createdSubdomains = [];
|
||||
$updatedCount = 0;
|
||||
$sslEnabledCount = 0;
|
||||
$sslConfiguredCount = 0;
|
||||
|
||||
// Benutzer-Shops durchlaufen und mit Subdomains abgleichen
|
||||
foreach ($userShops as $userShop) {
|
||||
$fullDomainName = $userShop->slug . '.' . $this->domain;
|
||||
|
||||
// Status der Subdomain setzen
|
||||
$userShop->hasSubdomain = false;
|
||||
$userShop->hasSSL = false;
|
||||
$userShop->sslActive = false;
|
||||
$userShop->PHPversion = "";
|
||||
|
||||
// Prüfen, ob Subdomain existiert
|
||||
if (array_key_exists($fullDomainName, $subdomains)) {
|
||||
$userShop->hasSubdomain = true;
|
||||
$userShop->hasSSL = ($subdomains[$fullDomainName]['ssl_certificate_sni'] === 'Y' ||
|
||||
$subdomains[$fullDomainName]['ssl_proxy'] === 'Y');
|
||||
$userShop->sslActive = ($subdomains[$fullDomainName]['ssl_certificate_sni_is_active'] ?? 'N') === 'Y';
|
||||
$userShop->PHPversion = $subdomains[$fullDomainName]['php_version'];
|
||||
|
||||
// Prüfen, ob PHP-Version aktualisiert werden muss
|
||||
$requiredPhpVersion = config('app.php_version');
|
||||
if ($force || $userShop->PHPversion !== $requiredPhpVersion) {
|
||||
$this->info("Shop {$userShop->slug}: PHP-Version aktualisieren von {$userShop->PHPversion} auf {$requiredPhpVersion}" . ($debug ? " (simuliert)" : ""));
|
||||
$outdatedPhpVersions[] = $userShop->slug;
|
||||
|
||||
if (!$debug && $this->updateSubdomainParams($userShop->slug, $requiredPhpVersion)) {
|
||||
$updatedCount++;
|
||||
} else if ($debug) {
|
||||
// Im Debug-Modus zählen wir trotzdem, als ob es erfolgreich wäre
|
||||
$updatedCount++;
|
||||
}
|
||||
}else{
|
||||
$this->info("Shop {$userShop->slug}: PHP-Version ist aktuell: {$userShop->PHPversion}");
|
||||
}
|
||||
|
||||
// Prüfen, ob SSL aktiviert werden muss
|
||||
/* if ($force || !$userShop->hasSSL) {
|
||||
$this->info("Shop {$userShop->slug}: SSL aktivieren" . ($debug ? " (simuliert)" : ""));
|
||||
$missingSSL[] = $userShop->slug;
|
||||
|
||||
if (!$debug && $this->enableSSL($userShop->slug)) {
|
||||
$sslEnabledCount++;
|
||||
} else if ($debug) {
|
||||
// Im Debug-Modus zählen wir trotzdem, als ob es erfolgreich wäre
|
||||
$sslEnabledCount++;
|
||||
}
|
||||
}
|
||||
// Prüfen, ob SSL-Konfiguration aktualisiert werden muss
|
||||
else if ($force || ($userShop->hasSSL && !$userShop->sslActive)) {
|
||||
$this->info("Shop {$userShop->slug}: SSL-Konfiguration aktualisieren" . ($debug ? " (simuliert)" : ""));
|
||||
$sslConfigurationNeeded[] = $userShop->slug;
|
||||
|
||||
if (!$debug && $this->updateSSL($fullDomainName)) {
|
||||
$sslConfiguredCount++;
|
||||
} else if ($debug) {
|
||||
// Im Debug-Modus zählen wir trotzdem, als ob es erfolgreich wäre
|
||||
$sslConfiguredCount++;
|
||||
}
|
||||
}*/
|
||||
|
||||
// Subdomain aus der Liste entfernen, um später ungenutzte zu identifizieren
|
||||
unset($subdomains[$fullDomainName]);
|
||||
} else {
|
||||
// Subdomain fehlt
|
||||
$missingSubdomains[] = $userShop->slug;
|
||||
$this->warn("Shop {$userShop->slug}: Keine Subdomain gefunden");
|
||||
|
||||
// Optional: Neue Subdomain erstellen
|
||||
if ($createMissing) {
|
||||
$this->info("Erstelle fehlende Subdomain für Shop {$userShop->slug}" . ($debug ? " (simuliert)" : ""));
|
||||
if (!$debug && $this->createSubdomain($userShop->slug)) {
|
||||
$createdSubdomains[] = $userShop->slug;
|
||||
} else if ($debug) {
|
||||
// Im Debug-Modus zählen wir trotzdem, als ob es erfolgreich wäre
|
||||
$createdSubdomains[] = $userShop->slug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Doppelte Domains pro Benutzer erfassen
|
||||
$doubleDomains[$userShop->user_id][$userShop->id] = $fullDomainName;
|
||||
}
|
||||
|
||||
// Bereinigen der doppelten Domains (nur Benutzer mit mehreren Shops behalten)
|
||||
foreach ($doubleDomains as $userId => $domains) {
|
||||
if (count($domains) === 1) {
|
||||
unset($doubleDomains[$userId]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->logExecutionTime("Synchronisation abgeschlossen" . ($debug ? " (DEBUG-MODUS)" : ""));
|
||||
|
||||
// Ergebnisdaten zurückgeben
|
||||
return [
|
||||
'shops' => $userShops,
|
||||
'unusedSubdomains' => $subdomains,
|
||||
'doubleDomains' => $doubleDomains,
|
||||
'missingSubdomains' => $missingSubdomains,
|
||||
'outdatedPhpVersions' => $outdatedPhpVersions,
|
||||
'missingSSL' => $missingSSL,
|
||||
'sslConfigurationNeeded' => $sslConfigurationNeeded,
|
||||
'createdSubdomains' => $createdSubdomains,
|
||||
'updatedCount' => $updatedCount,
|
||||
'sslEnabledCount' => $sslEnabledCount,
|
||||
'sslConfiguredCount' => $sslConfiguredCount
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ruft alle Subdomains ab und filtert sie
|
||||
*
|
||||
* @return array Gefilterte Subdomains
|
||||
*/
|
||||
private function getFilteredSubdomains()
|
||||
{
|
||||
$kas = new KasController();
|
||||
$subdomains = [];
|
||||
|
||||
// Alle Subdomains abrufen
|
||||
$this->info("Rufe Subdomains von KAS ab...");
|
||||
$getSubdomains = $kas->action('get_subdomains');
|
||||
|
||||
// Subdomains filtern und in ein leicht zugängliches Array umwandeln
|
||||
foreach ($getSubdomains as $subdomain) {
|
||||
if (!isset($subdomain['subdomain_name'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Spezielle Subdomains überspringen
|
||||
$skip = false;
|
||||
foreach ($this->skipPrefixes as $prefix) {
|
||||
if (strpos($subdomain['subdomain_name'], $prefix) !== false) {
|
||||
$skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($skip) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Subdomain-Informationen speichern
|
||||
$subdomains[$subdomain['subdomain_name']] = [
|
||||
'ssl_certificate_sni' => $subdomain['ssl_certificate_sni'] ?? 'N',
|
||||
'php_version' => $subdomain['php_version'] ?? '',
|
||||
'ssl_proxy' => $subdomain['ssl_proxy'] ?? 'N',
|
||||
'ssl_certificate_sni_is_active' => $subdomain['ssl_certificate_sni_is_active'] ?? 'N',
|
||||
];
|
||||
}
|
||||
|
||||
return $subdomains;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ändert Parameter einer Subdomain, insbesondere die PHP-Version
|
||||
*
|
||||
* @param string $subdomain Name der Subdomain ohne Domain
|
||||
* @param string $phpVersion Neue PHP-Version (z.B. '8.2')
|
||||
* @param array $additionalParams Weitere zu ändernde Parameter
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return bool Erfolg der Operation
|
||||
*/
|
||||
private function updateSubdomainParams($subdomain, $phpVersion, $additionalParams = [], $debug = false)
|
||||
{
|
||||
$this->info("Aktualisiere Parameter für: {$subdomain}.{$this->domain}" . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if ($debug) {
|
||||
$this->line(" - PHP-Version: {$phpVersion}");
|
||||
if (!empty($additionalParams)) {
|
||||
$this->line(" - Zusätzliche Parameter: " . json_encode($additionalParams));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$kas = new KasController();
|
||||
|
||||
// Standardparameter
|
||||
$params = [
|
||||
'subdomain_name' => $subdomain . '.' . $this->domain, // Vollständigen Domainnamen verwenden
|
||||
'php_version' => $phpVersion
|
||||
];
|
||||
|
||||
// Oder alternativ, falls die API die Subdomain und Domain getrennt erwartet:
|
||||
// $params = [
|
||||
// 'subdomain_name' => $subdomain,
|
||||
// 'domain_name' => $this->domain,
|
||||
// 'php_version' => $phpVersion
|
||||
// ];
|
||||
|
||||
// Zusätzliche Parameter hinzufügen
|
||||
$params = array_merge($params, $additionalParams);
|
||||
|
||||
// Subdomain aktualisieren
|
||||
$result = $kas->action('update_subdomain', $params);
|
||||
$this->info("Parameter: ".json_encode($params));
|
||||
|
||||
if ($result) {
|
||||
$this->info("Parameter für {$subdomain}.{$this->domain} erfolgreich aktualisiert " . json_encode($result));
|
||||
return true;
|
||||
} else {
|
||||
$this->error("Fehler beim Aktualisieren der Parameter für {$subdomain}.{$this->domain}: " . json_encode($result));
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error("Fehler beim Aktualisieren der Parameter für {$subdomain}.{$this->domain}: " . $e->getMessage());
|
||||
Log::error("Subdomain Parameter Update Fehler", [
|
||||
'subdomain' => $subdomain,
|
||||
'domain' => $this->domain,
|
||||
'php_version' => $phpVersion,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert die SSL-Konfiguration einer Subdomain mit erweiterten Parametern
|
||||
*
|
||||
* @param string $subdomainName Vollständiger Domainname (z.B. 'shop.mivita.care')
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return bool Erfolg der Operation
|
||||
*/
|
||||
private function updateSSL($subdomainName, $debug = false)
|
||||
{
|
||||
$this->info("Aktualisiere SSL-Konfiguration für: {$subdomainName}" . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if ($debug) {
|
||||
$this->line(" - SSL-Parameter werden aktualisiert");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$kas = new KasController();
|
||||
$ssl = KasSLLController::getApiSSLParameter();
|
||||
|
||||
$params = array_merge(['hostname' => $subdomainName], $ssl);
|
||||
$result = $kas->action('update_ssl', $params);
|
||||
|
||||
if ($result === "TRUE" || $result === true) {
|
||||
$this->info("SSL-Konfiguration für {$subdomainName} erfolgreich aktualisiert");
|
||||
return true;
|
||||
} else {
|
||||
$this->warn("SSL-Konfiguration für {$subdomainName} nicht vollständig aktualisiert: " . json_encode($result));
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error("Fehler bei der SSL-Konfiguration für {$subdomainName}: " . $e->getMessage());
|
||||
Log::error("SSL Update Fehler", [
|
||||
'subdomain' => $subdomainName,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktiviert SSL für eine Subdomain mit vollständiger Konfiguration
|
||||
*
|
||||
* @param string $subdomain Name der Subdomain ohne Domain
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return bool Erfolg der Operation
|
||||
*/
|
||||
private function enableSSL($subdomain, $debug = false)
|
||||
{
|
||||
$fullDomainName = $subdomain . '.' . $this->domain;
|
||||
$this->info("Aktiviere SSL für: {$fullDomainName}" . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if ($debug) {
|
||||
$this->line(" - SSL-Proxy wird aktiviert");
|
||||
$this->line(" - HTTP zu HTTPS Weiterleitung wird eingerichtet");
|
||||
$this->line(" - SSL-Konfiguration wird aktualisiert");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Schritt 1: Subdomain-Parameter aktualisieren (ssl_proxy aktivieren)
|
||||
$subdomainResult = $this->updateSubdomainParams($subdomain, config('app.php_version'), [
|
||||
'ssl_proxy' => 'Y',
|
||||
'redirect_status' => 301 // Weiterleitung von HTTP auf HTTPS
|
||||
]);
|
||||
|
||||
if (!$subdomainResult) {
|
||||
$this->error("SSL-Aktivierung für {$fullDomainName} fehlgeschlagen: Subdomain-Parameter konnten nicht aktualisiert werden");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Schritt 2: SSL-Konfiguration aktualisieren
|
||||
$sslResult = $this->updateSSL($fullDomainName);
|
||||
|
||||
if (!$sslResult) {
|
||||
$this->warn("SSL-Aktivierung für {$fullDomainName} teilweise erfolgreich: SSL-Konfiguration konnte nicht aktualisiert werden");
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->info("SSL für {$fullDomainName} vollständig aktiviert");
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt eine neue Subdomain für einen Shop
|
||||
*
|
||||
* @param string $slug Shop-Slug
|
||||
* @param bool $debug Debug-Modus (Dry-Run)
|
||||
* @return bool Erfolg der Operation
|
||||
*/
|
||||
private function createSubdomain($slug, $debug = false)
|
||||
{
|
||||
$fullDomainName = $slug . '.' . $this->domain;
|
||||
$this->info("Erstelle neue Subdomain: {$fullDomainName}" . ($debug ? " (simuliert)" : ""));
|
||||
|
||||
if ($debug) {
|
||||
$this->line(" - Pfad: /mein.mivita.care/public/");
|
||||
$this->line(" - PHP-Version: " . config('app.php_version'));
|
||||
$this->line(" - SSL wird direkt aktiviert");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
$kas = new KasController();
|
||||
|
||||
// Parameter für die neue Subdomain
|
||||
$params = [
|
||||
'subdomain_name' => $slug,
|
||||
'domain_name' => $this->domain,
|
||||
'subdomain_path' => '/mein.mivita.care/public/',
|
||||
'php_version' => config('app.php_version'),
|
||||
];
|
||||
|
||||
// Subdomain erstellen
|
||||
$result = $kas->action('add_subdomain', $params);
|
||||
|
||||
if ($result === $fullDomainName) {
|
||||
$this->info("Subdomain {$fullDomainName} erfolgreich erstellt");
|
||||
|
||||
// SSL direkt aktivieren
|
||||
$this->enableSSL($slug);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
$this->error("Fehler beim Erstellen der Subdomain {$fullDomainName}: " . json_encode($result));
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error("Fehler beim Erstellen der Subdomain {$fullDomainName}: " . $e->getMessage());
|
||||
Log::error("Subdomain Erstellung Fehler", [
|
||||
'slug' => $slug,
|
||||
'domain' => $this->domain,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Protokolliert die Ausführungszeit einer Operation
|
||||
*
|
||||
* @param string $message Nachricht für die Protokollierung
|
||||
* @return void
|
||||
*/
|
||||
private function logExecutionTime($message)
|
||||
{
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
$this->info($message. ' | Time: '.$sec. 'sec :' . round($micro * 1000, 4) . " ms");
|
||||
}
|
||||
}
|
||||
129
app/Console/Commands/SyncShoppingUserData.php
Normal file
129
app/Console/Commands/SyncShoppingUserData.php
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\User;
|
||||
use App\Services\ShoppingUserService;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class SyncShoppingUserData extends Command
|
||||
{
|
||||
//aufruf: php artisan shopping:sync-user-data --force --start=4
|
||||
protected $signature = 'shopping:sync-user-data {user_id?} {--force} {--start=1}';
|
||||
protected $description = 'Synchronisiere Shopping User Daten für einen oder alle User';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$userId = $this->argument('user_id');
|
||||
$force = $this->option('force');
|
||||
$startId = $this->option('start');
|
||||
|
||||
try {
|
||||
if ($userId) {
|
||||
$this->syncSingleUser($userId);
|
||||
} else {
|
||||
$this->syncAllUsers($force, $startId);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error("Ein Fehler ist aufgetreten: " . $e->getMessage());
|
||||
Log::error("Shopping User Sync Fehler: ", [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function syncAllUsers($force, $startId)
|
||||
{
|
||||
$this->info("Starte Synchronisierung für alle User ab ID: {$startId}...");
|
||||
$count = 0;
|
||||
$errors = [];
|
||||
|
||||
// Aktiviere SQL Query Logging für Debugging
|
||||
DB::enableQueryLog();
|
||||
|
||||
User::where('id', '>=', $startId)
|
||||
->orderBy('id')
|
||||
->chunk(10, function($users) use (&$count, &$errors, $force) {
|
||||
foreach($users as $user) {
|
||||
try {
|
||||
$this->info("\nVerarbeite User ID: {$user->id} ({$user->email})");
|
||||
|
||||
$this->syncUser($user);
|
||||
$count++;
|
||||
|
||||
$this->info("✓ User ID {$user->id} erfolgreich synchronisiert");
|
||||
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = "Fehler bei User ID {$user->id} ({$user->email}): " . $e->getMessage();
|
||||
$errors[] = $errorMessage;
|
||||
$this->error($errorMessage);
|
||||
|
||||
// Log die letzten SQL Queries
|
||||
Log::error("Letzte SQL Queries:", [
|
||||
'queries' => DB::getQueryLog()
|
||||
]);
|
||||
|
||||
if (!$force) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$this->newLine();
|
||||
$this->info("Synchronisierung abgeschlossen!");
|
||||
$this->info("Gesamt synchronisierte User: {$count}");
|
||||
|
||||
if (count($errors) > 0) {
|
||||
$this->warn("Es gab " . count($errors) . " Fehler während der Synchronisierung:");
|
||||
foreach($errors as $error) {
|
||||
$this->warn("- " . $error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function syncUser(User $user)
|
||||
{
|
||||
try {
|
||||
$this->output->write(" Setze Faker Mail... ");
|
||||
ShoppingUserService::setFakerMail($user);
|
||||
$this->info("✓");
|
||||
|
||||
$this->output->write(" Synchronisiere Numbers... ");
|
||||
ShoppingUserService::syncNumbersByEmail($user);
|
||||
$this->info("✓");
|
||||
|
||||
$this->output->write(" Synchronisiere Orders... ");
|
||||
ShoppingUserService::syncOrdersByEmail($user);
|
||||
$this->info("✓");
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new Exception($e->getMessage() . "\n" . $e->getTraceAsString());
|
||||
}
|
||||
}
|
||||
|
||||
private function syncSingleUser($userId)
|
||||
{
|
||||
$user = User::find($userId);
|
||||
if (!$user) {
|
||||
throw new Exception("User ID {$userId} nicht gefunden");
|
||||
}
|
||||
|
||||
$this->info("Starte Synchronisierung für User ID {$userId}...");
|
||||
|
||||
try {
|
||||
$this->syncUser($user);
|
||||
$this->info("✓ Synchronisierung erfolgreich abgeschlossen");
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Fehler bei User ID {$userId}: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
292
app/Console/Commands/UserMakeAboOrder.php
Normal file
292
app/Console/Commands/UserMakeAboOrder.php
Normal file
|
|
@ -0,0 +1,292 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Setting;
|
||||
use App\Models\UserAbo;
|
||||
use App\Services\MyLog;
|
||||
use App\Services\Payment;
|
||||
use App\Cron\UserMakeOrder;
|
||||
use App\Services\AboHelper;
|
||||
use App\Models\UserAboOrder;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UserMakeAboOrder extends Command
|
||||
{
|
||||
/**
|
||||
* ln -sfv /usr/bin/php73 /usr/bin/php
|
||||
* php artisan business:store month year
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'user:make_abo_order';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Make Orders from Abos';
|
||||
|
||||
private $timeStart;
|
||||
private $month;
|
||||
private $year;
|
||||
|
||||
private $sendCreditMail = false;
|
||||
private $sendUpdateMail = false;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->timeStart = microtime(true);
|
||||
Log::info('UserMakeAboOrder: Befehl gestartet');
|
||||
$this->info('RUN Command user:make_abo_order');
|
||||
|
||||
try {
|
||||
$this->checkAbosToOrder();
|
||||
$executionTime = $this->getExecutionTime();
|
||||
Log::info("UserMakeAboOrder: Befehl erfolgreich abgeschlossen in {$executionTime}");
|
||||
$this->info("Befehl erfolgreich abgeschlossen in {$executionTime}");
|
||||
|
||||
return 0;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('UserMakeAboOrder: Fehler beim Ausführen des Befehls', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
$this->error('Fehler beim Ausführen des Befehls: ' . $e->getMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft alle Abos, die heute fällig sind und erstellt Bestellungen
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function checkAbosToOrder()
|
||||
{
|
||||
$dateNow = Carbon::now()->format('Y-m-d');
|
||||
|
||||
Log::info('UserMakeAboOrder: Suche nach fälligen Abos für Datum', ['date' => $dateNow]);
|
||||
|
||||
$userAbos = UserAbo::where('next_date', '=', $dateNow)
|
||||
->where('active', true)
|
||||
->get();
|
||||
|
||||
$count = $userAbos->count();
|
||||
Log::info("UserMakeAboOrder: {$count} fällige Abos gefunden");
|
||||
$this->info("Gefundene fällige Abos: {$count}");
|
||||
|
||||
foreach ($userAbos as $userAbo) {
|
||||
Log::info('UserMakeAboOrder: Verarbeite Abo', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'payone_userid' => $userAbo->payone_userid
|
||||
]);
|
||||
|
||||
$this->info("Verarbeite Abo: {$userAbo->id} (PayoneUserid: {$userAbo->payone_userid})");
|
||||
|
||||
try {
|
||||
$shoppingOrder = $this->makeOrder($userAbo);
|
||||
|
||||
if ($shoppingOrder) {
|
||||
Log::info('UserMakeAboOrder: Bestellung erstellt', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'order_id' => $shoppingOrder->id
|
||||
]);
|
||||
$this->info("Bestellung erstellt: {$shoppingOrder->id}");
|
||||
} else {
|
||||
Log::warning('UserMakeAboOrder: Keine Bestellung erstellt für Abo', ['abo_id' => $userAbo->id]);
|
||||
$this->warn("Keine Bestellung erstellt für Abo: {$userAbo->id}");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('UserMakeAboOrder: Fehler bei der Verarbeitung des Abos', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
$this->error("Fehler bei Abo {$userAbo->id}: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt eine Bestellung für ein Abo
|
||||
*
|
||||
* @param UserAbo $userAbo
|
||||
* @return mixed
|
||||
*/
|
||||
private function makeOrder($userAbo)
|
||||
{
|
||||
Log::info('UserMakeAboOrder: Starte Bestellungserstellung', ['abo_id' => $userAbo->id]);
|
||||
$this->info('Starte Bestellungserstellung für Abo: ' . $userAbo->id);
|
||||
|
||||
$shoppingOrder = null;
|
||||
$userOrder = new UserMakeOrder($userAbo);
|
||||
|
||||
try {
|
||||
if (!$userOrder->createShoppingUser()) {
|
||||
Log::error('UserMakeAboOrder: Konnte Shopping-User nicht erstellen', ['abo_id' => $userAbo->id]);
|
||||
$this->error("Konnte Shopping-User für Abo {$userAbo->id} nicht erstellen");
|
||||
return null;
|
||||
}
|
||||
|
||||
$shoppingOrder = $userOrder->makeShoppingOrder();
|
||||
if (!$shoppingOrder) {
|
||||
Log::error('UserMakeAboOrder: Konnte Bestellung nicht erstellen', ['abo_id' => $userAbo->id]);
|
||||
$this->error("Konnte Bestellung für Abo {$userAbo->id} nicht erstellen");
|
||||
return null;
|
||||
}
|
||||
|
||||
Log::info('UserMakeAboOrder: Bestellung erstellt, starte Zahlungsvorgang', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'order_id' => $shoppingOrder->id
|
||||
]);
|
||||
|
||||
$response = $userOrder->makePayment();
|
||||
$this->info('makePayment response: ' . json_encode($response));
|
||||
|
||||
if (!isset($response['status'])) {
|
||||
Log::error('UserMakeAboOrder: Ungültige Zahlungsantwort', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'order_id' => $shoppingOrder->id,
|
||||
'response' => $response
|
||||
]);
|
||||
$this->error("Ungültige Zahlungsantwort für Abo {$userAbo->id}");
|
||||
return $shoppingOrder;
|
||||
}
|
||||
|
||||
if ($response['status'] === 'APPROVED') {
|
||||
Log::info('UserMakeAboOrder: Zahlung erfolgreich', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'order_id' => $shoppingOrder->id,
|
||||
'response' => $response
|
||||
]);
|
||||
$this->info("Zahlung erfolgreich für Abo {$userAbo->id}");
|
||||
$this->updateAbo($userAbo, $shoppingOrder, 1);
|
||||
} elseif ($response['status'] === 'ERROR') {
|
||||
Log::error('UserMakeAboOrder: Zahlungsfehler', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'order_id' => $shoppingOrder->id,
|
||||
'error' => $response
|
||||
]);
|
||||
$this->error("Zahlungsfehler für Abo {$userAbo->id}");
|
||||
|
||||
MyLog::writeLog(
|
||||
'userabo',
|
||||
'error',
|
||||
'Error:3002 App\Console\Commands\UserMakeAboOrder::makeOrder / makePayment Error response',
|
||||
$response
|
||||
);
|
||||
|
||||
$this->updateAbo($userAbo, $shoppingOrder, 3);
|
||||
|
||||
$shoppingPayment = $userOrder->getShoppingPayment();
|
||||
$data = [
|
||||
'mode' => $shoppingPayment->mode,
|
||||
'txaction' => 'error',
|
||||
'send_link' => false,
|
||||
'payment_error' => $response,
|
||||
];
|
||||
|
||||
Payment::paymentStatusSendMail($shoppingOrder, $shoppingPayment, $data);
|
||||
} else {
|
||||
Log::warning('UserMakeAboOrder: Unbekannter Zahlungsstatus', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'order_id' => $shoppingOrder->id,
|
||||
'status' => $response['status']
|
||||
]);
|
||||
$this->warn("Unbekannter Zahlungsstatus für Abo {$userAbo->id}: {$response['status']}");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
Log::error('UserMakeAboOrder: Ausnahme bei der Bestellungserstellung', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
]);
|
||||
$this->error("Ausnahme bei Abo {$userAbo->id}: " . $e->getMessage());
|
||||
}
|
||||
|
||||
return $shoppingOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktualisiert das Abo nach einer Bestellung
|
||||
*
|
||||
* @param UserAbo $userAbo
|
||||
* @param mixed $shoppingOrder
|
||||
* @param int $status
|
||||
* @return void
|
||||
*/
|
||||
private function updateAbo($userAbo, $shoppingOrder, $status = 1)
|
||||
{
|
||||
Log::info('UserMakeAboOrder: Aktualisiere Abo', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'order_id' => $shoppingOrder->id,
|
||||
'status' => $status
|
||||
]);
|
||||
|
||||
$this->info("Aktualisiere Abo: {$userAbo->id} mit Status {$status}");
|
||||
|
||||
$updateData = [
|
||||
'next_date' => AboHelper::setNextDate(now(), $userAbo->abo_interval),
|
||||
'last_date' => now(),
|
||||
];
|
||||
|
||||
if ($status !== 1) {
|
||||
$updateData['status'] = $status;
|
||||
}
|
||||
|
||||
try {
|
||||
$userAbo->update($updateData);
|
||||
|
||||
UserAboOrder::create([
|
||||
'user_abo_id' => $userAbo->id,
|
||||
'shopping_order_id' => $shoppingOrder->id,
|
||||
'status' => $status,
|
||||
]);
|
||||
|
||||
Log::info('UserMakeAboOrder: Abo erfolgreich aktualisiert', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'next_date' => $updateData['next_date']
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('UserMakeAboOrder: Fehler beim Aktualisieren des Abos', [
|
||||
'abo_id' => $userAbo->id,
|
||||
'error' => $e->getMessage()
|
||||
]);
|
||||
$this->error("Fehler beim Aktualisieren des Abos {$userAbo->id}: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet die Ausführungszeit
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getExecutionTime()
|
||||
{
|
||||
$diff = microtime(true) - $this->timeStart;
|
||||
$sec = intval($diff);
|
||||
$micro = $diff - $sec;
|
||||
|
||||
return $sec . ' Sekunden und ' . round($micro * 1000, 2) . ' ms';
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ class UserRestore extends Command
|
|||
{
|
||||
/**
|
||||
* ln -sfv /usr/bin/php73 /usr/bin/php
|
||||
* php artisan business:store month year
|
||||
* php artisan user:restore {user_id}
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
|
|
|
|||
203
app/Cron/UserMakeOrder.php
Normal file
203
app/Cron/UserMakeOrder.php
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
<?php
|
||||
namespace App\Cron;
|
||||
|
||||
use Yard;
|
||||
use App\User;
|
||||
use stdClass;
|
||||
use App\Services\Shop;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserAbo;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\UserService;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Http\Controllers\Pay\PayoneController;
|
||||
use App\Services\AboOrderCart;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UserMakeOrder
|
||||
{
|
||||
private $userAbo;
|
||||
private $shopping_user;
|
||||
private $shopping_order;
|
||||
private $is_for;
|
||||
private $user;
|
||||
private $pay;
|
||||
|
||||
|
||||
public function __construct(UserAbo $userAbo)
|
||||
{
|
||||
$this->userAbo = $userAbo;
|
||||
Log::info('UserMakeOrder initialisiert für UserAbo ID: ' . $userAbo->id);
|
||||
}
|
||||
|
||||
|
||||
public function checkProducts()
|
||||
{
|
||||
Log::info('Überprüfe Produkte für UserAbo ID: ' . $this->userAbo->id);
|
||||
$ret = [];
|
||||
|
||||
if (!$this->userAbo->items || $this->userAbo->items->isEmpty()) {
|
||||
Log::warning('Keine Artikel für UserAbo ID: ' . $this->userAbo->id . ' gefunden');
|
||||
return $ret;
|
||||
}
|
||||
//preise prüfen, ob sie sich geändert haben?
|
||||
foreach($this->userAbo->items as $item){
|
||||
$ret[] = [
|
||||
'product_id' => $item->product_id,
|
||||
'comp' => $item->comp,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => $item->price_net,
|
||||
'tax_rate' => $item->tax_rate,
|
||||
'tax' => $item->tax,
|
||||
'price_vk_net' => $item->price_vk_net,
|
||||
'discount' => $item->discount,
|
||||
'points' => $item->points,
|
||||
];
|
||||
}
|
||||
|
||||
Log::info('Produkte überprüft: ' . count($ret) . ' Artikel gefunden');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function makePayment()
|
||||
{
|
||||
Log::info('Starte Zahlungsvorgang für UserAbo ID: ' . $this->userAbo->id);
|
||||
|
||||
try {
|
||||
$this->pay = new PayoneController();
|
||||
$this->pay->init($this->shopping_user, $this->shopping_order);
|
||||
$amount = $this->shopping_order->subtotal_ws * 100;
|
||||
$this->pay->setAboPayment($this->userAbo, $amount, 'EUR');
|
||||
$this->pay->setPersonalData();
|
||||
$response = $this->pay->ResponseData(true);
|
||||
|
||||
Log::info('Zahlungsvorgang abgeschlossen für UserAbo ID: ' . $this->userAbo->id . ', Status: ' . ($response->status ?? 'unbekannt'));
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Fehler bei Zahlungsvorgang für UserAbo ID: ' . $this->userAbo->id . ': ' . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
public function getShoppingPayment()
|
||||
{
|
||||
Log::info('Rufe Zahlungsinformationen ab für UserAbo ID: ' . $this->userAbo->id);
|
||||
|
||||
if($this->pay){
|
||||
$payment = $this->pay->getShoppingPayment();
|
||||
Log::info('Zahlungsinformationen abgerufen: ' . ($payment ? 'erfolgreich' : 'nicht verfügbar'));
|
||||
return $payment;
|
||||
}
|
||||
|
||||
Log::warning('Keine Zahlungsinformationen verfügbar für UserAbo ID: ' . $this->userAbo->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function createShoppingUser()
|
||||
{
|
||||
Log::info('Erstelle Shopping-User für UserAbo ID: ' . $this->userAbo->id);
|
||||
//hier muss der letzte shopping_user verwendet werden
|
||||
try {
|
||||
$this->shopping_user = AboOrderCart::makeCustomerDetail($this->userAbo);
|
||||
$this->shopping_user->created_at = now();
|
||||
$this->shopping_user->updated_at = now();
|
||||
$this->shopping_user->save();
|
||||
|
||||
Log::info('Shopping-User erstellt für UserAbo ID: ' . $this->userAbo->id . ', Neue User-ID: ' . $this->shopping_user->id);
|
||||
return $this->shopping_user;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Fehler beim Erstellen des Shopping-Users für UserAbo ID: ' . $this->userAbo->id . ': ' . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
||||
Log::warning('Kein Shopping-User verfügbar für UserAbo ID: ' . $this->userAbo->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
public function makeShoppingOrder()
|
||||
{
|
||||
Log::info('Erstelle Bestellung für UserAbo ID: ' . $this->userAbo->id);
|
||||
|
||||
try {
|
||||
if (!$this->shopping_user) {
|
||||
Log::error('Kein Shopping-User verfügbar für Bestellerstellung, UserAbo ID: ' . $this->userAbo->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
AboOrderCart::initYard($this->userAbo, $this->shopping_user);
|
||||
//hier wird die Bestellung erstellt inkl aktueller Preise
|
||||
AboOrderCart::makeOrderYard($this->userAbo);
|
||||
|
||||
$yard = Yard::instance('shopping');
|
||||
|
||||
if (!$this->userAbo->shopping_user || !$this->userAbo->shopping_user->shopping_order || !$this->userAbo->shopping_user->shopping_order->user_shop) {
|
||||
Log::error('Fehlende Beziehungsdaten für Bestellerstellung, UserAbo ID: ' . $this->userAbo->id);
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->shopping_order = ShoppingOrder::create([
|
||||
'shopping_user_id' => $this->shopping_user->id,
|
||||
'auth_user_id' => $this->shopping_user->auth_user_id,
|
||||
'country_id' => $yard->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'user_shop_id' => $this->userAbo->shopping_user->shopping_order->user_shop->id,
|
||||
'payment_for' => $this->shopping_user->getOrderPaymentFor(),
|
||||
'total' => $yard->total(2, '.', ''),
|
||||
'subtotal' => $yard->subtotal(2, '.', ''),
|
||||
'shipping' => $yard->shipping(2, '.', ','),
|
||||
'shipping_net' => $yard->shippingNet(2, '.', ''),
|
||||
'subtotal_ws' => $yard->subtotalWithShipping(2, '.', ''),
|
||||
'tax' => $yard->taxWithShipping(2, '.', ''),
|
||||
'total_shipping' => $yard->totalWithShipping(2, '.', ''),
|
||||
'points' => $yard->points(),
|
||||
'weight' => $yard->weight(),
|
||||
'is_abo' => 1,
|
||||
'abo_interval' => 0,
|
||||
'txaction' => 'prev',
|
||||
'mode' => $this->userAbo->shopping_user->shopping_order->mode,
|
||||
]);
|
||||
|
||||
Log::info('Bestellung erstellt für UserAbo ID: ' . $this->userAbo->id . ', Bestellnummer: ' . $this->shopping_order->id);
|
||||
|
||||
$items = $yard->getContentByOrder();
|
||||
$itemCount = 0;
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $this->shopping_order->id)->where('row_id', $item->rowId)->count()){
|
||||
$price_net = $yard->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
$data = [
|
||||
'shopping_order_id' => $this->shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $this->shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $item->options->no_commission ? 0 : $this->shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug
|
||||
];
|
||||
ShoppingOrderItem::create($data);
|
||||
$itemCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Log::info('Bestellpositionen hinzugefügt für UserAbo ID: ' . $this->userAbo->id . ', Anzahl: ' . $itemCount);
|
||||
|
||||
$this->shopping_order->makeTaxSplit();
|
||||
Log::info('Steueraufteilung für Bestellung abgeschlossen, UserAbo ID: ' . $this->userAbo->id);
|
||||
|
||||
return $this->shopping_order;
|
||||
} catch (\Exception $e) {
|
||||
Log::error('Fehler bei Bestellerstellung für UserAbo ID: ' . $this->userAbo->id . ': ' . $e->getMessage());
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
151
app/Http/Controllers/Admin/AboController.php
Normal file
151
app/Http/Controllers/Admin/AboController.php
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Request;
|
||||
use App\Services\Shop;
|
||||
use App\Models\UserAbo;
|
||||
use App\Services\AboOrderCart;
|
||||
use App\Repositories\AboRepository;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
|
||||
class AboController extends Controller
|
||||
{
|
||||
protected $aboRepository;
|
||||
|
||||
public function __construct(AboRepository $aboRepository)
|
||||
{
|
||||
$this->middleware('admin');
|
||||
$this->aboRepository = $aboRepository;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (Request::get('reset') === 'filter') {
|
||||
set_user_attr('filter_user_shop_id', null);
|
||||
set_user_attr('filter_status', null);
|
||||
set_user_attr('filter_member_id', null);
|
||||
return redirect(route('admin_sales_customers'));
|
||||
}
|
||||
|
||||
//$filter_user_shops = UserAbo::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->orderBy('slug')->get()->pluck('slug', 'id')->unique()->toArray();
|
||||
$filter_members = UserAbo::join('users', 'user_id', '=', 'users.id')->groupBy('user_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
|
||||
$data = [
|
||||
//'filter_user_shops' => $filter_user_shops,
|
||||
'filter_members' => $filter_members,
|
||||
];
|
||||
return view('admin.abo.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
$user_abo = UserAbo::findOrFail($id);
|
||||
|
||||
//init Yard
|
||||
AboOrderCart::initYard($user_abo);
|
||||
$customer_detail = AboOrderCart::getCustomerDetail();
|
||||
AboOrderCart::makeOrderYard($user_abo);
|
||||
|
||||
$comp_products = [];
|
||||
if ($user_abo->is_for === 'me') {
|
||||
$comp_products = Shop::getCompProducts('abo-me');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_abo' => $user_abo,
|
||||
'isAdmin' => true,
|
||||
'customer_detail' => $customer_detail,
|
||||
'view' => $user_abo->is_for,
|
||||
'comp_products' => $comp_products,
|
||||
];
|
||||
return view('admin.abo.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$data = Request::all();
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'abo_update_settings') {
|
||||
$user_abo = UserAbo::findOrFail($data['id']);
|
||||
$this->aboRepository->setModel($user_abo);
|
||||
$this->aboRepository->update($data);
|
||||
return redirect(route('admin_abos_detail', [$id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = UserAbo::with('user_abo_orders')->with('shopping_user')->select('user_abos.*');
|
||||
|
||||
set_user_attr('filter_member_id', Request::get('filter_member_id'));
|
||||
if (Request::get('filter_member_id') != "") {
|
||||
$query->where('user_id', '=', Request::get('filter_member_id'));
|
||||
}
|
||||
|
||||
set_user_attr('filter_status', Request::get('filter_status'));
|
||||
if (Request::get('filter_status') != "") {
|
||||
$query->where('status', '=', Request::get('filter_status'));
|
||||
}
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserAbo $user_abo) {
|
||||
return '<a href="' . route('admin_abos_detail', [$user_abo->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('start_date', function (UserAbo $user_abo) {
|
||||
return $user_abo->start_date;
|
||||
})
|
||||
->addColumn('next_date', function (UserAbo $user_abo) {
|
||||
return $user_abo->next_date;
|
||||
})
|
||||
->addColumn('abo_interval', function (UserAbo $user_abo) {
|
||||
return \App\Services\HTMLHelper::getAboStrLang($user_abo->abo_interval);
|
||||
})
|
||||
->addColumn('status', function (UserAbo $user_abo) {
|
||||
return $user_abo->getStatusFormated();
|
||||
})
|
||||
->addColumn('active', function (UserAbo $user_abo) {
|
||||
return get_active_badge($user_abo->active);
|
||||
})
|
||||
|
||||
->addColumn('is_for', function (UserAbo $user_abo) {
|
||||
return $user_abo->getIsForFormated();
|
||||
})
|
||||
->addColumn('count', function (UserAbo $user_abo) {
|
||||
return $user_abo->getCountOrders();
|
||||
})
|
||||
->addColumn('amount', function (UserAbo $user_abo) {
|
||||
return $user_abo->getFormattedAmount() . ' €';
|
||||
})
|
||||
->addColumn('payment', function (UserAbo $user_abo) {
|
||||
return $user_abo->getPaymentType();
|
||||
})
|
||||
->addColumn('member', function (UserAbo $user_abo) {
|
||||
if (isset($user_abo->shopping_user) && $user_abo->shopping_user->member_id > 0) {
|
||||
return '<a href="' . route('admin_lead_edit', [$user_abo->shopping_user->member_id]) . '">' . $user_abo->shopping_user->member->getFullName() . '</a>';
|
||||
}
|
||||
})
|
||||
->addColumn('payone_userid', function (UserAbo $user_abo) {
|
||||
return $user_abo->payone_userid;
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('start_date', 'start_date $1')
|
||||
->orderColumn('next_date', 'next_date $1')
|
||||
->orderColumn('abo_interval', 'abo_interval $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
->orderColumn('active', 'active $1')
|
||||
->orderColumn('is_for', 'is_for $1')
|
||||
->orderColumn('count', 'count $1')
|
||||
->orderColumn('amount', 'amount $1')
|
||||
->orderColumn('payone_userid', 'payone_userid $1')
|
||||
->rawColumns(['id', 'status', 'active', 'is_for', 'member'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class KasController extends Controller
|
|||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
catch (\SoapFault $fault)
|
||||
{
|
||||
trigger_error(" Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
|
|
@ -88,7 +88,7 @@ class KasController extends Controller
|
|||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (SoapFault $fault)
|
||||
catch (\SoapFault $fault)
|
||||
{
|
||||
trigger_error("Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
|
|
|
|||
|
|
@ -8,48 +8,38 @@ use App\Http\Controllers\Controller;
|
|||
class KasSLLController extends Controller
|
||||
{
|
||||
|
||||
private static $ssl_certificate_sni_csr = "-----BEGIN CERTIFICATE REQUEST-----
|
||||
MIIBfzCCASUCAQAwgYoxCzAJBgNVBAYTAkRFMQ4wDAYDVQQRDAU4Nzc1NTEPMA0G
|
||||
A1UECAwGQmF5ZXJuMRUwEwYDVQQHDAxLaXJjaGhhc2xhY2gxEzARBgNVBAkMCkxl
|
||||
aW5mZWxkIDIxFjAUBgNVBAoMDXJpd2EtdGVjIGUuSy4xFjAUBgNVBAMMDSoubWl2
|
||||
aXRhLmNhcmUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATHOCZrM/6Ry1iMHtpL
|
||||
3OM+nm2NZJwbT91yWM25yaxXkkfgaKxfvjfTSgK3Yl/nE+cSrijT4BdP7H3U2ZnZ
|
||||
Rg0FoDgwNgYJKoZIhvcNAQkOMSkwJzAlBgNVHREEHjAcgg0qLm1pdml0YS5jYXJl
|
||||
ggttaXZpdGEuY2FyZTAKBggqhkjOPQQDBANIADBFAiEAva2vcfT1l/NvrMdFrujf
|
||||
pFrbXTZMecYsa9SDnHXhp1gCIG8BFZSN/mPjM3EZXunj4bb1AXqqdxe+VjPiw6VL
|
||||
lZwE
|
||||
-----END CERTIFICATE REQUEST-----";
|
||||
private static $ssl_certificate_sni_csr = "";
|
||||
private static $ssl_certificate_sni_key = "-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgGd8N4RsRov6Kd81z
|
||||
iclbCpD5e7nT1cTN2u8XQZRU/1ChRANCAATHOCZrM/6Ry1iMHtpL3OM+nm2NZJwb
|
||||
T91yWM25yaxXkkfgaKxfvjfTSgK3Yl/nE+cSrijT4BdP7H3U2ZnZRg0F
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgohGr2e3ysw/Awvzh
|
||||
qkqDS4iQgRvWwNIYxTcPxpdcndGhRANCAASZjlV2bQbLQrOveMlYOowR3IlfND7z
|
||||
OxauFGabhvWSU1cg2w4U4bu/QXnDXfHHkcLp4M5WgHzX9Nw2m/abyJJ6
|
||||
-----END PRIVATE KEY-----";
|
||||
private static $ssl_certificate_sni_crt = "-----BEGIN CERTIFICATE-----
|
||||
MIIEpzCCBEygAwIBAgIRAOdJ/xXHharlPCF26cIYht0wCgYIKoZIzj0EAwIwgY8x
|
||||
CzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNV
|
||||
BAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE3MDUGA1UEAxMu
|
||||
U2VjdGlnbyBFQ0MgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBDQTAe
|
||||
Fw0yMzA3MzEwMDAwMDBaFw0yNDA4MzAyMzU5NTlaMBgxFjAUBgNVBAMMDSoubWl2
|
||||
aXRhLmNhcmUwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATHOCZrM/6Ry1iMHtpL
|
||||
3OM+nm2NZJwbT91yWM25yaxXkkfgaKxfvjfTSgK3Yl/nE+cSrijT4BdP7H3U2ZnZ
|
||||
Rg0Fo4IC/TCCAvkwHwYDVR0jBBgwFoAU9oUKOxGG4QR9DqoLLNLuzGR7e64wHQYD
|
||||
VR0OBBYEFJco1/8VAvZA85Ct2Z/7XSA+DKNUMA4GA1UdDwEB/wQEAwIHgDAMBgNV
|
||||
HRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBJBgNVHSAE
|
||||
QjBAMDQGCysGAQQBsjEBAgIHMCUwIwYIKwYBBQUHAgEWF2h0dHBzOi8vc2VjdGln
|
||||
by5jb20vQ1BTMAgGBmeBDAECATCBhAYIKwYBBQUHAQEEeDB2ME8GCCsGAQUFBzAC
|
||||
hkNodHRwOi8vY3J0LnNlY3RpZ28uY29tL1NlY3RpZ29FQ0NEb21haW5WYWxpZGF0
|
||||
aW9uU2VjdXJlU2VydmVyQ0EuY3J0MCMGCCsGAQUFBzABhhdodHRwOi8vb2NzcC5z
|
||||
ZWN0aWdvLmNvbTAlBgNVHREEHjAcgg0qLm1pdml0YS5jYXJlggttaXZpdGEuY2Fy
|
||||
ZTCCAX8GCisGAQQB1nkCBAIEggFvBIIBawFpAHcAdv+IPwq2+5VRwmHM9Ye6NLSk
|
||||
zbsp3GhCCp/mZ0xaOnQAAAGJquwmHwAABAMASDBGAiEA7/7/S0CxtvREygwS3qR5
|
||||
THaAwfObqF09zN4AE+rjGSQCIQDNat5O0VSbx+cwaNrrVWz86C0PnUufqWNkBVEa
|
||||
5XM0bQB2ANq2v2s/tbYin5vCu1xr6HCRcWy7UYSFNL2kPTBI1/urAAABiarsJnYA
|
||||
AAQDAEcwRQIhAMkJ4iRoexvBzGa7zuHLn0/R4iDvUstKVb7ZK1XqjuVQAiACwcKG
|
||||
5WNIIeTjJ+CNDeME8mqHpgbFNWIAiiz0u+ANZwB2AO7N0GTV2xrOxVy3nbTNE6Iy
|
||||
h0Z8vOzew1FIWUZxH7WbAAABiarsJmEAAAQDAEcwRQIgVVxidEYEx6g2xLxAcI57
|
||||
eKJ4NDol/bnhmb0iERQmXOoCIQDf6Hviv4+SO+K3OoxxLI9qzFHNP6sb6aDaXfTW
|
||||
ucyTtTAKBggqhkjOPQQDAgNJADBGAiEA4hOvVoXr58YPVGi5/UEEnyDXlUfX4ZKq
|
||||
9PmblI2ZQVkCIQDRllVwklX+DUBcvzG6hapvn5Wv2171yIeoJo+vm7UO5g==
|
||||
MIIEpDCCBEqgAwIBAgIQVIm0T0SQ6D20YQxMaHEKbDAKBggqhkjOPQQDAjCBjzEL
|
||||
MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE
|
||||
BxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQDEy5T
|
||||
ZWN0aWdvIEVDQyBEb21haW4gVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMB4X
|
||||
DTI0MDgwMTAwMDAwMFoXDTI1MDkwMTIzNTk1OVowGDEWMBQGA1UEAwwNKi5taXZp
|
||||
dGEuY2FyZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJmOVXZtBstCs694yVg6
|
||||
jBHciV80PvM7Fq4UZpuG9ZJTVyDbDhThu79BecNd8ceRwungzlaAfNf03Dab9pvI
|
||||
knqjggL8MIIC+DAfBgNVHSMEGDAWgBT2hQo7EYbhBH0Oqgss0u7MZHt7rjAdBgNV
|
||||
HQ4EFgQUVCkHH2AasJQFWFs63rdcb6BRvyowDgYDVR0PAQH/BAQDAgeAMAwGA1Ud
|
||||
EwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMEkGA1UdIARC
|
||||
MEAwNAYLKwYBBAGyMQECAgcwJTAjBggrBgEFBQcCARYXaHR0cHM6Ly9zZWN0aWdv
|
||||
LmNvbS9DUFMwCAYGZ4EMAQIBMIGEBggrBgEFBQcBAQR4MHYwTwYIKwYBBQUHMAKG
|
||||
Q2h0dHA6Ly9jcnQuc2VjdGlnby5jb20vU2VjdGlnb0VDQ0RvbWFpblZhbGlkYXRp
|
||||
b25TZWN1cmVTZXJ2ZXJDQS5jcnQwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLnNl
|
||||
Y3RpZ28uY29tMCUGA1UdEQQeMByCDSoubWl2aXRhLmNhcmWCC21pdml0YS5jYXJl
|
||||
MIIBfgYKKwYBBAHWeQIEAgSCAW4EggFqAWgAdgDd3Mo0ldfhFgXnlTL6x5/4PRxQ
|
||||
39sAOhQSdgosrLvIKgAAAZEMky0iAAAEAwBHMEUCICSH9TLHP8tqMyBTBpxF1+lw
|
||||
4wAnWf4E5pPJ6651S8P9AiEAkKqOQDaVdoFI1+jM28grXnG5o0vFLUwa0o49KYQ3
|
||||
k+sAdgAN4fIwK9MNwUBiEgnqVS78R3R8sdfpMO8OQh60fk6qNAAAAZEMkyzbAAAE
|
||||
AwBHMEUCIFJfJS4cojUm9nHQ1TVlxpFwOV7QwCj9MOfq0CCkVzsGAiEA8WQrE1ri
|
||||
kJkeIVPSgUVJpIz8TKef2aR+Ivzkzon52QIAdgAS8U40vVNyTIQGGcOPP3oT+Oe1
|
||||
YoeInG0wBYTr5YYmOgAAAZEMkyzBAAAEAwBHMEUCIQCH8/qTmCNea3FdBVk0c3Wu
|
||||
FrvYnoQlTQaaDS/zeTxSzwIge6VO5Aeor30Wu675zBYzNsIru5gXOTl4dteBMYnC
|
||||
0JswCgYIKoZIzj0EAwIDSAAwRQIhAKxmgpPqW6UAcWHCoWAPN673pBMxnCKn3vFq
|
||||
wUkhGrT7AiBDUsDuMhabsGlZ10X2GXcm+1mwxdMLSDYEWiwk5fUaNA==
|
||||
-----END CERTIFICATE-----";
|
||||
private static $ssl_certificate_sni_bundle = "-----BEGIN CERTIFICATE-----
|
||||
MIIDqDCCAy6gAwIBAgIRAPNkTmtuAFAjfglGvXvh9R0wCgYIKoZIzj0EAwMwgYgx
|
||||
|
|
|
|||
|
|
@ -3,13 +3,17 @@
|
|||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Shop;
|
||||
use App\Services\Util;
|
||||
use App\Models\UserAbo;
|
||||
use App\Services\MyLog;
|
||||
use App\Services\Payment;
|
||||
use App\Services\AboHelper;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
use App\Models\PaymentTransaction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\ShoppingUserService;
|
||||
|
||||
|
||||
class PayoneController extends Controller
|
||||
|
|
@ -41,47 +45,60 @@ class PayoneController extends Controller
|
|||
*/
|
||||
|
||||
if(!isset($data['key']) || !isset($data['param']) || !isset($data['userid']) || !isset($data['txid']) || !isset($data['reference']) || !isset($data['price'])){
|
||||
\Log::channel('payone')->error('PaymentStatus: parameter incomplete: '.json_encode($data));
|
||||
echo "PaymentStatus: parameter incomplete:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2001 App\Http\Controllers\Api\PayoneController::paymentStatus parameter incomplete',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($data['key'] != config('payone.defaults.key')) {
|
||||
\Log::channel('payone')->error('PaymentStatus: Key error: '.json_encode($data));
|
||||
echo "PaymentStatus: Key error:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2002 App\Http\Controllers\Api\PayoneController::paymentStatus Key error',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
$shopping_order = ShoppingOrder::find($data['param']);
|
||||
if(!$shopping_order){
|
||||
\Log::channel('payone')->error('PaymentStatus: ShoppingOrder not found: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingOrder not found:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2003 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingOrder not found:',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
$shopping_payment = ShoppingPayment::where('reference', $data['reference'])->first();
|
||||
if(!$shopping_payment){
|
||||
\Log::channel('payone')->error('PaymentStatus: ShoppingPayment not found: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingPayment not found:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2004 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingPayment not found',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
if($shopping_payment->shopping_order_id != $shopping_order->id){
|
||||
\Log::channel('payone')->error('PaymentStatus: ShoppingPayment no realation ShoppingOrder: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingPayment no realation ShoppingOrder:";
|
||||
var_dump($data);
|
||||
die();
|
||||
}
|
||||
|
||||
if($data['key'] != config('payone.defaults.key')) {
|
||||
\Log::channel('payone')->error('PaymentStatus: Key error: '.json_encode($data));
|
||||
echo "PaymentStatus: ShoppingPayment no realation ShoppingOrder:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2005 App\Http\Controllers\Api\PayoneController::paymentStatus ShoppingPayment no realation ShoppingOrder',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
$price = number_format((round($data['price'],2) * 100), 0, '.', '');
|
||||
|
|
@ -89,21 +106,39 @@ class PayoneController extends Controller
|
|||
if($price_amount != $price){
|
||||
$data['shopping_payment-amount'] = $price_amount;
|
||||
$data['price-amount'] = $price;
|
||||
\Log::channel('payone')->error('PaymentStatus: Price error: '.json_encode($data));
|
||||
echo "PaymentStatus: Price error:";
|
||||
var_dump($data);
|
||||
die();
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2006 App\Http\Controllers\Api\PayoneController::paymentStatus Price error',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* TODO -- need this?
|
||||
|
||||
/* TODO -- need this? */
|
||||
if($shopping_payment->txaction == $data['txaction']){
|
||||
\Log::channel('payone')->error('PaymentStatus: same txaction error: '.json_encode($data));
|
||||
echo "PaymentStatus: same txaction:";
|
||||
var_dump($data);
|
||||
die();
|
||||
|
||||
if($data['txaction'] === 'paid' && $shopping_order->txaction === 'paid'){
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2007 App\Http\Controllers\Api\PayoneController::paymentStatus same txaction - was already paid',
|
||||
$data
|
||||
);
|
||||
//was already paid
|
||||
print("TSOK");
|
||||
exit;
|
||||
}else{
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2007 App\Http\Controllers\Api\PayoneController::paymentStatus same txaction - show',
|
||||
$data
|
||||
);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
//create transaction
|
||||
PaymentTransaction::create([
|
||||
'shopping_payment_id' => $shopping_payment->id,
|
||||
|
|
@ -124,19 +159,19 @@ class PayoneController extends Controller
|
|||
|
||||
$send_link = false;
|
||||
$send_mail = true;
|
||||
|
||||
if($data['txaction'] === 'failed'){
|
||||
$shopping_order->setUserHistoryValue(['status' => 6]);
|
||||
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 5);
|
||||
}
|
||||
if($data['txaction'] === 'appointed'){
|
||||
$shopping_order->setUserHistoryValue(['status' => 7]);
|
||||
Shop::userOrders();
|
||||
ShoppingUserService::snycOrdersByShoppingOrder($shopping_order);
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 4);
|
||||
}
|
||||
|
||||
if($data['txaction'] === 'paid'){
|
||||
if(!$shopping_order->paid){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true, $shopping_payment);
|
||||
}else{
|
||||
$send_mail = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -593,7 +593,7 @@ class ShoppingUserController extends Controller
|
|||
if ($order->price != ($product->price * 100)) {
|
||||
$error[] = "different price: " . ($product->price * 100);
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), (int) $order->qty, $product->price, false, false, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), (int) $order->qty, $product->price, false, false, ['image' => [], 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class BusinessController extends Controller
|
|||
private $filter_active = [1 => 'aktiv', 2 => 'nicht aktiv', 3 => 'alle'];
|
||||
private $month;
|
||||
private $year;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('admin');
|
||||
|
|
@ -42,7 +42,7 @@ class BusinessController extends Controller
|
|||
|
||||
$TreeCalcBot = new TreeCalcBot($this->month, $this->year, 'admin');
|
||||
$TreeCalcBot->initStructureAdmin();
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
'filter_years' => HTMLHelper::getYearRange(),
|
||||
|
|
@ -61,7 +61,7 @@ class BusinessController extends Controller
|
|||
$data['year'] = session('business_user_filter_year');
|
||||
$TreeCalcBot = new TreeCalcBot($data['month'], $data['year'], 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
if (!$TreeCalcBot->business_user) {
|
||||
abort(403, 'no user found');
|
||||
}
|
||||
return view('admin.business.user_detail', compact('TreeCalcBot', 'user', 'data'));
|
||||
|
|
@ -82,49 +82,52 @@ class BusinessController extends Controller
|
|||
//return back();
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('business_user_filter_month')){
|
||||
if (!session('business_user_filter_month')) {
|
||||
session(['business_user_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('business_user_filter_year')){
|
||||
if (!session('business_user_filter_year')) {
|
||||
session(['business_user_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(!session('business_user_filter_active')){
|
||||
if (!session('business_user_filter_active')) {
|
||||
session(['business_user_filter_active' => 1]);
|
||||
}
|
||||
if(!session('business_user_filter_depiction')){
|
||||
if (!session('business_user_filter_depiction')) {
|
||||
session(['business_user_filter_depiction' => 'active']);
|
||||
}
|
||||
|
||||
if(Request::get('business_user_filter_depiction')){
|
||||
if (Request::get('business_user_filter_depiction')) {
|
||||
session(['business_user_filter_depiction' => Request::get('business_user_filter_depiction')]);
|
||||
}
|
||||
if(Request::get('business_user_filter_name')){
|
||||
if (Request::get('business_user_filter_name')) {
|
||||
session(['business_user_filter_name' => Request::get('business_user_filter_name')]);
|
||||
} else {
|
||||
session(['business_user_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('business_user_filter_active')){
|
||||
if (Request::get('business_user_filter_active')) {
|
||||
session(['business_user_filter_active' => Request::get('business_user_filter_active')]);
|
||||
}
|
||||
if(Request::get('business_user_filter_month')){
|
||||
if (Request::get('business_user_filter_month')) {
|
||||
session(['business_user_filter_month' => Request::get('business_user_filter_month')]);
|
||||
}
|
||||
if(Request::get('business_user_filter_year')){
|
||||
if (Request::get('business_user_filter_year')) {
|
||||
session(['business_user_filter_year' => Request::get('business_user_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function userDatatable()
|
||||
{
|
||||
{
|
||||
$this->month = Request::get('business_user_filter_month');
|
||||
$this->year = Request::get('business_user_filter_year');
|
||||
|
||||
//only the currently month get from Users -> older month from UserBusiness
|
||||
return $this->userCurrentlyDatatable();
|
||||
if(TreeCalcBot::isFromStored($this->month, $this->year)){
|
||||
return $this->userCurrentlyDatatable();
|
||||
if (TreeCalcBot::isFromStored($this->month, $this->year)) {
|
||||
return $this->userStoredDatatable();
|
||||
}else{
|
||||
} else {
|
||||
return $this->userCurrentlyDatatable();
|
||||
}
|
||||
}
|
||||
|
|
@ -132,16 +135,16 @@ class BusinessController extends Controller
|
|||
private function initStoredSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
|
||||
$query = UserBusiness::select('user_businesses.*')->where('month', $this->month)->where('year', $this->year);
|
||||
if(Request::get('business_user_filter_active')){
|
||||
if(Request::get('business_user_filter_active') == 1){
|
||||
if (Request::get('business_user_filter_active')) {
|
||||
if (Request::get('business_user_filter_active') == 1) {
|
||||
$query->where('user_businesses.active_account', 1);
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 2){
|
||||
if (Request::get('business_user_filter_active') == 2) {
|
||||
$query->where('user_businesses.active_account', 0);
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 3){
|
||||
if (Request::get('business_user_filter_active') == 3) {
|
||||
//both -> payment_account only not null
|
||||
}
|
||||
}
|
||||
|
|
@ -149,18 +152,18 @@ class BusinessController extends Controller
|
|||
}
|
||||
|
||||
private function userStoredDatatable()
|
||||
{
|
||||
{
|
||||
$query = $this->initStoredSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserBusiness $userBusiness) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$userBusiness->user_id.'"
|
||||
data-id="' . $userBusiness->user_id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button>'.
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$userBusiness->user_id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button>' .
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$userBusiness->user_id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
})
|
||||
->addColumn('m_account', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->m_account;
|
||||
|
|
@ -169,19 +172,19 @@ class BusinessController extends Controller
|
|||
return $userBusiness->user_level_name;
|
||||
})
|
||||
->addColumn('is_qual_kp', function (UserBusiness $userBusiness) {
|
||||
if($userBusiness->m_level_id){
|
||||
if ($userBusiness->m_level_id) {
|
||||
$isQualKP = ($userBusiness->sales_volume_points_sum >= $userBusiness->qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-danger').'"> KU '.$userBusiness->qual_kp.'</span>';
|
||||
return '<span class="badge ' . ($isQualKP ? 'badge-outline-success' : 'badge-outline-danger') . '"> KU ' . $userBusiness->qual_kp . '</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_KP_points', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.$userBusiness->sales_volume_points_sum.'</div>'.
|
||||
'<span class="small no-line-break">E: '.$userBusiness->sales_volume_KP_points.' | S: '.$userBusiness->sales_volume_points_shop.'</span>';
|
||||
return '<div class="no-line-break">' . $userBusiness->sales_volume_points_sum . '</div>' .
|
||||
'<span class="small no-line-break">E: ' . $userBusiness->sales_volume_KP_points . ' | S: ' . $userBusiness->sales_volume_points_shop . '</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (UserBusiness $userBusiness) {
|
||||
return '<div class="no-line-break">'.formatNumber($userBusiness->sales_volume_total_sum).' €</div>'.
|
||||
'<span class="small no-line-break">E: '.formatNumber($userBusiness->sales_volume_total).' | S: '.formatNumber($userBusiness->sales_volume_total_shop).'</span>';
|
||||
return '<div class="no-line-break">' . formatNumber($userBusiness->sales_volume_total_sum) . ' €</div>' .
|
||||
'<span class="small no-line-break">E: ' . formatNumber($userBusiness->sales_volume_total) . ' | S: ' . formatNumber($userBusiness->sales_volume_total_shop) . '</span>';
|
||||
})
|
||||
->addColumn('email', function (UserBusiness $userBusiness) {
|
||||
return $userBusiness->email;
|
||||
|
|
@ -193,23 +196,23 @@ class BusinessController extends Controller
|
|||
return $userBusiness->last_name;
|
||||
})
|
||||
->addColumn('sponsor', function (UserBusiness $userBusiness) {
|
||||
if($userBusiness->sponsor){
|
||||
if ($userBusiness->sponsor) {
|
||||
$sponsor = "";
|
||||
if($userBusiness->sponsor->is_sponsor){
|
||||
$sponsor .= $userBusiness->sponsor->first_name." ".$userBusiness->sponsor->last_name;
|
||||
$sponsor .= " ".'<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$userBusiness->sponsor->user_id.'"
|
||||
if ($userBusiness->sponsor->is_sponsor) {
|
||||
$sponsor .= $userBusiness->sponsor->first_name . " " . $userBusiness->sponsor->last_name;
|
||||
$sponsor .= " " . '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="' . $userBusiness->sponsor->user_id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button><br>';
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button><br>';
|
||||
|
||||
$sponsor .= '<span class="small no-line-break">' . $userBusiness->sponsor->email;
|
||||
$sponsor .= ' | ' . $userBusiness->sponsor->m_account;
|
||||
$sponsor .= '</span>';
|
||||
}
|
||||
|
||||
$sponsor .= '<span class="small no-line-break">'.$userBusiness->sponsor->email;
|
||||
$sponsor .= ' | '.$userBusiness->sponsor->m_account;
|
||||
$sponsor .= '</span>';
|
||||
}
|
||||
|
||||
return $sponsor;
|
||||
}
|
||||
return '-';
|
||||
|
|
@ -222,25 +225,25 @@ class BusinessController extends Controller
|
|||
return $userBusiness->active_date ? formatDate($userBusiness->active_date) : "-";
|
||||
})
|
||||
|
||||
|
||||
->filterColumn('m_account', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("m_account LIKE ?", '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('first_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("first_name LIKE ?", '%'.$keyword.'%');
|
||||
|
||||
->filterColumn('m_account', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("m_account LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('last_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("last_name LIKE ?", '%'.$keyword.'%');
|
||||
->filterColumn('first_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("first_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('email', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("email LIKE ?", '%'.$keyword.'%');
|
||||
->filterColumn('last_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("last_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('email', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("email LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -253,29 +256,29 @@ class BusinessController extends Controller
|
|||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
private function initCurrentlySearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = User::join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.*', 'user_accounts.m_account', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
->where('users.admin', "<", 4)
|
||||
->where('users.m_level', "!=", null)
|
||||
->where('users.payment_account', "!=", null);
|
||||
|
||||
// $query = User::with('account')->select('users.*')
|
||||
|
||||
if(Request::get('business_user_filter_active')){
|
||||
if(Request::get('business_user_filter_active') == 1){
|
||||
$query = User::join('user_accounts', 'account_id', '=', 'user_accounts.id')
|
||||
->select('users.*', 'user_accounts.m_account', 'user_accounts.first_name', 'user_accounts.last_name')
|
||||
->where('users.deleted_at', '=', null)
|
||||
->where('users.id', '!=', 1)
|
||||
->where('users.admin', "<", 4)
|
||||
->where('users.m_level', "!=", null)
|
||||
->where('users.payment_account', "!=", null);
|
||||
|
||||
// $query = User::with('account')->select('users.*')
|
||||
|
||||
if (Request::get('business_user_filter_active')) {
|
||||
if (Request::get('business_user_filter_active') == 1) {
|
||||
$query->where('users.payment_account', ">=", now());
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 2){
|
||||
if (Request::get('business_user_filter_active') == 2) {
|
||||
$query->where('users.payment_account', "<", now());
|
||||
}
|
||||
if(Request::get('business_user_filter_active') == 3){
|
||||
if (Request::get('business_user_filter_active') == 3) {
|
||||
//both -> payment_account only not null
|
||||
}
|
||||
}
|
||||
|
|
@ -283,18 +286,18 @@ class BusinessController extends Controller
|
|||
}
|
||||
|
||||
private function userCurrentlyDatatable()
|
||||
{
|
||||
{
|
||||
$query = $this->initCurrentlySearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (User $user) {
|
||||
return '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$user->id.'"
|
||||
data-id="' . $user->id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button>'.
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button>' .
|
||||
(config('app.debug') === true ? '<a href="' . route('admin_business_user_detail', [$user->id]) . '" class="btn icon-btn btn-xs btn-primary"><span class="fa fa-calculator"></span></a>' : '');
|
||||
})
|
||||
->addColumn('m_account', function (User $user) {
|
||||
return $user->account ? $user->account->m_account : '';
|
||||
|
|
@ -303,21 +306,21 @@ class BusinessController extends Controller
|
|||
return $user->user_level ? $user->user_level->getLang('name') : '';
|
||||
})
|
||||
->addColumn('is_qual_kp', function (User $user) {
|
||||
if($user->user_level){
|
||||
if ($user->user_level) {
|
||||
$qual_kp = $user->user_level->qual_kp;
|
||||
$sales_volume_points_sum = $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum');
|
||||
$isQualKP = ($sales_volume_points_sum >= $qual_kp) ? true : false;
|
||||
return '<span class="badge '.($isQualKP ? 'badge-outline-success' : 'badge-outline-warning-dark').'"> KU '.$qual_kp.'</span>';
|
||||
return '<span class="badge ' . ($isQualKP ? 'badge-outline-success' : 'badge-outline-warning-dark') . '"> KU ' . $qual_kp . '</span>';
|
||||
}
|
||||
return '-';
|
||||
})
|
||||
->addColumn('sales_volume_KP_points', function (User $user) {
|
||||
return '<div class="no-line-break">'.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum').'</div>'.
|
||||
'<span class="small no-line-break">E: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_KP_points').' | S: '.$user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop').'</span>';
|
||||
})
|
||||
->addColumn('sales_volume_KP_points', function (User $user) {
|
||||
return '<div class="no-line-break">' . $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_KP_sum') . '</div>' .
|
||||
'<span class="small no-line-break">E: ' . $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_KP_points') . ' | S: ' . $user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_points_shop') . '</span>';
|
||||
})
|
||||
->addColumn('sales_volume_total', function (User $user) {
|
||||
return '<div class="no-line-break">'.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum')).' €</div>'.
|
||||
'<span class="small no-line-break">E: '.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total')).' | S: '.formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop')).'</span>';
|
||||
return '<div class="no-line-break">' . formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_sum')) . ' €</div>' .
|
||||
'<span class="small no-line-break">E: ' . formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total')) . ' | S: ' . formatNumber($user->getUserSalesVolumeBy($this->month, $this->year, 'sales_volume_total_shop')) . '</span>';
|
||||
})
|
||||
->addColumn('email', function (User $user) {
|
||||
return $user->email;
|
||||
|
|
@ -329,24 +332,24 @@ class BusinessController extends Controller
|
|||
return $user->account ? $user->account->last_name : '';
|
||||
})
|
||||
->addColumn('sponsor', function (User $user) {
|
||||
if($user->user_sponsor){
|
||||
if ($user->user_sponsor) {
|
||||
$sponsor = "";
|
||||
if($user->user_sponsor->account){
|
||||
$sponsor .= $user->user_sponsor->account->first_name." ".$user->user_sponsor->account->last_name;
|
||||
$sponsor .= " ".'<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$user->user_sponsor->id.'"
|
||||
if ($user->user_sponsor->account) {
|
||||
$sponsor .= $user->user_sponsor->account->first_name . " " . $user->user_sponsor->account->last_name;
|
||||
$sponsor .= " " . '<button type="button" class="btn icon-btn btn-xs btn-secondary" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="' . $user->user_sponsor->id . '"
|
||||
data-action="business-user-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="admin"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-calculator"></span></button><br>';
|
||||
}
|
||||
$sponsor .= '<span class="small no-line-break">'.$user->user_sponsor->email;
|
||||
if($user->user_sponsor->account){
|
||||
$sponsor .= ' | '.$user->user_sponsor->account->m_account;
|
||||
}
|
||||
$sponsor .= '</span>';
|
||||
|
||||
data-route="' . route('modal_load') . '"><span class="fa fa-calculator"></span></button><br>';
|
||||
}
|
||||
$sponsor .= '<span class="small no-line-break">' . $user->user_sponsor->email;
|
||||
if ($user->user_sponsor->account) {
|
||||
$sponsor .= ' | ' . $user->user_sponsor->account->m_account;
|
||||
}
|
||||
$sponsor .= '</span>';
|
||||
|
||||
return $sponsor;
|
||||
}
|
||||
return '-';
|
||||
|
|
@ -358,25 +361,25 @@ class BusinessController extends Controller
|
|||
->addColumn('payment_account_date', function (User $user) {
|
||||
return $user->payment_account ? $user->getPaymentAccountDateFormat(false) : "-";
|
||||
})
|
||||
|
||||
->filterColumn('m_account', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("m_account LIKE ?", '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->filterColumn('first_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("first_name LIKE ?", '%'.$keyword.'%');
|
||||
|
||||
->filterColumn('m_account', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("m_account LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('last_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("last_name LIKE ?", '%'.$keyword.'%');
|
||||
->filterColumn('first_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("first_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('email', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->whereRaw("email LIKE ?", '%'.$keyword.'%');
|
||||
->filterColumn('last_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("last_name LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('email', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereRaw("email LIKE ?", '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->orderColumn('id', 'm_account $1')
|
||||
|
|
@ -387,5 +390,5 @@ class BusinessController extends Controller
|
|||
->orderColumn('active_account', 'payment_account $1')
|
||||
->rawColumns(['id', 'is_qual_kp', 'sales_volume_KP_points', 'sales_volume_total', 'sponsor', 'active_account'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,16 @@ use App\Mail\MailVerifyAccount;
|
|||
use App\Services\PaymentHelper;
|
||||
use App\Repositories\UserRepository;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class CronController extends Controller
|
||||
{
|
||||
|
||||
|
||||
protected $userRepo;
|
||||
|
||||
// Konstanten für bessere Lesbarkeit
|
||||
private const CRON_KEY = 'CqZHL79FwUCcy9pjvi';
|
||||
private const RUN_CRON_KEY = 'G8ZvEbnP8fEPfnWX4L';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
|
|
@ -28,58 +31,94 @@ class CronController extends Controller
|
|||
public function __construct(UserRepository $userRepo)
|
||||
{
|
||||
$this->userRepo = $userRepo;
|
||||
|
||||
// $this->middleware('auth');
|
||||
Log::channel('cron')->info('CronController initialisiert');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hauptindex-Methode für Cron-Jobs
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
Log::channel('cron')->info('Cron-Index aufgerufen');
|
||||
//$this->checkConfirmation();
|
||||
//TODO
|
||||
//SEPA Booking
|
||||
//Mail reminder
|
||||
return "Cron-Index ausgeführt";
|
||||
}
|
||||
|
||||
public function action($action = false, $key = false){
|
||||
|
||||
if($key !== 'CqZHL79FwUCcy9pjvi'){
|
||||
/**
|
||||
* Führt eine bestimmte Cron-Aktion aus
|
||||
*
|
||||
* @param string|bool $action Die auszuführende Aktion
|
||||
* @param string|bool $key Sicherheitsschlüssel
|
||||
* @return mixed
|
||||
*/
|
||||
public function action($action = false, $key = false)
|
||||
{
|
||||
Log::channel('cron')->info('Cron-Aktion aufgerufen: ' . $action);
|
||||
|
||||
if($key !== self::CRON_KEY){
|
||||
Log::channel('cron')->warning('Ungültiger Cron-Key verwendet: ' . $key);
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if($action === 'check_payments_account'){
|
||||
$this->checkPaymentsAccounts();
|
||||
Log::channel('cron')->info('Starte Überprüfung der Zahlungskonten');
|
||||
return $this->checkPaymentsAccounts();
|
||||
}
|
||||
|
||||
Log::channel('cron')->warning('Unbekannte Aktion angefordert: ' . $action);
|
||||
return response('Keine gültige Aktion angegeben', 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
* Überprüft Benutzerbestätigungen und sendet Erinnerungen
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return string
|
||||
*/
|
||||
public function checkConfirmation()
|
||||
{
|
||||
Log::channel('cron')->info('Starte Überprüfung der Benutzerbestätigungen');
|
||||
|
||||
$now = date('Y-m-d H:i:s');
|
||||
$next = date('Y-m-d H:i:s', strtotime('+3 week'));
|
||||
|
||||
$users = User::where('confirmed', '=', 0)->where('confirmation_code_to', '<', $now)->get();
|
||||
Log::channel('cron')->info('Gefundene unbestätigte Benutzer: ' . $users->count());
|
||||
|
||||
foreach ($users as $user) {
|
||||
|
||||
//delete user
|
||||
if ($user->confirmation_code_remider == 1) {
|
||||
Log::channel('cron')->warning('Lösche unbestätigten Benutzer: ' . $user->email);
|
||||
$this->userRepo->deleteUser($user);
|
||||
|
||||
}
|
||||
//send new remider
|
||||
if ($user->confirmation_code_remider == 0) {
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($user->confirmation_code, $user));
|
||||
$user->confirmation_code_to = $next;
|
||||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
if(!Util::isTestSystem()){
|
||||
Log::channel('cron')->info('Sende Bestätigungserinnerung an: ' . $user->email);
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailVerifyAccount($user->confirmation_code, $user));
|
||||
$user->confirmation_code_to = $next;
|
||||
$user->confirmation_code_remider = 1;
|
||||
$user->save();
|
||||
} else {
|
||||
Log::channel('cron')->info('Testsystem: Bestätigungserinnerung an: ' . $user->email);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "TOSK";
|
||||
}
|
||||
|
||||
public function checkPaymentsAccounts(){
|
||||
/**
|
||||
* Überprüft Zahlungskonten und sendet Erinnerungen
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function checkPaymentsAccounts()
|
||||
{
|
||||
Log::channel('cron')->info('Starte Überprüfung der Zahlungskonten');
|
||||
|
||||
/*RULES
|
||||
reminders
|
||||
|
|
@ -93,207 +132,289 @@ class CronController extends Controller
|
|||
*/
|
||||
//max Date for reminder
|
||||
$renewalDate = Carbon::now()->modify('+'.(config('mivita.remind_first_days')+1).' days');
|
||||
//dump($renewalDate);
|
||||
Log::channel('cron')->info('Erneuerungsdatum für Zahlungen: ' . $renewalDate->format('Y-m-d H:i:s'));
|
||||
|
||||
$users = User::where('payment_account', '!=', NULL)
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $renewalDate)
|
||||
->get();
|
||||
|
||||
/* $user = User::find(2);
|
||||
$this->checkReminderPayments($user);
|
||||
dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
die();*/
|
||||
Log::channel('cron')->info('Gefundene Benutzer für Zahlungserinnerungen: ' . $users->count());
|
||||
|
||||
foreach ($users as $user){
|
||||
Log::channel('cron')->info('Prüfe Zahlungserinnerungen für Benutzer: ' . $user->email);
|
||||
$this->checkReminderPayments($user);
|
||||
/* Abo Option deaktiviert
|
||||
$this->userInitAboPayment($user);
|
||||
*/
|
||||
}
|
||||
|
||||
return "TOSK";
|
||||
}
|
||||
|
||||
private function userInitAboPayment(User $user){
|
||||
/**
|
||||
* Initiiert Abo-Zahlungen für einen Benutzer
|
||||
* hier geht es um die Mitglieschaft Abos - die sind derzeit deaktiviert
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @return bool
|
||||
*/
|
||||
private function userInitAboPayment(User $user)
|
||||
{
|
||||
if(!$user->isAcountAboPayDate()){
|
||||
Log::channel('cron')->info('Kein Abo-Zahlungsdatum für Benutzer: ' . $user->email);
|
||||
return false;
|
||||
}
|
||||
|
||||
//user has a open Abo Payment
|
||||
if($this->checkIsAboPaymentOpen($user)){
|
||||
Log::channel('cron')->info('Offene Abo-Zahlung für Benutzer: ' . $user->email);
|
||||
return false;
|
||||
}
|
||||
|
||||
if($user->payment_order_product){
|
||||
Log::channel('cron')->info('Starte Abo-Zahlung für Benutzer: ' . $user->email);
|
||||
$this->buyProductAboPayment($user, $user->payment_order_product);
|
||||
}
|
||||
/*dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
dump('-------------------');*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function checkIsAboPaymentOpen(User $user){
|
||||
/**
|
||||
* Prüft, ob eine offene Abo-Zahlung existiert
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIsAboPaymentOpen(User $user)
|
||||
{
|
||||
$isOpen = UserHistory::whereUserId($user->id)
|
||||
->whereAction('abo_open_payment')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->where('status', '>=', 1) //open //error // payment
|
||||
->get()->last();
|
||||
|
||||
if($isOpen){
|
||||
Log::channel('cron')->info('Offene Abo-Zahlung gefunden für: ' . $user->email);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function checkReminderPayments(User $user){
|
||||
|
||||
/* $isSend = $this->checkIsReminderSend($user, 31);
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
return ;*/
|
||||
|
||||
/**
|
||||
* Prüft und sendet Zahlungserinnerungen basierend auf Benutzerkontostand
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @return bool
|
||||
*/
|
||||
private function checkReminderPayments(User $user)
|
||||
{
|
||||
//35 reminder_deaktiv, 36 reminder_deaktiv_sepa
|
||||
if(!$user->isActiveAccount()){
|
||||
/* Abo Option deaktiviert
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
return $isSend;
|
||||
}
|
||||
*/
|
||||
Log::channel('cron')->info('Inaktives Konto für Benutzer: ' . $user->email);
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//34 reminder_last
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_last_days')){
|
||||
Log::channel('cron')->info('Letzte Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//33 reminder_sec
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_sec_days')){
|
||||
/* Abo Option deaktiviert
|
||||
if(!$user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
return $isSend;
|
||||
}
|
||||
*/
|
||||
|
||||
Log::channel('cron')->info('Zweite Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//31 reminder_first, 32 reminder_first_sepa
|
||||
//31 reminder_first
|
||||
if($user->daysActiveAccount() > config('mivita.remind_sec_days')){
|
||||
/* Abo Option deaktiviert
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
return $isSend;
|
||||
} */
|
||||
Log::channel('cron')->info('Erste Erinnerung für Benutzer: ' . $user->email . ' (Tage aktiv: ' . $user->daysActiveAccount() . ')');
|
||||
$isSend = $this->checkIsReminderSend($user, 31);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function checkIsReminderSend(User $user, $status){
|
||||
|
||||
/**
|
||||
* Überprüft, ob eine Erinnerung bereits gesendet wurde
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @param int $status Status-Code der Erinnerung
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIsReminderSend(User $user, $status)
|
||||
{
|
||||
$isSend = UserHistory::whereUserId($user->id)
|
||||
->whereAction('reminder_payments')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->whereStatus($status)
|
||||
->get()->last();
|
||||
->latest()
|
||||
->first();
|
||||
|
||||
if($isSend){
|
||||
Log::channel('cron')->info('Erinnerung bereits gesendet für Benutzer: ' . $user->email . ' (Status: ' . $status . ')');
|
||||
return true;
|
||||
}
|
||||
|
||||
Log::channel('cron')->info('Sende neue Erinnerung für Benutzer: ' . $user->email . ' (Status: ' . $status . ')');
|
||||
$referenz = $this->sendReminderMail($user, $status);
|
||||
|
||||
//is not sent create
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'reminder_payments', 'referenz'=>$referenz, 'identifier'=>$user->payment_account, 'status'=>$status]);
|
||||
UserHistory::create([
|
||||
'user_id' => $user->id,
|
||||
'action' => 'reminder_payments',
|
||||
'referenz' => $referenz,
|
||||
'identifier' => $user->payment_account,
|
||||
'status' => $status
|
||||
]);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private function sendReminderMail(User $user, $status){
|
||||
|
||||
$days = $user->daysActiveAccount();
|
||||
if($days < 0){
|
||||
$days = $days*-1;
|
||||
}
|
||||
|
||||
//dump($days);
|
||||
//dump($status);
|
||||
$pay_date = Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y');
|
||||
/**
|
||||
* Sendet eine Erinnerungs-E-Mail an den Benutzer
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @param int $status Status-Code der Erinnerung
|
||||
* @return int
|
||||
*/
|
||||
private function sendReminderMail(User $user, $status)
|
||||
{
|
||||
$days = abs($user->daysActiveAccount());
|
||||
|
||||
$pay_date = Carbon::parse($user->payment_account)
|
||||
->modify('- ' . config('mivita.abo_booking_days') . ' days')
|
||||
->format('d.m.Y');
|
||||
|
||||
$datetime = $user->getPaymentAccountDateFormat();
|
||||
$price = "";
|
||||
|
||||
if($user->payment_order_id && isset($user->payment_order_product->price)){
|
||||
$price = 'von '.$user->payment_order_product->getFormattedPrice().' EUR';
|
||||
$price = 'von ' . $user->payment_order_product->getFormattedPrice() . ' EUR';
|
||||
}
|
||||
|
||||
$message = __('reminder.copy_first_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$message_last = __('reminder.copy_last_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$button = __('reminder.button_'.$status);
|
||||
$message = __('reminder.copy_first_' . $status, [
|
||||
'days' => $days,
|
||||
'datetime' => $datetime,
|
||||
'price' => $price,
|
||||
'pay_date' => $pay_date
|
||||
]);
|
||||
|
||||
$message_last = __('reminder.copy_last_' . $status, [
|
||||
'days' => $days,
|
||||
'datetime' => $datetime,
|
||||
'price' => $price,
|
||||
'pay_date' => $pay_date
|
||||
]);
|
||||
|
||||
$button = __('reminder.button_' . $status);
|
||||
|
||||
$message = preg_replace("/[\n\r]/","",$message);
|
||||
$message_last = preg_replace("/[\n\r]/","",$message_last);
|
||||
$message = preg_replace("/[\n\r]/", "", $message);
|
||||
$message_last = preg_replace("/[\n\r]/", "", $message_last);
|
||||
|
||||
$data = [
|
||||
'subject' => __('reminder.subject')." | ID: ".$status,
|
||||
'subject' => __('reminder.subject') . " | ID: " . $status,
|
||||
'message' => $message,
|
||||
'message_last' => $message_last,
|
||||
'url' => route('user_membership'),
|
||||
'button' => $button,
|
||||
];
|
||||
//dump($data);
|
||||
|
||||
$sender = User::find(1);
|
||||
$customer_mail = UserMessage::create([
|
||||
'user_id' => $user->id,
|
||||
'user_id' => $user->id,
|
||||
'send_user_id' => $sender->id,
|
||||
'email' => $user->email,
|
||||
'subject' => $data['subject'],
|
||||
'message' => $data['message']." ".$data['message_last'],
|
||||
'message' => $data['message'] . " " . $data['message_last'],
|
||||
]);
|
||||
try{
|
||||
if($status >= 34){
|
||||
Mail::to($user->email)->locale($user->getLocale())->bcc(config('app.default_mail'))->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
}else{
|
||||
Mail::to($user->email)->locale($user->getLocale())->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
|
||||
try {
|
||||
if(!Util::isTestSystem()){
|
||||
if($status >= 34){
|
||||
Log::channel('cron')->info('Sende kritische Erinnerung mit BCC an: ' . $user->email);
|
||||
Mail::to($user->email)
|
||||
->locale($user->getLocale())
|
||||
->bcc(config('app.default_mail'))
|
||||
->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
} else {
|
||||
Log::channel('cron')->info('Sende normale Erinnerung an: ' . $user->email);
|
||||
Mail::to($user->email)
|
||||
->locale($user->getLocale())
|
||||
->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
}
|
||||
} else {
|
||||
Log::channel('cron')->info('Testsystem: E-Mail-Versand simuliert für: ' . $user->email);
|
||||
}
|
||||
}
|
||||
catch(\Exception $e){
|
||||
\Log::channel('cron')->error('Mail Error: '.$e->getMessage());
|
||||
// Never reached
|
||||
} catch(\Exception $e) {
|
||||
Log::channel('cron')->error('Mail-Fehler für Benutzer ' . $user->email . ': ' . $e->getMessage());
|
||||
|
||||
$customer_mail->fail = true;
|
||||
$customer_mail->error = $e->getMessage();
|
||||
$customer_mail->save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
$customer_mail->send = true;
|
||||
$customer_mail->sent_at = now();
|
||||
$customer_mail->save();
|
||||
|
||||
Log::channel('cron')->info('Erinnerungsmail erfolgreich gesendet an: ' . $user->email);
|
||||
return 1;
|
||||
}
|
||||
|
||||
private function buyProductAboPayment($user, $product){
|
||||
/**
|
||||
* Kauft ein Produkt mit Abo-Zahlung
|
||||
*
|
||||
* @param User $user Benutzer
|
||||
* @param object $product Produkt
|
||||
* @return void
|
||||
*/
|
||||
private function buyProductAboPayment($user, $product)
|
||||
{
|
||||
Log::channel('cron')->info('Starte Abo-Produktkauf für Benutzer: ' . $user->email);
|
||||
$paymentHelper = new PaymentHelper();
|
||||
$paymentHelper->setProduct($product);
|
||||
$paymentHelper->initELVPayment($user);
|
||||
Log::channel('cron')->info('Abo-Produktkauf abgeschlossen für: ' . $user->email);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Führt das Cron-Script aus
|
||||
*
|
||||
* @param string $key Sicherheitsschlüssel
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function runCron($key)
|
||||
{
|
||||
if($key !== 'G8ZvEbnP8fEPfnWX4L'){
|
||||
Log::channel('cron')->info('Cron-Script-Ausführung angefordert');
|
||||
|
||||
if($key !== self::RUN_CRON_KEY){
|
||||
Log::channel('cron')->warning('Ungültiger Cron-Script-Key verwendet: ' . $key);
|
||||
abort(404);
|
||||
}
|
||||
if(Util::isTestSystem()){
|
||||
exec("/bin/bash ../cron_script_local.sh 2>&1", $out, $result);
|
||||
}else{
|
||||
exec("/bin/bash ../cron_script_server.sh 2>&1", $out, $result);
|
||||
}
|
||||
echo "Returncode: " .$result ."<br>";
|
||||
echo "Ausgabe des Scripts: " ."<br>";
|
||||
|
||||
$scriptPath = Util::isTestSystem() ? '../cron_script_local.sh' : '../cron_script_server.sh';
|
||||
Log::channel('cron')->info('Führe Script aus: ' . $scriptPath);
|
||||
|
||||
exec("/bin/bash {$scriptPath} 2>&1", $out, $result);
|
||||
|
||||
Log::channel('cron')->info('Cron-Script-Ausführung abgeschlossen mit Code: ' . $result);
|
||||
|
||||
echo "Returncode: " . $result . "<br>";
|
||||
echo "Ausgabe des Scripts: " . "<br>";
|
||||
echo "<pre>"; print_r($out);
|
||||
|
||||
exit;
|
||||
|
||||
/*return response()->view('cron.result', [
|
||||
'result' => $result,
|
||||
'output' => $out
|
||||
]);*/
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ class CustomerController extends Controller
|
|||
\Session()->flash('alert-save', true);
|
||||
return redirect(route('admin_customer_detail', [$shopping_user->id]));
|
||||
}
|
||||
if ($data['action'] === 'shopping-user-store') {
|
||||
if($data['action'] === 'shopping-user-store') {
|
||||
$rules = array(
|
||||
'billing_salutation' => 'required',
|
||||
'billing_firstname'=>'required',
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class FileController extends Controller
|
|||
|
||||
|
||||
if(!Storage::disk($disk)->exists($path)){
|
||||
// return Response::make('File no found.', 404);
|
||||
return Response::make('Datei nicht gefunden.', 404);
|
||||
}
|
||||
$file = Storage::disk($disk)->get($path);
|
||||
$mime = Storage::disk($disk)->mimeType($path);
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Image;
|
||||
use Request;
|
||||
use Validator;
|
||||
use App\Models\Product;
|
||||
use App\Models\ProductImage;
|
||||
use App\Repositories\ProductRepository;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
||||
|
||||
|
|
@ -23,6 +24,7 @@ class ImportProductController extends Controller
|
|||
|
||||
public function import(){
|
||||
|
||||
dd('nicht aktiv, wenn muss geprüft werden, ob die funktion IMAGE existieren');
|
||||
$path = app_path().'/../_static/products/';
|
||||
|
||||
include($path.'_all_products.php');
|
||||
|
|
@ -73,7 +75,7 @@ class ImportProductController extends Controller
|
|||
$name = \App\Services\Slim::sanitizeFileName($image['image']);
|
||||
$name = uniqid() . '_' . $name;
|
||||
|
||||
$img = \Image::make($i_path);
|
||||
$img = Image::make($i_path);
|
||||
$img->resize(600, 800, function ($c) {
|
||||
// $c->aspectRatio();
|
||||
$c->upsize();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use App\Models\Ingredient;
|
|||
use App\Models\IqImage;
|
||||
use App\Models\ProductCategory;
|
||||
use App\Models\ProductIngredient;
|
||||
use\Request;
|
||||
use Request;
|
||||
|
||||
|
||||
class IngredientController extends Controller
|
||||
|
|
|
|||
|
|
@ -198,6 +198,9 @@ class LeadController extends Controller
|
|||
'city' => 'required',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
'bank_owner' => 'required',
|
||||
'bank_iban' => 'required',
|
||||
'bank_bic' => 'required',
|
||||
);
|
||||
if(!Request::get('same_as_billing')){
|
||||
$rules = array_merge($rules, [
|
||||
|
|
|
|||
|
|
@ -5,9 +5,10 @@ namespace App\Http\Controllers;
|
|||
use Request;
|
||||
use App\User;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserAbo;
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\UserLevel;
|
||||
|
||||
use App\Models\UserLevel;
|
||||
use App\Models\UserCredit;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\HTMLHelper;
|
||||
|
|
@ -99,7 +100,7 @@ class ModalController extends Controller
|
|||
$homeparty = Homeparty::find($data['id']);
|
||||
$homeparty_user = HomepartyUser::find($data['user_id']);
|
||||
$data['homeparty'] = $homeparty;
|
||||
$ret = view("user.homeparty.modal_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render();
|
||||
$ret = view("user.homeparty.modal_hp_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-level-edit'){
|
||||
|
|
@ -153,6 +154,20 @@ class ModalController extends Controller
|
|||
$UserCredit = UserCredit::find($data['id']); //current user form order
|
||||
$ret = view("admin.payment.modal_credit_status", compact('UserCredit', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'abo_update_settings'){
|
||||
$user_abo = UserAbo::find($data['id']);
|
||||
if($data['view'] === 'admin'){
|
||||
$route = route('admin_abos_update', [$user_abo->id]);
|
||||
}else{
|
||||
$route = route('user_abos_update', [$data['view'], $user_abo->id]);
|
||||
}
|
||||
$ret = view("admin.abo.modal_abo_update", compact('user_abo', 'data', 'route'))->render();
|
||||
}
|
||||
if($data['action'] === 'abo-add-product') {
|
||||
$user_abo = UserAbo::find($data['id']);
|
||||
$ret = view("user.abo.modal_abo_show_products", compact( 'data', 'user_abo'))->render();
|
||||
}
|
||||
|
||||
}
|
||||
return response()->json(['response' => $data, 'html'=>$ret, 'status'=>$status]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,48 @@ class PayoneController extends Controller
|
|||
public function getShoppingPayment(){
|
||||
return $this->shopping_payment;
|
||||
}
|
||||
public function setAboPayment($user_abo, $amount, $currency){
|
||||
$this->reference = substr(uniqid('m', false), 0, 16);
|
||||
|
||||
$this->method = [
|
||||
"clearingtype" => $user_abo->clearingtype,
|
||||
"wallettype" => $user_abo->wallettype,
|
||||
"pseudocardpan" => isset($user_abo->carddata['pseudocardpan']) ? $user_abo->carddata['pseudocardpan'] : '',
|
||||
"cardexpiredate" => isset($user_abo->carddata['cardexpiredate']) ? $user_abo->carddata['cardexpiredate'] : '',
|
||||
'userid' => $user_abo->payone_userid,
|
||||
'onlinebanktransfertype' => '',
|
||||
"request" => "authorization",
|
||||
];
|
||||
|
||||
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'no',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount
|
||||
];
|
||||
|
||||
$this->prepayment = [
|
||||
"reference" => $this->reference, // a unique reference, e.g. order number
|
||||
"amount" => $amount, // amount in smallest currency unit, i.e. cents
|
||||
"currency" => $currency,
|
||||
"param" => $this->shopping_order->id,
|
||||
];
|
||||
|
||||
$this->shopping_payment = ShoppingPayment::create([
|
||||
'shopping_order_id' => $this->shopping_order->id,
|
||||
'clearingtype' => $this->method["clearingtype"],
|
||||
'wallettype' => $this->method["wallettype"],
|
||||
'onlinebanktransfertype' => $this->method["onlinebanktransfertype"],
|
||||
'carddata' => $user_abo->carddata,
|
||||
'reference' => $this->reference,
|
||||
'amount' => $amount,
|
||||
'currency' => $currency,
|
||||
'is_abo' => $this->shopping_order->is_abo,
|
||||
'abo_interval' => 0,
|
||||
'mode' => $this->shopping_order->mode,
|
||||
]);
|
||||
}
|
||||
//make Payone payment
|
||||
public function setPrePayment($payment_method, $amount, $currency, $ret = []){
|
||||
|
||||
|
|
@ -87,7 +128,7 @@ class PayoneController extends Controller
|
|||
$this->setMethod($payment_method, $ret);
|
||||
|
||||
$this->urls = [
|
||||
'successurl' => route('checkout.transaction_status', ['success', $this->reference]),
|
||||
'successurl' => route('checkout.transaction_status', ['success', $this->reference]),
|
||||
'errorurl' => route('checkout.transaction_status', ['error', $this->reference]),
|
||||
'backurl' => route('checkout.transaction_status', ['cancel', $this->reference]),
|
||||
];
|
||||
|
|
@ -100,10 +141,30 @@ class PayoneController extends Controller
|
|||
];
|
||||
//init Abo
|
||||
if($this->shopping_order->is_abo){
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'yes'
|
||||
];
|
||||
if($this->method["clearingtype"] === "cc"){
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'yes',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount,
|
||||
];
|
||||
$this->method['request'] = 'authorization';
|
||||
|
||||
}
|
||||
|
||||
if($this->method["clearingtype"] === "wlt"){
|
||||
//payment for Abo PayPal
|
||||
$this->aboInitPayment = [
|
||||
'recurrence'=>'recurring',
|
||||
'customer_is_present'=>'yes',
|
||||
'request' => 'authorization',
|
||||
'amount' => $amount,
|
||||
'add_paydata[redirection_mode]' => 'DIRECT_TO_MERCHANT',
|
||||
];
|
||||
$this->setDeliverylData($this->shopping_user);
|
||||
$this->method['request'] = 'authorization';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$this->shopping_payment = ShoppingPayment::create([
|
||||
|
|
@ -111,11 +172,13 @@ class PayoneController extends Controller
|
|||
'clearingtype' => $this->method["clearingtype"],
|
||||
'wallettype' => $this->method["wallettype"],
|
||||
'onlinebanktransfertype' => $this->method["onlinebanktransfertype"],
|
||||
'carddata' => isset($ret['cc']) ? $ret['cc'] : null,
|
||||
'reference' => $this->reference,
|
||||
'amount' => $amount,
|
||||
'currency' => $currency,
|
||||
'is_abo' => $this->shopping_order->is_abo,
|
||||
'abo_interval' => $this->shopping_order->abo_interval,
|
||||
'identifier' => Util::getUserShopIdentifier(),
|
||||
'mode' => $this->shopping_order->mode,
|
||||
]);
|
||||
|
||||
|
|
@ -163,6 +226,8 @@ class PayoneController extends Controller
|
|||
'onlinebanktransfertype' => "",
|
||||
"request" => "authorization"
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
//Online-Überweisung
|
||||
if($payment_method[0] === 'sb'){
|
||||
|
|
@ -240,17 +305,17 @@ class PayoneController extends Controller
|
|||
}
|
||||
|
||||
public function onlyPaymentResponse(){
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->aboInitPayment, $this->prepayment, $this->urls);
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->aboInitPayment, $this->urls);
|
||||
$response = Payone::sendRequest($request);
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function ResponseData(){
|
||||
public function ResponseData($is_abo = false){
|
||||
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->aboInitPayment, $this->prepayment, $this->urls);
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->aboInitPayment, $this->urls);
|
||||
//dd($request);
|
||||
//RECHNUNG MIV
|
||||
if($this->shopping_payment->clearingtype === 'fnc' && $this->shopping_payment->onlinebanktransfertype === 'MIV'){
|
||||
|
||||
$payt = PaymentTransaction::create([
|
||||
'shopping_payment_id' => $this->shopping_payment->id,
|
||||
'request' => $this->method['request'],
|
||||
|
|
@ -262,6 +327,9 @@ class PayoneController extends Controller
|
|||
'mode' => $this->shopping_payment->mode,
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>5]);
|
||||
if($is_abo){
|
||||
return $this->reference;
|
||||
}
|
||||
return redirect(route('checkout.transaction_approved', [$payt->id, $this->reference]));
|
||||
exit;
|
||||
}
|
||||
|
|
@ -271,6 +339,12 @@ class PayoneController extends Controller
|
|||
* status APPROVED / REDIRECT / ERROR / PENDING
|
||||
*/
|
||||
if($response['status'] === 'ERROR'){
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'PayPal Preauthorization Fehler: ' . $response['errormessage'],
|
||||
$response
|
||||
);
|
||||
PaymentTransaction::create([
|
||||
'shopping_payment_id' => $this->shopping_payment->id,
|
||||
'request' => $this->method['request'],
|
||||
|
|
@ -281,6 +355,9 @@ class PayoneController extends Controller
|
|||
'mode' => $this->shopping_payment->mode,
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>3]);
|
||||
if($is_abo){
|
||||
return $response;
|
||||
}
|
||||
\Session::flash('errormessage', $response['errormessage']);
|
||||
\Session::flash('customermessage', $response['customermessage']);
|
||||
return redirect(route('checkout.checkout_card'));
|
||||
|
|
@ -298,6 +375,9 @@ class PayoneController extends Controller
|
|||
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>4]);
|
||||
if($is_abo){
|
||||
return $response;
|
||||
}
|
||||
return redirect()->away($response["redirecturl"]);
|
||||
exit;
|
||||
|
||||
|
|
@ -316,6 +396,9 @@ class PayoneController extends Controller
|
|||
|
||||
]);
|
||||
Util::setUserHistoryValue(['status'=>5]);
|
||||
if($is_abo){
|
||||
return $response;
|
||||
}
|
||||
|
||||
if($payt->shopping_payment->clearingtype === "vor"){
|
||||
//vorkasse
|
||||
|
|
@ -335,7 +418,6 @@ class PayoneController extends Controller
|
|||
exit;
|
||||
}
|
||||
|
||||
|
||||
var_dump($response);
|
||||
die();
|
||||
//txid
|
||||
|
|
@ -407,6 +489,27 @@ class PayoneController extends Controller
|
|||
return Payone::sendRequest($request);
|
||||
}
|
||||
|
||||
public function setDeliverylData($shopping_user){
|
||||
if($shopping_user->same_as_billing == true){
|
||||
$this->deliveryData = [
|
||||
'shipping_firstname' => $shopping_user->billing_firstname,
|
||||
'shipping_lastname' => $shopping_user->billing_lastname,
|
||||
'shipping_zip' => $shopping_user->billing_zipcode,
|
||||
'shipping_city' => $shopping_user->billing_city,
|
||||
'shipping_country' => $shopping_user->billing_country->code,
|
||||
'shipping_street' => $shopping_user->billing_address,
|
||||
];
|
||||
}else{
|
||||
$this->deliveryData = [
|
||||
'shipping_firstname' => $shopping_user->shipping_firstname,
|
||||
'shipping_lastname' => $shopping_user->shipping_lastname,
|
||||
'shipping_zip' => $shopping_user->shipping_zipcode,
|
||||
'shipping_city' => $shopping_user->shipping_city,
|
||||
'shipping_country' => $shopping_user->shipping_country->code,
|
||||
'shipping_street' => $shopping_user->shipping_address,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/* public function getPDFFile($mandateId)
|
||||
{
|
||||
|
|
@ -492,17 +595,7 @@ class PayoneController extends Controller
|
|||
|
||||
|
||||
|
||||
public function setDeliverylData($data){
|
||||
$this->deliveryData = [
|
||||
"shipping_company" => "Mr.",
|
||||
"shipping_firstname" => "Henry",
|
||||
"shipping_lastname" => "Tudor",
|
||||
"shipping_street" => "Royal Street 1",
|
||||
"shipping_zip" => "24118",
|
||||
"shipping_city" => "Kiel",
|
||||
"shipping_country" => "DE",
|
||||
];
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -41,24 +41,25 @@ class PaymentCreditController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function store(){
|
||||
public function store()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(isset($data['action']) && $data['action'] === 'add-user-credit'){
|
||||
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||
if (isset($data['action']) && $data['action'] === 'add-user-credit') {
|
||||
if (!isset($data['member_id']) || !$user = User::find($data['member_id'])) {
|
||||
\Session()->flash('alert-error', 'Vertriebspartner nicht gefunden');
|
||||
return back();
|
||||
}
|
||||
if(!isset($data['credit'])){
|
||||
if (!isset($data['credit'])) {
|
||||
\Session()->flash('alert-error', 'Bitte Betrag eingeben');
|
||||
return back();
|
||||
}
|
||||
if(!isset($data['message'])){
|
||||
if (!isset($data['message'])) {
|
||||
\Session()->flash('alert-error', 'Bitte Betreff eingeben');
|
||||
return back();
|
||||
}
|
||||
|
||||
$credit = Util::reFormatNumber($data['credit']);
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
Payment::addUserCreditMargin($user, $credit, 3, $data['message']);
|
||||
\Session()->flash('alert-success', "Guthaben hinzugefügt");
|
||||
}
|
||||
|
|
@ -66,11 +67,12 @@ class PaymentCreditController extends Controller
|
|||
return redirect(route('admin_payments_credit'));
|
||||
}
|
||||
|
||||
public function create(){
|
||||
public function create()
|
||||
{
|
||||
$data = Request::all();
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'create_credit'){
|
||||
if(!isset($data['userid'])){
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'create_credit') {
|
||||
if (!isset($data['userid'])) {
|
||||
abort(404);
|
||||
}
|
||||
$user = User::findOrFail($data['userid']);
|
||||
|
|
@ -79,7 +81,7 @@ class PaymentCreditController extends Controller
|
|||
\Session()->flash('alert-success', "Gutschrift erstellt");
|
||||
return redirect($data['back']);
|
||||
}
|
||||
if($data['action'] === 'user-credit-status'){
|
||||
if ($data['action'] === 'user-credit-status') {
|
||||
$UserCredit = UserCredit::findOrFail($data['id']);
|
||||
$UserCredit->status = $data['status'];
|
||||
$UserCredit->save();
|
||||
|
|
@ -89,34 +91,38 @@ class PaymentCreditController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
if(!session('credit_filter_month')){
|
||||
private function setFilterVars()
|
||||
{
|
||||
if (!session('credit_filter_month')) {
|
||||
session(['credit_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('credit_filter_year')){
|
||||
if (!session('credit_filter_year')) {
|
||||
session(['credit_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('credit_filter_name')){
|
||||
if (Request::get('credit_filter_name')) {
|
||||
session(['credit_filter_name' => Request::get('credit_filter_name')]);
|
||||
} else {
|
||||
session(['credit_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('credit_filter_month')){
|
||||
if (Request::get('credit_filter_month')) {
|
||||
session(['credit_filter_month' => Request::get('credit_filter_month')]);
|
||||
}
|
||||
if(Request::get('credit_filter_year')){
|
||||
if (Request::get('credit_filter_year')) {
|
||||
session(['credit_filter_year' => Request::get('credit_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
||||
private function makeUserCreditItems(){
|
||||
private function makeUserCreditItems()
|
||||
{
|
||||
$ret = [];
|
||||
$UserCreditItems = UserCreditItem::wherePaid(false)->get();
|
||||
foreach($UserCreditItems as $userCreditItem){
|
||||
if(isset($ret[$userCreditItem->user_id])){
|
||||
foreach ($UserCreditItems as $userCreditItem) {
|
||||
if (isset($ret[$userCreditItem->user_id])) {
|
||||
$ret[$userCreditItem->user_id]['sum'] += $userCreditItem->credit;
|
||||
$ret[$userCreditItem->user_id]['entries'][$userCreditItem->id] = $userCreditItem;
|
||||
}else{
|
||||
if(!isset($userCreditItem->user)){
|
||||
/* gelöschte User nicht anzeigen
|
||||
} else {
|
||||
if (!isset($userCreditItem->user)) {
|
||||
/* gelöschte User nicht anzeigen
|
||||
$user = User::withTrashed()->with(['account' => fn($q) => $q->withTrashed()])->where('id', $userCreditItem->user_id)->first();
|
||||
$ret[$userCreditItem->user_id] = [
|
||||
'user_id' => $userCreditItem->user_id,
|
||||
|
|
@ -128,7 +134,7 @@ class PaymentCreditController extends Controller
|
|||
'entries' => [$userCreditItem->id => $userCreditItem],
|
||||
];
|
||||
*/
|
||||
}else{
|
||||
} else {
|
||||
$ret[$userCreditItem->user_id] = [
|
||||
'user_id' => $userCreditItem->user_id,
|
||||
'm_account' => $userCreditItem->user->account->m_account,
|
||||
|
|
@ -138,20 +144,21 @@ class PaymentCreditController extends Controller
|
|||
'sum' => $userCreditItem->credit,
|
||||
'entries' => [$userCreditItem->id => $userCreditItem],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
public function delete($id, $del){
|
||||
public function delete($id, $del)
|
||||
{
|
||||
|
||||
if($del === 'user_credit_item'){
|
||||
if ($del === 'user_credit_item') {
|
||||
$UserCreditItem = UserCreditItem::findOrFail($id);
|
||||
if($deleteTime = $UserCreditItem->deleteTime()){
|
||||
if ($deleteTime = $UserCreditItem->deleteTime()) {
|
||||
$UserCreditItem->delete();
|
||||
\Session()->flash('alert-success', "Guthaben ist gelöscht");
|
||||
}else{
|
||||
} else {
|
||||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||
}
|
||||
}
|
||||
|
|
@ -160,24 +167,25 @@ class PaymentCreditController extends Controller
|
|||
|
||||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
|
||||
|
||||
$this->setFilterVars();
|
||||
|
||||
$date_start = Carbon::parse('01.'.Request::get('credit_filter_month').'.'.Request::get('credit_filter_year'))->format('Y-m-d');
|
||||
$date_end = Carbon::parse('01.'.Request::get('credit_filter_month').'.'.Request::get('credit_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
$date_start = Carbon::parse('01.' . Request::get('credit_filter_month') . '.' . Request::get('credit_filter_year'))->format('Y-m-d');
|
||||
$date_end = Carbon::parse('01.' . Request::get('credit_filter_month') . '.' . Request::get('credit_filter_year'))->endOfMonth()->format('Y-m-d');
|
||||
$query = UserCredit::with('user', 'user.account')->select('user_credits.*')
|
||||
->whereBetween('date', [$date_start, $date_end]);
|
||||
|
||||
if(Request::get('credit_filter_name')){
|
||||
->whereBetween('date', [$date_start, $date_end]);
|
||||
|
||||
if (Request::get('credit_filter_name')) {
|
||||
$query->whereHas('user.account', function ($query) {
|
||||
return $query->where('first_name', 'LIKE', '%'.Request::get('credit_filter_name').'%')
|
||||
->orWhere('last_name', 'LIKE', '%'.Request::get('credit_filter_name').'%');
|
||||
});
|
||||
return $query->where('first_name', 'LIKE', '%' . Request::get('credit_filter_name') . '%')
|
||||
->orWhere('last_name', 'LIKE', '%' . Request::get('credit_filter_name') . '%');
|
||||
});
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->initSearch();
|
||||
|
||||
|
|
@ -194,57 +202,54 @@ class PaymentCreditController extends Controller
|
|||
})
|
||||
->addColumn('view', function (UserCredit $UserCredit) {
|
||||
$ret = "";
|
||||
if($UserCredit->isCredit()){
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a><br>';
|
||||
if ($UserCredit->isCredit()) {
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a><br>';
|
||||
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'html']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
|
||||
|
||||
}else{
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit_detail', 'html']) . '" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']) . '" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
} else {
|
||||
$ret = "-";
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
|
||||
->addColumn('total', function (UserCredit $UserCredit) {
|
||||
return '<span class="no-line-break">'.$UserCredit->getFormattedTotal()." €</span>";
|
||||
return '<span class="no-line-break">' . $UserCredit->getFormattedTotal() . " €</span>";
|
||||
})
|
||||
->addColumn('credits', function (UserCredit $UserCredit) {
|
||||
$ret = "";
|
||||
if($UserCredit->user_credit_items){
|
||||
foreach($UserCredit->user_credit_items as $user_credit_item){
|
||||
$ret .= nl2br($user_credit_item->getTransMessage())." / ".$user_credit_item->created_at->format('d.m.Y')."<br>";
|
||||
|
||||
if ($UserCredit->user_credit_items) {
|
||||
foreach ($UserCredit->user_credit_items as $user_credit_item) {
|
||||
$ret .= nl2br($user_credit_item->getTransMessage()) . " / " . $user_credit_item->created_at->format('d.m.Y') . "<br>";
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
})
|
||||
->addColumn('status', function (UserCredit $UserCredit) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserCredit->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserCredit->getStatusColor().'">'.$UserCredit->getStatusType().' <span class="ion ion-md-cash"></span></span>
|
||||
data-id="' . $UserCredit->id . '" data-route="' . route('modal_load') . '" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-' . $UserCredit->getStatusColor() . '">' . $UserCredit->getStatusType() . ' <span class="ion ion-md-cash"></span></span>
|
||||
</a>';
|
||||
})
|
||||
->filterColumn('user.account.first_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
->filterColumn('user.account.first_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('user.account', function ($query) use ($keyword) {
|
||||
return $query->where('first_name', 'LIKE', '%'.$keyword.'%');
|
||||
return $query->where('first_name', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
->filterColumn('user.account.last_name', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
->filterColumn('user.account.last_name', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('user.account', function ($query) use ($keyword) {
|
||||
return $query->where('last_name', 'LIKE', '%'.$keyword.'%');
|
||||
return $query->where('last_name', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
->filterColumn('user.email', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
->filterColumn('user.email', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->whereHas('user', function ($query) use ($keyword) {
|
||||
return $query->where('email', 'LIKE', '%'.$keyword.'%');
|
||||
return $query->where('email', 'LIKE', '%' . $keyword . '%');
|
||||
});
|
||||
}
|
||||
})
|
||||
|
|
@ -254,4 +259,4 @@ class PaymentCreditController extends Controller
|
|||
->rawColumns(['total', 'credits', 'status', 'view'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
|
|
@ -19,7 +20,7 @@ class PaymentInvoiceController extends Controller
|
|||
|
||||
public function index()
|
||||
{
|
||||
|
||||
|
||||
$this->setFilterVars();
|
||||
$data = [
|
||||
'filter_months' => HTMLHelper::getTransMonths(),
|
||||
|
|
@ -28,21 +29,24 @@ class PaymentInvoiceController extends Controller
|
|||
return view('admin.payment.invoice', $data);
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('invoice_filter_month')){
|
||||
if (!session('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('invoice_filter_year')){
|
||||
if (!session('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('invoice_filter_name')){
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
session(['invoice_filter_name' => Request::get('invoice_filter_name')]);
|
||||
} else {
|
||||
session(['invoice_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('invoice_filter_month')){
|
||||
if (Request::get('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => Request::get('invoice_filter_month')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_year')){
|
||||
if (Request::get('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => Request::get('invoice_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,53 +54,53 @@ class PaymentInvoiceController extends Controller
|
|||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if(Request::get('invoice_filter_name')){
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
$query->whereHas('shopping_order.shopping_user', function ($query) {
|
||||
return $query->where('billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%')->orWhere('billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
return $query->where('billing_firstname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%')->orWhere('billing_lastname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%')->orWhere('billing_email', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
})->get();
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->initSearch();
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order->auth_user_id){
|
||||
if ($UserInvoice->shopping_order->auth_user_id) {
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
}
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
||||
})
|
||||
->addColumn('total_shipping', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping()." €</span>";
|
||||
return '<span class="no-line-break">' . $UserInvoice->shopping_order->getFormattedTotalShipping() . " €</span>";
|
||||
})
|
||||
->addColumn('created_at', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('txaction', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order){
|
||||
if ($UserInvoice->shopping_order) {
|
||||
return Payment::getShoppingOrderBadge($UserInvoice->shopping_order);
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('status', function (UserInvoice $UserInvoice) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserInvoice->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserInvoice->getStatusColor().'">'.$UserInvoice->getStatusType().'</span>
|
||||
data-id="' . $UserInvoice->id . '" data-route="' . route('modal_load') . '" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-' . $UserInvoice->getStatusColor() . '">' . $UserInvoice->getStatusType() . '</span>
|
||||
</a>';
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
return $ret;
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
|
|
@ -110,4 +114,4 @@ class PaymentInvoiceController extends Controller
|
|||
->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\Services\Payment;
|
||||
|
|
@ -32,21 +33,24 @@ class PaymentPointsController extends Controller
|
|||
return view('admin.payment.invoice', $data);
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('invoice_filter_month')){
|
||||
if (!session('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('invoice_filter_year')){
|
||||
if (!session('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(Request::get('invoice_filter_name')){
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
session(['invoice_filter_name' => Request::get('invoice_filter_name')]);
|
||||
} else {
|
||||
session(['invoice_filter_name' => '']);
|
||||
}
|
||||
if(Request::get('invoice_filter_month')){
|
||||
if (Request::get('invoice_filter_month')) {
|
||||
session(['invoice_filter_month' => Request::get('invoice_filter_month')]);
|
||||
}
|
||||
if(Request::get('invoice_filter_year')){
|
||||
if (Request::get('invoice_filter_year')) {
|
||||
session(['invoice_filter_year' => Request::get('invoice_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -54,59 +58,59 @@ class PaymentPointsController extends Controller
|
|||
private function initSearch($archive = false, $request = true)
|
||||
{
|
||||
$this->setFilterVars();
|
||||
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if(Request::get('invoice_filter_name')){
|
||||
$query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%'.Request::get('invoice_filter_name').'%');
|
||||
$query = UserInvoice::with('shopping_order')->with('shopping_order.shopping_user')->select('user_invoices.*')
|
||||
->where('user_invoices.month', '=', Request::get('invoice_filter_month'))
|
||||
->where('user_invoices.year', '=', Request::get('invoice_filter_year'));
|
||||
|
||||
if (Request::get('invoice_filter_name')) {
|
||||
$query->where('shopping_order.shopping_user.billing_firstname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
$query->where('shopping_order.shopping_user.billing_lastname', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
$query->where('shopping_order.shopping_user.billing_email', 'LIKE', '%' . Request::get('invoice_filter_name') . '%');
|
||||
}
|
||||
|
||||
//->orderBy('created_at', 'DESC');
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
/* $query = FlexHour::leftJoin("flex_hour_items", function($join) {
|
||||
$join->on("flex_hour_items.flex_hour_id","=","flex_hours.id");
|
||||
$join->where("flex_hour_items.date","=", FlexHourItemBot::$date);
|
||||
})*/
|
||||
return $query;
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
public function datatable()
|
||||
{
|
||||
|
||||
$query = $this->initSearch();
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order->auth_user_id){
|
||||
if ($UserInvoice->shopping_order->auth_user_id) {
|
||||
return '<a href="' . route('admin_sales_users_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
}
|
||||
return '<a href="' . route('admin_sales_customers_detail', [$UserInvoice->shopping_order->id]) . '" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
|
||||
})
|
||||
->addColumn('total_shipping', function (UserInvoice $UserInvoice) {
|
||||
return '<span class="no-line-break">'.$UserInvoice->shopping_order->getFormattedTotalShipping()." €</span>";
|
||||
return '<span class="no-line-break">' . $UserInvoice->shopping_order->getFormattedTotalShipping() . " €</span>";
|
||||
})
|
||||
->addColumn('created_at', function (UserInvoice $UserInvoice) {
|
||||
return $UserInvoice->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('txaction', function (UserInvoice $UserInvoice) {
|
||||
if($UserInvoice->shopping_order){
|
||||
if ($UserInvoice->shopping_order) {
|
||||
return Payment::getShoppingOrderBadge($UserInvoice->shopping_order);
|
||||
}
|
||||
return "-";
|
||||
})
|
||||
->addColumn('status', function (UserInvoice $UserInvoice) {
|
||||
return '<a href="#" data-toggle="modal" data-target="#modals-load-content" data-modal="modal-lg"
|
||||
data-id="'.$UserInvoice->id.'" data-route="'.route('modal_load').'" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-'.$UserInvoice->getStatusColor().'">'.$UserInvoice->getStatusType().'</span>
|
||||
data-id="' . $UserInvoice->id . '" data-route="' . route('modal_load') . '" data-action="user-credit-status" data-view="">
|
||||
<span class="badge badge-pill badge-' . $UserInvoice->getStatusColor() . '">' . $UserInvoice->getStatusType() . '</span>
|
||||
</a>';
|
||||
})
|
||||
->addColumn('invoice', function (UserInvoice $UserInvoice) {
|
||||
$ret = "";
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'download']) . '" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="' . route('storage_file', [$UserInvoice->shopping_order->id, 'invoice', 'stream']) . '" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
|
||||
return $ret;
|
||||
})
|
||||
|
||||
|
|
@ -118,4 +122,4 @@ class PaymentPointsController extends Controller
|
|||
->rawColumns(['id', 'shipping_order', 'txaction', 'total_shipping', 'status', 'txaction', 'invoice'])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class SalesController extends Controller
|
|||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
|
|
@ -132,9 +132,17 @@ class SalesController extends Controller
|
|||
set_user_attr('filter_member_id', null);
|
||||
return redirect(route('admin_sales_customers'));
|
||||
}
|
||||
$filter_user_shops = ShoppingOrder::join('user_shops', 'user_shop_id', '=', 'user_shops.id')->orderBy('slug')->get()->pluck('slug', 'id')->unique()->toArray();
|
||||
$filter_user_shops = ShoppingOrder::select('user_shops.id', 'user_shops.slug')
|
||||
->join('user_shops', 'shopping_orders.user_shop_id', '=', 'user_shops.id')
|
||||
->orderBy('user_shops.slug')
|
||||
->distinct()
|
||||
->pluck('slug', 'id')
|
||||
->toArray();
|
||||
$filter_members = ShoppingOrder::join('users', 'member_id', '=', 'users.id')->groupBy('member_id')->join('user_accounts', 'account_id', '=', 'user_accounts.id')->select('users.id', 'users.email', 'user_accounts.first_name', 'user_accounts.last_name')->get();
|
||||
//->pluck('email', 'id')->unique()->toArray();
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'filter_user_shops' => $filter_user_shops,
|
||||
'filter_members' => $filter_members,
|
||||
|
|
@ -270,7 +278,7 @@ class SalesController extends Controller
|
|||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
if(($ShoppingOrder->txaction === 'extern' || $ShoppingOrder->txaction === 'extern_paid') && $ShoppingOrder->wp_invoice_path){
|
||||
|
|
@ -365,11 +373,13 @@ class SalesController extends Controller
|
|||
if(isset($data['action'])){
|
||||
if($data['action'] === 'create_invoice'){
|
||||
$shopping_order = ShoppingOrder::findOrFail($data['id']);
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if($shopping_order->isInvoice()){
|
||||
$invoice_repo->update($data);
|
||||
}else{
|
||||
$invoice_repo->createAndSalesVolume($data);
|
||||
if($shopping_order->mode === 'live'){
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if($shopping_order->isInvoice()){
|
||||
$invoice_repo->update($data);
|
||||
}else{
|
||||
$invoice_repo->createAndSalesVolume($data);
|
||||
}
|
||||
}
|
||||
if(isset($data['view']) && $data['view'] === 'sales_customer'){
|
||||
return redirect(route('admin_sales_customers_detail', [$shopping_order->id]));
|
||||
|
|
|
|||
322
app/Http/Controllers/User/AboController.php
Normal file
322
app/Http/Controllers/User/AboController.php
Normal file
|
|
@ -0,0 +1,322 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserAbo;
|
||||
use App\Models\UserAboItem;
|
||||
use App\Repositories\AboRepository;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\AboOrderCart;
|
||||
use App\Services\Shop;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use Request;
|
||||
use Yard;
|
||||
|
||||
class AboController extends Controller
|
||||
{
|
||||
protected $aboRepository;
|
||||
|
||||
public function __construct(AboRepository $aboRepository)
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
$this->aboRepository = $aboRepository;
|
||||
}
|
||||
|
||||
public function index($view)
|
||||
{
|
||||
|
||||
if ($view === 'me') {
|
||||
// Nur Abos des aktuellen Benutzers
|
||||
$user_abos = UserAbo::where('user_id', \Auth::user()->id)
|
||||
->where('status', '>', 1);
|
||||
|
||||
if ($user_abos->count() > 0) {
|
||||
return redirect(route('user_abos_detail', ['me', $user_abos->first()->id]));
|
||||
}
|
||||
|
||||
return view('user.abo.index', [
|
||||
'user_abos' => [],
|
||||
'view' => 'me',
|
||||
'isAdmin' => false
|
||||
]);
|
||||
}
|
||||
|
||||
if ($view === 'ot') {
|
||||
$user_abos = UserAbo::where('member_id', \Auth::user()->id)
|
||||
->where('status', '>', 1)
|
||||
->where('is_for', 'ot')
|
||||
->orderBy('id', 'desc')
|
||||
->get();
|
||||
|
||||
return view('user.abo.index', [
|
||||
'user_abos' => $user_abos,
|
||||
'view' => 'ot',
|
||||
'isAdmin' => false
|
||||
]);
|
||||
}
|
||||
|
||||
// Standardfall, wenn weder 'me' noch 'ot'
|
||||
return view('user.abo.index', [
|
||||
'user_abos' => [],
|
||||
'view' => 'me',
|
||||
'isAdmin' => false
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function detail($view, $id)
|
||||
{
|
||||
$data = Request::all();
|
||||
$user_abo = UserAbo::findOrFail($id);
|
||||
|
||||
|
||||
$this->checkPermissions($view, $user_abo);
|
||||
|
||||
//init Yard
|
||||
AboOrderCart::initYard($user_abo);
|
||||
//holt die aktuellen UserAccount Daten oder die Userdaten des Abo
|
||||
$customer_detail = AboOrderCart::getCustomerDetail();
|
||||
AboOrderCart::makeOrderYard($user_abo);
|
||||
|
||||
$comp_products = [];
|
||||
if ($user_abo->is_for === 'me') {
|
||||
$comp_products = Shop::getCompProducts('abo-me');
|
||||
}
|
||||
|
||||
$data = [
|
||||
'user_abo' => $user_abo,
|
||||
'isAdmin' => false,
|
||||
'customer_detail' => $customer_detail,
|
||||
'view' => $view,
|
||||
'comp_products' => $comp_products,
|
||||
];
|
||||
return view('user.abo.detail', $data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function update($view, $id)
|
||||
{
|
||||
$data = Request::all();
|
||||
$user_abo = UserAbo::findOrFail($id);
|
||||
|
||||
$this->checkPermissions($view, $user_abo);
|
||||
if (isset($data['action'])) {
|
||||
if ($data['action'] === 'abo_update_settings') {
|
||||
$user_abo = UserAbo::findOrFail($data['id']);
|
||||
$this->aboRepository->setModel($user_abo);
|
||||
$this->aboRepository->update($data);
|
||||
return redirect(route('user_abos_detail', [$view, $id]));
|
||||
}
|
||||
|
||||
if (Request::ajax()) {
|
||||
$message = false;
|
||||
//addProduct
|
||||
if ($data['action'] === 'addProduct') {
|
||||
if ($product = Product::find($data['product_id'])) {
|
||||
if ($UserAboItem = UserAboItem::where('user_abo_id', $user_abo->id)->where('product_id', $product->id)->where('comp', 0)->first()) {
|
||||
$UserAboItem->qty = $UserAboItem->qty + 1;
|
||||
$UserAboItem->save();
|
||||
} else {
|
||||
UserAboItem::create([
|
||||
'user_abo_id' => $user_abo->id,
|
||||
'product_id' => $product->id,
|
||||
'comp' => 0,
|
||||
'qty' => 1,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//updateCart
|
||||
if ($data['action'] === 'updateCart') {
|
||||
//product_id | order_item_id | cart_order_id | qty
|
||||
if (isset($data['product_id']) && $product = Product::find($data['product_id'])) {
|
||||
if (isset($data['order_item_id']) && $UserAboItem = UserAboItem::find($data['order_item_id'])) {
|
||||
if (isset($data['qty'])) {
|
||||
$qty = (int) $data['qty'];
|
||||
$qty = $qty < 1 ? 1 : $qty;
|
||||
$qty = $qty > 100 ? 100 : $qty;
|
||||
$UserAboItem->qty = $qty;
|
||||
$UserAboItem->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//removeFromCart
|
||||
if ($data['action'] === 'removeFromCart') {
|
||||
if (!isset($data['product_id']) || !($product = Product::find($data['product_id']))) {
|
||||
$message = __('abo.product_not_found');
|
||||
}
|
||||
if (!isset($data['order_item_id']) || !($userAboItem = UserAboItem::find($data['order_item_id']))) {
|
||||
$message = __('abo.abo_item_not_found');
|
||||
}
|
||||
$has_basis_product = $this->check_need_basis_product($user_abo, $product, $data['order_item_id']);
|
||||
if (!$has_basis_product) {
|
||||
$message = __('abo.need_basis_product');
|
||||
}
|
||||
if (!$message) {
|
||||
|
||||
|
||||
$userAboItem->delete();
|
||||
$user_abo->refresh(); // Abo neu laden um die aktualisierten Items zu erhalten
|
||||
}
|
||||
}
|
||||
//updateCompProduct
|
||||
if ($data['action'] === 'updateCompProduct') {
|
||||
if ($UserAboItem = UserAboItem::where('user_abo_id', $user_abo->id)->where('comp', $data['comp_num'])->first()) {
|
||||
$UserAboItem->product_id = $data['comp_product_id'];
|
||||
$UserAboItem->save();
|
||||
} else {
|
||||
UserAboItem::create([
|
||||
'user_abo_id' => $user_abo->id,
|
||||
'product_id' => $data['comp_product_id'],
|
||||
'comp' => $data['comp_num'],
|
||||
'qty' => 1,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AboOrderCart::initYard($user_abo);
|
||||
AboOrderCart::makeOrderYard($user_abo); //reCalculateShippingPrice
|
||||
AboOrderCart::checkNumOfCompProducts($user_abo); //after reCalculateShippingPrice check it and remove or add comp product
|
||||
|
||||
if ($user_abo->is_for === 'me') {
|
||||
$data['comp_products'] = Shop::getCompProducts('abo-me');
|
||||
}
|
||||
$error_message = $message ? $message : false;
|
||||
$html_cart = view("admin.abo._order_abo_show", ['user_abo' => $user_abo, 'error_message' => $error_message])->render();
|
||||
$html_comp = view("user.order.comp_product", $data)->render();
|
||||
|
||||
$amount = $user_abo->getFormattedAmount();
|
||||
|
||||
// $html_total = view("user.homeparty.show_total_order", ['homeparty' => $homeparty])->render();
|
||||
return response()->json(['response' => true, 'data' => $data, 'html_cart' => $html_cart, 'html_comp' => $html_comp, 'amount' => $amount]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function check_need_basis_product($user_abo, $product, $order_item_id)
|
||||
{
|
||||
// Wenn das zu entfernende Produkt kein Basis-Produkt ist, keine weitere Prüfung nötig
|
||||
if (AboHelper::getAboShowOn($product) !== 'base') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Prüfe ob noch ein anderes Basis-Produkt vorhanden ist
|
||||
foreach ($user_abo->user_abo_items as $user_abo_item) {
|
||||
if ($user_abo_item->id == $order_item_id) {
|
||||
continue;
|
||||
}
|
||||
if (AboHelper::getAboShowOn($user_abo_item->product) === 'base') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function datatable($user_abo_id)
|
||||
{
|
||||
$user_abo = UserAbo::findOrFail($user_abo_id);
|
||||
if (!$user_abo) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
//$user_abo->is_for === 'me'
|
||||
|
||||
$show_on_ids = ['12', '13'];
|
||||
$query = Product::select('products.*')
|
||||
->where('active', true)
|
||||
->where(function ($q) use ($show_on_ids) {
|
||||
foreach ($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->orderByRaw(
|
||||
"CASE
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 1
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 2
|
||||
ELSE 3 END",
|
||||
[$show_on_ids[0], isset($show_on_ids[1]) ? $show_on_ids[1] : $show_on_ids[0]]
|
||||
);
|
||||
|
||||
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('add_card', function (Product $product) use ($user_abo) {
|
||||
$ufactor = $user_abo->is_for === 'me' ? true : false;
|
||||
$tax_free = $user_abo->is_for === 'me' ? true : Yard::instance('shopping')->getUserTaxFree();
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="' . $product->id . '">
|
||||
<strong>€ ' . $product->getFormattedPriceWith($tax_free, $ufactor, Yard::instance('shopping')->getUserCountry()) . '</strong> +<span class="ion ion-md-cart"></span>
|
||||
</button>';
|
||||
})
|
||||
->addColumn('picture', function (Product $product) {
|
||||
if (count($product->images)) {
|
||||
return '<img class="img-fluid img-extra" alt="" src="' . route('product_image', [$product->images->first()->slug]) . '">';
|
||||
}
|
||||
return "";
|
||||
})
|
||||
->addColumn('name', function (Product $product) use ($user_abo) {
|
||||
return '<strong>' . $product->getLang('name') . '</strong><br>' . get_abo_type_badge_by_product($product);
|
||||
})
|
||||
|
||||
->addColumn('price_net', function (Product $product) use ($user_abo) {
|
||||
$ufactor = $user_abo->is_for === 'me' ? true : false;
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(true, $ufactor, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
})
|
||||
->addColumn('price_gross', function (Product $product) use ($user_abo) {
|
||||
$ufactor = $user_abo->is_for === 'me' ? true : false;
|
||||
return '<span class="no-line-break">' . $product->getFormattedPriceWith(false, $ufactor, Yard::instance('shopping')->getUserCountry()) . " €</span>" . '<span class="no-line-break">' . $product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()) . '</span>';
|
||||
})
|
||||
->addColumn('action', function (Product $product) {
|
||||
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
|
||||
data-toggle="modal" data-target="#modals-load-content" data-id="' . $product->id . '" data-route="' . route('modal_load') . '"
|
||||
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
|
||||
})
|
||||
->filterColumn('product', function ($query, $keyword) {
|
||||
if ($keyword != "") {
|
||||
$query->where('name', 'LIKE', '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->orderColumn('name', 'name $1')
|
||||
->orderColumn('product', 'name $1')
|
||||
->orderColumn('number', 'number $1')
|
||||
->orderColumn('points', 'points $1')
|
||||
->orderColumn('price_net', 'price_net $1')
|
||||
->orderColumn('price_gross', 'price_gross $1')
|
||||
->orderColumn('contents_total', 'contents_total $1')
|
||||
->orderColumn('weight', 'weight $1')
|
||||
|
||||
->rawColumns(['add_card', 'product', 'name', 'quantity', 'picture', 'price_net', 'price_gross', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function checkPermissions($view, $user_abo)
|
||||
{
|
||||
if ($view === 'me' && $user_abo->is_for !== 'me') {
|
||||
abort(403, 'Unauthorized action. Is not for me');
|
||||
}
|
||||
if ($view === 'ot' && $user_abo->is_for !== 'ot') {
|
||||
abort(403, 'Unauthorized action. Is not your customer');
|
||||
}
|
||||
if ($view === 'me' && $user_abo->user_id !== \Auth::user()->id) {
|
||||
abort(403, 'Unauthorized action. Is not my abo');
|
||||
}
|
||||
if ($view === 'ot' && $user_abo->member_id !== \Auth::user()->id) {
|
||||
abort(403, 'Unauthorized action. Is not my customer abo');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,10 +5,13 @@ namespace App\Http\Controllers\User;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Repositories\CustomerRepository;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\HTMLHelper;
|
||||
use App\Services\ShoppingUserService;
|
||||
use App\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Request;
|
||||
use Validator;
|
||||
|
||||
|
|
@ -227,23 +230,51 @@ class CustomerController extends Controller
|
|||
return redirect(route('user_customer_detail', [$shopping_user->id]));
|
||||
}
|
||||
|
||||
|
||||
private function checkShoppingUsersByEmail(){
|
||||
|
||||
//ist an dieser stelle nicht machbar, zu viele Datenbankzugriffe
|
||||
//siehe App\Console\Commands\SyncShoppingUserData
|
||||
/* $user = User::find(\Auth::user()->id);
|
||||
ShoppingUserService::setFakerMail($user);
|
||||
ShoppingUserService::syncNumbersByEmail($user);
|
||||
ShoppingUserService::syncOrdersByEmail($user); */
|
||||
|
||||
}
|
||||
public function getCustomers()
|
||||
{
|
||||
//$this->checkShoppingUsersByEmail();
|
||||
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
//\Log::info('Current user ID: ' . $user->id);
|
||||
|
||||
$query = ShoppingUser::select(['id', 'billing_company', 'billing_salutation', 'billing_firstname', 'billing_lastname', 'billing_email', 'faker_mail', 'billing_zipcode', 'billing_city', 'billing_country_id', 'orders', 'subscribed', 'created_at', 'number', 'mode', 'is_like', 'wp_order_number'])
|
||||
->where('shopping_users.member_id', '=', $user->id);
|
||||
//->groupBy('shopping_users.number');
|
||||
->with('billing_country')
|
||||
->whereIn('id', function($query) {
|
||||
$query->select(DB::raw('MAX(id)'))
|
||||
->from('shopping_users')
|
||||
->groupBy('billing_email');
|
||||
})->where('shopping_users.member_id', '=', $user->id)->where('shopping_users.auth_user_id', '=', NULL);
|
||||
|
||||
/*set_user_attr('filter_member_id', Request::get('filter_member_id'));
|
||||
if(Request::get('filter_member_id') != ""){
|
||||
$query->where('member_id', '=', Request::get('filter_member_id'));
|
||||
}*/
|
||||
if(Request::get('isfor') === 'ot-member'){ //Bestellung für Kunden
|
||||
}
|
||||
if(Request::get('isfor') === 'ot-customer' || Request::get('isfor') === 'abo-ot-customer'){ //Bestellung für Kunden Zahlungslink
|
||||
$query->where(function($q) {
|
||||
$q->where('shopping_users.faker_mail', '!=', 1)
|
||||
->orWhereNull('shopping_users.faker_mail');
|
||||
});
|
||||
}
|
||||
//\Log::info('SQL Query: ' . $query->toSql());
|
||||
//\Log::info('Query Bindings: ' . print_r($query->getBindings(), true));
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('send_to', function (ShoppingUser $ShoppingUser) {
|
||||
$ot = Request::get('isfor') ? Request::get('isfor') : 'ot-member';
|
||||
if(Request::get('isfor') === 'abo-ot-customer' && AboHelper::memberHasAbo($ShoppingUser)){
|
||||
return '<span class="badge badge-pill badge-success"><i class="fa fa-check-circle"></i> '.__('abo.abo_assigned').'</span>';
|
||||
}
|
||||
return $ShoppingUser->is_like ? '<span class="badge badge-pill badge-warning"><i class="fa fa-clock"></i> '.__('customer.under_review').'</span>' : '<a href="' . route('user_order_my_delivery', [$ot, $ShoppingUser->id]) . '" class="btn btn-sm btn-secondary"><span class="fa fa-shopping-cart"></span> '.__('customer.select').'</a>';
|
||||
})
|
||||
->addColumn('billing_email', function (ShoppingUser $ShoppingUser) {
|
||||
|
|
@ -262,7 +293,7 @@ class CustomerController extends Controller
|
|||
return $ShoppingUser->firstEntryByNumber()->created_at->format('d.m.Y');
|
||||
})
|
||||
->addColumn('orders', function (ShoppingUser $ShoppingUser) {
|
||||
return $ShoppingUser->lastEntryByNumber()->orders;
|
||||
return $ShoppingUser->orders;
|
||||
})
|
||||
->addColumn('subscribed', function (ShoppingUser $ShoppingUser) {
|
||||
return get_active_badge($ShoppingUser->subscribed);
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ use Request;
|
|||
use App\User;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Models\Product;
|
||||
use App\Services\Payment;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Services\UserService;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingInstance;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
class MembershipController extends Controller
|
||||
|
|
@ -39,11 +41,35 @@ class MembershipController extends Controller
|
|||
if($user->payment_account){
|
||||
$diff_months = Carbon::now()->diffInMonths(Carbon::parse($user->payment_account)) +1;
|
||||
}
|
||||
|
||||
$userShoppingOrders = ShoppingOrder::with('shopping_user', 'shopping_payments')->select('shopping_orders.*')
|
||||
->where('auth_user_id', '=', $user->id)
|
||||
->where('txaction', '!=', NULL)
|
||||
->whereIn('payment_for', [1, 2])
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
|
||||
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->get()->last();
|
||||
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->get()->last();
|
||||
$userHistoryPaymentOrder = null;
|
||||
$userHistoryUpgradeOrder = null;
|
||||
|
||||
/* Bezhalung ist nur 29 Tage vor ablauf möglich */
|
||||
/* isRenewalAccount payment_account date - config('mivita.renewal_days') Vertragsverlängerung */
|
||||
if($user->isRenewalAccount()){
|
||||
//Acount ist noch nicht verlängert / bezahlt
|
||||
if ($user->payment_account) {
|
||||
//Die Order muss größer als das Datum sein.
|
||||
$payment_greaterThan = Carbon::parse($user->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days');
|
||||
$userHistoryPaymentOrder = UserHistory::whereUserId($user->id)->whereAction('payment_order')->where('created_at', '>=', $payment_greaterThan)->get()->last();
|
||||
}
|
||||
}
|
||||
if($user->isActiveAccount() && !$user->isActiveShop()){
|
||||
$payment_greaterThan = Carbon::parse($user->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days');
|
||||
$userHistoryUpgradeOrder = UserHistory::whereUserId($user->id)->whereAction('upgrade_order')->where('created_at', '>=', $payment_greaterThan)->get()->last();
|
||||
|
||||
}
|
||||
$userHistoryDeleteMembership = UserHistory::whereUserId($user->id)->whereAction('delete_membership')->whereStatus(50)->get()->last();
|
||||
|
||||
|
||||
$shipping_country_id = $this->checkShoppingCountry($user);
|
||||
if(!$shipping_country_id){
|
||||
abort(403, __('validation.custom.shipping_not_found'));
|
||||
|
|
@ -60,6 +86,7 @@ class MembershipController extends Controller
|
|||
'userHistoryUpgradeOrder' => $userHistoryUpgradeOrder,
|
||||
'userHistoryDeleteMembership' => $userHistoryDeleteMembership,
|
||||
'yard_info' => UserService::getYardInfo(),
|
||||
'userShoppingOrders' => $userShoppingOrders,
|
||||
];
|
||||
return view('user.membership.index', $data);
|
||||
|
||||
|
|
@ -131,7 +158,7 @@ class MembershipController extends Controller
|
|||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
674
app/Http/Controllers/User/OrderController_bak.php
Normal file
674
app/Http/Controllers/User/OrderController_bak.php
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailCustomPaymet;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserHistory;
|
||||
use App\Services\AboHelper;
|
||||
use App\Services\OrderPaymentService;
|
||||
use App\Services\Payment;
|
||||
use App\Services\Shop;
|
||||
use App\Services\UserService;
|
||||
use App\Services\Util;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
use Validator;
|
||||
use Yard;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$data = [
|
||||
];
|
||||
return view('user.order.index', $data);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->auth_user_id !== $user->id){
|
||||
abort(404);
|
||||
}
|
||||
if( $shopping_order->payment_for === 6 || $shopping_order->payment_for === 7){
|
||||
return redirect(route('user_shop_order_detail', [$shopping_order->id]));
|
||||
abort(403, 'Kundenbestellung');
|
||||
}
|
||||
$shopping_order->getLastShoppingPayment();
|
||||
|
||||
$data = [
|
||||
'shopping_order' => $shopping_order,
|
||||
'isAdmin' => false,
|
||||
];
|
||||
return view('user.order.detail', $data);
|
||||
}
|
||||
|
||||
public function ordersDatatable(){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$query = ShoppingOrder::with('shopping_user', 'shopping_payments')->select('shopping_orders.*')->where('auth_user_id', '=', $user->id)->where('txaction', '!=', NULL);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<a href="'.route('user_order_detail', [$ShoppingOrder->id]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('created_at', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getShoppingOrderBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('total_shipping', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="no-line-break">'.$ShoppingOrder->getFormattedTotalShipping()." €</span>";
|
||||
})
|
||||
->addColumn('payment', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('getPaymentType');
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
if($ShoppingOrder->payment_for === 8){
|
||||
return '<button type="button" class="btn btn-xs btn-info btn-round" data-toggle="modal" data-target="#modals-load-content"
|
||||
data-id="'.$ShoppingOrder->id.'"
|
||||
data-action="shop-user-order-shipping-detail"
|
||||
data-back=""
|
||||
data-modal="modal-xl"
|
||||
data-init_from="user"
|
||||
data-route="'.route('modal_load').'"><span class="fa fa-eye"></span></button>';
|
||||
}
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
|
||||
})
|
||||
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->isInvoice() ? '<span class="no-line-break"><a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a>
|
||||
<a href="'.route('storage_file', [$ShoppingOrder->id, 'invoice', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a></span>' : '-';
|
||||
})
|
||||
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
|
||||
return $ShoppingOrder->getLastShoppingPayment('reference');
|
||||
})
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('shipped', 'shipped $1')
|
||||
->orderColumn('total_shipping', 'total_shipping $1')
|
||||
->orderColumn('payment_for', 'payment_for $1')
|
||||
|
||||
->rawColumns(['id', 'txaction', 'payment_for', 'total_shipping', 'invoice', 'shipped'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
/*
|
||||
$for = me, ot-member, ot-customer, abo-ot-member, abo-ot-customer, abo-me
|
||||
*/
|
||||
|
||||
public function delivery($for, $id=null)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
if(strpos($for, 'ot') !== false){ //ot-member, ot-customer abo-ot-member, abo-ot-customer,
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
if(!Shop::checkShoppingCountry($for, $delivery_id) && !\Session()->has('custom-error')){
|
||||
$country = Shop::getDeliveryCountry($for, $delivery_id);
|
||||
\Session()->flash('custom-error', $country.": ".__('validation.custom.shipping_not_found'));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
if($for === 'abo-ot-customer'){
|
||||
//check if user has an Abo
|
||||
if(AboHelper::hasAboByEmail($shopping_user->billing_email) && !\Session()->has('custom-error')){
|
||||
\Session()->flash('custom-error', __('abo.error_email_has_abo', ['email' => $shopping_user->billing_email]));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(Request::get('action') === 'next'){
|
||||
Yard::instance('shopping')->destroy();
|
||||
if(strpos(Request::get('switchers-radio-is-for'), 'ot') !== false){
|
||||
$delivery_id = $id;
|
||||
}
|
||||
return redirect(route('user_order_my_list', [Request::get('switchers-radio-is-for'), $delivery_id]));
|
||||
}
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'isAdmin' => false,
|
||||
'isView' => 'customer',
|
||||
'for' => $for,
|
||||
'delivery_id' => $delivery_id,
|
||||
];
|
||||
return view('user.order.delivery', $data);
|
||||
}
|
||||
|
||||
public function list($for, $id=null)
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if($for === 'abo-me' && AboHelper::userHasAbo($user)){
|
||||
abort(403, 'User has an Abo. Cannot order.');
|
||||
}
|
||||
$shopping_user = null;
|
||||
$delivery_id = null;
|
||||
if(strpos($for, 'ot') !== false){ //ot-member, ot-customer abo-ot-member, abo-ot-customer,
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
$delivery_id = $shopping_user->id;
|
||||
}
|
||||
if($for === 'ot-customer' || $for === 'abo-ot-customer'){
|
||||
//Liederung an (abo-) ot-customer (Kunden) Zahlung und Rechnung geht an Kunden
|
||||
UserService::initCustomerYard($shopping_user, $for);
|
||||
}else{
|
||||
//Lieferung an user oder (abo-) ot-member (Kunden) rechnung geht an User
|
||||
//lieferland und rechnungsland prüfen
|
||||
$shipping_country_id = Shop::checkShoppingCountry($for, $id);
|
||||
if(!$shipping_country_id){
|
||||
$country = Shop::getDeliveryCountry($for, $id);
|
||||
\Session()->flash('custom-error', $country.": ".__('validation.custom.shipping_not_found'));
|
||||
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
|
||||
}
|
||||
UserService::initUserYard($user, $shipping_country_id, $for);
|
||||
}
|
||||
$data = [
|
||||
'shopping_user' => $shopping_user,
|
||||
'user' => $user,
|
||||
'isAdmin' => false,
|
||||
'isView' => 'customer',
|
||||
'for' => $for,
|
||||
'template' => str_replace('abo-', '', $for),
|
||||
'delivery_id' => $delivery_id,
|
||||
'is_abo' => strpos($for, 'abo') !== false,
|
||||
'comp_products' => Shop::getCompProducts($for),
|
||||
];
|
||||
return view('user.order.list', $data);
|
||||
}
|
||||
|
||||
public function payment($for, $id=null){
|
||||
$data = Request::all();
|
||||
$user = User::find(Auth::user()->id);
|
||||
$rules = array(
|
||||
'shipping_salutation' => 'required',
|
||||
'shipping_firstname'=>'required',
|
||||
'shipping_lastname'=>'required',
|
||||
'shipping_address'=>'required',
|
||||
'shipping_zipcode'=>'required',
|
||||
'shipping_city' => 'required',
|
||||
'shipping_state' => 'required',
|
||||
);
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
if ($validator->fails()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
//hier prüfen, ob versand etc richtig berechnet wurde
|
||||
$this->checkSendYardForPayment($data, $id);
|
||||
|
||||
if(Yard::instance('shopping')->getNumComp() > 0){
|
||||
if(!isset($data['switchers-comp-product'])){
|
||||
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
|
||||
}else{
|
||||
if(!is_array($data['switchers-comp-product'])){
|
||||
$validator->errors()->add('switchers-comp-product', __('msg.please_select_compensation_product'));
|
||||
}else{
|
||||
if(count($data['switchers-comp-product']) !== Yard::instance('shopping')->getNumComp()){
|
||||
$validator->errors()->add('switchers-comp-product', __('mdg.please_select_count_compensation_products', ['count'=>Yard::instance('shopping')->getNumComp()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($validator->errors()->count()) {
|
||||
return back()->withErrors($validator)->withInput(Request::all());
|
||||
}
|
||||
}
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
$data['is_from'] = 'user_order';
|
||||
$data['is_for'] = $for;
|
||||
$data['is_abo'] = $data['is_abo'] ?? 0;
|
||||
$data['abo_interval'] = $data['abo_interval'] ?? 0;
|
||||
$data['shopping_user_id'] = $id;
|
||||
$data['user_price_infos'] = Yard::instance('shopping')->getUserPriceInfos();
|
||||
unset($data['quantity']);
|
||||
unset($data['_token']);
|
||||
$data['mode'] = config('app.mode') === 'test' ? 'test' : 'live';
|
||||
if($for === 'ot-customer' || $for === 'abo-ot-customer'){
|
||||
$shopping_instance = ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => $user->shop->id,
|
||||
'payment' => 6, //Berater Shop to Customer Shop
|
||||
'subdomain' => $user->shop->getSubdomain(),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'amount' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'status' => 0,
|
||||
'shopping_user_id' => $id,
|
||||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$yard_shopping_items = OrderPaymentService::getRestoredYardShoppingItems($shopping_instance);
|
||||
|
||||
// send Mail to Customer
|
||||
$this->customPaymentSendMail($user, $identifier, $yard_shopping_items, $data);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_customer', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier, 'is_abo'=>$data['is_abo']]);
|
||||
|
||||
//eine Abschließen bestellseite für den User + Link zum Kunden Shop + Mail an den Kunden / Berater
|
||||
return redirect(route('user_order_my_custom_payment', ['identifier'=>$identifier]));
|
||||
}else{
|
||||
ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => 1, //is first faker shop for buy intern
|
||||
'auth_user_id' => Auth::user()->id,
|
||||
'payment' => 2, //Berater Shop
|
||||
'subdomain' => url('/'),
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'amount' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'status' => 0,
|
||||
'shopping_user_id' => $id,
|
||||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'user_order_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier, 'is_abo'=>$data['is_abo']]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function checkSendYardForPayment($data, $id){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_user = null;
|
||||
if(strpos($data['shipping_is_for'], 'ot') !== false){
|
||||
$shopping_user = Shop::checkShoppingUser($id, $user);
|
||||
}
|
||||
|
||||
$shipping_country_id = Shop::checkShoppingCountry($data['shipping_is_for'], $id);
|
||||
if(!$shipping_country_id){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'no shipping_country_id found | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_country_was_not_found'));
|
||||
}
|
||||
//must be the same shipping country
|
||||
if($shipping_country_id != Yard::instance('shopping')->getShippingCountryId()){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'shipping_country_id is not the same from Yard | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_country_was_not_correctly'));
|
||||
}
|
||||
|
||||
if($data['shipping_is_for'] !== 'ot-customer'){
|
||||
if(Yard::instance('shopping')->shipping_free){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard can by not shipping_free | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shopping_cart_was_shipping_free'));
|
||||
}
|
||||
}
|
||||
|
||||
if($data['shipping_is_for'] === 'ot-customer'){
|
||||
if(!$user->shop){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'User has no Shop for an User to Customer order| Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shopping_cart_was_not_user_shop'));
|
||||
}
|
||||
}
|
||||
|
||||
$shipping_price = Shop::getShippingPriceByShippingCountryId($shipping_country_id, Yard::instance('shopping')->weight());
|
||||
dump($shipping_price);
|
||||
//for other and has weight - check
|
||||
if(strpos($data['shipping_is_for'], 'ot') !== false && $data['shipping_is_for'] !== 'ot-customer' && Yard::instance('shopping')->weight() > 0){
|
||||
if(!Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is 0 or | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_cost_cannot_be_0'));
|
||||
}
|
||||
if(Yard::instance('shopping')->getShippingPrice() != $shipping_price->price){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard OT shipping_price is not the same from shipping_price | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_costs_were_not_calculated_correctly'));
|
||||
}
|
||||
}
|
||||
if(($data['shipping_is_for'] == 'me' || $data['shipping_is_for'] == 'abo-me') && Yard::instance('shopping')->weight() > 0){
|
||||
if(!Yard::instance('shopping')->getShippingPrice() || Yard::instance('shopping')->getShippingPrice() == 0){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is 0 or | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_cost_cannot_be_0'));
|
||||
}
|
||||
dump(Yard::instance('shopping')->getShippingPrice());
|
||||
dump($shipping_price->price_comp);
|
||||
dump(Yard::instance('shopping')->getNumComp());
|
||||
dump($shipping_price->num_comp);
|
||||
dd($data) ;
|
||||
|
||||
if(Yard::instance('shopping')->getShippingPrice() != $shipping_price->price_comp){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard ME shipping_price is not the same from shipping_price | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.shipping_costs_were_not_calculated_correctly'));
|
||||
}
|
||||
|
||||
if(Yard::instance('shopping')->getNumComp() != $shipping_price->num_comp){
|
||||
$identifier = 'error-'.time().mt_rand(1000000, 9999999);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
$data['user_id'] = Auth::user()->id;
|
||||
$data['shopping_user_id'] = $id;
|
||||
\App\Services\MyLog::writeLog('payment', 'error', 'Yard num_comp is 0 | Yard identifier: '.$identifier, $data);
|
||||
abort(403, __('msg.compensation_products_cannot_be_0'));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
|
||||
if(Request::get('shipping_is_for') === 'me' || Request::get('shipping_is_for') === 'abo-me'){
|
||||
$show_on_ids = Request::get('is_abo') ? ['12', '13'] : ['2'];
|
||||
$query = Product::with('product_buyings')
|
||||
->select('products.*')->where('products.active', true)
|
||||
->where(function($q) use ($show_on_ids) {
|
||||
foreach($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->orderByRaw("CASE
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 1
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 2
|
||||
ELSE 3 END",
|
||||
[$show_on_ids[0], isset($show_on_ids[1]) ? $show_on_ids[1] : $show_on_ids[0]]);
|
||||
}else{
|
||||
$show_on_ids = Request::get('is_abo') ? ['12', '13'] : ['3'];
|
||||
$query = Product::select('products.*')
|
||||
->where('active', true)
|
||||
->where(function($q) use ($show_on_ids) {
|
||||
foreach($show_on_ids as $id) {
|
||||
$q->orWhereJsonContains('show_on', $id);
|
||||
}
|
||||
})
|
||||
->orderByRaw("CASE
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 1
|
||||
WHEN JSON_CONTAINS(show_on, ?, '$') THEN 2
|
||||
ELSE 3 END",
|
||||
[$show_on_ids[0], isset($show_on_ids[1]) ? $show_on_ids[1] : $show_on_ids[0]]);
|
||||
}
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
->addColumn('product', function (Product $product) {
|
||||
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
|
||||
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
|
||||
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
|
||||
return '<strong>'.$product->getLang('name').'</strong><br>
|
||||
<div class="no-line-break input-group-min-w">
|
||||
<div class="input-group d-inline-flex w-auto">
|
||||
<span class="input-group-prepend">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">-</button>
|
||||
</span>
|
||||
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_'.$product->id.'" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'" value="'.$qty.'">
|
||||
<span class="input-group-append">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">+</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
})
|
||||
->addColumn('abo', function (Product $product) {
|
||||
return AboHelper::getAboTypeBadge(AboHelper::getAboShowOn($product));
|
||||
})
|
||||
/*
|
||||
->addColumn('add_card', function (Product $product) {
|
||||
return '<button type="button" class="btn btn-sm btn-md-extra btn-secondary add-product-basket" data-product-id="'.$product->id.'">
|
||||
<strong>€ '.$product->getFormattedPriceWith().'</strong> +<span class="ion ion-md-cart"></span>
|
||||
</button>';
|
||||
})
|
||||
->addColumn('quantity', function (Product $product) {
|
||||
$cartItem = Yard::instance('shopping')->getCartItemByProduct($product->id);
|
||||
$qty = isset($cartItem->qty) ? $cartItem->qty : 0;
|
||||
$rowId = isset($cartItem->rowId) ? $cartItem->rowId : '';
|
||||
return '<div class="no-line-break input-group-min-w">
|
||||
<div class="input-group d-inline-flex w-auto">
|
||||
<span class="input-group-prepend">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra remove-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">-</button>
|
||||
</span>
|
||||
<input type="text" class="form-control text-center input-extra table-input-event-onchange" name="product_qty_'.$product->id.'" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'" value="'.$qty.'">
|
||||
<span class="input-group-append">
|
||||
<button type="button" class="btn btn-secondary icon-btn md-btn-extra add-product-basket" data-row-id="'.$rowId.'" data-product-id="'.$product->id.'">+</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
})*/
|
||||
->addColumn('picture', function (Product $product) {
|
||||
if(count($product->images)){
|
||||
return '<img class="img-fluid img-extra" alt="" src="'.route('product_image', [$product->images->first()->slug]).'">';
|
||||
}
|
||||
return "";
|
||||
})
|
||||
->addColumn('price_net', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, true, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, true, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
})
|
||||
->addColumn('price_gross', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, true, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, true, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
})
|
||||
->addColumn('price_vk_gross', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
})
|
||||
->addColumn('customer_price_net', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
})
|
||||
->addColumn('customer_price_gross', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(false, false, Yard::instance('shopping')->getUserCountry()). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(false, false, Yard::instance('shopping')->getUserCountry()).'</span>';
|
||||
})
|
||||
->addColumn('my_commission_net', function (Product $product) {
|
||||
return '<span class="no-line-break">'.$product->getFormattedPriceWith(true, false, Yard::instance('shopping')->getUserCountry(), true). " €</span>".'<span class="no-line-break">'.$product->getFormattedPriceCurrencyWith(true, false, Yard::instance('shopping')->getUserCountry(), true).'</span>';
|
||||
})
|
||||
->addColumn('action', function (Product $product) {
|
||||
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
|
||||
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
|
||||
data-action="user-order-show-product" data-view="customer"><i class="ion ion-md-eye"></i></button>';
|
||||
})
|
||||
->filterColumn('product', function($query, $keyword) {
|
||||
if($keyword != ""){
|
||||
$query->where('name', 'LIKE', '%'.$keyword.'%');
|
||||
}
|
||||
})
|
||||
->orderColumn('name', 'name $1')
|
||||
->orderColumn('product', 'name $1')
|
||||
->orderColumn('number', 'number $1')
|
||||
->orderColumn('points', 'points $1')
|
||||
->orderColumn('price_net', 'price_net $1')
|
||||
->orderColumn('price_gross', 'price_gross $1')
|
||||
->orderColumn('price_vk_gross', 'price $1')
|
||||
->orderColumn('customer_price_net', 'price $1')
|
||||
->orderColumn('customer_price_gross', 'price $1')
|
||||
->orderColumn('my_commission_net', 'price $1')
|
||||
->orderColumn('contents_total', 'contents_total $1')
|
||||
->orderColumn('weight', 'weight $1')
|
||||
->orderColumn('abo', 'show_on $1')
|
||||
->rawColumns(['add_card', 'price_net', 'price_gross', 'price_vk_gross', 'customer_price_net', 'customer_price_gross', 'my_commission_net', 'product', 'quantity', 'picture', 'abo', 'action'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
public function performRequest(){
|
||||
|
||||
if(Request::ajax()) {
|
||||
$data = Request::all();
|
||||
|
||||
$is_for = isset($data['shipping_is_for']) ? $data['shipping_is_for'] : 'ot-member';
|
||||
$data['for'] = $is_for;
|
||||
$data['comp_products'] = Shop::getCompProducts($is_for);
|
||||
|
||||
if($data['action'] === 'updateCart' && isset($data['product_id'])){
|
||||
if($product = Product::find($data['product_id'])){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
|
||||
//get the card item
|
||||
if($is_for === 'ot-customer' || $is_for === 'abo-ot-customer'){
|
||||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), 1,
|
||||
round($product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), 1), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
}else{
|
||||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), 1,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), true, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
}
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith(Yard::instance('shopping')->getUserCountry()));
|
||||
}
|
||||
if(isset($data['qty']) && $data['qty'] > 0){
|
||||
Yard::instance('shopping')->update($cartItem->rowId, $data['qty']);
|
||||
}else{
|
||||
//if 0 get the item by qty:1 and remove it
|
||||
Yard::instance('shopping')->remove($cartItem->rowId);
|
||||
}
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
|
||||
$html_card = view("user.order.yard_view_form", $data)->render();
|
||||
$html_comp = view("user.order.comp_product", $data)->render();
|
||||
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
|
||||
}
|
||||
}
|
||||
if($data['action'] === 'clearCart') {
|
||||
Yard::instance('shopping')->destroy();
|
||||
return response()->json(['response' => true, 'data'=>Yard::instance('shopping')->count(), 'html_card'=>'', 'html_comp'=>'']);
|
||||
|
||||
}
|
||||
|
||||
if($data['action'] === 'updateShippingCountry') {
|
||||
if(isset($data['shipping_country_id'])){
|
||||
if($shipping_country = ShippingCountry::find($data['shipping_country_id'])){
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country->id, $is_for);
|
||||
$this->checkCompProduct(Yard::instance('shopping')->getNumComp());
|
||||
}
|
||||
}
|
||||
$html_card = view("user.order.yard_view_form", $data)->render();
|
||||
$html_comp = view("user.order.comp_product", $data)->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
|
||||
|
||||
}
|
||||
if($data['action'] === 'updateCompProduct'){
|
||||
// $data['comp_product_id']
|
||||
// $data['comp_num']
|
||||
//count_comp_products
|
||||
$this->updateCompProduct($data);
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
$html_card = view("user.order.yard_view_form", $data)->render();
|
||||
$html_comp = view("user.order.comp_product", $data)->render();
|
||||
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html_card'=>$html_card, 'html_comp'=>$html_comp]);
|
||||
|
||||
}
|
||||
return response()->json(['response' => false, 'data'=>$data]);
|
||||
}
|
||||
}
|
||||
|
||||
private function checkCompProduct($count_comp_products){
|
||||
foreach (Yard::instance('shopping')->content() as $row) {
|
||||
//wenn gleich löschen, da neue Versandkosten
|
||||
if($row->options->comp > $count_comp_products) {
|
||||
Yard::instance('shopping')->remove($row->rowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function updateCompProduct($data){
|
||||
//clear old
|
||||
foreach (Yard::instance('shopping')->content() as $row) {
|
||||
//wenn kleiner wurde ein produkt entfernt aufgrund der Anzahl
|
||||
//wenn gleich löschen, da neue Versandkosten
|
||||
if($row->options->comp === $data['comp_num'] || $row->options->comp > $data['count_comp_products']) {
|
||||
Yard::instance('shopping')->remove($row->rowId);
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($data['comp_product_id'])) {
|
||||
if ($product = Product::find($data['comp_product_id'])) {
|
||||
$image = "";
|
||||
if ($product->images->count()) {
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, 0, false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => 0, 'points' => 0,
|
||||
'comp' => $data['comp_num'], 'product_id' => $product->id]);
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function customPayment($identifier){
|
||||
|
||||
$data = OrderPaymentService::getCustomPayment($identifier);
|
||||
return view('user.order.payment.custom_payment', $data);
|
||||
}
|
||||
|
||||
|
||||
private static function customPaymentSendMail($user, $identifier, $yard_shopping_items, $data){
|
||||
$bcc = [];
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
if(!$shopping_instance){
|
||||
abort(403, __('msg.shopping_instance_not_found'));
|
||||
}
|
||||
$shopping_user = $data['shopping_user_id'] ? ShoppingUser::find($data['shopping_user_id']) : null;
|
||||
if(!$shopping_user){
|
||||
abort(403, __('msg.shopping_user_not_found'));
|
||||
}
|
||||
|
||||
$route = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
|
||||
$billing_email = $shopping_user->billing_email;
|
||||
if(!$billing_email){
|
||||
$billing_email = $data['mode'] === 'test' ? config('app.checkout_test_mail') : config('app.checkout_mail');
|
||||
}
|
||||
$bcc[] = $data['mode'] === 'test' ? config('app.checkout_test_mail') : config('app.checkout_mail');
|
||||
$bcc[] = $shopping_user->member ? $shopping_user->member->email : $user->email;
|
||||
|
||||
Mail::to($billing_email)->bcc($bcc)->locale(\App::getLocale())
|
||||
->send(new MailCustomPaymet($route, $shopping_user, $shopping_instance, $yard_shopping_items, $data['mode']));
|
||||
}
|
||||
}
|
||||
97
app/Http/Controllers/User/OrderPaymentController.php
Normal file
97
app/Http/Controllers/User/OrderPaymentController.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Models\ShoppingInstance;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\OrderPaymentService;
|
||||
|
||||
class OrderPaymentController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('active.account');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
return view('user.order.payment.index', $data);
|
||||
}
|
||||
|
||||
public function detail($identifier)
|
||||
{
|
||||
$data = OrderPaymentService::getCustomPayment($identifier);
|
||||
$data['backlink'] = route('user_order_payment_links');
|
||||
return view('user.order.payment.custom_payment', $data);
|
||||
}
|
||||
|
||||
public function delete($identifier){
|
||||
OrderPaymentService::deleteInstance($identifier);
|
||||
return redirect(route('user_order_payment_links'));
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$user_shop_id = $user->shop ? $user->shop->id : null;
|
||||
$query = ShoppingInstance::select('*')
|
||||
->where('user_shop_id', '=', $user_shop_id)
|
||||
->where('payment', 6);
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
->addColumn('id', function (ShoppingInstance $shoppingInstance) {
|
||||
return '<a href="'.route('user_order_payment_links_detail', [$shoppingInstance->identifier]).'" class="btn icon-btn btn-sm btn-primary"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('created_at', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->created_at->format("d.m.Y");
|
||||
})
|
||||
->addColumn('status', function (ShoppingInstance $shoppingInstance) {
|
||||
return OrderPaymentService::getStatusBadge($shoppingInstance);
|
||||
})
|
||||
->addColumn('payment_method', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->payment_method ? $shoppingInstance->payment_method->name : '-';
|
||||
})
|
||||
->addColumn('total', function (ShoppingInstance $shoppingInstance) {
|
||||
if($shoppingInstance->amount > 0){
|
||||
return '<span class="no-line-break">'.$shoppingInstance->getAmountFormatted()." €</span>";
|
||||
}else{
|
||||
return '-';
|
||||
}
|
||||
})
|
||||
->addColumn('type', function (ShoppingInstance $shoppingInstance) {
|
||||
return OrderPaymentService::getTypeBadge($shoppingInstance);
|
||||
})
|
||||
->addColumn('billing_firstname', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->shopping_data['billing_firstname'] ?? '-';
|
||||
})
|
||||
->addColumn('billing_lastname', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->shopping_data['billing_lastname'] ?? '-';
|
||||
})
|
||||
->addColumn('billing_email', function (ShoppingInstance $shoppingInstance) {
|
||||
return $shoppingInstance->shopping_data['billing_email'] ?? '-';
|
||||
})
|
||||
->addColumn('delete', function (ShoppingInstance $shoppingInstance) {
|
||||
return '<a onclick="return confirm(\''.__('confirm_delete').'\');" href="'.route('user_order_payment_links_delete', [$shoppingInstance->identifier]).'" class="btn icon-btn btn-sm btn-danger"><span class="fa fa-trash"></span></a>';
|
||||
})
|
||||
|
||||
->orderColumn('id', 'identifier $1')
|
||||
->orderColumn('created_at', 'created_at $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
->orderColumn('total', 'total $1')
|
||||
->orderColumn('type', 'type $1')
|
||||
->orderColumn('billing_firstname', 'billing_firstname $1')
|
||||
->orderColumn('billing_lastname', 'billing_lastname $1')
|
||||
->orderColumn('billing_email', 'billing_email $1')
|
||||
->rawColumns(['id', 'status', 'type', 'total', 'invoice', 'delete'])
|
||||
->make(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -50,10 +50,9 @@ class PaymentController extends Controller
|
|||
if(Credit::isCredit($UserCredit)){
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'download']).'" class="btn btn-primary btn-xs"><i class="fa fa-download"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit', 'stream']).'" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a><br>';
|
||||
if(Auth::user()->isVIP()){
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'html']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
}
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'html']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-eye"></i></a> ';
|
||||
$ret .= '<a href="'.route('storage_file', [$UserCredit->id, 'credit_detail', 'pdf']).'" target="_blank" class="btn btn-secondary btn-xs mt-2"><i class="fa fa-file-pdf" style="min-width:13.5px"></i></a> ';
|
||||
|
||||
}else{
|
||||
$ret = "-";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class ShopApiController extends Controller
|
|||
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ShopSalesController extends Controller
|
|||
$user = User::find(\Auth::user()->id);
|
||||
$shopping_order = ShoppingOrder::findOrFail($id);
|
||||
if($shopping_order->member_id !== $user->id){
|
||||
abort(404);
|
||||
abort(403, 'Unauthorized action. User ID does not match.');
|
||||
}
|
||||
if( $shopping_order->payment_for !== 6 && $shopping_order->payment_for !== 7){
|
||||
return redirect(route('user_order_detail', [$shopping_order->id]));
|
||||
|
|
@ -67,7 +67,7 @@ class ShopSalesController extends Controller
|
|||
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
|
||||
})
|
||||
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
|
||||
return Payment::getPaymentForBadge($ShoppingOrder);
|
||||
})
|
||||
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
|
||||
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
|
||||
use Auth;
|
||||
use Request;
|
||||
use App\User;
|
||||
|
|
@ -26,11 +27,11 @@ class TeamController extends Controller
|
|||
public function members()
|
||||
{
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if($user->isActiveShop() && $user->shop){
|
||||
$shop_register_link = $user->shop->getSubdomain(false)."/reg";
|
||||
}else{
|
||||
$member_id = 'm'.($user->id + config('mivita.add_number_id'));
|
||||
$shop_register_link = config('app.protocol').config('app.domain').config('app.tld_care').'/reg/'.$member_id;
|
||||
if ($user->isActiveShop() && $user->shop) {
|
||||
$shop_register_link = $user->shop->getSubdomain(false) . "/reg";
|
||||
} else {
|
||||
$member_id = 'm' . ($user->id + config('mivita.add_number_id'));
|
||||
$shop_register_link = config('app.protocol') . config('app.domain') . config('app.tld_care') . '/reg/' . $member_id;
|
||||
}
|
||||
$data = [
|
||||
'shop_register_link' => $shop_register_link
|
||||
|
|
@ -71,7 +72,7 @@ class TeamController extends Controller
|
|||
{
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if(!$user->isVIP()){
|
||||
if (!$user->isVIP()) {
|
||||
abort(404);
|
||||
}
|
||||
$ExportBot = new ExportBot('member');
|
||||
|
|
@ -82,14 +83,15 @@ class TeamController extends Controller
|
|||
return view('user.team.export', $data);
|
||||
}
|
||||
|
||||
public function userTeamExport(){
|
||||
public function userTeamExport()
|
||||
{
|
||||
|
||||
if(Request::get('action') === "export"){
|
||||
if (Request::get('action') === "export") {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$ExportBot = new ExportBot('member');
|
||||
$ExportBot->initStructureUser($user, 'list'); //tree or list
|
||||
$columns = [];
|
||||
$filename = __('team.filename_export').date('Y-m-d-H-i-s');
|
||||
$filename = __('team.filename_export') . date('Y-m-d-H-i-s');
|
||||
$headers = array(
|
||||
__('tables.line'),
|
||||
__('tables.level'),
|
||||
|
|
@ -104,12 +106,13 @@ class TeamController extends Controller
|
|||
__('tables.phone'),
|
||||
__('tables.mobil'),
|
||||
__('tables.birthday'),
|
||||
__('tables.partner_since'),
|
||||
__('tables.account'),
|
||||
__('tables.account_to'),
|
||||
__('tables.sponsor'),
|
||||
);
|
||||
if(isset($ExportBot->user_list->childs)){
|
||||
foreach ($ExportBot->user_list->childs as $child){
|
||||
if (isset($ExportBot->user_list->childs)) {
|
||||
foreach ($ExportBot->user_list->childs as $child) {
|
||||
$columns[] = array(
|
||||
__('tables.line') => $child->line,
|
||||
__('tables.level') => $child->level_name,
|
||||
|
|
@ -124,42 +127,44 @@ class TeamController extends Controller
|
|||
__('tables.phone') => $child->phone,
|
||||
__('tables.mobil') => $child->mobil,
|
||||
__('tables.birthday') => $child->birthday,
|
||||
__('tables.partner_since') => $child->partner_since,
|
||||
__('tables.account') => ($child->active_account == 1 ? __('yes') : __('no')),
|
||||
__('tables.account_to') => $child->payment_account_date,
|
||||
__('tables.sponsor') => $child->sponsor_name,
|
||||
);
|
||||
}
|
||||
}
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename.'.xls');
|
||||
return Excel::download(new UserTeamExport($columns, $headers), $filename . '.xls');
|
||||
}
|
||||
}
|
||||
|
||||
private function setFilterVars(){
|
||||
private function setFilterVars()
|
||||
{
|
||||
|
||||
if(!session('team_user_filter_month')){
|
||||
if (!session('team_user_filter_month')) {
|
||||
session(['team_user_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('team_user_filter_year')){
|
||||
if (!session('team_user_filter_year')) {
|
||||
session(['team_user_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
if(!session('team_user_points_filter_month')){
|
||||
if (!session('team_user_points_filter_month')) {
|
||||
session(['team_user_points_filter_month' => intval(date('m'))]);
|
||||
}
|
||||
if(!session('team_user_points_filter_year')){
|
||||
if (!session('team_user_points_filter_year')) {
|
||||
session(['team_user_points_filter_year' => intval(date('Y'))]);
|
||||
}
|
||||
|
||||
if(Request::get('team_user_filter_month')){
|
||||
|
||||
if (Request::get('team_user_filter_month')) {
|
||||
session(['team_user_filter_month' => Request::get('team_user_filter_month')]);
|
||||
}
|
||||
if(Request::get('team_user_filter_year')){
|
||||
if (Request::get('team_user_filter_year')) {
|
||||
session(['team_user_filter_year' => Request::get('team_user_filter_year')]);
|
||||
}
|
||||
|
||||
if(Request::get('team_user_points_filter_month')){
|
||||
if (Request::get('team_user_points_filter_month')) {
|
||||
session(['team_user_points_filter_month' => Request::get('team_user_points_filter_month')]);
|
||||
}
|
||||
if(Request::get('team_user_points_filter_year')){
|
||||
if (Request::get('team_user_points_filter_year')) {
|
||||
session(['team_user_points_filter_year' => Request::get('team_user_points_filter_year')]);
|
||||
}
|
||||
}
|
||||
|
|
@ -170,46 +175,47 @@ class TeamController extends Controller
|
|||
|
||||
$user_id = \Auth::user()->id;
|
||||
$query = UserSalesVolume::with('user', 'user.account')->with('shopping_order')->select('user_sales_volumes.*')
|
||||
->where('user_sales_volumes.user_id', '=', $user_id)
|
||||
->where('user_sales_volumes.month', '=', Request::get('team_user_points_filter_month'))
|
||||
->where('user_sales_volumes.year', '=', Request::get('team_user_points_filter_year'));
|
||||
->where('user_sales_volumes.user_id', '=', $user_id)
|
||||
->where('user_sales_volumes.month', '=', Request::get('team_user_points_filter_month'))
|
||||
->where('user_sales_volumes.year', '=', Request::get('team_user_points_filter_year'));
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
public function datatablePoints(){
|
||||
public function datatablePoints()
|
||||
{
|
||||
|
||||
$query = $this->initSearchPoints();
|
||||
return \DataTables::eloquent($query)
|
||||
|
||||
|
||||
->addColumn('order', function (UserSalesVolume $UserSalesVolume) {
|
||||
if($UserSalesVolume->shopping_order){
|
||||
if($UserSalesVolume->status === 1 && $UserSalesVolume->shopping_order->auth_user_id === $UserSalesVolume->user_id){
|
||||
return '<a href="' . route('user_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-primary">'.$UserSalesVolume->shopping_order->id.'</a>';
|
||||
if ($UserSalesVolume->shopping_order) {
|
||||
if ($UserSalesVolume->status === 1 && $UserSalesVolume->shopping_order->auth_user_id === $UserSalesVolume->user_id) {
|
||||
return '<a href="' . route('user_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-primary">' . $UserSalesVolume->shopping_order->id . '</a>';
|
||||
}
|
||||
if(($UserSalesVolume->status === 2 || $UserSalesVolume->status === 3) && $UserSalesVolume->shopping_order->member_id === $UserSalesVolume->user_id){
|
||||
return '<a href="' . route('user_shop_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-secondary">'.$UserSalesVolume->shopping_order->id.'</a>';
|
||||
if (($UserSalesVolume->status === 2 || $UserSalesVolume->status === 3) && $UserSalesVolume->shopping_order->member_id === $UserSalesVolume->user_id) {
|
||||
return '<a href="' . route('user_shop_order_detail', [$UserSalesVolume->shopping_order->id]) . '" class="btn btn-xs btn-secondary">' . $UserSalesVolume->shopping_order->id . '</a>';
|
||||
}
|
||||
}
|
||||
return '';
|
||||
})
|
||||
->addColumn('total_net', function (UserSalesVolume $UserSalesVolume) {
|
||||
return formatNumber($UserSalesVolume->total_net).' €';
|
||||
return formatNumber($UserSalesVolume->total_net) . ' €';
|
||||
})
|
||||
->addColumn('status_turnover', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="badge badge-pill badge-'.$UserSalesVolume->getStatusTurnoverColor().'">'.$UserSalesVolume->getStatusTurnoverType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $UserSalesVolume->getStatusTurnoverColor() . '">' . $UserSalesVolume->getStatusTurnoverType() . '</span>';
|
||||
})
|
||||
->addColumn('status', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="badge badge-pill badge-'.$UserSalesVolume->getStatusColor().'">'.$UserSalesVolume->getStatusType().'</span>';
|
||||
return '<span class="badge badge-pill badge-' . $UserSalesVolume->getStatusColor() . '">' . $UserSalesVolume->getStatusType() . '</span>';
|
||||
})
|
||||
->addColumn('message', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="no-line-break">'.$UserSalesVolume->message.'</span>';
|
||||
return '<span class="no-line-break">' . $UserSalesVolume->message . '</span>';
|
||||
})
|
||||
->addColumn('info', function (UserSalesVolume $UserSalesVolume) {
|
||||
return '<span class="no-line-break">'.$UserSalesVolume->info.'</span>';
|
||||
return '<span class="no-line-break">' . $UserSalesVolume->info . '</span>';
|
||||
})
|
||||
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('order', 'order $1')
|
||||
->orderColumn('status', 'status $1')
|
||||
|
|
@ -220,7 +226,8 @@ class TeamController extends Controller
|
|||
->make(true);
|
||||
}
|
||||
|
||||
public function load(){
|
||||
public function load()
|
||||
{
|
||||
|
||||
$user = User::find(\Auth::user()->id);
|
||||
$userSalesVolume = $user->getUserSalesVolume(intval(session('team_user_points_filter_month')), intval(session('team_user_points_filter_year')), 'first');
|
||||
|
|
@ -229,9 +236,6 @@ class TeamController extends Controller
|
|||
'userSalesVolume' => $userSalesVolume,
|
||||
];
|
||||
$html = view('user.team._points_sum', $data)->render();
|
||||
return response()->json(['response' => true, 'data'=>$data, 'html'=>$html]);
|
||||
|
||||
return response()->json(['response' => true, 'data' => $data, 'html' => $html]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ class UserDataController extends Controller
|
|||
'city' => 'required',
|
||||
'email' => 'required|string|email|max:255|exists:users,email',
|
||||
'email-confirm' => 'required|same:email',
|
||||
'bank_owner' => 'required',
|
||||
'bank_iban' => 'required',
|
||||
'bank_bic' => 'required',
|
||||
);
|
||||
if(!Request::get('same_as_billing')){
|
||||
$rules = array_merge($rules, [
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class CardController extends Controller
|
|||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), $quantity,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping, 'show_on' => $product->show_on]);
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
@ -65,7 +65,7 @@ class CardController extends Controller
|
|||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), $quantity,
|
||||
$product->getPriceWith(Yard::instance('shopping')->getUserTaxFree(), false, Yard::instance('shopping')->getUserCountry()), false, false,
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping]);
|
||||
['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'no_free_shipping' => $product->no_free_shipping, 'show_on' => $product->show_on]);
|
||||
if(Yard::instance('shopping')->getUserTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -252,6 +252,9 @@ class WizardController extends Controller
|
|||
'mobil' => 'required_without:phone',
|
||||
'country_id' => 'required|integer|min:1',
|
||||
'birthday' => 'required',
|
||||
'bank_owner' => 'required',
|
||||
'bank_iban' => 'required',
|
||||
'bank_bic' => 'required',
|
||||
);
|
||||
|
||||
if (!Request::get('same_as_billing')) {
|
||||
|
|
@ -572,7 +575,7 @@ class WizardController extends Controller
|
|||
if($product->images->count()){
|
||||
$image = $product->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
@ -587,7 +590,7 @@ class WizardController extends Controller
|
|||
if($product_on_board->images->count()){
|
||||
$image = $product_on_board->images->first()->slug;
|
||||
}
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight, 'points' => $product_on_board->points, 'no_commission' => $product_on_board->no_commission]);
|
||||
$cartItem = Yard::instance('shopping')->add($product_on_board->id, $product_on_board->getLang('name'), 1, $product_on_board->getPriceWith(\App\Services\UserService::getTaxFree(), false, \App\Services\UserService::$user_country), false, false, ['image' => $image, 'slug' => $product_on_board->slug, 'weight' => $product_on_board->weight, 'points' => $product_on_board->points, 'no_commission' => $product_on_board->no_commission, 'show_on' => $product_on_board->show_on]);
|
||||
if(\App\Services\UserService::getTaxFree()){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class Checkout
|
|||
Yard::instance('shopping')->setShippingCountryWithPrice($shopping_instance->country_id, $is_for);
|
||||
|
||||
if($shopping_instance->payment !== 6){
|
||||
//delete shopping instance
|
||||
//delete shopping instance is not save for restore, payment link
|
||||
ShoppingInstance::where('identifier', $request->route('identifier'))->delete();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,18 +17,20 @@ class MailCheckout extends Mailable
|
|||
protected $shopping_payment;
|
||||
protected $send_link;
|
||||
protected $mode;
|
||||
protected $payment_error;
|
||||
|
||||
public $subject;
|
||||
public $data;
|
||||
|
||||
|
||||
public function __construct($txaction, $shopping_order, $shopping_payment, $send_link, $mode)
|
||||
public function __construct($txaction, $shopping_order, $shopping_payment, $send_link, $mode, $payment_error = false)
|
||||
{
|
||||
$this->txaction = $txaction;
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->shopping_payment = $shopping_payment;
|
||||
$this->send_link = $send_link;
|
||||
$this->mode = $mode;
|
||||
$this->payment_error = $payment_error;
|
||||
|
||||
if($this->txaction === 'paid'){
|
||||
$this->subject = __('email.checkout_subject_paid')." ";
|
||||
|
|
@ -77,6 +79,7 @@ class MailCheckout extends Mailable
|
|||
'txaction' => $this->txaction,
|
||||
'shopping_order' => $this->shopping_order,
|
||||
'shopping_payment' => $this->shopping_payment,
|
||||
'payment_error' => $this->payment_error,
|
||||
'copy3line' => __('email.checkout_copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'sender' => __('email.sender'),
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ class MailCustomPaymet extends Mailable
|
|||
protected $mode;
|
||||
protected $name;
|
||||
protected $yard_shopping_items;
|
||||
protected $is_abo;
|
||||
protected $is_for;
|
||||
|
||||
|
||||
public $subject;
|
||||
|
|
@ -31,9 +33,10 @@ class MailCustomPaymet extends Mailable
|
|||
$this->shopping_instance = $shopping_instance;
|
||||
$this->mode = $mode;
|
||||
$this->yard_shopping_items = $yard_shopping_items;
|
||||
|
||||
$this->is_abo = isset($shopping_instance->shopping_data['is_abo']) ? $shopping_instance->shopping_data['is_abo'] : 0;
|
||||
$this->is_for = isset($shopping_instance->shopping_data['is_for']) ? $shopping_instance->shopping_data['is_for'] : 0;
|
||||
$this->name = $shopping_user->member->account->first_name." ".$shopping_user->member->account->last_name." - ";
|
||||
$this->subject = __('email.subject_custom_payout', ['name' => $this->name]);
|
||||
$this->subject =$this->is_abo ? __('email.subject_custom_abo_payout', ['name' => $this->name]) : __('email.subject_custom_payout', ['name' => $this->name]);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -43,10 +46,12 @@ class MailCustomPaymet extends Mailable
|
|||
|
||||
return $this->view('emails.custom_payment')->with([
|
||||
'salutation' => $salutation,
|
||||
'copy1line' => __('email.your_custom_payout', ['name' => $this->name]),
|
||||
'copy1line' => $this->is_abo ? __('email.your_custom_abo_payout', ['name' => $this->name]) : __('email.your_custom_payout', ['name' => $this->name]),
|
||||
'shopping_user' => $this->shopping_user,
|
||||
'shopping_instance' => $this->shopping_instance,
|
||||
'yard_shopping_items' => $this->yard_shopping_items,
|
||||
'is_abo' => $this->is_abo,
|
||||
'is_for' => $this->is_for,
|
||||
'copy3line' => __('email.checkout_copy3line'),
|
||||
'greetings' => __('email.greetings'),
|
||||
'route' => $this->route,
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ class Category extends Model
|
|||
'parent_id', 'name', 'headline', 'pos', 'active',
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -10,13 +10,20 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class DbipLookup
|
||||
*
|
||||
*
|
||||
* @property string $addr_type
|
||||
* @property string $ip_start
|
||||
* @property string $ip_end
|
||||
* @property string $country
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereAddrType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereCountry($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereIpEnd($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup whereIpStart($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class DbipLookup extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,13 +10,20 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class DbipLookup
|
||||
*
|
||||
*
|
||||
* @property string $addr_type
|
||||
* @property string $ip_start
|
||||
* @property string $ip_end
|
||||
* @property string $country
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereAddrType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereCountry($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereIpEnd($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup2 whereIpStart($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class DbipLookup2 extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,13 +10,20 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class DbipLookup
|
||||
*
|
||||
*
|
||||
* @property string $addr_type
|
||||
* @property string $ip_start
|
||||
* @property string $ip_end
|
||||
* @property string $country
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereAddrType($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereCountry($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereIpEnd($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DbipLookup3 whereIpStart($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class DbipLookup3 extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,15 +13,28 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
|
||||
/**
|
||||
* Class DcCategory
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property int $pos
|
||||
* @property string $slug
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
* @property bool $active
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory findSimilarSlugs(string $attribute, array $config, string $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcCategory withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class DcCategory extends Model
|
||||
{
|
||||
|
|
@ -41,7 +54,7 @@ class DcCategory extends Model
|
|||
'active'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class DcFile
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $filename
|
||||
* @property string $original_name
|
||||
|
|
@ -22,10 +22,26 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @property int|null $active
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property Collection|DcFileTag[] $dc_file_tags
|
||||
*
|
||||
* @package App\Models
|
||||
* @property-read int|null $dc_file_tags_count
|
||||
* @property-read Collection<int, \App\Models\DcFileTag> $fileTag
|
||||
* @property-read int|null $file_tag_count
|
||||
* @property-read Collection<int, \App\Models\DcTag> $tags
|
||||
* @property-read int|null $tags_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereExt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereFilename($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereMine($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereOriginalName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereSize($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFile whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class DcFile extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,17 +11,24 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class DcFileTag
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $file_id
|
||||
* @property int $tag_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property DcFile $dc_file
|
||||
* @property DcTag $dc_tag
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereFileId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereTagId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcFileTag whereUpdatedAt($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class DcFileTag extends Model
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
|
||||
/**
|
||||
* Class DcTag
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int|null $category_id
|
||||
* @property string $name
|
||||
|
|
@ -22,10 +22,24 @@ use Cviebrock\EloquentSluggable\Sluggable;
|
|||
* @property string $slug
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property Collection|DcFileTag[] $dc_file_tags
|
||||
*
|
||||
* @package App\Models
|
||||
* @property bool $active
|
||||
* @property-read int|null $dc_file_tags_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag findSimilarSlugs(string $attribute, array $config, string $slug)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereCategoryId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereName($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag wherePos($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereSlug($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|DcTag withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class DcTag extends Model
|
||||
{
|
||||
|
|
@ -47,7 +61,7 @@ class DcTag extends Model
|
|||
'active'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ use Illuminate\Database\Eloquent\Collection;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereOrder($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereSettings($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereStep($value)
|
||||
* @property array|null $trans_description
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Homeparty whereTransDescription($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class Homeparty extends Model
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class IqImage extends Model
|
|||
'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -75,7 +75,11 @@ class IqSite extends Model
|
|||
public function getProductModels(){
|
||||
$ret = [];
|
||||
foreach($this->products as $product_id){
|
||||
$ret[] = Product::findOrFail($product_id);
|
||||
$product = Product::findOrFail($product_id);
|
||||
if($product->active){
|
||||
$ret[] = $product;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $ret;
|
||||
|
|
@ -84,7 +88,10 @@ class IqSite extends Model
|
|||
public function getProductSetModels(){
|
||||
$ret = [];
|
||||
foreach($this->set_products as $product_id){
|
||||
$ret[] = Product::findOrFail($product_id);
|
||||
$product = Product::findOrFail($product_id);
|
||||
if($product->active){
|
||||
$ret[] = $product;
|
||||
}
|
||||
|
||||
}
|
||||
return $ret;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\PaymentMethod whereUpdatedAt($value)
|
||||
* @property array|null $show_on
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereShowOn($value)
|
||||
* @property bool $is_abo
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|PaymentMethod whereIsAbo($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PaymentMethod extends Model
|
||||
|
|
|
|||
|
|
@ -249,9 +249,8 @@ class Product extends Model
|
|||
8 => 'Mitgliedschaft Berater',
|
||||
9 => 'Onboarding Berater',
|
||||
10 => 'zur internen Berechnung',
|
||||
12 => 'Abo-ShopBerater',
|
||||
13 => 'Abo-ShopBeraterKunden',
|
||||
|
||||
12 => 'Abo-BasisProdukt',
|
||||
13 => 'Abo-AddonProdukt',
|
||||
];
|
||||
|
||||
public $actions = [
|
||||
|
|
@ -270,7 +269,18 @@ class Product extends Model
|
|||
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
/************* ✨ Codeium Command ⭐ *************/
|
||||
/**
|
||||
* Configure the model for auto-generating a slug.
|
||||
*
|
||||
* This method returns an array defining the attributes used
|
||||
* to generate the slug for the model. In this case, the 'name'
|
||||
* attribute is used as the source for generating the slug.
|
||||
*
|
||||
* @return array Configuration for slug generation.
|
||||
*/
|
||||
|
||||
/****** e935bd41-f49b-4736-9603-2da86dc27f25 *******/ public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
@ -393,23 +403,25 @@ class Product extends Model
|
|||
}
|
||||
|
||||
/*price by user Factor*/
|
||||
private function calcPriceUserFactor($price){
|
||||
private function calcPriceUserFactor($price, $user=null){
|
||||
if($this->no_commission){
|
||||
return $price;
|
||||
}
|
||||
if(\Auth::user() && \Auth::user()->user_level){
|
||||
$margin = ((\Auth::user()->user_level->margin -100)*-1) / 100;
|
||||
$user = $user ? $user : \Auth::user();
|
||||
if($user && $user->user_level){
|
||||
$margin = (($user->user_level->margin -100)*-1) / 100;
|
||||
$price = $price * $margin;
|
||||
}
|
||||
return $price;
|
||||
}
|
||||
|
||||
private function calcPriceUserCommission($price){
|
||||
private function calcPriceUserCommission($price, $user){
|
||||
if($this->no_commission){
|
||||
return $price;
|
||||
}
|
||||
if(\Auth::user() && \Auth::user()->user_level){
|
||||
$margin = \Auth::user()->user_level->margin;
|
||||
$user = $user ? $user : \Auth::user();
|
||||
if($user && $user->user_level){
|
||||
$margin = $user->user_level->margin;
|
||||
$price = $price / 100 * $margin;
|
||||
}
|
||||
return $price;
|
||||
|
|
@ -423,13 +435,13 @@ class Product extends Model
|
|||
return $price / $tax_rate;
|
||||
}
|
||||
//price calu with
|
||||
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false){
|
||||
public function getPriceWith(Bool $net = true, Bool $ufactor = true, $country = null, $commission=false, $user = null){
|
||||
$price = isset($this->attributes['price']) ? $this->attributes['price'] : null;
|
||||
$cprice = $country ? $this->getCPrice($country) : null;
|
||||
$price = $cprice ? $cprice : $price;
|
||||
$price = $net ? $this->calcPriceNet($price, $country) : $price;
|
||||
$price = $ufactor ? $this->calcPriceUserFactor($price) : $price;
|
||||
$price = $commission ? $this->calcPriceUserCommission($price) : $price;
|
||||
$price = $ufactor ? $this->calcPriceUserFactor($price, $user) : $price;
|
||||
$price = $commission ? $this->calcPriceUserCommission($price, $user) : $price;
|
||||
|
||||
return round($price, 2);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class ProductImage extends Model
|
|||
'product_id', 'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class Setting extends Model
|
|||
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ class ShoppingCollectOrder extends Model
|
|||
$add_tax = round($add_tax, 2);
|
||||
$tax_split[$tax_rate] = isset($tax_split[$tax_rate]) ? round($tax_split[$tax_rate] += $add_tax, 2) : $add_tax;
|
||||
|
||||
foreach($tax_split as $key=>$value){
|
||||
foreach((array)$tax_split as $key=>$value){
|
||||
$tax_split[$key] = number_format($value, 2);
|
||||
}
|
||||
$this->tax_split = $tax_split;
|
||||
|
|
@ -141,13 +141,31 @@ class ShoppingCollectOrder extends Model
|
|||
|
||||
public function addShopItem($shop_item_id, $shop_item)
|
||||
{
|
||||
$shop_item->user_price_net = number_format($shop_item->user_price_net, 2);
|
||||
$shop_item->user_price_total_net = number_format($shop_item->user_price_total_net, 2);
|
||||
$shop_item->user_tax = number_format($shop_item->user_tax, 2);
|
||||
$shop_item->user_tax_total = number_format($shop_item->user_tax_total, 2);
|
||||
$numberFields = [
|
||||
'user_price_net',
|
||||
'user_price_total_net',
|
||||
'user_tax',
|
||||
'user_tax_total'
|
||||
];
|
||||
|
||||
$intFields = [
|
||||
'points_total',
|
||||
'points'
|
||||
];
|
||||
|
||||
foreach ($numberFields as $field) {
|
||||
if (isset($shop_item->$field)) {
|
||||
$shop_item->$field = number_format($shop_item->$field, 2);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($intFields as $field) {
|
||||
if (isset($shop_item->$field)) {
|
||||
$shop_item->$field = intval($shop_item->$field);
|
||||
}
|
||||
}
|
||||
|
||||
$this->shop_items[$shop_item_id] = $shop_item;
|
||||
|
||||
}
|
||||
|
||||
public function addOrder($order)
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingInstance whereShoppingData($value)
|
||||
* @property string|null $language
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereLanguage($value)
|
||||
* @property int|null $status
|
||||
* @property float|null $amount
|
||||
* @property int|null $shopping_user_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereShoppingUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingInstance whereStatus($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingInstance extends Model
|
||||
|
|
@ -50,14 +56,29 @@ class ShoppingInstance extends Model
|
|||
|
||||
];
|
||||
|
||||
public $statuses = [
|
||||
0 => 'link_sent',
|
||||
1 => 'link_openly',
|
||||
2 => 'link_check',
|
||||
3 => 'link_pending',
|
||||
4 => 'link_appointed',
|
||||
5 => 'link_failed',
|
||||
6 => 'link_canceled',
|
||||
10 => 'link_paid',
|
||||
];
|
||||
|
||||
protected $table = 'shopping_instances';
|
||||
|
||||
protected $casts = ['shopping_data' => 'array'];
|
||||
protected $casts = ['shopping_data' => 'array', 'amount' => 'float'];
|
||||
|
||||
protected $fillable = [
|
||||
'identifier', 'user_shop_id', 'auth_user_id', 'payment', 'subdomain', 'language', 'country_id', 'shopping_data', 'back'
|
||||
'identifier', 'user_shop_id', 'auth_user_id', 'status', 'payment', 'subdomain', 'language', 'country_id', 'amount', 'shopping_user_id', 'shopping_data', 'back'
|
||||
];
|
||||
|
||||
public function getStatus(){
|
||||
return isset($this->statuses[$this->status]) ? $this->statuses[$this->status] : 'link_sent';
|
||||
}
|
||||
|
||||
public function getLocale(){
|
||||
return $this->language ? $this->language : \App::getLocale();
|
||||
}
|
||||
|
|
@ -78,5 +99,11 @@ class ShoppingInstance extends Model
|
|||
return $this->belongsTo('App\User','auth_user_id');
|
||||
}
|
||||
|
||||
public function getAmountFormatted(){
|
||||
return formatNumber($this->amount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,10 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereNetSplit($value)
|
||||
* @property string|null $language
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereLanguage($value)
|
||||
* @property bool|null $is_abo
|
||||
* @property int|null $abo_interval
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereAboInterval($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingOrder whereIsAbo($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingOrder extends Model
|
||||
|
|
@ -281,6 +285,13 @@ class ShoppingOrder extends Model
|
|||
|
||||
}
|
||||
|
||||
public function getUserAbo(){
|
||||
$UserAboOrder = UserAboOrder::where('shopping_order_id', $this->id)->first();
|
||||
if($UserAboOrder && $UserAboOrder->user_abo){
|
||||
return $UserAboOrder->user_abo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getLocale(){
|
||||
return $this->language ? $this->language : \App::getLocale();
|
||||
|
|
|
|||
|
|
@ -83,6 +83,16 @@ class ShoppingOrderItem extends Model
|
|||
'points',
|
||||
'slug',
|
||||
];
|
||||
protected $casts = [
|
||||
'qty' => 'int',
|
||||
'price' => 'float',
|
||||
'price_net' => 'float',
|
||||
'tax_rate' => 'float',
|
||||
'tax' => 'float',
|
||||
'price_vk_net' => 'float',
|
||||
'discount' => 'float',
|
||||
'points' => 'int',
|
||||
];
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,23 +40,35 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereWallettype($value)
|
||||
* @property string|null $mode
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\ShoppingPayment whereMode($value)
|
||||
* @property array|null $carddata
|
||||
* @property int|null $is_abo
|
||||
* @property int|null $abo_interval
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingPayment whereAboInterval($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingPayment whereCarddata($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|ShoppingPayment whereIsAbo($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class ShoppingPayment extends Model
|
||||
{
|
||||
protected $table = 'shopping_payments';
|
||||
|
||||
protected $casts = [
|
||||
'carddata' => 'array',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'shopping_order_id',
|
||||
'clearingtype',
|
||||
'wallettype',
|
||||
'onlinebanktransfertype',
|
||||
'carddata',
|
||||
'reference',
|
||||
'amount',
|
||||
'currency',
|
||||
'mode',
|
||||
'is_abo',
|
||||
'abo_interval',
|
||||
'identifier',
|
||||
];
|
||||
|
||||
|
||||
|
|
@ -69,7 +81,7 @@ class ShoppingPayment extends Model
|
|||
{
|
||||
return $this->hasMany('App\Models\PaymentTransaction','shopping_payment_id');
|
||||
}
|
||||
|
||||
|
||||
public function getPaymentType(){
|
||||
|
||||
if($this->clearingtype === 'wlt') {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\ShoppingUserService;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
|
|
@ -312,4 +313,8 @@ class ShoppingUser extends Model
|
|||
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllOrdersByMember(){
|
||||
return ShoppingUserService::getAllOrdersByMember($this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class SySetting extends Model
|
|||
1 => 'default',
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -8,20 +8,20 @@ namespace App\Models;
|
|||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
/**
|
||||
* Class UserAbo
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int $payone_userid
|
||||
* @property string $clearingtype
|
||||
* @property string|null $wallettype
|
||||
* @property int $amount
|
||||
* @property string $currency
|
||||
* @property bool $active
|
||||
* @property int $status
|
||||
* @property int $abo_interval
|
||||
|
|
@ -32,11 +32,51 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property Carbon|null $user_deleted_at
|
||||
*
|
||||
* @property User $user
|
||||
* @property Collection|UserAboOrder[] $user_abo_orders
|
||||
*
|
||||
* @package App\Models
|
||||
* @property int|null $member_id
|
||||
* @property int $shopping_user_id
|
||||
* @property string|null $email
|
||||
* @property string|null $is_for
|
||||
* @property array|null $carddata
|
||||
* @property \Illuminate\Support\Carbon|null $start_date
|
||||
* @property \Illuminate\Support\Carbon|null $last_date
|
||||
* @property \Illuminate\Support\Carbon|null $next_date
|
||||
* @property-read User|null $member
|
||||
* @property-read \App\Models\ShoppingUser $shopping_user
|
||||
* @property-read Collection<int, \App\Models\UserAboItem> $user_abo_items
|
||||
* @property-read int|null $user_abo_items_count
|
||||
* @property-read int|null $user_abo_orders_count
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo onlyTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereAboInterval($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereActive($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereAmount($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCancelDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCarddata($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereClearingtype($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereEmail($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereIsFor($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereLastDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereMemberId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereNextDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo wherePayoneUserid($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereShoppingUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereStartDate($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUserDeletedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereUserId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo whereWallettype($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo withTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAbo withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserAbo extends Model
|
||||
{
|
||||
|
|
@ -45,29 +85,33 @@ class UserAbo extends Model
|
|||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'member_id' => 'int',
|
||||
'shopping_user_id' => 'int',
|
||||
'payone_userid' => 'int',
|
||||
'amount' => 'int',
|
||||
'active' => 'bool',
|
||||
'status' => 'int',
|
||||
'abo_interval' => 'int',
|
||||
'amount' => 'int',
|
||||
'start_date' => 'datetime',
|
||||
'last_date' => 'datetime',
|
||||
'next_date' => 'datetime',
|
||||
'cancel_date' => 'datetime',
|
||||
'count' => 'int',
|
||||
'user_deleted_at' => 'datetime'
|
||||
'user_deleted_at' => 'datetime',
|
||||
'carddata' => 'array'
|
||||
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'member_id',
|
||||
'shopping_user_id',
|
||||
'is_for',
|
||||
'email',
|
||||
'payone_userid',
|
||||
'clearingtype',
|
||||
'wallettype',
|
||||
'carddata',
|
||||
'amount',
|
||||
'currency',
|
||||
'active',
|
||||
'status',
|
||||
'abo_interval',
|
||||
|
|
@ -75,13 +119,43 @@ class UserAbo extends Model
|
|||
'last_date',
|
||||
'next_date',
|
||||
'cancel_date',
|
||||
'count',
|
||||
'user_deleted_at'
|
||||
];
|
||||
|
||||
public static $aboDeliveryDays = [5, 10, 20, 25];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'abo_new',
|
||||
1 => 'abo_new',
|
||||
2 => 'abo_okay',
|
||||
3 => 'abo_hold',
|
||||
4 => 'abo_cancel',
|
||||
5 => 'abo_finish',
|
||||
6 => 'abo_inactive',
|
||||
7 => 'abo_grace'
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'success',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'danger',
|
||||
5 => 'info',
|
||||
6 => 'warning',
|
||||
7 => 'danger'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
return $this->belongsTo(User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function member()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'member_id');
|
||||
}
|
||||
|
||||
public function shopping_user()
|
||||
|
|
@ -89,12 +163,21 @@ class UserAbo extends Model
|
|||
return $this->belongsTo('App\Models\ShoppingUser','shopping_user_id');
|
||||
}
|
||||
|
||||
|
||||
public function user_abo_orders()
|
||||
{
|
||||
return $this->hasMany(UserAboOrder::class);
|
||||
}
|
||||
|
||||
public function user_abo_items()
|
||||
{
|
||||
return $this->hasMany(UserAboItem::class);
|
||||
}
|
||||
|
||||
public function getCountOrders(){
|
||||
//sind bezahlte Bestellungen
|
||||
return $this->user_abo_orders->where('status', '>=', 2)->count();
|
||||
}
|
||||
|
||||
public function setStartDateAttribute( $value ) {
|
||||
$this->attributes['start_date'] = isset($value) ? (new Carbon($value))->format('Y-m-d') : NULL;
|
||||
}
|
||||
|
|
@ -127,5 +210,29 @@ class UserAbo extends Model
|
|||
return $this->attributes['cancel_date'] ? Carbon::parse($this->attributes['cancel_date'])->format(\Util::formatDateDB()) : '';
|
||||
}
|
||||
|
||||
public function getFormattedAmount()
|
||||
{
|
||||
return isset($this->attributes['amount']) ? Util::formatNumber($this->attributes['amount']/100) : "";
|
||||
}
|
||||
public function getIsForFormated()
|
||||
{
|
||||
return $this->attributes['is_for'] === 'me' ? '<span class="badge badge-outline-warning-dark">'.__('tables.adviser').'</span>' : '<span class="badge badge-outline-info">'.__('tables.customer').'</span>';
|
||||
}
|
||||
|
||||
public function getStatusFormated(){
|
||||
return '<span class="badge badge-pill badge-'.$this->getStatusColor().'">'.$this->getStatusType().'</span>';
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? __('abo.'.self::$statusTypes[$this->status]) : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
public function getPaymentType(){
|
||||
return $this->clearingtype === 'wlt' ? __('payment.paypal') : __('payment.credit_card');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
90
app/Models/UserAboItem.php
Normal file
90
app/Models/UserAboItem.php
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\Util;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Yard;
|
||||
|
||||
/**
|
||||
* Class UserAboItem
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_abo_id
|
||||
* @property int $product_id
|
||||
* @property int|null $comp
|
||||
* @property int $qty
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Product $product
|
||||
* @property UserAbo $user_abo
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereComp($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereProductId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereQty($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboItem whereUserAboId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserAboItem extends Model
|
||||
{
|
||||
protected $table = 'user_abo_items';
|
||||
|
||||
protected $casts = [
|
||||
'user_abo_id' => 'int',
|
||||
'product_id' => 'int',
|
||||
'comp' => 'int',
|
||||
'qty' => 'int',
|
||||
'status' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_abo_id',
|
||||
'product_id',
|
||||
'comp',
|
||||
'qty',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function product()
|
||||
{
|
||||
return $this->belongsTo(Product::class);
|
||||
}
|
||||
|
||||
public function user_abo()
|
||||
{
|
||||
return $this->belongsTo(UserAbo::class);
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
$ufactor = $this->user_abo->is_for === 'me' ? true : false;
|
||||
$tax_free = $ufactor ? true : Yard::instance('shopping')->getUserTaxFree();
|
||||
$userCountry = Yard::instance('shopping')->getUserCountry();
|
||||
return $this->product->getPriceWith($tax_free, $ufactor, $userCountry);
|
||||
}
|
||||
|
||||
|
||||
public function getFormattedPrice(){
|
||||
/** der Preis wird für den User berechnet */
|
||||
return Util::formatNumber($this->getPrice());
|
||||
}
|
||||
|
||||
|
||||
public function getFormattedTotalPrice(){
|
||||
/** der Preis wird für den User berechnet */
|
||||
return Util::formatNumber($this->getPrice() * $this->qty);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,18 +12,26 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
/**
|
||||
* Class UserAboOrder
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_abo_id
|
||||
* @property int $shopping_order_id
|
||||
* @property int $status
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @property ShoppingOrder $shopping_order
|
||||
* @property UserAbo $user_abo
|
||||
*
|
||||
* @package App\Models
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder newQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder query()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereCreatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereShoppingOrderId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereStatus($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserAboOrder whereUserAboId($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserAboOrder extends Model
|
||||
{
|
||||
|
|
@ -42,6 +50,30 @@ class UserAboOrder extends Model
|
|||
'status'
|
||||
];
|
||||
|
||||
public static $statusTypes = [
|
||||
0 => 'abo_new',
|
||||
1 => 'abo_new',
|
||||
2 => 'abo_okay',
|
||||
3 => 'abo_hold',
|
||||
4 => 'abo_cancel',
|
||||
5 => 'abo_finish',
|
||||
6 => 'abo_inactive',
|
||||
7 => 'abo_grace'
|
||||
];
|
||||
|
||||
public static $statusColors = [
|
||||
0 => 'success',
|
||||
1 => 'success',
|
||||
2 => 'secondary',
|
||||
3 => 'warning',
|
||||
4 => 'danger',
|
||||
5 => 'info',
|
||||
6 => 'warning',
|
||||
7 => 'danger'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function shopping_order()
|
||||
{
|
||||
return $this->belongsTo(ShoppingOrder::class);
|
||||
|
|
@ -51,4 +83,17 @@ class UserAboOrder extends Model
|
|||
{
|
||||
return $this->belongsTo(UserAbo::class);
|
||||
}
|
||||
|
||||
public function getStatusFormated(){
|
||||
return '<span class="badge badge-pill badge-'.$this->getStatusColor().'">'.$this->getStatusType().'</span>';
|
||||
}
|
||||
|
||||
public function getStatusType(){
|
||||
return isset(self::$statusTypes[$this->status]) ? __('abo.'.self::$statusTypes[$this->status]) : "";
|
||||
}
|
||||
|
||||
public function getStatusColor(){
|
||||
return isset(self::$statusColors[$this->status]) ? self::$statusColors[$this->status] : "default";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,6 +119,10 @@ use Illuminate\Database\Eloquent\Casts\AsArrayObject;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumePointsTPSum($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereSalesVolumeTPPoints($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereVersion($value)
|
||||
* @property string|null $user_birthday
|
||||
* @property string|null $user_phone
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserBirthday($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserBusiness whereUserPhone($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserBusiness extends Model
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereUserBusinessId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereUserCreditId($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereUserId($value)
|
||||
* @property int|null $from_month
|
||||
* @property int|null $from_year
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereFromMonth($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserCreditItem whereFromYear($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserCreditItem extends Model
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ use App\User;
|
|||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereIdentifier($value)
|
||||
* @property int|null $abo_options
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\UserHistory whereAboOptions($value)
|
||||
* @property int|null $is_abo
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserHistory whereIsAbo($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserHistory extends Model
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|\App\Models\UserShop withoutTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShop withUniqueSlugConstraints(\Illuminate\Database\Eloquent\Model $model, string $attribute, array $config, string $slug)
|
||||
* @property array|null $trans
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|UserShop whereTrans($value)
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class UserShop extends Model
|
||||
|
|
@ -87,7 +89,7 @@ class UserShop extends Model
|
|||
protected $dates = ['deleted_at'];
|
||||
use Sluggable;
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ class UserShopOnSite extends Model
|
|||
'user_shop_id', 'filename', 'original_name', 'ext', 'mine', 'size'
|
||||
];
|
||||
|
||||
public function sluggable()
|
||||
public function sluggable() : array
|
||||
{
|
||||
return [
|
||||
'slug' => [
|
||||
|
|
|
|||
|
|
@ -1,72 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\User;
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
abstract class ModelPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
abstract protected function getModelClass(): string;
|
||||
|
||||
public function viewAny(User $user)
|
||||
{
|
||||
return $user->can('view-any-' . $this->getModelClass());
|
||||
}
|
||||
|
||||
public function view(User $user, Model $model)
|
||||
{
|
||||
if ($user->can('view-' . $this->getModelClass())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($user->can('view-self-' . $this->getModelClass())) {
|
||||
return $this->isOwner($user, $model);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function create(User $user)
|
||||
{
|
||||
return $user->can('create-' . $this->getModelClass());
|
||||
}
|
||||
|
||||
public function update(User $user, Model $model)
|
||||
{
|
||||
if ($user->can('update-' . $this->getModelClass())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($user->can('update-self-' . $this->getModelClass())) {
|
||||
return $this->isOwner($user, $model);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function delete(User $user, Model $model)
|
||||
{
|
||||
if ($user->can('delete-' . $this->getModelClass())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($user->can('delete-self-' . $this->getModelClass())) {
|
||||
return $this->isOwner($user, $model);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function isOwner(User $user, Model $model): bool
|
||||
{
|
||||
if (!empty($user) && method_exists($model, 'user')) {
|
||||
return $user->getKey() === $model->getRelation('user')->getKey();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
89
app/Repositories/AboRepository.php
Normal file
89
app/Repositories/AboRepository.php
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Carbon;
|
||||
use App\Models\UserAbo;
|
||||
use App\Services\AboHelper;
|
||||
|
||||
class AboRepository extends BaseRepository {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
public function setModel(UserAbo $model){
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
if(isset($data['action'])){
|
||||
if($data['action'] === 'abo_update_settings'){
|
||||
if($this->validate($data)){
|
||||
$this->updateStatus($data);
|
||||
$this->model->abo_interval = $data['abo_interval'];
|
||||
$this->model->next_date = AboHelper::setNextDate(now(), $data['abo_interval']);
|
||||
$this->model ->save();
|
||||
\Session()->flash('alert-success', 'Einstellungen gespeichert');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function create($data){
|
||||
|
||||
}
|
||||
|
||||
private function updateStatus($data){
|
||||
|
||||
$active = (isset($data['abo_is_active']) && $data['abo_is_active']) ? true : false;
|
||||
//if status is active and active is false, set status to inactive
|
||||
if($this->model->active && !$active){
|
||||
if($this->model->status = 2){ //okay
|
||||
$this->model->status = 6; //
|
||||
}
|
||||
}
|
||||
if(!$this->model->active && $active){
|
||||
if($this->model->status = 6){ //inactive
|
||||
$this->model->status = 2; //okay
|
||||
}
|
||||
}
|
||||
$this->model->active = $active;
|
||||
return;
|
||||
}
|
||||
|
||||
private function validate($data){
|
||||
if($data['view'] !== 'admin'){
|
||||
if($this->model->is_for === 'me' && $this->model->user_id !== \Auth::user()->id){
|
||||
\Session()->flash('alert-error', 'Unauthorized action. User ID does not match.');
|
||||
return false;
|
||||
}
|
||||
if($this->model->is_for === 'ot' && $this->model->member_id !== \Auth::user()->id){
|
||||
\Session()->flash('alert-error', 'Unauthorized action. User ID does not match.');
|
||||
return false;
|
||||
}
|
||||
if($data['view'] === 'me' && $this->model->is_for !== 'me'){
|
||||
\Session()->flash('alert-error', 'Unauthorized action. Is not for me');
|
||||
return false;
|
||||
}
|
||||
if($data['view'] === 'ot' && $this->model->is_for !== 'ot'){
|
||||
\Session()->flash('alert-error', 'Unauthorized action. Is not your customer');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!in_array($data['abo_interval'], \App\Models\UserAbo::$aboDeliveryDays)){
|
||||
//to check if user is not admin
|
||||
\Session()->flash('alert-error', __('abo.error_abo_interval'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
376
app/Repositories/CheckoutRepository.php
Normal file
376
app/Repositories/CheckoutRepository.php
Normal file
|
|
@ -0,0 +1,376 @@
|
|||
<?php
|
||||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Yard;
|
||||
use App\Services\Util;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\Homeparty;
|
||||
use App\Models\ShoppingCollectOrder;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingOrder;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
class CheckoutRepository extends BaseRepository {
|
||||
|
||||
private $session;
|
||||
private $instance;
|
||||
|
||||
|
||||
public function __construct(SessionManager $session)
|
||||
{
|
||||
$this->session = $session;
|
||||
$this->instance = sprintf('%s.%s', 'cart', 'payments');
|
||||
}
|
||||
|
||||
public function makeShoppingOrder($shopping_user, $data){
|
||||
|
||||
$user_shop = Util::getUserShop();
|
||||
|
||||
if($shopping_user->is_from === 'homeparty'){
|
||||
//get data
|
||||
$homeparty = Homeparty::find($shopping_user->homeparty_id);
|
||||
//set Data!
|
||||
$total = Yard::instance('shopping')->total(2, '.', ''); //ek_price
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment_for' => $shopping_user->getOrderPaymentFor(),
|
||||
'homeparty_id' => $shopping_user->homeparty_id,
|
||||
'total' => $total,
|
||||
'subtotal' => $homeparty->order['ek_price_net'],
|
||||
'shipping' => $homeparty->order['shipping_price'],
|
||||
'shipping_net' => $homeparty->order['shipping_price_net'],
|
||||
'subtotal_ws' => 0,
|
||||
'tax' => $total - $homeparty->order['ek_price_net'],
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'points' => $homeparty->order['points'] - $homeparty->order['bonus_points_diff'],
|
||||
'weight' => 0,
|
||||
'txaction' => 'prev',
|
||||
'mode' => Util::getUserShoppingMode(),
|
||||
];
|
||||
}elseif($shopping_user->is_from === 'collection'){
|
||||
//get data
|
||||
$ShoppingCollectOrder = ShoppingCollectOrder::find($shopping_user->shopping_collect_order_id);
|
||||
//set Data!
|
||||
$total = Yard::instance('shopping')->total(2, '.', ''); //ek_price
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment_for' => $shopping_user->getOrderPaymentFor(),
|
||||
'total' => $total,
|
||||
'subtotal' => $ShoppingCollectOrder->price_total_net,
|
||||
'shipping' => 0,
|
||||
'shipping_net' => 0,
|
||||
'subtotal_ws' => $ShoppingCollectOrder->price_total_net,
|
||||
'tax' => $ShoppingCollectOrder->tax_total,
|
||||
'tax_split' => $ShoppingCollectOrder->tax_split,
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'points' => $ShoppingCollectOrder->points,
|
||||
'weight' => 0,
|
||||
'txaction' => 'prev',
|
||||
'mode' => Util::getUserShoppingMode(),
|
||||
];
|
||||
}else{
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
|
||||
'language' => \App::getLocale(),
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment_for' => $shopping_user->getOrderPaymentFor(),
|
||||
'total' => Yard::instance('shopping')->total(2, '.', ''),
|
||||
'subtotal' => Yard::instance('shopping')->subtotal(2, '.', ''),
|
||||
'shipping' => Yard::instance('shopping')->shipping(2, '.', ','),
|
||||
'shipping_net' => Yard::instance('shopping')->shippingNet(2, '.', ''),
|
||||
'subtotal_ws' => Yard::instance('shopping')->subtotalWithShipping(2, '.', ''),
|
||||
'tax' => Yard::instance('shopping')->taxWithShipping(2, '.', ''),
|
||||
'total_shipping' => Yard::instance('shopping')->totalWithShipping(2, '.', ''),
|
||||
'points' => Yard::instance('shopping')->points(),
|
||||
'weight' => Yard::instance('shopping')->weight(),
|
||||
'is_abo' => isset($data['is_abo']) ? $data['is_abo'] : false,
|
||||
'abo_interval' => isset($data['abo_interval']) ? $data['abo_interval'] : null,
|
||||
'txaction' => 'prev',
|
||||
'mode' => Util::getUserShoppingMode(),
|
||||
];
|
||||
}
|
||||
|
||||
$shopping_order= false;
|
||||
if($this->getSessionPayments('shopping_order_id')){
|
||||
$shopping_order = ShoppingOrder::find($this->getSessionPayments('shopping_order_id'));
|
||||
if($shopping_order){
|
||||
$shopping_order->fill($data);
|
||||
$shopping_order->save();
|
||||
}
|
||||
}
|
||||
if(!$shopping_order){
|
||||
$shopping_order = ShoppingOrder::create($data);
|
||||
if($shopping_user->is_from === 'collection' && $ShoppingCollectOrder){
|
||||
$ShoppingCollectOrder->shopping_order_id = $shopping_order->id;
|
||||
$ShoppingCollectOrder->save();
|
||||
}
|
||||
}
|
||||
$this->putSessionPayments('shopping_order_id', $shopping_order->id);
|
||||
|
||||
$items = Yard::instance('shopping')->getContentByOrder();
|
||||
$shopping_order->shopping_order_items()->each(function($model) use ($items, $shopping_order, $shopping_user) {
|
||||
foreach ($items as $item) {
|
||||
if ($model->row_id === $item->rowId) {
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
$data = [
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug,
|
||||
];
|
||||
if($shopping_user->is_from === 'homeparty'){
|
||||
$data['homeparty_id'] = (int) $shopping_user->homeparty_id;
|
||||
$data['product_id'] = null;
|
||||
}
|
||||
if($shopping_user->is_from === 'collection'){
|
||||
$data['shopping_collect_order_id'] = (int) $shopping_user->shopping_collect_order_id;
|
||||
$data['product_id'] = null;
|
||||
}
|
||||
$model->fill($data)->save();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $model->delete();
|
||||
});
|
||||
foreach ($items as $item) {
|
||||
if (!ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()){
|
||||
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
|
||||
$data = [
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
'price' => $item->price,
|
||||
'price_net' => $price_net,
|
||||
'tax_rate' => $item->taxRate,
|
||||
'tax' => $tax,
|
||||
'price_vk_net' => $shopping_order->getPriceVkNetBy($item->id),
|
||||
'discount' => $item->options->no_commission ? 0 : $shopping_order->getUserDiscount(),
|
||||
'points' => $item->options->points,
|
||||
'slug' => $item->options->slug
|
||||
];
|
||||
|
||||
if($shopping_user->is_from === 'homeparty'){
|
||||
$data['homeparty_id'] = (int) $shopping_user->homeparty_id;
|
||||
$data['price_vk_net'] = 0;
|
||||
$data['product_id'] = null;
|
||||
}
|
||||
if($shopping_user->is_from === 'collection'){
|
||||
$data['price_vk_net'] = 0;
|
||||
$data['shopping_collect_order_id'] = (int) $shopping_user->shopping_collect_order_id;
|
||||
$data['product_id'] = null;
|
||||
}
|
||||
$shopping_order_item = ShoppingOrderItem::create($data);
|
||||
}
|
||||
}
|
||||
if($shopping_user->is_from === 'homeparty'){
|
||||
$shopping_order->makeHomepartyTaxSplit();
|
||||
}elseif($shopping_user->is_from === 'collection'){
|
||||
//is set on create / filll.
|
||||
}else{
|
||||
$shopping_order->makeTaxSplit();
|
||||
}
|
||||
return $shopping_order;
|
||||
}
|
||||
public function makeShoppingUser($data){
|
||||
|
||||
$data['same_as_billing'] = isset($data['same_as_billing']) ? false : true; //reinvert
|
||||
$data['accepted_data_checkbox'] = isset($data['accepted_data_checkbox']) ? true : false;
|
||||
$shopping_user = false;
|
||||
if($this->getSessionPayments('shopping_user_id')){
|
||||
$shopping_user = ShoppingUser::find($this->getSessionPayments('shopping_user_id'));
|
||||
if($shopping_user){
|
||||
$shopping_user->fill($data);
|
||||
$shopping_user->mode = null;
|
||||
$shopping_user->save();
|
||||
}
|
||||
}
|
||||
if(!$shopping_user){
|
||||
$shopping_user = ShoppingUser::create($data);
|
||||
}
|
||||
$this->putSessionPayments('shopping_user_id', $shopping_user->id);
|
||||
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public function getPaymentsMethods($is_from, $is_abo = false){
|
||||
$payment_methods = [];
|
||||
if($is_from !== 'shopping' && Util::getAuthUser()){
|
||||
$user = Util::getAuthUser();
|
||||
$payment_methods['default'] = $user->payment_methods;
|
||||
$payment_methods['data'] = $user->account->payment_data;
|
||||
}else{
|
||||
$payment_methods['default'] = PaymentMethod::getDefaultAsArray($is_abo)->toArray();
|
||||
$payment_methods['data'] = false;
|
||||
}
|
||||
if($is_abo){
|
||||
$payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->where('is_abo', true)->get()->pluck( 'id', 'short')->toArray();
|
||||
}else{
|
||||
$payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->get()->pluck( 'id', 'short')->toArray();
|
||||
}
|
||||
return $payment_methods;
|
||||
}
|
||||
|
||||
public function isPaymentsMethodsActive($payment_method, $is_from, $is_abo = false){
|
||||
$payment_names = ['wlt#PPE' => 'PP', 'cc' => 'CC', 'sb#PNT' => 'SB', 'elv' => 'SEPA', 'vor' => 'VOR', 'fnc#MIV' => 'FNC'];
|
||||
$payment_methods = $this->getPaymentsMethods($is_from, $is_abo);
|
||||
if(isset($payment_names[$payment_method])){
|
||||
$payment_with = $payment_names[$payment_method];
|
||||
if(array_key_exists($payment_with, $payment_methods['active']) && in_array($payment_methods['active'][$payment_with], $payment_methods['default'])){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
abort(404);
|
||||
}
|
||||
|
||||
public function makeCustomerShoppingUser($shopping_data){
|
||||
// $shopping_user = ShoppingUser::findOrFail($shopping_data['shopping_user_id']);
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->fill($shopping_data);
|
||||
$shopping_user->faker_mail = false;
|
||||
$shopping_user->auth_user_id = null;
|
||||
$shopping_user->homeparty_id = null;
|
||||
$shopping_user->same_as_billing = $shopping_user->same_as_billing ? false : true; //reinvert
|
||||
// $shopping_user->id = null;
|
||||
$shopping_user->accepted_data_checkbox = 1;
|
||||
return $shopping_user;
|
||||
|
||||
}
|
||||
|
||||
public function shoppingUserAuthData($is_from, $is_for, $data = []){
|
||||
|
||||
$user = Util::getAuthUser();
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->auth_user_id = $user->id;
|
||||
$shopping_user->mode = 'prev';
|
||||
$shopping_user->language = \App::getLocale();
|
||||
|
||||
$shopping_user->billing_salutation = $user->account->salutation;
|
||||
$shopping_user->billing_company = $user->account->company;
|
||||
$shopping_user->billing_firstname = $user->account->first_name;
|
||||
$shopping_user->billing_lastname = $user->account->last_name;
|
||||
$shopping_user->billing_address = $user->account->address;
|
||||
$shopping_user->billing_address_2 = $user->account->address_2;
|
||||
$shopping_user->billing_zipcode = $user->account->zipcode;
|
||||
$shopping_user->billing_city = $user->account->city;
|
||||
$shopping_user->billing_country_id = $user->account->country_id;
|
||||
$shopping_user->billing_phone = $user->account->phone;
|
||||
$shopping_user->billing_email = $user->email;
|
||||
$shopping_user->faker_mail = false;
|
||||
$shopping_user->shipping_email = $user->email;
|
||||
|
||||
$shopping_user->accepted_data_checkbox = 1;
|
||||
$shopping_user->is_for = $is_for;
|
||||
$shopping_user->is_from = $is_from;
|
||||
$shopping_user->homeparty_id = isset($data['homeparty_id']) ? $data['homeparty_id'] : null;
|
||||
$shopping_user->shopping_collect_order_id = isset($data['shopping_collect_order_id']) ? $data['shopping_collect_order_id'] : null;
|
||||
|
||||
//Lieferadresse
|
||||
if($is_from === 'user_order'){
|
||||
if(isset($data['shopping_user_id']) && strpos($data['is_for'], 'ot') !== false){
|
||||
$s_user = ShoppingUser::findOrFail($data['shopping_user_id']);
|
||||
/* $shopping_user->billing_salutation = $s_user->billing_salutation;
|
||||
$shopping_user->billing_company = $s_user->billing_company;
|
||||
$shopping_user->billing_firstname = $s_user->billing_firstname;
|
||||
$shopping_user->billing_lastname = $s_user->billing_lastname;
|
||||
$shopping_user->billing_address = $s_user->billing_address;
|
||||
$shopping_user->billing_address_2 = $s_user->billing_address_2;
|
||||
$shopping_user->billing_zipcode = $s_user->billing_zipcode;
|
||||
$shopping_user->billing_city = $s_user->billing_city;
|
||||
$shopping_user->billing_country_id = $s_user->billing_country_id;
|
||||
$shopping_user->billing_phone = $s_user->billing_phone;
|
||||
$shopping_user->billing_email = $s_user->billing_email;
|
||||
;*/
|
||||
$shopping_user->faker_mail = $s_user->faker_mail;
|
||||
if(!$s_user->faker_mail){
|
||||
$shopping_user->shipping_email = $s_user->billing_email;
|
||||
}
|
||||
$shopping_user->shopping_user_id = $data['shopping_user_id'];
|
||||
$shopping_user->member_id = $s_user->member_id;
|
||||
}
|
||||
$shopping_user->same_as_billing = true;
|
||||
$shopping_user->shipping_salutation = isset($data['shipping_salutation']) ? $data['shipping_salutation'] : '';
|
||||
$shopping_user->shipping_company = isset($data['shipping_company']) ? $data['shipping_company'] : '';
|
||||
$shopping_user->shipping_firstname = isset($data['shipping_firstname']) ? $data['shipping_firstname'] : '';
|
||||
$shopping_user->shipping_lastname = isset($data['shipping_lastname']) ? $data['shipping_lastname'] : '';
|
||||
$shopping_user->shipping_address = isset($data['shipping_address']) ? $data['shipping_address'] : '';
|
||||
$shopping_user->shipping_address_2 = isset($data['shipping_address_2']) ? $data['shipping_address_2'] : '';
|
||||
$shopping_user->shipping_zipcode = isset($data['shipping_zipcode']) ? $data['shipping_zipcode'] : '';
|
||||
$shopping_user->shipping_city = isset($data['shipping_city']) ? $data['shipping_city'] : '';
|
||||
$shopping_user->shipping_country_id = Yard::instance('shopping')->getShippingCountryCountryId();
|
||||
$shopping_user->shipping_phone = isset($data['shipping_phone']) ? $data['shipping_phone'] : '';
|
||||
|
||||
}else{
|
||||
$shopping_user->same_as_billing = $user->account->same_as_billing ? false : true;
|
||||
$shopping_user->shipping_salutation = $user->account->shipping_salutation;
|
||||
$shopping_user->shipping_company = $user->account->shipping_company;
|
||||
$shopping_user->shipping_firstname = $user->account->shipping_firstname;
|
||||
$shopping_user->shipping_lastname = $user->account->shipping_lastname;
|
||||
$shopping_user->shipping_address = $user->account->shipping_address;
|
||||
$shopping_user->shipping_address_2 = $user->account->shipping_address_2;
|
||||
$shopping_user->shipping_zipcode = $user->account->shipping_zipcode;
|
||||
$shopping_user->shipping_city = $user->account->shipping_city;
|
||||
$shopping_user->shipping_country_id = $user->account->shipping_country_id;
|
||||
$shopping_user->shipping_phone = $user->account->shipping_phone;
|
||||
}
|
||||
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public function putSessionPayments($key, $value){
|
||||
$content = $this->getContent();
|
||||
$content->put($key, $value);
|
||||
$this->session->put($this->instance, $content);
|
||||
|
||||
}
|
||||
|
||||
public function getSessionPayments($key){
|
||||
|
||||
$content = $this->getContent();
|
||||
if ($content->has($key)){
|
||||
return $content->get($key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function sessionDestroy()
|
||||
{
|
||||
$this->session->remove($this->instance);
|
||||
}
|
||||
|
||||
private function getContent()
|
||||
{
|
||||
if (is_null($this->session->get($this->instance))) {
|
||||
return new Collection([]);
|
||||
}
|
||||
return $this->session->get($this->instance);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,24 +2,36 @@
|
|||
|
||||
namespace App\Repositories\DC;
|
||||
|
||||
use Imagick;
|
||||
use Request;
|
||||
|
||||
use App\Models\DcFile;
|
||||
use App\Services\Util;
|
||||
use App\Models\DcFileTag;
|
||||
use App\Repositories\BaseRepository;
|
||||
use Intervention\Image\Facades\Image;
|
||||
|
||||
use Imagick;
|
||||
|
||||
class FileRepository extends BaseRepository {
|
||||
|
||||
private const ALLOWED_IMAGE_TYPES = [
|
||||
'image/jpeg',
|
||||
'image/gif',
|
||||
'image/png'
|
||||
];
|
||||
|
||||
private const ALLOWED_PDF_TYPES = [
|
||||
'application/pdf'
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
private const THUMB_WIDTH = 542;
|
||||
private const THUMB_HEIGHT = 360;
|
||||
private const BIG_WIDTH = 1600;
|
||||
private const BIG_HEIGHT = 900;
|
||||
|
||||
public function uploadFile( $form_data )
|
||||
public function uploadFile(array $form_data): DcFile
|
||||
{
|
||||
if (!isset($form_data['file']) || !$form_data['file']->isValid()) {
|
||||
throw new \InvalidArgumentException('Invalid file provided');
|
||||
}
|
||||
$file = $form_data['file'];
|
||||
$originalName = $file->getClientOriginalName();
|
||||
$extension = $file->getClientOriginalExtension();
|
||||
|
|
@ -43,109 +55,163 @@ class FileRepository extends BaseRepository {
|
|||
return $dc_file;
|
||||
}
|
||||
|
||||
public function makeThumb($id){
|
||||
public function makeThumb(int $id): bool
|
||||
{
|
||||
$file = DcFile::findOrFail($id);
|
||||
$this->makeThumbFromFile($file);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function makeThumbFromFile($file)
|
||||
public function makeThumbFromFile(DcFile $file): bool
|
||||
{
|
||||
$path = $file->getFile(true);
|
||||
$filename = $file->filename;
|
||||
$mine = \File::mimeType($path);
|
||||
//make thumb
|
||||
$allowedMimeTypes = ['image/jpeg','image/gif','image/png'];
|
||||
if (in_array($mine, $allowedMimeTypes)) {
|
||||
$img = Image::make($path);
|
||||
$img->resize(542, 360, function ($c) {
|
||||
$c->aspectRatio();
|
||||
$c->upsize();
|
||||
});
|
||||
\Storage::disk('public')->put('dc/thumb/'.basename($filename), (string) $img->encode());
|
||||
|
||||
$img = Image::make($path);
|
||||
$img->resize(1600, 900, function ($c) {
|
||||
$c->aspectRatio();
|
||||
$c->upsize();
|
||||
});
|
||||
\Storage::disk('public')->put('dc/big/'.basename($filename), (string) $img->encode());
|
||||
}
|
||||
|
||||
$allowedMimeTypes = ['application/pdf'];
|
||||
if (in_array($mine, $allowedMimeTypes)) {
|
||||
$imagick = new \Imagick ($path.'[0]'); // 0 specifies the first page of the pdf
|
||||
$imagick->setImageBackgroundColor('#ffffff');
|
||||
$imagick = $imagick->mergeImageLayers( Imagick::LAYERMETHOD_FLATTEN );
|
||||
$imagick->setImageFormat('jpg'); // set the format of the output image
|
||||
$imagick->setImageCompression(\Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality(60);
|
||||
|
||||
$imagick->resizeImage(1600, 900, \Imagick::FILTER_LANCZOS, 1,1);
|
||||
$filestore = \Storage::disk('public')->path('dc/big/').basename($filename).".jpg";
|
||||
$imagick->writeImage($filestore);
|
||||
|
||||
$imagick->resizeImage(542, 360, \Imagick::FILTER_LANCZOS, 1,1);
|
||||
$filestore = \Storage::disk('public')->path('dc/thumb/').basename($filename).".jpg";
|
||||
$imagick->writeImage($filestore);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function tagsUpdate($id, $tags){
|
||||
$file = DcFile::findOrFail($id);
|
||||
$file_tags = DcFileTag::where('file_id', $file->id)->get();
|
||||
|
||||
//remove Tags
|
||||
foreach ($file_tags as $file_tag) {
|
||||
if(is_array($tags) && ($pos = array_search($file_tag->tag_id, $tags)) !== FALSE){
|
||||
unset($tags[$pos]);
|
||||
}else{
|
||||
$file_tag->delete();
|
||||
try {
|
||||
$path = $file->getFile(true);
|
||||
if (!file_exists($path)) {
|
||||
throw new \Exception('File not found');
|
||||
}
|
||||
}
|
||||
//set taTagsgs
|
||||
if(is_array($tags)){
|
||||
foreach ($tags as $key => $tag_id) {
|
||||
DcFileTag::create([
|
||||
'file_id' => $file->id,
|
||||
'tag_id' => $tag_id
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$filename = $file->filename;
|
||||
$mime = \File::mimeType($path);
|
||||
|
||||
if (in_array($mime, self::ALLOWED_IMAGE_TYPES)) {
|
||||
$this->processImage($path, $filename);
|
||||
} elseif (in_array($mime, self::ALLOWED_PDF_TYPES)) {
|
||||
$this->processPdf($path, $filename);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Thumbnail creation failed: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function processImage(string $path, string $filename): void
|
||||
{
|
||||
// Thumbnail
|
||||
$img = Image::make($path);
|
||||
$img->resize(542, 360, function ($c) {
|
||||
$c->aspectRatio();
|
||||
$c->upsize();
|
||||
});
|
||||
\Storage::disk('public')->put('dc/thumb/'.basename($filename), (string) $img->encode());
|
||||
|
||||
// Big image
|
||||
$img = Image::make($path);
|
||||
$img->resize(1600, 900, function ($c) {
|
||||
$c->aspectRatio();
|
||||
$c->upsize();
|
||||
});
|
||||
\Storage::disk('public')->put('dc/big/'.basename($filename), (string) $img->encode());
|
||||
}
|
||||
|
||||
private function processPdf(string $path, string $filename): void
|
||||
{
|
||||
try {
|
||||
// PDF mit höherer Auflösung rendern
|
||||
$imagick = new \Imagick();
|
||||
$imagick->setResolution(300, 300);
|
||||
$imagick->readImage($path.'[0]');
|
||||
|
||||
// Grundlegende Bildoptimierungen
|
||||
$imagick->setImageBackgroundColor('#ffffff');
|
||||
$imagick->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN);
|
||||
$imagick->setImageFormat('jpg');
|
||||
$imagick->setImageCompression(\Imagick::COMPRESSION_JPEG);
|
||||
$imagick->setImageCompressionQuality(80);
|
||||
|
||||
// Große Version erstellen
|
||||
$bigImage = clone $imagick;
|
||||
$bigImage->resizeImage(self::BIG_WIDTH, self::BIG_HEIGHT, \Imagick::FILTER_LANCZOS, 1, true);
|
||||
$bigImage->writeImage(\Storage::disk('public')->path('dc/big/').basename($filename).'.jpg');
|
||||
$bigImage->clear();
|
||||
|
||||
// Thumbnail erstellen
|
||||
$imagick->resizeImage(self::THUMB_WIDTH, self::THUMB_HEIGHT, \Imagick::FILTER_LANCZOS, 1, true);
|
||||
$imagick->writeImage(\Storage::disk('public')->path('dc/thumb/').basename($filename).'.jpg');
|
||||
|
||||
// Ressourcen freigeben
|
||||
$imagick->clear();
|
||||
} catch (\ImagickException $e) {
|
||||
\Log::error('PDF Verarbeitung fehlgeschlagen: ' . $e->getMessage());
|
||||
throw new \RuntimeException('PDF Verarbeitung fehlgeschlagen: ' . $e->getMessage());
|
||||
} finally {
|
||||
if (isset($bigImage)) {
|
||||
$bigImage->destroy();
|
||||
}
|
||||
if (isset($imagick)) {
|
||||
$imagick->destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function tagsUpdate($id, array $tags = []): bool
|
||||
{
|
||||
$file = DcFile::findOrFail($id);
|
||||
|
||||
// Get existing tags
|
||||
$existingTags = DcFileTag::where('file_id', $file->id)
|
||||
->pluck('tag_id')
|
||||
->toArray();
|
||||
|
||||
// Delete removed tags
|
||||
$tagsToDelete = array_diff($existingTags, $tags);
|
||||
if (!empty($tagsToDelete)) {
|
||||
DcFileTag::where('file_id', $file->id)
|
||||
->whereIn('tag_id', $tagsToDelete)
|
||||
->delete();
|
||||
}
|
||||
|
||||
// Add new tags
|
||||
$tagsToAdd = array_diff($tags, $existingTags);
|
||||
$newTags = [];
|
||||
foreach ($tagsToAdd as $tagId) {
|
||||
$newTags[] = [
|
||||
'file_id' => $file->id,
|
||||
'tag_id' => $tagId
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($newTags)) {
|
||||
DcFileTag::insert($newTags);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deleteThumb($id){
|
||||
$file = DcFile::findOrFail($id);
|
||||
$path_thumb = $file->getThumb(true);
|
||||
if (file_exists($path_thumb)) {
|
||||
unlink($path_thumb);
|
||||
}
|
||||
$path_big = $file->getBig(true);
|
||||
if (file_exists($path_big)) {
|
||||
unlink($path_big);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deleteFile($id){
|
||||
$file = DcFile::findOrFail($id);
|
||||
$path_thumb = $file->getThumb(true);
|
||||
if (file_exists($path_thumb)) {
|
||||
unlink($path_thumb);
|
||||
}
|
||||
$path_big = $file->getBig(true);
|
||||
if (file_exists($path_big)) {
|
||||
unlink($path_big);
|
||||
}
|
||||
$path = $file->getFile(true);
|
||||
private function deleteFileIfExists(string $path): void
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
unlink($path);
|
||||
}
|
||||
$file->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function deleteThumb($id): bool
|
||||
{
|
||||
try {
|
||||
$file = DcFile::findOrFail($id);
|
||||
$this->deleteFileIfExists($file->getThumb(true));
|
||||
$this->deleteFileIfExists($file->getBig(true));
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('Thumbnail deletion failed: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFile(int $id): bool
|
||||
{
|
||||
try {
|
||||
$file = DcFile::findOrFail($id);
|
||||
$this->deleteFileIfExists($file->getThumb(true));
|
||||
$this->deleteFileIfExists($file->getBig(true));
|
||||
$this->deleteFileIfExists($file->getFile(true));
|
||||
$file->delete();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('File deletion failed: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -89,47 +89,5 @@ class FileRepository extends BaseRepository {
|
|||
], 200);
|
||||
}
|
||||
|
||||
/* public function createFile(Request $request)
|
||||
{
|
||||
$locale = \App::getLocale();
|
||||
$data = [
|
||||
'step' => 2,
|
||||
'locale' => $locale,
|
||||
];
|
||||
$rules = array(
|
||||
'network_name' => 'required|max:255',
|
||||
'input_file_now' => 'required|mimes:png,pdf,jpg,jpeg|max:30000'
|
||||
);
|
||||
$validator = Validator::make(Request::all(), $rules);
|
||||
|
||||
if ($validator->fails()) {
|
||||
// get the error messages from the validator
|
||||
$messages = $validator->messages();
|
||||
// redirect our user back to the form with the errors from the validator
|
||||
return view('user.register_complete', $data)->withErrors($validator);
|
||||
|
||||
} else {
|
||||
$user = \Auth::user();
|
||||
if(!$user->account->network_name){
|
||||
$file = request()->file('input_file_now');
|
||||
//$ext = $file->guessClientExtension();
|
||||
//$file->storeAs('user/' . $user->id .'/verification');
|
||||
$data = $file->store('user/' . $user->id .'/verification');
|
||||
$account = $user->account;
|
||||
$account->network_name = Input::get('network_name');
|
||||
$account->network_verification = basename($data);
|
||||
$account->save();
|
||||
|
||||
$user->role_id = 2; //set as User by default!
|
||||
$user->save();
|
||||
|
||||
|
||||
}
|
||||
|
||||
return redirect('complete_register');
|
||||
//return view('user.register_complete', $data);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -34,12 +34,12 @@ class ProductRepository extends BaseRepository {
|
|||
$data['sponsor_buying_points'] = isset($data['sponsor_buying_points']) ? 1 : 0;
|
||||
$data['show_on'] = isset($data['show_on']) ? $data['show_on'] : null;
|
||||
|
||||
|
||||
if($data['id'] === "new"){
|
||||
$this->model = Product::create($data);
|
||||
}
|
||||
else{
|
||||
$this->model = $this->getById($data['id']);
|
||||
$this->model->slug = null;
|
||||
$this->model->fill($data);
|
||||
$this->model->save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,158 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\Product;
|
||||
use Yard;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\UserAbo;
|
||||
use App\Models\UserAboItem;
|
||||
use App\Models\UserAboOrder;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingPayment;
|
||||
|
||||
use App\Models\ShoppingUser;
|
||||
|
||||
class AboHelper
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
public static $txaction_filter_text = [
|
||||
'paid' => 'paymend_paid',
|
||||
'appointed' => 'paymend_open',
|
||||
'failed' => 'paymend_failed',
|
||||
'extern' => 'extern_open', //offen
|
||||
'extern_paid' => 'extern_paid',
|
||||
'invoice_open' => 'invoice_open',
|
||||
'invoice_paid' => 'invoice_paid',
|
||||
'invoice_non' => 'invoice_no_payment',
|
||||
'NULL' => 'no_payment',
|
||||
];
|
||||
|
||||
|
||||
public static function userHasAbo(User $user){
|
||||
$user = $user ? $user : \Auth::user();
|
||||
return UserAbo::where('user_id', $user->id)->where('is_for', 'me')->where('status', '>', 1)->first() === null ? false : true;
|
||||
}
|
||||
|
||||
public static function memberHasAbo(ShoppingUser $shopping_user){
|
||||
if(!$shopping_user){
|
||||
return false;
|
||||
}
|
||||
return UserAbo::where('email', $shopping_user->billing_email)->where('is_for', 'ot')->where('status', '>', 1)->first() === null ? false : true;
|
||||
}
|
||||
|
||||
public static function hasAboByEmail($email){
|
||||
return UserAbo::where('email', $email)->where('status', '>', 1)->first() === null ? false : true;
|
||||
}
|
||||
|
||||
public static function setAboStatus(ShoppingOrder $shopping_order, $status){
|
||||
$user_abo = $shopping_order->getUserAbo();
|
||||
if($user_abo && $user_abo->status < 2){ //status < 2 is not active
|
||||
$user_abo->update(['status' => $status]);
|
||||
}
|
||||
UserAboOrder::where('user_abo_id', $user_abo->id)->where('shopping_order_id', $shopping_order->id)->update(['status' => $status]);
|
||||
}
|
||||
public static function setAboActive(ShoppingOrder $shopping_order, $status){
|
||||
self::setAboStatus($shopping_order, $status);
|
||||
|
||||
//delete UserAbo is not active status = 1
|
||||
//is_for = me
|
||||
UserAbo::where('user_id', $shopping_order->auth_user_id)->where('is_for', 'me')->where('status', 1)->delete();
|
||||
//is_for = ot
|
||||
UserAbo::where('member_id', $shopping_order->member_id)->where('email', $shopping_order->shopping_user->billing_email)->where('is_for', 'ot')->where('status', 1)->delete();
|
||||
|
||||
}
|
||||
|
||||
public static function aboHasBaseProduct($yard_products){
|
||||
foreach($yard_products as $product){
|
||||
if(is_array($product->options->show_on)){
|
||||
if(in_array('12', $product->options->show_on)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static function getAboShowOn(Product $product){
|
||||
$show_on = $product->show_on;
|
||||
if(in_array('12', $show_on)){
|
||||
return 'base';
|
||||
}
|
||||
if(in_array('13', $show_on)){
|
||||
return 'upgrade';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static function getAboTypeBadge($abo_type){
|
||||
if($abo_type === 'base'){
|
||||
return '<span class="badge badge-pill badge-warning"><i class="fas fa-star"></i> '.__('abo.'.$abo_type).'</span></a>';
|
||||
}
|
||||
if($abo_type === 'upgrade'){
|
||||
return '<span class="badge badge-pill badge-info"><i class="far fa-star"></i> '.__('abo.'.$abo_type).'</span></a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function setNextDate($date, $abo_interval){
|
||||
$nextDate = Carbon::parse($date)->firstOfMonth();
|
||||
$nextDate->addDays($abo_interval-1);
|
||||
return $nextDate->gt($date) ? $nextDate : $nextDate->addMonth(1);
|
||||
}
|
||||
|
||||
public static function createNewAbo(ShoppingPayment $shopping_payment){
|
||||
//is Abo - create init Abo from PP or else
|
||||
if($shopping_payment->shopping_order->is_abo && $shopping_payment->shopping_order->abo_interval > 0){
|
||||
$payment_transaction = $shopping_payment->payment_transactions->last();
|
||||
|
||||
$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 = UserAbo::create([
|
||||
'user_id' => $shopping_payment->shopping_order->auth_user_id,
|
||||
'member_id' => $shopping_payment->shopping_order->member_id,
|
||||
'shopping_user_id' => $shopping_payment->shopping_order->shopping_user_id,
|
||||
'email' => $shopping_payment->shopping_order->shopping_user->billing_email,
|
||||
'is_for' => $shopping_payment->shopping_order->shopping_user->is_for,
|
||||
'payone_userid' => $payment_transaction->userid,
|
||||
'clearingtype' => $shopping_payment->clearingtype,
|
||||
'wallettype' => $shopping_payment->wallettype,
|
||||
'carddata' => $shopping_payment->carddata,
|
||||
'amount' => $shopping_payment->amount,
|
||||
'status' => 1,
|
||||
'abo_interval' => $shopping_payment->abo_interval,
|
||||
'start_date' => now(),
|
||||
'last_date' => now(),
|
||||
'next_date' => self::setNextDate(now(), $shopping_payment->abo_interval),
|
||||
]);
|
||||
|
||||
if($user_abo){
|
||||
self::createAboItems($user_abo, $shopping_payment);
|
||||
UserAboOrder::create([
|
||||
'user_abo_id' => $user_abo->id,
|
||||
'shopping_order_id' => $shopping_payment->shopping_order_id,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function createAboItems($user_abo, ShoppingPayment $shopping_payment){
|
||||
foreach($shopping_payment->shopping_order->shopping_order_items as $item){
|
||||
UserAboItem::create([
|
||||
'user_abo_id' => $user_abo->id,
|
||||
'shopping_order_id' => $shopping_payment->shopping_order_id,
|
||||
'product_id' => $item->product_id,
|
||||
'comp' => $item->comp ?? 0,
|
||||
'qty' => $item->qty,
|
||||
'status' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function getTransStatusFilterText(){
|
||||
$ret = [];
|
||||
foreach(self::$txaction_filter_text as $key=>$val){
|
||||
$ret[$key] = trans('payment.'.$val);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
201
app/Services/AboOrderCart.php
Normal file
201
app/Services/AboOrderCart.php
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use Yard;
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Product;
|
||||
use App\Models\UserAbo;
|
||||
use App\Models\UserAboItem;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserAboOrder;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingPayment;
|
||||
|
||||
class AboOrderCart
|
||||
{
|
||||
private static $user_abo;
|
||||
private static $is_for;
|
||||
private static $customer_detail;
|
||||
|
||||
|
||||
public static function initYard($user_abo){
|
||||
|
||||
self::$user_abo = $user_abo;
|
||||
Yard::instance('shopping')->destroy();
|
||||
self::$customer_detail = self::makeCustomerDetail($user_abo);
|
||||
if($user_abo->is_for === 'me'){
|
||||
self::$is_for = 'abo-me';
|
||||
if($user_abo->user && $user_abo->user->account->same_as_billing){
|
||||
$country_id = $user_abo->user->account->country_id;
|
||||
}else{
|
||||
$country_id = $user_abo->user->account->shipping_country_id;
|
||||
}
|
||||
if($country_id && $shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
|
||||
if($shipping_country->shipping && $shipping_country->shipping->active){
|
||||
UserService::initUserYard($user_abo->user, $shipping_country->id, 'abo-me');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
abort(403, 'Fehler: Versandland nicht gefunden');
|
||||
}
|
||||
if($user_abo->is_for === 'ot'){
|
||||
self::$is_for = 'abo-ot-customer';
|
||||
UserService::initCustomerYard(self::$customer_detail, 'abo-ot-customer');
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static function makeOrderYard($user_abo)
|
||||
{
|
||||
self::$user_abo = $user_abo;
|
||||
if($user_abo->is_for === 'ot'){
|
||||
self::$is_for = 'abo-ot-customer';
|
||||
}
|
||||
if($user_abo->is_for === 'me'){
|
||||
self::$is_for = 'abo-me';
|
||||
}
|
||||
foreach($user_abo->user_abo_items as $abo_item){
|
||||
self::addProductToCart($abo_item);
|
||||
}
|
||||
Yard::instance('shopping')->reCalculateShippingPrice();
|
||||
|
||||
$user_abo->amount = Yard::instance('shopping')->totalWithShipping(2, '.', '')*100;
|
||||
$user_abo->save();
|
||||
}
|
||||
|
||||
private static function addProductToCart($item){
|
||||
|
||||
$product = Product::find($item->product_id);
|
||||
$tax_free = Yard::instance('shopping')->getUserTaxFree();
|
||||
$user_country = Yard::instance('shopping')->getUserCountry();
|
||||
|
||||
if($product){
|
||||
if($item->comp){
|
||||
$cartItem = Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, 0, false, false,
|
||||
['image' => '', 'slug' => $product->slug, 'weight' => 0, 'points' => 0,
|
||||
'comp' => $item->comp, 'product_id' => $product->id]);
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
return true;
|
||||
}
|
||||
if(self::$is_for === 'ot-customer' || self::$is_for === 'abo-ot-customer'){
|
||||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), $item->qty,
|
||||
round($product->getPriceWith($tax_free, false, $user_country, false, self::$user_abo->user), 1), false, false,
|
||||
['image' => '', 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
}else{
|
||||
$cartItem = Yard::instance('shopping')
|
||||
->add($product->id, $product->getLang('name'), $item->qty,
|
||||
$product->getPriceWith($tax_free, true, $user_country, false, self::$user_abo->user), false, false,
|
||||
['image' => '', 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
}
|
||||
if($tax_free){
|
||||
Yard::setTax($cartItem->rowId, 0);
|
||||
}else{
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith($user_country));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function checkNumOfCompProducts($user_abo){
|
||||
|
||||
if($user_abo->is_for === 'me'){
|
||||
$needNumComp = Yard::instance('shopping')->getNumComp();
|
||||
if($needNumComp > 0){
|
||||
$UserAboItems = UserAboItem::where('user_abo_id', $user_abo->id)->where('comp', '>', 0)->get();
|
||||
if(count($UserAboItems) === $needNumComp){
|
||||
return true;
|
||||
}
|
||||
|
||||
//need to add
|
||||
if(count($UserAboItems) < $needNumComp){
|
||||
$product = Product::whereActive(true)->where('shipping_addon', true)->whereJsonContains('show_on', '12')->orderBy('pos', 'DESC')->first();
|
||||
for($i = count($UserAboItems); $i <= $needNumComp; $i++){
|
||||
$UserAboItem = UserAboItem::create([
|
||||
'user_abo_id' => $user_abo->id,
|
||||
'product_id' => $product->id,
|
||||
'comp' => $i + 1,
|
||||
'qty' => 1,
|
||||
'status' => 1,
|
||||
]);
|
||||
self::addProductToCart($UserAboItem);
|
||||
}
|
||||
}
|
||||
//need to remove
|
||||
if(count($UserAboItems) > $needNumComp){
|
||||
foreach($UserAboItems as $UserAboItem){
|
||||
if($UserAboItem->comp > $needNumComp){
|
||||
$UserAboItem->delete();
|
||||
}
|
||||
}
|
||||
foreach (Yard::instance('shopping')->content() as $row) {
|
||||
if($row->options->comp > $needNumComp) {
|
||||
Yard::instance('shopping')->remove($row->rowId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getCustomerDetail(){
|
||||
return self::$customer_detail;
|
||||
}
|
||||
|
||||
/* Need this, can change the address */
|
||||
public static function makeCustomerDetail($user_abo){
|
||||
|
||||
if($user_abo->is_for === 'me'){
|
||||
//only on Abo!
|
||||
$user = $user_abo->user;
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user->billing_salutation = $user->account->salutation;
|
||||
$shopping_user->billing_company = $user->account->company;
|
||||
$shopping_user->billing_firstname = $user->account->first_name;
|
||||
$shopping_user->billing_lastname = $user->account->last_name;
|
||||
$shopping_user->billing_address = $user->account->address;
|
||||
$shopping_user->billing_address_2 = $user->account->address_2;
|
||||
$shopping_user->billing_zipcode = $user->account->zipcode;
|
||||
$shopping_user->billing_city = $user->account->city;
|
||||
$shopping_user->billing_country_id = $user->account->country_id;
|
||||
$shopping_user->billing_phone = $user->account->phone;
|
||||
|
||||
if($user->account->same_as_billing){
|
||||
$shopping_user->shipping_salutation = $user->account->salutation;
|
||||
$shopping_user->shipping_company = $user->account->company;
|
||||
$shopping_user->shipping_firstname = $user->account->first_name;
|
||||
$shopping_user->shipping_lastname = $user->account->last_name;
|
||||
$shopping_user->shipping_address = $user->account->address;
|
||||
$shopping_user->shipping_address_2 = $user->account->address_2;
|
||||
$shopping_user->shipping_zipcode = $user->account->zipcode;
|
||||
$shopping_user->shipping_city = $user->account->city;
|
||||
$shopping_user->shipping_country_id = $user->account->country_id;
|
||||
$shopping_user->shipping_phone = $user->account->phone;
|
||||
}else{
|
||||
$shopping_user->shipping_salutation = $user->account->shipping_salutation;
|
||||
$shopping_user->shipping_company = $user->account->shipping_company;
|
||||
$shopping_user->shipping_firstname = $user->account->shipping_firstname;
|
||||
$shopping_user->shipping_lastname = $user->account->shipping_lastname;
|
||||
$shopping_user->shipping_address = $user->account->shipping_address;
|
||||
$shopping_user->shipping_address_2 = $user->account->shipping_address_2;
|
||||
$shopping_user->shipping_zipcode = $user->account->shipping_zipcode;
|
||||
$shopping_user->shipping_city = $user->account->shipping_city;
|
||||
$shopping_user->shipping_country_id = $user->account->shipping_country_id;
|
||||
$shopping_user->shipping_phone = $user->account->shipping_phone;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($user_abo->is_for === 'ot'){
|
||||
//look for the primary user of this abo
|
||||
$shopping_user = $user_abo->shopping_user->replicate();
|
||||
}
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\BusinessPlan;
|
||||
|
||||
use App\User;
|
||||
|
|
@ -15,7 +16,7 @@ class ExportBot
|
|||
public $user_list;
|
||||
|
||||
private $root_user;
|
||||
|
||||
|
||||
|
||||
public function __construct($init_from = 'member')
|
||||
{
|
||||
|
|
@ -23,26 +24,25 @@ class ExportBot
|
|||
$this->init_from = $init_from;
|
||||
}
|
||||
|
||||
public function initStructureUser(User $user, $order='list') //tree or list
|
||||
public function initStructureUser(User $user, $order = 'list') //tree or list
|
||||
{
|
||||
$line = 0;
|
||||
$this->order = $order;
|
||||
$this->root_user = $user;
|
||||
|
||||
if($this->order === 'tree'){
|
||||
$this->user_tree = $this->setUserValues($user, $line);
|
||||
$this->user_tree->childs = $this->readChildUsers($this->user_tree, $line+1);
|
||||
}
|
||||
if($this->order === 'list'){
|
||||
$this->user_list = $this->setUserValues($user, $line);
|
||||
$this->readChildUsers($this->user_list, $line+1);
|
||||
}
|
||||
|
||||
|
||||
if ($this->order === 'tree') {
|
||||
$this->user_tree = $this->setUserValues($user, $line);
|
||||
$this->user_tree->childs = $this->readChildUsers($this->user_tree, $line + 1);
|
||||
}
|
||||
if ($this->order === 'list') {
|
||||
$this->user_list = $this->setUserValues($user, $line);
|
||||
$this->readChildUsers($this->user_list, $line + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function readChildUsers($parent_user, $line){
|
||||
private function readChildUsers($parent_user, $line)
|
||||
{
|
||||
|
||||
$childUsers = [];
|
||||
$users = User::with('account')->select('users.*')
|
||||
|
|
@ -55,24 +55,25 @@ class ExportBot
|
|||
->where('users.active', "=", 1)
|
||||
->get();
|
||||
|
||||
if($users){
|
||||
foreach($users as $user){
|
||||
if ($users) {
|
||||
foreach ($users as $user) {
|
||||
$user_values = $this->setUserValues($user, $line);
|
||||
$childUsers[] = $user_values;
|
||||
if($this->order === 'list'){
|
||||
$childUsers[] = $user_values;
|
||||
if ($this->order === 'list') {
|
||||
$this->user_list->childs[] = $user_values;
|
||||
$this->readChildUsers($user_values, $line+1);
|
||||
}
|
||||
$this->readChildUsers($user_values, $line + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $childUsers;
|
||||
}
|
||||
|
||||
private function setUserValues(User $user, $line){
|
||||
private function setUserValues(User $user, $line)
|
||||
{
|
||||
|
||||
$sponsor_name = "";
|
||||
if($user->m_sponsor && $user->user_sponsor->account){
|
||||
$sponsor_name = $user->user_sponsor->account->m_first_name." ".$user->user_sponsor->account->m_last_name;
|
||||
if ($user->m_sponsor && $user->user_sponsor->account) {
|
||||
$sponsor_name = $user->user_sponsor->account->m_first_name . " " . $user->user_sponsor->account->m_last_name;
|
||||
}
|
||||
$obj = new stdClass();
|
||||
$obj->line = $line;
|
||||
|
|
@ -93,28 +94,28 @@ class ExportBot
|
|||
$obj->zipcode = $user->account->zipcode;
|
||||
$obj->city = $user->account->city;
|
||||
$obj->country_id = $user->account->country_id ? $user->account->country->getLocated() : "";
|
||||
$pre_phone = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone." " : "";
|
||||
$pre_mobil = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone." " : "";
|
||||
$obj->phone = $pre_phone.$user->account->phone;
|
||||
$obj->mobil = $pre_mobil.$user->account->mobil;
|
||||
$pre_phone = $user->account->pre_phone_id != "" ? $user->account->pre_phone->phone . " " : "";
|
||||
$pre_mobil = $user->account->pre_mobil_id != "" ? $user->account->pre_mobil->phone . " " : "";
|
||||
$obj->phone = $pre_phone . $user->account->phone;
|
||||
$obj->mobil = $pre_mobil . $user->account->mobil;
|
||||
$obj->birthday = $user->account->birthday;
|
||||
$obj->partner_since = $user->active_date ? $user->getActiveDateFormat(false) : "";
|
||||
|
||||
if($this->order === 'tree'){
|
||||
$obj->childs = $this->readChildUsers($obj, $line+1);
|
||||
if ($this->order === 'tree') {
|
||||
$obj->childs = $this->readChildUsers($obj, $line + 1);
|
||||
}
|
||||
if($this->order === 'list'){
|
||||
if ($this->order === 'list') {
|
||||
$obj->childs = [];
|
||||
}
|
||||
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getUser(){
|
||||
|
||||
|
||||
public function getUser()
|
||||
{
|
||||
return $this->root_user;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ class SalesPointsVolumeHelper
|
|||
line: nach reihenfolge sortiert,
|
||||
*/
|
||||
private static $business_users_line = [];
|
||||
|
||||
private static $totalcommission = [];
|
||||
private static $totalpoints = [];
|
||||
private static $cbot = null;
|
||||
|
||||
|
||||
|
|
@ -36,7 +37,6 @@ class SalesPointsVolumeHelper
|
|||
$deep = 0;
|
||||
$ret = "";
|
||||
foreach(self::$cbot->business_users as $business_user){
|
||||
|
||||
$ret .= self::addTableItemStructur($business_user, $deep);
|
||||
}
|
||||
return $ret;
|
||||
|
|
@ -68,7 +68,7 @@ class SalesPointsVolumeHelper
|
|||
<td><div class="no-line-break">'.$pp.'</div></td>
|
||||
<td><span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>'.$item->first_name.' '.$item->last_name.'
|
||||
</td>
|
||||
<td><div class="no-line-break">'.formatNumber($points, 0).' €</span></td>
|
||||
<td><div class="no-line-break">'.formatNumber($points, 0).'</span></td>
|
||||
<td>'.formatNumber($margin, 1).' %</td>
|
||||
<td><div class="no-line-break">'.formatNumber($commission, 2).' €</span></td>
|
||||
<td><span class="small">'.$item->user_level_name.'</span></td>
|
||||
|
|
@ -84,10 +84,16 @@ class SalesPointsVolumeHelper
|
|||
self::addTableItemLine($business_user, $deep);
|
||||
}
|
||||
foreach(self::$business_users_line as $deep => $items){
|
||||
self::$totalcommission[$deep] = 0;
|
||||
self::$totalpoints[$deep] = 0;
|
||||
foreach($items as $item){
|
||||
$ret .= self::setTableHTMLItemLine($item, $deep);
|
||||
}
|
||||
if($deep > 0){
|
||||
$ret .= self::addTableHTMLTotalItemLine($deep, 'line');
|
||||
}
|
||||
}
|
||||
$ret .= self::addTableHTMLTotalItemLine($deep, 'end');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +106,39 @@ class SalesPointsVolumeHelper
|
|||
}
|
||||
}
|
||||
}
|
||||
private static function addTableHTMLTotalItemLine($deep, $type){
|
||||
$points = 0;
|
||||
$commission = 0;
|
||||
if($type == 'end'){
|
||||
$pp = '<div class=" line-height-1 my-2 badge badge-outline-success text-dark font-weight-bolder">'.__('team.PP').'</div>';
|
||||
$style = ' style="background-color:#d7d700;"';
|
||||
$text = __('order.total');
|
||||
foreach(self::$totalpoints as $key => $value){
|
||||
$points += $value;
|
||||
$commission += self::$totalcommission[$key];
|
||||
}
|
||||
|
||||
}else{
|
||||
$pp = '<div class=" line-height-1 my-2 badge badge-outline-success text-dark font-weight-bolder">'.$deep.'. '.__('team.PP').'</div>';
|
||||
$style = 'style="background-color:#e5e4e4"';
|
||||
$text = __('order.sum');
|
||||
$points = self::$totalpoints[$deep];
|
||||
$commission = self::$totalcommission[$deep];
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ret = '<tr '.$style.'>
|
||||
<td><div class="no-line-break">'.$pp.'</div></td>
|
||||
<td><b>'.$text.'</b></td>
|
||||
<td><div class="no-line-break"><b>'.formatNumber($points, 0).'</b></span></td>
|
||||
<td> </td>
|
||||
<td><div class="no-line-break"><b>'.formatNumber($commission, 2).' €</b></span></td>
|
||||
<td> </td>
|
||||
</tr>';
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private static function setTableHTMLItemLine($item, $deep){
|
||||
|
||||
|
|
@ -111,6 +150,8 @@ class SalesPointsVolumeHelper
|
|||
$pp = '<div class=" line-height-1 my-2 badge badge-outline-success text-dark font-weight-bolder">'.$deep.'. '.__('team.PP').'</div>';
|
||||
$margin = self::$cbot->getKeybyLine($deep, 'margin');
|
||||
$commission = $points / 100 * $margin;
|
||||
self::$totalcommission[$deep] += $commission;
|
||||
self::$totalpoints[$deep] += $points;
|
||||
}
|
||||
//
|
||||
/*
|
||||
|
|
@ -121,11 +162,12 @@ class SalesPointsVolumeHelper
|
|||
<th>{{__('tables.commission')}} €</th>
|
||||
<th>{{ __('tables.level') }}</th>
|
||||
*/
|
||||
|
||||
$ret = '<tr>
|
||||
<td><div class="no-line-break">'.$pp.'</div></td>
|
||||
<td><span class="mr-1 ion ion-ios-contact '.($item->active_account ? 'text-primary' : 'text-danger').'"></span>'.$item->first_name.' '.$item->last_name.'
|
||||
</td>
|
||||
<td><div class="no-line-break">'.formatNumber($points, 0).' €</span></td>
|
||||
<td><div class="no-line-break">'.formatNumber($points, 0).'</span></td>
|
||||
<td>'.formatNumber($margin, 1).' %</td>
|
||||
<td><div class="no-line-break">'.formatNumber($commission, 2).' €</span></td>
|
||||
<td><span class="small">'.$item->user_level_name.'</span></td>
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ class CustomerPriority
|
|||
$matches = [];
|
||||
$change = [];
|
||||
$ret = 'update';
|
||||
|
||||
//email geändert
|
||||
|
||||
if(isset($data['billing_email']) && $shopping_user->billing_email != $data['billing_email']){
|
||||
$found = ShoppingUser::where('auth_user_id', '=', NULL)
|
||||
->where('number', '!=', NULL) //has number
|
||||
|
|
@ -205,8 +205,10 @@ class CustomerPriority
|
|||
$shopping_user->member_id = $member_id;
|
||||
$shopping_user->number = self::nextNumber();
|
||||
$shopping_user->save();
|
||||
$shopping_user->shopping_order->member_id = $member_id;
|
||||
$shopping_user->shopping_order->save();
|
||||
if($shopping_user->shopping_order){
|
||||
$shopping_user->shopping_order->member_id = $member_id;
|
||||
$shopping_user->shopping_order->save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -104,23 +104,22 @@ class HTMLHelper
|
|||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAboIntervallWeeks($default = 1){
|
||||
$values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
|
||||
public static function getAboDeliveryOptions($default = 5){
|
||||
$values = \App\Models\UserAbo::$aboDeliveryDays;
|
||||
$ret = "";
|
||||
foreach ($values as $value){
|
||||
$attr = ($value == $default) ? 'selected="selected"' : '';
|
||||
$str = self::getAboWeeksLang($value);
|
||||
$str = self::getAboStrLang($value);
|
||||
$ret .= '<option value="'.$value.'" '.$attr.'>'.$str.'</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getAboWeeksLang($num){
|
||||
if($num == 1){
|
||||
return __('order.every_week');
|
||||
}
|
||||
return __('order.every_weeks', ['num' => $num]);
|
||||
public static function getAboStrLang($num){
|
||||
return $num.'. '.__('abo.of_month');
|
||||
}
|
||||
|
||||
|
||||
public static function getAttributesWithoutParents($id = false, $sameId = false, $all = true){
|
||||
$values = Attribute::where('parent_id', null)->get();
|
||||
$ret = "";
|
||||
|
|
@ -157,14 +156,14 @@ class HTMLHelper
|
|||
if($ids == null){
|
||||
$ids = array();
|
||||
}
|
||||
$values = Product::where('active', 1)->get();
|
||||
$values = Product::all();
|
||||
$ret = "";
|
||||
if($all){
|
||||
$ret .= '<option value="">'.__('none').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
$attr = in_array($value->id, $ids) ? 'selected="selected"' : '';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.'</option>\n';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$value->name.' ('.($value->active ? 'on' : 'off').')</option>\n';
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
|||
180
app/Services/OrderPaymentService.php
Normal file
180
app/Services/OrderPaymentService.php
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\ShoppingInstance;
|
||||
use Yard;
|
||||
|
||||
class OrderPaymentService
|
||||
{
|
||||
|
||||
public static function deleteInstance($identifier){
|
||||
|
||||
Yard::instance('shopping')->deleteStoredCart($identifier);
|
||||
\App\Models\ShoppingInstance::where('identifier', $identifier)->delete();
|
||||
//delete session
|
||||
/* if(\Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6){
|
||||
$user_shop_identifier = \Session::get('user_shop_identifier');
|
||||
Yard::instance('shopping')->deleteStoredCart($identifier);
|
||||
\App\Models\ShoppingInstance::where('identifier', $identifier)->delete();
|
||||
}*/
|
||||
}
|
||||
|
||||
public static function updateInstanceStatus($identifier, $status, $lower = true){
|
||||
if(!ShoppingInstance::where('identifier', $identifier)->exists()){
|
||||
return false;
|
||||
}
|
||||
if($lower){
|
||||
ShoppingInstance::where('identifier', $identifier)->where('status', '<', $status)
|
||||
->update(['status' => $status]);
|
||||
}else{
|
||||
ShoppingInstance::where('identifier', $identifier)
|
||||
->update(['status' => $status]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getInstanceStatus($identifier){
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
if(!$shopping_instance){
|
||||
return false;
|
||||
}
|
||||
return $shopping_instance->getStatus();
|
||||
}
|
||||
|
||||
public static function getTypeBadge(ShoppingInstance $shoppingInstance){
|
||||
$isFor = $shoppingInstance->shopping_data['is_for'] ?? '-';
|
||||
if ($isFor === 'abo-ot-customer' ) {
|
||||
return ' <span class="badge badge-pill badge-warning">'.__('abo.abo').'</span>';
|
||||
}
|
||||
if ($isFor === 'ot-customer' ) {
|
||||
return ' <span class="badge badge-pill badge-secondary">'.__('order.order').'</span>';
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static function getStatusBadge(ShoppingInstance $shoppingInstance){
|
||||
$status = $shoppingInstance->getStatus();
|
||||
$badgeClasses = [
|
||||
'link_sent' => 'success',
|
||||
'link_openly' => 'warning',
|
||||
'link_paid' => 'secondary',
|
||||
'link_check' => 'warning',
|
||||
'link_pending' => 'warning',
|
||||
'link_appointed' => 'secondary',
|
||||
'link_failed' => 'danger',
|
||||
'link_canceled' => 'danger'
|
||||
];
|
||||
|
||||
if (isset($badgeClasses[$status])) {
|
||||
return sprintf(' <span class="badge badge-pill badge-%s">%s</span>',
|
||||
$badgeClasses[$status],
|
||||
__('payment.' . $status)
|
||||
);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function getStatusAlert($status){
|
||||
$badgeClasses = [
|
||||
'link_sent' => 'success',
|
||||
'link_openly' => 'success',
|
||||
'link_check' => 'warning',
|
||||
'link_pending' => 'warning',
|
||||
'link_failed' => 'danger',
|
||||
'link_canceled' => 'danger',
|
||||
'link_appointed' => 'success',
|
||||
'link_paid' => 'success',
|
||||
|
||||
];
|
||||
|
||||
if (isset($badgeClasses[$status])) {
|
||||
return sprintf(' <div class="alert alert-%s">%s</div>',
|
||||
$badgeClasses[$status],
|
||||
__('payment.alert_' . $status)
|
||||
);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function getCustomPayment($identifier){
|
||||
|
||||
$shopping_instance = ShoppingInstance::where('identifier', $identifier)->first();
|
||||
if(!$shopping_instance){
|
||||
abort(403, __('msg.shopping_instance_not_found'));
|
||||
}
|
||||
$shopping_data = $shopping_instance->shopping_data;
|
||||
$shopping_user = $shopping_data['shopping_user_id'] ? ShoppingUser::find($shopping_data['shopping_user_id']) : null;
|
||||
if(!$shopping_user){
|
||||
abort(403, __('msg.shopping_user_not_found'));
|
||||
}
|
||||
$yard_shopping_items = self::getRestoredYardShoppingItems($shopping_instance);
|
||||
|
||||
$data = [
|
||||
'shopping_instance' => $shopping_instance,
|
||||
'shopping_user' => $shopping_user,
|
||||
'yard_shopping_items' => $yard_shopping_items,
|
||||
'identifier' => $identifier,
|
||||
'is_abo' => $shopping_instance->shopping_data['is_abo'] ?? false,
|
||||
'is_for' => $shopping_instance->shopping_data['is_for'] ?? false,
|
||||
'backlink' => false,
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getRestoredYardShoppingItems($shopping_instance){
|
||||
|
||||
Yard::instance('shopping')->destroy();
|
||||
Yard::instance('shopping')->restore($shopping_instance->identifier, [], false);
|
||||
Yard::instance('shopping')->putYardExtra('user_shop_payment', $shopping_instance->payment);
|
||||
|
||||
Yard::instance('shopping')->putYardExtra('shopping_data', $shopping_instance->shopping_data);
|
||||
$is_for = isset($shopping_instance->shopping_data['is_for']) ? $shopping_instance->shopping_data['is_for'] : 'ot-member';
|
||||
Yard::instance('shopping')->setUserPriceInfos($shopping_instance->shopping_data['user_price_infos']);
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($shopping_instance->country_id, $is_for);
|
||||
|
||||
|
||||
$rows = Yard::instance('shopping')->getContentByOrder();
|
||||
$ret = [];
|
||||
$ret['items'] = [];
|
||||
$is_currency = Yard::instance('shopping')->isPriceCurrency();
|
||||
$tax_free = Yard::instance('shopping')->getUserTaxFree();
|
||||
|
||||
foreach($rows as $row){
|
||||
$product = \App\Models\Product::find($row->id);
|
||||
$item = new \stdClass();
|
||||
$item->image = $row->options->has('image') ? $row->options->image : null;
|
||||
$item->price_net = (float) Yard::instance('shopping')->rowPriceNet($row, 3, '.', '');
|
||||
$item->price_net_total = (float) Yard::instance('shopping')->rowSubtotalNet($row, 2, '.', '');
|
||||
$item->price_currency = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('rowPriceNetCurrency', $row, 3)." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price_currency_total = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('rowSubtotalCurrency', $row, 3)." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price = $row->price;
|
||||
$item->price_total = ($row->qty * $row->price);
|
||||
$item->qty = $row->qty;
|
||||
$item->name = $product->name;
|
||||
$item->contents = $product->contents;
|
||||
$item->numbers = $product->numbers;
|
||||
$item->abo_type = AboHelper::getAboShowOn($product);
|
||||
$item->number = $product->number;
|
||||
$item->contents = $product->contents;
|
||||
$ret['items'][] = $item;
|
||||
}
|
||||
|
||||
$ret['tax_free'] = $tax_free;
|
||||
$ret['total']['subtotal'] = Yard::instance('shopping')->subtotal();
|
||||
$ret['total']['subtotal_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('subtotal')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['shippingCountryName'] = Yard::instance('shopping')->getShippingCountryName();
|
||||
$ret['total']['shippingNet'] = Yard::instance('shopping')->shippingNet();
|
||||
$ret['total']['shippingNet currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('shippingNet')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['subtotalWithShipping'] = Yard::instance('shopping')->subtotalWithShipping();
|
||||
$ret['total']['subtotalWithShipping_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('subtotalWithShipping')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['taxWithShipping'] = Yard::instance('shopping')->taxWithShipping();
|
||||
$ret['total']['taxWithShipping_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('taxWithShipping')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['totalWithShipping'] = Yard::instance('shopping')->totalWithShipping();
|
||||
$ret['total']['totalWithShipping_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('totalWithShipping')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ 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;
|
||||
|
|
@ -91,6 +92,7 @@ class Payment
|
|||
}
|
||||
|
||||
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>';
|
||||
}
|
||||
|
|
@ -100,6 +102,14 @@ class Payment
|
|||
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>';
|
||||
}
|
||||
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>';
|
||||
|
|
@ -159,10 +169,10 @@ 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){
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid, $shopping_payment = null){
|
||||
$send_link = false;
|
||||
$shopping_order->setUserHistoryValue(['status' => 8]);
|
||||
Shop::userOrders();
|
||||
ShoppingUserService::snycOrdersByShoppingOrder($shopping_order);
|
||||
$shopping_order->paid = $paid;
|
||||
$shopping_order->save();
|
||||
|
||||
|
|
@ -225,6 +235,7 @@ class Payment
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
if($shopping_order->homeparty){
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
$shopping_order->homeparty->completed = 1;
|
||||
|
|
@ -235,12 +246,24 @@ class Payment
|
|||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
ShopApiOrderCart::finishOrder($shopping_order->shopping_collect_order);
|
||||
}
|
||||
|
||||
//make Invoice and
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if(!$shopping_order->isInvoice()){
|
||||
$invoice_repo->createAndSalesVolume();
|
||||
//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);
|
||||
}
|
||||
|
||||
//make Invoice is not exist and is live
|
||||
if($shopping_order->mode === 'live'){
|
||||
$invoice_repo = new InvoiceRepository($shopping_order);
|
||||
if(!$shopping_order->isInvoice()){
|
||||
$invoice_repo->createAndSalesVolume();
|
||||
}
|
||||
}
|
||||
|
||||
return $send_link;
|
||||
}
|
||||
|
||||
|
|
@ -263,6 +286,7 @@ class Payment
|
|||
if(!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member){
|
||||
$bcc[] = $shopping_order->shopping_user->member->email;
|
||||
}
|
||||
Mail::to($billing_email)->bcc($bcc)->locale($shopping_order->getLocale())->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $data['send_link'], $data['mode']));
|
||||
$data['payment_error'] = isset($data['payment_error']) ? $data['payment_error'] : false;
|
||||
Mail::to($billing_email)->bcc($bcc)->locale($shopping_order->getLocale())->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $data['send_link'], $data['mode'], $data['payment_error']));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class PaymentHelper
|
|||
|
||||
public function setProduct($product){
|
||||
Yard::instance('shopping')->destroy();
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, false, false, ['image' => "", 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission]);
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), 1, $product->price, false, false, ['image' => "", 'slug' => $product->slug, 'weight' => $product->weight, 'points' => $product->points, 'no_commission' => $product->no_commission, 'show_on' => $product->show_on]);
|
||||
}
|
||||
|
||||
public function initELVPayment($user){
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use Yard;
|
||||
use App\User;
|
||||
use App\Models\Country;
|
||||
use App\Models\Product;
|
||||
use App\Models\Setting;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\dbip\MyDBIP;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Services\IPinfo\IPinfo;
|
||||
use App\User;
|
||||
use Yard;
|
||||
|
||||
class Shop
|
||||
{
|
||||
|
|
@ -19,99 +21,73 @@ class Shop
|
|||
public static $shipping_free;
|
||||
public static $user_reverse_charge = false;
|
||||
|
||||
public static function userOrders() {
|
||||
$shopping_users = ShoppingUser::whereHas('shopping_order', function($q) {
|
||||
$q->where('txaction', 'paid')->OrWhere('txaction', 'appointed')->OrWhere('txaction', 'extern')->OrWhere('txaction', 'invoice_open')->OrWhere('txaction', 'invoice_paid');
|
||||
})->where('orders', '=', NULL)->get();
|
||||
foreach ($shopping_users as $shopping_user) {
|
||||
if ($shopping_user->number) {
|
||||
$orders = ShoppingUser::where('number', '=', $shopping_user->number)->max('orders');
|
||||
$orders = $orders + 1;
|
||||
} else {
|
||||
$orders = ShoppingUser::where('billing_email', '=', $shopping_user->billing_email)->max('orders');
|
||||
$orders = $orders + 1;
|
||||
}
|
||||
$shopping_user->orders = $orders;
|
||||
$shopping_user->save();
|
||||
}
|
||||
|
||||
public static function newUserOrder($number)
|
||||
{
|
||||
ShoppingUserService::snycOrdersByNumber($number);
|
||||
}
|
||||
|
||||
public static function newUserOrder($number){
|
||||
if($number > 0){
|
||||
$shopping_users = ShoppingUser::where('number', '=', $number)->get();
|
||||
$orders = 1;
|
||||
foreach ($shopping_users as $shopping_user) {
|
||||
if($shopping_user->shopping_order && ($shopping_user->shopping_order->txaction === 'paid' ||
|
||||
$shopping_user->shopping_order->txaction === 'appointed' ||
|
||||
$shopping_user->shopping_order->txaction === 'extern' ||
|
||||
$shopping_user->shopping_order->txaction === 'extern_paid' )){
|
||||
$shopping_user->orders = $orders++;
|
||||
|
||||
}else{
|
||||
$shopping_user->orders = NULL;
|
||||
}
|
||||
$shopping_user->save();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getShippingCountryCountryId($shipping_country_id){
|
||||
public static function getShippingCountryCountryId($shipping_country_id)
|
||||
{
|
||||
$shippingCountry = ShippingCountry::find($shipping_country_id);
|
||||
if($shippingCountry && $shippingCountry->country){
|
||||
if ($shippingCountry && $shippingCountry->country) {
|
||||
return $shippingCountry->country->id;
|
||||
}
|
||||
return 1; //default DE
|
||||
}
|
||||
|
||||
public static function getCountryShippingCountryId($country_id){
|
||||
public static function getCountryShippingCountryId($country_id)
|
||||
{
|
||||
$shippingCountry = ShippingCountry::whereCountryId($country_id)->first();
|
||||
if($shippingCountry){
|
||||
if ($shippingCountry) {
|
||||
return $shippingCountry->id;
|
||||
}
|
||||
return ShippingCountry::all()->first()->id;
|
||||
}
|
||||
|
||||
|
||||
public static function getLangChange(){
|
||||
public static function getLangChange()
|
||||
{
|
||||
$ret = [];
|
||||
$countries = Country::whereActive(true)->whereSwitch(true)->get();
|
||||
$first_country = null;
|
||||
foreach($countries as $country){
|
||||
$ShippingCountry = ShippingCountry::whereCountryId($country->id)->first();
|
||||
if($ShippingCountry && $ShippingCountry->shipping && $ShippingCountry->shipping->active){
|
||||
if(!$first_country){
|
||||
foreach ($countries as $country) {
|
||||
$ShippingCountry = ShippingCountry::whereCountryId($country->id)->first();
|
||||
if ($ShippingCountry && $ShippingCountry->shipping && $ShippingCountry->shipping->active) {
|
||||
if (!$first_country) {
|
||||
$first_country = $country;
|
||||
}
|
||||
$ret[strtolower($country->code)] = $country;
|
||||
}
|
||||
}
|
||||
$ret[strtolower($country->code)] = $country;
|
||||
}
|
||||
}
|
||||
Shop::getUserShopLang($first_country);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public static function getUserShopLang($country = null){
|
||||
if(\Session::has('user_shop_lang')){
|
||||
if($user_shop_lang = \Session::get('user_shop_lang')){
|
||||
return $user_shop_lang;
|
||||
public static function getUserShopLang($country = null)
|
||||
{
|
||||
if (\Session::has('user_shop_lang')) {
|
||||
if ($user_shop_lang = \Session::get('user_shop_lang')) {
|
||||
return $user_shop_lang;
|
||||
}
|
||||
}
|
||||
if($country){
|
||||
if ($country) {
|
||||
Shop::initUserShopLang($country);
|
||||
return strtolower($country->code);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function initUserShopLang($country){
|
||||
public static function initUserShopLang($country)
|
||||
{
|
||||
Yard::instance('shopping')->destroy();
|
||||
\Session::put('user_shop_lang', strtolower($country->code));
|
||||
//init Yard
|
||||
self::initUserShopYard($country);
|
||||
|
||||
}
|
||||
|
||||
public static function initUserShopYard($country){
|
||||
public static function initUserShopYard($country)
|
||||
{
|
||||
//Lieferadresse im Drittland?
|
||||
self::$user_tax_free = $country->supply_country ? true : false;
|
||||
$ShippingCountry = ShippingCountry::whereCountryId($country->id)->first();
|
||||
|
|
@ -123,8 +99,9 @@ class Shop
|
|||
Yard::instance('shopping')->setUserPriceInfos(Shop::getShopYardInfo());
|
||||
}
|
||||
|
||||
|
||||
public static function getShopYardInfo(){
|
||||
|
||||
public static function getShopYardInfo()
|
||||
{
|
||||
return [
|
||||
'user_tax_free' => self::$user_tax_free,
|
||||
'shipping_free' => self::$shipping_free,
|
||||
|
|
@ -133,107 +110,68 @@ class Shop
|
|||
'shipping_country_id' => self::$shipping_country->id,
|
||||
];
|
||||
}
|
||||
|
||||
public static function getYardShoppingItems(){
|
||||
$rows = Yard::instance('shopping')->getContentByOrder();
|
||||
$ret = [];
|
||||
$ret['items'] = [];
|
||||
$is_currency = Yard::instance('shopping')->isPriceCurrency();
|
||||
$tax_free = Yard::instance('shopping')->getUserTaxFree();
|
||||
|
||||
foreach($rows as $row){
|
||||
$product = \App\Models\Product::find($row->id);
|
||||
$item = new \stdClass();
|
||||
$item->image = $row->options->has('image') ? $row->options->image : null;
|
||||
$item->price_net = (float) Yard::instance('shopping')->rowPriceNet($row, 3, '.', '');
|
||||
$item->price_net_total = (float) Yard::instance('shopping')->rowSubtotalNet($row, 2, '.', '');
|
||||
$item->price_currency = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('rowPriceNetCurrency', $row, 3)." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price_currency_total = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('rowSubtotalCurrency', $row, 3)." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$item->price = $row->price;
|
||||
$item->price_total = ($row->qty * $row->price);
|
||||
$item->qty = $row->qty;
|
||||
$item->name = $product->name;
|
||||
$item->contents = $product->contents;
|
||||
$item->numbers = $product->numbers;
|
||||
$ret['items'][] = $item;
|
||||
}
|
||||
|
||||
$ret['tax_free'] = $tax_free;
|
||||
$ret['total']['subtotal'] = Yard::instance('shopping')->subtotal();
|
||||
$ret['total']['subtotal_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('subtotal')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['shippingCountryName'] = Yard::instance('shopping')->getShippingCountryName();
|
||||
$ret['total']['shippingNet'] = Yard::instance('shopping')->shippingNet();
|
||||
$ret['total']['shippingNet currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('shippingNet')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['subtotalWithShipping'] = Yard::instance('shopping')->subtotalWithShipping();
|
||||
$ret['total']['subtotalWithShipping_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('subtotalWithShipping')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['taxWithShipping'] = Yard::instance('shopping')->taxWithShipping();
|
||||
$ret['total']['taxWithShipping_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('taxWithShipping')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
$ret['total']['totalWithShipping'] = Yard::instance('shopping')->totalWithShipping();
|
||||
$ret['total']['totalWithShipping_currency'] = $is_currency ? "~".Yard::instance('shopping')->getCurrencyByKey('totalWithShipping')." ".Yard::instance('shopping')->getPriceCurrencyUnit() : null;
|
||||
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
public static function checkShoppingUser($id, $user){
|
||||
if($id === null){
|
||||
public static function checkShoppingUser($id, $user)
|
||||
{
|
||||
if ($id === null) {
|
||||
abort(403, 'Error: Keine User ID');
|
||||
}
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->member_id !== $user->id){
|
||||
if ($shopping_user->member_id !== $user->id) {
|
||||
abort(403, 'Error: Falsche User ID');
|
||||
}
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->is_like){
|
||||
if ($shopping_user->is_like) {
|
||||
abort(403, 'Error: Kunde in Prüfung');
|
||||
}
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public static function checkShoppingCountry($for, $id=null){
|
||||
public static function checkShoppingCountry($for, $id = null)
|
||||
{
|
||||
$country_id = null;
|
||||
if($for === 'me' || $for === 'abo-me'){
|
||||
if ($for === 'me' || $for === 'abo-me') {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if($user->account->same_as_billing){
|
||||
if ($user->account->same_as_billing) {
|
||||
$country_id = $user->account->country_id;
|
||||
}else{
|
||||
} else {
|
||||
$country_id = $user->account->shipping_country_id;
|
||||
}
|
||||
}
|
||||
if(strpos($for, 'ot') !== false && $id){
|
||||
if (strpos($for, 'ot') !== false && $id) {
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->same_as_billing){
|
||||
if ($shopping_user->same_as_billing) {
|
||||
$country_id = $shopping_user->billing_country->id;
|
||||
}else{
|
||||
} else {
|
||||
$country_id = $shopping_user->shipping_country->id;
|
||||
}
|
||||
}
|
||||
if($country_id){
|
||||
if($shipping_country = ShippingCountry::whereCountryId($country_id)->first()){
|
||||
if($shipping_country->shipping && $shipping_country->shipping->active){
|
||||
if ($country_id) {
|
||||
if ($shipping_country = ShippingCountry::whereCountryId($country_id)->first()) {
|
||||
if ($shipping_country->shipping && $shipping_country->shipping->active) {
|
||||
return $shipping_country->id;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getDeliveryCountry($for, $id=null){
|
||||
public static function getDeliveryCountry($for, $id = null)
|
||||
{
|
||||
$country_id = null;
|
||||
if($for === 'me' || $for === 'abo-me'){
|
||||
if ($for === 'me' || $for === 'abo-me') {
|
||||
$user = User::find(\Auth::user()->id);
|
||||
if($user->account->same_as_billing){
|
||||
return $user->account->country ? $user->account->country->getLocated() : '';
|
||||
}else{
|
||||
if ($user->account->same_as_billing) {
|
||||
return $user->account->country ? $user->account->country->getLocated() : '';
|
||||
} else {
|
||||
return $user->account->shipping_country ? $user->account->shipping_country->getLocated() : '';
|
||||
}
|
||||
}
|
||||
if(strpos($for, 'ot') !== false && $id){
|
||||
if (strpos($for, 'ot') !== false && $id) {
|
||||
$shopping_user = ShoppingUser::findOrFail($id);
|
||||
if($shopping_user->same_as_billing){
|
||||
if ($shopping_user->same_as_billing) {
|
||||
return $shopping_user->billing_country ? $shopping_user->billing_country->getLocated() : '';
|
||||
}else{
|
||||
} else {
|
||||
return $shopping_user->shipping_country ? $shopping_user->shipping_country->getLocated() : '';
|
||||
}
|
||||
}
|
||||
|
|
@ -241,16 +179,17 @@ class Shop
|
|||
}
|
||||
|
||||
|
||||
public static function getShippingPriceByShippingCountryId($shipping_country_id, $shipping_weight){
|
||||
public static function getShippingPriceByShippingCountryId($shipping_country_id, $shipping_weight)
|
||||
{
|
||||
$shippingCountry = ShippingCountry::find($shipping_country_id);
|
||||
if(!$shippingCountry){
|
||||
if (!$shippingCountry) {
|
||||
abort(403, 'Fehler: Versandland nicht gefunden');
|
||||
}
|
||||
if(!isset($shippingCountry->shipping) && count($shippingCountry->shipping->shipping_prices) === 0){
|
||||
if (!isset($shippingCountry->shipping) && count($shippingCountry->shipping->shipping_prices) === 0) {
|
||||
abort(403, 'Fehler: Kein Preise für das Versandland angelegt');
|
||||
}
|
||||
$shipping_price = $shippingCountry->shipping->shipping_prices->first();
|
||||
if(!$shipping_price){
|
||||
if (!$shipping_price) {
|
||||
abort(403, 'Fehler: Preis vom Versandland nicht gefunden');
|
||||
}
|
||||
|
||||
|
|
@ -258,13 +197,13 @@ class Shop
|
|||
abort(403, 'Fehler: Kein Versandgewicht');
|
||||
}*/
|
||||
|
||||
if($shipping_weight == 0){
|
||||
if ($shipping_weight == 0) {
|
||||
$shipping_price->price = 0;
|
||||
$shipping_price->price_comp = 0;
|
||||
return $shipping_price;
|
||||
}
|
||||
|
||||
if($shipping_weight > 0){
|
||||
if ($shipping_weight > 0) {
|
||||
/*
|
||||
if($this->shipping_free && $this->total(2, '.', '') >= $this->shipping_free){
|
||||
if($this->weightByFreeShipping() == 0){
|
||||
|
|
@ -293,13 +232,13 @@ class Shop
|
|||
//default
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
public static function shippingPriceByWeight($shipping_prices, $shipping_weight){
|
||||
foreach ($shipping_prices as $price){
|
||||
if($price->weight_from > 0 && $price->weight_to > 0){
|
||||
if($shipping_weight >= $price->weight_from && $shipping_weight <= $price->weight_to){
|
||||
public static function shippingPriceByWeight($shipping_prices, $shipping_weight)
|
||||
{
|
||||
foreach ($shipping_prices as $price) {
|
||||
if ($price->weight_from > 0 && $price->weight_to > 0) {
|
||||
if ($shipping_weight >= $price->weight_from && $shipping_weight <= $price->weight_to) {
|
||||
return $price;
|
||||
}
|
||||
}
|
||||
|
|
@ -307,25 +246,56 @@ class Shop
|
|||
abort(403, 'Fehler: Preis nach Gewicht im Versandland nicht gefunden');
|
||||
}
|
||||
|
||||
public static function isCompProducts($for){
|
||||
/*
|
||||
public static function isCompProducts($for)
|
||||
{
|
||||
/*
|
||||
$for = me, ot-member, ot-customer, abo-ot-member, abo-ot-customer, abo-me
|
||||
*/
|
||||
if($for === 'me'){
|
||||
if ($for === 'me') {
|
||||
return (bool) Setting::getContentBySlug('is_comp_me_order');
|
||||
}
|
||||
if($for === 'abo-me'){
|
||||
if ($for === 'abo-me') {
|
||||
return (bool) Setting::getContentBySlug('is_comp_me_abo');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getIPDatabaseInfo(){
|
||||
public static function getCompProducts($for)
|
||||
{
|
||||
if (Shop::isCompProducts($for)) {
|
||||
$show_on = '0';
|
||||
switch ($for) {
|
||||
case 'me':
|
||||
$show_on = '2';
|
||||
break;
|
||||
case 'abo-me':
|
||||
$show_on = '12';
|
||||
break;
|
||||
case 'ot-member':
|
||||
$show_on = '3';
|
||||
break;
|
||||
case 'ot-customer':
|
||||
$show_on = '3';
|
||||
break;
|
||||
case 'abo-ot-member':
|
||||
$show_on = '13';
|
||||
break;
|
||||
case 'abo-ot-customer':
|
||||
$show_on = '13';
|
||||
break;
|
||||
}
|
||||
return Product::whereActive(true)->where('shipping_addon', true)->whereJsonContains('show_on', $show_on)->orderBy('pos', 'DESC')->get();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public static function getIPDatabaseInfo()
|
||||
{
|
||||
|
||||
//first check the DBs for the IP
|
||||
|
||||
|
||||
/* testing
|
||||
/* testing
|
||||
|
||||
foreach(self::testIps() as $ip_address){
|
||||
$country = MyDBIP::lookup($ip_address);
|
||||
|
|
@ -355,12 +325,12 @@ class Shop
|
|||
dd("done");
|
||||
*/
|
||||
|
||||
/* live */
|
||||
/* live */
|
||||
|
||||
$ip_address = \Request::ip();
|
||||
// $ip_address = '86.189.47.78'; //testing
|
||||
// $ip_address = '86.189.47.78'; //testing
|
||||
$country = MyDBIP::lookup($ip_address);
|
||||
if($country !== false){
|
||||
if ($country !== false) {
|
||||
return strtolower($country);
|
||||
}
|
||||
//not found search in IPinfo
|
||||
|
|
@ -368,10 +338,10 @@ class Shop
|
|||
$client = new IPinfo($access_token);
|
||||
|
||||
$details = $client->getDetails($ip_address);
|
||||
if(isset($details->error) && $details->error !== null){
|
||||
if (isset($details->error) && $details->error !== null) {
|
||||
return 'error';
|
||||
}
|
||||
if(isset($details->country) && $details->country !== null){
|
||||
if (isset($details->country) && $details->country !== null) {
|
||||
MyDBIP::insert($ip_address, $details->country);
|
||||
return strtolower($details->country);
|
||||
}
|
||||
|
|
@ -379,82 +349,83 @@ class Shop
|
|||
}
|
||||
|
||||
|
||||
private static function testIps(){
|
||||
private static function testIps()
|
||||
{
|
||||
return [
|
||||
'58.217.40.197'
|
||||
,'207.117.144.54'
|
||||
,'65.169.228.128'
|
||||
,'6.84.3.236'
|
||||
,'214.56.36.93'
|
||||
,'9.43.145.245'
|
||||
,'231.199.26.76'
|
||||
,'86.189.47.78'
|
||||
,'3.122.58.75'
|
||||
,'251.133.143.149'
|
||||
,'6.142.181.83'
|
||||
,'2.55.191.86'
|
||||
,'90.189.58.233'
|
||||
,'57.3.139.111'
|
||||
,'41.130.99.194'
|
||||
,'1.59.123.14'
|
||||
,'9.119.131.109'
|
||||
,'54.240.231.9'
|
||||
,'117.19.131.144'
|
||||
,'221.217.39.211'
|
||||
,'7.43.125.76'
|
||||
,'224.86.233.79'
|
||||
,'32.151.38.98'
|
||||
,'4.134.40.92'
|
||||
,'4.70.188.58'
|
||||
,'24.7.152.228'
|
||||
,'58.122.179.1'
|
||||
,'5.123.9.44'
|
||||
,'3.175.206.5'
|
||||
,'8.142.119.47'
|
||||
,'40.248.58.203'
|
||||
,'7.84.254.187'
|
||||
,'215.215.239.71'
|
||||
,'124.40.66.196'
|
||||
,'215.87.143.102'
|
||||
,'143.39.97.13'
|
||||
,'202.56.79.198'
|
||||
,'143.60.125.142'
|
||||
,'73.233.153.126'
|
||||
,'121.144.28.245'
|
||||
,'53.232.193.122'
|
||||
,'104.222.102.209'
|
||||
,'216.55.215.13'
|
||||
,'84.106.145.239'
|
||||
,'200.131.52.20'
|
||||
,'132.252.158.0'
|
||||
,'220.11.129.27'
|
||||
,'8.153.0.186'
|
||||
,'119.206.117.107'
|
||||
,'222.93.42.133'
|
||||
,'105.104.224.98'
|
||||
,'252.156.181.78'
|
||||
,'7.139.235.187'
|
||||
,'111.140.127.91'
|
||||
,'1.186.17.84'
|
||||
,'85.59.39.221'
|
||||
,'231.152.252.43'
|
||||
,'125.214.216.123'
|
||||
,'69.31.65.238'
|
||||
,'126.12.105.55'
|
||||
,'211.39.4.118'
|
||||
,'73.102.88.79'
|
||||
,'210.229.38.137'
|
||||
,'5.3.230.214'
|
||||
,'208.92.91.242'
|
||||
,'4.105.177.199'
|
||||
,'38.10.48.92'
|
||||
,'133.33.44.13'
|
||||
,'202.189.24.255'
|
||||
,'5.101.244.234'
|
||||
,'2.52.110.194'
|
||||
,'1.130.73.146'
|
||||
,'84.237.232.120'
|
||||
,'25.163.83.194'
|
||||
'58.217.40.197',
|
||||
'207.117.144.54',
|
||||
'65.169.228.128',
|
||||
'6.84.3.236',
|
||||
'214.56.36.93',
|
||||
'9.43.145.245',
|
||||
'231.199.26.76',
|
||||
'86.189.47.78',
|
||||
'3.122.58.75',
|
||||
'251.133.143.149',
|
||||
'6.142.181.83',
|
||||
'2.55.191.86',
|
||||
'90.189.58.233',
|
||||
'57.3.139.111',
|
||||
'41.130.99.194',
|
||||
'1.59.123.14',
|
||||
'9.119.131.109',
|
||||
'54.240.231.9',
|
||||
'117.19.131.144',
|
||||
'221.217.39.211',
|
||||
'7.43.125.76',
|
||||
'224.86.233.79',
|
||||
'32.151.38.98',
|
||||
'4.134.40.92',
|
||||
'4.70.188.58',
|
||||
'24.7.152.228',
|
||||
'58.122.179.1',
|
||||
'5.123.9.44',
|
||||
'3.175.206.5',
|
||||
'8.142.119.47',
|
||||
'40.248.58.203',
|
||||
'7.84.254.187',
|
||||
'215.215.239.71',
|
||||
'124.40.66.196',
|
||||
'215.87.143.102',
|
||||
'143.39.97.13',
|
||||
'202.56.79.198',
|
||||
'143.60.125.142',
|
||||
'73.233.153.126',
|
||||
'121.144.28.245',
|
||||
'53.232.193.122',
|
||||
'104.222.102.209',
|
||||
'216.55.215.13',
|
||||
'84.106.145.239',
|
||||
'200.131.52.20',
|
||||
'132.252.158.0',
|
||||
'220.11.129.27',
|
||||
'8.153.0.186',
|
||||
'119.206.117.107',
|
||||
'222.93.42.133',
|
||||
'105.104.224.98',
|
||||
'252.156.181.78',
|
||||
'7.139.235.187',
|
||||
'111.140.127.91',
|
||||
'1.186.17.84',
|
||||
'85.59.39.221',
|
||||
'231.152.252.43',
|
||||
'125.214.216.123',
|
||||
'69.31.65.238',
|
||||
'126.12.105.55',
|
||||
'211.39.4.118',
|
||||
'73.102.88.79',
|
||||
'210.229.38.137',
|
||||
'5.3.230.214',
|
||||
'208.92.91.242',
|
||||
'4.105.177.199',
|
||||
'38.10.48.92',
|
||||
'133.33.44.13',
|
||||
'202.189.24.255',
|
||||
'5.101.244.234',
|
||||
'2.52.110.194',
|
||||
'1.130.73.146',
|
||||
'84.237.232.120',
|
||||
'25.163.83.194'
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
198
app/Services/ShoppingUserService.php
Normal file
198
app/Services/ShoppingUserService.php
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\User;
|
||||
use Yard;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class ShoppingUserService
|
||||
{
|
||||
|
||||
/**
|
||||
* Gibt alle Bestellungen eines Mitglieds zurück
|
||||
*
|
||||
* @param ShoppingUser $shopping_user Das Mitglied, dessen Bestellungen zurückgegeben werden sollen
|
||||
* @return Collection Die Bestellungen des Mitglieds
|
||||
*/
|
||||
public static function getAllOrdersByMember($shopping_user){
|
||||
$users = ShoppingUser::where('billing_email', '=', $shopping_user->billing_email)->where('member_id', '=', $shopping_user->member_id)->get();
|
||||
return $users->flatMap(function($user) {
|
||||
return $user->shopping_orders;
|
||||
})->sortByDesc('created_at');
|
||||
}
|
||||
|
||||
public static function syncOrdersByEmail($user)
|
||||
{
|
||||
$maxAttempts = 3;
|
||||
$attempt = 1;
|
||||
|
||||
while ($attempt <= $maxAttempts) {
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$shopping_user = ShoppingUser::where('member_id', $user->id)
|
||||
->first();
|
||||
|
||||
if (!$shopping_user) {
|
||||
DB::commit();
|
||||
return;
|
||||
}
|
||||
|
||||
$shopping_users = ShoppingUser::where('billing_email', '=', $shopping_user->billing_email)
|
||||
->whereHas('shopping_order', function($q) {
|
||||
$q->where('txaction', 'paid')
|
||||
->orWhere('txaction', 'appointed')
|
||||
->orWhere('txaction', 'extern')
|
||||
->orWhere('txaction', 'invoice_open')
|
||||
->orWhere('txaction', 'invoice_paid');
|
||||
})
|
||||
->lockForUpdate()
|
||||
->get();
|
||||
|
||||
$order_count = $shopping_users->count();
|
||||
|
||||
foreach($shopping_users as $user) {
|
||||
$user->orders = $order_count;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
DB::commit();
|
||||
return; // Erfolgreicher Fall
|
||||
|
||||
} catch (QueryException $e) {
|
||||
DB::rollBack();
|
||||
|
||||
// Wenn es ein Deadlock ist, versuchen wir es erneut
|
||||
if ($e->getCode() == 40001 && $attempt < $maxAttempts) {
|
||||
$sleepTime = pow(2, $attempt) * 100000; // Exponentielles Backoff in Mikrosekunden
|
||||
usleep($sleepTime);
|
||||
$attempt++;
|
||||
continue;
|
||||
}
|
||||
|
||||
throw $e; // Andere Fehler oder zu viele Versuche
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*public static function syncOrdersByEmail($user){
|
||||
ShoppingUser::where('member_id', $user->id)
|
||||
->whereNotNull('billing_email')
|
||||
->where('billing_email', '!=', '')
|
||||
->select('billing_email')
|
||||
->groupBy('billing_email')
|
||||
->get()
|
||||
->each(function($shopping_user) {
|
||||
self::snycOrdersByShoppingUser($shopping_user);
|
||||
});
|
||||
}*/
|
||||
/**
|
||||
* Synchronisiert die Bestellungen eines ShoppingOrders mit den Bestellungen des zugehörigen ShoppingUsers
|
||||
*
|
||||
* @param ShoppingOrder $shopping_order Der zu synchronisierende ShoppingOrder
|
||||
*/
|
||||
public static function snycOrdersByShoppingOrder(ShoppingOrder $shopping_order) {
|
||||
$shopping_user = $shopping_order->shopping_user ? $shopping_order->shopping_user : null;
|
||||
if($shopping_user){
|
||||
self::snycOrdersByShoppingUser($shopping_user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronisiert die Bestellungen eines ShoppingUsers mit den Bestellungen des zugehörigen Benutzers
|
||||
*
|
||||
* @param ShoppingUser $shopping_user Der zu synchronisierende ShoppingUser
|
||||
*/
|
||||
public static function snycOrdersByShoppingUser(ShoppingUser $shopping_user) {
|
||||
|
||||
// Aktualisiere alle Benutzer mit einer einzigen Datenbankabfrage
|
||||
ShoppingUser::where('billing_email', $shopping_user->billing_email)
|
||||
->update([
|
||||
'orders' => ShoppingUser::where('billing_email', $shopping_user->billing_email)
|
||||
->whereHas('shopping_order', function($q) {
|
||||
$q->whereIn('txaction', ['paid', 'appointed', 'extern', 'invoice_open', 'invoice_paid']);
|
||||
})
|
||||
->count()
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public static function snycOrdersByNumber($number){
|
||||
if($number <= 0) {
|
||||
return;
|
||||
}
|
||||
// Aktualisiere alle Benutzer mit einer einzigen Datenbankabfrage
|
||||
|
||||
ShoppingUser::where('number', '=', $number)
|
||||
->update([
|
||||
'orders' => ShoppingUser::where('number', '=', $number)
|
||||
->whereHas('shopping_order', function($q) {
|
||||
$q->whereIn('txaction', ['paid', 'appointed', 'extern', 'invoice_open', 'invoice_paid']);
|
||||
})
|
||||
->count()
|
||||
]);
|
||||
// Setze orders auf NULL für alle anderen
|
||||
ShoppingUser::where('number', '=', $number)
|
||||
->whereDoesntHave('shopping_order', function($q) {
|
||||
$q->whereIn('txaction', ['paid', 'appointed', 'extern', 'extern_paid']);
|
||||
})
|
||||
->update(['orders' => null]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronisiert die Nummern aller ShoppingUser eines Benutzers anhand der E-Mails
|
||||
*
|
||||
* @param User $user Der Benutzer, dessen ShoppingUser synchronisiert werden sollen
|
||||
*/
|
||||
public static function syncNumbersByEmail($user) {
|
||||
// Hole alle ShoppingUser mit E-Mail gruppiert
|
||||
$emailGroups = ShoppingUser::where('member_id', $user->id)
|
||||
->whereNotNull('billing_email')
|
||||
->where('billing_email', '!=', '')
|
||||
->get()
|
||||
->groupBy('billing_email');
|
||||
|
||||
foreach($emailGroups as $email => $users) {
|
||||
// Suche ob es bereits eine Nummer für diese E-Mail gibt
|
||||
$existingNumber = ($users->whereNotNull('number')->first()) ? $users->whereNotNull('number')->first()->number : null;
|
||||
|
||||
if($existingNumber) {
|
||||
// Wenn eine Nummer existiert, nutze diese für alle User mit der E-Mail
|
||||
ShoppingUser::where('member_id', $user->id)
|
||||
->where('billing_email', $email)
|
||||
->whereNull('number')
|
||||
->update(['number' => $existingNumber]);
|
||||
} else {
|
||||
// Wenn keine Nummer existiert, generiere eine neue
|
||||
$maxNumber = ShoppingUser::max('number') ?: 1000;
|
||||
$newNumber = $maxNumber + 1;
|
||||
|
||||
ShoppingUser::where('member_id', $user->id)
|
||||
->where('billing_email', $email)
|
||||
->update(['number' => $newNumber]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt alle Faker-E-Mails für einen Benutzer auf 1
|
||||
*
|
||||
* @param User $user Der Benutzer, dessen Faker-E-Mails gesetzt werden sollen
|
||||
*/
|
||||
public static function setFakerMail($user){
|
||||
// Aktualisiere alle Faker-E-Mails für den Benutzer in einem einzigen Update
|
||||
// Schneller da nur ein einzelner SQL Query ausgeführt wird
|
||||
ShoppingUser::where('member_id', $user->id)
|
||||
->where('faker_mail', '!=', 1)
|
||||
->where('billing_email', 'LIKE', '%faker@mivita.care')
|
||||
->update(['faker_mail' => 1]);
|
||||
|
||||
// Setze alle anderen auf NULL zurück
|
||||
ShoppingUser::where('member_id', $user->id)
|
||||
->where('billing_email', 'NOT LIKE', '%faker@mivita.care')
|
||||
->update(['faker_mail' => null]);
|
||||
}
|
||||
}
|
||||
|
|
@ -43,9 +43,7 @@ class Slim {
|
|||
if (empty($value)) {return null;}
|
||||
|
||||
// If magic quotes enabled
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$value = stripslashes($value);
|
||||
}
|
||||
// Magic quotes were removed in PHP 5.4, no need to check in PHP 8.2
|
||||
|
||||
// The data is posted as a JSON String so to be used it needs to be deserialized first
|
||||
$data = json_decode($value);
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use Request;
|
|||
use App\Services\Shop;
|
||||
use App\Models\UserShop;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\ShoppingUserService;
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ class ShoppingOrders
|
|||
}
|
||||
|
||||
if($data['action'] === 'next_run'){
|
||||
Shop::userOrders();
|
||||
ShoppingUserService::snycOrdersByShoppingUser($shopping_user);
|
||||
\Session()->flash('alert-save', true);
|
||||
}
|
||||
return back();
|
||||
|
|
|
|||
|
|
@ -85,7 +85,15 @@ class Util
|
|||
return number_format($value, $dec, self::_decimal_separator(), self::_thousands_separator());
|
||||
|
||||
}
|
||||
|
||||
public static function cleanIntegerFromString($value) {
|
||||
// Entferne alle nicht-numerischen Zeichen außer Minus
|
||||
$cleanStr = preg_replace("/[^0-9-]/", "", $value);
|
||||
|
||||
// Konvertiere zu Integer und entferne führende Nullen
|
||||
$number = (int)$cleanStr;
|
||||
|
||||
return $number;
|
||||
}
|
||||
public static function cleanNumberFormat($num = 0, $dec = 2, $fullzero = false){
|
||||
|
||||
if($fullzero && $num == 0){
|
||||
|
|
@ -140,6 +148,35 @@ class Util
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getInstanceStatus(){
|
||||
$identifier = self::getUserShopIdentifier();
|
||||
if($identifier && \Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6){
|
||||
return OrderPaymentService::getInstanceStatus($identifier);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function setInstanceStatus($status, $lower = true){
|
||||
$identifier = self::getUserShopIdentifier();
|
||||
if($identifier && \Session::has('user_shop_payment') && \Session::get('user_shop_payment') === 6){
|
||||
OrderPaymentService::updateInstanceStatus($identifier, $status, $lower);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setInstanceStatusByPayment($shopping_payment, $status, $lower = true){
|
||||
if($shopping_payment->identifier){
|
||||
OrderPaymentService::updateInstanceStatus($shopping_payment->identifier, $status, $lower);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getShoppingInstance(){
|
||||
if(\Session::has('shopping_instance')){
|
||||
return \Session::get('shopping_instance');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function getUserHistory(){
|
||||
$auth_user = self::getAuthUser();
|
||||
$user_shop_identifier = self::getUserShopIdentifier();
|
||||
|
|
@ -171,7 +208,7 @@ class Util
|
|||
return 'test';
|
||||
}
|
||||
}
|
||||
return 'live';
|
||||
return config('app.mode');
|
||||
}
|
||||
public static function addRoute($p = []){
|
||||
$b = [];
|
||||
|
|
|
|||
219
app/User.php
219
app/User.php
|
|
@ -136,12 +136,15 @@ class User extends Authenticatable
|
|||
*/
|
||||
|
||||
protected $fillable = [
|
||||
'email', 'password', 'token',
|
||||
'email',
|
||||
'password',
|
||||
'token',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'settings' => 'array',
|
||||
'payment_methods' => 'array'
|
||||
'payment_methods' => 'array',
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -150,41 +153,51 @@ class User extends Authenticatable
|
|||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token', 'token',
|
||||
'password',
|
||||
'remember_token',
|
||||
'token',
|
||||
];
|
||||
|
||||
private $userSalesVolume = false;
|
||||
|
||||
public function account(){
|
||||
public function account()
|
||||
{
|
||||
return $this->belongsTo('App\Models\UserAccount', 'account_id');
|
||||
}
|
||||
|
||||
public function user_level(){
|
||||
public function user_level()
|
||||
{
|
||||
return $this->belongsTo('App\Models\UserLevel', 'm_level');
|
||||
}
|
||||
|
||||
public function user_sponsor(){
|
||||
public function user_sponsor()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'm_sponsor');
|
||||
}
|
||||
|
||||
public function user_pre_sponsor(){
|
||||
public function user_pre_sponsor()
|
||||
{
|
||||
return $this->belongsTo('App\User', 'pre_sponsor');
|
||||
}
|
||||
|
||||
public function payment_order_product(){
|
||||
public function payment_order_product()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Product', 'payment_order_id');
|
||||
}
|
||||
|
||||
public function files(){
|
||||
public function files()
|
||||
{
|
||||
return $this->hasMany('App\Models\File', 'user_id', '');
|
||||
}
|
||||
|
||||
|
||||
public function shopping_orders(){
|
||||
public function shopping_orders()
|
||||
{
|
||||
return $this->hasMany('App\Models\ShoppingOrder', 'auth_user_id', '');
|
||||
}
|
||||
|
||||
public function user_histories(){
|
||||
public function user_histories()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserHistory', 'user_id', '');
|
||||
}
|
||||
|
||||
|
|
@ -208,33 +221,35 @@ class User extends Authenticatable
|
|||
return $this->hasMany('App\Models\ShoppingUser', 'member_id', 'id');
|
||||
}
|
||||
|
||||
public function getLocale(){
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->lang ? $this->lang : \App::getLocale();
|
||||
}
|
||||
|
||||
|
||||
public function getMUserSponsor(){
|
||||
if($this->user_sponsor && $this->user_sponsor->account){
|
||||
return $this->user_sponsor->account->first_name." ".$this->user_sponsor->account->last_name." | ".$this->user_sponsor->email;
|
||||
|
||||
public function getMUserSponsor()
|
||||
{
|
||||
if ($this->user_sponsor && $this->user_sponsor->account) {
|
||||
return $this->user_sponsor->account->first_name . " " . $this->user_sponsor->account->last_name . " | " . $this->user_sponsor->email;
|
||||
}
|
||||
}
|
||||
public function getFullName($email=true){
|
||||
public function getFullName($email = true)
|
||||
{
|
||||
$ret = "";
|
||||
if($this->account){
|
||||
$ret = $this->account->first_name." ".$this->account->last_name;
|
||||
|
||||
if ($this->account) {
|
||||
$ret = $this->account->first_name . " " . $this->account->last_name;
|
||||
}
|
||||
if($email && $this->id > 1){
|
||||
$ret .= " | ".$this->email;
|
||||
if ($email && $this->id > 1) {
|
||||
$ret .= " | " . $this->email;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPasswort(){
|
||||
if($this->password == env('APP_KEY')){
|
||||
public function isPasswort()
|
||||
{
|
||||
if ($this->password == env('APP_KEY')) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -246,7 +261,7 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function isVIP()
|
||||
{
|
||||
if($this->admin >= 1){
|
||||
if ($this->admin >= 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -258,7 +273,7 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function isAdmin()
|
||||
{
|
||||
if($this->admin >= 2){
|
||||
if ($this->admin >= 2) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -269,7 +284,7 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function isSuperAdmin()
|
||||
{
|
||||
if($this->admin >= 3){
|
||||
if ($this->admin >= 3) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -280,7 +295,7 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function isSySAdmin()
|
||||
{
|
||||
if($this->admin >= 4){
|
||||
if ($this->admin >= 4) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -289,7 +304,7 @@ class User extends Authenticatable
|
|||
|
||||
public function isUserHasApi()
|
||||
{
|
||||
if($this->id === 3){
|
||||
if ($this->id === 3) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -300,7 +315,7 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function isApiUser()
|
||||
{
|
||||
if($this->admin >= 5){
|
||||
if ($this->admin >= 5) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -320,68 +335,81 @@ class User extends Authenticatable
|
|||
*/
|
||||
public function showSideNav()
|
||||
{
|
||||
if($this->active == 1 && $this->blocked == 0 && $this->wizard >= 10){
|
||||
if ($this->active == 1 && $this->blocked == 0 && $this->wizard >= 10) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isAboOption(){
|
||||
return false;
|
||||
public function isAboOption()
|
||||
{
|
||||
return false;
|
||||
// Abo Option deaktiviert ($this->abo_options && $this->account && $this->account->payment_data) ? true : false;
|
||||
}
|
||||
|
||||
public function isActive(){
|
||||
public function isActive()
|
||||
{
|
||||
return ($this->active == 1 && $this->blocked == 0) ? true : false;
|
||||
}
|
||||
public function isActiveAccount(){
|
||||
public function isActiveAccount()
|
||||
{
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->gt(Carbon::now()) : false;
|
||||
}
|
||||
|
||||
public function isActiveShop(){
|
||||
public function isActiveShop()
|
||||
{
|
||||
return $this->payment_shop ? Carbon::parse($this->payment_shop)->gt(Carbon::now()) : false;
|
||||
}
|
||||
|
||||
public function isRenewalAccount(){
|
||||
public function isRenewalAccount()
|
||||
{
|
||||
if ($this->payment_account) {
|
||||
return Carbon::parse($this->payment_account)->modify('-'.(config('mivita.renewal_days')+1).' days')->lt(Carbon::now());
|
||||
return Carbon::parse($this->payment_account)->modify('-' . (config('mivita.renewal_days') + 1) . ' days')->lt(Carbon::now());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function nextRenewalAccount(){
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-'.config('mivita.renewal_days').' days')->format(\Util::formatDateTimeDB()) : false ;
|
||||
public function nextRenewalAccount()
|
||||
{
|
||||
return $this->payment_account ? Carbon::parse($this->payment_account)->modify('-' . config('mivita.renewal_days') . ' days')->format(\Util::formatDateTimeDB()) : false;
|
||||
}
|
||||
|
||||
public function daysActiveAccount(){
|
||||
public function daysActiveAccount()
|
||||
{
|
||||
return Carbon::now()->diffInDays(Carbon::parse($this->payment_account), false);
|
||||
}
|
||||
|
||||
public function modifyActiveAccount($add = "1 year"){
|
||||
public function modifyActiveAccount($add = "1 year")
|
||||
{
|
||||
return Carbon::parse($this->payment_account)->modify($add)->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function daysHumansActiveAccount(){
|
||||
public function daysHumansActiveAccount()
|
||||
{
|
||||
return Carbon::now()->diffForHumans(Carbon::parse($this->payment_account));
|
||||
}
|
||||
|
||||
public function daysActiveShop(){
|
||||
public function daysActiveShop()
|
||||
{
|
||||
return Carbon::now()->diffInDays(Carbon::parse($this->payment_shop), false);
|
||||
}
|
||||
|
||||
public function modifyActiveShop($add = "1 year"){
|
||||
public function modifyActiveShop($add = "1 year")
|
||||
{
|
||||
return Carbon::parse($this->payment_shop)->modify($add)->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function daysHumansActiveShop(){
|
||||
public function daysHumansActiveShop()
|
||||
{
|
||||
return Carbon::now()->diffForHumans(Carbon::parse($this->payment_shop));
|
||||
}
|
||||
|
||||
public function isAcountAboPayDate(){
|
||||
if($this->isAboOption()){
|
||||
$pay_days = Carbon::parse($this->payment_account)->modify('- '.config('mivita.abo_booking_days').' days');
|
||||
public function isAcountAboPayDate()
|
||||
{
|
||||
if ($this->isAboOption()) {
|
||||
$pay_days = Carbon::parse($this->payment_account)->modify('- ' . config('mivita.abo_booking_days') . ' days');
|
||||
$diff_days = Carbon::now()->diffInDays($pay_days, false);
|
||||
if($diff_days <= 0){
|
||||
if ($diff_days <= 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -391,54 +419,76 @@ class User extends Authenticatable
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getConfirmationDateFormat(){
|
||||
if(!$this->attributes['confirmation_date']){ return ""; }
|
||||
public function getConfirmationDateFormat()
|
||||
{
|
||||
if (!$this->attributes['confirmation_date']) {
|
||||
return "";
|
||||
}
|
||||
return Carbon::parse($this->attributes['confirmation_date'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getActiveDateFormat(){
|
||||
if(!$this->attributes['active_date']){ return ""; }
|
||||
public function getActiveDateFormat($time = true)
|
||||
{
|
||||
if (!$this->attributes['active_date']) {
|
||||
return "";
|
||||
}
|
||||
if (!$time) {
|
||||
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateDB());
|
||||
}
|
||||
return Carbon::parse($this->attributes['active_date'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAgreementFormat(){
|
||||
if(!$this->attributes['agreement']){ return ""; }
|
||||
public function getAgreementFormat()
|
||||
{
|
||||
if (!$this->attributes['agreement']) {
|
||||
return "";
|
||||
}
|
||||
return Carbon::parse($this->attributes['agreement'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function getPaymentAccountDateFormat($time = true){
|
||||
if(!$this->attributes['payment_account']){ return ""; }
|
||||
if(!$time){
|
||||
public function getPaymentAccountDateFormat($time = true)
|
||||
{
|
||||
if (!$this->attributes['payment_account']) {
|
||||
return "";
|
||||
}
|
||||
if (!$time) {
|
||||
return Carbon::parse($this->attributes['payment_account'])->format(\Util::formatDateDB());
|
||||
}
|
||||
return Carbon::parse($this->attributes['payment_account'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function getPaymentShopDateFormat($time = true){
|
||||
if(!$this->attributes['payment_shop']){ return ""; }
|
||||
if(!$time){
|
||||
public function getPaymentShopDateFormat($time = true)
|
||||
{
|
||||
if (!$this->attributes['payment_shop']) {
|
||||
return "";
|
||||
}
|
||||
if (!$time) {
|
||||
return Carbon::parse($this->attributes['payment_shop'])->format(\Util::formatDateDB());
|
||||
}
|
||||
return Carbon::parse($this->attributes['payment_shop'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
public function getReleaseAccountFormat($time = true){
|
||||
if(!$this->attributes['release_account']){ return ""; }
|
||||
if(!$time){
|
||||
public function getReleaseAccountFormat($time = true)
|
||||
{
|
||||
if (!$this->attributes['release_account']) {
|
||||
return "";
|
||||
}
|
||||
if (!$time) {
|
||||
return Carbon::parse($this->attributes['release_account'])->format(\Util::formatDateDB());
|
||||
}
|
||||
return Carbon::parse($this->attributes['release_account'])->format(\Util::formatDateTimeDB());
|
||||
}
|
||||
|
||||
|
||||
public function setSetting(array $revisions, bool $save = true){
|
||||
if(!$this->settings){
|
||||
public function setSetting(array $revisions, bool $save = true)
|
||||
{
|
||||
if (!$this->settings) {
|
||||
$this->settings = [];
|
||||
}
|
||||
$this->settings = array_merge($this->settings, $revisions);
|
||||
|
|
@ -448,16 +498,18 @@ class User extends Authenticatable
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getSetting($key, $default = null){
|
||||
public function getSetting($key, $default = null)
|
||||
{
|
||||
return isset($this->settings[$key]) ? $this->settings[$key] : $default;
|
||||
}
|
||||
|
||||
public function getPaymentMethodsShort(){
|
||||
public function getPaymentMethodsShort()
|
||||
{
|
||||
$ret = "";
|
||||
if($this->payment_methods !== null){
|
||||
foreach ($this->payment_methods as $payment_method){
|
||||
if($find = PaymentMethod::find($payment_method)){
|
||||
$ret .= $find->short." | ";
|
||||
if ($this->payment_methods !== null) {
|
||||
foreach ($this->payment_methods as $payment_method) {
|
||||
if ($find = PaymentMethod::find($payment_method)) {
|
||||
$ret .= $find->short . " | ";
|
||||
}
|
||||
}
|
||||
$ret = rtrim($ret, " | ");
|
||||
|
|
@ -467,19 +519,20 @@ class User extends Authenticatable
|
|||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLandByCountry(){
|
||||
if($this->account && $this->account->country_id){
|
||||
public function getLandByCountry()
|
||||
{
|
||||
if ($this->account && $this->account->country_id) {
|
||||
$code = $this->account->country->code;
|
||||
if($code == "FR"){
|
||||
if ($code == "FR") {
|
||||
return 'fr';
|
||||
}
|
||||
if($code == "CH"){
|
||||
if ($code == "CH") {
|
||||
return 'de';
|
||||
}
|
||||
if($code == "NL"){
|
||||
if ($code == "NL") {
|
||||
return 'nl';
|
||||
}
|
||||
if($code == "DE"){
|
||||
if ($code == "DE") {
|
||||
return 'de';
|
||||
}
|
||||
}
|
||||
|
|
@ -504,10 +557,10 @@ class User extends Authenticatable
|
|||
{
|
||||
|
||||
//NOTE check ist, cant change month year !
|
||||
if($this->userSalesVolume === false){
|
||||
if ($this->userSalesVolume === false) {
|
||||
$this->userSalesVolume = $this->getUserSalesVolume($month, $year, 'first');
|
||||
}
|
||||
if($this->userSalesVolume){
|
||||
if ($this->userSalesVolume) {
|
||||
switch ($key) {
|
||||
case 'sales_volume_KP_points':
|
||||
return $this->userSalesVolume->month_KP_points;
|
||||
|
|
@ -529,7 +582,7 @@ class User extends Authenticatable
|
|||
case 'sales_volume_total':
|
||||
return $this->userSalesVolume->month_total_net;
|
||||
break;
|
||||
|
||||
|
||||
case 'sales_volume_total_shop':
|
||||
return $this->userSalesVolume->month_shop_total_net;
|
||||
break;
|
||||
|
|
@ -540,7 +593,7 @@ class User extends Authenticatable
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public function getUserSalesVolume($month, $year, $record = 'get')
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
use App\Services\AboHelper;
|
||||
|
||||
if (! function_exists('make_old_url')) {
|
||||
function make_old_url($path)
|
||||
{
|
||||
|
|
@ -85,4 +87,22 @@ if (! function_exists('maxStrLength')) {
|
|||
function maxStrLength($str, $lenght = 40)
|
||||
{
|
||||
return !$str ? $str : Util::maxStrLength($str, $lenght); }
|
||||
}
|
||||
|
||||
if (! function_exists('get_abo_type_badge_by_product')) {
|
||||
function get_abo_type_badge_by_product($product){
|
||||
return AboHelper::getAboTypeBadge(AboHelper::getAboShowOn($product));
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('get_abo_type_badge')) {
|
||||
function get_abo_type_badge($type){
|
||||
return AboHelper::getAboTypeBadge($type);
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('cleanIntegerFromString')) {
|
||||
function cleanIntegerFromString($value) {
|
||||
return Util::cleanIntegerFromString($value);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue