April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
|
|
@ -2,60 +2,54 @@
|
|||
|
||||
namespace App\Repositories;
|
||||
|
||||
use Str;
|
||||
use App\User;
|
||||
use stdClass;
|
||||
use Validator;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\UserAccount;
|
||||
use App\Models\UserRegister;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use stdClass;
|
||||
use Validator;
|
||||
|
||||
class UserRepository extends BaseRepository {
|
||||
|
||||
|
||||
class UserRepository extends BaseRepository
|
||||
{
|
||||
public function __construct(User $model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function update($data)
|
||||
{
|
||||
|
||||
if($data['user_id'] === "new" || $data['user_id'] == 0){
|
||||
if ($data['user_id'] === 'new' || $data['user_id'] == 0) {
|
||||
|
||||
$this->model = User::create([
|
||||
'email' => $data['email'],
|
||||
'password' => env('APP_KEY'),
|
||||
'password' => Hash::make(config('app.key')),
|
||||
]);
|
||||
$this->model->payment_methods = PaymentMethod::getDefaultAsArray();
|
||||
$this->model->save();
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$this->model = $this->getById($data['user_id']);
|
||||
}
|
||||
|
||||
if(!$this->model->account_id){
|
||||
$account = new UserAccount();
|
||||
}else{
|
||||
if (! $this->model->account_id) {
|
||||
$account = new UserAccount;
|
||||
} else {
|
||||
$account = $this->model->account;
|
||||
}
|
||||
|
||||
$data['same_as_billing'] = !isset($data['same_as_billing']) ? 0 : 1;
|
||||
$data['same_as_billing'] = ! isset($data['same_as_billing']) ? 0 : 1;
|
||||
|
||||
$data['birthday_day'] = isset($data['birthday_day']) ? $data['birthday_day'] : 1;
|
||||
$data['birthday_month'] = isset($data['birthday_month']) ? $data['birthday_month'] : 1;
|
||||
$data['birthday_year'] = isset($data['birthday_year']) ? $data['birthday_year'] : 1900;
|
||||
$data['birthday'] = $data['birthday_day'].".".$data['birthday_month'].".".$data['birthday_year'];
|
||||
$data['birthday'] = $data['birthday'] == "1.1.1900" ? null : $data['birthday'];
|
||||
|
||||
$data['birthday'] = $data['birthday_day'].'.'.$data['birthday_month'].'.'.$data['birthday_year'];
|
||||
$data['birthday'] = $data['birthday'] == '1.1.1900' ? null : $data['birthday'];
|
||||
|
||||
$account->fill($data)->save();
|
||||
|
||||
if(!$this->model->account_id){
|
||||
if (! $this->model->account_id) {
|
||||
$this->model->account_id = $account->id;
|
||||
$this->model->save();
|
||||
}
|
||||
|
|
@ -63,9 +57,10 @@ class UserRepository extends BaseRepository {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function createUserRegister($data){
|
||||
public function createUserRegister($data)
|
||||
{
|
||||
|
||||
$obj = new stdClass();
|
||||
$obj = new stdClass;
|
||||
|
||||
$obj->email = $data['email'];
|
||||
$obj->password = Hash::make($data['password']);
|
||||
|
|
@ -76,11 +71,11 @@ class UserRepository extends BaseRepository {
|
|||
$obj->first_name = $data['first_name'];
|
||||
$obj->last_name = $data['last_name'];
|
||||
$obj->data_protection = now()->toDateTimeString();
|
||||
|
||||
|
||||
$obj->confirmation_code_to = date('Y-m-d H:i:s', strtotime('+1 week'));
|
||||
$obj->confirmation_code_remider = 0;
|
||||
$obj->m_sponsor = config('app.main_user_id');
|
||||
if(isset($data['from_member_id'])){
|
||||
if (isset($data['from_member_id'])) {
|
||||
$obj->m_sponsor = (int) str_replace('gs', '', $data['from_member_id']) - config('main.add_number_id');
|
||||
}
|
||||
$confirmation_code = UserService::createConfirmationCode();
|
||||
|
|
@ -88,24 +83,26 @@ class UserRepository extends BaseRepository {
|
|||
UserRegister::create([
|
||||
'identifier' => $data['email'],
|
||||
'instance' => $confirmation_code,
|
||||
'content' => $obj
|
||||
'content' => $obj,
|
||||
]);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function clearUserRegister(){
|
||||
$cleartime = date('Y-m-d H:i:s', strtotime('-1 day')); //gestern -24h
|
||||
public function clearUserRegister()
|
||||
{
|
||||
$cleartime = date('Y-m-d H:i:s', strtotime('-1 day')); // gestern -24h
|
||||
UserRegister::where('created_at', '<', $cleartime)->delete();
|
||||
}
|
||||
|
||||
public function create($UserRegister){
|
||||
public function create($UserRegister)
|
||||
{
|
||||
|
||||
|
||||
$userObj = $UserRegister->content;
|
||||
|
||||
$user = User::create([
|
||||
'email' => $userObj->email,
|
||||
'password' =>$userObj->password,
|
||||
'password' => $userObj->password,
|
||||
]);
|
||||
|
||||
$account = UserAccount::create([
|
||||
|
|
@ -122,17 +119,17 @@ class UserRepository extends BaseRepository {
|
|||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 0;
|
||||
$user->confirmation_date = now();
|
||||
$user->lang = !empty(\App::getLocale()) ? \App::getLocale() : "de";
|
||||
$user->lang = ! empty(\App::getLocale()) ? \App::getLocale() : 'de';
|
||||
$user->m_sponsor = $userObj->m_sponsor;
|
||||
|
||||
$user->account_id = $account->id;
|
||||
$user->payment_methods = PaymentMethod::getDefaultAsArray();
|
||||
|
||||
$user->save();
|
||||
|
||||
|
||||
$user = User::find($user->id);
|
||||
|
||||
//clear
|
||||
// clear
|
||||
$identifier = $UserRegister->identifier;
|
||||
UserRegister::where('identifier', $identifier)->delete();
|
||||
|
||||
|
|
@ -141,13 +138,13 @@ class UserRepository extends BaseRepository {
|
|||
|
||||
public function deleteUser(User $user)
|
||||
{
|
||||
if($user->account){
|
||||
if ($user->account) {
|
||||
$user->account->delete();
|
||||
}
|
||||
$user->email = "delete".time();
|
||||
$user->password = "delete".time();
|
||||
$user->email = 'delete'.time();
|
||||
$user->password = 'delete'.time();
|
||||
$user->confirmed = 0;
|
||||
$user->confirmation_code = "delete".time();
|
||||
$user->confirmation_code = 'delete'.time();
|
||||
$user->confirmation_date = null;
|
||||
$user->confirmation_code_to = null;
|
||||
$user->confirmation_code_remider = 2;
|
||||
|
|
@ -162,31 +159,35 @@ class UserRepository extends BaseRepository {
|
|||
return true;
|
||||
}
|
||||
|
||||
public function reverse_charge_validate($data, $user, $route){
|
||||
public function reverse_charge_validate($data, $user, $route)
|
||||
{
|
||||
|
||||
if(isset($data['action']) && $data['action'] == 'reverse_charge_validate'){
|
||||
$rules = array(
|
||||
if (isset($data['action']) && $data['action'] == 'reverse_charge_validate') {
|
||||
$rules = [
|
||||
'tax_identification_number' => 'required',
|
||||
);
|
||||
];
|
||||
$validator = Validator::make($data, $rules);
|
||||
if ($validator->fails()) {
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
return redirect($route)->withErrors($validator)->withInput($data);
|
||||
}
|
||||
}
|
||||
$ret = $this->reverse_charge_activate($data, $user);
|
||||
if($ret === 'error'){
|
||||
if ($ret === 'error') {
|
||||
$validator = Validator::make($data, []);
|
||||
$validator->errors()->add('tax_identification_number_validated', __('msg.VATID_could_not_be_validated'));
|
||||
$data['reverse_charge'] = 0;
|
||||
$data = [
|
||||
'user' => $user,
|
||||
];
|
||||
|
||||
return redirect($route.'#user-vat-validation')->withErrors($validator)->withInput($data);
|
||||
}
|
||||
if($ret === 'valid'){
|
||||
if ($ret === 'valid') {
|
||||
\Session()->flash('alert-success', __('msg.VATID_successfully_entered'));
|
||||
|
||||
return redirect($route.'#user-vat-validation')->withInput($data);
|
||||
|
||||
return redirect($route.'#user-vat-validation')->withInput($data);
|
||||
|
|
@ -194,20 +195,23 @@ class UserRepository extends BaseRepository {
|
|||
}
|
||||
}
|
||||
|
||||
public function reverse_charge_delete($data, $user, $route){
|
||||
if(isset($data['action']) && $data['action'] == 'reverse_charge_delete'){
|
||||
public function reverse_charge_delete($data, $user, $route)
|
||||
{
|
||||
if (isset($data['action']) && $data['action'] == 'reverse_charge_delete') {
|
||||
$user->account->tax_identification_number = '';
|
||||
$user->account->reverse_charge = 0;
|
||||
$user->account->reverse_charge_code = null;
|
||||
$user->account->reverse_charge_code = null;
|
||||
$user->account->reverse_charge_valid = null;
|
||||
$user->account->save();
|
||||
$data['tax_identification_number'] = '';
|
||||
\Session()->flash('alert-success', __('msg.reverse_charge_procedure_and_VATID_deleted'));
|
||||
|
||||
return redirect($route.'#user-vat-validation')->withInput($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function reverse_charge_activate($data, $user){
|
||||
public function reverse_charge_activate($data, $user)
|
||||
{
|
||||
|
||||
/* 'AT' => 'AT-Oesterreich',
|
||||
'BE' => 'BE-Belgien',
|
||||
|
|
@ -237,44 +241,43 @@ class UserRepository extends BaseRepository {
|
|||
'SI' => 'SI-Slowenien',
|
||||
'SK' => 'SK-Slowakei',
|
||||
'XI' => 'XI-Nordirland', */
|
||||
$countryCode = 'DE';
|
||||
|
||||
if($user->account->country_id){
|
||||
$countryCode = $user->account->country->code;
|
||||
}
|
||||
|
||||
$vatid = str_replace(array(' ', '.', '-', ',', ', '), '', trim($data['tax_identification_number']));
|
||||
$cc = substr($vatid, 0, 2);
|
||||
$vatNo = substr($vatid, 2);
|
||||
|
||||
$options = [
|
||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||
'trace' => 1,
|
||||
'stream_context' => stream_context_create(
|
||||
[
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true
|
||||
]
|
||||
]
|
||||
)
|
||||
];
|
||||
|
||||
$client = new \SoapClient("https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl", $options);
|
||||
$result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $vatNo]);
|
||||
|
||||
if($result->valid == true) {
|
||||
$user->account->tax_identification_number = $data['tax_identification_number'];
|
||||
$user->account->reverse_charge = 1;
|
||||
$user->account->reverse_charge_code = $countryCode;
|
||||
$user->account->reverse_charge_valid = now();
|
||||
$user->account->save();
|
||||
return 'valid';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
$countryCode = 'DE';
|
||||
|
||||
if ($user->account->country_id) {
|
||||
$countryCode = $user->account->country->code;
|
||||
}
|
||||
|
||||
}
|
||||
$vatid = str_replace([' ', '.', '-', ',', ', '], '', trim($data['tax_identification_number']));
|
||||
$cc = substr($vatid, 0, 2);
|
||||
$vatNo = substr($vatid, 2);
|
||||
|
||||
$options = [
|
||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||
'trace' => 1,
|
||||
'stream_context' => stream_context_create(
|
||||
[
|
||||
'ssl' => [
|
||||
'verify_peer' => false,
|
||||
'verify_peer_name' => false,
|
||||
'allow_self_signed' => true,
|
||||
],
|
||||
]
|
||||
),
|
||||
];
|
||||
|
||||
$client = new \SoapClient('https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', $options);
|
||||
$result = $client->checkVat(['countryCode' => $countryCode, 'vatNumber' => $vatNo]);
|
||||
|
||||
if ($result->valid == true) {
|
||||
$user->account->tax_identification_number = $data['tax_identification_number'];
|
||||
$user->account->reverse_charge = 1;
|
||||
$user->account->reverse_charge_code = $countryCode;
|
||||
$user->account->reverse_charge_valid = now();
|
||||
$user->account->save();
|
||||
|
||||
return 'valid';
|
||||
} else {
|
||||
return 'error';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue