1. POSTBonus in/out
2. POSTPresale in/out
3. Переработана форма гостя
This commit is contained in:
miroman-afk
2022-12-14 12:42:39 +03:00
parent 4d3ad7727d
commit d24bba305f
49 changed files with 2525 additions and 772 deletions

View File

@@ -9,93 +9,92 @@ use App\Component\Models\Staff;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETOnlineStaff extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getonlinestaff';
class GETOnlineStaff extends HRCCommand implements HRCCommandInterface
{
protected $signature = 'getonlinestaff';
public function command($input, $output = null) {
function staffName($data) {
$staff_name = Staff::where('code', $data)->where('is_history', 0)->first();
if ($staff_name) {
$staff_name = $staff_name['name'];
} else {
$staff_name = Staff::where('code', $data)->where('is_history', 1)->first();
if ($staff_name) {
$staff_name = $staff_name['name'];
} else {
$staff_name = 'Связанный персонал не найден';
}
}
return $staff_name;
}
if ($input['method'] == 'dashboard') {
$staff_data = [];
$staffs = ShiftOnlineOrders::select('who_open')
->where('is_deleted', 0)
->where('is_returned', 0)
->where('order_sum', '>', 0)
->groupBy('who_open')
->get();
foreach ($staffs as $key => $staff) {
$count = ShiftOnlineOrders::where('who_open', $staff['who_open'])
->where('is_deleted', 0)
->where('is_returned', 0)
->where('order_sum', '>', 0)
->count();
$name = staffName($staff['who_open']);
$code = $staff['who_open'];
$sum = ShiftOnlineOrders::where('who_open', $staff['who_open'])
->where('is_deleted', 0)
->where('is_returned', 0)
->where('order_sum', '>', 0)
->sum('order_sum');
$staff_data[] = array('name' => $name, 'code' => $code + 0, 'orders_count' => $count + 0, 'orders_sum' => $sum + 0);
}
public function command($input, $output = null)
{
if ($input['method'] == 'dashboard') {
$staff_data = [];
$staffs = ShiftOnlineOrders::select('who_open')
->where('is_deleted', 0)
->where('is_returned', 0)
->where('order_sum', '>', 0)
->groupBy('who_open')
->get();
foreach ($staffs as $staff) {
$count = ShiftOnlineOrders::where('who_open', $staff['who_open'])
->where('is_deleted', 0)
->where('is_returned', 0)
->where('order_sum', '>', 0)
->count();
$name = Staff::getName($staff['who_open']);
$code = $staff['who_open'];
$sum = ShiftOnlineOrders::where('who_open', $staff['who_open'])
->where('is_deleted', 0)
->where('is_returned', 0)
->where('order_sum', '>', 0)
->sum('order_sum');
$staff_data[] = array(
'name' => $name,
'code' => $code + 0,
'orders_count' => $count + 0,
'orders_sum' => $sum + 0
);
}
return [
'status' => 'success',
'staff' => $staff_data,
];
}
if ($input['method'] == 'items') {
if (isset($input['order'])) {
$orderId = $input['order'] + 0;
$items = [];
$order = ShiftOnlineOrders::where('code', $orderId)->first();
$who_open = staffName($order['who_open']);
if ($order['who_close'] == 0) {
$who_close = '-';
} else {
$who_close = staffName($order['who_close']);
}
return [
'status' => 'success',
'staff' => $staff_data,
];
}
if ($input['method'] == 'items') {
if (isset($input['order'])) {
$orderId = $input['order'] + 0;
$items = [];
$order = ShiftOnlineOrders::where('code', $orderId)->first();
$who_open = Staff::getName($order['who_open']);
if ($order['who_close'] == 0) {
$who_close = '-';
} else {
$who_close = Staff::getName($order['who_close']);
}
$onlineItems = ShiftOnlineItems::where('order_code', $order['code'])->where('modificator_code', 0)->get();
foreach ($onlineItems as $key => $item) {
$realPrice = $item['real_price'] * $item['count'] * $item['cof'];
$salePrice = $item['sale_price'] * $item['count'];
if ($realPrice > 0) {
$discount = $salePrice / $realPrice;
$discount = (1 - $discount) * 100;
} else {
$discount = 0;
}
$dish = Dishes::where('code', $item['dish_code'])->where('is_history', 0)->first();
$items[] = array('name' => $dish['name'], 'discount' => round($discount, 0), 'count' => $item['count'], 'sale_price' => $salePrice, 'sum' => round($realPrice, 2));
}
} else {
return [
'status' => 'success',
'message' => 'Проверьте введенные данные',
];
}
return [
'status' => 'success',
'who_open' => $who_open,
'who_close' => $who_close,
'title' => 'Подробнее о заказе №' . $order['code'],
'total' => $order['order_sum'],
'items' => $items,
];
}
$onlineItems = ShiftOnlineItems::where('order_code', $order['code'])->where('modificator_code', 0)->get();
foreach ($onlineItems as $item) {
$realPrice = $item['real_price'] * $item['count'] * $item['cof'];
$salePrice = $item['sale_price'] * $item['count'];
if ($realPrice > 0) {
$discount = $salePrice / $realPrice;
$discount = (1 - $discount) * 100;
} else {
$discount = 0;
}
$dish_name = Dishes::getName($item['menu_code']);
$items[] = array(
'name' => $dish_name,
'discount' => round($discount, 0),
'count' => $item['count'],
'sale_price' => $salePrice,
'sum' => round($realPrice, 2)
);
}
} else {
return [
'status' => 'success',
'message' => 'Проверьте введенные данные',
];
}
return [
'status' => 'success',
'who_open' => $who_open,
'who_close' => $who_close,
'title' => 'Подробнее о заказе №' . $order['code'],
'total' => $order['order_sum'],
'items' => $items,
];
}
}
}
}