Discounts block update
This commit is contained in:
miroman-afk
2022-04-28 23:55:53 +03:00
parent 53dfb77d7a
commit 2d148e3eb5
9 changed files with 169 additions and 22 deletions

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Commands;
use App\Component\Models\Dishes;
use App\Component\Models\ShiftOnlineItems;
use App\Component\Models\ShiftOnlineOrders;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETDiscountItems extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getdiscountitems';
public function command($input, $output = null) {
$orderId = $input['order'] + 0;
$items = [];
$order = ShiftOnlineOrders::where('code', $orderId)->first();
$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));
}
return [
'status' => 'success',
'title' => $order['code'],
'total' => $order['order_sum'],
'items' => $items,
];
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace App\Commands;
use App\Component\Models\ShiftOnlineOrders;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETMoreDiscount extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getmorediscount';
public function command($input, $output = null) {
$amountWithoutDiscount = 0;
$totalSum = 0;
$orderInfo = [];
$orders = ShiftOnlineOrders::where('is_deleted', 0)
->where('is_returned', 0)
->where('sale_sum', '>', 0)
->get();
if ($orders) {
foreach ($orders as $key => $order) {
$orderInfo[] = array('number' => $order['code'], 'full_sum' => $order['full_sum'], 'sale_sum' => $order['sale_sum'], 'order_sum' => $order['order_sum']);
$amountWithoutDiscount = $amountWithoutDiscount + $order['full_sum'];
$totalSum = $totalSum + $order['order_sum'];
}
}
return [
'status' => 'success',
'title' => 'Подробнее о заказах со скидками',
'amount' => $amountWithoutDiscount,
'total_sum' => $totalSum,
'orders' => $orderInfo,
];
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Commands;
use App\Component\Models\ShiftOnlineItems;
use App\Component\Models\ShiftOnlineOrders;
use App\Console\Commands\HRCCommand;
use App\Console\Commands\HRCCommandInterface;
class GETOnlineDiscount extends HRCCommand implements HRCCommandInterface {
protected $signature = 'getonlinediscount';
public function command($input, $output = null) {
$count = $totalSum = $discountSum = 0;
$count = ShiftOnlineOrders::where('is_deleted', 0)
->where('is_returned', 0)
->where('sale_sum', '>', 0)
->count();
if ($count > 0) {
$totalSum = ShiftOnlineOrders::where('is_deleted', 0)
->where('is_returned', 0)
->where('sale_sum', '>', 0)
->sum('order_sum');
$orders = ShiftOnlineOrders::where('is_deleted', 0)
->where('is_returned', 0)->get();
foreach ($orders as $key => $order) {
$items = ShiftOnlineItems::where('order_code', $order['code'])->get();
foreach ($items as $key => $item) {
$realPrice = $item['real_price'] * $item['count'] * $item['cof'];
$salePrice = $item['sale_price'] * $item['count'];
$discountSum = round(($discountSum + abs($salePrice - $realPrice)), 2);
}
}
}
return [
'status' => 'success',
'count' => $count,
'sum' => $discountSum,
'total_sum' => $totalSum,
];
}
}

View File

@@ -173,7 +173,18 @@ class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
foreach ($slice_order_items as $key => $slice_order_item) {
$slice_items[] = array('id' => $key + 1, 'name' => $slice_order_item['name'], 'count' => $slice_order_item['count']);
}
$sliced_order_items[] = array('order' => $slice_order, 'items' => $slice_items);
$staff_name = Staff::where('code', $item['who'])->where('is_history', 0)->first();
if ($staff_name) {
$staff_name = $staff_name['name'];
} else {
$staff_name = Staff::where('code', $item['who'])->where('is_history', 1)->first();
if ($staff_name) {
$staff_name = $staff_name['name'];
} else {
$staff_name = 'Связанный персонал не найден';
}
}
$sliced_order_items[] = array('order' => $slice_order, 'time' => date('d.m.Y H:i:s', strtotime($item['time'])), 'staff' => $staff_name, 'items' => $slice_items);
$slice_trigger = 1;
}
}
@@ -219,7 +230,18 @@ class GETOrderHistory extends HRCCommand implements HRCCommandInterface {
'name' => $merged_item['name'],
'count' => $merged_item['count']);
}
$merged_order_items[] = array('order' => $merge_order, 'items' => $merge_items);
$staff_name = Staff::where('code', $item['who'])->where('is_history', 0)->first();
if ($staff_name) {
$staff_name = $staff_name['name'];
} else {
$staff_name = Staff::where('code', $item['who'])->where('is_history', 1)->first();
if ($staff_name) {
$staff_name = $staff_name['name'];
} else {
$staff_name = 'Связанный персонал не найден';
}
}
$merged_order_items[] = array('order' => $merge_order, 'time' => date('d.m.Y H:i:s', strtotime($item['time'])), 'staff' => $staff_name, 'items' => $merge_items);
}
}
}

View File

@@ -392,7 +392,7 @@
$scope.deleted_sum = Math.roundNG(data.sum, -2);
});
smartRequest.get('dashboard/online/discount', function (data) {
smartRequest.get('v1/onlinediscount', function (data) {
$scope.discounts = Math.roundNG(data.count, -2);
$scope.discounts_sum = Math.roundNG(data.sum, -2);
$scope.tot_disc_sum = Math.roundNG(data.total_sum, -2);
@@ -555,7 +555,7 @@
$scope.deleted_sum = Math.roundNG(data.sum, -2);
});
smartRequest.get('dashboard/online/discount', function (data) {
smartRequest.get('v1/onlinediscount', function (data) {
$scope.discounts = Math.roundNG(data.count, -2);
$scope.discounts_sum = Math.roundNG(data.sum, -2);
$scope.tot_disc_sum = Math.roundNG(data.total_sum, -2);
@@ -715,6 +715,13 @@
});
};
$scope.getMoreDiscount = function () {
smartRequest.get('v1/morediscount/', function (data) {
$scope.moreData = data;
$('#get-more-discount').modal();
});
};
$scope.getItems = function (modal, order) {
$('#get-more-' + modal).modal('toggle');
smartRequest.get('dashboard/' + modal + '/items?order=' + order.number, function (data) {
@@ -723,6 +730,14 @@
});
};
$scope.getItemsDiscount = function (order) {
$('#get-more-discount').modal('toggle');
smartRequest.get('v1/discountitems?order=' + order.number, function (data) {
$scope.order = data;
$('#items-discount').modal('toggle');
});
};
$scope.returnModal = function (name) {
$('#items-' + name).on('hidden.bs.modal', function (event) {
$('#get-more-' + name).modal('show');
@@ -735,7 +750,6 @@
$scope.order = data;
smartRequest.get('v1/orderhistory?order_id=' + order.number, function (actions) {
$scope.actions = actions;
console.log(actions);
});
$('#items-total').modal('toggle');
});

View File

@@ -143,7 +143,7 @@
<div class="box-tool box-tool-white">
<ul class="nav">
<li class="nav-item">
<a ng-click="getMore('discount')">
<a ng-click="getMoreDiscount()">
<i class="fa fa-eye"></i>
</a>
</li>
@@ -531,20 +531,6 @@
</div>
</div>
<div class="col-md-12 col-xl-4">
<div class="box">
<div class="box-header">
<h3>Типы меню</h3>
</div>
<div class="box-body">
<div class="box-body">
<canvas class="chart chart-pie" chart-data="menus.data" chart-labels="menus.labels" chart-options="menus.options"></canvas>
</div>
</div>
</div>
</div>
<div class="col-md-12 col-xl-4">
<div class="box">
<div class="box-header">

View File

@@ -14,6 +14,7 @@
<th>Блюдо (со скидкой)</th>
<th>Количество</th>
<th class="text-right">Цена, BYN</th>
<th class="text-right">Cкидка, BYN</th>
<th class="text-right">Сумма, BYN</th>
</tr>
</thead>
@@ -21,8 +22,9 @@
<tr ng-repeat="item in order.items">
<td>{{ item.name }} ({{ item.discount }}%)</td>
<td>{{ item.count }}</td>
<td class="text-right">{{ item.sale_price | curr }}</td>
<td class="text-right">{{ item.sum | curr }}</td>
<td class="text-right">{{ (item.sum * item.discount) / 100 | curr }}</td>
<td class="text-right">{{ item.sale_price | curr }}</td>
</tr>
</tbody>
<thead>

View File

@@ -99,6 +99,8 @@
<!--Разбиение заказа-->
<div ng-if="actions.slice_trigger == 1" class="tab-pane animated fadeIn text-muted" id="tab3" aria-expanded="false">
<div ng-repeat="sliced_order_item in actions.sliced_order_items">
<p class="text-muted m-b-0">Время разбиения: <span class="m-b-0">{{ sliced_order_item.time }}</span></p>
<p class="text-muted m-b-0">Пользователь: <span class="m-b-0">{{ sliced_order_item.staff }}</span></p>
<p class="text-muted m-b-0">Товары перенесенные в заказ №<span class="m-b-0">{{ sliced_order_item.order }}</span></p>
<div class="table-responsive">
<table class="table m-a-0">
@@ -122,7 +124,10 @@
<!--Объединение заказа-->
<div ng-if="actions.merge_trigger == 1" class="tab-pane animated fadeIn text-muted" id="tab4" aria-expanded="false">
<div ng-repeat="merged_order_item in actions.merged_order_items">
<p class="text-muted m-b-0">Время объединения: <span class="m-b-0">{{ merged_order_item.time }}</span></p>
<p class="text-muted m-b-0">Пользователь: <span class="m-b-0">{{ merged_order_item.staff }}</span></p>
<p class="text-muted m-b-0">Товары перенесенные из заказа №<span class="m-b-0">{{ merged_order_item.order }}</span></p>
<div class="table-responsive">
<table class="table m-a-0">
<thead>

View File

@@ -17,7 +17,7 @@
</thead>
<tbody>
<tr ng-repeat="order in moreData.orders" ng-click="getItems('discount', order)">
<tr ng-repeat="order in moreData.orders" ng-click="getItemsDiscount(order)">
<td>{{ order.number }}</td>
<td class="text-right">{{ order.full_sum | curr }}</td>
<td class="text-right">{{ order.sale_sum | curr }}</td>