瀏覽代碼

改一下bug

gogs 2 月之前
父節點
當前提交
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'];
                 $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. 计算分摊天数与工资
         // 2. 计算分摊天数与工资
         $item_list = [];
         $item_list = [];
@@ -482,7 +491,6 @@ class StatisticService extends Service
             $total_salary = $salary_map[$key] ?? 0;
             $total_salary = $salary_map[$key] ?? 0;
             $total_min = $employee_monthly_total_min[$key] ?? 0;
             $total_min = $employee_monthly_total_min[$key] ?? 0;
 
 
-
             // B. 计算工资分摊:(项目工时 / 月总工时) * 月工资
             // B. 计算工资分摊:(项目工时 / 月总工时) * 月工资
             if ($total_min > 0) {
             if ($total_min > 0) {
                 $ratio = $item['total_work'] / $total_min;
                 $ratio = $item['total_work'] / $total_min;