v.2.2 Update

Top dishes block update
This commit is contained in:
miroman-afk
2021-11-18 10:59:38 +03:00
parent 276576f007
commit 1a7808f75b
6 changed files with 185 additions and 12 deletions

View File

@@ -19,20 +19,18 @@ class TopDishes extends HRCCommand implements HRCCommandInterface {
$out[] = $value;
}
foreach ($out as $key => $item) {
$dishInfo = Dishes::select('name')
->where('code', '=', $item['menu_code'])
$dishInfo = Dishes::where('code', '=', $item['menu_code'])
->where('legacy_code', '=', $item['dish_code'])
->where('is_history', '=', 0)
->get();
$onlineDishInfo = OnlineItems::select('real_price', 'sale_price', 'special_price')
->where('menu_code', '=', $item['menu_code'])
->first();
$onlineDishInfo = OnlineItems::where('menu_code', '=', $item['menu_code'])
->where('dish_code', '=', $item['dish_code'])
->get();
$dishName = $dishInfo[0]->name;
->first();
$dishName = $dishInfo['name'];
$dishCount = OnlineItems::where('menu_code', '=', $item['menu_code'])->sum('count');
$dishSum = $onlineDishInfo[0]->real_price * $dishCount;
$dishSum = $onlineDishInfo['real_price'] * $dishCount;
if ($dishSum > 0) {
$dishTotalCost = round(($onlineDishInfo[0]->special_price * $dishCount), 2);
$dishTotalCost = round(($onlineDishInfo['special_price'] * $dishCount), 2);
$dishPercent = round((100 - ((($dishSum - $dishTotalCost) * 100) / $dishSum)), 2);
$dishProfit = $dishSum - $dishTotalCost;
} else {