Parcourir la source

Merge remote-tracking branch 'origin/master'

cqp il y a 1 mois
Parent
commit
239b618152
1 fichiers modifiés avec 63 ajouts et 58 suppressions
  1. 63 58
      app/Service/StatisticService.php

+ 63 - 58
app/Service/StatisticService.php

@@ -350,31 +350,25 @@ class StatisticService extends StatisticCommonService
             return $group->count();
             return $group->count();
         })->toArray();
         })->toArray();
 
 
-        $month_employee_list = $collect->transform(function ($item) use (&$employee_count,&$salary_map) {
+        $sums = [
+            "salary_map" => $salary_map
+        ];
+        $employee_counts = [
+            "salary_map" => $employee_count
+        ];
+        $word_keys = [
+            "salary_map" => [
+                "key" => "allocated_salary",
+                "value" => "allocated_salary",
+                "type" => "money",
+            ]
+        ];
+
+        $month_employee_list = $collect->transform(function ($item) use (&$employee_counts,&$sums,$word_keys) {
 
 
             // 如果不是最后一条
             // 如果不是最后一条
             $key = $item['employee_id'] . '_' . $item['month'];
             $key = $item['employee_id'] . '_' . $item['month'];
-            $sums = [
-                "salary_map" => $salary_map
-            ];
-            $word_keys = [
-                "salary_map" => [
-                    "key" => "allocated_salary",
-                    "value" => "allocated_salary",
-                    "type" => "money",
-                ]
-            ];
-            $this->calculateClosure($key,$item,$employee_count,$sums,$word_keys);
-
-//            if(!isset($all_salary[$key])) $item['allocated_salary'] = 0;
-//            else{
-//                if (--$employee_count[$key] > 0) {
-//                    $all_salary[$key] -= $item['allocated_salary'];
-//                } else {
-//                    $item['allocated_salary'] = $all_salary[$key];
-//                }
-//            }
-
+            $this->calculateClosure($key,$item,$employee_counts,$sums,$word_keys);
             return $item;
             return $item;
         })->all();
         })->all();
 
 
@@ -407,21 +401,25 @@ class StatisticService extends StatisticCommonService
             return $group->count();
             return $group->count();
         })->toArray();
         })->toArray();
 
 
-        $month_employee_list = $collect->transform(function ($item) use (&$device_count,&$month_device_salary) {
+        $sums = [
+            "salary_map" => $month_device_salary
+        ];
+        $word_keys = [
+            "salary_map" => [
+                "key" => "allocated_depreciation",
+                "value" => "allocated_depreciation",
+                "type" => "money",
+            ]
+        ];
+        $device_counts = [
+            "salary_map" => $device_count
+        ];
+        $month_employee_list = $collect->transform(function ($item) use (&$device_counts,&$sums,$word_keys) {
 
 
             // 如果不是最后一条
             // 如果不是最后一条
             $key = $item['device_id'] . '_' . $item['month'];
             $key = $item['device_id'] . '_' . $item['month'];
-            $sums = [
-                "salary_map" => $month_device_salary
-            ];
-            $word_keys = [
-                "salary_map" => [
-                    "key" => "allocated_depreciation",
-                    "value" => "allocated_depreciation",
-                    "type" => "money",
-                ]
-            ];
-            $this->calculateClosure($key,$item,$device_count,$sums,$word_keys);
+
+            $this->calculateClosure($key,$item,$device_counts,$sums,$word_keys);
             return $item;
             return $item;
         })->all();
         })->all();
         $return_item_list = [];
         $return_item_list = [];
@@ -717,19 +715,23 @@ class StatisticService extends StatisticCommonService
         })->map(function ($group) {
         })->map(function ($group) {
             return $group->count();
             return $group->count();
         })->toArray();
         })->toArray();
-        $month_employee_list = $collect->transform(function ($item) use (&$employee_count,&$salary_map) {
+        $sums = [
+            "salary_map" => $salary_map
+        ];
+        $word_keys = [
+            "salary_map" => [
+                "key" => "allocated_salary",
+                "value" => "allocated_salary",
+                "type" => "money",
+            ]
+        ];
+        $employee_count = [
+            'salary_map' => $employee_count
+        ];
+        $month_employee_list = $collect->transform(function ($item) use (&$employee_count,&$sums,$word_keys) {
             // 如果不是最后一条
             // 如果不是最后一条
             $key = $item['employee_id'] . '_' . $item['month'];
             $key = $item['employee_id'] . '_' . $item['month'];
-            $sums = [
-                "salary_map" => $salary_map
-            ];
-            $word_keys = [
-                "salary_map" => [
-                    "key" => "allocated_salary",
-                    "value" => "allocated_salary",
-                    "type" => "money",
-                ]
-            ];
+
             $this->calculateClosure($key,$item,$employee_count,$sums,$word_keys);
             $this->calculateClosure($key,$item,$employee_count,$sums,$word_keys);
             return $item;
             return $item;
         })->all();
         })->all();
@@ -762,20 +764,23 @@ class StatisticService extends StatisticCommonService
         })->map(function ($group) {
         })->map(function ($group) {
             return $group->count();
             return $group->count();
         })->toArray();
         })->toArray();
-
-        $month_employee_list = $collect->transform(function ($item) use (&$device_count,&$depreciation_map) {
+        $sums = [
+            "salary_map" => $depreciation_map
+        ];
+        $word_keys = [
+            "salary_map" => [
+                "key" => "allocated_depreciation",
+                "value" => "depreciation",
+                "type" => "money",
+            ]
+        ];
+        $device_count = [
+            'salary_map' => $device_count
+        ];
+        $month_employee_list = $collect->transform(function ($item) use (&$device_count,&$sums,$word_keys) {
 
 
             $key = $item['device_id'] . '_' . $item['month'];
             $key = $item['device_id'] . '_' . $item['month'];
-            $sums = [
-                "salary_map" => $depreciation_map
-            ];
-            $word_keys = [
-                "salary_map" => [
-                    "key" => "allocated_depreciation",
-                    "value" => "depreciation",
-                    "type" => "money",
-                ]
-            ];
+
             $this->calculateClosure($key,$item,$device_count,$sums,$word_keys);
             $this->calculateClosure($key,$item,$device_count,$sums,$word_keys);
             return $item;
             return $item;
         })->all();
         })->all();
@@ -858,7 +863,7 @@ class StatisticService extends StatisticCommonService
             $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 = round($item['total_work'] / $total_min, 4);
+                $ratio = round((round($item['total_work']/60,2) / round($total_min/60,2)), 4);
             } else {
             } else {
                 $ratio = 0;
                 $ratio = 0;
             }
             }