65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
namespace App\Services\SyS;
|
|
|
|
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;
|
|
|
|
class ShoppingOrders
|
|
{
|
|
|
|
public static function show()
|
|
{
|
|
abort(403, 'STOP funtion not online');
|
|
|
|
$shopping_users = ShoppingUser::all();
|
|
$data = [
|
|
'values' => $shopping_users,
|
|
'text' => '',
|
|
];
|
|
return view('sys.tools.shopping-orders', $data);
|
|
}
|
|
|
|
|
|
public static function store()
|
|
{
|
|
abort(403, 'STOP funtion not online');
|
|
dd("");
|
|
|
|
|
|
$data = Request::all();
|
|
|
|
if($data['action'] === 'first_run'){
|
|
$shopping_users = ShoppingUser::whereHas('shopping_order', function($q) {
|
|
$q->where('txaction', 'paid')->OrWhere('txaction', 'appointed');
|
|
})->get();
|
|
|
|
$order_email = [];
|
|
$order_number = [];
|
|
|
|
foreach ($shopping_users as $shopping_user){
|
|
$order_email[$shopping_user->billing_email] = isset($order_email[$shopping_user->billing_email]) ? $order_email[$shopping_user->billing_email] + 1 : 1;
|
|
if($shopping_user->number) {
|
|
$order_number[$shopping_user->number] = isset($order_number[$shopping_user->number]) ? $order_number[$shopping_user->number] + 1 : 1;
|
|
$shopping_user->orders = $order_number[$shopping_user->number];
|
|
}else {
|
|
$shopping_user->orders = $order_email[$shopping_user->billing_email];
|
|
}
|
|
$shopping_user->save();
|
|
|
|
}
|
|
\Session()->flash('alert-save', true);
|
|
}
|
|
|
|
if($data['action'] === 'next_run'){
|
|
ShoppingUserService::snycOrdersByShoppingUser($shopping_user);
|
|
\Session()->flash('alert-save', true);
|
|
}
|
|
return back();
|
|
}
|
|
|
|
}
|