gogs 2 месяцев назад
Родитель
Сommit
f4591a8cf5
1 измененных файлов с 9 добавлено и 1 удалено
  1. 9 1
      app/Service/StatisticService.php

+ 9 - 1
app/Service/StatisticService.php

@@ -468,6 +468,15 @@ class StatisticService extends Service
                 $salary_map[$val['employee_id'] . '_' . $month] = $val['salary'];
             }
         }
+        // 2. 计算每个员工在每个月的全月总工时
+        $employee_monthly_total_min = [];
+        foreach ($month_employee_list as $row) {
+            $key = $row['employee_id'] . '_' . $row['order_month'];
+            if (!isset($employee_monthly_total_min[$key])) {
+                $employee_monthly_total_min[$key] = 0;
+            }
+            $employee_monthly_total_min[$key] += $row['total_work'];
+        }
 
         // 2. 计算分摊天数与工资
         $item_list = [];
@@ -482,7 +491,6 @@ class StatisticService extends Service
             $total_salary = $salary_map[$key] ?? 0;
             $total_min = $employee_monthly_total_min[$key] ?? 0;
 
-
             // B. 计算工资分摊:(项目工时 / 月总工时) * 月工资
             if ($total_min > 0) {
                 $ratio = $item['total_work'] / $total_min;