From: Vladimir Fomichev Date: Mon, 8 Dec 2025 06:56:58 +0000 (+0300) Subject: Корректировка общего отчета и подсчтета недель X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=cc86fbbafe5131459f9207d9696f5403c40bd0ae;p=erp24_rep%2Fyii-erp24%2F.git Корректировка общего отчета и подсчтета недель --- 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],