20-02-2026
This commit is contained in:
parent
a8b395e20d
commit
a00c42e770
252 changed files with 28785 additions and 8907 deletions
|
|
@ -2,24 +2,22 @@
|
|||
|
||||
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\ShoppingCollectOrder;
|
||||
use App\Models\ShoppingOrder;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use App\Models\ShoppingOrderItem;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Services\Util;
|
||||
use Illuminate\Session\SessionManager;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
use Yard;
|
||||
|
||||
class CheckoutRepository extends BaseRepository
|
||||
{
|
||||
|
||||
private $session;
|
||||
private $instance;
|
||||
|
||||
private $instance;
|
||||
|
||||
public function __construct(SessionManager $session)
|
||||
{
|
||||
|
|
@ -33,10 +31,10 @@ class CheckoutRepository extends BaseRepository
|
|||
$user_shop = Util::getUserShop();
|
||||
|
||||
if ($shopping_user->is_from === 'homeparty') {
|
||||
//get data
|
||||
// get data
|
||||
$homeparty = Homeparty::find($shopping_user->homeparty_id);
|
||||
//set Data!
|
||||
$total = Yard::instance($this->instance)->total(2, '.', ''); //ek_price
|
||||
// set Data!
|
||||
$total = Yard::instance($this->instance)->total(2, '.', ''); // ek_price
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
|
|
@ -44,7 +42,7 @@ class CheckoutRepository extends BaseRepository
|
|||
'language' => \App::getLocale(),
|
||||
'user_shop_id' => $user_shop->id,
|
||||
'payment_for' => $shopping_user->getOrderPaymentFor(),
|
||||
'homeparty_id' => $shopping_user->homeparty_id,
|
||||
'homeparty_id' => $shopping_user->homeparty_id,
|
||||
'total' => $total,
|
||||
'subtotal' => $homeparty->order['ek_price_net'],
|
||||
'shipping' => $homeparty->order['shipping_price'],
|
||||
|
|
@ -58,10 +56,10 @@ class CheckoutRepository extends BaseRepository
|
|||
'mode' => Util::getUserShoppingMode(),
|
||||
];
|
||||
} elseif ($shopping_user->is_from === 'collection') {
|
||||
//get data
|
||||
// get data
|
||||
$ShoppingCollectOrder = ShoppingCollectOrder::find($shopping_user->shopping_collect_order_id);
|
||||
//set Data!
|
||||
$total = Yard::instance($this->instance)->total(2, '.', ''); //ek_price
|
||||
// set Data!
|
||||
$total = Yard::instance($this->instance)->total(2, '.', ''); // ek_price
|
||||
$data = [
|
||||
'shopping_user_id' => $shopping_user->id,
|
||||
'auth_user_id' => $shopping_user->auth_user_id,
|
||||
|
|
@ -75,7 +73,7 @@ class CheckoutRepository extends BaseRepository
|
|||
'shipping_net' => 0,
|
||||
'subtotal_ws' => $ShoppingCollectOrder->price_total_net,
|
||||
'tax' => $ShoppingCollectOrder->tax_total,
|
||||
'tax_split' => $ShoppingCollectOrder->tax_split,
|
||||
'tax_split' => $ShoppingCollectOrder->tax_split,
|
||||
'total_shipping' => Yard::instance($this->instance)->totalWithShipping(2, '.', ''),
|
||||
'points' => round($ShoppingCollectOrder->points, 2),
|
||||
'weight' => 0,
|
||||
|
|
@ -114,7 +112,7 @@ class CheckoutRepository extends BaseRepository
|
|||
$shopping_order->save();
|
||||
}
|
||||
}
|
||||
if (!$shopping_order) {
|
||||
if (! $shopping_order) {
|
||||
$shopping_order = ShoppingOrder::create($data);
|
||||
if ($shopping_user->is_from === 'collection' && $ShoppingCollectOrder) {
|
||||
$ShoppingCollectOrder->shopping_order_id = $shopping_order->id;
|
||||
|
|
@ -131,7 +129,7 @@ class CheckoutRepository extends BaseRepository
|
|||
$tax = $item->price - $price_net;
|
||||
$data = [
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
|
|
@ -153,20 +151,22 @@ class CheckoutRepository extends BaseRepository
|
|||
$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()) {
|
||||
if (! ShoppingOrderItem::where('shopping_order_id', $shopping_order->id)->where('row_id', $item->rowId)->count()) {
|
||||
|
||||
$price_net = Yard::instance($this->instance)->rowPriceNet($item, 2, '.', '');
|
||||
$tax = $item->price - $price_net;
|
||||
|
||||
$data = [
|
||||
'shopping_order_id' => $shopping_order->id,
|
||||
'row_id' => $item->rowId,
|
||||
'row_id' => $item->rowId,
|
||||
'product_id' => $item->id,
|
||||
'comp' => $item->options->comp,
|
||||
'qty' => $item->qty,
|
||||
|
|
@ -177,7 +177,7 @@ class CheckoutRepository extends BaseRepository
|
|||
'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
|
||||
'slug' => $item->options->slug,
|
||||
];
|
||||
|
||||
if ($shopping_user->is_from === 'homeparty') {
|
||||
|
|
@ -196,16 +196,18 @@ class CheckoutRepository extends BaseRepository
|
|||
if ($shopping_user->is_from === 'homeparty') {
|
||||
$shopping_order->makeHomepartyTaxSplit();
|
||||
} elseif ($shopping_user->is_from === 'collection') {
|
||||
//is set on create / filll.
|
||||
// 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['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')) {
|
||||
|
|
@ -216,7 +218,7 @@ class CheckoutRepository extends BaseRepository
|
|||
$shopping_user->save();
|
||||
}
|
||||
}
|
||||
if (!$shopping_user) {
|
||||
if (! $shopping_user) {
|
||||
$shopping_user = ShoppingUser::create($data);
|
||||
}
|
||||
$this->putSessionPayments('shopping_user_id', $shopping_user->id);
|
||||
|
|
@ -240,6 +242,7 @@ class CheckoutRepository extends BaseRepository
|
|||
} else {
|
||||
$payment_methods['active'] = \App\Models\PaymentMethod::where('active', true)->get()->pluck('id', 'short')->toArray();
|
||||
}
|
||||
|
||||
return $payment_methods;
|
||||
}
|
||||
|
||||
|
|
@ -259,44 +262,46 @@ class CheckoutRepository extends BaseRepository
|
|||
public function makeCustomerShoppingUser($shopping_data, $is_for, $is_from)
|
||||
{
|
||||
// $shopping_user = ShoppingUser::findOrFail($shopping_data['shopping_user_id']);
|
||||
$shopping_user = new ShoppingUser();
|
||||
$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->same_as_billing = $shopping_user->same_as_billing ? false : true; // reinvert
|
||||
// $shopping_user->id = null;
|
||||
$shopping_user->accepted_data_checkbox = 1;
|
||||
$shopping_user->is_for = $is_for;
|
||||
$shopping_user->is_from = $is_from;
|
||||
$shopping_user->mode = 'prev';
|
||||
$shopping_user->language = \App::getLocale();
|
||||
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public function initShoppingUser($is_for, $is_from, $homeparty_id = null)
|
||||
{
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user = new ShoppingUser;
|
||||
$shopping_user->homeparty_id = $homeparty_id;
|
||||
$shopping_user->language = \App::getLocale();
|
||||
//eingeloggter Kunde
|
||||
// eingeloggter Kunde
|
||||
if (\Auth::guard('customers')->check()) {
|
||||
$shopping_user = $this->shoppingUserByAuthCustomer(\Auth::guard('customers')->user());
|
||||
}
|
||||
//eingeloggter User Berater
|
||||
// eingeloggter User Berater
|
||||
if (\Auth::guard('user')->check()) {
|
||||
$shopping_user = $this->shoppingUserByAuthUser(\Auth::guard('user')->user(), $is_from, $is_for);
|
||||
}
|
||||
$shopping_user->mode = 'prev';
|
||||
$shopping_user->is_for = $is_for;
|
||||
$shopping_user->is_from = $is_from;
|
||||
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
public function shoppingUserByAuthCustomer(\App\Models\Customer $user)
|
||||
{
|
||||
|
||||
//clone shopping user!
|
||||
// clone shopping user!
|
||||
if ($user->shopping_user_id) {
|
||||
$find_shopping_user = ShoppingUser::find($user->shopping_user_id);
|
||||
if ($find_shopping_user) {
|
||||
|
|
@ -305,7 +310,7 @@ class CheckoutRepository extends BaseRepository
|
|||
$shopping_user->shipping_country_id = null;
|
||||
}
|
||||
} else {
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user = new ShoppingUser;
|
||||
$shopping_user->language = \App::getLocale();
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +320,7 @@ class CheckoutRepository extends BaseRepository
|
|||
public function shoppingUserByAuthUser(\App\User $user, $is_from, $is_for)
|
||||
{
|
||||
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user = new ShoppingUser;
|
||||
$shopping_user->language = \App::getLocale();
|
||||
|
||||
$shopping_user->billing_salutation = $user->account->salutation;
|
||||
|
|
@ -326,16 +331,16 @@ class CheckoutRepository extends BaseRepository
|
|||
$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_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->language = $user->account->getLocale();
|
||||
|
||||
$shopping_user->accepted_data_checkbox = 1;
|
||||
|
||||
|
||||
//Lieferadresse
|
||||
// Lieferadresse
|
||||
$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;
|
||||
|
|
@ -345,11 +350,10 @@ class CheckoutRepository extends BaseRepository
|
|||
$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_country_id = $user->account->shipping_country_id;
|
||||
$shopping_user->shipping_phone = $user->account->shipping_phone;
|
||||
$shopping_user->shipping_postnumber = $user->account->shipping_postnumber;
|
||||
|
||||
|
||||
return $shopping_user;
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +361,7 @@ class CheckoutRepository extends BaseRepository
|
|||
{
|
||||
|
||||
$user = Util::getAuthUser();
|
||||
$shopping_user = new ShoppingUser();
|
||||
$shopping_user = new ShoppingUser;
|
||||
$shopping_user->auth_user_id = $user->id;
|
||||
$shopping_user->mode = 'prev';
|
||||
$shopping_user->language = \App::getLocale();
|
||||
|
|
@ -375,6 +379,7 @@ class CheckoutRepository extends BaseRepository
|
|||
$shopping_user->billing_email = $user->email;
|
||||
$shopping_user->faker_mail = false;
|
||||
$shopping_user->shipping_email = $user->email;
|
||||
$shopping_user->language = $user->account->getLocale();
|
||||
|
||||
$shopping_user->accepted_data_checkbox = 1;
|
||||
$shopping_user->is_for = $is_for;
|
||||
|
|
@ -382,7 +387,7 @@ class CheckoutRepository extends BaseRepository
|
|||
$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
|
||||
// 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']);
|
||||
|
|
@ -399,7 +404,7 @@ class CheckoutRepository extends BaseRepository
|
|||
$shopping_user->billing_email = $s_user->billing_email;
|
||||
;*/
|
||||
$shopping_user->faker_mail = $s_user->faker_mail;
|
||||
if (!$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'];
|
||||
|
|
@ -449,13 +454,14 @@ class CheckoutRepository extends BaseRepository
|
|||
if ($content->has($key)) {
|
||||
return $content->get($key);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function sessionDestroy($with_shopping = false)
|
||||
{
|
||||
if ($with_shopping) {
|
||||
if (session('user_shop_payment') === 1) { //ShoppingInstance payment 1 = webshop
|
||||
if (session('user_shop_payment') === 1) { // ShoppingInstance payment 1 = webshop
|
||||
Yard::instance('webshop')->destroy();
|
||||
} else {
|
||||
Yard::instance('shopping')->destroy();
|
||||
|
|
@ -469,6 +475,7 @@ class CheckoutRepository extends BaseRepository
|
|||
if (is_null($this->session->get($this->instance))) {
|
||||
return new Collection([]);
|
||||
}
|
||||
|
||||
return $this->session->get($this->instance);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue