v.2.27
Fixed reports
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
namespace App\Commands;
|
||||
|
||||
use App\Component\Models\Dishes;
|
||||
use App\Component\Models\OnlineItems;
|
||||
use App\Component\Models\ShiftOnlineItems;
|
||||
use App\Component\Models\ShiftOnlineOrders;
|
||||
use App\Component\Models\Terminal;
|
||||
use App\Console\Commands\HRCCommand;
|
||||
use App\Console\Commands\HRCCommandInterface;
|
||||
@@ -18,8 +19,21 @@ class GETTopDishes extends HRCCommand implements HRCCommandInterface {
|
||||
} else {
|
||||
$terminalKey = 0;
|
||||
}
|
||||
$info = OnlineItems::where('menu_code', '>', 0)->get()->unique('menu_code');
|
||||
$count = OnlineItems::where('menu_code', '>', 0)->count();
|
||||
$allOrders = ShiftOnlineOrders::select('code')
|
||||
->where('is_closed', 1)
|
||||
->where('is_returned', 0)
|
||||
->where('is_deleted', 0)
|
||||
->get();
|
||||
foreach ($allOrders as $order) {
|
||||
$orders[] = array($order['code']);
|
||||
}
|
||||
$info = ShiftOnlineItems::where('menu_code', '>', 0)
|
||||
->whereIn('order_code', $orders)
|
||||
->get()
|
||||
->unique('menu_code');
|
||||
$count = ShiftOnlineItems::where('menu_code', '>', 0)
|
||||
->whereIn('order_code', $orders)
|
||||
->count();
|
||||
if ($count > 0) {
|
||||
foreach ($info as $key => $value) {
|
||||
$out[] = $value;
|
||||
@@ -29,18 +43,22 @@ class GETTopDishes extends HRCCommand implements HRCCommandInterface {
|
||||
->where('legacy_code', '=', $item['dish_code'])
|
||||
->where('is_history', '=', 0)
|
||||
->first();
|
||||
$onlineDishInfo = OnlineItems::where('menu_code', '=', $item['menu_code'])
|
||||
$onlineDishInfo = ShiftOnlineItems::where('menu_code', '=', $item['menu_code'])
|
||||
->where('dish_code', '=', $item['dish_code'])
|
||||
->whereIn('order_code', $orders)
|
||||
->first();
|
||||
if ($dishInfo['name'] == '') {
|
||||
$dishHistInfo = Dishes::where('code', '=', $item['menu_code'])
|
||||
->where('legacy_code', '=', $item['dish_code'])
|
||||
->whereIn('order_code', $orders)
|
||||
->first();
|
||||
$dishName = $dishHistInfo['name'];
|
||||
} else {
|
||||
$dishName = $dishInfo['name'];
|
||||
}
|
||||
$dishCount = OnlineItems::where('menu_code', '=', $item['menu_code'])->sum('count');
|
||||
$dishCount = ShiftOnlineItems::where('menu_code', '=', $item['menu_code'])
|
||||
->whereIn('order_code', $orders)
|
||||
->sum('count');
|
||||
$dishSum = $onlineDishInfo['real_price'] * $dishCount;
|
||||
if ($dishSum > 0) {
|
||||
$dishTotalCost = round(($onlineDishInfo['special_price'] * $dishCount), 2);
|
||||
|
||||
Reference in New Issue
Block a user