From cc86fbbafe5131459f9207d9696f5403c40bd0ae Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Mon, 8 Dec 2025 09:56:58 +0300 Subject: [PATCH] =?utf8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=B8?= =?utf8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BE=D0=B1=D1=89=D0=B5=D0=B3?= =?utf8?q?=D0=BE=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=D0=B0=20=D0=B8=20=D0=BF?= =?utf8?q?=D0=BE=D0=B4=D1=81=D1=87=D1=82=D0=B5=D1=82=D0=B0=20=D0=BD=D0=B5?= =?utf8?q?=D0=B4=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api3/core/services/ReportService.php | 38 ++++++++++++++-------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/erp24/api3/core/services/ReportService.php b/erp24/api3/core/services/ReportService.php index 11555bb5..1f0e71c4 100644 --- a/erp24/api3/core/services/ReportService.php +++ b/erp24/api3/core/services/ReportService.php @@ -432,16 +432,8 @@ class ReportService ]; } - // Подсчет должностей на смене для этого дня + // Подсчет должностей на смене для этого дня (используется для информации по дню) $employeePositionsOnShift = $this->countEmployeesByPosition($timetables, $positionMap); - - // Суммируем для общего отчета - foreach ($employeePositionsOnShift as $positionName => $count) { - if (!isset($totalEmployeePositionsOnShift[$positionName])) { - $totalEmployeePositionsOnShift[$positionName] = 0; - } - $totalEmployeePositionsOnShift[$positionName] += $count; - } $adminPayrollDaysMonth = AdminPayrollDays::find()->select(["FLOOR(SUM(day_payroll)) as total", "store_id"]) ->where(['>=', 'date', date("Y-m-01", strtotime($currentDate))]) @@ -886,6 +878,16 @@ class ReportService $totalEmployeeSkillsScore = round(array_sum($totalEmployeeSkillsScores) / count($totalEmployeeSkillsScores), 1); } + // Агрегируем сотрудников по магазинам без дедупликации + $totalEmployeePositionsOnShift = []; + $totalEmployeeCountOnShift = 0; + foreach ($report["stores"] as $storeData) { + $totalEmployeeCountOnShift += $storeData["employee_count_on_shift"]; + foreach ($storeData["employee_positions_on_shift"] as $positionName => $count) { + $totalEmployeePositionsOnShift[$positionName] = ($totalEmployeePositionsOnShift[$positionName] ?? 0) + $count; + } + } + $report['total'] = [ "sale_total" => $storeSaleTotalTotal, "sale_quantity" => $storeSaleQuantityTotal, @@ -912,9 +914,9 @@ class ReportService "total_wrap_per_day" => $totalWrapPerDayTotal, "total_services_per_day" => $totalServicePerDayTotal, "total_potted_per_day" => $totalPottedPerDayTotal, - "employee_positions_on_shift" => $employeePositionsOnShift, + "employee_positions_on_shift" => $totalEmployeePositionsOnShift, "employee_skills_score" => $totalEmployeeSkillsScore, - "employee_count_on_shift" => count($timetables), + "employee_count_on_shift" => $totalEmployeeCountOnShift, ]; // Создаем итоговый массив для дня с правильным порядком полей @@ -1369,6 +1371,16 @@ class ReportService $total["total_services_per_day"] = ($total["total_services_per_day"] ?? 0) + ($totalServicePerDayTotal[$store_id] ?? 0); $total["total_potted_per_day"] = ($total["total_potted_per_day"] ?? 0) + ($totalPottedPerDayTotal[$store_id] ?? 0); } + + // Суммы по всем магазинам без дедупликации сотрудников + $totalEmployeePositionsOnShift = []; + foreach ($stores as $storeData) { + foreach ($storeData['data']['employee_positions_on_shift'] as $position => $count) { + $totalEmployeePositionsOnShift[$position] = ($totalEmployeePositionsOnShift[$position] ?? 0) + $count; + } + } + $totalEmployeeCountOnShift = array_sum($employeeCount); + $total["sale_avg"] = $total["sale_quantity"] > 0 ? floor($total["sale_total"] / $total["sale_quantity"]) : 0; $total["total_write_offs_per_date_percent"] = $total["sale_total"] > 0 ? floor($total["total_write_offs_per_date"] / $total["sale_total"] * 100) : 0; $total["total_write_offs_per_month_percent"] = $total["sale_month_total"] > 0 ? floor($total["total_write_offs_per_month"] / $total["sale_month_total"] * 100) : 0; @@ -1377,8 +1389,8 @@ class ReportService $total["employee_sale_avg"] = $employeeCountTotal > 0 ? floor($total["sale_total"] / $employeeCountTotal) : 0; $total["conversion"] = $total["visitors_quantity"] > 0 ? floor($total["sale_quantity"] / $total["visitors_quantity"] * 100) : 0;; $total["bonus_user_per_sale_percent"] = $total["sale_quantity"] > 0 ? floor($total["bonus_user_count"] / $total["sale_quantity"] * 100) : 0; - $total["employee_positions_on_shift"] = $employeePositionsOnShift; - $total["employee_count_on_shift"] = count($weekEmployees); + $total["employee_positions_on_shift"] = $totalEmployeePositionsOnShift; + $total["employee_count_on_shift"] = $totalEmployeeCountOnShift; $report = [ "date_from" => $dateStartEnd[0], -- 2.39.5