update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
112
dev/app-bak/Http/Controllers/Api/AuthController.php
Executable file
112
dev/app-bak/Http/Controllers/Api/AuthController.php
Executable file
|
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
//protected static API_MAIL = 'api.thomas.krummel@gmail.com';
|
||||
//protected static API_PASS = 'UF(Q<9knap!ev3vH?5~!b8DP';
|
||||
//protected static API_URL = 'https://mein.sterntours.test/api/';
|
||||
|
||||
|
||||
public $successStatus = 200;
|
||||
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'email' => 'required|string|email',
|
||||
'password' => 'required|string',
|
||||
'remember_me' => 'boolean'
|
||||
]);
|
||||
$credentials = request(['email', 'password']);
|
||||
|
||||
if (!Auth::attempt($credentials))
|
||||
return response()->json([
|
||||
'message' => 'Unauthorized'
|
||||
], 401);
|
||||
$user = $request->user();
|
||||
|
||||
$tokenResult = $user->createToken('Personal Access Token');
|
||||
$token = $tokenResult->token;
|
||||
|
||||
if ($request->remember_me){
|
||||
$token->expires_at = Carbon::now()->addWeeks(1);
|
||||
}else{
|
||||
$token->expires_at = Carbon::now()->addDays(1);
|
||||
}
|
||||
|
||||
\DB::table('oauth_access_tokens')
|
||||
->whereDate('expires_at', '<', now()->addWeeks(1))
|
||||
->delete();
|
||||
|
||||
\DB::table('oauth_refresh_tokens')
|
||||
->whereDate('expires_at', '<', now()->addWeeks(1))
|
||||
->delete();
|
||||
|
||||
|
||||
$token->save();
|
||||
return response()->json([
|
||||
'access_token' => $tokenResult->accessToken,
|
||||
'token_type' => 'Bearer',
|
||||
'expires_at' => Carbon::parse(
|
||||
$tokenResult->token->expires_at
|
||||
)->toDateTimeString()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function checked(Request $request)
|
||||
{
|
||||
return response()->json([
|
||||
'message' => 'login'
|
||||
]);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$request->user()->token()->revoke();
|
||||
return response()->json([
|
||||
'message' => 'Successfully logged out'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authenticated User
|
||||
*
|
||||
* @return [json] user object
|
||||
*/
|
||||
/* public function user(Request $request)
|
||||
{
|
||||
return response()->json($request->user());
|
||||
}
|
||||
*/
|
||||
|
||||
/*public function signup(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string',
|
||||
'email' => 'required|string|email|unique:users',
|
||||
'password' => 'required|string|confirmed'
|
||||
]);
|
||||
$user = new User([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password),
|
||||
]);
|
||||
$user->save();
|
||||
return response()->json([
|
||||
'message' => 'Successfully created user!'
|
||||
], 201);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Product as ModelsProduct;
|
||||
use Illuminate\Http\Response;
|
||||
use Wearepixel\LaravelGoogleShoppingFeed\LaravelGoogleShoppingFeed;
|
||||
use App\Services\Util;
|
||||
|
||||
|
||||
class GoogleMerchantController extends Controller
|
||||
{
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Generate Google Merchant feed
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function feed()
|
||||
{
|
||||
$products = ModelsProduct::where('active', true)->whereJsonContains('show_on', '1')->orderBy('pos', 'DESC')->get();
|
||||
|
||||
// Create feed object
|
||||
$feed = LaravelGoogleShoppingFeed::init(
|
||||
'mivita shop',
|
||||
'Bio Aloe Vera & Naturkosmetik',
|
||||
'https://mivita.shop'
|
||||
);
|
||||
|
||||
// Put products to the feed
|
||||
foreach ($products as $product) {
|
||||
$feed->addItem([
|
||||
'id' => $product->id,
|
||||
'title' => $product->name,
|
||||
'description' => $product->copy,
|
||||
'link' => $product->getProductUrl(),
|
||||
'g:image_link' => $product->getImageUrl(),
|
||||
'g:availability' => 'in stock',
|
||||
'g:price' => "{$product->price} EUR",
|
||||
'g:brand' => 'MIVITA',
|
||||
'g:gtin' => $product->ean,
|
||||
'g:condition' => 'new',
|
||||
'g:custom_label_0' => $product->weight,
|
||||
'g:custom_label_1' => $product->contents_total,
|
||||
'g:custom_label_2' => $product->getUnitType(),
|
||||
'g:custom_label_3' => $product->contents_str,
|
||||
'g:custom_label_4' => $product->ingredients,
|
||||
'g:unit_pricing_measure' => $product->getBasePriceFormattedFullWith(false, false, null)
|
||||
]);
|
||||
}
|
||||
return $feed->generate();
|
||||
// Get the feed XML
|
||||
//$feedXml = $feed->toString();
|
||||
//return response($feedXml)->header('Content-Type', 'application/xml');
|
||||
}
|
||||
|
||||
// http://api.mivita.test/google/merchant/feed
|
||||
|
||||
}
|
||||
116
dev/app-bak/Http/Controllers/Api/KasController.php
Executable file
116
dev/app-bak/Http/Controllers/Api/KasController.php
Executable file
|
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Session;
|
||||
use \SoapClient;
|
||||
|
||||
class KasController extends Controller
|
||||
{
|
||||
|
||||
|
||||
// Logindaten
|
||||
private $kas_user = 'w017f6e4'; // KAS-Logon
|
||||
private $kas_pass = 'Medxiz-funteb-7dubdi'; // KAS-Passwort
|
||||
private $session_lifetime = 600; // Gültigkeit des Tokens in Sek. bis zur neuen Authentifizierung
|
||||
private $session_update_lifetime = 'Y'; // bei N läuft die Session nach <$session_lifetime> Sekunden ab, bei Y verlängert sich die Session mit jeder Benutzung
|
||||
private $CredentialToken = false;
|
||||
private $kas_flood_delay = 2;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->login();
|
||||
}
|
||||
|
||||
|
||||
public function action($func, $para = array()){
|
||||
|
||||
$this->checkSession($func);
|
||||
try
|
||||
{
|
||||
$Params = array(); // Parameter für die API-Funktion
|
||||
$SoapRequest = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasApi.wsdl', [
|
||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||
'exceptions' => false
|
||||
]);
|
||||
$req = $SoapRequest->KasApi(json_encode(array(
|
||||
'KasUser' => $this->kas_user, // KAS-User
|
||||
'KasAuthType' => 'session', // Auth per Sessiontoken
|
||||
'KasAuthData' => $this->CredentialToken, // Auth-Token
|
||||
'KasRequestType' => $func, // API-Funktion
|
||||
'KasRequestParams' => $para // Parameter an die API-Funktion
|
||||
)));
|
||||
Session::put('flood_protection.'.$func, time() + $this->kas_flood_delay + 0.2);
|
||||
|
||||
if(is_array($req) && isset($req['Response']['ReturnString']) && $req['Response']['ReturnString'] == "TRUE"){
|
||||
return $req['Response']['ReturnInfo'];
|
||||
}
|
||||
return $req;
|
||||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (\SoapFault $fault)
|
||||
{
|
||||
trigger_error(" Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
Verursacher: {$fault->faultactor},
|
||||
Details: {$fault->detail}", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function login(){
|
||||
|
||||
$this->checkSession('auth');
|
||||
try
|
||||
{
|
||||
|
||||
$SoapLogon = new SoapClient('https://kasapi.kasserver.com/soap/wsdl/KasAuth.wsdl', [
|
||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||
'exceptions' => false
|
||||
]);
|
||||
$this->CredentialToken = $SoapLogon->KasAuth(json_encode(array(
|
||||
'KasUser' => $this->kas_user,
|
||||
'KasAuthType' => 'plain',
|
||||
'KasPassword' => $this->kas_pass,
|
||||
'SessionLifeTime' => $this->session_lifetime,
|
||||
'SessionUpdateLifeTime' => $this->session_update_lifetime
|
||||
)));
|
||||
Session::put('flood_protection.auth', time() + $this->kas_flood_delay + 0.2);
|
||||
|
||||
}
|
||||
|
||||
// Fehler abfangen und ausgeben
|
||||
catch (\SoapFault $fault)
|
||||
{
|
||||
trigger_error("Fehlernummer: {$fault->faultcode},
|
||||
Fehlermeldung: {$fault->faultstring},
|
||||
Verursacher: {$fault->faultactor},
|
||||
Details: {$fault->detail}", E_USER_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function checkSession($func)
|
||||
{
|
||||
$name = 'flood_protection.'.$func;
|
||||
|
||||
if(Session::exists($name)){
|
||||
$time_to_wait = (float)Session::get($name) - time();
|
||||
Session::forget($name);
|
||||
}else {
|
||||
$time_to_wait = 0;
|
||||
}
|
||||
if ( $time_to_wait >= 0 ) {
|
||||
usleep( intval( $time_to_wait*1000000 ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
267
dev/app-bak/Http/Controllers/Api/KasSLLController.php
Executable file
267
dev/app-bak/Http/Controllers/Api/KasSLLController.php
Executable file
|
|
@ -0,0 +1,267 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class KasSLLController extends Controller
|
||||
{
|
||||
|
||||
private static $ssl_certificate_sni_csr = "";
|
||||
private static $ssl_certificate_sni_key = "-----BEGIN PRIVATE KEY-----
|
||||
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgohGr2e3ysw/Awvzh
|
||||
qkqDS4iQgRvWwNIYxTcPxpdcndGhRANCAASZjlV2bQbLQrOveMlYOowR3IlfND7z
|
||||
OxauFGabh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5jcnQwIwYIKwYBBQUHMAGGF2h0dHA6Ly9vY3NwLnNl
|
||||
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
|
||||
CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtKZXJz
|
||||
ZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJU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agNIYyaHR0cDovL2NybC5jb21vZG9jYS5j
|
||||
b20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNlcy5jcmwwNAYIKwYBBQUHAQEEKDAmMCQG
|
||||
CCsGAQUFBzABhhhodHRwOi8vb2NzcC5jb21vZG9jYS5jb20wDQYJKoZIhvcNAQEM
|
||||
BQADggEBABns652JLCALBIAdGN5CmXKZFjK9Dpx1WywV4ilAbe7/ctvbq5AfjJXy
|
||||
ij0IckKJUAfiORVsAYfZFhr1wHUrxeZWEQff2Ji8fJ8ZOd+LygBkc7xGEJuTI42+
|
||||
FsMuCIKchjN0djsoTI0DQoWz4rIjQtUfenVqGtF8qmchxDM6OW1TyaLtYiKou+JV
|
||||
bJlsQ2uRl9EMC5MCHdK8aXdJ5htN978UeAOwproLtOGFfy/cQjutdAFI3tZs4RmY
|
||||
CV4Ks2dH/hzg1cEo70qLRDEmBDeNiXQ2Lu+lIg+DdEmSx/cQwgwp+7e9un/jX9Wf
|
||||
8qn0dNW44bOwgeThpWOjzOoEeJBuv/c=
|
||||
-----END CERTIFICATE-----";
|
||||
|
||||
|
||||
public static function getApiSSLParameter(){
|
||||
|
||||
return [
|
||||
'ssl_certificate_is_active' => "Y",
|
||||
'ssl_certificate_sni_csr' => self::$ssl_certificate_sni_csr,
|
||||
'ssl_certificate_sni_key' => self::$ssl_certificate_sni_key,
|
||||
'ssl_certificate_sni_crt' => self::$ssl_certificate_sni_crt,
|
||||
'ssl_certificate_sni_bundle' => self::$ssl_certificate_sni_bundle,
|
||||
'ssl_certificate_force_https' => "Y",
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPara(){
|
||||
return [
|
||||
"ssl_proxy" => "N",
|
||||
"ssl_certificate_ip" => "N",
|
||||
"ssl_certificate_sni" => "Y",
|
||||
"ssl_certificate_sni_csr" => "-----BEGIN CERTIFICATE REQUEST-----\n
|
||||
MIIC0DCCAbgCAQAwgYoxCzAJBgNVBAYTAkRFMQ4wDAYDVQQRDAU4Nzc1NTEPM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BgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqGSIb3DQEBDAUA\n
|
||||
A4IBAQAYh1HcdCE9nIrgJ7cz0C7M7PDmy14R3iJvm3WOnnL+5Nb+qh+cli3vA0p+\n
|
||||
rvSNb3I8QzvAP+u431yqqcau8vzY7qN7Q/aGNnwU4M309z/+3ri0ivCRlv79Q2R+\n
|
||||
/czSAaF9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA\n
|
||||
CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F\n
|
||||
zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA\n
|
||||
vGp4z7h/jnZymQyd/teRCBaho1+V\n
|
||||
-----END CERTIFICATE-----
|
||||
",
|
||||
"ssl_certificate_sni_chainfile" => null,
|
||||
"ssl_certificate_sni_force_https" => "N",
|
||||
"ssl_certificate_sni_hsts_max_age" => "-1"
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
187
dev/app-bak/Http/Controllers/Api/PayoneController.php
Executable file
187
dev/app-bak/Http/Controllers/Api/PayoneController.php
Executable file
|
|
@ -0,0 +1,187 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function paymentStatus(){
|
||||
|
||||
$data = \Request::all();
|
||||
// test para
|
||||
|
||||
/* $data = [
|
||||
'key' => '698fb2555f8b2efc74f60b2121421f45',
|
||||
'txaction' => 'paid',
|
||||
'clearingtype' => 'wlt',
|
||||
'userid' => '158723953',
|
||||
'txid' => '321623031',
|
||||
'price' => '89.00',
|
||||
'param' => '1', //$this->shopping_order->id,
|
||||
'reference' => '15c83aee2766c3',
|
||||
];
|
||||
|
||||
*/
|
||||
|
||||
if(!isset($data['key']) || !isset($data['param']) || !isset($data['userid']) || !isset($data['txid']) || !isset($data['reference']) || !isset($data['price'])){
|
||||
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')) {
|
||||
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){
|
||||
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){
|
||||
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){
|
||||
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, '.', '');
|
||||
$price_amount = number_format($shopping_payment->amount, 0, '.', '');
|
||||
if($price_amount != $price){
|
||||
$data['shopping_payment-amount'] = $price_amount;
|
||||
$data['price-amount'] = $price;
|
||||
MyLog::writeLog(
|
||||
'payone',
|
||||
'error',
|
||||
'Error:2006 App\Http\Controllers\Api\PayoneController::paymentStatus Price error',
|
||||
$data
|
||||
);
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
/* TODO -- need this? */
|
||||
if($shopping_payment->txaction == $data['txaction']){
|
||||
|
||||
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,
|
||||
'request' => 'transaction',
|
||||
'txid' => $data['txid'],
|
||||
'userid' => $data['userid'],
|
||||
'status' => 'PAYONE',
|
||||
'key' => $data['key'],
|
||||
'txaction' => $data['txaction'],
|
||||
'transmitted_data' => Util::utf8ize($data),
|
||||
'mode' => $data['mode'],
|
||||
]);
|
||||
|
||||
$shopping_order->txaction = $data['txaction'];
|
||||
$shopping_order->save();
|
||||
$shopping_payment->txaction = $data['txaction'];
|
||||
$shopping_payment->save();
|
||||
|
||||
$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]);
|
||||
ShoppingUserService::snycOrdersByShoppingOrder($shopping_order);
|
||||
Util::setInstanceStatusByPayment($shopping_payment, 4);
|
||||
}
|
||||
|
||||
if($data['txaction'] === 'paid'){
|
||||
if(!$shopping_order->paid){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true, $shopping_payment);
|
||||
}else{
|
||||
$send_mail = false;
|
||||
}
|
||||
}
|
||||
$data['send_link'] = $send_link;
|
||||
if($send_mail){
|
||||
Payment::paymentStatusSendMail($shopping_order, $shopping_payment, $data);
|
||||
}
|
||||
print("TSOK");
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
718
dev/app-bak/Http/Controllers/Api/ShoppingUserController.php
Executable file
718
dev/app-bak/Http/Controllers/Api/ShoppingUserController.php
Executable file
|
|
@ -0,0 +1,718 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Mail\MailCheckout;
|
||||
use App\Models\Country;
|
||||
use App\Models\Product;
|
||||
use App\Models\ShippingCountry;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\CustomerPriority;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use PHPUnit\Framework\Constraint\Count;
|
||||
use Yard;
|
||||
|
||||
|
||||
class ShoppingUserController extends Controller
|
||||
{
|
||||
|
||||
//protected static API_MAIL = 'api.thomas.krummel@gmail.com';
|
||||
//protected static API_PASS = 'UF(Q<9knap!ev3vH?5~!b8DP';
|
||||
|
||||
|
||||
protected $successStatus = 200;
|
||||
protected $member_id = 3; //service@aloe-vera.bio
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* wp_order_numbers[1234, 1234]
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function status(Request $request)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'wp_order_numbers' => 'required',
|
||||
]);
|
||||
|
||||
if(!is_array($request->wp_order_numbers)){
|
||||
$wp_order_numbers = json_decode($request->wp_order_numbers);
|
||||
|
||||
}else{
|
||||
$wp_order_numbers = $request->wp_order_numbers;
|
||||
}
|
||||
|
||||
if(!$wp_order_numbers || !is_array($wp_order_numbers)){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'wp_order_numbers need as json [1234, 1234] ',
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
|
||||
$status = [];
|
||||
foreach ($wp_order_numbers as $wp_order_number){
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $wp_order_number)->first();
|
||||
$status[] = [
|
||||
'wp_order_number' => $wp_order_number,
|
||||
'user' => $shopping_user ? true : false,
|
||||
'order' => ($shopping_user && $shopping_user->shopping_order) ? true : false,
|
||||
'status' => $shopping_user ? $shopping_user->getAPIShippedType() : false,
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $status,
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* wp_order_number [1234]
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function cancel(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'wp_order_number' => 'required|int',
|
||||
]);
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
|
||||
if (!$shopping_user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
|
||||
'order' => false,
|
||||
'status' => false,
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
if(!$shopping_user->shopping_order){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' has no order',
|
||||
'order' => false,
|
||||
'status' => $shopping_user->getAPIShippedType(),
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
if($shopping_user->shopping_order->shipped > 0){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' can not cancel',
|
||||
'order' => true,
|
||||
'status' => $shopping_user->getAPIShippedType(),
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
|
||||
$shopping_user->shopping_order->shipped = 10;
|
||||
$shopping_user->shopping_order->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' is cancel',
|
||||
'order' => true,
|
||||
'status' => $shopping_user->getAPIShippedType(),
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* wp_order_number [1234]
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function open(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'wp_order_number' => 'required|int',
|
||||
]);
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
|
||||
if (!$shopping_user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
|
||||
'order' => false,
|
||||
'status' => false,
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
if(!$shopping_user->shopping_order){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' has no order',
|
||||
'order' => false,
|
||||
'status' => $shopping_user->getAPIShippedType(),
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
if($shopping_user->shopping_order->shipped !== 10){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' can not open',
|
||||
'order' => true,
|
||||
'status' => $shopping_user->getAPIShippedType(),
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
|
||||
$shopping_user->shopping_order->shipped = 0;
|
||||
$shopping_user->shopping_order->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' is open',
|
||||
'order' => true,
|
||||
'status' => $shopping_user->getAPIShippedType(),
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* wp_order_numbers [1234, 1234]
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function show(Request $request)
|
||||
{
|
||||
//$this->member_id = auth()->user()->m_sponsor;
|
||||
$request->validate([
|
||||
'wp_order_numbers' => 'required',
|
||||
]);
|
||||
|
||||
if(!is_array($request->wp_order_numbers)){
|
||||
$wp_order_numbers = json_decode($request->wp_order_numbers);
|
||||
|
||||
}else{
|
||||
$wp_order_numbers = $request->wp_order_numbers;
|
||||
}
|
||||
|
||||
if(!$wp_order_numbers || !is_array($wp_order_numbers)){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'wp_order_numbers need as json [1234, 1234] ',
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
$data = [];
|
||||
|
||||
foreach ($wp_order_numbers as $wp_order_number){
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $wp_order_number)->first();
|
||||
$user = false;
|
||||
$order = false;
|
||||
if ($shopping_user) {
|
||||
$user = $this->prepareForShow($shopping_user);
|
||||
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
|
||||
}
|
||||
$data[] = [
|
||||
'wp_order_number' => $wp_order_number,
|
||||
'user' => $user,
|
||||
'order' => $order,
|
||||
'customer_number' => $shopping_user ? $shopping_user->number : false,
|
||||
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
|
||||
'status' => $shopping_user ? $shopping_user->getAPIShippedType() : false, ];
|
||||
}
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $data,
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'billing_email' => 'required|string|email',
|
||||
'billing_firstname' => 'required|string',
|
||||
'billing_lastname' => 'required|string',
|
||||
'billing_address' => 'required|string',
|
||||
'billing_zipcode' => 'required|string',
|
||||
'billing_city' => 'required|string',
|
||||
'billing_country_code' => 'required|string',
|
||||
'wp_order_number' => 'required|int|unique:shopping_users,wp_order_number',
|
||||
'wp_order_date' => 'required|date',
|
||||
]);
|
||||
|
||||
$this->member_id = auth()->user()->m_sponsor;
|
||||
|
||||
$data = $this->prepareForStore($request->all());
|
||||
$data['member_id'] = $this->member_id ;
|
||||
$data['number'] = ShoppingUser::max('number') + 1;
|
||||
$data['mode'] = $request->mode ? $request->mode : 'live';
|
||||
$data['is_from'] = 'extern';
|
||||
$data['is_for'] = 'ot-member';
|
||||
|
||||
$shopping_user = ShoppingUser::create($data);
|
||||
|
||||
//Kundenhoheit prüfen
|
||||
$priority = CustomerPriority::checkOne($shopping_user, true, false, true);
|
||||
\App\Services\Shop::newUserOrder($shopping_user->number);
|
||||
//exists //like //update
|
||||
$user = $this->prepareForShow($shopping_user);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'wp_order_number' => $shopping_user->wp_order_number,
|
||||
'user' => $user,
|
||||
'customer_priority' => $priority,
|
||||
'customer_number' => $shopping_user->number,
|
||||
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
|
||||
],
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'wp_order_number' => 'required|int',
|
||||
]);
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
|
||||
if (!$shopping_user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
|
||||
$data = $this->prepareForUpdate($request->all());
|
||||
//Kundenhoheit prüfen
|
||||
$priority = CustomerPriority::checkChangeOne($shopping_user, $data, true);
|
||||
$updated = $shopping_user->fill($data)->save();
|
||||
\App\Services\Shop::newUserOrder($shopping_user->number);
|
||||
|
||||
if ($updated){
|
||||
$user = $this->prepareForShow($shopping_user);
|
||||
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'wp_order_number' => $shopping_user->wp_order_number,
|
||||
'user' => $user,
|
||||
'order' => $order,
|
||||
'customer_priority' => $priority,
|
||||
'customer_number' => $shopping_user ? $shopping_user->number : false,
|
||||
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
|
||||
'status' => $shopping_user ? $shopping_user->getAPIShippedType() : false,
|
||||
],
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
}
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry could not be updated'
|
||||
], 500);
|
||||
}
|
||||
|
||||
public function order(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'wp_order_number' => 'required|int',
|
||||
'wp_order' => 'required',
|
||||
]);
|
||||
|
||||
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->first();
|
||||
if (!$shopping_user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found',
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
|
||||
if($shopping_user->shopping_order){
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Order with wp_order_number ' . $request->wp_order_number . ' exists',
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
if(!is_array($request->wp_order)){
|
||||
$wp_order = json_decode($request->wp_order);
|
||||
|
||||
}else{
|
||||
$wp_order = $request->wp_order;
|
||||
}
|
||||
|
||||
$wp_invoice_path = isset($request->wp_invoice_path) ? $request->wp_invoice_path : null;
|
||||
$wp_advertising = isset($request->wp_advertising) ? $request->wp_advertising : '';
|
||||
$wp_incentives = isset($request->wp_incentives) ? $request->wp_incentives : '';
|
||||
|
||||
$api_notice = [
|
||||
'wp_advertising' => $wp_advertising,
|
||||
'wp_incentives' => $wp_incentives,
|
||||
];
|
||||
|
||||
$wp_order = $this->prepareOrder($wp_order, $shopping_user, $wp_invoice_path, $api_notice);
|
||||
|
||||
if ($wp_order){
|
||||
$user = $this->prepareForShow($shopping_user);
|
||||
$order = $this->prepareForShowOrder($shopping_user->shopping_order);
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => [
|
||||
'wp_order_number' => $shopping_user->wp_order_number,
|
||||
'wp_invoice_path' => $wp_invoice_path,
|
||||
'wp_advertising' => $wp_advertising,
|
||||
'wp_incentives' => $wp_incentives,
|
||||
'wp_order' => $wp_order,
|
||||
'user' => $user,
|
||||
'order' => $order,
|
||||
'customer_number' => $shopping_user->number,
|
||||
'member_email' => ($shopping_user && $shopping_user->member) ? $shopping_user->member->email : false,
|
||||
'status' => $shopping_user->getAPIShippedType(),
|
||||
],
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 200);
|
||||
}
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Order could not be stored'
|
||||
], 500);
|
||||
}
|
||||
|
||||
public function delete(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'wp_order_number' => 'required|int',
|
||||
]);
|
||||
$shopping_user = ShoppingUser::where('wp_order_number', '=', $request->wp_order_number)->where('mode', '=', 'dev')->first();
|
||||
if (!$shopping_user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry with wp_order_number ' . $request->wp_order_number . ' not found or mode != dev',
|
||||
'time' => Carbon::now()->toDateTimeString()
|
||||
], 400);
|
||||
}
|
||||
$shopping_order = $shopping_user->shopping_order;
|
||||
if($shopping_order){
|
||||
foreach ($shopping_order->shopping_order_items as $shopping_order_item){
|
||||
$shopping_order_item->delete();
|
||||
}
|
||||
$shopping_order->delete();
|
||||
}
|
||||
$shopping_user->wp_order_number = time();
|
||||
$shopping_user->save();
|
||||
if ($shopping_user->delete()) {
|
||||
return response()->json([
|
||||
'success' => true
|
||||
]);
|
||||
}
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Entry could not be deleted'
|
||||
], 500);
|
||||
}
|
||||
|
||||
private function prepareForShow($shopping_user){
|
||||
|
||||
if(!$shopping_user){
|
||||
return false;
|
||||
}
|
||||
|
||||
$shopping_user_data = $shopping_user->toArray();
|
||||
$needs = ['wp_order_number', 'wp_order_date', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email',
|
||||
'same_as_billing', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone',
|
||||
'created_at', 'updated_at', 'user_deleted_at']; //'has_buyed', 'subscribed',
|
||||
|
||||
//$salutation = array('mr' => 1, 'ms' => 2);
|
||||
$ret = [];
|
||||
foreach ($shopping_user_data as $key=>$value){
|
||||
|
||||
if($key === 'billing_country_id'){
|
||||
$ret['billing_country_code'] = $shopping_user->billing_country_id ? $shopping_user->billing_country->code : null;
|
||||
}
|
||||
if($key === 'shipping_country_id'){
|
||||
$ret['shipping_country_code'] = $shopping_user->shipping_country_id ? $shopping_user->shipping_country->code : null;
|
||||
}
|
||||
if($key === 'billing_salutation'){
|
||||
$ret['billing_salutation'] = $shopping_user->billing_salutation === 'ms' ? 2 : 1;
|
||||
}
|
||||
if($key === 'shipping_salutation'){
|
||||
$ret['shipping_salutation'] = $shopping_user->shipping_salutation === 'ms' ? 2 : 1;
|
||||
}
|
||||
|
||||
if(in_array($key, $needs)){
|
||||
$ret[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function prepareForShowOrder($shopping_order){
|
||||
|
||||
if(!$shopping_order){
|
||||
return false;
|
||||
}
|
||||
$ret = [
|
||||
'country' => isset($shopping_order->shipping_country->country->code) ? $shopping_order->shipping_country->country->code : '',
|
||||
'wp_invoice_path' => $shopping_order->wp_invoice_path,
|
||||
'total' => ($shopping_order->total*100),
|
||||
'shipping' => ($shopping_order->shipping*100),
|
||||
'total_net' => ($shopping_order->subtotal*100),
|
||||
'tax_rate' => ($shopping_order->tax_rate*100),
|
||||
'tax' => ($shopping_order->tax*100),
|
||||
'total_with_shipping' => ($shopping_order->total_shipping*100),
|
||||
'weight' => $shopping_order->weight,
|
||||
];
|
||||
$ret['items'] = [];
|
||||
foreach ($shopping_order->shopping_order_items as $item){
|
||||
$ret['items'][] = [
|
||||
'article' => $item->product->wp_number,
|
||||
'name' => $item->product->getLang('name'),
|
||||
'qty' => $item->qty,
|
||||
'price' => ($item->price * 100),
|
||||
];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function prepareForUpdate($data){
|
||||
|
||||
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
|
||||
|
||||
if(isset($data['billing_salutation'])){
|
||||
$data['billing_salutation'] = (int) $data['billing_salutation'];
|
||||
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if(isset($data['shipping_salutation'])){
|
||||
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
|
||||
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
|
||||
$ret = [];
|
||||
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_phone', 'billing_email', 'same_as_billing',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_phone'];
|
||||
|
||||
foreach ($data as $key=>$value){
|
||||
if($key === 'billing_country_code' && isset($data['billing_country_code'])) {
|
||||
$ret['billing_country_id'] = Country::getCountryIdByCodeOrOne($data['billing_country_code']);
|
||||
}
|
||||
if($key === 'shipping_country_code' && isset($data['shipping_country_code']) ) {
|
||||
$ret['shipping_country_id'] = Country::getCountryIdByCodeOrOne($data['shipping_country_code']);
|
||||
}
|
||||
if($key === 'billing_phone') {
|
||||
$ret['billing_phone'] = strlen($data['billing_phone']) <= 3 ? '' : $data['billing_phone'];
|
||||
}
|
||||
if($key === 'shipping_phone') {
|
||||
$ret['shipping_phone'] = strlen($data['shipping_phone']) <= 3 ? '' : $data['shipping_phone'];
|
||||
}
|
||||
if(in_array($key, $needs)){
|
||||
$ret[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function prepareForStore($data){
|
||||
|
||||
//$salutation = array(1 => 'mr', 2 => 'ms', 3=>null);
|
||||
if(isset($data['billing_salutation'])){
|
||||
$data['billing_salutation'] = (int) $data['billing_salutation'];
|
||||
$data['billing_salutation'] = $data['billing_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
if(isset($data['shipping_salutation'])){
|
||||
$data['shipping_salutation'] = (int) $data['shipping_salutation'];
|
||||
$data['shipping_salutation'] = $data['shipping_salutation'] == 2 ? 'ms' : 'mr';
|
||||
}
|
||||
$ret = [];
|
||||
$needs = [ 'billing_salutation', 'billing_company', 'billing_firstname', 'billing_lastname', 'billing_address', 'billing_address_2', 'billing_zipcode', 'billing_city', 'billing_country_id', 'billing_phone', 'billing_email',
|
||||
'shipping_salutation', 'shipping_company', 'shipping_firstname', 'shipping_lastname', 'shipping_address', 'shipping_address_2', 'shipping_zipcode', 'shipping_city', 'shipping_country_id', 'shipping_phone',
|
||||
'same_as_billing', //'has_buyed', 'subscribed',
|
||||
'wp_order_number', 'wp_order_date'];
|
||||
|
||||
foreach ($needs as $need){
|
||||
|
||||
$ret[$need] = isset($data[$need]) ? $data[$need] : null;
|
||||
if ($need === 'billing_country_id') {
|
||||
$ret['billing_country_id'] = isset($data['billing_country_code']) ? Country::getCountryIdByCodeOrOne($data['billing_country_code']) : 1;
|
||||
}
|
||||
if ($need === 'shipping_country_id') {
|
||||
$ret['shipping_country_id'] = isset($data['shipping_country_code']) ? Country::getCountryIdByCodeOrOne($data['shipping_country_code']) : $ret['billing_country_id'];
|
||||
}
|
||||
if ($need === 'billing_phone' && $ret[$need] !== null) {
|
||||
$ret['billing_phone'] = strlen($data['billing_phone']) <= 3 ? '' : $data['billing_phone'];
|
||||
}
|
||||
if ($need === 'shipping_phone' && $ret[$need] !== null) {
|
||||
$ret['shipping_phone'] = strlen($data['shipping_phone']) <= 3 ? '' : $data['shipping_phone'];
|
||||
}
|
||||
if ($need === 'wp_order_date') {
|
||||
$ret['wp_order_date'] = Carbon::parse($ret['wp_order_date'])->toDateTimeString();
|
||||
}
|
||||
if ($need === 'same_as_billing') {
|
||||
$ret['same_as_billing'] = isset($data['same_as_billing']) ? $data['same_as_billing'] : true;
|
||||
}
|
||||
}
|
||||
$ret['has_buyed'] = true;
|
||||
$ret['subscribed'] = false;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function prepareOrder($wp_shopping_order, $shopping_user, $wp_invoice_path, $api_notice){
|
||||
Yard::instance('shopping')->destroy();
|
||||
$ret = [];
|
||||
|
||||
if(is_array($wp_shopping_order)){
|
||||
foreach ($wp_shopping_order as $order) {
|
||||
//$object = json_decode(json_encode($order), FALSE);
|
||||
$order = (object) $order;
|
||||
$error = [];
|
||||
if (!isset($order->article) || !isset($order->qty) || !isset($order->price)) {
|
||||
$error[] = "article parameter is missing";
|
||||
} else {
|
||||
|
||||
$product = Product::whereWpNumber($order->article)->first();
|
||||
if (!$product) {
|
||||
$error[] = "article not found";
|
||||
} else {
|
||||
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, 'show_on' => $product->show_on]);
|
||||
Yard::setTax($cartItem->rowId, $product->getTaxWith());
|
||||
}
|
||||
}
|
||||
$order->message = $error;
|
||||
$ret[] = $order;
|
||||
}
|
||||
|
||||
$ShippingCountry = ShippingCountry::whereCountryId($shopping_user->shipping_country_id)->first();
|
||||
if($ShippingCountry){
|
||||
Yard::instance('shopping')->setShippingCountryWithPrice($ShippingCountry->id);
|
||||
}
|
||||
$shopping_order = $this->makeShoppingOrder($shopping_user, $wp_invoice_path, $api_notice);
|
||||
$this->orderStatusSendMail($shopping_order);
|
||||
|
||||
$shopping_user->shopping_order = $shopping_order;
|
||||
Yard::instance('shopping')->destroy();
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
private function makeShoppingOrder($shopping_user, $wp_invoice_path, $api_notice){
|
||||
|
||||
$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' => auth()->user()->user_sponsor->shop->id,
|
||||
'payment_for' => 7,
|
||||
'member_id' => $shopping_user->member_id,
|
||||
'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(),
|
||||
'paid' => true,
|
||||
'txaction' => 'extern',
|
||||
'wp_invoice_path' => $wp_invoice_path,
|
||||
'api_notice' => $api_notice,
|
||||
'api_status' => 0,
|
||||
'mode' => $shopping_user->mode,
|
||||
];
|
||||
$shopping_order = $shopping_user->shopping_order;
|
||||
if($shopping_order){
|
||||
$shopping_order->fill($data);
|
||||
$shopping_order->save();
|
||||
}else{
|
||||
$shopping_order= ShoppingOrder::create($data);
|
||||
}
|
||||
$items = Yard::instance('shopping')->content();
|
||||
|
||||
|
||||
$shopping_order->shopping_order_items()->each(function($model) use ($items, $shopping_order) {
|
||||
foreach ($items as $item) {
|
||||
$price_net = Yard::instance('shopping')->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
if ($model->row_id === $item->rowId) {
|
||||
$model->fill([
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'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,
|
||||
])->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;
|
||||
ShoppingOrderItem::create([
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'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
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
$shopping_order->makeTaxSplit();
|
||||
return $shopping_order;
|
||||
}
|
||||
|
||||
|
||||
public function orderStatusSendMail(ShoppingOrder $shopping_order){
|
||||
|
||||
$bcc = [];
|
||||
$user_mail = $shopping_order->shopping_user->member->email;
|
||||
if($shopping_order->mode === 'dev'){
|
||||
$bcc[] = config('app.checkout_test_mail');
|
||||
}else{
|
||||
$bcc[] = config('app.checkout_mail');
|
||||
}
|
||||
|
||||
Mail::to($user_mail)->bcc($bcc)->locale($shopping_order->getLocale())->send(new MailCheckout($shopping_order->txaction, $shopping_order, null, false, $shopping_order->mode));
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue