Sammelbestellung von Extern

This commit is contained in:
Kevin Adametz 2022-07-18 18:07:31 +02:00
parent d01b4bd560
commit 582ca8299d
33 changed files with 3437 additions and 1466 deletions

View file

@ -3,26 +3,27 @@
namespace App\Http\Controllers\Web;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Pay\PayoneController;
use App\Models\Homeparty;
use App\Models\PaymentMethod;
use App\Models\PaymentTransaction;
use App\Models\ShippingCountry;
use App\Models\ShoppingOrder;
use App\Models\ShoppingOrderItem;
use App\Models\ShoppingPayment;
use App\Models\ShoppingUser;
use App\Services\CustomerPriority;
use App\Services\Payment;
use App\Services\Shop;
use App\User;
use Illuminate\Session\SessionManager;
use Illuminate\Support\Collection;
use Validator;
use App\Services\Util;
use Yard;
use Request;
use App\User;
use Validator;
use App\Services\Shop;
use App\Services\Util;
use App\Models\Homeparty;
use App\Services\Payment;
use App\Models\ShoppingUser;
use App\Models\PaymentMethod;
use App\Models\ShoppingOrder;
use App\Models\ShippingCountry;
use App\Models\ShoppingPayment;
use App\Models\ShoppingOrderItem;
use App\Models\PaymentTransaction;
use App\Services\CustomerPriority;
use Illuminate\Support\Collection;
use App\Http\Controllers\Controller;
use App\Models\ShoppingCollectOrder;
use Illuminate\Session\SessionManager;
use App\Http\Controllers\Pay\PayoneController;
class CheckoutController extends Controller
{
@ -67,7 +68,7 @@ class CheckoutController extends Controller
if(!$this->getPayments('shopping_user_id')){
if($shopping_data && $is_from !== 'shopping'){
//can wizard membership user_order
//can wizard membership user_order
//$shopping_user_id = isset($shopping_data['shopping_user_id']) ? $shopping_data['shopping_user_id'] : false;
$shopping_user = $this->shoppingUserAuthData($is_from, $is_for, $shopping_data);
$shopping_user->save();
@ -177,6 +178,7 @@ class CheckoutController extends Controller
$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'){
@ -508,6 +510,30 @@ class CheckoutController extends Controller
'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(),
'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,
@ -539,6 +565,10 @@ class CheckoutController extends Controller
}
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->putPayments('shopping_order_id', $shopping_order->id);
@ -567,6 +597,10 @@ class CheckoutController extends Controller
$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;
}
@ -597,14 +631,21 @@ class CheckoutController extends Controller
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();
}